Changeset 5547
- Timestamp:
- 06/01/08 17:38:50 (3 months ago)
- Files:
-
- libwired/trunk/configure (modified) (3 diffs)
- libwired/trunk/configure.in (modified) (2 diffs)
- libwired/trunk/libwired/base/wi-private.h (modified) (1 diff)
- libwired/trunk/libwired/collections/wi-array.c (modified) (4 diffs)
- libwired/trunk/libwired/collections/wi-array.h (modified) (3 diffs)
- libwired/trunk/libwired/collections/wi-hash.c (modified) (5 diffs)
- libwired/trunk/libwired/collections/wi-hash.h (modified) (3 diffs)
- libwired/trunk/libwired/crypto/wi-digest.c (modified) (3 diffs)
- libwired/trunk/libwired/data/wi-data.c (modified) (1 diff)
- libwired/trunk/libwired/data/wi-date.c (modified) (3 diffs)
- libwired/trunk/libwired/data/wi-number.c (modified) (1 diff)
- libwired/trunk/libwired/data/wi-number.h (modified) (1 diff)
- libwired/trunk/libwired/data/wi-plist.c (added)
- libwired/trunk/libwired/data/wi-plist.h (added)
- libwired/trunk/libwired/data/wi-string.c (modified) (3 diffs)
- libwired/trunk/libwired/data/wi-string.h (modified) (1 diff)
- libwired/trunk/libwired/misc/wi-error.c (modified) (3 diffs)
- libwired/trunk/libwired/misc/wi-error.h (modified) (1 diff)
- libwired/trunk/libwired/misc/wi-xml.c (added)
- libwired/trunk/libwired/misc/wi-xml.h (added)
- libwired/trunk/libwired/p7/wi-p7-message.c (modified) (13 diffs)
- libwired/trunk/libwired/p7/wi-p7-private.c (modified) (1 diff)
- libwired/trunk/libwired/p7/wi-p7-private.h (modified) (1 diff)
- libwired/trunk/libwired/p7/wi-p7-socket.c (modified) (31 diffs)
- libwired/trunk/libwired/p7/wi-p7-spec.c (modified) (78 diffs)
- libwired/trunk/libwired/wired.h (modified) (2 diffs)
- libwired/trunk/test/fixture/wi-plist-tests-1.plist (added)
- libwired/trunk/test/test.c (modified) (1 diff)
- libwired/trunk/test/tests/wi-crypto-tests.c (modified) (4 diffs)
- libwired/trunk/test/tests/wi-plist-test.c (added)
- libwired/trunk/test/tests/wi-string-tests.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/configure
r5446 r5547 1270 1270 --enable-ssl enable OpenSSL support 1271 1271 --enable-iconv enable iconv support 1272 --enable-libxml2 enable libxml2 support 1272 1273 --enable-p7 enable P7 support 1273 1274 … … 3698 3699 3699 3700 3701 # Check for libxml2 support 3702 # Check whether --enable-libxml2 was given. 3703 if test "${enable_libxml2+set}" = set; then 3704 enableval=$enable_libxml2; 3705 fi 3706 3707 3708 if test -n "$enable_libxml2"; then 3709 CPPFLAGS="$CPPFLAGS -DWI_LIBXML2" 3710 fi 3711 3712 3700 3713 # Check for P7 support 3701 3714 # Check whether --enable-p7 was given. … … 7024 7037 fi 7025 7038 7039 7040 7041 fi 7042 7043 if test -n "$enable_libxml2"; then 7044 7045 if test -d /usr/include/libxml2; then 7046 CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2" 7047 fi 7048 7049 if test -d /usr/local/include/libxml2; then 7050 CPPFLAGS="$CPPFLAGS -I/usr/local/include/libxml2" 7051 fi 7052 7053 7054 for ac_header in libxml/parser.h 7055 do 7056 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 7057 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 7058 { echo "$as_me:$LINENO: checking for $ac_header" >&5 7059 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 7060 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 7061 echo $ECHO_N "(cached) $ECHO_C" >&6 7062 fi 7063 ac_res=`eval echo '${'$as_ac_Header'}'` 7064 { echo "$as_me:$LINENO: result: $ac_res" >&5 7065 echo "${ECHO_T}$ac_res" >&6; } 7066 else 7067 # Is the header compilable? 7068 { echo "$as_me:$LINENO: checking $ac_header usability" >&5 7069 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } 7070 cat >conftest.$ac_ext <<_ACEOF 7071 /* confdefs.h. */ 7072 _ACEOF 7073 cat confdefs.h >>conftest.$ac_ext 7074 cat >>conftest.$ac_ext <<_ACEOF 7075 /* end confdefs.h. */ 7076 $ac_includes_default 7077 #include <$ac_header> 7078 _ACEOF 7079 rm -f conftest.$ac_objext 7080 if { (ac_try="$ac_compile" 7081 case "(($ac_try" in 7082 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 7083 *) ac_try_echo=$ac_try;; 7084 esac 7085 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 7086 (eval "$ac_compile") 2>conftest.er1 7087 ac_status=$? 7088 grep -v '^ *+' conftest.er1 >conftest.err 7089 rm -f conftest.er1 7090 cat conftest.err >&5 7091 echo "$as_me:$LINENO: \$? = $ac_status" >&5 7092 (exit $ac_status); } && { 7093 test -z "$ac_c_werror_flag" || 7094 test ! -s conftest.err 7095 } && test -s conftest.$ac_objext; then 7096 ac_header_compiler=yes 7097 else 7098 echo "$as_me: failed program was:" >&5 7099 sed 's/^/| /' conftest.$ac_ext >&5 7100 7101 ac_header_compiler=no 7102 fi 7103 7104 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 7105 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 7106 echo "${ECHO_T}$ac_header_compiler" >&6; } 7107 7108 # Is the header present? 7109 { echo "$as_me:$LINENO: checking $ac_header presence" >&5 7110 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } 7111 cat >conftest.$ac_ext <<_ACEOF 7112 /* confdefs.h. */ 7113 _ACEOF 7114 cat confdefs.h >>conftest.$ac_ext 7115 cat >>conftest.$ac_ext <<_ACEOF 7116 /* end confdefs.h. */ 7117 #include <$ac_header> 7118 _ACEOF 7119 if { (ac_try="$ac_cpp conftest.$ac_ext" 7120 case "(($ac_try" in 7121 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 7122 *) ac_try_echo=$ac_try;; 7123 esac 7124 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 7125 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 7126 ac_status=$? 7127 grep -v '^ *+' conftest.er1 >conftest.err 7128 rm -f conftest.er1 7129 cat conftest.err >&5 7130 echo "$as_me:$LINENO: \$? = $ac_status" >&5 7131 (exit $ac_status); } >/dev/null && { 7132 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || 7133 test ! -s conftest.err 7134 }; then 7135 ac_header_preproc=yes 7136 else 7137 echo "$as_me: failed program was:" >&5 7138 sed 's/^/| /' conftest.$ac_ext >&5 7139 7140 ac_header_preproc=no 7141 fi 7142 7143 rm -f conftest.err conftest.$ac_ext 7144 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 7145 echo "${ECHO_T}$ac_header_preproc" >&6; } 7146 7147 # So? What about this header? 7148 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in 7149 yes:no: ) 7150 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 7151 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} 7152 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 7153 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} 7154 ac_header_preproc=yes 7155 ;; 7156 no:yes:* ) 7157 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 7158 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} 7159 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 7160 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} 7161 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 7162 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} 7163 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 7164 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} 7165 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 7166 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} 7167 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 7168 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} 7169 ( cat <<\_ASBOX 7170 ## ------------------------------------- ## 7171 ## Report this to axel@zankasoftware.com ## 7172 ## ------------------------------------- ## 7173 _ASBOX 7174 ) | sed "s/^/$as_me: WARNING: /" >&2 7175 ;; 7176 esac 7177 { echo "$as_me:$LINENO: checking for $ac_header" >&5 7178 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 7179 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 7180 echo $ECHO_N "(cached) $ECHO_C" >&6 7181 else 7182 eval "$as_ac_Header=\$ac_header_preproc" 7183 fi 7184 ac_res=`eval echo '${'$as_ac_Header'}'` 7185 { echo "$as_me:$LINENO: result: $ac_res" >&5 7186 echo "${ECHO_T}$ac_res" >&6; } 7187 7188 fi 7189 if test `eval echo '${'$as_ac_Header'}'` = yes; then 7190 cat >>confdefs.h <<_ACEOF 7191 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 7192 _ACEOF 7193 7194 { echo "$as_me:$LINENO: checking for xmlParseFile in -lxml2" >&5 7195 echo $ECHO_N "checking for xmlParseFile in -lxml2... $ECHO_C" >&6; } 7196 if test "${ac_cv_lib_xml2_xmlParseFile+set}" = set; then 7197 echo $ECHO_N "(cached) $ECHO_C" >&6 7198 else 7199 ac_check_lib_save_LIBS=$LIBS 7200 LIBS="-lxml2 $LIBS" 7201 cat >conftest.$ac_ext <<_ACEOF 7202 /* confdefs.h. */ 7203 _ACEOF 7204 cat confdefs.h >>conftest.$ac_ext 7205 cat >>conftest.$ac_ext <<_ACEOF 7206 /* end confdefs.h. */ 7207 7208 /* Override any GCC internal prototype to avoid an error. 7209 Use char because int might match the return type of a GCC 7210 builtin and then its argument prototype would still apply. */ 7211 #ifdef __cplusplus 7212 extern "C" 7213 #endif 7214 char xmlParseFile (); 7215 int 7216 main () 7217 { 7218 return xmlParseFile (); 7219 ; 7220 return 0; 7221 } 7222 _ACEOF 7223 rm -f conftest.$ac_objext conftest$ac_exeext 7224 if { (ac_try="$ac_link" 7225 case "(($ac_try" in 7226 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 7227 *) ac_try_echo=$ac_try;; 7228 esac 7229 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 7230 (eval "$ac_link") 2>conftest.er1 7231 ac_status=$? 7232 grep -v '^ *+' conftest.er1 >conftest.err 7233 rm -f conftest.er1 7234 cat conftest.err >&5 7235 echo "$as_me:$LINENO: \$? = $ac_status" >&5 7236 (exit $ac_status); } && { 7237 test -z "$ac_c_werror_flag" || 7238 test ! -s conftest.err 7239 } && test -s conftest$ac_exeext && 7240 $as_test_x conftest$ac_exeext; then 7241 ac_cv_lib_xml2_xmlParseFile=yes 7242 else 7243 echo "$as_me: failed program was:" >&5 7244 sed 's/^/| /' conftest.$ac_ext >&5 7245 7246 ac_cv_lib_xml2_xmlParseFile=no 7247 fi 7248 7249 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ 7250 conftest$ac_exeext conftest.$ac_ext 7251 LIBS=$ac_check_lib_save_LIBS 7252 fi 7253 { echo "$as_me:$LINENO: result: $ac_cv_lib_xml2_xmlParseFile" >&5 7254 echo "${ECHO_T}$ac_cv_lib_xml2_xmlParseFile" >&6; } 7255 if test $ac_cv_lib_xml2_xmlParseFile = yes; then 7256 7257 LIBS="$LIBS -lxml2" 7258 7259 else 7260 7261 7262 { { echo "$as_me:$LINENO: error: could not locate libxml2 7263 7264 If you installed libxml2 into a non-standard directory, please run: 7265 7266 env CPPFLAGS=\"-I/path/to/include\" LDFLAGS=\"-L/path/to/lib\" ./configure" >&5 7267 echo "$as_me: error: could not locate libxml2 7268 7269 If you installed libxml2 into a non-standard directory, please run: 7270 7271 env CPPFLAGS=\"-I/path/to/include\" LDFLAGS=\"-L/path/to/lib\" ./configure" >&2;} 7272 { (exit 1); exit 1; }; } 7273 7274 7275 fi 7276 7277 7278 else 7279 7280 7281 { { echo "$as_me:$LINENO: error: could not locate libxml2 7282 7283 If you installed libxml2 into a non-standard directory, please run: 7284 7285 env CPPFLAGS=\"-I/path/to/include\" LDFLAGS=\"-L/path/to/lib\" ./configure" >&5 7286 echo "$as_me: error: could not locate libxml2 7287 7288 If you installed libxml2 into a non-standard directory, please run: 7289 7290 env CPPFLAGS=\"-I/path/to/include\" LDFLAGS=\"-L/path/to/lib\" ./configure" >&2;} 7291 { (exit 1); exit 1; }; } 7292 7293 7294 fi 7295 7296 done 7026 7297 7027 7298 libwired/trunk/configure.in
r5446 r5547 85 85 86 86 87 # Check for libxml2 support 88 AC_ARG_ENABLE([libxml2], AC_HELP_STRING([--enable-libxml2], [enable libxml2 support])) 89 90 if test -n "$enable_libxml2"; then 91 CPPFLAGS="$CPPFLAGS -DWI_LIBXML2" 92 fi 93 94 87 95 # Check for P7 support 88 96 AC_ARG_ENABLE([p7], AC_HELP_STRING([--enable-p7], [enable P7 support])) … … 149 157 if test -n "$enable_iconv"; then 150 158 WI_INCLUDE_ICONV_LIBRARY 159 fi 160 161 if test -n "$enable_libxml2"; then 162 WI_INCLUDE_LIBXML2_LIBRARY 151 163 fi 152 164 libwired/trunk/libwired/base/wi-private.h
r5417 r5547 167 167 WI_EXPORT void wi_error_set_carbon_error(int); 168 168 WI_EXPORT void wi_error_set_libwired_error(int); 169 WI_EXPORT void wi_error_set_libwired_p7_error(int, wi_string_t *, ...); 169 WI_EXPORT void wi_error_set_libwired_error_with_string(int, wi_string_t *); 170 WI_EXPORT void wi_error_set_libwired_error_with_format(int, wi_string_t *, ...); 170 171 171 172 WI_EXPORT void wi_socket_exit_thread(void); libwired/trunk/libwired/collections/wi-array.c
r5283 r5547 40 40 #include <wired/wi-lock.h> 41 41 #include <wired/wi-log.h> 42 #include <wired/wi-plist.h> 42 43 #include <wired/wi-private.h> 43 44 #include <wired/wi-runtime.h> … … 210 211 return wi_autorelease(array); 211 212 } 213 214 215 216 #ifdef WI_LIBXML2 217 218 wi_array_t * wi_array_with_plist_file(wi_string_t *path) { 219 return wi_autorelease(wi_array_init_with_plist_file(wi_array_alloc(), path)); 220 } 221 222 #endif 212 223 213 224 … … 387 398 388 399 400 #ifdef WI_LIBXML2 401 402 wi_array_t * wi_array_init_with_plist_file(wi_array_t *array, wi_string_t *path) { 403 wi_runtime_instance_t *instance; 404 405 wi_release(array); 406 407 instance = wi_plist_read_instance_from_file(path); 408 409 if(!instance) 410 return NULL; 411 412 if(wi_runtime_id(instance) != wi_array_runtime_id()) 413 return NULL; 414 415 return wi_retain(instance); 416 } 417 418 #endif 419 420 421 389 422 static void _wi_array_dealloc(wi_runtime_instance_t *instance) { 390 423 wi_array_t *array = instance; … … 1017 1050 _WI_ARRAY_CHECK_OPTIMIZE(array); 1018 1051 } 1052 1053 1054 1055 #pragma mark - 1056 1057 wi_boolean_t wi_array_write_to_file(wi_array_t *array, wi_string_t *path) { 1058 return wi_plist_write_instance_to_file(array, path); 1059 } libwired/trunk/libwired/collections/wi-array.h
r5151 r5547 51 51 WI_EXPORT wi_array_t * wi_array(void); 52 52 WI_EXPORT wi_array_t * wi_array_with_data(void *, ...) WI_SENTINEL; 53 WI_EXPORT wi_array_t * wi_array_with_plist_file(wi_string_t *); 53 54 54 55 WI_EXPORT wi_array_t * wi_array_alloc(void); … … 61 62 WI_EXPORT wi_array_t * wi_array_init_with_string(wi_array_t *, wi_string_t *, wi_string_t *); 62 63 WI_EXPORT wi_array_t * wi_array_init_with_argument_string(wi_array_t *, wi_string_t *, wi_integer_t); 64 WI_EXPORT wi_array_t * wi_array_init_with_plist_file(wi_array_t *, wi_string_t *); 63 65 64 66 WI_EXPORT void wi_array_wrlock(wi_array_t *); … … 99 101 WI_EXPORT void wi_array_remove_all_data(wi_array_t *); 100 102 103 WI_EXPORT wi_boolean_t wi_array_write_to_file(wi_array_t *, wi_string_t *); 104 101 105 102 106 WI_EXPORT const wi_array_callbacks_t wi_array_default_callbacks; libwired/trunk/libwired/collections/wi-hash.c
r5300 r5547 39 39 #include <wired/wi-lock.h> 40 40 #include <wired/wi-macros.h> 41 #include <wired/wi-plist.h> 41 42 #include <wired/wi-private.h> 42 43 #include <wired/wi-runtime.h> … … 243 244 244 245 246 #ifdef WI_LIBXML2 247 248 wi_hash_t * wi_hash_with_plist_file(wi_string_t *path) { 249 return wi_autorelease(wi_hash_init_with_plist_file(wi_hash_alloc(), path)); 250 } 251 252 #endif 253 254 255 245 256 #pragma mark - 246 257 … … 296 307 297 308 309 #ifdef WI_LIBXML2 310 311 wi_hash_t * wi_hash_init_with_plist_file(wi_hash_t *hash, wi_string_t *path) { 312 wi_runtime_instance_t *instance; 313 314 wi_release(hash); 315 316 instance = wi_plist_read_instance_from_file(path); 317 318 if(!instance) 319 return NULL; 320 321 if(wi_runtime_id(instance) != wi_hash_runtime_id()) 322 return NULL; 323 324 return wi_retain(instance); 325 } 326 327 #endif 328 329 330 298 331 static wi_runtime_instance_t * _wi_hash_copy(wi_runtime_instance_t *instance) { 299 332 wi_hash_t *hash = instance, *hash_copy; … … 347 380 for(i = 0; i < hash1->buckets_count; i++) { 348 381 for(bucket = hash1->buckets[i]; bucket; bucket = bucket->next) { 349 if(!_WI_HASH_VALUE_IS_EQUAL(hash1, bucket->data, wi_hash_data_for_key(hash2, bucket->key))) 382 if(!_WI_HASH_VALUE_IS_EQUAL(hash1, bucket->data, wi_hash_data_for_key(hash2, bucket->key))) { 383 wi_log_info(WI_STR("%@ %@ != %@"), bucket->key, bucket->data, wi_hash_data_for_key(hash2, bucket->key)); 350 384 return false; 385 } 351 386 } 352 387 } … … 821 856 _WI_HASH_CHECK_RESIZE(hash); 822 857 } 858 859 860 861 #pragma mark - 862 863 wi_boolean_t wi_hash_write_to_file(wi_hash_t *hash, wi_string_t *path) { 864 return wi_plist_write_instance_to_file(hash, path); 865 } libwired/trunk/libwired/collections/wi-hash.h
r5300 r5547 57 57 58 58 WI_EXPORT wi_hash_t * wi_hash_with_data_and_keys(void *, void *, ...) WI_SENTINEL; 59 WI_EXPORT wi_hash_t * wi_hash_with_plist_file(wi_string_t *); 59 60 60 61 WI_EXPORT wi_hash_t * wi_hash_alloc(void); … … 63 64 WI_EXPORT wi_hash_t * wi_hash_init_with_capacity_and_callbacks(wi_hash_t *, wi_uinteger_t, wi_hash_key_callbacks_t, wi_hash_value_callbacks_t); 64 65 WI_EXPORT wi_hash_t * wi_hash_init_with_data_and_keys(wi_hash_t *, ...) WI_SENTINEL; 66 WI_EXPORT wi_hash_t * wi_hash_init_with_plist_file(wi_hash_t *, wi_string_t *); 65 67 66 68 WI_EXPORT void wi_hash_wrlock(wi_hash_t *); … … 85 87 WI_EXPORT void wi_hash_remove_all_data(wi_hash_t *); 86 88 89 WI_EXPORT wi_boolean_t wi_hash_write_to_file(wi_hash_t *, wi_string_t *); 90 87 91 88 92 WI_EXPORT const wi_hash_key_callbacks_t wi_hash_default_key_callbacks; libwired/trunk/libwired/crypto/wi-digest.c
r5529 r5547 29 29 #include "config.h" 30 30 31 #ifdef WI_CRYPTO32 33 31 #include <wired/wi-data.h> 34 32 #include <wired/wi-digest.h> … … 37 35 #include <wired/wi-system.h> 38 36 37 #ifdef WI_CRYPTO 39 38 #include <openssl/md5.h> 40 39 #include <openssl/sha.h> 40 #endif 41 42 #ifdef WI_CRYPTO 41 43 42 44 wi_string_t * wi_digest_md5_string(wi_data_t *data) { … … 206 208 } 207 209 208 return data;209 } 210 return wi_autorelease(data); 211 } libwired/trunk/libwired/data/wi-data.c
r5529 r5547 115 115 116 116 117 #ifdef WI_CRYPTO 118 117 119 wi_data_t * wi_data_with_random_bytes(wi_uinteger_t length) { 118 120 return wi_autorelease(wi_data_init_with_random_bytes(wi_data_alloc(), length)); 119 121 } 122 123 #endif 120 124 121 125 libwired/trunk/libwired/data/wi-date.c
r5411 r5547 40 40 #include <wired/wi-string.h> 41 41 42 #define _WI_DATE_ISO8601_STRING_SIZE 2543 42 #define _WI_DATE_EPSILON 0.001 44 43 … … 252 251 253 252 wi_date_t * wi_date_init_with_iso8601_string(wi_date_t *date, wi_string_t *string) { 254 wi_string_t * substring;253 wi_string_t *timezone, *datetime; 255 254 256 255 wi_release(date); 257 256 258 if(wi_string_length(string) < _WI_DATE_ISO8601_STRING_SIZE)257 if(wi_string_length(string) < 19) 259 258 return NULL; 260 259 261 substring = wi_string_by_deleting_characters_in_range(string, wi_make_range(22, 1)); 262 date = wi_date_init_with_string(wi_date_alloc(), substring, WI_STR("%Y-%m-%dT%H:%M:%S%z")); 263 264 if(date) 265 return date; 266 267 substring = wi_string_by_deleting_characters_in_range(string, wi_make_range(19, 6)); 268 date = wi_date_init_with_string(wi_date_alloc(), substring, WI_STR("%Y-%m-%dT%H:%M:%S")); 269 270 return date; 260 datetime = wi_string_substring_to_index(string, 19); 261 timezone = wi_string_substring_from_index(string, 19); 262 263 if(wi_is_equal(timezone, WI_STR("Z"))) { 264 date = wi_date_init_with_string(wi_date_alloc(), datetime, WI_STR("%Y-%m-%dT%H:%M:%S")); 265 266 if(date) 267 return date; 268 } 269 else if(wi_string_length(timezone) == 6) { 270 timezone = wi_string_by_deleting_characters_in_range(timezone, wi_make_range(3, 1)); 271 date = wi_date_init_with_string(wi_date_alloc(), wi_string_by_appending_string(datetime, timezone), WI_STR("%Y-%m-%dT%H:%M:%S%z")); 272 273 if(date) 274 return date; 275 } 276 277 return NULL; 271 278 } 272 279 … … 285 292 wi_date_t *date2 = instance2; 286 293 287 return (WI_MAX(date1 , date2) - WI_MIN(date1, date2) < _WI_DATE_EPSILON);294 return (WI_MAX(date1->interval, date2->interval) - WI_MIN(date1->interval, date2->interval) < _WI_DATE_EPSILON); 288 295 } 289 296 libwired/trunk/libwired/data/wi-number.c
r5331 r5547 414 414 return value; 415 415 } 416 417 418 419 #pragma mark - 420 421 wi_string_t * wi_number_string(wi_number_t *number) { 422 if(_wi_number_is_float(number)) 423 return wi_string_with_format(WI_STR("%f"), wi_number_double(number)); 424 else 425 return wi_string_with_format(WI_STR("%lld"), wi_number_int64(number)); 426 } libwired/trunk/libwired/data/wi-number.h
r5331 r5547 95 95 WI_EXPORT double wi_number_double(wi_number_t *); 96 96 97 WI_EXPORT wi_string_t * wi_number_string(wi_number_t *); 98 97 99 #endif /* WI_NUMBER_H */ libwired/trunk/libwired/data/wi-string.c
r5529 r5547 223 223 224 224 return wi_autorelease(string); 225 } 226 227 228 229 wi_string_t * wi_string_with_format_and_arguments(wi_string_t *fmt, va_list ap) { 230 return wi_autorelease(wi_string_init_with_format_and_arguments(wi_string_alloc(), fmt, ap)); 225 231 } 226 232 … … 1660 1666 1661 1667 1668 #ifdef WI_CRYPTO 1669 1662 1670 wi_string_t * wi_string_md5(wi_string_t *string) { 1663 1671 return wi_digest_md5_string(wi_string_data(string)); … … 1669 1677 return wi_digest_sha1_string(wi_string_data(string)); 1670 1678 } 1679 1680 #endif 1671 1681 1672 1682 libwired/trunk/libwired/data/wi-string.h
r5324 r5547 57 57 WI_EXPORT wi_string_t * wi_string_with_cstring_no_copy(char *, wi_boolean_t); 58 58 WI_EXPORT wi_string_t * wi_string_with_format(wi_string_t *, ...); 59 WI_EXPORT wi_string_t * wi_string_with_format_and_arguments(wi_string_t *, va_list); 59 60 WI_EXPORT wi_string_t * wi_string_with_data(wi_data_t *); 60 61 WI_EXPORT wi_string_t * wi_string_with_bytes(const void *, wi_uinteger_t); libwired/trunk/libwired/misc/wi-error.c
r5433 r5547 113 113 /* WI_ERROR_P7_MESSAGETOOLARGE */ 114 114 "Message too large", 115 116 /* WI_ERROR_PLIST_READFAILED */ 117 "Property list read failed", 118 /* WI_ERROR_PLIST_WRITEFAILED */ 119 "Property list write failed", 115 120 116 121 /* WI_ERROR_REGEXP_NOSLASH */ … … 340 345 341 346 342 void wi_error_set_libwired_p7_error(int code, wi_string_t *fmt, ...) { 343 wi_error_t *error; 344 va_list ap; 347 void wi_error_set_libwired_error_with_string(int code, wi_string_t *string) { 348 wi_error_t *error; 345 349 346 350 error = _wi_get_error(); … … 352 356 error->string = wi_string_init_with_cstring(wi_string_alloc(), _wi_error_strings[error->code]); 353 357 354 if(wi_string_length(fmt) > 0) { 355 wi_string_append_string(error->string, WI_STR(": ")); 356 357 va_start(ap, fmt); 358 wi_string_append_format_and_arguments(error->string, fmt, ap); 359 va_end(ap); 360 } 358 if(wi_string_length(string) > 0) 359 wi_string_append_format(error->string, WI_STR(": %@"), string); 360 } 361 362 363 364 void wi_error_set_libwired_error_with_format(int code, wi_string_t *fmt, ...) { 365 wi_string_t *string; 366 va_list ap; 367 368 va_start(ap, fmt); 369 string = wi_string_with_format_and_arguments(fmt, ap); 370 va_end(ap); 371 372 wi_error_set_libwired_error_with_string(code, string); 361 373 } 362 374 libwired/trunk/libwired/misc/wi-error.h
r5369 r5547 72 72 WI_ERROR_P7_MESSAGETOOLARGE, 73 73 74 WI_ERROR_PLIST_READFAILED, 75 WI_ERROR_PLIST_WRITEFAILED, 76 74 77 WI_ERROR_REGEXP_NOSLASH, 75 78 WI_ERROR_REGEXP_INVALIDOPTION, libwired/trunk/libwired/p7/wi-p7-message.c
r5538 r5547 44 44 #include <wired/wi-string.h> 45 45 #include <wired/wi-system.h> 46 #include <wired/wi-xml.h> 46 47 47 48 #include <libxml/tree.h> … … 258 259 for(node = p7_message->xml_root_node->children; node != NULL; node = node->next) { 259 260 if(node->type == XML_ELEMENT_NODE) { 260 field_name = wi_ autorelease(wi_p7_xml_copy_string_for_attribute(node, WI_STR("name")));261 field_name = wi_xml_node_attribute_with_name(node, WI_STR("name")); 261 262 field = wi_p7_spec_field_with_name(p7_message->spec, field_name); 262 263 field_value = _wi_p7_message_field_string_value(p7_message, field); … … 587 588 588 589 if(!field) { 589 wi_error_set_libwired_ p7_error(WI_ERROR_P7_UNKNOWNFIELD,590 wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNFIELD, 590 591 WI_STR("No id found for field \"%@\""), field_name); 591 592 … … 643 644 644 645 if(!field) { 645 wi_error_set_libwired_ p7_error(WI_ERROR_P7_UNKNOWNFIELD,646 wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNFIELD, 646 647 WI_STR("No id found for field \"%@\""), field_name); 647 648 … … 944 945 945 946 if(p7_message->xml_root_node) 946 p7_message->name = wi_ p7_xml_copy_string_for_attribute(p7_message->xml_root_node, WI_STR("name"));947 p7_message->name = wi_retain(wi_xml_node_attribute_with_name(p7_message->xml_root_node, WI_STR("name"))); 947 948 } 948 949 } … … 960 961 961 962 if(!message) { 962 wi_error_set_libwired_ p7_error(WI_ERROR_P7_UNKNOWNMESSAGE,963 wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNMESSAGE, 963 964 WI_STR("No id found for message \"%@\""), name); 964 965 … … 1035 1036 for(node = p7_message->xml_root_node->children; node != NULL; node = node->next) { 1036 1037 if(node->type == XML_ELEMENT_NODE) { 1037 field_name = wi_ autorelease(wi_p7_xml_copy_string_for_attribute(node, WI_STR("name")));1038 field_name = wi_xml_node_attribute_with_name(node, WI_STR("name")); 1038 1039 field = wi_p7_spec_field_with_name(p7_message->spec, field_name); 1039 1040 field_value = _wi_p7_message_field_string_value(p7_message, field); … … 1563 1564 1564 1565 if(!field) { 1565 wi_error_set_libwired_ p7_error(WI_ERROR_P7_UNKNOWNFIELD,1566 wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNFIELD, 1566 1567 WI_STR("No id found for field \"%@\""), field_name); 1567 1568 … … 1575 1576 1576 1577 if(!wi_hash_contains_key(enums, enum_name)) { 1577 wi_error_set_libwired_ p7_error(WI_ERROR_P7_UNKNOWNFIELD,1578 wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNFIELD, 1578 1579 WI_STR("No value found for enum \"%@\""), enum_name); 1579 1580 … … 1603 1604 1604 1605 if(!wi_hash_contains_key(enums, (void *) enum_value)) { 1605 wi_error_set_libwired_ p7_error(WI_ERROR_P7_UNKNOWNFIELD,1606 wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNFIELD, 1606 1607 WI_STR("No name found for enum \"%u\""), enum_value); 1607 1608 … … 1727 1728 field_size += 4 + wi_string_length(instance) + 1; 1728 1729 } else { 1729 wi_error_set_libwired_ p7_error(WI_ERROR_P7_UNKNOWNFIELD,1730 wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNFIELD, 1730 1731 WI_STR("Unhandled type %@ in list"), wi_runtime_class_name(instance)); 1731 1732 … … 1777 1778 1778 1779 if(!field) { 1779 wi_error_set_libwired_ p7_error(WI_ERROR_P7_UNKNOWNFIELD,1780 wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNFIELD, 1780 1781 WI_STR("No id found for field \"%@\""), field_name); 1781 1782 … … 1790 1791 1791 1792 if(listtype_id != WI_P7_STRING) { 1792 wi_error_set_libwired_ p7_error(WI_ERROR_P7_UNKNOWNFIELD,1793 wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNFIELD, 1793 1794 WI_STR("Unhandled type %@ in list"), wi_p7_spec_type_name(listtype)); 1794 1795 libwired/trunk/libwired/p7/wi-p7-private.c
r5261 r5547 29 29 #include "config.h" 30 30 31 #ifndef WI_P732 33 31 int wi_p7_private_dummy = 0; 34 35 #else36 37 #include <wired/wi-string.h>38 #include <wired/wi-p7-private.h>39 40 #include <libxml/tree.h>41 42 wi_string_t * wi_p7_xml_copy_string_for_attribute(xmlNodePtr node, wi_string_t *attribute) {43 xmlChar *prop;44 wi_string_t *string;45 46 prop = xmlGetProp(node, (xmlChar *) wi_string_cstring(attribute));47 48 if(!prop)49 return NULL;50 51 string = wi_string_init_with_cstring(wi_string_alloc(), (const char *) prop);52 53 xmlFree(prop);54 55 return string;56 }57 58 59 60 wi_integer_t wi_p7_xml_integer_for_attribute(xmlNodePtr node, wi_string_t *attribute) {61 wi_string_t *string;62 wi_uinteger_t value;63 64 string = wi_p7_xml_copy_string_for_attribute(node, attribute);65 66 if(!string)67 return 0;68 &nb
