blob: 14c0570fd2c803bef3f5ecbe6e7899b3840ec254 [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
15#include <stdio.h>
16
Theodore Ts'o3839e651997-04-26 13:21:57 +000017#include <com_err.h>
18#include "ss_internal.h"
19
Theodore Ts'o50e1e101997-04-26 13:58:21 +000020#include <stdarg.h>
Theodore Ts'o3839e651997-04-26 13:21:57 +000021
Theodore Ts'o3839e651997-04-26 13:21:57 +000022char * ss_name(sci_idx)
23 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 cp = ret_val;
46 cp1 = infop->subsystem_name;
47 while (*cp1)
48 *cp++ = *cp1++;
49 *cp++ = ' ';
50 *cp++ = '(';
51 cp1 = infop->current_request;
52 while (*cp1)
53 *cp++ = *cp1++;
54 *cp++ = ')';
55 *cp = '\0';
56 return(ret_val);
57 }
58}
59
Theodore Ts'o3839e651997-04-26 13:21:57 +000060void ss_error (int sci_idx, long code, const char * fmt, ...)
Theodore Ts'o3839e651997-04-26 13:21:57 +000061{
Theodore Ts'o1e3472c1997-04-29 14:53:37 +000062 register char *whoami;
Theodore Ts'o3839e651997-04-26 13:21:57 +000063 va_list pvar;
Theodore Ts'o91835c12003-03-30 22:26:13 -050064
Theodore Ts'o3839e651997-04-26 13:21:57 +000065 va_start (pvar, fmt);
Theodore Ts'o3839e651997-04-26 13:21:57 +000066 whoami = ss_name (sci_idx);
67 com_err_va (whoami, code, fmt, pvar);
68 free (whoami);
69 va_end(pvar);
70}
71
72void ss_perror (sci_idx, code, msg) /* for compatibility */
73 int sci_idx;
74 long code;
75 char const *msg;
76{
77 ss_error (sci_idx, code, "%s", msg);
78}