1 /*
2 * Copyright 1987, 1988, 1989 by MIT Student Information Processing
3 * Board
4 *
5 * Permission to use, copy, modify, and distribute this software and
6 * its documentation for any purpose is hereby granted, provided that
7 * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
8 * advertising or publicity pertaining to distribution of the software
9 * without specific, written prior permission. M.I.T. and the
10 * M.I.T. S.I.P.B. make no representations about the suitability of
11 * this software for any purpose. It is provided "as is" without
12 * express or implied warranty.
13 */
14
15 #include "config.h"
16 #include <stdio.h>
17
18 #include "et/com_err.h"
19 #include "ss_internal.h"
20
21 #include <stdarg.h>
22
ss_name(int sci_idx)23 char *ss_name(int sci_idx)
24 {
25 register char *ret_val;
26 register ss_data *infop;
27
28 infop = ss_info(sci_idx);
29 if (infop->current_request == (char const *)NULL) {
30 ret_val = malloc((unsigned)
31 (strlen(infop->subsystem_name)+1)
32 * sizeof(char));
33 if (ret_val == (char *)NULL)
34 return((char *)NULL);
35 strcpy(ret_val, infop->subsystem_name);
36 return(ret_val);
37 }
38 else {
39 register char *cp;
40 register char const *cp1;
41 ret_val = malloc((unsigned)sizeof(char) *
42 (strlen(infop->subsystem_name)+
43 strlen(infop->current_request)+
44 4));
45 if (ret_val == (char *)NULL)
46 return ((char *)NULL);
47 cp = ret_val;
48 cp1 = infop->subsystem_name;
49 while (*cp1)
50 *cp++ = *cp1++;
51 *cp++ = ' ';
52 *cp++ = '(';
53 cp1 = infop->current_request;
54 while (*cp1)
55 *cp++ = *cp1++;
56 *cp++ = ')';
57 *cp = '\0';
58 return(ret_val);
59 }
60 }
61
ss_error(int sci_idx,long code,const char * fmt,...)62 void ss_error (int sci_idx, long code, const char * fmt, ...)
63 {
64 register char *whoami;
65 va_list pvar;
66
67 va_start (pvar, fmt);
68 whoami = ss_name (sci_idx);
69 com_err_va (whoami, code, fmt, pvar);
70 free (whoami);
71 va_end(pvar);
72 }
73
ss_perror(int sci_idx,long code,char const * msg)74 void ss_perror(int sci_idx, long code, char const *msg) /* for compatibility */
75 {
76 ss_error (sci_idx, code, "%s", msg);
77 }
78