From: ambar Date: Tue, 1 Sep 1987 18:07:42 +0000 (+0000) Subject: added com_err_hook fix; X-Git-Tag: BETA5-24-88~76 X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/0faf7beefc0f0bfb75a81594ba099c7dc97b3391 added com_err_hook fix; picked off LOTS of lint. --- diff --git a/clients/mailmaint/mailmaint.c b/clients/mailmaint/mailmaint.c index 47c07b5d..033345ca 100644 --- a/clients/mailmaint/mailmaint.c +++ b/clients/mailmaint/mailmaint.c @@ -5,6 +5,7 @@ #ifndef lint static char rcsid_mailmaint_c[] = "$Header$"; + #endif lint /***********************************************************************/ @@ -35,16 +36,16 @@ static char *whoami; static int status; static void scream(); char *ds(); -static int bool_answer(); typedef struct list_info { - char *acl; - char *desc; - char *expdate; -} List_info; - -static char *ascbuff={"0123456789"}; -static int print_2(), print_1(); + char *acl; + char *desc; + char *expdate; +} List_info; + +static char *ascbuff = {"0123456789"}; +static int +print_2(), print_1(); static List_info *current_li = (List_info *) NULL; static int get_list_info(); static int fetch_list_info(); @@ -55,12 +56,15 @@ char *strcpy(); char *getlogin(); char *strsave(); char *getenv(); +char *calloc(); + +uid_t getuid(); typedef struct _menu { int num_items; char *title; char **items; -}MENU; +} MENU; MENU *main_menu, *help_menu; @@ -71,100 +75,108 @@ char *uname; /****************************************************/ +/*ARGSUSED*/ main(argc, argv) - int argc; - char *argv[]; - -{ - - int use_menu = 1; - char buf[BUFSIZ]; - - init_sms_err_tbl(); - init_krb_err_tbl(); - - if (getenv("TERM") == (char *) NULL) { - printf("Please set your TERM environment variable\n"); - goto punt; - } - if (getenv("TERMCAP") == (char *) NULL) { - printf("Please set your TERMCAP environment variable\n"); - goto punt; - } - if ((whoami = rindex(argv[0], '/')) == NULL) - whoami = argv[0]; - else - whoami++; - uname = (char *) calloc(20, 1); - if ((current_li = (List_info *) malloc(sizeof(List_info))) - == (List_info *) NULL) { - (void) sprintf(buf, ": allocating list info"); - goto punt; - } else { - current_li->acl = (char *) NULL; - current_li->desc = (char *) NULL; - current_li->expdate = (char *) NULL; - } - if ((uname = getlogin()) == NULL) { - struct passwd *getpwuid(); - uname = getpwuid(getuid())->pw_name; - } - uname = (uname && strlen(uname))? ds(uname): ""; + int argc; + char *argv[]; + +{ + + int use_menu = 1; + char buf[BUFSIZ]; + extern void sms_com_err_hook(); + + init_sms_err_tbl(); + init_krb_err_tbl(); + set_com_err_hook(sms_com_err_hook); + + /* + * This shouldn't be here.... the experienced user will catch the error + * -- the inexperienced one will just be confused. + * + * if (getenv("TERM") == (char *) NULL) { Put_message("Please set your TERM + * environment variable\n"); goto punt; } if (getenv("TERMCAP") == (char + * *) NULL) { Put_message("Please set your TERMCAP environment + * variable\n"); goto punt; } + * + */ + if ((whoami = rindex(argv[0], '/')) == NULL) + whoami = argv[0]; + else + whoami++; + uname = calloc(20, 1); + if ((current_li = (List_info *) malloc(sizeof(List_info))) + == (List_info *) NULL) { + (void) sprintf(buf, ": allocating list info"); + goto punt; + } + else { + current_li->acl = (char *) NULL; + current_li->desc = (char *) NULL; + current_li->expdate = (char *) NULL; + } + if ((uname = getlogin()) == NULL) { + struct passwd *getpwuid(); - printf("Connecting to database for %s...please hold on.\n", uname); + uname = getpwuid((int) getuid())->pw_name; + } + uname = (uname && strlen(uname)) ? ds(uname) : ""; - status = sms_connect(); - if (status) { - (void) sprintf(buf, "\nConnection to SMS server failed"); - goto punt; - } + printf("Connecting to database for %s...please hold on.\n", uname); - status = sms_auth(); - if (status) { - (void) sprintf(buf, "\nAuthorization failed.\n"); - goto punt; - } + status = sms_connect(); + if (status) { + (void) sprintf(buf, "\nConnection to SMS server failed"); + goto punt; + } - if (use_menu) { - initscr(); - if ((LINES < 24) || (COLS < 60)) { - printf("Display window too small.\n\n"); + status = sms_auth(); + if (status) { + (void) sprintf(buf, "\nAuthorization failed.\n"); + goto punt; + } - printf("Current window parameters are (%d lines, %d columns)\n", LINES, COLS); - printf("Please resize your window\n"); - printf("to at least 24 lines and 60 columns.\n"); - exit(0); - } - raw(); - noecho(); - position[0] = oldpos[0] = 1; - level = 0; - pack_main_menu(); - pack_help_menu(); - display_menu(main_menu); - get_main_input(); - cls(); - endwin(); + if (use_menu) { + (void) initscr(); + if ((LINES < 24) || (COLS < 60)) { + Put_message("Display window too small.\n\n"); + (void) sprintf(buf, "Current window parameters are (%d \ +lines, %d columns)\n", LINES, COLS); + Put_message(buf); + Put_message("Please resize your window\n"); + Put_message("to at least 24 lines and 60 columns.\n"); + exit(0); } - sms_disconnect(); - exit(0); + raw(); + noecho(); + position[0] = oldpos[0] = 1; + level = 0; + pack_main_menu(); + pack_help_menu(); + display_menu(main_menu); + get_main_input(); + cls(); + endwin(); + } + sms_disconnect(); + exit(0); punt: - com_err(whoami, status, buf); + com_err(whoami, status, buf); /* sms_disconnect(); */ - exit(1); + exit(1); } /****************************************************/ get_main_input() { -int c; -int retflg; - - while(1) { + int c; + int retflg; + + while (1) { oldpos[level] = position[level]; retflg = 0; - currow = DISPROW+2; + currow = DISPROW + 2; page = 1; toggle = num_members = moreflg = 0; c = getchar(); @@ -175,11 +187,12 @@ int retflg; c = ascbuff[position[level]]; retflg = 1; } - switch(c) { - case 'L' & 037: /* clear screen */ + switch (c) { + case 'L' & 037: /* clear screen */ display_menu(main_menu); break; - case 'q': case 'Q': /*quit*/ + case 'q': + case 'Q': /* quit */ position[level] = 7; highlight(main_menu); if (retflg) { @@ -187,43 +200,43 @@ int retflg; return; } break; - case '1': /* show all lists */ + case '1': /* show all lists */ position[level] = 1; if (retflg) { show_all(); } break; - case '2': /* get all members of a list */ + case '2': /* get all members of a list */ position[level] = 2; if (retflg) { - list_members(); + (void) list_members(); } break; - case '3': /* display list which user is a recipient */ + case '3': /* display list which user is a recipient */ position[level] = 3; if (retflg) { list_by_member(); } break; - case '4': /* show description */ + case '4': /* show description */ position[level] = 4; if (retflg) { show_list_info(); } break; - case '5': /* add to list */ + case '5': /* add to list */ position[level] = 5; if (retflg) { add_member(); } break; - case '6': /* delete */ + case '6': /* delete */ position[level] = 6; if (retflg) { delete_member(); } break; - case 27: /* up arrow */ + case 27: /* up arrow */ c = getchar(); if (c == 91) { c = getchar(); @@ -232,7 +245,7 @@ int retflg; if (!position[level]) position[level] = 7; } - else { + else { if (c == 66) { position[level]++; if (position[level] > 7) @@ -248,21 +261,21 @@ int retflg; highlight(main_menu); } } + /****************************************************/ show_list_info() { -char *argv[2]; -char *buf; -char c; + char *buf; + char c; show_text(DISPROW, STARTCOL, "Show information about a list.\n\r"); - buf = (char *) calloc(1024, 1); - if (Prompt("Enter List Name: ", buf, LISTSIZE)==1) { - printf("\n\r"); + buf = calloc((unsigned)1024, 1); + if (Prompt("Enter List Name: ", buf, LISTSIZE) == 1) { + Put_message("\n\r"); if (fetch_list_info(buf, current_li) == 0) { (void) sprintf(buf, "Description: %s\n\r", current_li->desc); - if (strlen(buf) > 60) - display_buff(buf); + if (strlen(buf) > 60) + (void) display_buff(buf); else show_text(currow, STARTCOL, buf); currow++; @@ -282,9 +295,10 @@ char c; } clrwin(DISPROW); } + /****************************************************/ display_buff(buf) -char *buf; + char *buf; { int i, cnt; char *printbuf; @@ -295,76 +309,82 @@ char *buf; maxcol = 80; cnt = 0; - printbuf = (char *) calloc(maxcol, 1); - for(i=0; i<=strlen(buf); i++) { + printbuf = calloc((unsigned)maxcol, 1); + for (i = 0; i <= strlen(buf); i++) { printbuf[cnt] = buf[i]; cnt++; if (cnt >= maxcol) { - start_display_buff(printbuf); + (void) start_display_buff(printbuf); cnt = 0; free(printbuf); - printbuf = (char *) calloc(maxcol, 1); + printbuf = calloc((unsigned)maxcol, 1); } } - if (strlen(buf)%maxcol != 0) { - start_display_buff(printbuf); + if (strlen(buf) % maxcol != 0) { + (void) start_display_buff(printbuf); free(printbuf); } - return(0); + return (0); } + /****************************************************/ start_display_buff(buff) -char *buff; + char *buff; { -char c; -char buffer[5]; + char buffer[5]; num_members++; if (moreflg) - return; - if (currow >= LINES-2) { + return (0); + if (currow >= LINES - 2) { page++; currow++; - mvcur(0,0,currow,STARTCOL); + mvcur(0, 0, currow, STARTCOL); refresh(); if (Prompt("--RETURN for more, ctl-c to exit--", buffer, 1) == 0) { - printf("Flushing query..."); - moreflg = 1; - return(0); + Put_message("Flushing query..."); + moreflg = 1; + return (0); } - clrwin(DISPROW+2); - currow = DISPROW+2; + clrwin(DISPROW + 2); + currow = DISPROW + 2; show_text(currow, STARTCOL, "continued"); currow++; } show_text(currow, STARTCOL, buff); currow++; + return (0); } + /****************************************************/ add_member() { -char *argv[3]; -char *buf; -char c; + static char *argv[] = { + "add_member_to_list", + 0, + 0, + 0 + }; + char *buf; + char c; show_text(DISPROW, STARTCOL, "Add yourself to a list\n\r"); - buf = (char *) calloc(LISTMAX, 1); - if (Prompt("Enter List Name: ", buf, LISTSIZE)==1) { - printf("\r\n"); - argv[0] = strsave(buf); - argv[1] = strsave("user"); - argv[2] = strsave(uname); - if (status = sms_query("add_member_to_list", 3, argv, - scream, (char *) NULL)) { - printf("\r\n"); + buf = calloc(LISTMAX, 1); + if (Prompt("Enter List Name: ", buf, LISTSIZE) == 1) { + Put_message("\r\n"); + argv[1] = strsave(buf); + argv[2] = strsave("user"); + argv[3] = strsave(uname); + if (status = sms_query_internal(3, argv, scream, (char *) NULL)) { + Put_message("\r\n"); com_err(whoami, status, " found.\n"); } else { - sprintf(buf, "User %s added to list\r", uname); - show_text(DISPROW+3, STARTCOL, buf); + (void) sprintf(buf, "User %s added to list\r", uname); + show_text(DISPROW + 3, STARTCOL, buf); } - currow = DISPROW+4; - show_text(DISPROW+4, STARTCOL, "Press any Key to continue..."); + currow = DISPROW + 4; + show_text(DISPROW + 4, STARTCOL, "Press any Key to continue..."); c = getchar(); } clrwin(DISPROW); @@ -373,61 +393,66 @@ char c; /****************************************************/ delete_member() { -char *argv[3]; -char *buf; -char c; + static char *argv[] = { + "delete_member_from_list", + 0, + 0, + 0 + }; + char *buf; + char c; show_text(DISPROW, STARTCOL, "Remove yourself from a list\n\r"); - buf = (char *) calloc(LISTMAX, 1); - if (Prompt("Enter List Name: ", buf, LISTSIZE)==1) { - printf("\r\n"); - argv[0] = strsave(buf); - argv[1] = strsave("user"); - argv[2] = strsave(uname); - if (status = sms_query("delete_member_from_list", 3, argv, - scream, (char *) NULL)) { - printf("\r\n"); + buf = calloc(LISTMAX, 1); + if (Prompt("Enter List Name: ", buf, LISTSIZE) == 1) { + Put_message("\r\n"); + argv[1] = strsave(buf); + argv[2] = strsave("user"); + argv[3] = strsave(uname); + if (status = sms_query_internal(3, argv, scream, (char *) NULL)) { + Put_message("\r\n"); com_err(whoami, status, " found.\n"); } else { - sprintf(buf, "User %s deleted from list\r", uname); - show_text(DISPROW+3, STARTCOL, buf); + (void) sprintf(buf, "User %s deleted from list\r", uname); + show_text(DISPROW + 3, STARTCOL, buf); } - currow=DISPROW+4; - show_text(DISPROW+4, STARTCOL, "Press any Key to continue..."); + currow = DISPROW + 4; + show_text(DISPROW + 4, STARTCOL, "Press any Key to continue..."); c = getchar(); } clrwin(DISPROW); } -/****************************************************/ -list_by_member(argc, argv) +/****************************************************/ +list_by_member() { -char *argv[3]; -char *buf; -char c; + char *nargv[3]; + char *buf; + char c; - argv[1] = strsave("user"); - argv[2] = strsave(uname); - buf = (char *) calloc(BUFSIZ, 1); - sprintf(buf, "%s is on the following lists:\r", uname); + nargv[1] = strsave("user"); + nargv[2] = strsave(uname); + buf = calloc(BUFSIZ, 1); + (void) sprintf(buf, "%s is on the following lists:\r", uname); show_text(DISPROW, STARTCOL, buf); - mvcur(0,0,currow, STARTCOL); + mvcur(0, 0, currow, STARTCOL); refresh(); - if (status = sms_query("get_lists_of_member", 2, argv+1, + if (status = sms_query("get_lists_of_member", 2, nargv + 1, print_1, (char *) NULL)) { - printf("\r\n"); - com_err(whoami, status, " in get_lists_of_member"); + Put_message("\r\n"); + com_err(whoami, status, " in get_lists_of_member"); } show_text(currow, STARTCOL, "Press any Key to continue..."); c = getchar(); clrwin(DISPROW); return; } + /****************************************************/ show_all() { -char c; + char c; show_text(DISPROW, STARTCOL, "This function may take a while...proceed[y]?"); c = getchar(); @@ -435,44 +460,48 @@ char c; erase_line(DISPROW, STARTCOL); return; } - move(DISPROW+1, STARTCOL); + move(DISPROW + 1, STARTCOL); addstr("Processing query...please hold"); refresh(); - list_all_groups(); + (void) list_all_groups(); } /****************************************************/ +/*ARGSUSED*/ static int print_1(argc, argv, callback) - int argc; - char *argv[], *callback; + int argc; + char *argv[], *callback; { - char buf[BUFSIZ]; + char buf[BUFSIZ]; - /* no newline 'cause Put_message adds one */ - (void) sprintf(buf, "%s\r", argv[0]); - start_display(buf); + /* no newline 'cause Put_message adds one */ + (void) sprintf(buf, "%s\r", argv[0]); + (void) start_display(buf); - return (0); + return (0); } + /****************************************************/ +/*ARGSUSED*/ static int print_all(argc, argv, callback) - int argc; - char *argv[], *callback; -{ - char buf[BUFSIZ]; - if (moreflg) - return; - if (first_time) { - erase_line(DISPROW+1, STARTCOL); - show_text(DISPROW+1, STARTCOL, "All mailing lists:"); - first_time = 0; - } - (void) sprintf(buf, "%s\r", argv[0]); - start_display(buf); + int argc; + char *argv[], *callback; +{ + char buf[BUFSIZ]; + if (moreflg) return (0); + if (first_time) { + erase_line(DISPROW + 1, STARTCOL); + show_text(DISPROW + 1, STARTCOL, "All mailing lists:"); + first_time = 0; + } + (void) sprintf(buf, "%s\r", argv[0]); + (void) start_display(buf); + + return (0); } /****************************************************/ @@ -481,14 +510,15 @@ list_all_groups() first_time = 1; if (status = sms_query("get_all_visible_maillists", 0, (char **) NULL, - print_all, (char *) NULL)) { - printf("\r\n"); + print_all, (char *) NULL)) { + Put_message("\r\n"); com_err(whoami, status, " in list_all_groups\n"); } end_display(); return (DM_NORMAL); /* HA! */ } + /****************************************************/ list_members() { @@ -498,68 +528,69 @@ list_members() found_some = 0; move(DISPROW, STARTCOL); - mvcur(0,0,DISPROW,STARTCOL); + mvcur(0, 0, DISPROW, STARTCOL); refresh(); - buf = (char *) calloc(LISTMAX, 1); - if (Prompt("Enter List Name: ", buf, LISTSIZE)==1) { - sprintf(buffer, "The members of list '%s' are:", buf); - show_text(DISPROW+1, STARTCOL, buffer); + buf = calloc(LISTMAX, 1); + if (Prompt("Enter List Name: ", buf, LISTSIZE) == 1) { + (void) sprintf(buffer, "The members of list '%s' are:", buf); + show_text(DISPROW + 1, STARTCOL, buffer); argv[0] = buf; if (status = sms_query("get_members_of_list", 1, argv, print_2, (char *) NULL)) { - printf("\r\n"); + Put_message("\r\n"); com_err(whoami, status, " found.\n"); currow++; } if (!found_some) { - show_text(currow, STARTCOL,"List is empty (no members)."); + show_text(currow, STARTCOL, "List is empty (no members)."); currow++; } end_display(); - return; + return(0); } clrwin(DISPROW); return (DM_NORMAL); /* HA! */ } /****************************************************/ +/*ARGSUSED*/ static int print_2(argc, argv, callback) - int argc; - char *argv[], *callback; + int argc; + char *argv[], *callback; { - char buf[BUFSIZ]; + char buf[BUFSIZ]; - found_some = 1; - (void) sprintf(buf, "%s %s", argv[0], argv[1]); - start_display(buf); + found_some = 1; + (void) sprintf(buf, "%s %s", argv[0], argv[1]); + (void) start_display(buf); - return (0); + return (0); } + /****************************************************/ start_display(buff) -char *buff; + char *buff; { -char c; -char *buffer; + char *buffer; num_members++; if (moreflg) - return; - buffer = (char *) calloc(50, 1); - if (currow >= LINES-2) { + return(0); + buffer = calloc(50, 1); + if (currow >= LINES - 2) { page++; currow++; - mvcur(0,0,currow,STARTCOL); + mvcur(0, 0, currow, STARTCOL); refresh(); if (Prompt("--RETURN for more, ctl-c to exit--", buffer, 1) == 0) { - printf("Flushing query..."); - moreflg = 1; - return(0); + Put_message("Flushing query..."); + moreflg = 1; + return (0); } - clrwin(DISPROW+2); - currow = DISPROW+2; - sprintf(buffer, "Continued (Page %d)", page); + clrwin(DISPROW + 2); + currow = DISPROW + 2; + (void) sprintf(buffer, "Continued (Page %d)", page); show_text(currow, STARTCOL, buffer); currow++; toggle = 0; @@ -571,20 +602,22 @@ char *buffer; currow++; } toggle = !toggle; + return(0); } + /****************************************************/ end_display() { -char *buffer, c; + char *buffer, c; if (moreflg) { clrwin(DISPROW); return; } - buffer = (char *) calloc(50, 1); + buffer = calloc(50, 1); currow++; - sprintf(buffer, "End of List. %d Total Members\r", num_members); + (void) sprintf(buffer, "End of List. %d Total Members\r", num_members); show_text(currow, STARTCOL, buffer); currow++; show_text(currow, STARTCOL, "Press any key to continue..."); @@ -592,100 +625,88 @@ char *buffer, c; clrwin(DISPROW); } + /****************************************************/ display_menu(menu) -MENU *menu; + MENU *menu; { int i; cls(); title(menu->title); - mvcur(0,0,STARTROW, STARTCOL); + mvcur(0, 0, STARTROW, STARTCOL); refresh(); - for(i=0; i<=menu->num_items-1; i++) { - move(STARTROW+i, STARTCOL); + for (i = 0; i <= menu->num_items - 1; i++) { + move(STARTROW + i, STARTCOL); standend(); addstr(menu->items[i]); refresh(); } - center_text(STARTROW+menu->num_items+2, + center_text(STARTROW + menu->num_items + 2, "Enter a number, , or ."); if (!level) - center_text(STARTROW+menu->num_items+3, - "Press 'q' to exit, to confirm choice."); + center_text(STARTROW + menu->num_items + 3, + "Press 'q' to exit, to confirm choice."); else - center_text(STARTROW+menu->num_items+3, - "Press 'q' to exit, 'r' for main menu, to confirm choice."); + center_text(STARTROW + menu->num_items + 3, + "Press 'q' to exit, 'r' for main menu, to confirm choice."); if (!level) highlight(main_menu); -} +} /****************************************************/ pack_main_menu() { -char *buf; + char *buf; -main_menu = (MENU *) malloc((unsigned) sizeof(MENU)); -main_menu->num_items = 7; -main_menu->items = (char **) malloc((unsigned) sizeof(char *) * main_menu->num_items); + main_menu = (MENU *) malloc((unsigned) sizeof(MENU)); + main_menu->num_items = 7; + main_menu->items = (char **) malloc((unsigned) sizeof(char *) * main_menu->num_items); -buf = (char *) calloc(50, 1); -sprintf(buf, "Mail List Program for %s", uname); -main_menu->title = strsave(buf); -main_menu->items[0] = strsave("1. Show all mailing lists."); -main_menu->items[1] = strsave("2. Get all members of a mailing list."); -main_menu->items[2] = strsave("3. Display lists of which you are a member."); -main_menu->items[3] = strsave("4. Show description of list."); -main_menu->items[4] = strsave("5. Add yourself to a mailing list."); -main_menu->items[5] = strsave("6. Delete yourself from a mailing list."); -main_menu->items[6] = strsave("q. Quit."); + buf = calloc(50, 1); + (void) sprintf(buf, "Mail List Program for %s", uname); + main_menu->title = strsave(buf); + main_menu->items[0] = strsave("1. Show all mailing lists."); + main_menu->items[1] = strsave("2. Get all members of a mailing list."); + main_menu->items[2] = strsave("3. Display lists of which you are a member."); + main_menu->items[3] = strsave("4. Show description of list."); + main_menu->items[4] = strsave("5. Add yourself to a mailing list."); + main_menu->items[5] = strsave("6. Delete yourself from a mailing list."); + main_menu->items[6] = strsave("q. Quit."); } /****************************************************/ pack_help_menu() { -help_menu = (MENU *) malloc((unsigned) sizeof(MENU)); -help_menu->num_items = 5; -help_menu->items = (char **) malloc((unsigned) sizeof(char *) * help_menu->num_items); + help_menu = (MENU *) malloc((unsigned) sizeof(MENU)); + help_menu->num_items = 5; + help_menu->items = (char **) malloc((unsigned) sizeof(char *) * help_menu->num_items); -help_menu->title = strsave("madm is designed as a basic mail list administration program."); -help_menu->items[0] = strsave("if you need to perform more advanced list manipulation like"); -help_menu->items[1] = strsave("adding lists, or changing list characteristics, refer to the"); -help_menu->items[2] = strsave("program listmaint."); -help_menu->items[3] = strsave(" "); -help_menu->items[4] = strsave("Press any key to continue."); + help_menu->title = strsave("madm is designed as a basic mail list administration program."); + help_menu->items[0] = strsave("if you need to perform more advanced list manipulation like"); + help_menu->items[1] = strsave("adding lists, or changing list characteristics, refer to the"); + help_menu->items[2] = strsave("program listmaint."); + help_menu->items[3] = strsave(" "); + help_menu->items[4] = strsave("Press any key to continue."); } -/****************************************************/ -func_help_menu() -{ -int i; -char c; -show_text(currow, STARTCOL, help_menu->title); -for(i=0;i<=help_menu->num_items-1;i++) { - currow++; - show_text(currow, STARTCOL, help_menu->items[i]); -} -c=getchar(); -clrwin(DISPROW); -} /****************************************************/ highlight(menu) -MENU *menu; + MENU *menu; { if (oldpos[level] != position[level]) { - move(STARTROW+oldpos[level]-1, STARTCOL); + move(STARTROW + oldpos[level] - 1, STARTCOL); standend(); - addstr(menu->items[oldpos[level]-1]); + addstr(menu->items[oldpos[level] - 1]); refresh(); } - move(STARTROW+position[level]-1, STARTCOL); + move(STARTROW + position[level] - 1, STARTCOL); standout(); - addstr(menu->items[position[level]-1]); + addstr(menu->items[position[level] - 1]); refresh(); standend(); refresh(); @@ -693,66 +714,48 @@ MENU *menu; /****************************************************/ title(buff) -char *buff; -{ - move(0, MAX(0, (COLS - strlen(buff))>>1)); - standout(); - addstr(buff); - refresh(); - standend(); -} -/****************************************************/ -rvid(row, buff) -int row; -char *buff; + char *buff; { - move(row, STARTCOL); - mvcur(0,0,row,STARTCOL); - addstr(buff); + move(0, MAX(0, (COLS - strlen(buff)) >> 1)); standout(); + addstr(buff); refresh(); - move(row, STARTCOL); - mvcur(0,0,row,STARTCOL); - refresh(); - printf("%s", buff); standend(); - refresh(); } - /****************************************************/ center_text(row, buff) -int row; -char *buff; + int row; + char *buff; { - move(row, MAX(0, (COLS - strlen(buff))>>1)); + move(row, MAX(0, (COLS - strlen(buff)) >> 1)); addstr(buff); refresh(); } /****************************************************/ show_text(row, col, buff) -int row, col; -char *buff; + int row, col; + char *buff; { - mvcur(0,0,row,col); + mvcur(0, 0, row, col); refresh(); printf("%s", buff); } /****************************************************/ erase_line(row, col) -int row, col; + int row, col; { -char *buff; -int i; + char *buff; + int i; - buff = (char *) calloc(COLS, 1); - for(i=0; i<=COLS-2; i++) + buff = calloc((unsigned)COLS, 1); + for (i = 0; i <= COLS - 2; i++) buff[i] = ' '; - buff[i] = 0; /* just to be sure ! */ + buff[i] = 0; /* just to be sure ! */ move(row, col); - mvcur(0,0,row,col); + mvcur(0, 0, row, col); printf("%s", buff); refresh(); } @@ -766,56 +769,62 @@ cls() /****************************************************/ clrwin(erase_row) -int erase_row; + int erase_row; { -int i; -char *buff; -int maxcol; + int i; + char *buff; + int maxcol; maxcol = COLS; if (maxcol > 80) - maxcol = 80; /* limit width */ + maxcol = 80; /* limit width */ - buff = (char *) calloc(maxcol+1, 1); - for(i=0; i<=maxcol-1; i++) + buff = calloc((unsigned)maxcol + 1, 1); + for (i = 0; i <= maxcol - 1; i++) buff[i] = ' '; - buff[i] = 0; /* just to be sure ! */ - mvcur(0,0,erase_row, STARTCOL); + buff[i] = 0; /* just to be sure ! */ + mvcur(0, 0, erase_row, STARTCOL); refresh(); - for(i=erase_row; i<=currow-1; i++) { + for (i = erase_row; i <= currow - 1; i++) { printf("%s\n\r", buff); } - printf("%s", buff); - mvcur(erase_row,STARTCOL,STARTROW+oldpos[level]-1, STARTCOL); + printf("%s", buff); + mvcur(erase_row, STARTCOL, STARTROW + oldpos[level] - 1, STARTCOL); refresh(); } /****************************************************/ -char *strsave(s) - char *s; +char * +strsave(s) + char *s; { char *p; - - if ((p = (char *) calloc(1, strlen(s)+1)) != NULL) { - strcpy(p, s); + + if ((p = calloc((unsigned)1, (unsigned)(strlen(s) + 1))) != NULL) { + (void) strcpy(p, s); } else - printf("error in alloc\n\r"); - return(p); + Put_message("error in alloc\n\r"); + return (p); } + /****************************************************/ /* jean's routine ??? */ -static void scream() +static void +scream() { - com_err(whoami, status, "\nAn SMS update returned a value -- programmer \ + com_err(whoami, status, "\nAn SMS update returned a value -- programmer \ botch\n"); - sms_disconnect(); - exit(1); + sms_disconnect(); + exit(1); } + /****************************************************/ -static int fetch_list_info(list, li) -char *list; -List_info *li; +/*ARGSUSED*/ +static int +fetch_list_info(list, li) + char *list; + List_info *li; { char *argv[1]; @@ -831,21 +840,22 @@ List_info *li; } /* ARGSUSED */ -static int get_list_info(argc, argv) -int argc; -char **argv; -{ - - if (current_li->acl) - free(current_li->acl); - current_li->acl = strsave(argv[2]); - if (current_li->desc) - free(current_li->desc); - current_li->desc = strsave(argv[3]); - if (current_li->expdate) - free(current_li->expdate); - current_li->expdate = strsave(argv[4]); - return (0); +static int +get_list_info(argc, argv) + int argc; + char **argv; +{ + + if (current_li->acl) + free(current_li->acl); + current_li->acl = strsave(argv[2]); + if (current_li->desc) + free(current_li->desc); + current_li->desc = strsave(argv[3]); + if (current_li->expdate) + free(current_li->expdate); + current_li->expdate = strsave(argv[4]); + return (0); } @@ -853,18 +863,19 @@ char **argv; /****************************************************/ /* Prompt the user for input */ -int Prompt(prompt, buf, buflen) +int +Prompt(prompt, buf, buflen) char *prompt; char *buf; int buflen; { int c; char *p; - int y, x, oldx; + int x, oldx; printf("%s", prompt); refresh(); - for (p = buf; abs(strlen(p)-strlen(buf)) <= buflen;) { + for (p = buf; abs(strlen(p) - strlen(buf)) <= buflen;) { refresh(); c = getchar(); switch (c) { @@ -875,23 +886,23 @@ int Prompt(prompt, buf, buflen) case CTL('L'): cls(); display_menu(main_menu); - return 0; + return (0); case '\n': case '\r': - printf("\r"); + Put_message("\r"); *p = '\0'; - if (strlen(buf) < 1) /* only /n or /r in buff */ - return -1; + if (strlen(buf) < 1)/* only /n or /r in buff */ + return (-1); else - return 1; + return (1); case '\b': case '\177': if (p > buf) { p--; x--; - printf("\b"); - printf(" "); - printf("\b"); + Put_message("\b"); + Put_message(" "); + Put_message("\b"); } break; case CTL('U'): @@ -901,7 +912,7 @@ int Prompt(prompt, buf, buflen) p = buf; break; default: - if (abs(strlen(p)-strlen(buf)) >= buflen) { + if (abs(strlen(p) - strlen(buf)) >= buflen) { printf("%c", 7); break; } @@ -909,48 +920,28 @@ int Prompt(prompt, buf, buflen) (void) addch(c); *p++ = c; x++; - } else - putchar(CTL('G')); + } + else + (void) putchar(CTL('G')); break; } } + return(0); } /* * duplicate string */ -char *ds(str) - char *str; -{ - register char *newstr = malloc((unsigned) strlen(str) + 1); - - if (newstr == (char *) NULL) - return ((char *) NULL); - else - return (strcpy(newstr, str)); -} - -int bool_query(name, argc, argv) -char *name; -int argc; -char *argv[]; +char * +ds(str) + char *str; { - int result = 0; - sms_query(name, argc, argv, bool_answer, (caddr_t) &result); - return result; -} + register char *newstr = malloc((unsigned) strlen(str) + 1); -static int bool_answer(argc, argv, arg) -int argc; -char *argv[]; -caddr_t arg; -{ - int *result = (int *) arg; - if (strcmp(argv[0], "true") == 0) - *result = 1; - else if (strcmp(argv[0], "false") == 0) - *result = 0; - return; + if (newstr == (char *) NULL) + return ((char *) NULL); + else + return (strcpy(newstr, str)); } /*