src/main.c
changeset 16 33245bf7873a
parent 15 f19c1f9b4cd3
child 17 9a32b5242320
equal deleted inserted replaced
15:f19c1f9b4cd3 16:33245bf7873a
    21 
    21 
    22 #ifndef LOCALE_PATH
    22 #ifndef LOCALE_PATH
    23 #define LOCALE_PATH "/var/lib/nobody/data/locale"
    23 #define LOCALE_PATH "/var/lib/nobody/data/locale"
    24 #endif
    24 #endif
    25 
    25 
       
    26 short active = 1;               /* needed for a safe shutdown */
       
    27 
    26 void sigproc ()
    28 void sigproc ()
    27 {
    29 {
    28     signal (SIGTERM, sigproc);
    30     signal (SIGTERM, sigproc);
       
    31     active = 0;
    29 }
    32 }
    30 
    33 
    31 int main (int argc, char **argv)
    34 int main (int argc, char **argv)
    32 {
    35 {
    33     UC uc;
    36     UC uc;
    89             fprintf (message.stream, "TOPIC %s :%s\r\n", uc.channel, uc.topic);
    92             fprintf (message.stream, "TOPIC %s :%s\r\n", uc.channel, uc.topic);
    90     }
    93     }
    91 
    94 
    92     while (!feof (message.stream)) {
    95     while (!feof (message.stream)) {
    93         *buf = '\0';
    96         *buf = '\0';
    94         fgets (buf, 512, message.stream);
    97 
       
    98         if (active)             /* SIGPROC */
       
    99             fgets (buf, 512, message.stream);
       
   100         else
       
   101             break;
    95 
   102 
    96         if ((command = irc_parsemessage (buf, &message))) {
   103         if ((command = irc_parsemessage (buf, &message))) {
    97             printf ("%10s %s %s\n", command, message.channel, message.line);
   104             printf ("%10s %s %s\n", command, message.channel, message.line);
    98             if (!strcmp (command, "ERROR") || !strcmp (command, "ENOMEM"))
   105             if (!strcmp (command, "ERROR") || !strcmp (command, "ENOMEM"))
    99                 break;
   106                 break;