Changeset 538 for trunk/src/ocatctrl.c


Ignore:
Timestamp:
01/24/10 19:55:24 (2 years ago)
Author:
eagle
Message:
  • options are parsed sequentially (-f and -I first)
  • config file is always read from SYSCONFDIR (usually /etc or /usr/local/etc)
  • changed Makefile.am to not install header files
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ocatctrl.c

    r535 r538  
    3838   int fd, c; 
    3939   FILE *ff, *fo; 
    40    char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[NDESC(name_size)], timestr[32], *s, *tokbuf; 
     40   char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[NDESC(name_size)], timestr[32], *s, *tokbuf, *bufp; 
    4141   int rlen, cfd; 
    4242   struct tm *tm; 
     
    7272      } 
    7373      log_debug("fd %d fdopen'ed \"r\"", fd); 
    74       fo = CNF(logf); 
     74      fo = CNF(logf) ? CNF(logf) : stderr; 
    7575      //CNF(config_read) = 1; 
    7676   } 
     
    133133         continue; 
    134134 
    135       if (!strtok_r(buf, " \t\r\n", &tokbuf)) 
     135      if (!(bufp = strtok_r(buf, " \t\r\n", &tokbuf))) 
    136136         continue; 
    137137 
    138138      // "exit"/"quit" => terminate thread 
    139       if (!strncmp(buf, "exit", 4) || !strncmp(buf, "quit", 4)) 
     139      if (!strncmp(bufp, "exit", 4) || !strncmp(bufp, "quit", 4)) 
    140140         break; 
    141141      // "status" 
    142       else if (!strcmp(buf, "status")) 
     142      else if (!strcmp(bufp, "status")) 
    143143      { 
    144144         lock_peers(); 
     
    159159         unlock_peers(); 
    160160      } 
    161       else if (!strcmp(buf, "close")) 
    162       { 
    163          cfd = atoi(&buf[6]); 
     161      else if (!strcmp(bufp, "close")) 
     162      { 
     163         cfd = atoi(bufp +6); 
    164164         lock_peers(); 
    165165         for (peer = get_first_peer(); peer; peer = peer->next) 
     
    178178         unlock_peers(); 
    179179      } 
    180       else if (!strcmp(buf, "threads")) 
     180      else if (!strcmp(bufp, "threads")) 
    181181      { 
    182182         print_threads(ff); 
    183183      } 
    184       else if (!strcmp(buf, "terminate")) 
     184      else if (!strcmp(bufp, "terminate")) 
    185185      { 
    186186         log_msg(LOG_INFO, "terminate request from control port"); 
    187187         kill(getpid(), SIGINT); 
    188188      } 
    189       else if (!strcmp(buf, "route")) 
     189      else if (!strcmp(bufp, "route")) 
    190190      { 
    191191         if (rlen > 6) 
    192192         { 
    193             if ((c = parse_route(&buf[6])) == E_RT_SYNTAX) 
    194                if ((c = ipv6_parse_route(&buf[6])) > 0) 
     193            if ((c = parse_route(bufp + 6)) == E_RT_SYNTAX) 
     194               if ((c = ipv6_parse_route(bufp + 6)) > 0) 
    195195                  c = 0; 
    196196            switch (c) 
     
    224224         } 
    225225      } 
    226       else if (!strcmp(buf, "connect")) 
     226      else if (!strcmp(bufp, "connect")) 
    227227      { 
    228228         if ((s = strtok_r(NULL, " \t\r\n", &tokbuf))) 
    229229         { 
    230230            if ((strlen(s) != 16) || (oniontipv6(s, &in6) == -1)) 
    231                fprintf(ff, "ERR \"%s\" not valid .onion-URL\n", &buf[8]); 
     231               fprintf(ff, "ERR \"%s\" not valid .onion-URL\n", bufp + 8); 
    232232            else 
    233233            { 
     
    243243            fprintf(ff, "ERR missing args\n"); 
    244244      } 
    245       else if (!strcmp(buf, "macs")) 
     245      else if (!strcmp(bufp, "macs")) 
    246246      { 
    247247         print_mac_tbl(ff); 
    248248      } 
    249       else if (!strcmp(buf, "queue")) 
     249      else if (!strcmp(bufp, "queue")) 
    250250      { 
    251251         print_socks_queue((FILE*) (long) pfd[1]); 
     
    258258         } 
    259259      } 
    260       else if (!strcmp(buf, "setup")) 
     260      else if (!strcmp(bufp, "setup")) 
    261261      { 
    262262         print_setup_struct(ff); 
    263263      } 
    264       else if (!strcmp(buf, "version")) 
     264      else if (!strcmp(bufp, "version")) 
    265265      { 
    266266         fprintf(ff, "%s\n", CNF(version)); 
    267267      } 
    268       else if (!strcmp(buf, "help") || !strcmp(buf, "?")) 
     268      else if (!strcmp(bufp, "help") || !strcmp(bufp, "?")) 
    269269      { 
    270270         fprintf(fo, 
Note: See TracChangeset for help on using the changeset viewer.