src/main.c
changeset 9 aff6726b8b87
parent 8 3152de03758e
child 10 311ea5fa60dd
equal deleted inserted replaced
8:3152de03758e 9:aff6726b8b87
    88 
    88 
    89     signal (SIGTERM, sigproc);
    89     signal (SIGTERM, sigproc);
    90 
    90 
    91     if (uc.channel) {
    91     if (uc.channel) {
    92         fprintf (message.stream, "JOIN :%s\r\n", uc.channel);
    92         fprintf (message.stream, "JOIN :%s\r\n", uc.channel);
       
    93         message.current_channel = uc.channel;
    93         if (uc.topic)
    94         if (uc.topic)
    94             fprintf (message.stream, "TOPIC %s :%s\r\n", uc.channel, uc.topic);
    95             fprintf (message.stream, "TOPIC %s :%s\r\n", uc.channel, uc.topic);
    95     }
    96     }
    96 
    97 
    97     while (!feof (message.stream)) {
    98     while (!feof (message.stream)) {
    99         *buf = 0;
   100         *buf = 0;
   100         fgets (buf, 512, message.stream);
   101         fgets (buf, 512, message.stream);
   101 
   102 
   102         if ((command = irc_parsemessage (buf, &message))) {
   103         if ((command = irc_parsemessage (buf, &message))) {
   103             printf ("%10s %s %s\n", command, message.channel, message.line);
   104             printf ("%10s %s %s\n", command, message.channel, message.line);
       
   105             if (!strcmp (command, "ERROR"))
       
   106                 break;
   104         } else {
   107         } else {
   105             if ((msg = parse (&message)) != NULL) {
   108             if ((msg = parse (&message)) != NULL) {
   106                 fprintf (message.stream, "%s\r\n", msg);
   109                 fprintf (message.stream, "%s\r\n", msg);
   107                 printf ("%10s %s", "WRITE", msg);
   110                 printf ("%10s %s", "WRITE", msg);
   108             }
   111             }