$Log$
+ Revision 591.59 2002/06/29 15:55:07 error
+ * Convert whobbs, serv_info, misc. functions to new IPC code
+
Revision 591.58 2002/06/27 03:10:04 error
* rooms.c: converted most functions to new IPC code
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
logging.c messages.c msgbase.c msgform.c serv_spam.c \
policy.c readlog.c migratenet.c screen.c serv_mrtg.c \
room_ops.c rooms.c routines.c routines2.c serv_chat.c serv_crypto.c \
- serv_info.c serv_test.c setup.c snprintf.c stats.c serv_vcard.c \
+ serv_test.c setup.c snprintf.c stats.c serv_vcard.c \
support.c sysdep.c tools.c user_ops.c userlist.c serv_expire.c \
whobbs.c sendcommand.c mime_parser.c base64.c getutline.c \
auth.c chkpwd.c html.c vcard.c serv_upgrade.c serv_vandelay.c \
citadel$(EXEEXT): ipc_c_tcp.o citadel.o rooms.o routines.o \
routines2.o messages.o screen.o citadel_ipc.o \
client_passwords.o md5.o client_crypto.o \
- commands.o client_chat.o serv_info.o tools.o $(LIBOBJS)
+ commands.o client_chat.o tools.o $(LIBOBJS)
$(CC) ipc_c_tcp.o citadel.o rooms.o routines.o \
routines2.o messages.o screen.o citadel_ipc.o \
- commands.o client_chat.o serv_info.o tools.o \
+ commands.o client_chat.o tools.o \
client_passwords.o md5.o client_crypto.o \
$(LIBOBJS) $(LDFLAGS) -o citadel $(LIBS)
chkpwd: chkpwd.o auth.o config.o
$(CC) chkpwd.o auth.o config.o $(LDFLAGS) -o chkpwd $(chkpwd_LIBS)
-whobbs$(EXEEXT): whobbs.o ipc_c_tcp.o tools.o client_crypto.o $(LIBOBJS)
- $(CC) whobbs.o ipc_c_tcp.o tools.o client_crypto.o $(LIBOBJS) $(LDFLAGS) -o whobbs $(LIBS)
+whobbs$(EXEEXT): whobbs.o ipc_c_tcp.o tools.o client_crypto.o citadel_ipc.o $(LIBOBJS)
+ $(CC) whobbs.o ipc_c_tcp.o tools.o client_crypto.o citadel_ipc.o $(LIBOBJS) $(LDFLAGS) -o whobbs $(LIBS)
migratenet$(EXEEXT): migratenet.o config.o ipc_c_tcp.o client_crypto.o tools.o libcitserver.la $(LIBOBJS)
$(LIBTOOL) $(CC) migratenet.o config.o ipc_c_tcp.o client_crypto.o tools.o libcitserver.la $(LIBOBJS) $(LDFLAGS) -o migratenet $(LIBS)
#include "citadel.h"
#include "axdefs.h"
-#include "serv_info.h"
#include "routines.h"
#include "routines2.h"
#include "rooms.h"
char floor_mode;
char curr_floor = 0; /* number of current floor */
char floorlist[128][SIZ]; /* names of floors */
-char express_msgs = 0; /* express messages waiting! */
int termn8 = 0; /* Set to nonzero to cause a logoff */
int secure; /* Set to nonzero when wire is encrypted */
+extern char express_msgs; /* express messages waiting! */
extern int rc_ansi_color; /* ansi color value from citadel.rc */
extern int next_lazy_cmd;
*/
void get_serv_info(char *supplied_hostname)
{
- char buf[512];
+ char buf[SIZ];
- CtdlInternalGetServInfo(&serv_info);
+ CtdlIPCServerInfo(&serv_info, buf);
/* be nice and identify ourself to the server */
CtdlIPCIdentifySoftware(SERVER_TYPE, 0, REV_LEVEL,
time_t idletime, idlehours, idlemins, idlesecs;
int last_session = (-1);
int skipidle = 0;
+ char *listing = NULL;
+ int r; /* IPC response code */
if (longlist == 2) {
longlist = 0;
color(DIM_WHITE);
pprintf("--- --- ------------------------- -------------------- ------------------------\n");
}
- serv_puts("RWHO");
- serv_gets(buf);
- if (buf[0] == '1') {
- while (serv_gets(buf), strcmp(buf, "000")) {
- int isidle = 0;
+ r = CtdlIPCOnlineUsers(&listing, &timenow, buf);
+ if (r / 100 == 1) {
+ while (strlen(listing) > 0) {
+ int isidle = 0;
+
+ /* Get another line */
+ extract_token(buf, listing, 0, '\n');
+ remove_token(listing, 0, '\n');
+
extract(username, buf, 1);
extract(roomname, buf, 2);
extract(fromhost, buf, 3);
strcat(roomname, " ");
}
strcpy(&roomname[14], "[idle]");
- if (skipidle)
- isidle = 1;
+ if (skipidle)
+ isidle = 1;
}
if (longlist) {
-
extract(actual_user, buf, 8);
extract(actual_room, buf, 9);
extract(actual_host, buf, 10);
#ifdef THREADED_CLIENT
pthread_mutex_t rwlock;
#endif
-extern char express_msgs;
+char express_msgs = 0;
static volatile int download_in_progress = 0; /* download file open */
static volatile int upload_in_progress = 0; /* upload file open */
{
char aaa[128];
- register int ret;
-
- netio_lock();
- serv_puts("NOOP");
- serv_gets(aaa);
- ret = atoi(aaa);
- netio_unlock();
- return ret;
+ return CtdlIPCGenericCommand("NOOP", NULL, 0, NULL, NULL, aaa);
}
if (ret / 100 == 1) {
if (!as_mime) {
while (strlen(bbb) > 4 && bbb[4] == '=') {
- int a;
-
extract_token(aaa, bbb, 0, '\n');
- a = strlen(aaa);
- safestrncpy(bbb, &bbb[a + 1], strlen(bbb) - a);
+ remove_token(bbb, 0, '\n');
if (!strncasecmp(aaa, "nhdr=yes", 8))
mret[0]->nhdr = 1;
}
}
/* Eliminate "text\n" */
- safestrncpy(bbb, &bbb[5], strlen(bbb) - 4);
+ remove_token(bbb, 0, '\n');
}
if (strlen(bbb)) {
/* Strip trailing whitespace */
/* INFO */
-int CtdlIPCServerInfo(char **listing, char *cret)
+int CtdlIPCServerInfo(struct CtdlServInfo *ServInfo, char *cret)
{
register int ret;
size_t bytes;
+ char *listing = NULL;
+ char buf[SIZ];
if (!cret) return -2;
- if (!listing) return -2;
- if (*listing) return -2;
+ if (!ServInfo) return -2;
+
+ ret = CtdlIPCGenericCommand("INFO", NULL, 0, &listing, &bytes, cret);
+ if (ret / 100 == 1) {
+ int line = 0;
+
+ while (*listing && strlen(listing)) {
+ extract_token(buf, listing, 0, '\n');
+ remove_token(listing, 0, '\n');
+ switch (line++) {
+ case 0: ServInfo->serv_pid = atoi(buf);
+ break;
+ case 1: strcpy(ServInfo->serv_nodename,buf);
+ break;
+ case 2: strcpy(ServInfo->serv_humannode,buf);
+ break;
+ case 3: strcpy(ServInfo->serv_fqdn,buf);
+ break;
+ case 4: strcpy(ServInfo->serv_software,buf);
+ break;
+ case 5: ServInfo->serv_rev_level = atoi(buf);
+ break;
+ case 6: strcpy(ServInfo->serv_bbs_city,buf);
+ break;
+ case 7: strcpy(ServInfo->serv_sysadm,buf);
+ break;
+ case 9: strcpy(ServInfo->serv_moreprompt,buf);
+ break;
+ case 10: ServInfo->serv_ok_floors = atoi(buf);
+ break;
+ case 11: ServInfo->serv_paging_level = atoi(buf);
+ break;
+ case 13: ServInfo->serv_supports_qnop = atoi(buf);
+ break;
+ }
+ }
- ret = CtdlIPCGenericCommand("INFO", NULL, 0, listing, &bytes, cret);
+ }
return ret;
}
int CtdlIPCGetSingleMessage(long msgnum, int headers, int as_mime,
struct ctdlipcmessage **mret, char *cret);
int CtdlIPCWhoKnowsRoom(char **listing, char *cret);
-int CtdlIPCServerInfo(char **listing, char *cret);
+int CtdlIPCServerInfo(struct CtdlServInfo *ServInfo, char *cret);
int CtdlIPCReadDirectory(char **listing, char *cret);
int CtdlIPCSetLastRead(long msgnum, char *cret);
int CtdlIPCInviteUserToRoom(const char *username, char *cret);
#include <sys/types.h>
#include "citadel.h"
#include "client_crypto.h"
+#include "citadel_ipc.h"
#include "ipc.h"
#ifdef HAVE_OPENSSL
{
#ifdef HAVE_OPENSSL
int a;
+ int r; /* IPC response code */
char buf[SIZ];
SSL_METHOD *ssl_method;
DH *dh;
serv_puts("STLS");
serv_gets(buf);
if (buf[0] != '2') {
- error_printf("Server can't start TLS: %s\n", &buf[4]);
+ error_printf("Server can't start TLS: %s\n", buf);
return 0;
}
+ /* New code
+ r = CtdlIPCStartEncryption(buf);
+ if (r / 100 != 2) {
+ error_printf("Server can't start TLS: %s\n", buf);
+ return 0;
+ }
+ */
/* Do SSL/TLS handshake */
if ((a = SSL_connect(ssl)) < 1) {
static time_t idlet = 0;
static void really_do_keepalive(void) {
char buf[1024];
+ int r; /* IPC response code */
time(&idlet);
* wait for a response.
*/
if (keepalives_enabled == KA_YES) {
- serv_puts("NOOP");
- serv_gets(buf);
- if (buf[3] == '*') {
- express_msgs = 1;
+ r = CtdlIPCNoop();
+ if (express_msgs > 0) {
if (ok_to_interrupt == 1) {
scr_printf("\r%64s\r", "");
print_express();
int rorder;
int expire_mode = 0;
int expire_value = 0;
+ int r; /* IPC response code */
/* Fetch the existing room config */
serv_puts("GETR");
char buf[SIZ];
int expire_mode = 0;
int expire_value = 0;
+ int r; /* IPC response code */
load_floorlist();
/* Save it */
r = CtdlIPCSetMessageExpirationPolicy(1, expire_mode,
expire_value, buf);
- r = CtdlIPCEditFloor(curr_floor, &floorlist[(int)curr_floor][0]);
+ r = CtdlIPCEditFloor(curr_floor, &floorlist[(int)curr_floor][0], buf);
scr_printf("%s\n", buf);
load_floorlist();
}
*
*/
+#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "citadel.h"
+#include "citadel_ipc.h"
#include "ipc.h"
#include "tools.h"
{
char buf[512];
char nodetitle[SIZ];
- int a;
int www = 0;
int s_pid = 0;
int my_pid = 0;
char s_room[SIZ];
char s_host[SIZ];
char s_client[SIZ];
+ int r; /* IPC response code */
+ time_t timenow;
+ char *listing = NULL;
+ struct CtdlServInfo *serv_info = NULL;
/* If this environment variable is set, we assume that the program
* is being called as a cgi-bin from a webserver and will output
logoff(atoi(buf));
}
strcpy(nodetitle, "this BBS");
- serv_puts("INFO");
- serv_gets(buf);
- if (buf[0]=='1') {
- a = 0;
- while (serv_gets(buf), strcmp(buf,"000")) {
- if (a==0) my_pid = atoi(buf);
- if (a==2) strcpy(nodetitle, buf);
- ++a;
- }
- }
+ r = CtdlIPCServerInfo(serv_info, buf);
+ if (r / 100 == 1) {
+ my_pid = serv_info->serv_pid;
+ strcpy(nodetitle, serv_info->serv_humannode);
+ }
if (www) {
printf( "Content-type: text/html\n"
printf("</H1>\n");
}
- serv_puts("RWHO");
- serv_gets(buf);
- if (buf[0]!='1') {
- fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
+ r = CtdlIPCOnlineUsers(&listing, &timenow, buf);
+ if (r / 100 != 1) {
+ fprintf(stderr,"%s: %s\n",argv[0], buf);
logoff(atoi(buf));
}
printf( "Session User name "
"Room From host\n");
printf( "------- ------------------------- "
- "-------------------- ------------------------\n");
+ "------------------- ------------------------\n");
}
- while (serv_gets(buf), strcmp(buf,"000")) {
+ while (strlen(listing) > 0) {
+ extract_token(buf, listing, 0, '\n');
+ remove_token(listing, 0, '\n');
/* Escape some stuff if we're using www mode */
if (www) escapize(buf, sizeof buf);
"once per minute)</FONT>\n"
"</BODY></HTML>\n");
- serv_puts("QUIT");
- serv_gets(buf);
- return 0;
- }
+ r = CtdlIPCQuit();
+ return (r / 100 == 2) ? 0 : r;
+}
#ifndef HAVE_STRERROR