Changeset 5547

Show
Ignore:
Timestamp:
06/01/08 17:38:50 (3 months ago)
Author:
morris
Message:

Add support for serializing/deserializing arrays and dictionaries in Apple's plist format, available when libxml2 is configured

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libwired/trunk/configure

    r5446 r5547  
    12701270  --enable-ssl            enable OpenSSL support 
    12711271  --enable-iconv          enable iconv support 
     1272  --enable-libxml2        enable libxml2 support 
    12721273  --enable-p7             enable P7 support 
    12731274 
     
    36983699 
    36993700 
     3701# Check for libxml2 support 
     3702# Check whether --enable-libxml2 was given. 
     3703if test "${enable_libxml2+set}" = set; then 
     3704  enableval=$enable_libxml2; 
     3705fi 
     3706 
     3707 
     3708if test -n "$enable_libxml2"; then 
     3709        CPPFLAGS="$CPPFLAGS -DWI_LIBXML2" 
     3710fi 
     3711 
     3712 
    37003713# Check for P7 support 
    37013714# Check whether --enable-p7 was given. 
     
    70247037fi 
    70257038 
     7039 
     7040 
     7041fi 
     7042 
     7043if 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 
     7054for ac_header in libxml/parser.h 
     7055do 
     7056as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 
     7057if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 
     7058  { echo "$as_me:$LINENO: checking for $ac_header" >&5 
     7059echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 
     7060if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 
     7061  echo $ECHO_N "(cached) $ECHO_C" >&6 
     7062fi 
     7063ac_res=`eval echo '${'$as_ac_Header'}'` 
     7064               { echo "$as_me:$LINENO: result: $ac_res" >&5 
     7065echo "${ECHO_T}$ac_res" >&6; } 
     7066else 
     7067  # Is the header compilable? 
     7068{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 
     7069echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } 
     7070cat >conftest.$ac_ext <<_ACEOF 
     7071/* confdefs.h.  */ 
     7072_ACEOF 
     7073cat confdefs.h >>conftest.$ac_ext 
     7074cat >>conftest.$ac_ext <<_ACEOF 
     7075/* end confdefs.h.  */ 
     7076$ac_includes_default 
     7077#include <$ac_header> 
     7078_ACEOF 
     7079rm -f conftest.$ac_objext 
     7080if { (ac_try="$ac_compile" 
     7081case "(($ac_try" in 
     7082  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
     7083  *) ac_try_echo=$ac_try;; 
     7084esac 
     7085eval "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 
     7097else 
     7098  echo "$as_me: failed program was:" >&5 
     7099sed 's/^/| /' conftest.$ac_ext >&5 
     7100 
     7101        ac_header_compiler=no 
     7102fi 
     7103 
     7104rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext 
     7105{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 
     7106echo "${ECHO_T}$ac_header_compiler" >&6; } 
     7107 
     7108# Is the header present? 
     7109{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 
     7110echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } 
     7111cat >conftest.$ac_ext <<_ACEOF 
     7112/* confdefs.h.  */ 
     7113_ACEOF 
     7114cat confdefs.h >>conftest.$ac_ext 
     7115cat >>conftest.$ac_ext <<_ACEOF 
     7116/* end confdefs.h.  */ 
     7117#include <$ac_header> 
     7118_ACEOF 
     7119if { (ac_try="$ac_cpp conftest.$ac_ext" 
     7120case "(($ac_try" in 
     7121  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
     7122  *) ac_try_echo=$ac_try;; 
     7123esac 
     7124eval "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 
     7136else 
     7137  echo "$as_me: failed program was:" >&5 
     7138sed 's/^/| /' conftest.$ac_ext >&5 
     7139 
     7140  ac_header_preproc=no 
     7141fi 
     7142 
     7143rm -f conftest.err conftest.$ac_ext 
     7144{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 
     7145echo "${ECHO_T}$ac_header_preproc" >&6; } 
     7146 
     7147# So?  What about this header? 
     7148case $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 
     7151echo "$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 
     7153echo "$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 
     7158echo "$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 
     7160echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;} 
     7161    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 
     7162echo "$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 
     7164echo "$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 
     7166echo "$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 
     7168echo "$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    ;; 
     7176esac 
     7177{ echo "$as_me:$LINENO: checking for $ac_header" >&5 
     7178echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } 
     7179if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then 
     7180  echo $ECHO_N "(cached) $ECHO_C" >&6 
     7181else 
     7182  eval "$as_ac_Header=\$ac_header_preproc" 
     7183fi 
     7184ac_res=`eval echo '${'$as_ac_Header'}'` 
     7185               { echo "$as_me:$LINENO: result: $ac_res" >&5 
     7186echo "${ECHO_T}$ac_res" >&6; } 
     7187 
     7188fi 
     7189if 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 
     7195echo $ECHO_N "checking for xmlParseFile in -lxml2... $ECHO_C" >&6; } 
     7196if test "${ac_cv_lib_xml2_xmlParseFile+set}" = set; then 
     7197  echo $ECHO_N "(cached) $ECHO_C" >&6 
     7198else 
     7199  ac_check_lib_save_LIBS=$LIBS 
     7200LIBS="-lxml2  $LIBS" 
     7201cat >conftest.$ac_ext <<_ACEOF 
     7202/* confdefs.h.  */ 
     7203_ACEOF 
     7204cat confdefs.h >>conftest.$ac_ext 
     7205cat >>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 
     7212extern "C" 
     7213#endif 
     7214char xmlParseFile (); 
     7215int 
     7216main () 
     7217{ 
     7218return xmlParseFile (); 
     7219  ; 
     7220  return 0; 
     7221} 
     7222_ACEOF 
     7223rm -f conftest.$ac_objext conftest$ac_exeext 
     7224if { (ac_try="$ac_link" 
     7225case "(($ac_try" in 
     7226  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 
     7227  *) ac_try_echo=$ac_try;; 
     7228esac 
     7229eval "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 
     7242else 
     7243  echo "$as_me: failed program was:" >&5 
     7244sed 's/^/| /' conftest.$ac_ext >&5 
     7245 
     7246        ac_cv_lib_xml2_xmlParseFile=no 
     7247fi 
     7248 
     7249rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ 
     7250      conftest$ac_exeext conftest.$ac_ext 
     7251LIBS=$ac_check_lib_save_LIBS 
     7252fi 
     7253{ echo "$as_me:$LINENO: result: $ac_cv_lib_xml2_xmlParseFile" >&5 
     7254echo "${ECHO_T}$ac_cv_lib_xml2_xmlParseFile" >&6; } 
     7255if test $ac_cv_lib_xml2_xmlParseFile = yes; then 
     7256 
     7257                        LIBS="$LIBS -lxml2" 
     7258 
     7259else 
     7260 
     7261 
     7262        { { echo "$as_me:$LINENO: error: could not locate libxml2 
     7263 
     7264If 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 
     7267echo "$as_me: error: could not locate libxml2 
     7268 
     7269If 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 
     7275fi 
     7276 
     7277 
     7278else 
     7279 
     7280 
     7281        { { echo "$as_me:$LINENO: error: could not locate libxml2 
     7282 
     7283If 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 
     7286echo "$as_me: error: could not locate libxml2 
     7287 
     7288If 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 
     7294fi 
     7295 
     7296done 
    70267297 
    70277298 
  • libwired/trunk/configure.in

    r5446 r5547  
    8585 
    8686 
     87# Check for libxml2 support 
     88AC_ARG_ENABLE([libxml2], AC_HELP_STRING([--enable-libxml2], [enable libxml2 support])) 
     89 
     90if test -n "$enable_libxml2"; then 
     91        CPPFLAGS="$CPPFLAGS -DWI_LIBXML2" 
     92fi 
     93 
     94 
    8795# Check for P7 support 
    8896AC_ARG_ENABLE([p7], AC_HELP_STRING([--enable-p7], [enable P7 support])) 
     
    149157if test -n "$enable_iconv"; then 
    150158        WI_INCLUDE_ICONV_LIBRARY 
     159fi 
     160 
     161if test -n "$enable_libxml2"; then 
     162        WI_INCLUDE_LIBXML2_LIBRARY 
    151163fi 
    152164 
  • libwired/trunk/libwired/base/wi-private.h

    r5417 r5547  
    167167WI_EXPORT void                                                  wi_error_set_carbon_error(int); 
    168168WI_EXPORT void                                                  wi_error_set_libwired_error(int); 
    169 WI_EXPORT void                                                  wi_error_set_libwired_p7_error(int, wi_string_t *, ...); 
     169WI_EXPORT void                                                  wi_error_set_libwired_error_with_string(int, wi_string_t *); 
     170WI_EXPORT void                                                  wi_error_set_libwired_error_with_format(int, wi_string_t *, ...); 
    170171 
    171172WI_EXPORT void                                                  wi_socket_exit_thread(void); 
  • libwired/trunk/libwired/collections/wi-array.c

    r5283 r5547  
    4040#include <wired/wi-lock.h> 
    4141#include <wired/wi-log.h> 
     42#include <wired/wi-plist.h> 
    4243#include <wired/wi-private.h> 
    4344#include <wired/wi-runtime.h> 
     
    210211        return wi_autorelease(array); 
    211212} 
     213 
     214 
     215 
     216#ifdef WI_LIBXML2 
     217 
     218wi_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 
    212223 
    213224 
     
    387398 
    388399 
     400#ifdef WI_LIBXML2 
     401 
     402wi_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 
    389422static void _wi_array_dealloc(wi_runtime_instance_t *instance) { 
    390423        wi_array_t              *array = instance; 
     
    10171050        _WI_ARRAY_CHECK_OPTIMIZE(array); 
    10181051} 
     1052 
     1053 
     1054 
     1055#pragma mark - 
     1056 
     1057wi_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  
    5151WI_EXPORT wi_array_t *                                  wi_array(void); 
    5252WI_EXPORT wi_array_t *                                  wi_array_with_data(void *, ...) WI_SENTINEL; 
     53WI_EXPORT wi_array_t *                                  wi_array_with_plist_file(wi_string_t *); 
    5354 
    5455WI_EXPORT wi_array_t *                                  wi_array_alloc(void); 
     
    6162WI_EXPORT wi_array_t *                                  wi_array_init_with_string(wi_array_t *, wi_string_t *, wi_string_t *); 
    6263WI_EXPORT wi_array_t *                                  wi_array_init_with_argument_string(wi_array_t *, wi_string_t *, wi_integer_t); 
     64WI_EXPORT wi_array_t *                                  wi_array_init_with_plist_file(wi_array_t *, wi_string_t *); 
    6365 
    6466WI_EXPORT void                                                  wi_array_wrlock(wi_array_t *); 
     
    99101WI_EXPORT void                                                  wi_array_remove_all_data(wi_array_t *); 
    100102 
     103WI_EXPORT wi_boolean_t                                  wi_array_write_to_file(wi_array_t *, wi_string_t *); 
     104 
    101105 
    102106WI_EXPORT const wi_array_callbacks_t    wi_array_default_callbacks; 
  • libwired/trunk/libwired/collections/wi-hash.c

    r5300 r5547  
    3939#include <wired/wi-lock.h> 
    4040#include <wired/wi-macros.h> 
     41#include <wired/wi-plist.h> 
    4142#include <wired/wi-private.h> 
    4243#include <wired/wi-runtime.h> 
     
    243244 
    244245 
     246#ifdef WI_LIBXML2 
     247 
     248wi_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 
    245256#pragma mark - 
    246257 
     
    296307 
    297308 
     309#ifdef WI_LIBXML2 
     310 
     311wi_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 
    298331static wi_runtime_instance_t * _wi_hash_copy(wi_runtime_instance_t *instance) { 
    299332        wi_hash_t                       *hash = instance, *hash_copy; 
     
    347380        for(i = 0; i < hash1->buckets_count; i++) { 
    348381                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)); 
    350384                                return false; 
     385                        } 
    351386                } 
    352387        } 
     
    821856        _WI_HASH_CHECK_RESIZE(hash); 
    822857} 
     858 
     859 
     860 
     861#pragma mark - 
     862 
     863wi_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  
    5757 
    5858WI_EXPORT wi_hash_t *                                           wi_hash_with_data_and_keys(void *, void *, ...) WI_SENTINEL; 
     59WI_EXPORT wi_hash_t *                                           wi_hash_with_plist_file(wi_string_t *); 
    5960 
    6061WI_EXPORT wi_hash_t *                                           wi_hash_alloc(void); 
     
    6364WI_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); 
    6465WI_EXPORT wi_hash_t *                                           wi_hash_init_with_data_and_keys(wi_hash_t *, ...) WI_SENTINEL; 
     66WI_EXPORT wi_hash_t *                                           wi_hash_init_with_plist_file(wi_hash_t *, wi_string_t *); 
    6567 
    6668WI_EXPORT void                                                          wi_hash_wrlock(wi_hash_t *); 
     
    8587WI_EXPORT void                                                          wi_hash_remove_all_data(wi_hash_t *); 
    8688 
     89WI_EXPORT wi_boolean_t                                          wi_hash_write_to_file(wi_hash_t *, wi_string_t *); 
     90 
    8791 
    8892WI_EXPORT const wi_hash_key_callbacks_t         wi_hash_default_key_callbacks; 
  • libwired/trunk/libwired/crypto/wi-digest.c

    r5529 r5547  
    2929#include "config.h" 
    3030 
    31 #ifdef WI_CRYPTO 
    32  
    3331#include <wired/wi-data.h> 
    3432#include <wired/wi-digest.h> 
     
    3735#include <wired/wi-system.h> 
    3836 
     37#ifdef WI_CRYPTO 
    3938#include <openssl/md5.h> 
    4039#include <openssl/sha.h> 
     40#endif 
     41 
     42#ifdef WI_CRYPTO 
    4143 
    4244wi_string_t * wi_digest_md5_string(wi_data_t *data) { 
     
    206208        } 
    207209         
    208         return data
    209 } 
     210        return wi_autorelease(data)
     211} 
  • libwired/trunk/libwired/data/wi-data.c

    r5529 r5547  
    115115 
    116116 
     117#ifdef WI_CRYPTO 
     118 
    117119wi_data_t * wi_data_with_random_bytes(wi_uinteger_t length) { 
    118120        return wi_autorelease(wi_data_init_with_random_bytes(wi_data_alloc(), length)); 
    119121} 
     122 
     123#endif 
    120124 
    121125 
  • libwired/trunk/libwired/data/wi-date.c

    r5411 r5547  
    4040#include <wired/wi-string.h> 
    4141 
    42 #define _WI_DATE_ISO8601_STRING_SIZE    25 
    4342#define _WI_DATE_EPSILON                                0.001 
    4443 
     
    252251 
    253252wi_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
    255254 
    256255        wi_release(date); 
    257256         
    258         if(wi_string_length(string) < _WI_DATE_ISO8601_STRING_SIZE
     257        if(wi_string_length(string) < 19
    259258                return NULL; 
    260259         
    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; 
    271278} 
    272279 
     
    285292        wi_date_t               *date2 = instance2; 
    286293         
    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); 
    288295} 
    289296 
  • libwired/trunk/libwired/data/wi-number.c

    r5331 r5547  
    414414        return value; 
    415415} 
     416 
     417 
     418 
     419#pragma mark - 
     420 
     421wi_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  
    9595WI_EXPORT double                                                wi_number_double(wi_number_t *); 
    9696 
     97WI_EXPORT wi_string_t *                                 wi_number_string(wi_number_t *); 
     98 
    9799#endif /* WI_NUMBER_H */ 
  • libwired/trunk/libwired/data/wi-string.c

    r5529 r5547  
    223223         
    224224        return wi_autorelease(string); 
     225} 
     226 
     227 
     228 
     229wi_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)); 
    225231} 
    226232 
     
    16601666 
    16611667 
     1668#ifdef WI_CRYPTO 
     1669 
    16621670wi_string_t * wi_string_md5(wi_string_t *string) { 
    16631671        return wi_digest_md5_string(wi_string_data(string)); 
     
    16691677        return wi_digest_sha1_string(wi_string_data(string)); 
    16701678} 
     1679 
     1680#endif 
    16711681 
    16721682 
  • libwired/trunk/libwired/data/wi-string.h

    r5324 r5547  
    5757WI_EXPORT wi_string_t *                                         wi_string_with_cstring_no_copy(char *, wi_boolean_t); 
    5858WI_EXPORT wi_string_t *                                         wi_string_with_format(wi_string_t *, ...); 
     59WI_EXPORT wi_string_t *                                         wi_string_with_format_and_arguments(wi_string_t *, va_list); 
    5960WI_EXPORT wi_string_t *                                         wi_string_with_data(wi_data_t *); 
    6061WI_EXPORT wi_string_t *                                         wi_string_with_bytes(const void *, wi_uinteger_t); 
  • libwired/trunk/libwired/misc/wi-error.c

    r5433 r5547  
    113113        /* WI_ERROR_P7_MESSAGETOOLARGE */ 
    114114        "Message too large", 
     115 
     116        /* WI_ERROR_PLIST_READFAILED */ 
     117        "Property list read failed", 
     118        /* WI_ERROR_PLIST_WRITEFAILED */ 
     119        "Property list write failed", 
    115120         
    116121        /* WI_ERROR_REGEXP_NOSLASH */ 
     
    340345 
    341346 
    342 void wi_error_set_libwired_p7_error(int code, wi_string_t *fmt, ...) { 
    343         wi_error_t              *error; 
    344         va_list                 ap; 
     347void wi_error_set_libwired_error_with_string(int code, wi_string_t *string) { 
     348        wi_error_t              *error; 
    345349 
    346350        error = _wi_get_error(); 
     
    352356        error->string = wi_string_init_with_cstring(wi_string_alloc(), _wi_error_strings[error->code]); 
    353357 
    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 
     364void 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); 
    361373} 
    362374 
  • libwired/trunk/libwired/misc/wi-error.h

    r5369 r5547  
    7272        WI_ERROR_P7_MESSAGETOOLARGE, 
    7373 
     74        WI_ERROR_PLIST_READFAILED, 
     75        WI_ERROR_PLIST_WRITEFAILED, 
     76 
    7477        WI_ERROR_REGEXP_NOSLASH, 
    7578        WI_ERROR_REGEXP_INVALIDOPTION, 
  • libwired/trunk/libwired/p7/wi-p7-message.c

    r5538 r5547  
    4444#include <wired/wi-string.h> 
    4545#include <wired/wi-system.h> 
     46#include <wired/wi-xml.h> 
    4647 
    4748#include <libxml/tree.h> 
     
    258259                        for(node = p7_message->xml_root_node->children; node != NULL; node = node->next) { 
    259260                                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")); 
    261262                                        field                   = wi_p7_spec_field_with_name(p7_message->spec, field_name); 
    262263                                        field_value             = _wi_p7_message_field_string_value(p7_message, field); 
     
    587588         
    588589        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, 
    590591                        WI_STR("No id found for field \"%@\""), field_name); 
    591592 
     
    643644 
    644645        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, 
    646647                        WI_STR("No id found for field \"%@\""), field_name); 
    647648                 
     
    944945                         
    945946                        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"))); 
    947948                } 
    948949        } 
     
    960961 
    961962                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, 
    963964                                WI_STR("No id found for message \"%@\""), name); 
    964965                         
     
    10351036                        for(node = p7_message->xml_root_node->children; node != NULL; node = node->next) { 
    10361037                                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")); 
    10381039                                        field                   = wi_p7_spec_field_with_name(p7_message->spec, field_name); 
    10391040                                        field_value             = _wi_p7_message_field_string_value(p7_message, field); 
     
    15631564         
    15641565        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, 
    15661567                        WI_STR("No id found for field \"%@\""), field_name); 
    15671568                 
     
    15751576         
    15761577        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, 
    15781579                        WI_STR("No value found for enum \"%@\""), enum_name); 
    15791580                 
     
    16031604         
    16041605        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, 
    16061607                        WI_STR("No name found for enum \"%u\""), enum_value); 
    16071608                 
     
    17271728                        field_size += 4 + wi_string_length(instance) + 1; 
    17281729                } else { 
    1729                         wi_error_set_libwired_p7_error(WI_ERROR_P7_UNKNOWNFIELD, 
     1730                        wi_error_set_libwired_error_with_format(WI_ERROR_P7_UNKNOWNFIELD, 
    17301731                                WI_STR("Unhandled type %@ in list"), wi_runtime_class_name(instance)); 
    17311732                         
     
    17771778         
    17781779        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, 
    17801781                        WI_STR("No id found for field \"%@\""), field_name); 
    17811782                 
     
    17901791 
    17911792        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, 
    17931794                        WI_STR("Unhandled type %@ in list"), wi_p7_spec_type_name(listtype)); 
    17941795                 
  • libwired/trunk/libwired/p7/wi-p7-private.c

    r5261 r5547  
    2929#include "config.h" 
    3030 
    31 #ifndef WI_P7 
    32  
    3331int wi_p7_private_dummy = 0; 
    34  
    35 #else 
    36  
    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