- /*
- * See if there is any chat data waiting.
- */
- do {
- got_data = 0;
- pf.fd = WC->chat_sock;
- pf.events = POLLIN;
- pf.revents = 0;
- if (poll(&pf, 1, 1) > 0) if (pf.revents & POLLIN) {
- ++got_data;
-
- for (i=0; i<CHATLINES-1; ++i) {
- strcpy(WC->chatlines[i], WC->chatlines[i+1]);
- }
-
- /* Temporarily swap the serv and chat sockets during chat talk */
- i = WC->serv_sock;
- WC->serv_sock = WC->chat_sock;
- WC->chat_sock = i;
-
- serv_gets(WC->chatlines[CHATLINES-1]);
- if (!strcmp(WC->chatlines[CHATLINES-1], "000")) {
- end_chat_now = 1;
- strcpy(WC->chatlines[CHATLINES-1], ":|exiting chat mode");
- }
-
- /* Unswap the sockets. */
- i = WC->serv_sock;
- WC->serv_sock = WC->chat_sock;
- WC->chat_sock = i;
- }
- } while ( (got_data) && (!end_chat_now) );
-
- /*
- * Display appropriately.
- */
- for (i=0; i<CHATLINES; ++i) {
- if (strlen(WC->chatlines[i]) > 0) {
- extract(name, WC->chatlines[i], 0);
- extract(text, WC->chatlines[i], 1);
- if (!strcasecmp(name, WC->wc_username)) {
- wprintf("<FONT COLOR=\"#00FF00\">");
- }
- else if (!strcmp(name, ":")) {
- wprintf("<FONT COLOR=\"#FF0000\">");
- }
- else {
- wprintf("<FONT COLOR=\"#0000FF\">");
- }
- escputs(name);
- wprintf(": </FONT>");
- escputs(text);
- wprintf("<BR>\n");
- }
- }