Show
Ignore:
Timestamp:
05/15/05 07:13:05 (18 years ago)
Author:
pieterpalmers
Message:

- added some extra error checking
- commented a lot of verbose debug statements

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libfreebobctl/examples/test-freebobctl-osc.c

    r72 r94  
    1313main(int argc, char **argv) { 
    1414        char *url; 
     15        freebob_connection_info_t *test_info; 
    1516         
    1617        printf("Using freebob control library version: %s\n",freebobctl_get_version()); 
     
    2324        url = argv[1]; 
    2425 
    25         freebob_connection_info_t *test_info=freebobctl_get_connection_info_from_osc(url, 0); 
     26        // capture 
     27        printf("CAPTURE DIRECTION\n");  
     28        test_info=freebobctl_get_connection_info_from_osc(url, 0); 
     29        freebobctl_print_connection_info(test_info); 
    2630        freebobctl_free_connection_info(test_info); 
    27          
    28         //test_info=freebobctl_get_connection_info_from_xml_file(docname, 1); 
    29         //freebobctl_free_connection_info(test_info); 
     31 
     32        printf("PLAYBACK DIRECTION\n");  
     33        test_info=freebobctl_get_connection_info_from_osc(url, 1); 
     34        freebobctl_print_connection_info(test_info); 
     35        freebobctl_free_connection_info(test_info); 
     36 
    3037         
    3138         
  • trunk/libfreebobctl/src/ipchandler.c

    r72 r94  
    3333 
    3434void freebobctl_ipc_error(int num, const char *m, const char *path) { 
    35     printf("liblo server error %d in path %s: %s\n", num, path, m); 
     35    fprintf(stderr,"liblo server error %d in path %s: %s\n", num, path, m); 
    3636}; 
    3737 
     
    5353int freebobctl_ipc_generic_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { 
    5454         
    55       int i; 
     55/*    int i; 
    5656         
    57         printf("message received on path: <%s>\n", path); 
     57        fprintf(stderr,"message received on path: <%s>\n", path); 
    5858        for (i=0; i<argc; i++) { 
    59                 printf("arg %d '%c' ", i, types[i]); 
     59                fprintf(stderr,"arg %d '%c' ", i, types[i]); 
    6060                lo_arg_pp(types[i], argv[i]); 
    61                 printf("\n"); 
     61                fprintf(stderr,"\n"); 
    6262        } 
    6363 
    64         printf("\n");    
     64        fprintf(stderr,"\n");    
     65*/ 
    6566        return 1; 
    6667         
     
    6970char * freebobctl_ipc_request_connection_info(char *url) { 
    7071        char *buffer=NULL; 
    71          
    72         printf("requesting channel info from %s\n",url); 
    73          
    74         lo_server s = lo_server_new("7770", freebobctl_ipc_error); 
     72        lo_server s; 
     73 
     74        fprintf(stderr,"requesting channel info from %s\n",url); 
     75        s = lo_server_new(NULL, freebobctl_ipc_error); 
    7576         
    7677        if(!s) { 
     78                fprintf(stderr,"Could not create server\n"); 
    7779                return NULL; 
    7880        } 
    7981         
    8082        /* add method that will match any path and args */ 
     83        fprintf(stderr,"adding generic handler...\n"); 
    8184        lo_server_add_method(s, NULL, NULL, freebobctl_ipc_generic_handler, NULL); 
    8285         
     86        fprintf(stderr,"adding /reponse handler...\n"); 
    8387        lo_server_add_method(s, "/response", "s", freebobctl_ipc_response_handler, &buffer); 
    8488         
     89        fprintf(stderr,"parsing address...\n"); 
    8590        lo_address t = lo_address_new_from_url(url); 
    86          
     91        if(!t) { 
     92                fprintf(stderr,"Could not parse address\n"); 
     93                lo_server_free(s); 
     94                 
     95                return NULL; 
     96        } 
     97 
     98        fprintf(stderr,"sending request... "); 
    8799        if (lo_send(t, "/freebob/request", "s","connection_info") == -1) { 
    88                 printf("OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
     100                fprintf(stderr,"OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 
    89101                lo_address_free(t); 
    90102                lo_server_free(s); 
    91103                return NULL; 
    92104        } 
    93          
     105 
     106        fprintf(stderr,"waiting for response... "); 
    94107        /* wait for the response, with timeout */ 
    95108        if (lo_server_recv_noblock(s,5000)==0) { 
    96                 printf("Timeout receiving response...\n"); 
     109                fprintf(stderr,"Timeout receiving response...\n"); 
    97110                lo_address_free(t); 
    98111                lo_server_free(s); 
    99112                return NULL; 
    100113        } 
     114        fprintf(stderr,"ok\n"); 
     115 
     116        fprintf(stderr,"freeing...\n"); 
    101117         
    102118        lo_address_free(t); 
    103119        lo_server_free(s); 
    104          
    105         printf("done...\n"); 
     120 
     121        fprintf(stderr,"done...\n"); 
    106122        return buffer; 
    107123 
  • trunk/libfreebobctl/src/xmlparser.c

    r84 r94  
    5454            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Position"))) { 
    5555                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    56                   printf("\t\tposition: %s\n", key); 
     56//                printf("\t\tposition: %s\n", key); 
    5757                    stream_spec->position=strtol(key, (char **)NULL, 10); 
    5858                    xmlFree(key); 
     
    6060            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Location"))) { 
    6161                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    62                   printf("\t\tlocation: %s\n", key); 
     62//                printf("\t\tlocation: %s\n", key); 
    6363                    stream_spec->location=strtol(key, (char **)NULL, 10); 
    6464                    xmlFree(key); 
     
    6666            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Format"))) { 
    6767                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    68                   printf("\t\tformat: %s\n", key); 
     68//                printf("\t\tformat: %s\n", key); 
    6969                    stream_spec->format=strtol(key, (char **)NULL, 10); 
    7070                    xmlFree(key); 
     
    7272            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Type"))) { 
    7373                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    74                   printf("\t\ttype: %s\n", key); 
     74//                printf("\t\ttype: %s\n", key); 
    7575                    stream_spec->type=strtol(key, (char **)NULL, 10); 
    7676                    xmlFree(key); 
     
    7878            if ((!xmlStrcmp(cur->name, (const xmlChar *)"DestinationPort"))) { 
    7979                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    80                   printf("\t\tdestination_port: %s\n", key); 
     80//                printf("\t\tdestination_port: %s\n", key); 
    8181                    stream_spec->destination_port=strtol(key, (char **)NULL, 10); 
    8282                    xmlFree(key); 
     
    8585            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Name"))) { 
    8686                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    87                   printf("\t\tname: %s\n", key); 
     87//                printf("\t\tname: %s\n", key); 
    8888                    strncpy(stream_spec->name,key,FREEBOBCTL_MAX_NAME_LEN); 
    8989                    xmlFree(key); 
     
    171171            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Id"))) { 
    172172                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    173                   printf("\tid: %s\n", key); 
     173//                printf("\tid: %s\n", key); 
    174174                    connection_spec->id=strtol(key, (char **)NULL, 10); 
    175175                    xmlFree(key); 
     
    177177            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Node"))) { 
    178178                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    179                   printf("\tnode: %s\n", key); 
     179//                printf("\tnode: %s\n", key); 
    180180                    connection_spec->node=strtol(key, (char **)NULL, 10); 
    181181                     
     
    184184            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Port"))) { 
    185185                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    186                   printf("\tport: %s\n", key); 
     186//                printf("\tport: %s\n", key); 
    187187                    connection_spec->port=strtol(key, (char **)NULL, 10); 
    188188                    xmlFree(key); 
     
    190190            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Plug"))) { 
    191191                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    192                   printf("\tplug: %s\n", key); 
     192//                printf("\tplug: %s\n", key); 
    193193                    connection_spec->plug=strtol(key, (char **)NULL, 10); 
    194194                    xmlFree(key); 
     
    196196            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Dimension"))) { 
    197197                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    198                   printf("\tdimension: %s\n", key); 
     198//                printf("\tdimension: %s\n", key); 
    199199                    connection_spec->dimension=strtol(key, (char **)NULL, 10); 
    200200                    xmlFree(key); 
     
    202202            if ((!xmlStrcmp(cur->name, (const xmlChar *)"Samplerate"))) { 
    203203                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    204                   printf("\tsamplerate: %s\n", key); 
     204//                printf("\tsamplerate: %s\n", key); 
    205205                    connection_spec->samplerate=strtol(key, (char **)NULL, 10); 
    206206                    xmlFree(key); 
     
    240240        cur = node->xmlChildrenNode; 
    241241        while (cur != NULL) { 
    242               printf("%s\n",cur->name); 
     242//            printf("%s\n",cur->name); 
    243243                 
    244244                if ((!xmlStrcmp(cur->name, (const xmlChar *)"Connection"))) { 
    245245                        connection_info->nb_connections=connection_info->nb_connections+1; 
    246                       printf("nb_connections: %d\n", connection_info->nb_connections); 
     246//                    printf("nb_connections: %d\n", connection_info->nb_connections); 
    247247                } 
    248248                 
    249249                if ((!xmlStrcmp(cur->name, (const xmlChar *)"Direction"))) { 
    250250                        key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 
    251                       printf("\tdirection: %s\n", key); 
     251//                    printf("\tdirection: %s\n", key); 
    252252                        connection_info->direction=strtol(key, (char **)NULL, 10); 
    253253                        xmlFree(key); 
     
    354354        connection_info=freebobctl_xmlparse_connectionset (doc, cur); 
    355355         
    356         freebobctl_print_connection_info(connection_info); 
     356        //freebobctl_print_connection_info(connection_info); 
    357357 
    358358        return connection_info;