]> code.citadel.org Git - citadel.git/blob - citadel/citserver.c
* citadel.h (and related files): removed defunct parameters,
[citadel.git] / citadel / citserver.c
1 /* $Id$ */
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <stdio.h>
5 #include <fcntl.h>
6 #include <signal.h>
7 #include <time.h>
8 #include <ctype.h>
9 #include <string.h>
10 #include <errno.h>
11 #include <limits.h>
12 #include <pthread.h>
13 #include <syslog.h>
14 #include <dlfcn.h>
15 #include "citadel.h"
16 #include "server.h"
17 #include "sysdep_decls.h"
18 #include "citserver.h"
19 #include "config.h"
20 #include "database.h"
21 #include "housekeeping.h"
22 #include "user_ops.h"
23 #include "logging.h"
24 #include "support.h"
25 #include "msgbase.h"
26 #include "locate_host.h"
27 #include "room_ops.h"
28 #include "file_ops.h"
29 #include "dynloader.h"
30 #include "policy.h"
31 #include "control.h"
32
33 struct CitContext *ContextList = NULL;
34 int ScheduledShutdown = 0;
35
36 /*
37  * Various things that need to be initialized at startup
38  */
39 void master_startup(void) {
40         lprintf(7, "Opening databases\n");
41         open_databases();
42
43         lprintf(7, "Checking floor reference counts\n");
44         check_ref_counts();
45
46         lprintf(7, "Creating base rooms (if necessary)\n");
47         create_room(BASEROOM, 0, "", 0);
48         create_room(AIDEROOM, 4, "", 0);
49         create_room(config.c_twitroom, 0, "", 0);
50         }
51
52 /*
53  * Cleanup routine to be called when the server is shutting down.
54  */
55 void master_cleanup(void) {
56         struct CleanupFunctionHook *fcn;
57
58         /* Cancel all running sessions */
59         lprintf(7, "Cancelling running sessions...\n");
60         while (ContextList != NULL) {
61                 kill_session(ContextList->cs_pid);
62                 }
63
64         /* Run any cleanup routines registered by loadable modules */
65         for (fcn = CleanupHookTable; fcn != NULL; fcn = fcn->next) {
66                 (*fcn->h_function_pointer)();
67                 }
68
69         /* Close databases */
70         lprintf(7, "Closing databases\n");
71         close_databases();
72
73         /* Do system-dependent stuff */
74         sysdep_master_cleanup();
75
76         /* Now go away. */
77         lprintf(3, "citserver: exiting.\n");
78         exit(0);
79         }
80
81
82 /*
83  * Gracefully terminate the session and thread.
84  * (This is called as a cleanup handler by the thread library.)
85  *
86  * All NON-system-dependent stuff is done in this function.
87  * System-dependent session/thread cleanup is in cleanup() in sysdep.c
88  */
89 void cleanup_stuff(void *arg)
90 {
91         struct ExpressMessage *emptr;
92
93         lprintf(9, "cleanup_stuff() called\n");
94
95         lprintf(7, "Calling logout(%d)\n", CC->cs_pid);
96         logout(CC);
97
98         rec_log(CL_TERMINATE,CC->curr_user);
99         unlink(CC->temp);
100         lprintf(3, "citserver[%3d]: ended.\n",CC->cs_pid);
101         
102         /* Run any cleanup routines registered by loadable modules */
103         PerformSessionHooks(EVT_STOP);
104
105         syslog(LOG_NOTICE,"session %d ended", CC->cs_pid);
106         
107         /* Deallocate any unsent express messages */
108         begin_critical_section(S_SESSION_TABLE);
109         while (CC->FirstExpressMessage != NULL) {
110                 emptr = CC->FirstExpressMessage;
111                 CC->FirstExpressMessage = CC->FirstExpressMessage->next;
112                 free(emptr);
113                 }
114         end_critical_section(S_SESSION_TABLE);
115
116         /* Deallocate any message list we might have in memory */
117         if (CC->msglist != NULL) free(CC->msglist);
118
119         /* Purge any stale user/room relationships */
120         PurgeStaleRelationships();
121
122         /* Now get rid of the session and context */
123         lprintf(7, "cleanup_stuff() calling RemoveContext(%d)\n", CC->cs_pid);
124         RemoveContext(CC);
125
126         /* While we still have an extra thread with no user attached to it,
127          * take the opportunity to do some housekeeping before exiting.
128          */
129         do_housekeeping();
130         }
131
132
133 /*
134  * set_wtmpsupp()  -  alter the session listing
135  */
136 void set_wtmpsupp(char *newtext)
137 {
138         strncpy(CC->cs_room,newtext,sizeof CC->cs_room);
139         CC->cs_room[sizeof CC->cs_room - 1] = 0;
140         time(&CC->cs_lastupdt);
141
142         /* Run any routines registered by loadable modules */
143         PerformSessionHooks(EVT_NEWROOM);
144         }
145
146
147 /*
148  * cmd_info()  -  tell the client about this server
149  */
150 void cmd_info(void) {
151         cprintf("%d Server info:\n",LISTING_FOLLOWS);
152         cprintf("%d\n",CC->cs_pid);
153         cprintf("%s\n",config.c_nodename);
154         cprintf("%s\n",config.c_humannode);
155         cprintf("%s\n",config.c_fqdn);
156         cprintf("%s\n",CITADEL);
157         cprintf("%d\n",REV_LEVEL);
158         cprintf("%s\n",config.c_bbs_city);
159         cprintf("%s\n",config.c_sysadm);
160         cprintf("%d\n",SERVER_TYPE);
161         cprintf("%s\n",config.c_moreprompt);
162         cprintf("1\n"); /* 1 = yes, this system supports floors */
163         cprintf("000\n");
164         }
165
166 void cmd_rchg(char *newroomname)
167 {
168    if ((newroomname) && (newroomname[0]))
169    {
170       bzero(CC->fake_roomname, ROOMNAMELEN);
171       strncpy(CC->fake_roomname, newroomname, ROOMNAMELEN-1);
172    }
173    else
174       CC->fake_roomname[0] = '\0';
175    cprintf("%d\n",OK);
176 }
177
178 void cmd_hchg(char *newhostname)
179 {
180    if ((newhostname) && (newhostname[0]))
181    {
182       bzero(CC->fake_hostname, 25);
183       strncpy(CC->fake_hostname, newhostname, 24);
184    }
185    else
186       CC->fake_hostname[0] = '\0';
187    cprintf("%d\n",OK);
188 }
189
190 void cmd_uchg(char *newusername)
191 {
192    if (CC->usersupp.axlevel < 6) 
193    {
194       cprintf("%d You must be an Aide to use UCHG.\n",
195                 ERROR+HIGHER_ACCESS_REQUIRED);
196       return;
197    }
198    if ((newusername) && (newusername[0]))
199    {
200       CC->cs_flags &= ~CS_STEALTH;
201       bzero(CC->fake_username, 32);
202       if (strncasecmp(newusername, CC->curr_user, strlen(CC->curr_user)))
203          strncpy(CC->fake_username, newusername, 31);
204    }
205    else
206    {
207       CC->fake_username[0] = '\0';
208       CC->cs_flags |= CS_STEALTH;
209    }
210    cprintf("%d\n",OK);
211 }
212
213 /*
214  * returns an asterisk if there are any express messages waiting,
215  * space otherwise.
216  */
217 char check_express(void) {
218         if (CC->FirstExpressMessage == NULL) {
219                 return(' ');
220                 }
221         else {
222                 return('*');
223                 }
224         }
225
226 void cmd_time(void)
227 {
228    time_t tv;
229    
230    tv = time(NULL);
231    
232    cprintf("%d %ld\n", OK, tv);
233 }
234
235 /*
236  * check a hostname against the public_clients file
237  */
238 int is_public_client(char *where)
239 {
240         char buf[256];
241         FILE *fp;
242
243         if (!strcasecmp(where,"localhost")) return(1);
244         if (!strcasecmp(where,config.c_fqdn)) return(1);
245
246         fp = fopen("public_clients","r");
247         if (fp == NULL) return(0);
248
249         while (fgets(buf,256,fp)!=NULL) {
250                 while (isspace((buf[strlen(buf)-1]))) 
251                         buf[strlen(buf)-1] = 0;
252                 if (!strcasecmp(buf,where)) {
253                         fclose(fp);
254                         return(1);
255                         }
256                 }
257
258         fclose(fp);
259         return(0);
260         }
261
262
263 /*
264  * the client is identifying itself to the server
265  */
266 void cmd_iden(char *argbuf)
267 {
268         int dev_code;
269         int cli_code;
270         int rev_level;
271         char desc[256];
272         char from_host[256];
273
274         if (num_parms(argbuf)<4) {
275                 cprintf("%d usage error\n",ERROR);
276                 return;
277                 }
278
279         dev_code = extract_int(argbuf,0);
280         cli_code = extract_int(argbuf,1);
281         rev_level = extract_int(argbuf,2);
282         extract(desc,argbuf,3);
283
284         strncpy(from_host,config.c_fqdn,sizeof from_host);
285         from_host[sizeof from_host - 1] = 0;
286         if (num_parms(argbuf)>=5) extract(from_host,argbuf,4);
287
288         CC->cs_clientdev = dev_code;
289         CC->cs_clienttyp = cli_code;
290         CC->cs_clientver = rev_level;
291         strncpy(CC->cs_clientname,desc,31);
292         CC->cs_clientname[31] = 0;
293
294         if ((strlen(from_host)>0) && 
295            (is_public_client(CC->cs_host))) {
296                 strncpy(CC->cs_host,from_host,24);
297                 CC->cs_host[24] = 0;
298                 }
299         set_wtmpsupp(CC->quickroom.QRname);
300
301         syslog(LOG_NOTICE,"client %d/%d/%01d.%02d (%s)\n",
302                 dev_code,
303                 cli_code,
304                 (rev_level / 100),
305                 (rev_level % 100),
306                 desc);
307                 cprintf("%d Ok\n",OK);
308         }
309
310
311 /*
312  * enter or exit "stealth mode"
313  */
314 void cmd_stel(char *cmdbuf)
315 {
316         int requested_mode;
317
318         requested_mode = extract_int(cmdbuf,0);
319         if (requested_mode !=0) requested_mode = 1;
320
321         if (!CC->logged_in) {
322                 cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
323                 return;
324                 }
325
326         if (CC->usersupp.axlevel < 6) {
327                 cprintf("%d You must be an Aide to use stealth mode.\n",
328                         ERROR+HIGHER_ACCESS_REQUIRED);
329                 return;
330                 }
331
332         if (CC->cs_flags & CS_STEALTH) {
333                 if (requested_mode == 0)
334                         CC->cs_flags = CC->cs_flags-CS_STEALTH;
335                 }
336         else {
337                 if (requested_mode == 1)
338                         CC->cs_flags = CC->cs_flags|CS_STEALTH;
339                 }
340
341         set_wtmpsupp(CC->quickroom.QRname);
342         cprintf("%d Ok\n",OK);
343         }
344
345
346
347
348 /*
349  * display system messages or help
350  */
351 void cmd_mesg(char *mname)
352 {
353         FILE *mfp;
354         char targ[256];
355         char buf[256];
356         char *dirs[2];
357
358         extract(buf,mname,0);
359
360
361         dirs[0]=malloc(64);
362         dirs[1]=malloc(64);
363         strcpy(dirs[0],"messages");
364         strcpy(dirs[1],"help");
365         mesg_locate(targ,buf,2,dirs);
366         free(dirs[0]);
367         free(dirs[1]);
368
369
370         if (strlen(targ)==0) {
371                 cprintf("%d '%s' not found.\n",ERROR,mname);
372                 return;
373                 }
374
375         mfp = fopen(targ,"r");
376         if (mfp==NULL) {
377                 cprintf("%d Cannot open '%s': %s\n",
378                         ERROR,targ,strerror(errno));
379                 return;
380                 }
381         cprintf("%d %s\n",LISTING_FOLLOWS,buf);
382
383         while (fgets(buf,255,mfp)!=NULL) {
384                 buf[strlen(buf)-1] = 0;
385                 do_help_subst(buf);
386                 cprintf("%s\n",buf);
387                 }
388
389         fclose(mfp);
390         cprintf("000\n");
391         }
392
393
394 /*
395  * enter system messages or help
396  */
397 void cmd_emsg(char *mname)
398 {
399         FILE *mfp;
400         char targ[256];
401         char buf[256];
402         char *dirs[2];
403         int a;
404
405         if (CC->usersupp.axlevel < 6) {
406                 cprintf("%d You must be an Aide to edit system messages.\n",
407                         ERROR+HIGHER_ACCESS_REQUIRED);
408                 return;
409                 }
410
411         extract(buf,mname,0);
412         for (a=0; a<strlen(buf); ++a) {         /* security measure */
413                 if (buf[a] == '/') buf[a] = '.';
414                 }
415
416         dirs[0]=malloc(64);
417         dirs[1]=malloc(64);
418         strcpy(dirs[0],"messages");
419         strcpy(dirs[1],"help");
420         mesg_locate(targ,buf,2,dirs);
421         free(dirs[0]);
422         free(dirs[1]);
423
424         if (strlen(targ)==0) {
425                 sprintf(targ, "./help/%s", buf);
426                 }
427
428         mfp = fopen(targ,"w");
429         if (mfp==NULL) {
430                 cprintf("%d Cannot open '%s': %s\n",
431                         ERROR,targ,strerror(errno));
432                 return;
433                 }
434         cprintf("%d %s\n", SEND_LISTING, targ);
435
436         while (client_gets(buf), strcmp(buf, "000")) {
437                 fprintf(mfp, "%s\n", buf);
438                 }
439
440         fclose(mfp);
441         }
442
443
444 /*
445  * who's online
446  */
447 void cmd_rwho(void) {
448         struct CitContext *cptr;
449         int spoofed = 0;
450         int aide;
451         char un[40], room[40], host[40], flags[5];
452         
453         aide = CC->usersupp.axlevel >= 6;
454         cprintf("%d\n",LISTING_FOLLOWS);
455         
456         for (cptr = ContextList; cptr != NULL; cptr = cptr->next) 
457         {
458                 flags[0] = '\0';
459                 spoofed = 0;
460                 
461                 if (cptr->cs_flags & CS_POSTING)
462                    strcat(flags, "*");
463                 else
464                    strcat(flags, ".");
465                    
466                 if (cptr->fake_username[0])
467                 {
468                    strcpy(un, cptr->fake_username);
469                    spoofed = 1;
470                 }
471                 else
472                    strcpy(un, cptr->curr_user);
473                    
474                 if (cptr->fake_hostname[0])
475                 {
476                    strcpy(host, cptr->fake_hostname);
477                    spoofed = 1;
478                 }
479                 else
480                    strcpy(host, cptr->cs_host);
481
482                 if (cptr->fake_roomname[0])
483                 {
484                    strcpy(room, cptr->fake_roomname);
485                    spoofed = 1;
486                 }
487                 else
488                    strcpy(room, cptr->cs_room);
489                    
490                 
491                 if ((aide) && (spoofed))
492                    strcat(flags, "+");
493                 
494                 if ((cptr->cs_flags & CS_STEALTH) && (aide))
495                    strcat(flags, "-");
496                 
497                 if (((cptr->cs_flags&CS_STEALTH)==0) || (aide))
498                 {
499                         cprintf("%d|%s|%s|%s|%s|%ld|%s|%s\n",
500                                 cptr->cs_pid, un, room,
501                                 host, cptr->cs_clientname,
502                                 (long)(cptr->lastidle),
503                                 cptr->lastcmdname, flags);
504                 }
505                 if ((spoofed) && (aide))
506                 {
507                         cprintf("%d|%s|%s|%s|%s|%ld|%s|%s\n",
508                                 cptr->cs_pid, cptr->curr_user, cptr->cs_room,
509                                 cptr->cs_host, cptr->cs_clientname,
510                                 (long)(cptr->lastidle),
511                                 cptr->lastcmdname, flags);
512                 
513                 }
514         }
515         cprintf("000\n");
516         }
517
518
519 /*
520  * Terminate another running session
521  */
522 void cmd_term(char *cmdbuf)
523 {
524         int session_num;
525         struct CitContext *ccptr;
526
527         if (!CC->logged_in) {
528                 cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
529                 return;
530                 }
531
532         if (CC->usersupp.axlevel < 6) {
533                 cprintf("%d You must be an Aide to terminate sessions.\n",
534                         ERROR+HIGHER_ACCESS_REQUIRED);
535                 return;
536                 }
537
538         session_num = extract_int(cmdbuf, 0);
539         if (session_num == CC->cs_pid) {
540                 cprintf("%d You can't kill your own session.\n", ERROR);
541                 return;
542                 }
543
544         for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
545                 if (session_num == ccptr->cs_pid) {
546                         kill_session(ccptr->cs_pid);
547                         cprintf("%d Session terminated.\n", OK);
548                         return;
549                         }
550                 }
551
552         cprintf("%d No such session.\n", ERROR);
553         }
554
555
556
557
558
559 /* 
560  * get the paginator prompt
561  */
562 void cmd_more(void) {
563         cprintf("%d %s\n",OK,config.c_moreprompt);
564         }
565
566 /*
567  * echo 
568  */
569 void cmd_echo(char *etext)
570 {
571         cprintf("%d %s\n",OK,etext);
572         }
573
574
575
576 /* 
577  * identify as internal program
578  */
579 void cmd_ipgm(char *argbuf)
580 {
581         int secret;
582
583         secret = extract_int(argbuf, 0);
584         if (secret == config.c_ipgm_secret) {
585                 CC->internal_pgm = 1;
586                 strcpy(CC->curr_user, "<internal program>");
587                 CC->cs_flags = CC->cs_flags|CS_STEALTH;
588                 cprintf("%d Authenticated as an internal program.\n",OK);
589                 }
590         else {
591                 cprintf("%d Authentication failed.\n",ERROR);
592                 }
593         }
594
595
596 /*
597  * Shut down the server
598  */
599 void cmd_down(void) {
600         if (!CC->logged_in) {
601                 cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
602                 return;
603                 }
604
605         if (CC->usersupp.axlevel < 6) {
606                 cprintf("%d You must be an Aide to shut down the server.\n",
607                         ERROR+HIGHER_ACCESS_REQUIRED);
608                 return;
609                 }
610
611         cprintf("%d Shutting down server.  Goodbye.\n", OK);
612         master_cleanup();
613         }
614
615 /*
616  * Schedule or cancel a server shutdown
617  */
618 void cmd_scdn(char *argbuf)
619 {
620         int new_state;
621
622         if (!CC->logged_in) {
623                 cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN);
624                 return;
625                 }
626
627         if (CC->usersupp.axlevel < 6) {
628                 cprintf("%d You must be an Aide to schedule a shutdown.\n",
629                         ERROR+HIGHER_ACCESS_REQUIRED);
630                 return;
631                 }
632
633         new_state = extract_int(argbuf, 0);
634         if ((new_state == 0) || (new_state == 1)) {
635                 ScheduledShutdown = new_state;
636                 }
637         cprintf("%d %d\n", OK, ScheduledShutdown);
638         }
639
640
641 /*
642  * main context loop
643  */
644 void *context_loop(struct CitContext *con)
645 {
646         char cmdbuf[256];
647         int session_num;
648
649         /*
650          * Wedge our way into the context table.
651          */
652         InitMyContext(con);
653
654         /* 
655          * Initialize some variables specific to our context.
656          */
657         CC->logged_in = 0;
658         CC->internal_pgm = 0;
659         CC->download_fp = NULL;
660         CC->upload_fp = NULL;
661         CC->cs_pid = con->client_socket;        /* not necessarily portable */
662         CC->FirstExpressMessage = NULL;
663         CC->msglist = NULL;
664         CC->num_msgs = 0;
665         time(&CC->lastcmd);
666         time(&CC->lastidle);
667         strcpy(CC->lastcmdname, "    ");
668         strcpy(CC->cs_clientname, "(unknown)");
669         strcpy(CC->curr_user,"");
670         strcpy(CC->net_node,"");
671         sprintf(CC->temp,"/tmp/CitServer.%d.%d", getpid(), CC->cs_pid);
672         strcpy(CC->cs_room, "");
673         strncpy(CC->cs_host, config.c_fqdn, sizeof CC->cs_host);
674         CC->cs_host[sizeof CC->cs_host - 1] = 0;
675         locate_host(CC->cs_host);
676         CC->cs_flags = 0;
677         CC->upload_type = UPL_FILE;
678         CC->dl_is_net = 0;
679
680         session_num = session_count();
681         CC->nologin = 0;
682         if ((config.c_maxsessions > 0)&&(session_num >= config.c_maxsessions))
683                 CC->nologin = 1;
684
685         if (CC->nologin==1) {
686            cprintf("%d %s: Too many users are already online (maximum is %d)\n",
687                 ERROR+MAX_SESSIONS_EXCEEDED,
688                 config.c_nodename,config.c_maxsessions);
689                 }
690         else {
691            cprintf("%d %s Citadel/UX server ready.\n",OK,config.c_nodename);
692                 }
693
694         lprintf(3, "citserver[%3d]: started.\n", CC->cs_pid);
695
696         /* Run any session startup routines registered by loadable modules */
697         PerformSessionHooks(EVT_START);
698
699         rec_log(CL_CONNECT, "");
700
701         do {
702                 time(&CC->lastcmd);
703                 bzero(cmdbuf, sizeof cmdbuf); /* Clear it, just in case */
704                 if (client_gets(cmdbuf) < 1) cleanup(EXIT_NULL);
705                 lprintf(5, "citserver[%3d]: %s\n", CC->cs_pid, cmdbuf);
706
707                 /*
708                  * Let other clients see the last command we executed, but
709                  * exclude NOOP because that would be boring.
710                  */
711                 if (strncasecmp(cmdbuf, "NOOP", 4)) {
712                         strcpy(CC->lastcmdname, "    ");
713                         strncpy(CC->lastcmdname, cmdbuf, 4);
714                         time(&CC->lastidle);
715                         }
716                         
717                 if ((strncasecmp(cmdbuf, "ENT0", 4)) && (strncasecmp(cmdbuf, "MESG", 4)) && (strncasecmp(cmdbuf, "MSGS", 4)))
718                 {
719                    CC->cs_flags &= ~CS_POSTING;
720                 }
721                    
722 /*
723  * This loop recognizes all server commands.
724  */
725
726                 if (!strncasecmp(cmdbuf,"NOOP",4)) {
727                         cprintf("%d%cok\n",OK,check_express());
728                         }
729
730                 else if (!strncasecmp(cmdbuf,"QUIT",4)) {
731                         cprintf("%d Goodbye.\n",OK);
732                         }
733
734                 else if (!strncasecmp(cmdbuf,"LOUT",4)) {
735                         if (CC->logged_in) logout(CC);
736                         cprintf("%d logged out.\n",OK);
737                         }
738
739                 else if (!strncasecmp(cmdbuf,"USER",4)) {
740                         cmd_user(&cmdbuf[5]);
741                         }
742
743                 else if (!strncasecmp(cmdbuf,"PASS",4)) {
744                         cmd_pass(&cmdbuf[5]);
745                         }
746
747                 else if (!strncasecmp(cmdbuf,"NEWU",4)) {
748                         cmd_newu(&cmdbuf[5]);
749                         }
750
751                 else if (!strncasecmp(cmdbuf,"SETP",4)) {
752                         cmd_setp(&cmdbuf[5]);
753                         }
754
755                 else if (!strncasecmp(cmdbuf,"LRMS",4)) {
756                         cmd_lrms(&cmdbuf[5]);
757                         }
758
759                 else if (!strncasecmp(cmdbuf,"LKRA",4)) {
760                         cmd_lkra(&cmdbuf[5]);
761                         }
762
763                 else if (!strncasecmp(cmdbuf,"LKRN",4)) {
764                         cmd_lkrn(&cmdbuf[5]);
765                         }
766
767                 else if (!strncasecmp(cmdbuf,"LKRO",4)) {
768                         cmd_lkro(&cmdbuf[5]);
769                         }
770
771                 else if (!strncasecmp(cmdbuf,"LZRM",4)) {
772                         cmd_lzrm(&cmdbuf[5]);
773                         }
774
775                 else if (!strncasecmp(cmdbuf,"GETU",4)) {
776                         cmd_getu();
777                         }
778
779                 else if (!strncasecmp(cmdbuf,"SETU",4)) {
780                         cmd_setu(&cmdbuf[5]);
781                         }
782
783                 else if (!strncasecmp(cmdbuf,"GOTO",4)) {
784                         cmd_goto(&cmdbuf[5]);
785                         }
786
787                 else if (!strncasecmp(cmdbuf,"MSGS",4)) {
788                         cmd_msgs(&cmdbuf[5]);
789                         }
790
791                 else if (!strncasecmp(cmdbuf,"WHOK",4)) {
792                         cmd_whok();
793                         }
794
795                 else if (!strncasecmp(cmdbuf,"RDIR",4)) {
796                         cmd_rdir();
797                         }
798
799                 else if (!strncasecmp(cmdbuf,"MSG0",4)) {
800                         cmd_msg0(&cmdbuf[5]);
801                         }
802
803                 else if (!strncasecmp(cmdbuf,"MSG2",4)) {
804                         cmd_msg2(&cmdbuf[5]);
805                         }
806
807                 else if (!strncasecmp(cmdbuf,"MSG3",4)) {
808                         cmd_msg3(&cmdbuf[5]);
809                         }
810
811                 else if (!strncasecmp(cmdbuf,"INFO",4)) {
812                         cmd_info();
813                         }
814
815                 else if (!strncasecmp(cmdbuf,"SLRP",4)) {
816                         cmd_slrp(&cmdbuf[5]);
817                         }
818
819                 else if (!strncasecmp(cmdbuf,"INVT",4)) {
820                         cmd_invt_kick(&cmdbuf[5],1);
821                         }
822
823                 else if (!strncasecmp(cmdbuf,"KICK",4)) {
824                         cmd_invt_kick(&cmdbuf[5],0);
825                         }
826
827                 else if (!strncasecmp(cmdbuf,"GETR",4)) {
828                         cmd_getr();
829                         }
830
831                 else if (!strncasecmp(cmdbuf,"SETR",4)) {
832                         cmd_setr(&cmdbuf[5]);
833                         }
834
835                 else if (!strncasecmp(cmdbuf,"GETA",4)) {
836                         cmd_geta();
837                         }
838
839                 else if (!strncasecmp(cmdbuf,"SETA",4)) {
840                         cmd_seta(&cmdbuf[5]);
841                         }
842
843                 else if (!strncasecmp(cmdbuf,"ENT0",4)) {
844                         cmd_ent0(&cmdbuf[5]);
845                         }
846
847                 else if (!strncasecmp(cmdbuf,"ENT3",4)) {
848                         cmd_ent3(&cmdbuf[5]);
849                         }
850
851                 else if (!strncasecmp(cmdbuf,"RINF",4)) {
852                         cmd_rinf();
853                         }
854
855                 else if (!strncasecmp(cmdbuf,"DELE",4)) {
856                         cmd_dele(&cmdbuf[5]);
857                         }
858
859                 else if (!strncasecmp(cmdbuf,"KILL",4)) {
860                         cmd_kill(&cmdbuf[5]);
861                         }
862
863                 else if (!strncasecmp(cmdbuf,"CRE8",4)) {
864                         cmd_cre8(&cmdbuf[5]);
865                         }
866
867                 else if (!strncasecmp(cmdbuf,"MOVE",4)) {
868                         cmd_move(&cmdbuf[5]);
869                         }
870
871                 else if (!strncasecmp(cmdbuf,"FORG",4)) {
872                         cmd_forg();
873                         }
874
875                 else if (!strncasecmp(cmdbuf,"MESG",4)) {
876                         cmd_mesg(&cmdbuf[5]);
877                         }
878
879                 else if (!strncasecmp(cmdbuf,"EMSG",4)) {
880                         cmd_emsg(&cmdbuf[5]);
881                         }
882
883                 else if (!strncasecmp(cmdbuf,"GNUR",4)) {
884                         cmd_gnur();
885                         }
886
887                 else if (!strncasecmp(cmdbuf,"GREG",4)) {
888                         cmd_greg(&cmdbuf[5]);
889                         }
890
891                 else if (!strncasecmp(cmdbuf,"VALI",4)) {
892                         cmd_vali(&cmdbuf[5]);
893                         }
894
895                 else if (!strncasecmp(cmdbuf,"EINF",4)) {
896                         cmd_einf(&cmdbuf[5]);
897                         }
898
899                 else if (!strncasecmp(cmdbuf,"LIST",4)) {
900                         cmd_list();
901                         }
902
903                 else if (!strncasecmp(cmdbuf,"REGI",4)) {
904                         cmd_regi();
905                         }
906
907                 else if (!strncasecmp(cmdbuf,"CHEK",4)) {
908                         cmd_chek();
909                         }
910
911                 else if (!strncasecmp(cmdbuf,"DELF",4)) {
912                         cmd_delf(&cmdbuf[5]);
913                         }
914
915                 else if (!strncasecmp(cmdbuf,"MOVF",4)) {
916                         cmd_movf(&cmdbuf[5]);
917                         }
918
919                 else if (!strncasecmp(cmdbuf,"NETF",4)) {
920                         cmd_netf(&cmdbuf[5]);
921                         }
922
923                 else if (!strncasecmp(cmdbuf,"RWHO",4)) {
924                         cmd_rwho();
925                         }
926
927                 else if (!strncasecmp(cmdbuf,"OPEN",4)) {
928                         cmd_open(&cmdbuf[5]);
929                         }
930
931                 else if (!strncasecmp(cmdbuf,"CLOS",4)) {
932                         cmd_clos();
933                         }
934
935                 else if (!strncasecmp(cmdbuf,"UOPN",4)) {
936                         cmd_uopn(&cmdbuf[5]);
937                         }
938
939                 else if (!strncasecmp(cmdbuf,"UCLS",4)) {
940                         cmd_ucls(&cmdbuf[5]);
941                         }
942
943                 else if (!strncasecmp(cmdbuf,"READ",4)) {
944                         cmd_read(&cmdbuf[5]);
945                         }
946
947                 else if (!strncasecmp(cmdbuf,"WRIT",4)) {
948                         cmd_writ(&cmdbuf[5]);
949                         }
950
951                 else if (!strncasecmp(cmdbuf,"QUSR",4)) {
952                         cmd_qusr(&cmdbuf[5]);
953                         }
954
955                 else if (!strncasecmp(cmdbuf,"ECHO",4)) {
956                         cmd_echo(&cmdbuf[5]);
957                         }
958
959                 else if (!strncasecmp(cmdbuf,"OIMG",4)) {
960                         cmd_oimg(&cmdbuf[5]);
961                         }
962
963                 else if (!strncasecmp(cmdbuf,"MORE",4)) {
964                         cmd_more();
965                         }
966
967                 else if (!strncasecmp(cmdbuf,"NETP",4)) {
968                         cmd_netp(&cmdbuf[5]);
969                         }
970
971                 else if (!strncasecmp(cmdbuf,"NDOP",4)) {
972                         cmd_ndop(&cmdbuf[5]);
973                         }
974
975                 else if (!strncasecmp(cmdbuf,"NUOP",4)) {
976                         cmd_nuop(&cmdbuf[5]);
977                         }
978
979                 else if (!strncasecmp(cmdbuf,"LFLR",4)) {
980                         cmd_lflr();
981                         }
982
983                 else if (!strncasecmp(cmdbuf,"CFLR",4)) {
984                         cmd_cflr(&cmdbuf[5]);
985                         }
986
987                 else if (!strncasecmp(cmdbuf,"KFLR",4)) {
988                         cmd_kflr(&cmdbuf[5]);
989                         }
990
991                 else if (!strncasecmp(cmdbuf,"EFLR",4)) {
992                         cmd_eflr(&cmdbuf[5]);
993                         }
994
995                 else if (!strncasecmp(cmdbuf,"IDEN",4)) {
996                         cmd_iden(&cmdbuf[5]);
997                         }
998
999                 else if (!strncasecmp(cmdbuf,"IPGM",4)) {
1000                         cmd_ipgm(&cmdbuf[5]);
1001                         }
1002
1003                 else if (!strncasecmp(cmdbuf,"EBIO",4)) {
1004                         cmd_ebio();
1005                         }
1006
1007                 else if (!strncasecmp(cmdbuf,"RBIO",4)) {
1008                         cmd_rbio(&cmdbuf[5]);
1009                         }
1010
1011                 else if (!strncasecmp(cmdbuf,"LBIO",4)) {
1012                         cmd_lbio();
1013                         }
1014
1015                 else if (!strncasecmp(cmdbuf,"STEL",4)) {
1016                         cmd_stel(&cmdbuf[5]);
1017                         }
1018
1019                 else if (!strncasecmp(cmdbuf,"TERM",4)) {
1020                         cmd_term(&cmdbuf[5]);
1021                         }
1022
1023                 else if (!strncasecmp(cmdbuf,"DOWN",4)) {
1024                         cmd_down();
1025                         }
1026
1027                 else if (!strncasecmp(cmdbuf,"SCDN",4)) {
1028                         cmd_scdn(&cmdbuf[5]);
1029                         }
1030
1031                 else if (!strncasecmp(cmdbuf, "NSET", 4)) {
1032                         cmd_nset(&cmdbuf[5]);
1033                         }
1034
1035                 else if (!strncasecmp(cmdbuf, "UIMG", 4)) {
1036                         cmd_uimg(&cmdbuf[5]);
1037                         }
1038
1039                 else if (!strncasecmp(cmdbuf, "UCHG", 4)) {
1040                         cmd_uchg(&cmdbuf[5]);
1041                         }
1042
1043                 else if (!strncasecmp(cmdbuf, "TIME", 4)) {
1044                         cmd_time();
1045                         }
1046
1047                 else if (!strncasecmp(cmdbuf, "HCHG", 4)) {
1048                         cmd_hchg(&cmdbuf[5]);
1049                         }
1050
1051                 else if (!strncasecmp(cmdbuf, "RCHG", 4)) {
1052                         cmd_rchg(&cmdbuf[5]);
1053                         }
1054
1055                 else if (!strncasecmp(cmdbuf, "AGUP", 4)) {
1056                         cmd_agup(&cmdbuf[5]);
1057                         }
1058
1059                 else if (!strncasecmp(cmdbuf, "ASUP", 4)) {
1060                         cmd_asup(&cmdbuf[5]);
1061                         }
1062
1063                 else if (!strncasecmp(cmdbuf, "GPEX", 4)) {
1064                         cmd_gpex(&cmdbuf[5]);
1065                         }
1066
1067                 else if (!strncasecmp(cmdbuf, "SPEX", 4)) {
1068                         cmd_spex(&cmdbuf[5]);
1069                         }
1070
1071                 else if (!strncasecmp(cmdbuf, "CONF", 4)) {
1072                         cmd_conf(&cmdbuf[5]);
1073                         }
1074
1075                 else if (!DLoader_Exec_Cmd(cmdbuf))
1076                         {
1077                            cprintf("%d Unrecognized or unsupported command.\n",
1078                                     ERROR);
1079                         }
1080
1081                 } while(strncasecmp(cmdbuf, "QUIT", 4));
1082
1083         cleanup(EXIT_NORMAL);
1084         return(NULL);
1085         }