]> code.citadel.org Git - citadel.git/blobdiff - citadel/citadel.c
Changeover to new room structure. See ChangeLog for details.
[citadel.git] / citadel / citadel.c
index 73c50712946a31d344c71467c405c3ec3eb405f3..abbf44dc1f3fcab3d5856a487fb8f8f16b8b3736 100644 (file)
 
 #include "citadel.h"
 #include "axdefs.h"
+#include "serv_info.h"
+#include "routines.h"
+#include "routines2.h"
+#include "commands.h"
+#include "rooms.h"
+#include "messages.h"
+#include "ipc.h"
+#include "client_chat.h"
+#include "citadel_decls.h"
 
 struct march {
        struct march *next;
@@ -36,72 +45,6 @@ struct march {
 #define IFNAIDE if (axlevel<6)
 
 struct march *march = NULL;
-long finduser();
-void extract();
-long extract_long();
-int extract_int();
-void load_command_set();
-void updatelsa();
-void movefile();
-void deletefile();
-void netsendfile();
-void listzrooms();
-int ka_system();
-void interr();
-int struncmp();
-int yesno();
-void sttybbs();
-void newprompt();
-void strprompt();
-int fmout();
-int checkpagin();
-int pattern();
-int pattern2();
-void readinfo();
-int num_parms();
-void attach_to_server();
-void strproc();
-void enter_config();
-void entregis();
-int entmsg();
-void updatels();
-void forget();
-void readmsgs();
-int getcmd();
-void subshell();
-void entroom();
-void killroom();
-void invite();
-void kickout();
-void editthisroom();
-void roomdir();
-void download();
-void upload();
-void cli_upload();
-void ungoto();
-void whoknows();
-void validate();
-void enterinfo();
-void display_help();
-void edituser();
-void knrooms();
-void locate_host();
-void chatmode();
-void load_floorlist();
-void create_floor();
-void edit_floor();
-void kill_floor();
-void enter_bio();
-void read_bio();
-void misc_server_cmd();
-int nukedir();
-void color();
-void cls();
-void edit_system_message();
-void send_ansi_detect();
-void look_for_ansi();
-void cli_image_upload();
-
 
 /* globals associated with the client program */
 char temp[16];                         /* Name of general temp file */
@@ -112,12 +55,12 @@ char printcmd[256];                        /* print command */
 int editor_pid = (-1);
 char fullname[32];
 jmp_buf nextbuf;
-struct serv_info serv_info;            /* Info on the server connected */
+struct CtdlServInfo serv_info;         /* Info on the server connected */
 int screenwidth;
 int screenheight;
 unsigned room_flags;
 char room_name[32];
-char ugname[20];
+char ugname[ROOMNAMELEN];
 long uglsn;                            /* holds <u>ngoto info */
 char is_mail = 0;                      /* nonzero when we're in a mail room */
 char axlevel = 0;                      /* access level */
@@ -140,13 +83,11 @@ char floorlist[128][256];          /* names of floors */
 char express_msgs = 0;                 /* express messages waiting! */
 char last_paged[32]="";
 
-extern char server_is_local;           /* defined in ipc module */
-
 /*
  * here is our 'clean up gracefully and exit' routine
  */
-void logoff(code)
-int code; {
+void logoff(int code)
+{
        if (editor_pid>0) {             /* kill the editor if it's running */
                kill(editor_pid,SIGHUP);
                }
@@ -183,8 +124,8 @@ int code; {
  * We handle "next" and "stop" much differently than in earlier versions.
  * The signal catching routine simply sets a flag and returns.
  */
-void sighandler(which_sig)
-int which_sig; {
+void sighandler(int which_sig)
+{
        signal(SIGINT,SIG_IGN);
        signal(SIGQUIT,SIG_IGN);
        sigcaught = which_sig;
@@ -195,7 +136,7 @@ int which_sig; {
 /*
  * signal catching function for hangups...
  */
-void dropcarr() {
+void dropcarr(int signum) {
        logoff(SIGHUP);
        }
 
@@ -203,8 +144,8 @@ void dropcarr() {
 
 /* general purpose routines */
 
-void formout(name) /* display a file */
-char name[];
+void formout(char *name) /* display a file */
+            
        {
        char cmd[256];
        sprintf(cmd,"MESG %s",name);
@@ -220,11 +161,11 @@ char name[];
        }
 
 
-void userlist() { 
+void userlist(void) { 
        char buf[256];
        char fl[256];
        struct tm *tmbuf;
-       long lc;
+       time_t lc;
        int linecount = 2;
 
        serv_puts("LIST");
@@ -263,60 +204,11 @@ void userlist() {
        }
 
 
-/*
- * get info about the server we've connected to
- */
-void get_serv_info() {
-       char buf[256];
-       int a;
-
-       /* fetch info */        
-       serv_puts("INFO");
-       serv_gets(buf);
-       if (buf[0]!='1') return;
-
-       a = 0;
-       while(serv_gets(buf), strcmp(buf,"000")) {
-           switch(a) {
-               case 0:         serv_info.serv_pid = atoi(buf);
-                               break;
-               case 1:         strcpy(serv_info.serv_nodename,buf);
-                               break;
-               case 2:         strcpy(serv_info.serv_humannode,buf);
-                               break;
-               case 3:         strcpy(serv_info.serv_fqdn,buf);
-                               break;
-               case 4:         strcpy(serv_info.serv_software,buf);
-                               break;
-               case 5:         serv_info.serv_rev_level = atoi(buf);
-                               break;
-               case 6:         strcpy(serv_info.serv_bbs_city,buf);
-                               break;
-               case 7:         strcpy(serv_info.serv_sysadm,buf);
-                               break;
-               case 9:         strcpy(serv_info.serv_moreprompt,buf);
-                               break;
-               case 10:        serv_info.serv_ok_floors = atoi(buf);
-                               break;
-               }
-           ++a;
-           }
-
-       /* be nice and identify ourself to the server */
-       sprintf(buf,"IDEN %d|%d|%d|%s%s|",
-               SERVER_TYPE,0,REV_LEVEL,CITADEL,
-               (server_is_local ? "(local)" : ""));
-       locate_host(&buf[strlen(buf)]); /* append to the end */
-       serv_puts(buf);
-       serv_gets(buf); /* we don't care about the result code */
-
-       }
-
 /*
  * grab assorted info about the user...
  */
-void load_user_info(params)
-char *params; {
+void load_user_info(char *params)
+{
        extract(fullname,params,0);
        axlevel = extract_int(params,1);
        timescalled = extract_int(params,2);
@@ -331,9 +223,8 @@ char *params; {
  * 'roomname' is set to _FLOOR_, in which case all rooms on the requested
  * floor will be removed from the march list.
  */
-void remove_march(roomname,floornum)
-char *roomname;
-int floornum; {
+void remove_march(char *roomname, int floornum)
+{
        struct march *mptr,*mptr2;
 
        if (march==NULL) return;
@@ -366,7 +257,7 @@ int floornum; {
 /*
  * sort the march list by floor
  */
-void sort_march_list() {
+void sort_march_list(void) {
        struct march *mlist[129];
        struct march *mptr = NULL;
        int a;
@@ -417,9 +308,8 @@ void sort_march_list() {
 /*
  * jump directly to a room
  */
-void dotgoto(towhere,display_name)
-char *towhere;
-int display_name; {
+void dotgoto(char *towhere, int display_name)
+{
        char aaa[256],bbb[256],psearch[256];
        static long ls = 0L;
        int newmailcount;
@@ -529,7 +419,7 @@ int display_name; {
  * We start the search in the current room rather than the beginning to prevent
  * two or more concurrent users from dragging each other back to the same room.
  */
-void gotonext() {
+void gotonext(void) {
        char buf[256];
        struct march *mptr,*mptr2;
        char next_room[32];
@@ -595,8 +485,8 @@ void gotonext() {
 /*
  * forget all rooms on a given floor
  */
-void forget_all_rooms_on(ffloor)
-int ffloor; {
+void forget_all_rooms_on(int ffloor)
+{
        char buf[256];
        struct march *flist,*fptr;
 
@@ -635,9 +525,8 @@ int ffloor; {
 /*
  * routine called by gotofloor() to move to a new room on a new floor
  */
-void gf_toroom(towhere,mode)
-char *towhere;
-int mode; {
+void gf_toroom(char *towhere, int mode)
+{
        int floor_being_left;
 
        floor_being_left = curr_floor;
@@ -663,9 +552,8 @@ int mode; {
 /*
  * go to a new floor
  */
-void gotofloor(towhere,mode)
-char *towhere;
-int mode; {
+void gotofloor(char *towhere, int mode)
+{
        int a,tofloor;
        struct march *mptr;
        char buf[256],targ[256];
@@ -720,7 +608,7 @@ int mode; {
 /*
  * forget all rooms on current floor
  */
-void forget_this_floor() {
+void forget_this_floor(void) {
        
        if (curr_floor == 0) {
                printf("Can't forget this floor.\n");
@@ -739,7 +627,7 @@ void forget_this_floor() {
 /* 
  * Figure out the physical screen dimensions, if we can
  */
-void check_screen_dims() {
+void check_screen_dims(void) {
 #ifdef TIOCGWINSZ
        struct {
                unsigned short height;          /* rows */
@@ -761,7 +649,7 @@ void check_screen_dims() {
 /*
  * set floor mode depending on client, server, and user settings
  */
-void set_floor_mode() {
+void set_floor_mode(void) {
        if (serv_info.serv_ok_floors == 0) {
                floor_mode = 0;         /* Don't use floors if the server */
                }                       /* doesn't support them!          */
@@ -781,7 +669,7 @@ void set_floor_mode() {
 /*
  * Set or change the user's password
  */
-int set_password() {
+int set_password(void) {
        char pass1[20];
        char pass2[20];
        char buf[256];
@@ -809,18 +697,38 @@ int set_password() {
        }
 
 
+
+/*
+ * get info about the server we've connected to
+ */
+void get_serv_info(void) {
+       char buf[256];
+
+       CtdlInternalGetServInfo(&serv_info);
+
+       /* be nice and identify ourself to the server */
+       sprintf(buf,"IDEN %d|%d|%d|%s|",
+               SERVER_TYPE,0,REV_LEVEL,
+               (server_is_local ? "local" : CITADEL));
+       locate_host(&buf[strlen(buf)]); /* append to the end */
+       serv_puts(buf);
+       serv_gets(buf); /* we don't care about the result code */
+       }
+
+
+
+
+
 /*
  * Display list of users currently logged on to the server
  */
 void who_is_online(int longlist) 
 {
        char buf[128], username[128], roomname[128], fromhost[128], flags[128];
-       char tbuf[128], timestr[128], idlebuf[128];
-       long timenow=0;
-       long idletime;
+       char tbuf[128], timestr[128], idlebuf[128], clientsoft[128];
+       time_t timenow=0;
+       time_t idletime, idlehours, idlemins, idlesecs;
        
-       printf("FLG ###        User Name                 Room                 From host\n");
-       printf("--- --- ------------------------- -------------------- ------------------------\n");
        if (longlist)
        {
           serv_puts("TIME");
@@ -828,6 +736,10 @@ void who_is_online(int longlist)
           extract(timestr, tbuf, 1);
           timenow = atol(timestr);
        }
+       else {
+       printf("FLG ###        User Name                 Room                 From host\n");
+       printf("--- --- ------------------------- -------------------- ------------------------\n");
+               }
        serv_puts("RWHO");
        serv_gets(buf);
        if (buf[0]=='1') 
@@ -837,19 +749,30 @@ void who_is_online(int longlist)
                        extract(username,buf,1);
                        extract(roomname,buf,2);
                        extract(fromhost,buf,3);
+                       extract(clientsoft, buf, 4);
                        extract(idlebuf, buf,5);
                        extract(flags,buf,7);
+
+                       if (longlist) {
+                               idletime = timenow - atol(idlebuf);
+                               idlehours = idletime / 3600;
+                               idlemins = (idletime - (idlehours*3600)) / 60;
+                               idlesecs = (idletime - (idlehours*3600) - (idlemins*60) );
+                               printf("\nFlags: %-3s  Sess# %-3d  Name: %-25s  Room: %s\n",
+                                       flags, extract_int(buf,0), username, roomname);
+                               printf("from <%s> using <%s>, idle %ld:%02ld:%02ld\n",
+                                       fromhost, clientsoft,
+                                       (long)idlehours, (long)idlemins, (long)idlesecs);
+
+                               }
+                       else {
                        printf("%-3s %-3d %-25s %-20s %-24s\n",
                                flags, extract_int(buf,0), username,
                                roomname, fromhost);
-                       if (longlist)
-                       {
-                          idletime = atol(idlebuf);
-                          printf("Idle time: %ld seconds\n", timenow-idletime);
+                               }
                        }
                }
        }
-}
 
 void enternew(char *desc, char *buf, int maxlen)
 {
@@ -861,9 +784,8 @@ void enternew(char *desc, char *buf, int maxlen)
 /*
  * main
  */
-void main(argc,argv)
-int argc;
-char *argv[]; {
+int main(int argc, char **argv)
+{
 int a,b,mcmd;
 int termn8 = 0;
 char aaa[100],bbb[100],ccc[100],eee[100];      /* general purpose variables */