Changeset 4607

Show
Ignore:
Timestamp:
02/13/07 21:36:19 (2 years ago)
Author:
morris
Message:

Make log function semi-public

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libwired/trunk/libwired/p7/wi-p7-private.h

    r4601 r4607  
    6363WI_EXPORT void                                          wi_p7_message_deserialize(wi_p7_message_t *); 
    6464 
     65WI_EXPORT void                                          wi_p7_spec_log_warn(wi_p7_spec_t *, wi_string_t *, ...); 
    6566WI_EXPORT wi_boolean_t                          wi_p7_spec_is_checking(wi_p7_spec_t *); 
    6667 
  • libwired/trunk/libwired/p7/wi-p7-spec.c

    r4606 r4607  
    259259static void                                                                     _wi_p7_spec_dealloc(wi_runtime_instance_t *); 
    260260static 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 *, ...); 
    263261 
    264262static wi_boolean_t                                                     _wi_p7_spec_load_builtin(wi_p7_spec_t *, wi_boolean_t); 
     
    572570#pragma mark - 
    573571 
    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                 else 
    586                         wi_log_warn(WI_STR("%@"), string); 
    587         } 
    588 } 
    589  
    590  
    591  
    592 #pragma mark - 
    593  
    594572static wi_boolean_t _wi_p7_spec_load_builtin(wi_p7_spec_t *p7_spec, wi_boolean_t checking) { 
    595573        xmlDocPtr               doc; 
     
    736714                        if(p7_spec->checking) { 
    737715                                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"), 
    739717                                                type->name); 
    740718                                         
     
    743721 
    744722                                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"), 
    746724                                                type->name, type->id); 
    747725                                         
     
    777755                        if(p7_spec->checking) { 
    778756                                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"), 
    780758                                                field->name); 
    781759                                         
     
    784762                                 
    785763                                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"), 
    787765                                                field->name, field->id); 
    788766                                         
     
    818796                        if(p7_spec->checking) { 
    819797                                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"), 
    821799                                                message->name); 
    822800                                         
     
    825803                                 
    826804                                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"), 
    828806                                                message->id, message->name); 
    829807                                         
     
    859837                        if(p7_spec->checking) { 
    860838                                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"), 
    862840                                                transaction->message->name); 
    863841                                         
     
    877855#pragma mark - 
    878856 
     857void 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 
    879877wi_boolean_t wi_p7_spec_is_checking(wi_p7_spec_t *p7_spec) { 
    880878        return p7_spec->checking; 
     
    928926                if(!other_transaction || !other_transaction->required) { 
    929927                        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"), 
    931929                                        transaction->message->name); 
    932930                        } 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"), 
    934932                                        transaction->message->name); 
    935933                        } 
     
    944942                 
    945943                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 %@"), 
    947945                                transaction->message->name, 
    948946                                _wi_p7_spec_transaction_originator(transaction), 
     
    10031001         
    10041002        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"), 
    10061004                        transaction->message->name, 
    10071005                        count, 
     
    10281026                if(!other_reply || !other_reply->required) { 
    10291027                        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"), 
    10311029                                        reply->message->name, transaction->message->name); 
    10321030                        } 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"), 
    10341032                                        reply->message->name, transaction->message->name); 
    10351033                        } 
     
    10411039        if(other_reply) { 
    10421040                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 %@"), 
    10441042                                reply->message->name, 
    10451043                                reply->count, 
     
    10711069         
    10721070        if(message->id != other_message->id) { 
    1073                 _wi_p7_spec_log_warn(p7_spec, 
     1071                wi_p7_spec_log_warn(p7_spec, 
    10741072                        WI_STR("Message in reply \"%@\" in transaction \"%@\" should have id %u, but peer has id %u"), 
    10751073                        message->name, transaction->message->name, message->id, other_message->id); 
     
    10871085                        if(!other_parameter || !other_parameter->required) { 
    10881086                                if(!other_parameter) { 
    1089                                         _wi_p7_spec_log_warn(p7_spec, 
     1087                                        wi_p7_spec_log_warn(p7_spec, 
    10901088                                                WI_STR("Parameter \"%@\" in reply \"%@\" in transaction \"%@\" is required, but peer lacks it"), 
    10911089                                                parameter->field->name, message->name, transaction->message->name); 
    10921090                                } else { 
    1093                                         _wi_p7_spec_log_warn(p7_spec, 
     1091                                        wi_p7_spec_log_warn(p7_spec, 
    10941092                                                WI_STR("Parameter \"%@\" in reply \"%@\" in transaction \"%@\" is required, but peer has it optional"), 
    10951093                                                parameter->field->name, message->name, transaction->message->name); 
     
    11051103                         
    11061104                        if(field->id != other_field->id) { 
    1107                                 _wi_p7_spec_log_warn(p7_spec, 
     1105                                wi_p7_spec_log_warn(p7_spec, 
    11081106                                        WI_STR("Field in parameter \"%@\" in reply \"%@\" in transaction \"%@\" should have id %u, but peer has id %u"), 
    11091107                                        parameter->field->name, message->name, transaction->message->name, field->id, other_field->id); 
     
    11131111                         
    11141112                        if(field->type->id != other_field->type->id) { 
    1115                                 _wi_p7_spec_log_warn(p7_spec, 
     1113                                wi_p7_spec_log_warn(p7_spec, 
    11161114                                        WI_STR("Parameter \"%@\" in reply \"%@\" in transaction \"%@\" should be of type \"%@\", but peer has it as \"%@\""), 
    11171115                                        parameter->field->name, message->name, transaction->message->name, field->type->name, other_field->type->name); 
     
    11221120                        if(field->type->id == WI_P7_ENUM) { 
    11231121                                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, 
    11251123                                                WI_STR("Parameter \"%@\" in reply \"%@\" in transaction \"%@\" have enumerations that differ with those of peer"), 
    11261124                                                parameter->field->name, message->name, transaction->message->name); 
     
    13041302         
    13051303        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\"")); 
    13071305                 
    13081306                return NULL; 
     
    13121310         
    13131311        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\""), 
    13151313                        type->name); 
    13161314                 
     
    13661364 
    13671365        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\"")); 
    13691367 
    13701368                return NULL; 
     
    13741372 
    13751373        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\""), 
    13771375                        field->name); 
    13781376 
     
    13861384         
    13871385        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\" (\"%@\")"), 
    13891387                        field->name, type); 
    13901388 
     
    13951393         
    13961394        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\""), 
    13981396                        field->name); 
    13991397 
     
    14091407                                 
    14101408                                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\""), 
    14121410                                                field->name); 
    14131411                                         
     
    14621460 
    14631461        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")); 
    14651463                 
    14661464                return NULL; 
     
    14701468         
    14711469        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\""), 
    14731471                        message->name); 
    14741472 
     
    14891487                        if(p7_spec->checking) { 
    14901488                                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 \"%@\""), 
    14921490                                                message->name, parameter->field->name); 
    14931491                                         
     
    15371535 
    15381536        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\""), 
    15401538                        message->name); 
    15411539                 
     
    15491547         
    15501548        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\" (\"%@\")"), 
    15521550                        message->name, field); 
    15531551                 
     
    15611559                        if(wi_string_case_insensitive_compare(use, WI_STR("required")) != 0 && 
    15621560                           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\" (\"%@\")"), 
    15641562                                        message->name, parameter->field->name, use); 
    15651563                                 
     
    16061604         
    16071605        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\"")); 
    16091607                 
    16101608                return NULL; 
     
    16171615         
    16181616        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\" (\"%@\")"), 
    16201618                        message); 
    16211619                 
     
    16261624 
    16271625        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\""), 
    16291627                        transaction->message->name); 
    16301628                 
     
    16361634                   wi_string_case_insensitive_compare(originator, WI_STR("server")) != 0 && 
    16371635                   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\" (\"%@\")"), 
    16391637                                transaction->message->name, originator); 
    16401638                         
     
    16561654                        if(wi_string_case_insensitive_compare(use, WI_STR("required")) != 0 && 
    16571655                           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\" (\"%@\")"), 
    16591657                                        transaction->message->name, use); 
    16601658                                 
     
    17371735                                if(p7_spec->checking) { 
    17381736                                        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 \"%@\""), 
    17401738                                                        transaction->message->name, reply->message->name); 
    17411739                                                 
     
    17951793 
    17961794        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\""), 
    17981796                        transaction->message->name); 
    17991797                 
     
    18071805         
    18081806        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\" (\"%@\")"), 
    18101808                        transaction->message->name, message); 
    18111809                 
     
    18191817                        if(wi_string_case_insensitive_compare(use, WI_STR("required")) != 0 && 
    18201818                           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\" (\"%@\")"), 
    18221820                                        reply->message->name, transaction->message->name, use); 
    18231821