/* * This is the sending side of the chat window. The form is designed to transmit asynchronously. */ void chat_send(void) { char send_this[SIZ]; char buf[SIZ]; begin_ajax_response(); if (havebstr("send_this")) { strcpy(send_this, bstr("send_this")); } else { strcpy(send_this, ""); } if (havebstr("exit_button")) { strcpy(send_this, "/quit"); } if (!IsEmptyStr(send_this)) { serv_puts("RCHT send"); serv_getln(buf, sizeof buf); if (buf[0] == '4') { text_to_server(send_this); serv_puts("000"); } } end_ajax_response(); }
/* * Wraps a Citadel server command in an AJAX transaction. */ void ajax_servcmd(void) { wcsession *WCC = WC; int Done = 0; StrBuf *Buf; char *junk; size_t len; if (verbose) syslog(LOG_DEBUG, "ajax_servcmd() g_cmd=\"%s\"", bstr("g_cmd") ); begin_ajax_response(); Buf = NewStrBuf(); serv_puts(bstr("g_cmd")); StrBuf_ServGetln(Buf); StrBufAppendBuf(WCC->WBuf, Buf, 0); StrBufAppendBufPlain(WCC->WBuf, HKEY("\n"), 0); switch (GetServerStatus(Buf, NULL)) { case 8: serv_puts("\n\n000"); if ( (StrLength(Buf)==3) && !strcmp(ChrPtr(Buf), "000")) { StrBufAppendBufPlain(WCC->WBuf, HKEY("\000"), 0); break; } case 1: while (!Done) { if (StrBuf_ServGetln(Buf) < 0) break; if ( (StrLength(Buf)==3) && !strcmp(ChrPtr(Buf), "000")) { Done = 1; } StrBufAppendBuf(WCC->WBuf, Buf, 0); StrBufAppendBufPlain(WCC->WBuf, HKEY("\n"), 0); } break; case 4: text_to_server(bstr("g_input")); serv_puts("000"); break; case 6: len = atol(&ChrPtr(Buf)[4]); StrBuf_ServGetBLOBBuffered(Buf, len); break; case 7: len = atol(&ChrPtr(Buf)[4]); junk = malloc(len); memset(junk, 0, len); serv_write(junk, len); free(junk); } end_ajax_response(); /* * This is kind of an ugly hack, but this is the only place it can go. * If the command was GEXP, then the instant messenger window must be * running, so reset the "last_pager_check" watchdog timer so * that page_popup() doesn't try to open it a second time. TODO: page_popup isn't with us anymore. */ if (!strncasecmp(bstr("g_cmd"), "GEXP", 4)) { WCC->last_pager_check = time(NULL); } FreeStrBuf(&Buf); }