diff options
| author | Tom Yu <tlyu@mit.edu> | 2009-12-07 22:36:41 +0000 |
|---|---|---|
| committer | Tom Yu <tlyu@mit.edu> | 2009-12-07 22:36:41 +0000 |
| commit | ac911f663389980be59a0f9ee98f062e6c627658 (patch) | |
| tree | c423ac7174c1a82a107013894a6944a506e68774 /src/util/ss | |
| parent | 741938feb12538b659a36d7e0329efe6a5550669 (diff) | |
| download | krb5-ac911f663389980be59a0f9ee98f062e6c627658.tar.gz krb5-ac911f663389980be59a0f9ee98f062e6c627658.tar.xz krb5-ac911f663389980be59a0f9ee98f062e6c627658.zip | |
Mark and reindent util, with some exceptions
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23455 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/ss')
| -rw-r--r-- | src/util/ss/copyright.h | 33 | ||||
| -rw-r--r-- | src/util/ss/data.c | 1 | ||||
| -rw-r--r-- | src/util/ss/error.c | 13 | ||||
| -rw-r--r-- | src/util/ss/execute_cmd.c | 65 | ||||
| -rw-r--r-- | src/util/ss/help.c | 173 | ||||
| -rw-r--r-- | src/util/ss/invocation.c | 163 | ||||
| -rw-r--r-- | src/util/ss/list_rqs.c | 5 | ||||
| -rw-r--r-- | src/util/ss/listen.c | 89 | ||||
| -rw-r--r-- | src/util/ss/mit-sipb-copyright.h | 33 | ||||
| -rw-r--r-- | src/util/ss/mk_cmds.c | 31 | ||||
| -rw-r--r-- | src/util/ss/options.c | 27 | ||||
| -rw-r--r-- | src/util/ss/pager.c | 109 | ||||
| -rw-r--r-- | src/util/ss/parse.c | 179 | ||||
| -rw-r--r-- | src/util/ss/prompt.c | 11 | ||||
| -rw-r--r-- | src/util/ss/request_tbl.c | 85 | ||||
| -rw-r--r-- | src/util/ss/requests.c | 15 | ||||
| -rw-r--r-- | src/util/ss/ss.h | 17 | ||||
| -rw-r--r-- | src/util/ss/ss_internal.h | 27 | ||||
| -rw-r--r-- | src/util/ss/test_ss.c | 89 | ||||
| -rw-r--r-- | src/util/ss/utils.c | 43 |
20 files changed, 614 insertions, 594 deletions
diff --git a/src/util/ss/copyright.h b/src/util/ss/copyright.h index 07d487f9d..96042f8ed 100644 --- a/src/util/ss/copyright.h +++ b/src/util/ss/copyright.h @@ -1,21 +1,22 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* -Copyright 1987, 1989 by the Student Information Processing Board - of the Massachusetts Institute of Technology + Copyright 1987, 1989 by the Student Information Processing Board + of the Massachusetts Institute of Technology -Permission to use, copy, modify, and distribute this software -and its documentation for any purpose and without fee is -hereby granted, provided that the above copyright notice -appear in all copies and that both that copyright notice and -this permission notice appear in supporting documentation, -and that the names of M.I.T. and the M.I.T. S.I.P.B. not be -used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. -Furthermore if you modify this software you must label -your software as modified software and not distribute it in such a -fashion that it might be confused with the original M.I.T. software. -M.I.T. and the M.I.T. S.I.P.B. make no representations about -the suitability of this software for any purpose. It is -provided "as is" without express or implied warranty. + Permission to use, copy, modify, and distribute this software + and its documentation for any purpose and without fee is + hereby granted, provided that the above copyright notice + appear in all copies and that both that copyright notice and + this permission notice appear in supporting documentation, + and that the names of M.I.T. and the M.I.T. S.I.P.B. not be + used in advertising or publicity pertaining to distribution + of the software without specific, written prior permission. + Furthermore if you modify this software you must label + your software as modified software and not distribute it in such a + fashion that it might be confused with the original M.I.T. software. + M.I.T. and the M.I.T. S.I.P.B. make no representations about + the suitability of this software for any purpose. It is + provided "as is" without express or implied warranty. */ diff --git a/src/util/ss/data.c b/src/util/ss/data.c index dd6341c0c..1a56dc76f 100644 --- a/src/util/ss/data.c +++ b/src/util/ss/data.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1987, 1988, 1989 Massachusetts Institute of Technology * (Student Information Processing Board) diff --git a/src/util/ss/error.c b/src/util/ss/error.c index ee2738aef..daff8497d 100644 --- a/src/util/ss/error.c +++ b/src/util/ss/error.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2007 Massachusetts Institute of Technology. * All Rights Reserved. @@ -41,13 +42,13 @@ char * ss_name(sci_idx) infop = ss_info(sci_idx); if (infop->current_request == (char const *)NULL) { - return strdup(infop->subsystem_name); + return strdup(infop->subsystem_name); } else { - char *ret_val; - if (asprintf(&ret_val, "%s (%s)", - infop->subsystem_name, infop->current_request) < 0) - return NULL; - return ret_val; + char *ret_val; + if (asprintf(&ret_val, "%s (%s)", + infop->subsystem_name, infop->current_request) < 0) + return NULL; + return ret_val; } } diff --git a/src/util/ss/execute_cmd.c b/src/util/ss/execute_cmd.c index 6839d1c0d..6c3855c28 100644 --- a/src/util/ss/execute_cmd.c +++ b/src/util/ss/execute_cmd.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1987, 1988, 1989 by Massachusetts Institute of Technology * @@ -67,14 +68,14 @@ static int check_request_table (rqtbl, argc, argv, sci_idx) info->argc = argc; info->argv = argv; for (i = 0; (request = get_request(rqtbl, i))->command_names; i++) { - for (name = request->command_names; *name; name++) - if (!strcmp(*name, string)) { - info->current_request = request->command_names[0]; - (request->function)(argc, (const char *const *) argv, - sci_idx,info->info_ptr); - info->current_request = (char *)NULL; - return(0); - } + for (name = request->command_names; *name; name++) + if (!strcmp(*name, string)) { + info->current_request = request->command_names[0]; + (request->function)(argc, (const char *const *) argv, + sci_idx,info->info_ptr); + info->current_request = (char *)NULL; + return(0); + } } return(SS_ET_COMMAND_NOT_FOUND); } @@ -121,36 +122,36 @@ static int really_execute_command (sci_idx, argc, argv) * ss_execute_command(sci_idx, argv) * * Function: - * Executes a parsed command list within the subsystem. + * Executes a parsed command list within the subsystem. * Arguments: - * sci_idx (int) - * ss-internal index for subsystem control info structure - * argv (char *[]) - * parsed argument list + * sci_idx (int) + * ss-internal index for subsystem control info structure + * argv (char *[]) + * parsed argument list * Returns: - * (int) - * Zero if successful, ss_et_command_not_found otherwise. + * (int) + * Zero if successful, ss_et_command_not_found otherwise. * Notes: */ int ss_execute_command(sci_idx, argv) - int sci_idx; - register char *argv[]; + int sci_idx; + register char *argv[]; { - register unsigned int i, argc; - char **argp; - int ret; - - argc = 0; - for (argp = argv; *argp; argp++) - argc++; - argp = (char **)malloc((argc+1)*sizeof(char *)); - for (i = 0; i <= argc; i++) - argp[i] = argv[i]; - ret = really_execute_command(sci_idx, argc, &argp); - free(argp); - return(ret); + register unsigned int i, argc; + char **argp; + int ret; + + argc = 0; + for (argp = argv; *argp; argp++) + argc++; + argp = (char **)malloc((argc+1)*sizeof(char *)); + for (i = 0; i <= argc; i++) + argp[i] = argv[i]; + ret = really_execute_command(sci_idx, argc, &argp); + free(argp); + return(ret); } /* @@ -165,7 +166,7 @@ ss_execute_command(sci_idx, argv) * Pointer to command line to be parsed. * Returns: * (int) - * Error code. + * Error code. * Notes: */ @@ -187,7 +188,7 @@ int ss_execute_line (sci_idx, line_ptr) else { line_ptr++; system(line_ptr); - return 0; + return 0; } } diff --git a/src/util/ss/help.c b/src/util/ss/help.c index 981a75fab..4463ad45f 100644 --- a/src/util/ss/help.c +++ b/src/util/ss/help.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1987, 1988 by MIT Student Information Processing Board * @@ -8,7 +9,7 @@ #include <sys/types.h> #include <errno.h> #include <sys/file.h> -#include <fcntl.h> /* just for O_* */ +#include <fcntl.h> /* just for O_* */ #include <sys/wait.h> #include "ss_internal.h" #include "copyright.h" @@ -29,66 +30,66 @@ void ss_help (argc, argv, sci_idx, info_ptr) request_name = ss_current_request(sci_idx, &code); if (code != 0) { - ss_perror(sci_idx, code, ""); - return; /* no ss_abort_line, if invalid invocation */ + ss_perror(sci_idx, code, ""); + return; /* no ss_abort_line, if invalid invocation */ } if (argc == 1) { - ss_list_requests(argc, argv, sci_idx, info_ptr); - return; + ss_list_requests(argc, argv, sci_idx, info_ptr); + return; } else if (argc != 2) { - /* should do something better than this */ - snprintf(buffer, sizeof(buffer), - "usage:\n\t%s [topic|command]\nor\t%s\n", - request_name, request_name); - ss_perror(sci_idx, 0, buffer); - return; + /* should do something better than this */ + snprintf(buffer, sizeof(buffer), + "usage:\n\t%s [topic|command]\nor\t%s\n", + request_name, request_name); + ss_perror(sci_idx, 0, buffer); + return; } info = ss_info(sci_idx); if (info->info_dirs == (char **)NULL) { - ss_perror(sci_idx, SS_ET_NO_INFO_DIR, (char *)NULL); - return; + ss_perror(sci_idx, SS_ET_NO_INFO_DIR, (char *)NULL); + return; } if (info->info_dirs[0] == (char *)NULL) { - ss_perror(sci_idx, SS_ET_NO_INFO_DIR, (char *)NULL); - return; + ss_perror(sci_idx, SS_ET_NO_INFO_DIR, (char *)NULL); + return; } for (idx = 0; info->info_dirs[idx] != (char *)NULL; idx++) { - (void) strncpy(buffer, info->info_dirs[idx], sizeof(buffer) - 1); - buffer[sizeof(buffer) - 1] = '\0'; - (void) strncat(buffer, "/", sizeof(buffer) - 1 - strlen(buffer)); - (void) strncat(buffer, argv[1], sizeof(buffer) - 1 - strlen(buffer)); - (void) strncat(buffer, ".info", sizeof(buffer) - 1 - strlen(buffer)); - if ((fd = open(&buffer[0], O_RDONLY)) >= 0) goto got_it; + (void) strncpy(buffer, info->info_dirs[idx], sizeof(buffer) - 1); + buffer[sizeof(buffer) - 1] = '\0'; + (void) strncat(buffer, "/", sizeof(buffer) - 1 - strlen(buffer)); + (void) strncat(buffer, argv[1], sizeof(buffer) - 1 - strlen(buffer)); + (void) strncat(buffer, ".info", sizeof(buffer) - 1 - strlen(buffer)); + if ((fd = open(&buffer[0], O_RDONLY)) >= 0) goto got_it; } if ((fd = open(&buffer[0], O_RDONLY)) < 0) { - char buf[MAXPATHLEN]; - strncpy(buf, "No info found for ", sizeof(buf) - 1); - buf[sizeof(buf) - 1] = '\0'; - strncat(buf, argv[1], sizeof(buf) - 1 - strlen(buf)); - ss_perror(sci_idx, 0, buf); - return; + char buf[MAXPATHLEN]; + strncpy(buf, "No info found for ", sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; + strncat(buf, argv[1], sizeof(buf) - 1 - strlen(buf)); + ss_perror(sci_idx, 0, buf); + return; } got_it: switch (child = fork()) { case -1: - ss_perror(sci_idx, errno, "Can't fork for pager"); - close(fd); - return; + ss_perror(sci_idx, errno, "Can't fork for pager"); + close(fd); + return; case 0: - (void) dup2(fd, 0); /* put file on stdin */ - ss_page_stdin(); + (void) dup2(fd, 0); /* put file on stdin */ + ss_page_stdin(); default: - (void) close(fd); /* what can we do if it fails? */ + (void) close(fd); /* what can we do if it fails? */ #ifdef WAIT_USES_INT - while (wait((int *)NULL) != child) { + while (wait((int *)NULL) != child) { #else - while (wait((union wait *)NULL) != child) { + while (wait((union wait *)NULL) != child) { #endif - /* do nothing if wrong pid */ - }; + /* do nothing if wrong pid */ + }; + } } -} #ifndef USE_DIRENT_H #include <sys/dir.h> @@ -96,60 +97,60 @@ got_it: #include <dirent.h> #endif -void ss_add_info_dir(sci_idx, info_dir, code_ptr) - int sci_idx; + void ss_add_info_dir(sci_idx, info_dir, code_ptr) + int sci_idx; char *info_dir; int *code_ptr; -{ - register ss_data *info; - DIR *d; - int n_dirs; - register char **dirs; + { + register ss_data *info; + DIR *d; + int n_dirs; + register char **dirs; - info = ss_info(sci_idx); - if ((info_dir == NULL) || (*info_dir == '\0')) { - *code_ptr = SS_ET_NO_INFO_DIR; - return; + info = ss_info(sci_idx); + if ((info_dir == NULL) || (*info_dir == '\0')) { + *code_ptr = SS_ET_NO_INFO_DIR; + return; + } + if ((d = opendir(info_dir)) == (DIR *)NULL) { + *code_ptr = errno; + return; + } + closedir(d); + dirs = info->info_dirs; + for (n_dirs = 0; dirs[n_dirs] != (char *)NULL; n_dirs++) + ; /* get number of non-NULL dir entries */ + dirs = (char **)realloc((char *)dirs, + (unsigned)(n_dirs + 2)*sizeof(char *)); + if (dirs == (char **)NULL) { + info->info_dirs = (char **)NULL; + *code_ptr = errno; + return; + } + info->info_dirs = dirs; + dirs[n_dirs + 1] = (char *)NULL; + dirs[n_dirs] = strdup(info_dir); + *code_ptr = 0; } - if ((d = opendir(info_dir)) == (DIR *)NULL) { - *code_ptr = errno; - return; - } - closedir(d); - dirs = info->info_dirs; - for (n_dirs = 0; dirs[n_dirs] != (char *)NULL; n_dirs++) - ; /* get number of non-NULL dir entries */ - dirs = (char **)realloc((char *)dirs, - (unsigned)(n_dirs + 2)*sizeof(char *)); - if (dirs == (char **)NULL) { - info->info_dirs = (char **)NULL; - *code_ptr = errno; - return; - } - info->info_dirs = dirs; - dirs[n_dirs + 1] = (char *)NULL; - dirs[n_dirs] = strdup(info_dir); - *code_ptr = 0; -} -void ss_delete_info_dir(sci_idx, info_dir, code_ptr) - int sci_idx; + void ss_delete_info_dir(sci_idx, info_dir, code_ptr) + int sci_idx; char *info_dir; int *code_ptr; -{ - register char **i_d; - register char **info_dirs; + { + register char **i_d; + register char **info_dirs; - info_dirs = ss_info(sci_idx)->info_dirs; - for (i_d = info_dirs; *i_d; i_d++) { - if (!strcmp(*i_d, info_dir)) { - while (*i_d) { - *i_d = *(i_d+1); - i_d++; - } - *code_ptr = 0; - return; - } + info_dirs = ss_info(sci_idx)->info_dirs; + for (i_d = info_dirs; *i_d; i_d++) { + if (!strcmp(*i_d, info_dir)) { + while (*i_d) { + *i_d = *(i_d+1); + i_d++; + } + *code_ptr = 0; + return; + } + } + *code_ptr = SS_ET_NO_INFO_DIR; } - *code_ptr = SS_ET_NO_INFO_DIR; -} diff --git a/src/util/ss/invocation.c b/src/util/ss/invocation.c index a7e17bd42..d9c4ea5fa 100644 --- a/src/util/ss/invocation.c +++ b/src/util/ss/invocation.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2007 Massachusetts Institute of Technology. * All Rights Reserved. @@ -28,7 +29,7 @@ */ #include "ss_internal.h" #include "copyright.h" -#define size sizeof(ss_data *) +#define size sizeof(ss_data *) /* XXX The memory in _ss_table never gets freed up until program exit! If you change the code to free it and stick a null pointer into @@ -36,95 +37,95 @@ not assume there are no null pointers in the middle of the array. */ int ss_create_invocation(subsystem_name, version_string, info_ptr, - request_table_ptr, code_ptr) - char *subsystem_name, *version_string; - char *info_ptr; - ss_request_table *request_table_ptr; - int *code_ptr; + request_table_ptr, code_ptr) + char *subsystem_name, *version_string; + char *info_ptr; + ss_request_table *request_table_ptr; + int *code_ptr; { - register int sci_idx; - register ss_data *new_table; - register ss_data **table, **tmp; + register int sci_idx; + register ss_data *new_table; + register ss_data **table, **tmp; - *code_ptr = 0; - table = _ss_table; - new_table = (ss_data *) malloc(sizeof(ss_data)); - if (new_table == NULL) { - *code_ptr = errno; - return -1; - } + *code_ptr = 0; + table = _ss_table; + new_table = (ss_data *) malloc(sizeof(ss_data)); + if (new_table == NULL) { + *code_ptr = errno; + return -1; + } - if (table == (ss_data **) NULL) { - table = (ss_data **) malloc(2 * size); - if (table == NULL) { - *code_ptr = errno; - return -1; - } - table[0] = table[1] = (ss_data *)NULL; - _ss_table = table; - } - initialize_ss_error_table (); + if (table == (ss_data **) NULL) { + table = (ss_data **) malloc(2 * size); + if (table == NULL) { + *code_ptr = errno; + return -1; + } + table[0] = table[1] = (ss_data *)NULL; + _ss_table = table; + } + initialize_ss_error_table (); - for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++) - ; - tmp = (ss_data **) realloc((char *)table, - ((unsigned)sci_idx+2)*size); - if (tmp == NULL) { - *code_ptr = errno; - return 0; - } - _ss_table = table = tmp; - table[sci_idx+1] = (ss_data *) NULL; - table[sci_idx] = NULL; + for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++) + ; + tmp = (ss_data **) realloc((char *)table, + ((unsigned)sci_idx+2)*size); + if (tmp == NULL) { + *code_ptr = errno; + return 0; + } + _ss_table = table = tmp; + table[sci_idx+1] = (ss_data *) NULL; + table[sci_idx] = NULL; - new_table->subsystem_name = subsystem_name; - new_table->subsystem_version = version_string; - new_table->argv = (char **)NULL; - new_table->current_request = (char *)NULL; - new_table->info_dirs = (char **)malloc(sizeof(char *)); - if (new_table->info_dirs == NULL) { - *code_ptr = errno; - free(new_table); - return 0; - } - *new_table->info_dirs = (char *)NULL; - new_table->info_ptr = info_ptr; - if (asprintf(&new_table->prompt, "%s: ", subsystem_name) < 0) { - *code_ptr = errno; - free(new_table->info_dirs); - free(new_table); - return 0; - } - new_table->abbrev_info = NULL; - new_table->flags.escape_disabled = 0; - new_table->flags.abbrevs_disabled = 0; - new_table->rqt_tables = - (ss_request_table **) calloc(2, sizeof(ss_request_table *)); - if (new_table->rqt_tables == NULL) { - *code_ptr = errno; - free(new_table->prompt); - free(new_table->info_dirs); - free(new_table); - return 0; - } - *(new_table->rqt_tables) = request_table_ptr; - *(new_table->rqt_tables+1) = (ss_request_table *) NULL; - table[sci_idx] = new_table; - return(sci_idx); + new_table->subsystem_name = subsystem_name; + new_table->subsystem_version = version_string; + new_table->argv = (char **)NULL; + new_table->current_request = (char *)NULL; + new_table->info_dirs = (char **)malloc(sizeof(char *)); + if (new_table->info_dirs == NULL) { + *code_ptr = errno; + free(new_table); + return 0; + } + *new_table->info_dirs = (char *)NULL; + new_table->info_ptr = info_ptr; + if (asprintf(&new_table->prompt, "%s: ", subsystem_name) < 0) { + *code_ptr = errno; + free(new_table->info_dirs); + free(new_table); + return 0; + } + new_table->abbrev_info = NULL; + new_table->flags.escape_disabled = 0; + new_table->flags.abbrevs_disabled = 0; + new_table->rqt_tables = + (ss_request_table **) calloc(2, sizeof(ss_request_table *)); + if (new_table->rqt_tables == NULL) { + *code_ptr = errno; + free(new_table->prompt); + free(new_table->info_dirs); + free(new_table); + return 0; + } + *(new_table->rqt_tables) = request_table_ptr; + *(new_table->rqt_tables+1) = (ss_request_table *) NULL; + table[sci_idx] = new_table; + return(sci_idx); } void ss_delete_invocation(sci_idx) - int sci_idx; + int sci_idx; { - register ss_data *t; - int ignored_code; + register ss_data *t; + int ignored_code; - t = ss_info(sci_idx); - free(t->prompt); - free(t->rqt_tables); - while(t->info_dirs[0] != (char *)NULL) - ss_delete_info_dir(sci_idx, t->info_dirs[0], &ignored_code); - free(t->info_dirs); - free(t); + t = ss_info(sci_idx); + free(t->prompt); + free(t->rqt_tables); + while(t->info_dirs[0] != (char *)NULL) + ss_delete_info_dir(sci_idx, t->info_dirs[0], &ignored_code); + free(t->info_dirs); + free(t); } diff --git a/src/util/ss/list_rqs.c b/src/util/ss/list_rqs.c index f7d03c5eb..d5b3c877b 100644 --- a/src/util/ss/list_rqs.c +++ b/src/util/ss/list_rqs.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1987, 1988 by MIT Student Information Processing Board * @@ -68,7 +69,7 @@ ss_list_requests(argc, argv, sci_idx, info_ptr) func = signal(SIGINT, SIG_IGN); #endif - fd = ss_pager_create(); /* FD_CLOEXEC set */ + fd = ss_pager_create(); /* FD_CLOEXEC set */ output = fdopen(fd, "w"); #ifdef POSIX_SIGNALS @@ -78,7 +79,7 @@ ss_list_requests(argc, argv, sci_idx, info_ptr) #endif fprintf (output, "Available %s requests:\n\n", - ss_info (sci_idx) -> subsystem_name); + ss_info (sci_idx) -> subsystem_name); for (table = ss_info(sci_idx)->rqt_tables; *table; table++) { entry = (*table)->requests; diff --git a/src/util/ss/listen.c b/src/util/ss/listen.c index 36f261961..ce8e527a4 100644 --- a/src/util/ss/listen.c +++ b/src/util/ss/listen.c @@ -1,7 +1,8 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Listener loop for subsystem library libss.a. * - * util/ss/listen.c + * util/ss/listen.c * * Copyright 1987, 1988 by MIT Student Information Processing Board * @@ -24,8 +25,8 @@ static RETSIGTYPE print_prompt() struct termios termbuf; if (tcgetattr(STDIN_FILENO, &termbuf) == 0) { - termbuf.c_lflag |= ICANON|ISIG|ECHO; - tcsetattr(STDIN_FILENO, TCSANOW, &termbuf); + termbuf.c_lflag |= ICANON|ISIG|ECHO; + tcsetattr(STDIN_FILENO, TCSANOW, &termbuf); } (void) fputs(current_info->prompt, stdout); (void) fflush(stdout); @@ -90,53 +91,53 @@ int ss_listen (sci_idx) (void) sigsetmask(mask); #endif while(!info->abort) { - print_prompt(); - *end = '\0'; + print_prompt(); + *end = '\0'; #ifdef POSIX_SIGNALS - nsig.sa_handler = listen_int_handler; /* fgets is not signal-safe */ - osig = csig; - sigaction(SIGCONT, &nsig, &csig); - if ((RETSIGTYPE (*)())csig.sa_handler==(RETSIGTYPE (*)())listen_int_handler) - csig = osig; + nsig.sa_handler = listen_int_handler; /* fgets is not signal-safe */ + osig = csig; + sigaction(SIGCONT, &nsig, &csig); + if ((RETSIGTYPE (*)())csig.sa_handler==(RETSIGTYPE (*)())listen_int_handler) + csig = osig; #else - old_sig_cont = sig_cont; - sig_cont = signal(SIGCONT, print_prompt); - if (sig_cont == print_prompt) - sig_cont = old_sig_cont; + old_sig_cont = sig_cont; + sig_cont = signal(SIGCONT, print_prompt); + if (sig_cont == print_prompt) + sig_cont = old_sig_cont; #endif - if (fgets(input, BUFSIZ, stdin) != input) { - code = SS_ET_EOF; - goto egress; - } - cp = strchr(input, '\n'); - if (cp) { - *cp = '\0'; - if (cp == input) - continue; - } + if (fgets(input, BUFSIZ, stdin) != input) { + code = SS_ET_EOF; + goto egress; + } + cp = strchr(input, '\n'); + if (cp) { + *cp = '\0'; + if (cp == input) + continue; + } #ifdef POSIX_SIGNALS - sigaction(SIGCONT, &csig, (struct sigaction *)0); + sigaction(SIGCONT, &csig, (struct sigaction *)0); #else - (void) signal(SIGCONT, sig_cont); + (void) signal(SIGCONT, sig_cont); #endif - for (end = input; *end; end++) - ; - - code = ss_execute_line (sci_idx, input); - if (code == SS_ET_COMMAND_NOT_FOUND) { - register char *c = input; - while (*c == ' ' || *c == '\t') - c++; - cp = strchr (c, ' '); - if (cp) - *cp = '\0'; - cp = strchr (c, '\t'); - if (cp) - *cp = '\0'; - ss_error (sci_idx, 0, - "Unknown request \"%s\". Type \"?\" for a request list.", - c); - } + for (end = input; *end; end++) + ; + + code = ss_execute_line (sci_idx, input); + if (code == SS_ET_COMMAND_NOT_FOUND) { + register char *c = input; + while (*c == ' ' || *c == '\t') + c++; + cp = strchr (c, ' '); + if (cp) + *cp = '\0'; + cp = strchr (c, '\t'); + if (cp) + *cp = '\0'; + ss_error (sci_idx, 0, + "Unknown request \"%s\". Type \"?\" for a request list.", + c); + } } code = 0; egress: diff --git a/src/util/ss/mit-sipb-copyright.h b/src/util/ss/mit-sipb-copyright.h index 5e8ec1731..3a1ddeb03 100644 --- a/src/util/ss/mit-sipb-copyright.h +++ b/src/util/ss/mit-sipb-copyright.h @@ -1,21 +1,22 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* -Copyright 1987 by the Student Information Processing Board - of the Massachusetts Institute of Technology + Copyright 1987 by the Student Information Processing Board + of the Massachusetts Institute of Technology -Permission to use, copy, modify, and distribute this software -and its documentation for any purpose and without fee is -hereby granted, provided that the above copyright notice -appear in all copies and that both that copyright notice and -this permission notice appear in supporting documentation, -and that the names of M.I.T. and the M.I.T. S.I.P.B. not be -used in advertising or publicity pertaining to distribution -of the software without specific, written prior permission. -Furthermore if you modify this software you must label -your software as modified software and not distribute it in such a -fashion that it might be confused with the original M.I.T. software. -M.I.T. and the M.I.T. S.I.P.B. make no representations about -the suitability of this software for any purpose. It is -provided "as is" without express or implied warranty. + Permission to use, copy, modify, and distribute this software + and its documentation for any purpose and without fee is + hereby granted, provided that the above copyright notice + appear in all copies and that both that copyright notice and + this permission notice appear in supporting documentation, + and that the names of M.I.T. and the M.I.T. S.I.P.B. not be + used in advertising or publicity pertaining to distribution + of the software without specific, written prior permission. + Furthermore if you modify this software you must label + your software as modified software and not distribute it in such a + fashion that it might be confused with the original M.I.T. software. + M.I.T. and the M.I.T. S.I.P.B. make no representations about + the suitability of this software for any purpose. It is + provided "as is" without express or implied warranty. */ diff --git a/src/util/ss/mk_cmds.c b/src/util/ss/mk_cmds.c index 8e29ccfb3..6488f7c2d 100644 --- a/src/util/ss/mk_cmds.c +++ b/src/util/ss/mk_cmds.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * make_commands.c * @@ -37,26 +38,26 @@ int main(argc, argv) char *path, *p, *q; if (argc != 2) { - fputs("Usage: ", stderr); - fputs(argv[0], stderr); - fputs("cmdtbl.ct\n", stderr); - exit(1); + fputs("Usage: ", stderr); + fputs(argv[0], stderr); + fputs("cmdtbl.ct\n", stderr); + exit(1); } path = malloc(strlen(argv[1])+4); /* extra space to add ".ct" */ strcpy(path, argv[1]); p = strrchr(path, '/'); if (p == (char *)NULL) - p = path; + p = path; else - p++; + p++; p = strrchr(p, '.'); if (p == (char *)NULL || strcmp(p, ".ct")) - strcat(path, ".ct"); + strcat(path, ".ct"); yyin = fopen(path, "r"); if (!yyin) { - perror(path); - exit(1); + perror(path); + exit(1); } p = strrchr(path, '.'); @@ -69,8 +70,8 @@ int main(argc, argv) output_file = fopen(c_file, "w+"); if (!output_file) { - perror(c_file); - exit(1); + perror(c_file); + exit(1); } fputs("/* ", output_file); @@ -83,20 +84,20 @@ int main(argc, argv) /* parse it */ result = yyparse(); /* put file descriptors back where they belong */ - fclose(yyin); /* bye bye input file */ - fclose(output_file); /* bye bye output file */ + fclose(yyin); /* bye bye input file */ + fclose(output_file); /* bye bye output file */ return result; } yyerror(s) - char *s; +char *s; { fputs(s, stderr); #ifdef NO_YYLINENO fprintf(stderr, "\nLast token was '%s'\n", last_token); #else fprintf(stderr, "\nLine %d; last token was '%s'\n", - yylineno, last_token); + yylineno, last_token); #endif } diff --git a/src/util/ss/options.c b/src/util/ss/options.c index dd648b01a..c3452f9e1 100644 --- a/src/util/ss/options.c +++ b/src/util/ss/options.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1987, 1988 by MIT Student Information Processing Board * @@ -8,25 +9,25 @@ #include "ss.h" struct option { - char *text; - long value; + char *text; + long value; }; static struct option options[] = { - { "dont_list", SS_OPT_DONT_LIST }, - { "^list", SS_OPT_DONT_LIST }, - { "dont_summarize", SS_OPT_DONT_SUMMARIZE }, - { "^summarize", SS_OPT_DONT_SUMMARIZE }, - { (char *)NULL, 0 } + { "dont_list", SS_OPT_DONT_LIST }, + { "^list", SS_OPT_DONT_LIST }, + { "dont_summarize", SS_OPT_DONT_SUMMARIZE }, + { "^summarize", SS_OPT_DONT_SUMMARIZE }, + { (char *)NULL, 0 } }; long flag_val(string) - register char *string; + register char *string; { - register struct option *opt; - for (opt = options; opt->text; opt++) - if (!strcmp(opt->text, string)) - return(opt->value); - return(0); + register struct option *opt; + for (opt = options; opt->text; opt++) + if (!strcmp(opt->text, string)) + return(opt->value); + return(0); } diff --git a/src/util/ss/pager.c b/src/util/ss/pager.c index 8e8aeeda4..be8fd0bfe 100644 --- a/src/util/ss/pager.c +++ b/src/util/ss/pager.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Pager: Routines to create a "more" running out of a particular file * descriptor. @@ -31,30 +32,30 @@ void ss_page_stdin(); #ifndef NO_FORK int ss_pager_create() { - int filedes[2]; + int filedes[2]; - if (pipe(filedes) != 0) - return(-1); + if (pipe(filedes) != 0) + return(-1); - switch((int) fork()) { - case -1: - return(-1); - case 0: - /* - * Child; dup read half to 0, close all but 0, 1, and 2 - */ - if (dup2(filedes[0], 0) == -1) - exit(1); - ss_page_stdin(); - default: - /* - * Parent: close "read" side of pipe, return - * "write" side. - */ - (void) close(filedes[0]); - set_cloexec_fd(filedes[1]); - return(filedes[1]); - } + switch((int) fork()) { + case -1: + return(-1); + case 0: + /* + * Child; dup read half to 0, close all but 0, 1, and 2 + */ + if (dup2(filedes[0], 0) == -1) + exit(1); + ss_page_stdin(); + default: + /* + * Parent: close "read" side of pipe, return + * "write" side. + */ + (void) close(filedes[0]); + set_cloexec_fd(filedes[1]); + return(filedes[1]); + } } #else /* don't fork */ int ss_pager_create() @@ -62,50 +63,50 @@ int ss_pager_create() int fd; fd = open("/dev/tty", O_WRONLY, 0); if (fd >= 0) - set_cloexec_fd(fd); + set_cloexec_fd(fd); return fd; } #endif void ss_page_stdin() { - int i; + int i; #ifdef POSIX_SIGNALS - struct sigaction sa; - sigset_t mask; + struct sigaction sa; + sigset_t mask; #endif - for (i = 3; i < 32; i++) - (void) close(i); + for (i = 3; i < 32; i++) + (void) close(i); #ifdef POSIX_SIGNALS - sa.sa_handler = SIG_DFL; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sigaction(SIGINT, &sa, (struct sigaction *)0); + sa.sa_handler = SIG_DFL; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sigaction(SIGINT, &sa, (struct sigaction *)0); #else - (void) signal(SIGINT, SIG_DFL); + (void) signal(SIGINT, SIG_DFL); #endif - { + { #ifdef POSIX_SIGNALS - sigemptyset(&mask); - sigaddset(&mask, SIGINT); - sigprocmask(SIG_UNBLOCK, &mask, (sigset_t *)0); + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigprocmask(SIG_UNBLOCK, &mask, (sigset_t *)0); #else - int mask = sigblock(0); - mask &= ~sigmask(SIGINT); - sigsetmask(mask); + int mask = sigblock(0); + mask &= ~sigmask(SIGINT); + sigsetmask(mask); #endif - } - if (_ss_pager_name == (char *)NULL) { - if ((_ss_pager_name = getenv("PAGER")) == (char *)NULL) - _ss_pager_name = MORE; - } - (void) execlp(_ss_pager_name, _ss_pager_name, (char *) NULL); - { - /* minimal recovery if pager program isn't found */ - char buf[80]; - register int n; - while ((n = read(0, buf, 80)) > 0) - write(1, buf, (unsigned) n); - } - exit(errno); + } + if (_ss_pager_name == (char *)NULL) { + if ((_ss_pager_name = getenv("PAGER")) == (char *)NULL) + _ss_pager_name = MORE; + } + (void) execlp(_ss_pager_name, _ss_pager_name, (char *) NULL); + { + /* minimal recovery if pager program isn't found */ + char buf[80]; + register int n; + while ((n = read(0, buf, 80)) > 0) + write(1, buf, (unsigned) n); + } + exit(errno); } diff --git a/src/util/ss/parse.c b/src/util/ss/parse.c index 28507b1d1..456b14743 100644 --- a/src/util/ss/parse.c +++ b/src/util/ss/parse.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2007 Massachusetts Institute of Technology. * All Rights Reserved. @@ -49,8 +50,8 @@ enum parse_mode { WHITESPACE, TOKEN, QUOTED_STRING }; * Series of pointers to parsed tokens in the original string. */ -#define NEW_ARGV(old,n) (char **)realloc((char *)old,\ - (unsigned)(n+2)*sizeof(char*)) +#define NEW_ARGV(old,n) (char **)realloc((char *)old, \ + (unsigned)(n+2)*sizeof(char*)) char **ss_parse (sci_idx, line_ptr, argc_ptr) int sci_idx; @@ -64,106 +65,106 @@ char **ss_parse (sci_idx, line_ptr, argc_ptr) argv = (char **) malloc (sizeof(char *)); if (argv == (char **)NULL) { - ss_error(sci_idx, errno, "Can't allocate storage"); - *argc_ptr = 0; - return(argv); + ss_error(sci_idx, errno, "Can't allocate storage"); + *argc_ptr = 0; + return(argv); } *argv = (char *)NULL; argc = 0; - parse_mode = WHITESPACE; /* flushing whitespace */ - cp = line_ptr; /* cp is for output */ + parse_mode = WHITESPACE; /* flushing whitespace */ + cp = line_ptr; /* cp is for output */ while (1) { #ifdef DEBUG - { - printf ("character `%c', mode %d\n", *line_ptr, parse_mode); - } + { + printf ("character `%c', mode %d\n", *line_ptr, parse_mode); + } #endif - while (parse_mode == WHITESPACE) { - if (*line_ptr == '\0') - goto end_of_line; - if (*line_ptr == ' ' || *line_ptr == '\t') { - line_ptr++; - continue; - } - if (*line_ptr == '"') { - /* go to quoted-string mode */ - parse_mode = QUOTED_STRING; - cp = line_ptr++; - newargv = NEW_ARGV (argv, argc); - if (newargv == NULL) { - out_of_mem_in_argv: - free(argv); - ss_error(sci_idx, errno, "Can't allocate storage"); - *argc_ptr = 0; - return NULL; - } - argv = newargv; - argv[argc++] = cp; - argv[argc] = NULL; - } - else { - /* random-token mode */ - parse_mode = TOKEN; - cp = line_ptr; - newargv = NEW_ARGV (argv, argc); - if (newargv == NULL) - goto out_of_mem_in_argv; - argv = newargv; - argv[argc++] = line_ptr; - argv[argc] = NULL; - } - } - while (parse_mode == TOKEN) { - if (*line_ptr == '\0') { - *cp++ = '\0'; - goto end_of_line; - } - else if (*line_ptr == ' ' || *line_ptr == '\t') { - *cp++ = '\0'; - line_ptr++; - parse_mode = WHITESPACE; - } - else if (*line_ptr == '"') { - line_ptr++; - parse_mode = QUOTED_STRING; - } - else { - *cp++ = *line_ptr++; - } - } - while (parse_mode == QUOTED_STRING) { - if (*line_ptr == '\0') { - ss_error (sci_idx, 0, - "Unbalanced quotes in command line"); - free (argv); - *argc_ptr = 0; - return NULL; - } - else if (*line_ptr == '"') { - if (*++line_ptr == '"') { - *cp++ = '"'; - line_ptr++; - } - else { - parse_mode = TOKEN; - } - } - else { - *cp++ = *line_ptr++; - } - } + while (parse_mode == WHITESPACE) { + if (*line_ptr == '\0') + goto end_of_line; + if (*line_ptr == ' ' || *line_ptr == '\t') { + line_ptr++; + continue; + } + if (*line_ptr == '"') { + /* go to quoted-string mode */ + parse_mode = QUOTED_STRING; + cp = line_ptr++; + newargv = NEW_ARGV (argv, argc); + if (newargv == NULL) { + out_of_mem_in_argv: + free(argv); + ss_error(sci_idx, errno, "Can't allocate storage"); + *argc_ptr = 0; + return NULL; + } + argv = newargv; + argv[argc++] = cp; + argv[argc] = NULL; + } + else { + /* random-token mode */ + parse_mode = TOKEN; + cp = line_ptr; + newargv = NEW_ARGV (argv, argc); + if (newargv == NULL) + goto out_of_mem_in_argv; + argv = newargv; + argv[argc++] = line_ptr; + argv[argc] = NULL; + } + } + while (parse_mode == TOKEN) { + if (*line_ptr == '\0') { + *cp++ = '\0'; + goto end_of_line; + } + else if (*line_ptr == ' ' || *line_ptr == '\t') { + *cp++ = '\0'; + line_ptr++; + parse_mode = WHITESPACE; + } + else if (*line_ptr == '"') { + line_ptr++; + parse_mode = QUOTED_STRING; + } + else { + *cp++ = *line_ptr++; + } + } + while (parse_mode == QUOTED_STRING) { + if (*line_ptr == '\0') { + ss_error (sci_idx, 0, + "Unbalanced quotes in command line"); + free (argv); + *argc_ptr = 0; + return NULL; + } + else if (*line_ptr == '"') { + if (*++line_ptr == '"') { + *cp++ = '"'; + line_ptr++; + } + else { + parse_mode = TOKEN; + } + } + else { + *cp++ = *line_ptr++; + } + } } end_of_line: *argc_ptr = argc; #ifdef DEBUG { - int i; - printf ("argc = %d\n", argc); - for (i = 0; i <= argc; i++) - printf ("\targv[%2d] = `%s'\n", i, - argv[i] ? argv[i] : "<NULL>"); + int i; + printf ("argc = %d\n", argc); + for (i = 0; i <= argc; i++) + printf ("\targv[%2d] = `%s'\n", i, + argv[i] ? argv[i] : "<NULL>"); } #endif return(argv); diff --git a/src/util/ss/prompt.c b/src/util/ss/prompt.c index 0751baeba..f42fde990 100644 --- a/src/util/ss/prompt.c +++ b/src/util/ss/prompt.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * prompt.c: Routines for retrieving and setting a prompt. * @@ -14,15 +15,15 @@ void ss_set_prompt(sci_idx, new_prompt) - int sci_idx; - char *new_prompt; + int sci_idx; + char *new_prompt; { - ss_info(sci_idx)->prompt = new_prompt; + ss_info(sci_idx)->prompt = new_prompt; } char * ss_get_prompt(sci_idx) - int sci_idx; + int sci_idx; { - return(ss_info(sci_idx)->prompt); + return(ss_info(sci_idx)->prompt); } diff --git a/src/util/ss/request_tbl.c b/src/util/ss/request_tbl.c index a214eb05d..7721a5f23 100644 --- a/src/util/ss/request_tbl.c +++ b/src/util/ss/request_tbl.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1987, 1988 by MIT Student Information Processing Board * @@ -7,59 +8,59 @@ #include "copyright.h" #include "ss_internal.h" -#define ssrt ss_request_table /* for some readable code... */ +#define ssrt ss_request_table /* for some readable code... */ void ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr) - int sci_idx; - ssrt *rqtbl_ptr; - int position; /* 1 -> becomes second... */ - int *code_ptr; + int sci_idx; + ssrt *rqtbl_ptr; + int position; /* 1 -> becomes second... */ + int *code_ptr; { - register ss_data *info; - register int i, size; + register ss_data *info; + register int i, size; - info = ss_info(sci_idx); - for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++) - ; - /* size == C subscript of NULL == #elements */ - size += 2; /* new element, and NULL */ - info->rqt_tables = (ssrt **)realloc(info->rqt_tables, - size*sizeof(ssrt *)); - if (info->rqt_tables == (ssrt **)NULL) { - *code_ptr = errno; - return; - } - if (position > size - 2) - position = size - 2; + info = ss_info(sci_idx); + for (size=0; info->rqt_tables[size] != (ssrt *)NULL; size++) + ; + /* size == C subscript of NULL == #elements */ + size += 2; /* new element, and NULL */ + info->rqt_tables = (ssrt **)realloc(info->rqt_tables, + size*sizeof(ssrt *)); + if (info->rqt_tables == (ssrt **)NULL) { + *code_ptr = errno; + return; + } + if (position > size - 2) + position = size - 2; - if (size > 1) - for (i = size - 2; i >= position; i--) - info->rqt_tables[i+1] = info->rqt_tables[i]; + if (size > 1) + for (i = size - 2; i >= position; i--) + info->rqt_tables[i+1] = info->rqt_tables[i]; - info->rqt_tables[position] = rqtbl_ptr; - info->rqt_tables[size-1] = (ssrt *)NULL; - *code_ptr = 0; + info->rqt_tables[position] = rqtbl_ptr; + info->rqt_tables[size-1] = (ssrt *)NULL; + *code_ptr = 0; } void ss_delete_request_table(sci_idx, rqtbl_ptr, code_ptr) - int sci_idx; - ssrt *rqtbl_ptr; - int *code_ptr; + int sci_idx; + ssrt *rqtbl_ptr; + int *code_ptr; { - register ss_data *info; - register ssrt **rt1, **rt2; + register ss_data *info; + register ssrt **rt1, **rt2; - *code_ptr = SS_ET_TABLE_NOT_FOUND; - info = ss_info(sci_idx); - rt1 = info->rqt_tables; - for (rt2 = rt1; *rt1; rt1++) { - if (*rt1 != rqtbl_ptr) { - *rt2++ = *rt1; - *code_ptr = 0; - } - } - *rt2 = (ssrt *)NULL; - return; + *code_ptr = SS_ET_TABLE_NOT_FOUND; + info = ss_info(sci_idx); + rt1 = info->rqt_tables; + for (rt2 = rt1; *rt1; rt1++) { + if (*rt1 != rqtbl_ptr) { + *rt2++ = *rt1; + *code_ptr = 0; + } + } + *rt2 = (ssrt *)NULL; + return; } diff --git a/src/util/ss/requests.c b/src/util/ss/requests.c index ccd0f792c..27c4a2084 100644 --- a/src/util/ss/requests.c +++ b/src/util/ss/requests.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Various minor routines... * @@ -9,16 +10,16 @@ #include <stdio.h> #include "ss_internal.h" -#define DECLARE(name) void name(argc,argv,sci_idx,info_ptr)int argc,sci_idx;const char * const *argv; pointer info_ptr; +#define DECLARE(name) void name(argc,argv,sci_idx,info_ptr)int argc,sci_idx;const char * const *argv; pointer info_ptr; /* * ss_self_identify -- assigned by default to the "." request */ DECLARE(ss_self_identify) { - register ss_data *info = ss_info(sci_idx); - printf("%s version %s\n", info->subsystem_name, - info->subsystem_version); + register ss_data *info = ss_info(sci_idx); + printf("%s version %s\n", info->subsystem_name, + info->subsystem_version); } /* @@ -26,7 +27,7 @@ DECLARE(ss_self_identify) */ DECLARE(ss_subsystem_name) { - printf("%s\n", ss_info(sci_idx)->subsystem_name); + printf("%s\n", ss_info(sci_idx)->subsystem_name); } /* @@ -34,7 +35,7 @@ DECLARE(ss_subsystem_name) */ DECLARE(ss_subsystem_version) { - printf("%s\n", ss_info(sci_idx)->subsystem_version); + printf("%s\n", ss_info(sci_idx)->subsystem_version); } /* @@ -43,5 +44,5 @@ DECLARE(ss_subsystem_version) */ DECLARE(ss_unimplemented) { - ss_perror(sci_idx, SS_ET_UNIMPLEMENTED, ""); + ss_perror(sci_idx, SS_ET_UNIMPLEMENTED, ""); } diff --git a/src/util/ss/ss.h b/src/util/ss/ss.h index ac25266d3..38d8974e3 100644 --- a/src/util/ss/ss.h +++ b/src/util/ss/ss.h @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1987, 1988 by MIT Student Information Processing Board * @@ -21,8 +22,8 @@ typedef __SS_CONST struct _ss_request_entry { __SS_CONST char * __SS_CONST *command_names; /* whatever */ void (* __SS_CONST function) __SS_PROTO; /* foo */ - __SS_CONST char * __SS_CONST info_string; /* NULL */ - int flags; /* 0 */ + __SS_CONST char * __SS_CONST info_string; /* NULL */ + int flags; /* 0 */ } ss_request_entry; typedef __SS_CONST struct _ss_request_table { @@ -30,19 +31,19 @@ typedef __SS_CONST struct _ss_request_table { ss_request_entry *requests; } ss_request_table; -#define SS_RQT_TBL_V2 2 +#define SS_RQT_TBL_V2 2 -typedef struct _ss_rp_options { /* DEFAULT VALUES */ - int version; /* SS_RP_V1 */ - void (*unknown) __SS_PROTO; /* call for unknown command */ +typedef struct _ss_rp_options { /* DEFAULT VALUES */ + int version; /* SS_RP_V1 */ + void (*unknown) __SS_PROTO; /* call for unknown command */ int allow_suspend; int catch_int; } ss_rp_options; #define SS_RP_V1 1 -#define SS_OPT_DONT_LIST 0x0001 -#define SS_OPT_DONT_SUMMARIZE 0x0002 +#define SS_OPT_DONT_LIST 0x0001 +#define SS_OPT_DONT_SUMMARIZE 0x0002 void ss_help __SS_PROTO; void ss_list_requests __SS_PROTO; diff --git a/src/util/ss/ss_internal.h b/src/util/ss/ss_internal.h index 5c9201a2d..400f3126b 100644 --- a/src/util/ss/ss_internal.h +++ b/src/util/ss/ss_internal.h @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1987, 1988 by MIT Student Information Processing Board * @@ -29,7 +30,7 @@ typedef void * pointer; #define LOCAL_FREE(x) extern pointer alloca (unsigned); #else -#if defined(__HIGHC__) /* Barf! */ +#if defined(__HIGHC__) /* Barf! */ pragma on(alloca); #define LOCAL_ALLOC(x) alloca(x) #define LOCAL_FREE(x) @@ -40,13 +41,13 @@ extern pointer alloca (unsigned); #define LOCAL_FREE(x) free(x) #endif #endif -#endif /* LOCAL_ALLOC stuff */ +#endif /* LOCAL_ALLOC stuff */ typedef char BOOL; typedef struct _ss_abbrev_entry { - char *name; /* abbrev name */ - char **abbrev; /* new tokens to insert */ + char *name; /* abbrev name */ + char **abbrev; /* new tokens to insert */ unsigned int beginning_of_line : 1; } ss_abbrev_entry; @@ -60,36 +61,36 @@ typedef struct { ss_abbrev_list abbrevs[127]; } ss_abbrev_info; -typedef struct _ss_data { /* init values */ +typedef struct _ss_data { /* init values */ /* this subsystem */ char *subsystem_name; char *subsystem_version; /* current request info */ int argc; - char **argv; /* arg list */ + char **argv; /* arg list */ char const *current_request; /* primary name */ /* info directory for 'help' */ char **info_dirs; /* to be extracted by subroutines */ - pointer info_ptr; /* (void *) NULL */ + pointer info_ptr; /* (void *) NULL */ /* for ss_listen processing */ char *prompt; ss_request_table **rqt_tables; ss_abbrev_info *abbrev_info; struct { - unsigned int escape_disabled : 1, - abbrevs_disabled : 1; + unsigned int escape_disabled : 1, + abbrevs_disabled : 1; } flags; /* to get out */ - int abort; /* exit subsystem */ + int abort; /* exit subsystem */ int exit_status; } ss_data; #define CURRENT_SS_VERSION 1 -#define ss_info(sci_idx) (_ss_table[sci_idx]) -#define ss_current_request(sci_idx,code_ptr) \ - (*code_ptr=0,ss_info(sci_idx)->current_request) +#define ss_info(sci_idx) (_ss_table[sci_idx]) +#define ss_current_request(sci_idx,code_ptr) \ + (*code_ptr=0,ss_info(sci_idx)->current_request) void ss_unknown_function(); void ss_delete_info_dir(); char **ss_parse (int, char *, int *); diff --git a/src/util/ss/test_ss.c b/src/util/ss/test_ss.c index 9bab95c3c..34287b0e5 100644 --- a/src/util/ss/test_ss.c +++ b/src/util/ss/test_ss.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * util/ss/test_ss.c */ @@ -21,70 +22,70 @@ int main(argc, argv) int code; char *argv0 = argv[0]; char *initial_request = (char *)NULL; - int quit = FALSE; /* quit after processing request */ + int quit = FALSE; /* quit after processing request */ int sci_idx; char *subsystem_name; subsystem_name = def_subsystem_name; for (; *argv; ++argv, --argc) { - printf("checking arg: %s\n", *argv); - if (!strcmp(*argv, "-prompt")) { - if (argc == 1) { - fprintf(stderr, - "No argument supplied with -prompt\n"); - exit(1); - } - argc--; argv++; - subsystem_name = *argv; - } - else if (!strcmp(*argv, "-request") || !strcmp(*argv, "-rq")) { - if (argc == 1) { - fprintf(stderr, - "No string supplied with -request.\n"); - exit(1); - } - argc--; argv++; - initial_request = *argv; - } - else if (!strcmp(*argv, "-quit")) - quit = TRUE; - else if (!strcmp(*argv, "-no_quit")) - quit = FALSE; - else if (**argv == '-') { - fprintf(stderr, "Unknown control argument %s\n", - *argv); - fprintf(stderr, - "Usage: %s [gateway] [ -prompt name ] [ -request name ] [ -quit ]\n", - argv0); - exit(1); - } + printf("checking arg: %s\n", *argv); + if (!strcmp(*argv, "-prompt")) { + if (argc == 1) { + fprintf(stderr, + "No argument supplied with -prompt\n"); + exit(1); + } + argc--; argv++; + subsystem_name = *argv; + } + else if (!strcmp(*argv, "-request") || !strcmp(*argv, "-rq")) { + if (argc == 1) { + fprintf(stderr, + "No string supplied with -request.\n"); + exit(1); + } + argc--; argv++; + initial_request = *argv; + } + else if (!strcmp(*argv, "-quit")) + quit = TRUE; + else if (!strcmp(*argv, "-no_quit")) + quit = FALSE; + else if (**argv == '-') { + fprintf(stderr, "Unknown control argument %s\n", + *argv); + fprintf(stderr, + "Usage: %s [gateway] [ -prompt name ] [ -request name ] [ -quit ]\n", + argv0); + exit(1); + } } sci_idx = ss_create_invocation(subsystem_name, version, - (char *)NULL, &test_cmds, &code); + (char *)NULL, &test_cmds, &code); if (code) { - ss_perror(sci_idx, code, "creating invocation"); - exit(1); + ss_perror(sci_idx, code, "creating invocation"); + exit(1); } (void) ss_add_request_table (sci_idx, &ss_std_requests, 1, &code); if (code) { - ss_perror (sci_idx, code, "adding standard requests"); - exit (1); + ss_perror (sci_idx, code, "adding standard requests"); + exit (1); } if (!quit) - printf("test version %s. Type '?' for a list of commands.\n\n", - version); + printf("test version %s. Type '?' for a list of commands.\n\n", + version); if (initial_request != (char *)NULL) { - code = ss_execute_line(sci_idx, initial_request); - if (code != 0) - ss_perror(sci_idx, code, initial_request); + code = ss_execute_line(sci_idx, initial_request); + if (code != 0) + ss_perror(sci_idx, code, initial_request); } if (!quit || code) - code = ss_listen (sci_idx); + code = ss_listen (sci_idx); exit(0); } @@ -94,6 +95,6 @@ void test_cmd (argc, argv) char **argv; { while (++argv, --argc) - fputs(*argv, stdout); + fputs(*argv, stdout); putchar ('\n'); } diff --git a/src/util/ss/utils.c b/src/util/ss/utils.c index d24033333..3b1f6582a 100644 --- a/src/util/ss/utils.c +++ b/src/util/ss/utils.c @@ -1,3 +1,4 @@ +/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 1987, 1988 by MIT Student Information Processing Board * @@ -6,7 +7,7 @@ #include <string.h> #include "copyright.h" -#include "ss_internal.h" /* includes stdio and string */ +#include "ss_internal.h" /* includes stdio and string */ extern FILE *output_file; @@ -60,50 +61,50 @@ char * generate_rqte(func_name, info_string, cmds, options) var_name = generate_cmds_string(cmds); generate_function_definition(func_name); asprintf(&string, " { %s,\n %s,\n %s,\n %d },\n", - var_name, func_name, info_string, options); + var_name, func_name, info_string, options); return(string); } char * gensym(name) - char *name; + char *name; { - char *symbol; + char *symbol; - gensym_n++; - asprintf(&symbol, "%s%05ld", name, gensym_n); - return(symbol); + gensym_n++; + asprintf(&symbol, "%s%05ld", name, gensym_n); + return(symbol); } /* concatenate three strings and return the result */ char *str_concat3(a, b, c) - register char *a, *b, *c; + register char *a, *b, *c; { - char *result; + char *result; - asprintf(&result, "%s%s%s", a, c, b); - return(result); + asprintf(&result, "%s%s%s", a, c, b); + return(result); } /* return copy of string enclosed in double-quotes */ char *quote(string) - register char *string; + register char *string; { - register char *result; + register char *result; - asprintf(&result, "\"%s\"", string); - return(result); + asprintf(&result, "\"%s\"", string); + return(result); } #ifndef HAVE_STRDUP /* make duplicate of string and return pointer */ char *strdup(s) - register char *s; + register char *s; { - register int len = strlen(s) + 1; - register char *new; - new = malloc(len); - strncpy(new, s, len); - return(new); + register int len = strlen(s) + 1; + register char *new; + new = malloc(len); + strncpy(new, s, len); + return(new); } #endif |
