xref: /illumos-gate/usr/src/lib/krb5/ss/error.c (revision 1da57d55)
1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright 1987, 1988, 1989 by MIT Student Information Processing
8  * Board
9  *
10  * For copyright information, see copyright.h.
11  */
12 
13 #include <stdio.h>
14 
15 #include "copyright.h"
16 #include "com_err.h"
17 #include "ss_internal.h"
18 
ss_name(sci_idx)19 char * ss_name(sci_idx)
20     int sci_idx;
21 {
22     register char *ret_val;
23     register ss_data *infop;
24 
25     infop = ss_info(sci_idx);
26     if (infop->current_request == (char const *)NULL) {
27 	ret_val = malloc((unsigned)
28 			 (strlen(infop->subsystem_name)+1)
29 			 * sizeof(char));
30 	if (ret_val == (char *)NULL)
31 	    return((char *)NULL);
32 	strcpy(ret_val, infop->subsystem_name);
33 	return(ret_val);
34     }
35     else {
36 	register char *cp;
37 	register char const *cp1;
38 	ret_val = malloc((unsigned)sizeof(char) *
39 			 (strlen(infop->subsystem_name)+
40 			  strlen(infop->current_request)+
41 			  4));
42 	cp = ret_val;
43 	cp1 = infop->subsystem_name;
44 	while (*cp1)
45 	    *cp++ = *cp1++;
46 	*cp++ = ' ';
47 	*cp++ = '(';
48 	cp1 = infop->current_request;
49 	while (*cp1)
50 	    *cp++ = *cp1++;
51 	*cp++ = ')';
52 	*cp = '\0';
53 	return(ret_val);
54     }
55 }
56 
ss_error(int sci_idx,long code,const char * fmt,...)57 void ss_error (int sci_idx, long code, const char * fmt, ...)
58 {
59     register char *whoami;
60     va_list pvar;
61     va_start (pvar, fmt);
62     whoami = ss_name (sci_idx);
63     com_err_va (whoami, code, fmt, pvar);
64     free (whoami);
65     va_end(pvar);
66 }
67 
ss_perror(sci_idx,code,msg)68 void ss_perror (sci_idx, code, msg) /* for compatibility */
69     int sci_idx;
70     long code;
71     char const *msg;
72 {
73     ss_error (sci_idx, code, "%s", msg);
74 }
75