X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=textclient%2Froutines2.c;h=a5225b027aa185da52dd221e1fc45b688b2f2b3e;hb=HEAD;hp=5105ee08238492f3f214ae5c763afa6509111dd5;hpb=633eabfc5820a6cc3b3c45793243928d0fa9c099;p=citadel.git diff --git a/textclient/routines2.c b/textclient/routines2.c index 5105ee082..de1f2db1f 100644 --- a/textclient/routines2.c +++ b/textclient/routines2.c @@ -2,17 +2,11 @@ // // Copyright (c) 1987-2017 by the citadel.org team // -// This program is open source software. Use, duplication, and/or -// disclosure are subject to the GNU General Purpose License version 3. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. +// This program is open source software. Use, duplication, or disclosure is subject to the GNU General Public License version 3. #include "textclient.h" -/* work around solaris include files */ +// work around solaris include files #ifdef reg #undef reg #endif @@ -26,24 +20,19 @@ extern unsigned room_flags; extern int screenwidth; -/* - * return proper room prompt character - */ -int room_prompt(unsigned int qrflags) -{ +// return proper room prompt character +int room_prompt(unsigned int qrflags) { int a; a = '>'; - if (qrflags & QR_DIRECTORY) + if (qrflags & QR_DIRECTORY) { a = ']'; + } return (a); } -/* - * Register with name and address - */ -void entregis(CtdlIPC * ipc) -{ +// Register with name and address +void entregis(CtdlIPC * ipc) { char buf[SIZ]; char tmpname[30]; @@ -80,21 +69,21 @@ void entregis(CtdlIPC * ipc) remove_token(reg, 0, '\n'); if (a == 2) - safestrncpy(tmpname, buf, sizeof tmpname); + strncpy(tmpname, buf, sizeof tmpname); else if (a == 3) - safestrncpy(tmpaddr, buf, sizeof tmpaddr); + strncpy(tmpaddr, buf, sizeof tmpaddr); else if (a == 4) - safestrncpy(tmpcity, buf, sizeof tmpcity); + strncpy(tmpcity, buf, sizeof tmpcity); else if (a == 5) - safestrncpy(tmpstate, buf, sizeof tmpstate); + strncpy(tmpstate, buf, sizeof tmpstate); else if (a == 6) - safestrncpy(tmpzip, buf, sizeof tmpzip); + strncpy(tmpzip, buf, sizeof tmpzip); else if (a == 7) - safestrncpy(tmpphone, buf, sizeof tmpphone); + strncpy(tmpphone, buf, sizeof tmpphone); else if (a == 9) - safestrncpy(tmpemail, buf, sizeof tmpemail); + strncpy(tmpemail, buf, sizeof tmpemail); else if (a == 10) - safestrncpy(tmpcountry, buf, sizeof tmpcountry); + strncpy(tmpcountry, buf, sizeof tmpcountry); ++a; } } @@ -108,20 +97,20 @@ void entregis(CtdlIPC * ipc) do { ok = 1; - safestrncpy(holdemail, tmpemail, sizeof holdemail); + strncpy(holdemail, tmpemail, sizeof holdemail); strprompt("Email address", tmpemail, 31); r = CtdlIPCDirectoryLookup(ipc, tmpemail, buf); if (r / 100 == 2) { extract_token(diruser, buf, 0, '@', sizeof diruser); extract_token(dirnode, buf, 1, '@', sizeof dirnode); - striplt(diruser); - striplt(dirnode); + string_trim(diruser); + string_trim(dirnode); if ((strcasecmp(diruser, fullname)) || (strcasecmp(dirnode, ipc->ServInfo.nodename))) { scr_printf("\nYou can't use %s as your address.\n", tmpemail); scr_printf("It is already in use by %s @ %s.\n", diruser, dirnode); ok = 0; - safestrncpy(tmpemail, holdemail, sizeof tmpemail); + strncpy(tmpemail, holdemail, sizeof tmpemail); } } } while (ok == 0); @@ -142,8 +131,7 @@ void entregis(CtdlIPC * ipc) /* * make all messages old in current room */ -void updatels(CtdlIPC * ipc) -{ +void updatels(CtdlIPC * ipc) { char buf[256]; int r; /* IPC response code */ @@ -156,8 +144,7 @@ void updatels(CtdlIPC * ipc) /* * only make messages old in this room that have been read */ -void updatelsa(CtdlIPC * ipc) -{ +void updatelsa(CtdlIPC * ipc) { char buf[256]; int r; /* IPC response code */ @@ -170,8 +157,7 @@ void updatelsa(CtdlIPC * ipc) /* * client-based uploads (for users with their own clientware) */ -void cli_upload(CtdlIPC * ipc) -{ +void cli_upload(CtdlIPC * ipc) { char flnm[PATH_MAX]; char desc[151]; char buf[256]; @@ -220,8 +206,7 @@ void cli_upload(CtdlIPC * ipc) /* * Function used for various image upload commands */ -void cli_image_upload(CtdlIPC * ipc, char *keyname) -{ +void cli_image_upload(CtdlIPC * ipc, char *keyname) { char flnm[PATH_MAX]; char buf[256]; int r; @@ -236,7 +221,8 @@ void cli_image_upload(CtdlIPC * ipc, char *keyname) r = CtdlIPCImageUpload(ipc, 1, flnm, keyname, progress, buf); if (r / 100 == 5) { scr_printf("%s\n", buf); - } else if (r < 0) { + } + else if (r < 0) { scr_printf("Cannot upload '%s': %s\n", flnm, strerror(errno)); } /* else upload succeeded */ @@ -246,8 +232,7 @@ void cli_image_upload(CtdlIPC * ipc, char *keyname) /* * protocol-based uploads (Xmodem, Ymodem, Zmodem) */ -void upload(CtdlIPC * ipc, int c) -{ /* c = upload mode */ +void upload(CtdlIPC * ipc, int c) { /* c = upload mode */ char flnm[PATH_MAX]; char desc[151]; char buf[256]; @@ -317,7 +302,8 @@ void upload(CtdlIPC * ipc, int c) execlp("rz", "rz", NULL); exit(1); } - } else + } + else do { b = ka_wait(&a); } while ((b != xfer_pid) && (b != (-1))); @@ -345,11 +331,11 @@ void upload(CtdlIPC * ipc, int c) nukedir(tempdir); } + /* * validate a user (returns 0 for successful validation, nonzero if quitting) */ -int val_user(CtdlIPC * ipc, char *user, int do_validate) -{ +int val_user(CtdlIPC * ipc, char *user, int do_validate) { int a; char cmd[256]; char buf[256]; @@ -395,7 +381,8 @@ int val_user(CtdlIPC * ipc, char *user, int do_validate) * Webcit limits to 6 as does the code here but there are 7 in axdefs.h */ scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]); - } else { + } + else { scr_printf("%s\n%s\n", user, &cmd[4]); } if (resp) @@ -432,8 +419,7 @@ int val_user(CtdlIPC * ipc, char *user, int do_validate) /* * Validate new users */ -void validate(CtdlIPC * ipc) -{ +void validate(CtdlIPC * ipc) { char cmd[256]; char buf[256]; int finished = 0; @@ -453,8 +439,8 @@ void validate(CtdlIPC * ipc) } while (finished == 0); } -void subshell(void) -{ + +void subshell(void) { int a, b; stty_ctdl(SB_RESTORE); @@ -475,8 +461,7 @@ void subshell(void) /* * <.A>ide ile elete command */ -void deletefile(CtdlIPC * ipc) -{ +void deletefile(CtdlIPC * ipc) { char filename[32]; char buf[256]; @@ -491,8 +476,7 @@ void deletefile(CtdlIPC * ipc) /* * <.A>ide ile ove command */ -void movefile(CtdlIPC * ipc) -{ +void movefile(CtdlIPC * ipc) { char filename[64]; char newroom[ROOMNAMELEN]; char buf[256]; @@ -509,8 +493,7 @@ void movefile(CtdlIPC * ipc) /* * list of users who have filled out a bio */ -void list_bio(CtdlIPC * ipc) -{ +void list_bio(CtdlIPC * ipc) { char buf[256]; char *resp = NULL; int pos = 1; @@ -537,11 +520,8 @@ void list_bio(CtdlIPC * ipc) } -/* - * read bio - */ -void read_bio(CtdlIPC * ipc) -{ +// read bio +void read_bio(CtdlIPC * ipc) { char who[256]; char buf[256]; char *resp = NULL;