89 if (uc.topic) |
90 if (uc.topic) |
90 fprintf (message.stream, "TOPIC %s :%s\r\n", uc.channel, uc.topic); |
91 fprintf (message.stream, "TOPIC %s :%s\r\n", uc.channel, uc.topic); |
91 } |
92 } |
92 |
93 |
93 while (!feof (message.stream)) { |
94 while (!feof (message.stream)) { |
94 *buf = '\0'; |
95 fgets (buf, sizeof (buf), message.stream); |
95 fgets (buf, 512, message.stream); |
|
96 |
96 |
97 if (!active) /* the bot was killed with SIGTERM */ |
97 if (!active) /* the bot was killed with SIGTERM */ |
98 break; |
98 break; |
99 |
99 |
100 if ((command = irc_parsemessage (buf, &message))) { |
100 if ((command = irc_parsemessage (buf, &message))) { |
|
101 if (!strcmp (command, "ERROR") || !strcmp (command, "ENOMEM")) |
|
102 break; |
101 printf ("%10s %s %s\n", command, message.channel, message.line); |
103 printf ("%10s %s %s\n", command, message.channel, message.line); |
102 if (!strcmp (command, "ERROR") || !strcmp (command, "ENOMEM")) { |
|
103 break; |
|
104 } |
|
105 } else { |
104 } else { |
106 if ((msg = parse (&message)) != NULL) { |
105 if ((msg = parse (&message)) != NULL) { |
107 fprintf (message.stream, "%s\r\n", msg); |
106 fprintf (message.stream, "%s\r\n", msg); |
108 fflush (message.stream); |
107 fflush (message.stream); |
109 printf ("%10s %s", "WRITE", msg); |
108 printf ("%10s %s", "WRITE", msg); |
110 } |
109 } |
111 } |
110 } |
|
111 fflush (stdout); |
112 } |
112 } |
113 printf ("\n\nClosing Connection\n\n"); |
113 printf ("\n\nClosing Connection\n\n"); |
114 fclose (message.stream); |
114 fclose (message.stream); |
115 |
115 |
116 /* |
116 /* |