4 * Main source module for the Citadel server
18 #include <sys/types.h>
22 #if TIME_WITH_SYS_TIME
23 # include <sys/time.h>
27 # include <sys/time.h>
37 /* #include <dlfcn.h> */
39 #include <sys/types.h>
40 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
45 #include "serv_extensions.h"
46 #include "sysdep_decls.h"
47 #include "citserver.h"
50 #include "housekeeping.h"
54 #include "locate_host.h"
65 struct CitContext *ContextList = NULL;
66 struct CitContext* next_session = NULL;
67 char *unique_session_numbers;
68 int ScheduledShutdown = 0;
70 time_t server_startup_time;
71 char pid_file_name[PATH_MAX];
74 * Various things that need to be initialized at startup
76 void master_startup(void) {
80 struct ctdlroom qrbuf;
83 lprintf(CTDL_DEBUG, "master_startup() started\n");
84 time(&server_startup_time);
86 /* pid file. If we go FSSTND this should end up in 'localstatedir' */
87 snprintf(pid_file_name, sizeof pid_file_name, "./citadel.pid");
88 pidfile_fp = fopen(pid_file_name, "w");
89 if (pidfile_fp != NULL) {
90 fprintf(pidfile_fp, "%d\n", (int)getpid());
94 lprintf(CTDL_INFO, "Opening databases\n");
103 lprintf(CTDL_INFO, "Creating base rooms (if necessary)\n");
104 create_room(BASEROOM, 0, "", 0, 1, 0, VIEW_BBS);
105 create_room(AIDEROOM, 3, "", 0, 1, 0, VIEW_BBS);
106 create_room(SYSCONFIGROOM, 3, "", 0, 1, 0, VIEW_BBS);
107 create_room(config.c_twitroom, 0, "", 0, 1, 0, VIEW_BBS);
109 /* The "Local System Configuration" room doesn't need to be visible */
110 if (lgetroom(&qrbuf, SYSCONFIGROOM) == 0) {
111 qrbuf.QRflags2 |= QR2_SYSTEM;
115 lprintf(CTDL_INFO, "Seeding the pseudo-random number generator...\n");
116 urandom = fopen("/dev/urandom", "r");
117 if (urandom != NULL) {
118 fread(&seed, sizeof seed, 1, urandom);
122 gettimeofday(&tv, NULL);
127 lprintf(CTDL_INFO, "Initializing ipgm secret\n");
129 config.c_ipgm_secret = rand();
132 lprintf(CTDL_DEBUG, "master_startup() finished\n");
137 * Cleanup routine to be called when the server is shutting down.
139 void master_cleanup(int exitcode) {
140 struct CleanupFunctionHook *fcn;
141 static int already_cleaning_up = 0;
143 if (already_cleaning_up) while(1) sleep(1);
144 already_cleaning_up = 1;
146 /* Run any cleanup routines registered by loadable modules */
147 for (fcn = CleanupHookTable; fcn != NULL; fcn = fcn->next) {
148 (*fcn->h_function_pointer)();
151 /* Close databases */
152 lprintf(CTDL_INFO, "Closing databases\n");
155 /* Do system-dependent stuff */
156 sysdep_master_cleanup();
158 #ifdef DEBUG_MEMORY_LEAKS
163 lprintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode);
164 fflush(stdout); fflush(stderr);
166 unlink(pid_file_name);
173 * Terminate a session and remove its context data structure.
175 void RemoveContext (struct CitContext *con)
178 lprintf(CTDL_ERR, "WARNING: RemoveContext() called with NULL!\n");
181 lprintf(CTDL_DEBUG, "RemoveContext() called\n");
183 /* Remove the context from the global context list. This needs
184 * to get done FIRST to avoid concurrency problems. It is *vitally*
185 * important to keep num_sessions accurate!!
187 lprintf(CTDL_DEBUG, "Removing context for session %d\n", con->cs_pid);
188 begin_critical_section(S_SESSION_TABLE);
190 con->prev->next = con->next;
193 ContextList = con->next;
196 con->next->prev = con->prev;
199 end_critical_section(S_SESSION_TABLE);
201 /* Run any cleanup routines registered by loadable modules.
202 * Note: We have to "become_session()" because the cleanup functions
203 * might make references to "CC" assuming it's the right one.
206 PerformSessionHooks(EVT_STOP);
207 become_session(NULL);
209 /* Now handle all of the administrivia. */
210 lprintf(CTDL_DEBUG, "Calling logout(%d)\n", con->cs_pid);
214 lprintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
216 /* If the client is still connected, blow 'em away. */
217 lprintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
218 close(con->client_socket);
220 /* This is where we used to check for scheduled shutdowns. */
222 /* Free up the memory used by this context */
225 lprintf(CTDL_DEBUG, "Done with RemoveContext()\n");
233 * cmd_info() - tell the client about this server
235 void cmd_info(void) {
236 cprintf("%d Server info:\n", LISTING_FOLLOWS);
237 cprintf("%d\n", CC->cs_pid);
238 cprintf("%s\n", config.c_nodename);
239 cprintf("%s\n", config.c_humannode);
240 cprintf("%s\n", config.c_fqdn);
241 cprintf("%s\n", CITADEL);
242 cprintf("%d\n", REV_LEVEL);
243 cprintf("%s\n", config.c_bbs_city);
244 cprintf("%s\n", config.c_sysadm);
245 cprintf("%d\n", SERVER_TYPE);
246 cprintf("%s\n", config.c_moreprompt);
247 cprintf("1\n"); /* 1 = yes, this system supports floors */
248 cprintf("1\n"); /* 1 = we support the extended paging options */
249 cprintf("%s\n", CC->cs_nonce);
250 cprintf("1\n"); /* 1 = yes, this system supports the QNOP command */
252 cprintf("1\n"); /* 1 = yes, this server is LDAP-enabled */
254 cprintf("0\n"); /* 1 = no, this server is not LDAP-enabled */
261 * returns an asterisk if there are any instant messages waiting,
264 char CtdlCheckExpress(void) {
265 if (CC->FirstExpressMessage == NULL) {
279 localtime_r(&tv, &tmp);
281 /* timezone and daylight global variables are not portable. */
282 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
283 cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst);
285 cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst);
291 * Check originating host against the public_clients file. This determines
292 * whether the client is allowed to change the hostname for this session
293 * (for example, to show the location of the user rather than the location
296 int is_public_client(void)
303 static time_t pc_timestamp = 0;
304 static char public_clients[SIZ];
306 #define PUBLIC_CLIENTS "./public_clients"
309 * Check the time stamp on the public_clients file. If it's been
310 * updated since the last time we were here (or if this is the first
311 * time we've been through the loop), read its contents and learn
312 * the IP addresses of the listed hosts.
314 if (stat(PUBLIC_CLIENTS, &statbuf) != 0) {
315 /* No public_clients file exists, so bail out */
316 lprintf(CTDL_WARNING, "Warning: '%s' does not exist\n", PUBLIC_CLIENTS);
320 if (statbuf.st_mtime > pc_timestamp) {
321 begin_critical_section(S_PUBLIC_CLIENTS);
322 lprintf(CTDL_INFO, "Loading %s\n", PUBLIC_CLIENTS);
324 strcpy(public_clients, "127.0.0.1");
325 if (hostname_to_dotted_quad(addrbuf, config.c_fqdn) == 0) {
326 strcat(public_clients, "|");
327 strcat(public_clients, addrbuf);
330 fp = fopen("public_clients", "r");
331 if (fp != NULL) while (fgets(buf, sizeof buf, fp)!=NULL) {
332 for (i=0; i<strlen(buf); ++i) {
333 if (buf[i] == '#') buf[i] = 0;
335 while (isspace((buf[strlen(buf)-1]))) {
336 buf[strlen(buf)-1] = 0;
338 if (hostname_to_dotted_quad(addrbuf, buf) == 0) {
339 if ((strlen(public_clients) +
341 < sizeof(public_clients)) {
342 strcat(public_clients, addrbuf);
347 pc_timestamp = time(NULL);
348 end_critical_section(S_PUBLIC_CLIENTS);
351 lprintf(CTDL_DEBUG, "Checking whether %s is a local or public client\n",
353 for (i=0; i<num_parms(public_clients); ++i) {
354 extract(addrbuf, public_clients, i);
355 if (!strcasecmp(CC->cs_addr, addrbuf)) {
356 lprintf(CTDL_DEBUG, "... yes it is.\n");
361 /* No hits. This is not a public client. */
362 lprintf(CTDL_DEBUG, "... no it isn't.\n");
368 * the client is identifying itself to the server
370 void cmd_iden(char *argbuf)
380 if (num_parms(argbuf)<4) {
381 cprintf("%d usage error\n", ERROR + ILLEGAL_VALUE);
385 dev_code = extract_int(argbuf,0);
386 cli_code = extract_int(argbuf,1);
387 rev_level = extract_int(argbuf,2);
388 extract(desc,argbuf,3);
390 safestrncpy(from_host, config.c_fqdn, sizeof from_host);
391 from_host[sizeof from_host - 1] = 0;
392 if (num_parms(argbuf)>=5) extract(from_host,argbuf,4);
394 CC->cs_clientdev = dev_code;
395 CC->cs_clienttyp = cli_code;
396 CC->cs_clientver = rev_level;
397 safestrncpy(CC->cs_clientname, desc, sizeof CC->cs_clientname);
398 CC->cs_clientname[31] = 0;
400 if (strlen(from_host) > 0) {
401 if (CC->is_local_socket) do_lookup = 1;
402 else if (is_public_client()) do_lookup = 1;
406 lprintf(CTDL_DEBUG, "Looking up hostname '%s'\n", from_host);
407 if ((addr.s_addr = inet_addr(from_host)) != -1) {
408 locate_host(CC->cs_host, sizeof CC->cs_host,
413 safestrncpy(CC->cs_host, from_host, sizeof CC->cs_host);
414 CC->cs_host[sizeof CC->cs_host - 1] = 0;
418 lprintf(CTDL_NOTICE, "Client %d/%d/%01d.%02d (%s) from %s\n",
425 cprintf("%d Ok\n",CIT_OK);
430 * display system messages or help
432 void cmd_mesg(char *mname)
440 extract(buf,mname,0);
444 strcpy(dirs[0],"messages");
445 strcpy(dirs[1],"help");
446 snprintf(buf2, sizeof buf2, "%s.%d.%d", buf, CC->cs_clientdev, CC->cs_clienttyp);
447 mesg_locate(targ,sizeof targ,buf2,2,(const char **)dirs);
448 if (strlen(targ) == 0) {
449 snprintf(buf2, sizeof buf2, "%s.%d", buf, CC->cs_clientdev);
450 mesg_locate(targ,sizeof targ,buf2,2,(const char **)dirs);
451 if (strlen(targ) == 0) {
452 mesg_locate(targ,sizeof targ,buf,2,(const char **)dirs);
458 if (strlen(targ)==0) {
459 cprintf("%d '%s' not found.\n",ERROR + FILE_NOT_FOUND, mname);
463 mfp = fopen(targ,"r");
465 cprintf("%d Cannot open '%s': %s\n",
466 ERROR + INTERNAL_ERROR, targ, strerror(errno));
469 cprintf("%d %s\n",LISTING_FOLLOWS,buf);
471 while (fgets(buf, (SIZ-1), mfp)!=NULL) {
472 buf[strlen(buf)-1] = 0;
483 * enter system messages or help
485 void cmd_emsg(char *mname)
495 if (CtdlAccessCheck(ac_aide)) return;
497 extract(buf,mname,0);
498 for (a=0; a<strlen(buf); ++a) { /* security measure */
499 if (buf[a] == '/') buf[a] = '.';
504 strcpy(dirs[0],"messages");
505 strcpy(dirs[1],"help");
506 mesg_locate(targ,sizeof targ,buf,2,(const char**)dirs);
510 if (strlen(targ)==0) {
511 snprintf(targ, sizeof targ, "./help/%s", buf);
514 mfp = fopen(targ,"w");
516 cprintf("%d Cannot open '%s': %s\n",
517 ERROR + INTERNAL_ERROR, targ, strerror(errno));
520 cprintf("%d %s\n", SEND_LISTING, targ);
522 while (client_getln(buf, sizeof buf), strcmp(buf, "000")) {
523 fprintf(mfp, "%s\n", buf);
530 /* Don't show the names of private rooms unless the viewing
531 * user also knows the rooms.
533 void GenerateRoomDisplay(char *real_room,
534 struct CitContext *viewed,
535 struct CitContext *viewer) {
539 strcpy(real_room, viewed->room.QRname);
540 if (viewed->room.QRflags & QR_MAILBOX) {
541 strcpy(real_room, &real_room[11]);
543 if (viewed->room.QRflags & QR_PRIVATE) {
544 CtdlRoomAccess(&viewed->room, &viewer->user, &ra, NULL);
545 if ( (ra & UA_KNOWN) == 0) {
546 strcpy(real_room, "<private room>");
550 if (viewed->cs_flags & CS_CHAT) {
551 while (strlen(real_room) < 14)
552 strcat(real_room, " ");
554 strcpy(&real_room[14], "<chat>");
560 * Convenience function.
562 int CtdlAccessCheck(int required_level) {
564 if (CC->internal_pgm) return(0);
565 if (required_level >= ac_internal) {
566 cprintf("%d This is not a user-level command.\n",
567 ERROR + HIGHER_ACCESS_REQUIRED);
571 if ((required_level >= ac_logged_in) && (CC->logged_in == 0)) {
572 cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
576 if (CC->user.axlevel >= 6) return(0);
577 if (required_level >= ac_aide) {
578 cprintf("%d This command requires Aide access.\n",
579 ERROR + HIGHER_ACCESS_REQUIRED);
583 if (is_room_aide()) return(0);
584 if (required_level >= ac_room_aide) {
585 cprintf("%d This command requires Aide or Room Aide access.\n",
586 ERROR + HIGHER_ACCESS_REQUIRED);
590 /* shhh ... succeed quietly */
597 * Terminate another running session
599 void cmd_term(char *cmdbuf)
602 struct CitContext *ccptr;
606 session_num = extract_int(cmdbuf, 0);
607 if (session_num == CC->cs_pid) {
608 cprintf("%d You can't kill your own session.\n", ERROR + ILLEGAL_VALUE);
612 lprintf(CTDL_DEBUG, "Locating session to kill\n");
613 begin_critical_section(S_SESSION_TABLE);
614 for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
615 if (session_num == ccptr->cs_pid) {
617 if ((ccptr->user.usernum == CC->user.usernum)
618 || (CC->user.axlevel >= 6)) {
627 end_critical_section(S_SESSION_TABLE);
631 cprintf("%d Session terminated.\n", CIT_OK);
634 cprintf("%d You are not allowed to do that.\n",
635 ERROR + HIGHER_ACCESS_REQUIRED);
639 cprintf("%d No such session.\n", ERROR + ILLEGAL_VALUE);
648 * get the paginator prompt
650 void cmd_more(void) {
651 cprintf("%d %s\n", CIT_OK, config.c_moreprompt);
657 void cmd_echo(char *etext)
659 cprintf("%d %s\n", CIT_OK, etext);
665 * identify as internal program
667 void cmd_ipgm(char *argbuf)
671 secret = extract_int(argbuf, 0);
673 /* For security reasons, we do NOT allow this command to run
674 * over the network. Local sockets only.
676 if (!CC->is_local_socket) {
678 cprintf("%d Authentication failed.\n",
679 ERROR + PASSWORD_REQUIRED);
681 else if (secret == config.c_ipgm_secret) {
682 CC->internal_pgm = 1;
683 strcpy(CC->curr_user, "<internal program>");
684 CC->cs_flags = CC->cs_flags|CS_STEALTH;
685 cprintf("%d Authenticated as an internal program.\n", CIT_OK);
689 cprintf("%d Authentication failed.\n",
690 ERROR + PASSWORD_REQUIRED);
691 lprintf(CTDL_ERR, "Warning: ipgm authentication failed.\n");
695 /* Now change the ipgm secret for the next round.
696 * (Disabled because it breaks concurrent scripts. The fact that
697 * we no longer accept IPGM over the network should be sufficient
698 * to prevent brute-force attacks. If you don't agree, uncomment
701 config.c_ipgm_secret = rand();
708 * Shut down the server
710 void cmd_down(void) {
712 if (CtdlAccessCheck(ac_aide)) return;
714 cprintf("%d Shutting down server. Goodbye.\n", CIT_OK);
719 * Schedule or cancel a server shutdown
721 void cmd_scdn(char *argbuf)
725 if (CtdlAccessCheck(ac_aide)) return;
727 new_state = extract_int(argbuf, 0);
728 if ((new_state == 0) || (new_state == 1)) {
729 ScheduledShutdown = new_state;
731 cprintf("%d %d\n", CIT_OK, ScheduledShutdown);
736 * Set or unset asynchronous protocol mode
738 void cmd_asyn(char *argbuf)
742 new_state = extract_int(argbuf, 0);
743 if ((new_state == 0) || (new_state == 1)) {
744 CC->is_async = new_state;
746 cprintf("%d %d\n", CIT_OK, CC->is_async);
751 * Generate a "nonce" for APOP-style authentication.
753 * RFC 1725 et al specify a PID to be placed in front of the nonce.
754 * Quoth BTX: That would be stupid.
756 void generate_nonce(struct CitContext *con) {
759 memset(con->cs_nonce, NONCE_SIZE, 0);
760 gettimeofday(&tv, NULL);
761 memset(con->cs_nonce, NONCE_SIZE, 0);
762 snprintf(con->cs_nonce, NONCE_SIZE, "<%d%ld@%s>",
763 rand(), (long)tv.tv_usec, config.c_fqdn);
770 * Back-end function for starting a session
772 void begin_session(struct CitContext *con)
775 struct sockaddr_in sin;
778 * Initialize some variables specific to our context.
781 con->internal_pgm = 0;
782 con->download_fp = NULL;
783 con->upload_fp = NULL;
784 con->FirstExpressMessage = NULL;
786 time(&con->lastidle);
787 strcpy(con->lastcmdname, " ");
788 strcpy(con->cs_clientname, "(unknown)");
789 strcpy(con->curr_user, NLI);
790 strcpy(con->net_node,"");
791 strcpy(con->fake_username, "");
792 strcpy(con->fake_postname, "");
793 strcpy(con->fake_hostname, "");
794 strcpy(con->fake_roomname, "");
796 safestrncpy(con->temp, tmpnam(NULL), sizeof con->temp);
797 safestrncpy(con->cs_host, config.c_fqdn, sizeof con->cs_host);
798 safestrncpy(con->cs_addr, "", sizeof con->cs_addr);
799 con->cs_host[sizeof con->cs_host - 1] = 0;
801 if (!CC->is_local_socket) {
802 if (!getpeername(con->client_socket,
803 (struct sockaddr *) &sin, &len)) /* should be socklen_t but doesn't work on Macintosh */
804 locate_host(con->cs_host, sizeof con->cs_host,
805 con->cs_addr, sizeof con->cs_addr,
809 strcpy(con->cs_host, "");
812 con->upload_type = UPL_FILE;
816 if ((config.c_maxsessions > 0)&&(num_sessions > config.c_maxsessions))
819 lprintf(CTDL_NOTICE, "Session started.\n");
821 /* Run any session startup routines registered by loadable modules */
822 PerformSessionHooks(EVT_START);
826 void citproto_begin_session() {
827 if (CC->nologin==1) {
828 cprintf("%d %s: Too many users are already online "
830 ERROR + MAX_SESSIONS_EXCEEDED,
831 config.c_nodename, config.c_maxsessions);
834 cprintf("%d %s Citadel server ready.\n",
835 CIT_OK, config.c_nodename);
843 * This loop recognizes all server commands.
845 void do_command_loop(void) {
849 memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */
850 if (client_getln(cmdbuf, sizeof cmdbuf) < 1) {
851 lprintf(CTDL_ERR, "Client socket is broken; ending session\n");
856 /* Log the server command, but don't show passwords... */
857 if ( (strncasecmp(cmdbuf, "PASS", 4))
858 && (strncasecmp(cmdbuf, "SETP", 4)) ) {
859 lprintf(CTDL_INFO, "%s\n", cmdbuf);
862 lprintf(CTDL_INFO, "<password command sent>\n");
868 * Let other clients see the last command we executed, and
869 * update the idle time, but not NOOP, QNOP, PEXP, or GEXP.
871 if ( (strncasecmp(cmdbuf, "NOOP", 4))
872 && (strncasecmp(cmdbuf, "QNOP", 4))
873 && (strncasecmp(cmdbuf, "PEXP", 4))
874 && (strncasecmp(cmdbuf, "GEXP", 4)) ) {
875 strcpy(CC->lastcmdname, " ");
876 safestrncpy(CC->lastcmdname, cmdbuf,
877 sizeof(CC->lastcmdname) );
881 if ((strncasecmp(cmdbuf, "ENT0", 4))
882 && (strncasecmp(cmdbuf, "MESG", 4))
883 && (strncasecmp(cmdbuf, "MSGS", 4)))
885 CC->cs_flags &= ~CS_POSTING;
888 if (!strncasecmp(cmdbuf,"NOOP",4)) {
889 cprintf("%d%cok\n", CIT_OK, CtdlCheckExpress() );
892 else if (!strncasecmp(cmdbuf,"QNOP",4)) {
893 /* do nothing, this command returns no response */
896 else if (!strncasecmp(cmdbuf,"QUIT",4)) {
897 cprintf("%d Goodbye.\n", CIT_OK);
901 else if (!strncasecmp(cmdbuf,"ASYN",4)) {
902 cmd_asyn(&cmdbuf[5]);
905 else if (!strncasecmp(cmdbuf,"LOUT",4)) {
906 if (CC->logged_in) logout(CC);
907 cprintf("%d logged out.\n", CIT_OK);
910 else if (!strncasecmp(cmdbuf,"USER",4)) {
911 cmd_user(&cmdbuf[5]);
914 else if (!strncasecmp(cmdbuf,"PASS",4)) {
915 cmd_pass(&cmdbuf[5]);
918 else if (!strncasecmp(cmdbuf,"NEWU",4)) {
919 cmd_newu(&cmdbuf[5]);
922 else if (!strncasecmp(cmdbuf,"CREU",4)) {
923 cmd_creu(&cmdbuf[5]);
926 else if (!strncasecmp(cmdbuf,"SETP",4)) {
927 cmd_setp(&cmdbuf[5]);
930 else if (!strncasecmp(cmdbuf,"LRMS",4)) {
931 cmd_lrms(&cmdbuf[5]);
934 else if (!strncasecmp(cmdbuf,"LKRA",4)) {
935 cmd_lkra(&cmdbuf[5]);
938 else if (!strncasecmp(cmdbuf,"LKRN",4)) {
939 cmd_lkrn(&cmdbuf[5]);
942 else if (!strncasecmp(cmdbuf,"LKRO",4)) {
943 cmd_lkro(&cmdbuf[5]);
946 else if (!strncasecmp(cmdbuf,"LZRM",4)) {
947 cmd_lzrm(&cmdbuf[5]);
950 else if (!strncasecmp(cmdbuf,"LPRM",4)) {
951 cmd_lprm(&cmdbuf[5]);
954 else if (!strncasecmp(cmdbuf,"GETU",4)) {
958 else if (!strncasecmp(cmdbuf,"SETU",4)) {
959 cmd_setu(&cmdbuf[5]);
962 else if (!strncasecmp(cmdbuf,"GOTO",4)) {
963 cmd_goto(&cmdbuf[5]);
966 else if (!strncasecmp(cmdbuf,"MSGS",4)) {
967 cmd_msgs(&cmdbuf[5]);
970 else if (!strncasecmp(cmdbuf,"WHOK",4)) {
974 else if (!strncasecmp(cmdbuf,"RDIR",4)) {
978 else if (!strncasecmp(cmdbuf,"MSG0",4)) {
979 cmd_msg0(&cmdbuf[5]);
982 else if (!strncasecmp(cmdbuf,"MSG2",4)) {
983 cmd_msg2(&cmdbuf[5]);
986 else if (!strncasecmp(cmdbuf,"MSG3",4)) {
987 cmd_msg3(&cmdbuf[5]);
990 else if (!strncasecmp(cmdbuf,"MSG4",4)) {
991 cmd_msg4(&cmdbuf[5]);
994 else if (!strncasecmp(cmdbuf,"MSGP",4)) {
995 cmd_msgp(&cmdbuf[5]);
998 else if (!strncasecmp(cmdbuf,"OPNA",4)) {
999 cmd_opna(&cmdbuf[5]);
1002 else if (!strncasecmp(cmdbuf,"INFO",4)) {
1006 else if (!strncasecmp(cmdbuf,"SLRP",4)) {
1007 cmd_slrp(&cmdbuf[5]);
1010 else if (!strncasecmp(cmdbuf,"INVT",4)) {
1011 cmd_invt_kick(&cmdbuf[5],1);
1014 else if (!strncasecmp(cmdbuf,"KICK",4)) {
1015 cmd_invt_kick(&cmdbuf[5],0);
1018 else if (!strncasecmp(cmdbuf,"GETR",4)) {
1022 else if (!strncasecmp(cmdbuf,"SETR",4)) {
1023 cmd_setr(&cmdbuf[5]);
1026 else if (!strncasecmp(cmdbuf,"GETA",4)) {
1030 else if (!strncasecmp(cmdbuf,"SETA",4)) {
1031 cmd_seta(&cmdbuf[5]);
1034 else if (!strncasecmp(cmdbuf,"ENT0",4)) {
1035 cmd_ent0(&cmdbuf[5]);
1038 else if (!strncasecmp(cmdbuf,"RINF",4)) {
1042 else if (!strncasecmp(cmdbuf,"DELE",4)) {
1043 cmd_dele(&cmdbuf[5]);
1046 else if (!strncasecmp(cmdbuf,"KILL",4)) {
1047 cmd_kill(&cmdbuf[5]);
1050 else if (!strncasecmp(cmdbuf,"CRE8",4)) {
1051 cmd_cre8(&cmdbuf[5]);
1054 else if (!strncasecmp(cmdbuf,"MOVE",4)) {
1055 cmd_move(&cmdbuf[5]);
1058 else if (!strncasecmp(cmdbuf,"FORG",4)) {
1062 else if (!strncasecmp(cmdbuf,"MESG",4)) {
1063 cmd_mesg(&cmdbuf[5]);
1066 else if (!strncasecmp(cmdbuf,"EMSG",4)) {
1067 cmd_emsg(&cmdbuf[5]);
1070 else if (!strncasecmp(cmdbuf,"GNUR",4)) {
1074 else if (!strncasecmp(cmdbuf,"VALI",4)) {
1075 cmd_vali(&cmdbuf[5]);
1078 else if (!strncasecmp(cmdbuf,"EINF",4)) {
1079 cmd_einf(&cmdbuf[5]);
1082 else if (!strncasecmp(cmdbuf,"LIST",4)) {
1086 else if (!strncasecmp(cmdbuf,"CHEK",4)) {
1090 else if (!strncasecmp(cmdbuf,"DELF",4)) {
1091 cmd_delf(&cmdbuf[5]);
1094 else if (!strncasecmp(cmdbuf,"MOVF",4)) {
1095 cmd_movf(&cmdbuf[5]);
1098 else if (!strncasecmp(cmdbuf,"NETF",4)) {
1099 cmd_netf(&cmdbuf[5]);
1102 else if (!strncasecmp(cmdbuf,"OPEN",4)) {
1103 cmd_open(&cmdbuf[5]);
1106 else if (!strncasecmp(cmdbuf,"CLOS",4)) {
1110 else if (!strncasecmp(cmdbuf,"UOPN",4)) {
1111 cmd_uopn(&cmdbuf[5]);
1114 else if (!strncasecmp(cmdbuf,"UCLS",4)) {
1115 cmd_ucls(&cmdbuf[5]);
1118 else if (!strncasecmp(cmdbuf,"READ",4)) {
1119 cmd_read(&cmdbuf[5]);
1122 else if (!strncasecmp(cmdbuf,"WRIT",4)) {
1123 cmd_writ(&cmdbuf[5]);
1126 else if (!strncasecmp(cmdbuf,"QUSR",4)) {
1127 cmd_qusr(&cmdbuf[5]);
1130 else if (!strncasecmp(cmdbuf,"ECHO",4)) {
1131 cmd_echo(&cmdbuf[5]);
1134 else if (!strncasecmp(cmdbuf,"OIMG",4)) {
1135 cmd_oimg(&cmdbuf[5]);
1138 else if (!strncasecmp(cmdbuf,"MORE",4)) {
1142 else if (!strncasecmp(cmdbuf,"NDOP",4)) {
1143 cmd_ndop(&cmdbuf[5]);
1146 else if (!strncasecmp(cmdbuf,"NUOP",4)) {
1147 cmd_nuop(&cmdbuf[5]);
1150 else if (!strncasecmp(cmdbuf,"LFLR",4)) {
1154 else if (!strncasecmp(cmdbuf,"CFLR",4)) {
1155 cmd_cflr(&cmdbuf[5]);
1158 else if (!strncasecmp(cmdbuf,"KFLR",4)) {
1159 cmd_kflr(&cmdbuf[5]);
1162 else if (!strncasecmp(cmdbuf,"EFLR",4)) {
1163 cmd_eflr(&cmdbuf[5]);
1166 else if (!strncasecmp(cmdbuf,"IDEN",4)) {
1167 cmd_iden(&cmdbuf[5]);
1170 else if (!strncasecmp(cmdbuf,"IPGM",4)) {
1171 cmd_ipgm(&cmdbuf[5]);
1174 else if (!strncasecmp(cmdbuf,"TERM",4)) {
1175 cmd_term(&cmdbuf[5]);
1178 else if (!strncasecmp(cmdbuf,"DOWN",4)) {
1182 else if (!strncasecmp(cmdbuf,"SCDN",4)) {
1183 cmd_scdn(&cmdbuf[5]);
1186 else if (!strncasecmp(cmdbuf, "UIMG", 4)) {
1187 cmd_uimg(&cmdbuf[5]);
1190 else if (!strncasecmp(cmdbuf, "TIME", 4)) {
1194 else if (!strncasecmp(cmdbuf, "AGUP", 4)) {
1195 cmd_agup(&cmdbuf[5]);
1198 else if (!strncasecmp(cmdbuf, "ASUP", 4)) {
1199 cmd_asup(&cmdbuf[5]);
1202 else if (!strncasecmp(cmdbuf, "GPEX", 4)) {
1203 cmd_gpex(&cmdbuf[5]);
1206 else if (!strncasecmp(cmdbuf, "SPEX", 4)) {
1207 cmd_spex(&cmdbuf[5]);
1210 else if (!strncasecmp(cmdbuf, "CONF", 4)) {
1211 cmd_conf(&cmdbuf[5]);
1214 else if (!strncasecmp(cmdbuf, "SEEN", 4)) {
1215 cmd_seen(&cmdbuf[5]);
1218 else if (!strncasecmp(cmdbuf, "GTSN", 4)) {
1219 cmd_gtsn(&cmdbuf[5]);
1222 else if (!strncasecmp(cmdbuf, "VIEW", 4)) {
1223 cmd_view(&cmdbuf[5]);
1226 else if (!strncasecmp(cmdbuf, "ISME", 4)) {
1227 cmd_isme(&cmdbuf[5]);
1230 else if (!DLoader_Exec_Cmd(cmdbuf)) {
1231 cprintf("%d Unrecognized or unsupported command.\n",
1232 ERROR + CMD_NOT_SUPPORTED);
1237 /* Run any after-each-command routines registered by modules */
1238 PerformSessionHooks(EVT_CMD);
1243 * This loop performs all asynchronous functions.
1245 void do_async_loop(void) {
1246 PerformSessionHooks(EVT_ASYNC);