error.c revision d1154eb460efe588eaed3d439c1caaca149fa362
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 23char * ss_name(sci_idx) 24 int sci_idx; 25{ 26 register char *ret_val; 27 register ss_data *infop; 28 29 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; 42 ret_val = malloc((unsigned)sizeof(char) * 43 (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 61void ss_error (int sci_idx, long code, const char * fmt, ...) 62{ 63 register char *whoami; 64 va_list pvar; 65 66 va_start (pvar, fmt); 67 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} 80