| Theodore Ts'o | 3839e65 | 1997-04-26 13:21:57 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1987, 1988, 1989 by MIT Student Information Processing |
| 3 | * Board |
| 4 | * |
| 5 | * For copyright information, see copyright.h. |
| 6 | */ |
| 7 | |
| 8 | #include <stdio.h> |
| 9 | |
| 10 | /* |
| 11 | * I'm assuming that com_err.h includes varargs.h, which it does |
| 12 | * (right now). There really ought to be a way for me to include the |
| 13 | * file without worrying about whether com_err.h includes it or not, |
| 14 | * but varargs.h doesn't define anything that I can use as a flag, and |
| 15 | * gcc will lose if I try to include it twice and redefine stuff. |
| 16 | */ |
| 17 | #if !defined(__STDC__) || !defined(ibm032) || !defined(NeXT) |
| 18 | #define ss_error ss_error_external |
| 19 | #endif |
| 20 | |
| 21 | #include "copyright.h" |
| 22 | #include <com_err.h> |
| 23 | #include "ss_internal.h" |
| 24 | |
| 25 | #ifdef _STDARG_H_ |
| 26 | #define STDARG |
| 27 | #endif |
| 28 | |
| 29 | #ifdef _STDARG_H |
| 30 | #define STDARG |
| 31 | #endif |
| 32 | |
| 33 | #ifndef __STDC__ |
| 34 | /* we didn't get it in com_err.h if it wasn't STDC. */ |
| 35 | #ifndef STDARG |
| 36 | /* and we don't need it, either, if we're using stdarg.h... */ |
| 37 | #include <varargs.h> |
| 38 | #endif |
| 39 | #endif |
| 40 | |
| 41 | #undef ss_error |
| 42 | |
| 43 | char * ss_name(sci_idx) |
| 44 | int sci_idx; |
| 45 | { |
| 46 | register char *ret_val; |
| 47 | register ss_data *infop; |
| 48 | |
| 49 | infop = ss_info(sci_idx); |
| 50 | if (infop->current_request == (char const *)NULL) { |
| 51 | ret_val = malloc((unsigned) |
| 52 | (strlen(infop->subsystem_name)+1) |
| 53 | * sizeof(char)); |
| 54 | if (ret_val == (char *)NULL) |
| 55 | return((char *)NULL); |
| 56 | strcpy(ret_val, infop->subsystem_name); |
| 57 | return(ret_val); |
| 58 | } |
| 59 | else { |
| 60 | register char *cp; |
| 61 | register char const *cp1; |
| 62 | ret_val = malloc((unsigned)sizeof(char) * |
| 63 | (strlen(infop->subsystem_name)+ |
| 64 | strlen(infop->current_request)+ |
| 65 | 4)); |
| 66 | cp = ret_val; |
| 67 | cp1 = infop->subsystem_name; |
| 68 | while (*cp1) |
| 69 | *cp++ = *cp1++; |
| 70 | *cp++ = ' '; |
| 71 | *cp++ = '('; |
| 72 | cp1 = infop->current_request; |
| 73 | while (*cp1) |
| 74 | *cp++ = *cp1++; |
| 75 | *cp++ = ')'; |
| 76 | *cp = '\0'; |
| 77 | return(ret_val); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | #ifdef STDARG |
| 82 | void ss_error (int sci_idx, long code, const char * fmt, ...) |
| 83 | #else |
| 84 | void ss_error (va_alist) |
| 85 | va_dcl |
| 86 | #endif |
| 87 | { |
| 88 | register char const *whoami; |
| 89 | va_list pvar; |
| 90 | #ifndef STDARG |
| 91 | int sci_idx; |
| 92 | long code; |
| 93 | char * fmt; |
| 94 | va_start (pvar); |
| 95 | sci_idx = va_arg (pvar, int); |
| 96 | code = va_arg (pvar, long); |
| 97 | fmt = va_arg (pvar, char *); |
| 98 | #else |
| 99 | va_start (pvar, fmt); |
| 100 | #endif |
| 101 | whoami = ss_name (sci_idx); |
| 102 | com_err_va (whoami, code, fmt, pvar); |
| 103 | free (whoami); |
| 104 | va_end(pvar); |
| 105 | } |
| 106 | |
| 107 | void ss_perror (sci_idx, code, msg) /* for compatibility */ |
| 108 | int sci_idx; |
| 109 | long code; |
| 110 | char const *msg; |
| 111 | { |
| 112 | ss_error (sci_idx, code, "%s", msg); |
| 113 | } |