From: Art Cancro Date: Thu, 6 Aug 1998 03:03:45 +0000 (+0000) Subject: Second attempt at getting the server API started. Now it runs X-Git-Tag: v7.86~8395 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=33d1454b258ae3b7a3c3945cecd082960bb2f087;p=citadel.git Second attempt at getting the server API started. Now it runs outside of the server and builds a connection. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 3e6160f52..2b23cbd4a 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,3 +1,7 @@ +Wed Aug 5 23:02:22 EDT 1998 Art Cancro + * Second attempt at getting the server API started. Now it runs + outside of the server and builds a connection. + Tue Aug 4 18:33:06 EDT 1998 Art Cancro * Modified the appearance of Internet addresses when they arrive on a Citadel system. diff --git a/citadel/Makefile.in b/citadel/Makefile.in index 4697f0938..2f718332d 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -61,12 +61,10 @@ client_chat.o: client_chat.c citadel.h citserver: citserver.o user_ops.o support.o room_ops.o file_ops.o \ msgbase.o config.o sysdep.o locate_host.o serv_chat.o \ - hooks.o housekeeping.o database.o control.o logging.o \ - serverapi.o + hooks.o housekeeping.o database.o control.o logging.o $(CC) $(CFLAGS) citserver.o user_ops.o room_ops.o file_ops.o support.o \ msgbase.o config.o sysdep.o locate_host.o serv_chat.o \ hooks.o housekeeping.o database.o control.o logging.o \ - serverapi.o \ $(LFLAGS) $(SERVER_LFLAGS) -o citserver citserver.o: citserver.c citadel.h @@ -108,9 +106,6 @@ control.o: control.c citadel.h logging.o: logging.c citadel.h $(CC) $(CFLAGS) -D_REENTRANT -c logging.c -serverapi.o: serverapi.c citadel.h - $(CC) $(CFLAGS) -D_REENTRANT -c serverapi.c - config.o: config.c config_decls.h citadel.h axdefs.h $(CC) -O $(CFLAGS) -D_REENTRANT -c config.c diff --git a/citadel/serverapi.c b/citadel/serverapi.c index 8d8b41ab8..86d4cb9d8 100644 --- a/citadel/serverapi.c +++ b/citadel/serverapi.c @@ -5,59 +5,115 @@ #include #include #include -#include #include "citadel.h" -#include "server.h" -#include "proto.h" -int CtdlGetLastError() { - return(CC->CtdlErrno); +struct CtdlServerHandle { + char ServerAddress[64]; + int ServerPort; + char ipgmSecret[32]; + char UserName[32]; + char Password[32]; + char InitialRoom[32]; + int AssocClientSession; + }; + +struct CtdlServerHandle CtdlMyHandle; + + +void logoff(exitcode) { + exit(exitcode); } -int CtdlInternalGetUser(char *UserName, struct usersupp *usbuf) { - if ( (strlen(UserName)==0) || (!strcasecmp(UserName,CC->curr_user)) ) { - if (!CC->logged_in) { - CC->CtdlErrno = ERROR+NOT_LOGGED_IN; - return(-1); - } - memcpy(usbuf, &CC->usersupp, sizeof(struct usersupp)); - return(0); - } - else { - if (getuser(usbuf, UserName) != 0) { - CC->CtdlErrno = ERROR+NO_SUCH_USER; - return(-1); - } - else { - CC->CtdlErrno = 0; - return(0); - } +/* + * Programs linked against the Citadel server extension library need to + * be called with the following arguments: + * 0 - program name (as always) + * 1 - server address (usually 127.0.0.1) + * 2 - server port number + * 3 - internal program secret + * 4 - user name + * 5 - user password + * 6 - initial room + * 7 - associated client session + * + */ + +main(argc, argv) +int argc; +char *argv[]; { + int a; + char buf[256]; + + /* We're really not interested in stdio */ + close(0); + close(1); + close(2); + + /* Bail out if someone tries to run this thing manually */ + if (argc < 3) exit(1); + + /* Zeroing out the server handle neatly sets the values of + * CtdlMyHandle to sane default values + */ + bzero(&CtdlMyHandle, sizeof(struct CtdlServerHandle)); + + /* Now parse the command-line arguments fed to us by the server */ + for (a=0; a 0) { + sprintf(buf, "IPGM %s", CtdlMyHandle.ipgmSecret); + serv_puts(buf); + serv_gets(buf); + } + + if (strlen(CtdlMyHandle.UserName) > 0) { + sprintf(buf, "USER %s", CtdlMyHandle.UserName); + serv_puts(buf); + serv_gets(buf); + sprintf(buf, "PASS %s", CtdlMyHandle.Password); + serv_puts(buf); + serv_gets(buf); + } + + sprintf(buf, "GOTO %s", CtdlMyHandle.InitialRoom); + serv_puts(buf); + serv_gets(buf); + if (buf[0] != '2') { + serv_puts("GOTO _BASEROOM_"); + serv_gets(buf); + } -time_t CtdlGetUserLastCall(char *UserName) { - struct usersupp usbuf; + /* Now do the loop. */ + sleep(10); - return( (CtdlInternalGetUser(UserName, &usbuf)==0) - ? usbuf.lastcall - : (-1L) - ); + /* Clean up gracefully and exit. */ + serv_puts("QUIT"); + exit(0); } diff --git a/citadel/sysdep.c b/citadel/sysdep.c index cda0b0b93..34090f179 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -429,7 +429,7 @@ int client_gets(char *buf) * The system-dependent part of master_cleanup() - close the master socket. */ void sysdep_master_cleanup(void) { - lprintf(3, "Closing master socket %d\n", msock); + lprintf(7, "Closing master socket %d\n", msock); close(msock); } diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index 1cc3c2144..9979b4829 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -505,7 +505,8 @@ even if your proprietary extensions aren't supported. -> Please contact Art Cancro and obtain a unique server type code, which can be assigned to your server program. -> If you document what you did in detail, perhaps it can be added to a -future release of the Citadel/UX program, so everyone can enjoy it. +future release of the Citadel/UX program, so everyone can enjoy it. Better +yet, just work with the Citadel development team on the main source tree. If everyone follows this scheme, we can avoid a chaotic situation with lots of confusion about which client program works with which server, etc. Client