Changeset 5381
- Timestamp:
- 03/14/08 07:42:30 (6 months ago)
- Files:
-
- libwired/trunk/libwired/p7/wi-p7-private.h (modified) (1 diff)
- libwired/trunk/libwired/p7/wi-p7-socket.c (modified) (15 diffs)
- libwired/trunk/libwired/p7/wi-p7-spec.c (modified) (10 diffs)
- libwired/trunk/libwired/p7/wi-p7-spec.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/libwired/p7/wi-p7-private.h
r5261 r5381 64 64 WI_EXPORT void wi_p7_message_deserialize(wi_p7_message_t *); 65 65 66 WI_EXPORT wi_boolean_t wi_p7_spec_is_compatible_with_protocol(wi_p7_spec_t *, wi_string_t *, double);66 WI_EXPORT wi_boolean_t wi_p7_spec_is_compatible_with_protocol(wi_p7_spec_t *, wi_string_t *, wi_string_t *); 67 67 68 68 WI_EXPORT wi_string_t * wi_p7_xml_copy_string_for_attribute(xmlNodePtr, wi_string_t *); libwired/trunk/libwired/p7/wi-p7-socket.c
r5369 r5381 134 134 wi_p7_spec_t *spec; 135 135 wi_string_t *name; 136 doubleversion;136 wi_string_t *version; 137 137 138 138 wi_p7_serialization_t serialization; … … 278 278 wi_release(p7_socket->spec); 279 279 wi_release(p7_socket->name); 280 wi_release(p7_socket->version); 280 281 wi_release(p7_socket->rsa); 281 282 wi_release(p7_socket->cipher); … … 355 356 356 357 static wi_boolean_t _wi_p7_socket_connect_handshake(wi_p7_socket_t *p7_socket, wi_time_interval_t timeout, wi_p7_options_t options) { 358 wi_string_t *version; 357 359 wi_p7_message_t *p7_message; 358 wi_p7_double_t version;359 360 wi_p7_enum_t flag; 360 361 … … 364 365 return false; 365 366 366 if(!wi_p7_message_set_ double_for_name(p7_message, wi_p7_spec_version(wi_p7_spec_builtin_spec()), WI_STR("p7.handshake.version")))367 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_version(wi_p7_spec_builtin_spec()), WI_STR("p7.handshake.version"))) 367 368 return false; 368 369 … … 370 371 return false; 371 372 372 if(!wi_p7_message_set_ double_for_name(p7_message, wi_p7_spec_version(p7_socket->spec), WI_STR("p7.handshake.protocol_version")))373 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_version(p7_socket->spec), WI_STR("p7.handshake.protocol_version"))) 373 374 return false; 374 375 … … 415 416 } 416 417 417 if(!wi_p7_message_get_double_for_name(p7_message, &version, WI_STR("p7.handshake.version"))) { 418 version = wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.version")); 419 420 if(!version) { 418 421 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 419 422 WI_STR("Message has no \"p7.handshake.version\" field")); … … 422 425 } 423 426 424 if( version != wi_p7_spec_version(wi_p7_spec_builtin_spec())) {427 if(!wi_is_equal(version, wi_p7_spec_version(wi_p7_spec_builtin_spec()))) { 425 428 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 426 429 WI_STR("Remote P7 protocol %.1f is not compatible"), … … 439 442 } 440 443 441 if(!wi_p7_message_get_double_for_name(p7_message, &p7_socket->version, WI_STR("p7.handshake.protocol_version"))) { 444 p7_socket->version = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol_version"))); 445 446 if(!p7_socket->version) { 442 447 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 443 448 WI_STR("Message has no \"p7.handshake.protocol_version\" field")); … … 481 486 482 487 static wi_boolean_t _wi_p7_socket_accept_handshake(wi_p7_socket_t *p7_socket, wi_time_interval_t timeout, wi_p7_options_t options) { 488 wi_string_t *version; 483 489 wi_p7_message_t *p7_message; 484 wi_p7_double_t version;485 490 wi_p7_enum_t flag; 486 491 wi_p7_options_t client_options; … … 499 504 } 500 505 501 if(!wi_p7_message_get_double_for_name(p7_message, &version, WI_STR("p7.handshake.version"))) { 506 version = wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.version")); 507 508 if(!version) { 502 509 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 503 510 WI_STR("Message has no \"p7.handshake.version\" field")); … … 506 513 } 507 514 508 if( version != wi_p7_spec_version(wi_p7_spec_builtin_spec())) {515 if(!wi_is_equal(version, wi_p7_spec_version(wi_p7_spec_builtin_spec()))) { 509 516 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 510 517 WI_STR("Remote P7 protocol %.1f is not compatible"), … … 523 530 } 524 531 525 if(!wi_p7_message_get_double_for_name(p7_message, &p7_socket->version, WI_STR("p7.handshake.protocol_version"))) { 532 p7_socket->version = wi_retain(wi_p7_message_string_for_name(p7_message, WI_STR("p7.handshake.protocol_version"))); 533 534 if(!p7_socket->version) { 526 535 wi_error_set_libwired_p7_error(WI_ERROR_P7_HANDSHAKEFAILED, 527 536 WI_STR("Message has no \"p7.handshake.protocol_version\" field")); … … 560 569 return false; 561 570 562 if(!wi_p7_message_set_ double_for_name(p7_message, wi_p7_spec_version(wi_p7_spec_builtin_spec()), WI_STR("p7.handshake.version")))571 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_version(wi_p7_spec_builtin_spec()), WI_STR("p7.handshake.version"))) 563 572 return false; 564 573 … … 566 575 return false; 567 576 568 if(!wi_p7_message_set_ double_for_name(p7_message, wi_p7_spec_version(p7_socket->spec), WI_STR("p7.handshake.protocol_version")))577 if(!wi_p7_message_set_string_for_name(p7_message, wi_p7_spec_version(p7_socket->spec), WI_STR("p7.handshake.protocol_version"))) 569 578 return false; 570 579 … … 989 998 990 999 compatible = wi_p7_spec_is_compatible_with_spec(p7_socket->spec, p7_spec); 991 1000 1001 wi_log_info(WI_STR("%d %m"), compatible); 1002 992 1003 wi_release(p7_spec); 993 1004 libwired/trunk/libwired/p7/wi-p7-spec.c
r5380 r5381 302 302 wi_string_t *filename; 303 303 wi_string_t *name; 304 doubleversion;304 wi_string_t *version; 305 305 wi_p7_originator_t originator; 306 306 … … 367 367 "" 368 368 " <p7:fields>" 369 " <p7:field name=\"p7.handshake.version\" type=\" double\" id=\"1\" />"369 " <p7:field name=\"p7.handshake.version\" type=\"string\" id=\"1\" />" 370 370 " <p7:field name=\"p7.handshake.protocol_name\" type=\"string\" id=\"2\" />" 371 " <p7:field name=\"p7.handshake.protocol_version\" type=\" double\" id=\"3\" />"371 " <p7:field name=\"p7.handshake.protocol_version\" type=\"string\" id=\"3\" />" 372 372 " <p7:field name=\"p7.handshake.compression\" type=\"enum\" id=\"4\">" 373 373 " <p7:enum name=\"p7.handshake.compression.deflate\" value=\"0\" />" … … 637 637 wi_release(p7_spec->filename); 638 638 wi_release(p7_spec->name); 639 wi_release(p7_spec->version); 639 640 wi_release(p7_spec->compatible_protocols); 640 641 … … 657 658 wi_p7_spec_t *p7_spec = instance; 658 659 659 return wi_string_with_format(WI_STR("<%@ %p>{name = %@, version = % .1f, types = %@, fields = %@, messages = %@}"),660 return wi_string_with_format(WI_STR("<%@ %p>{name = %@, version = %@, types = %@, fields = %@, messages = %@}"), 660 661 wi_runtime_class_name(p7_spec), 661 662 p7_spec, … … 758 759 759 760 static wi_boolean_t _wi_p7_spec_load_spec(wi_p7_spec_t *p7_spec, xmlDocPtr doc) { 760 wi_string_t *version;761 761 xmlNodePtr root_node, node; 762 762 … … 780 780 } 781 781 782 version = wi_autorelease(wi_p7_xml_copy_string_for_attribute(root_node, WI_STR("version")));783 784 if(! version) {782 p7_spec->version = wi_p7_xml_copy_string_for_attribute(root_node, WI_STR("version")); 783 784 if(!p7_spec->version) { 785 785 wi_error_set_libwired_p7_error(WI_ERROR_P7_INVALIDSPEC, 786 786 WI_STR("Protocol has no \"version\"")); … … 788 788 return false; 789 789 } 790 791 p7_spec->version = wi_string_double(version);792 790 793 791 for(node = root_node->children; node != NULL; node = node->next) { … … 1070 1068 #pragma mark - 1071 1069 1072 wi_boolean_t wi_p7_spec_is_compatible_with_protocol(wi_p7_spec_t *p7_spec, wi_string_t *name, doubleversion) {1073 return ((wi_is_equal(p7_spec->name, name) && p7_spec->version == version) ||1074 wi_set_contains_data(p7_spec->compatible_protocols, wi_string_with_format(WI_STR("%@ % .1f"), name, version)));1070 wi_boolean_t wi_p7_spec_is_compatible_with_protocol(wi_p7_spec_t *p7_spec, wi_string_t *name, wi_string_t *version) { 1071 return ((wi_is_equal(p7_spec->name, name) && wi_is_equal(p7_spec->version, version)) || 1072 wi_set_contains_data(p7_spec->compatible_protocols, wi_string_with_format(WI_STR("%@ %@"), name, version))); 1075 1073 } 1076 1074 … … 1083 1081 1084 1082 if(compatible) { 1085 wi_set_add_data(p7_spec->compatible_protocols, wi_string_with_format(WI_STR("%@ % .1f"),1083 wi_set_add_data(p7_spec->compatible_protocols, wi_string_with_format(WI_STR("%@ %@"), 1086 1084 other_p7_spec->name, other_p7_spec->version)); 1087 1085 } … … 1409 1407 1410 1408 1411 doublewi_p7_spec_version(wi_p7_spec_t *p7_spec) {1409 wi_string_t * wi_p7_spec_version(wi_p7_spec_t *p7_spec) { 1412 1410 return p7_spec->version; 1413 1411 } libwired/trunk/libwired/p7/wi-p7-spec.h
r5326 r5381 59 59 60 60 WI_EXPORT wi_string_t * wi_p7_spec_name(wi_p7_spec_t *); 61 WI_EXPORT doublewi_p7_spec_version(wi_p7_spec_t *);61 WI_EXPORT wi_string_t * wi_p7_spec_version(wi_p7_spec_t *); 62 62 WI_EXPORT wi_p7_originator_t wi_p7_spec_originator(wi_p7_spec_t *); 63 63 WI_EXPORT wi_string_t * wi_p7_spec_xml(wi_p7_spec_t *);
