xref: /titanic_50/usr/src/lib/krb5/ss/error.c (revision b6c3f7863936abeae522e48a13887dddeb691a45)
1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 /*
9  * Copyright 1987, 1988, 1989 by MIT Student Information Processing
10  * Board
11  *
12  * For copyright information, see copyright.h.
13  */
14 
15 #include <stdio.h>
16 
17 #include "copyright.h"
18 #include "com_err.h"
19 #include "ss_internal.h"
20 
21 char * ss_name(sci_idx)
22     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     va_start (pvar, fmt);
64     whoami = ss_name (sci_idx);
65     com_err_va (whoami, code, fmt, pvar);
66     free (whoami);
67     va_end(pvar);
68 }
69 
70 void ss_perror (sci_idx, code, msg) /* for compatibility */
71     int sci_idx;
72     long code;
73     char const *msg;
74 {
75     ss_error (sci_idx, code, "%s", msg);
76 }
77