blob: 781ba82dd3db3060f0c8808c038e1639faf66edf [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001/*
2 * Copyright 1987, 1988, 1989 by MIT Student Information Processing
3 * Board
4 *
Theodore Ts'o06cefee1999-10-23 01:16:22 +00005 * 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.
Theodore Ts'o3839e651997-04-26 13:21:57 +000013 */
14
Theodore Ts'od1154eb2011-09-18 17:34:37 -040015#include "config.h"
Theodore Ts'o3839e651997-04-26 13:21:57 +000016#include <stdio.h>
17
Theodore Ts'od1154eb2011-09-18 17:34:37 -040018#include "et/com_err.h"
Theodore Ts'o3839e651997-04-26 13:21:57 +000019#include "ss_internal.h"
20
Theodore Ts'o50e1e101997-04-26 13:58:21 +000021#include <stdarg.h>
Theodore Ts'oefc6f622008-08-27 23:07:54 -040022
Theodore Ts'o3839e651997-04-26 13:21:57 +000023char * ss_name(sci_idx)
24 int sci_idx;
25{
26 register char *ret_val;
27 register ss_data *infop;
Theodore Ts'oefc6f622008-08-27 23:07:54 -040028
Theodore Ts'o3839e651997-04-26 13:21:57 +000029 infop = ss_info(sci_idx);
30 if (infop->current_request == (char const *)NULL) {
31 ret_val = malloc((unsigned)
32 (strlen(infop->subsystem_name)+1)
33 * sizeof(char));
34 if (ret_val == (char *)NULL)
35 return((char *)NULL);
36 strcpy(ret_val, infop->subsystem_name);
37 return(ret_val);
38 }
39 else {
40 register char *cp;
41 register char const *cp1;
Theodore Ts'oefc6f622008-08-27 23:07:54 -040042 ret_val = malloc((unsigned)sizeof(char) *
Theodore Ts'o3839e651997-04-26 13:21:57 +000043 (strlen(infop->subsystem_name)+
44 strlen(infop->current_request)+
45 4));
46 cp = ret_val;
47 cp1 = infop->subsystem_name;
48 while (*cp1)
49 *cp++ = *cp1++;
50 *cp++ = ' ';
51 *cp++ = '(';
52 cp1 = infop->current_request;
53 while (*cp1)
54 *cp++ = *cp1++;
55 *cp++ = ')';
56 *cp = '\0';
57 return(ret_val);
58 }
59}
60
Theodore Ts'o3839e651997-04-26 13:21:57 +000061void ss_error (int sci_idx, long code, const char * fmt, ...)
Theodore Ts'o3839e651997-04-26 13:21:57 +000062{
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000063 register char *whoami;
Theodore Ts'o3839e651997-04-26 13:21:57 +000064 va_list pvar;
Theodore Ts'o91835c12003-03-30 22:26:13 -050065
Theodore Ts'o3839e651997-04-26 13:21:57 +000066 va_start (pvar, fmt);
Theodore Ts'o3839e651997-04-26 13:21:57 +000067 whoami = ss_name (sci_idx);
68 com_err_va (whoami, code, fmt, pvar);
69 free (whoami);
70 va_end(pvar);
71}
72
73void ss_perror (sci_idx, code, msg) /* for compatibility */
74 int sci_idx;
75 long code;
76 char const *msg;
77{
78 ss_error (sci_idx, code, "%s", msg);
79}