Home | History | Annotate | Download | only in ss
      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 <stdio.h>
     16 
     17 #include "et/com_err.h"
     18 #include "ss_internal.h"
     19 
     20 #include <stdarg.h>
     21 
     22 char *ss_name(int sci_idx)
     23 {
     24     register char *ret_val;
     25     register ss_data *infop;
     26 
     27     infop = ss_info(sci_idx);
     28     if (infop->current_request == (char const *)NULL) {
     29 	ret_val = malloc((unsigned)
     30 			 (strlen(infop->subsystem_name)+1)
     31 			 * sizeof(char));
     32 	if (ret_val == (char *)NULL)
     33 	    return((char *)NULL);
     34 	strcpy(ret_val, infop->subsystem_name);
     35 	return(ret_val);
     36     }
     37     else {
     38 	register char *cp;
     39 	register char const *cp1;
     40 	ret_val = malloc((unsigned)sizeof(char) *
     41 			 (strlen(infop->subsystem_name)+
     42 			  strlen(infop->current_request)+
     43 			  4));
     44 	cp = ret_val;
     45 	cp1 = infop->subsystem_name;
     46 	while (*cp1)
     47 	    *cp++ = *cp1++;
     48 	*cp++ = ' ';
     49 	*cp++ = '(';
     50 	cp1 = infop->current_request;
     51 	while (*cp1)
     52 	    *cp++ = *cp1++;
     53 	*cp++ = ')';
     54 	*cp = '\0';
     55 	return(ret_val);
     56     }
     57 }
     58 
     59 void ss_error (int sci_idx, long code, const char * fmt, ...)
     60 {
     61     register char *whoami;
     62     va_list pvar;
     63 
     64     va_start (pvar, fmt);
     65     whoami = ss_name (sci_idx);
     66     com_err_va (whoami, code, fmt, pvar);
     67     free (whoami);
     68     va_end(pvar);
     69 }
     70 
     71 void ss_perror(int sci_idx, long code, char const *msg) /* for compatibility */
     72 {
     73     ss_error (sci_idx, code, "%s", msg);
     74 }
     75