Changeset 4607
- Timestamp:
- 02/13/07 21:36:19 (2 years ago)
- Files:
-
- libwired/trunk/libwired/p7/wi-p7-private.h (modified) (1 diff)
- libwired/trunk/libwired/p7/wi-p7-spec.c (modified) (42 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libwired/trunk/libwired/p7/wi-p7-private.h
r4601 r4607 63 63 WI_EXPORT void wi_p7_message_deserialize(wi_p7_message_t *); 64 64 65 WI_EXPORT void wi_p7_spec_log_warn(wi_p7_spec_t *, wi_string_t *, ...); 65 66 WI_EXPORT wi_boolean_t wi_p7_spec_is_checking(wi_p7_spec_t *); 66 67 libwired/trunk/libwired/p7/wi-p7-spec.c
r4606 r4607 259 259 static void _wi_p7_spec_dealloc(wi_runtime_instance_t *); 260 260 static wi_string_t * _wi_p7_spec_description(wi_runtime_instance_t *); 261 262 static void _wi_p7_spec_log_warn(wi_p7_spec_t *, wi_string_t *, ...);263 261 264 262 static wi_boolean_t _wi_p7_spec_load_builtin(wi_p7_spec_t *, wi_boolean_t); … … 572 570 #pragma mark - 573 571 574 static void _wi_p7_spec_log_warn(wi_p7_spec_t *p7_spec, wi_string_t *fmt, ...) {575 wi_string_t *string;576 va_list ap;577 578 if(p7_spec->checking) {579 va_start(ap, fmt);580 string = wi_string_init_with_format_and_arguments(wi_string_alloc(), fmt, ap);581 va_end(ap);582 583 if(p7_spec->filename)584 wi_log_warn(WI_STR("%@: %@"), p7_spec->filename, string);585 else586 wi_log_warn(WI_STR("%@"), string);587 }588 }589 590 591 592 #pragma mark -593 594 572 static wi_boolean_t _wi_p7_spec_load_builtin(wi_p7_spec_t *p7_spec, wi_boolean_t checking) { 595 573 xmlDocPtr doc; … … 736 714 if(p7_spec->checking) { 737 715 if(wi_hash_data_for_key(p7_spec->types_name, type->name)) { 738 _wi_p7_spec_log_warn(p7_spec, WI_STR("Type with name \"%@\" already exists"),716 wi_p7_spec_log_warn(p7_spec, WI_STR("Type with name \"%@\" already exists"), 739 717 type->name); 740 718 … … 743 721 744 722 if(wi_hash_data_for_key(p7_spec->types_id, (void *) type->id)) { 745 _wi_p7_spec_log_warn(p7_spec, WI_STR("Type with id %u (name \"%@\") already exists"),723 wi_p7_spec_log_warn(p7_spec, WI_STR("Type with id %u (name \"%@\") already exists"), 746 724 type->name, type->id); 747 725 … … 777 755 if(p7_spec->checking) { 778 756 if(wi_hash_data_for_key(p7_spec->fields_name, field->name)) { 779 _wi_p7_spec_log_warn(p7_spec, WI_STR("Field with name \"%@\" already exists"),757 wi_p7_spec_log_warn(p7_spec, WI_STR("Field with name \"%@\" already exists"), 780 758 field->name); 781 759 … … 784 762 785 763 if(wi_hash_data_for_key(p7_spec->fields_id, (void *) field->id)) { 786 _wi_p7_spec_log_warn(p7_spec, WI_STR("Field with id %u (name \"%@\") already exists"),764 wi_p7_spec_log_warn(p7_spec, WI_STR("Field with id %u (name \"%@\") already exists"), 787 765 field->name, field->id); 788 766 … … 818 796 if(p7_spec->checking) { 819 797 if(wi_hash_data_for_key(p7_spec->messages_name, message->name)) { 820 _wi_p7_spec_log_warn(p7_spec, WI_STR("Message with name \"%@\" already exists"),798 wi_p7_spec_log_warn(p7_spec, WI_STR("Message with name \"%@\" already exists"), 821 799 message->name); 822 800 … … 825 803 826 804 if(wi_hash_data_for_key(p7_spec->messages_id, (void *) message->id)) { 827 _wi_p7_spec_log_warn(p7_spec, WI_STR("Message with id %u (name \"%@\") already exists"),805 wi_p7_spec_log_warn(p7_spec, WI_STR("Message with id %u (name \"%@\") already exists"), 828 806 message->id, message->name); 829 807 … … 859 837 if(p7_spec->checking) { 860 838 if(wi_hash_data_for_key(p7_spec->transactions_name, transaction->message->name)) { 861 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction with message \"%@\" already exists"),839 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction with message \"%@\" already exists"), 862 840 transaction->message->name); 863 841 … … 877 855 #pragma mark - 878 856 857 void wi_p7_spec_log_warn(wi_p7_spec_t *p7_spec, wi_string_t *fmt, ...) { 858 wi_string_t *string; 859 va_list ap; 860 861 if(p7_spec->checking) { 862 va_start(ap, fmt); 863 string = wi_string_init_with_format_and_arguments(wi_string_alloc(), fmt, ap); 864 va_end(ap); 865 866 if(p7_spec->filename) 867 wi_log_warn(WI_STR("%@: %@"), p7_spec->filename, string); 868 else 869 wi_log_warn(WI_STR("%@"), string); 870 } 871 } 872 873 874 875 #pragma mark - 876 879 877 wi_boolean_t wi_p7_spec_is_checking(wi_p7_spec_t *p7_spec) { 880 878 return p7_spec->checking; … … 928 926 if(!other_transaction || !other_transaction->required) { 929 927 if(!other_transaction) { 930 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" is required, but peer lacks it"),928 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" is required, but peer lacks it"), 931 929 transaction->message->name); 932 930 } else { 933 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" is required, but peer has it optional"),931 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" is required, but peer has it optional"), 934 932 transaction->message->name); 935 933 } … … 944 942 945 943 if(transaction->originator != other_transaction->originator) { 946 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" should be sent by %@, but peer sends it by %@"),944 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" should be sent by %@, but peer sends it by %@"), 947 945 transaction->message->name, 948 946 _wi_p7_spec_transaction_originator(transaction), … … 1003 1001 1004 1002 if(count != other_count) { 1005 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" should have %u %@, but peer has %u"),1003 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" should have %u %@, but peer has %u"), 1006 1004 transaction->message->name, 1007 1005 count, … … 1028 1026 if(!other_reply || !other_reply->required) { 1029 1027 if(!other_reply) { 1030 _wi_p7_spec_log_warn(p7_spec, WI_STR("Reply \"%@\" in transaction \"%@\" is required, but peer lacks it"),1028 wi_p7_spec_log_warn(p7_spec, WI_STR("Reply \"%@\" in transaction \"%@\" is required, but peer lacks it"), 1031 1029 reply->message->name, transaction->message->name); 1032 1030 } else { 1033 _wi_p7_spec_log_warn(p7_spec, WI_STR("Reply \"%@\" in transaction \"%@\" is required, but peer has it optional"),1031 wi_p7_spec_log_warn(p7_spec, WI_STR("Reply \"%@\" in transaction \"%@\" is required, but peer has it optional"), 1034 1032 reply->message->name, transaction->message->name); 1035 1033 } … … 1041 1039 if(other_reply) { 1042 1040 if(reply->count != other_reply->count) { 1043 _wi_p7_spec_log_warn(p7_spec, WI_STR("Reply \"%@\" in transaction \"%@\" should be sent %u %@, but peer sends it %u %@"),1041 wi_p7_spec_log_warn(p7_spec, WI_STR("Reply \"%@\" in transaction \"%@\" should be sent %u %@, but peer sends it %u %@"), 1044 1042 reply->message->name, 1045 1043 reply->count, … … 1071 1069 1072 1070 if(message->id != other_message->id) { 1073 _wi_p7_spec_log_warn(p7_spec,1071 wi_p7_spec_log_warn(p7_spec, 1074 1072 WI_STR("Message in reply \"%@\" in transaction \"%@\" should have id %u, but peer has id %u"), 1075 1073 message->name, transaction->message->name, message->id, other_message->id); … … 1087 1085 if(!other_parameter || !other_parameter->required) { 1088 1086 if(!other_parameter) { 1089 _wi_p7_spec_log_warn(p7_spec,1087 wi_p7_spec_log_warn(p7_spec, 1090 1088 WI_STR("Parameter \"%@\" in reply \"%@\" in transaction \"%@\" is required, but peer lacks it"), 1091 1089 parameter->field->name, message->name, transaction->message->name); 1092 1090 } else { 1093 _wi_p7_spec_log_warn(p7_spec,1091 wi_p7_spec_log_warn(p7_spec, 1094 1092 WI_STR("Parameter \"%@\" in reply \"%@\" in transaction \"%@\" is required, but peer has it optional"), 1095 1093 parameter->field->name, message->name, transaction->message->name); … … 1105 1103 1106 1104 if(field->id != other_field->id) { 1107 _wi_p7_spec_log_warn(p7_spec,1105 wi_p7_spec_log_warn(p7_spec, 1108 1106 WI_STR("Field in parameter \"%@\" in reply \"%@\" in transaction \"%@\" should have id %u, but peer has id %u"), 1109 1107 parameter->field->name, message->name, transaction->message->name, field->id, other_field->id); … … 1113 1111 1114 1112 if(field->type->id != other_field->type->id) { 1115 _wi_p7_spec_log_warn(p7_spec,1113 wi_p7_spec_log_warn(p7_spec, 1116 1114 WI_STR("Parameter \"%@\" in reply \"%@\" in transaction \"%@\" should be of type \"%@\", but peer has it as \"%@\""), 1117 1115 parameter->field->name, message->name, transaction->message->name, field->type->name, other_field->type->name); … … 1122 1120 if(field->type->id == WI_P7_ENUM) { 1123 1121 if(!wi_is_equal(field->enums, other_field->enums)) { 1124 _wi_p7_spec_log_warn(p7_spec,1122 wi_p7_spec_log_warn(p7_spec, 1125 1123 WI_STR("Parameter \"%@\" in reply \"%@\" in transaction \"%@\" have enumerations that differ with those of peer"), 1126 1124 parameter->field->name, message->name, transaction->message->name); … … 1304 1302 1305 1303 if(!type->name) { 1306 _wi_p7_spec_log_warn(p7_spec, WI_STR("Type has no \"name\""));1304 wi_p7_spec_log_warn(p7_spec, WI_STR("Type has no \"name\"")); 1307 1305 1308 1306 return NULL; … … 1312 1310 1313 1311 if(type->id == WI_P7_SPEC_TYPE_ID_NULL) { 1314 _wi_p7_spec_log_warn(p7_spec, WI_STR("Type \"%@\" has no \"id\""),1312 wi_p7_spec_log_warn(p7_spec, WI_STR("Type \"%@\" has no \"id\""), 1315 1313 type->name); 1316 1314 … … 1366 1364 1367 1365 if(!field->name) { 1368 _wi_p7_spec_log_warn(p7_spec, WI_STR("Field has no \"name\""));1366 wi_p7_spec_log_warn(p7_spec, WI_STR("Field has no \"name\"")); 1369 1367 1370 1368 return NULL; … … 1374 1372 1375 1373 if(!type) { 1376 _wi_p7_spec_log_warn(p7_spec, WI_STR("Field \"%@\" has no \"type\""),1374 wi_p7_spec_log_warn(p7_spec, WI_STR("Field \"%@\" has no \"type\""), 1377 1375 field->name); 1378 1376 … … 1386 1384 1387 1385 if(!field->type) { 1388 _wi_p7_spec_log_warn(p7_spec, WI_STR("Field \"%@\" has an invalid \"type\" (\"%@\")"),1386 wi_p7_spec_log_warn(p7_spec, WI_STR("Field \"%@\" has an invalid \"type\" (\"%@\")"), 1389 1387 field->name, type); 1390 1388 … … 1395 1393 1396 1394 if(field->id == WI_P7_SPEC_FIELD_ID_NULL) { 1397 _wi_p7_spec_log_warn(p7_spec, WI_STR("Field \"%@\" has no \"id\""),1395 wi_p7_spec_log_warn(p7_spec, WI_STR("Field \"%@\" has no \"id\""), 1398 1396 field->name); 1399 1397 … … 1409 1407 1410 1408 if(!name) { 1411 _wi_p7_spec_log_warn(p7_spec, WI_STR("Field \"%@\" enum has no \"name\""),1409 wi_p7_spec_log_warn(p7_spec, WI_STR("Field \"%@\" enum has no \"name\""), 1412 1410 field->name); 1413 1411 … … 1462 1460 1463 1461 if(!message->name) { 1464 _wi_p7_spec_log_warn(p7_spec, WI_STR("Message has no name"));1462 wi_p7_spec_log_warn(p7_spec, WI_STR("Message has no name")); 1465 1463 1466 1464 return NULL; … … 1470 1468 1471 1469 if(message->id == WI_P7_SPEC_MESSAGE_ID_NULL) { 1472 _wi_p7_spec_log_warn(p7_spec, WI_STR("Message \"%@\" has no \"id\""),1470 wi_p7_spec_log_warn(p7_spec, WI_STR("Message \"%@\" has no \"id\""), 1473 1471 message->name); 1474 1472 … … 1489 1487 if(p7_spec->checking) { 1490 1488 if(wi_hash_data_for_key(message->parameters, parameter->field->name)) { 1491 _wi_p7_spec_log_warn(p7_spec, WI_STR("Message \"%@\" has a duplicate field \"%@\""),1489 wi_p7_spec_log_warn(p7_spec, WI_STR("Message \"%@\" has a duplicate field \"%@\""), 1492 1490 message->name, parameter->field->name); 1493 1491 … … 1537 1535 1538 1536 if(!field) { 1539 _wi_p7_spec_log_warn(p7_spec, WI_STR("Parameter in message \"%@\" has no \"field\""),1537 wi_p7_spec_log_warn(p7_spec, WI_STR("Parameter in message \"%@\" has no \"field\""), 1540 1538 message->name); 1541 1539 … … 1549 1547 1550 1548 if(!parameter->field) { 1551 _wi_p7_spec_log_warn(p7_spec, WI_STR("Parameter in message \"%@\" has an invalid \"field\" (\"%@\")"),1549 wi_p7_spec_log_warn(p7_spec, WI_STR("Parameter in message \"%@\" has an invalid \"field\" (\"%@\")"), 1552 1550 message->name, field); 1553 1551 … … 1561 1559 if(wi_string_case_insensitive_compare(use, WI_STR("required")) != 0 && 1562 1560 wi_string_case_insensitive_compare(use, WI_STR("optional")) != 0) { 1563 _wi_p7_spec_log_warn(p7_spec, WI_STR("Parameter \"%@\" in message \"%@\" has an invalid \"use\" (\"%@\")"),1561 wi_p7_spec_log_warn(p7_spec, WI_STR("Parameter \"%@\" in message \"%@\" has an invalid \"use\" (\"%@\")"), 1564 1562 message->name, parameter->field->name, use); 1565 1563 … … 1606 1604 1607 1605 if(!message) { 1608 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction has no \"message\""));1606 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction has no \"message\"")); 1609 1607 1610 1608 return NULL; … … 1617 1615 1618 1616 if(!transaction->message) { 1619 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction has an invalid \"message\" (\"%@\")"),1617 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction has an invalid \"message\" (\"%@\")"), 1620 1618 message); 1621 1619 … … 1626 1624 1627 1625 if(!originator) { 1628 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" has no \"originator\""),1626 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" has no \"originator\""), 1629 1627 transaction->message->name); 1630 1628 … … 1636 1634 wi_string_case_insensitive_compare(originator, WI_STR("server")) != 0 && 1637 1635 wi_string_case_insensitive_compare(originator, WI_STR("both")) != 0) { 1638 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" has an invalid \"originator\" (\"%@\")"),1636 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" has an invalid \"originator\" (\"%@\")"), 1639 1637 transaction->message->name, originator); 1640 1638 … … 1656 1654 if(wi_string_case_insensitive_compare(use, WI_STR("required")) != 0 && 1657 1655 wi_string_case_insensitive_compare(use, WI_STR("optional"))) { 1658 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" has an invalid \"use\" (\"%@\")"),1656 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" has an invalid \"use\" (\"%@\")"), 1659 1657 transaction->message->name, use); 1660 1658 … … 1737 1735 if(p7_spec->checking) { 1738 1736 if(wi_hash_data_for_key(andor->replies_hash, reply->message->name)) { 1739 _wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" has a duplicate reply \"%@\""),1737 wi_p7_spec_log_warn(p7_spec, WI_STR("Transaction \"%@\" has a duplicate reply \"%@\""), 1740 1738 transaction->message->name, reply->message->name); 1741 1739 … … 1795 1793 1796 1794 if(!message) { 1797 _wi_p7_spec_log_warn(p7_spec, WI_STR("Reply in transaction \"%@\" has no \"message\""),1795 wi_p7_spec_log_warn(p7_spec, WI_STR("Reply in transaction \"%@\" has no \"message\""), 1798 1796 transaction->message->name); 1799 1797 … … 1807 1805 1808 1806 if(!reply->message) { 1809 _wi_p7_spec_log_warn(p7_spec, WI_STR("Reply in transaction \"%@\" has an invalid \"message\" (\"%@\")"),1807 wi_p7_spec_log_warn(p7_spec, WI_STR("Reply in transaction \"%@\" has an invalid \"message\" (\"%@\")"), 1810 1808 transaction->message->name, message); 1811 1809 … … 1819 1817 if(wi_string_case_insensitive_compare(use, WI_STR("required")) != 0 && 1820 1818 wi_string_case_insensitive_compare(use, WI_STR("optional"))) { 1821 _wi_p7_spec_log_warn(p7_spec, WI_STR("Reply \"%@\" in transaction \"%@\" has an invalid \"use\" (\"%@\")"),1819 wi_p7_spec_log_warn(p7_spec, WI_STR("Reply \"%@\" in transaction \"%@\" has an invalid \"use\" (\"%@\")"), 1822 1820 reply->message->name, transaction->message->name, use); 1823 1821
