xref: /onnv-gate/usr/src/lib/krb5/ss/error.c (revision 2881:ea6360e7e1c5)
10Sstevel@tonic-gate /*
2*2881Smp153739  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3*2881Smp153739  * Use is subject to license terms.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate 
60Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
70Sstevel@tonic-gate 
80Sstevel@tonic-gate /*
90Sstevel@tonic-gate  * Copyright 1987, 1988, 1989 by MIT Student Information Processing
100Sstevel@tonic-gate  * Board
110Sstevel@tonic-gate  *
120Sstevel@tonic-gate  * For copyright information, see copyright.h.
130Sstevel@tonic-gate  */
140Sstevel@tonic-gate 
150Sstevel@tonic-gate #include <stdio.h>
160Sstevel@tonic-gate 
170Sstevel@tonic-gate #include "copyright.h"
180Sstevel@tonic-gate #include "com_err.h"
190Sstevel@tonic-gate #include "ss_internal.h"
200Sstevel@tonic-gate 
ss_name(sci_idx)210Sstevel@tonic-gate char * ss_name(sci_idx)
220Sstevel@tonic-gate     int sci_idx;
230Sstevel@tonic-gate {
240Sstevel@tonic-gate     register char *ret_val;
250Sstevel@tonic-gate     register ss_data *infop;
260Sstevel@tonic-gate 
270Sstevel@tonic-gate     infop = ss_info(sci_idx);
280Sstevel@tonic-gate     if (infop->current_request == (char const *)NULL) {
290Sstevel@tonic-gate 	ret_val = malloc((unsigned)
300Sstevel@tonic-gate 			 (strlen(infop->subsystem_name)+1)
310Sstevel@tonic-gate 			 * sizeof(char));
320Sstevel@tonic-gate 	if (ret_val == (char *)NULL)
330Sstevel@tonic-gate 	    return((char *)NULL);
340Sstevel@tonic-gate 	strcpy(ret_val, infop->subsystem_name);
350Sstevel@tonic-gate 	return(ret_val);
360Sstevel@tonic-gate     }
370Sstevel@tonic-gate     else {
380Sstevel@tonic-gate 	register char *cp;
390Sstevel@tonic-gate 	register char const *cp1;
400Sstevel@tonic-gate 	ret_val = malloc((unsigned)sizeof(char) *
410Sstevel@tonic-gate 			 (strlen(infop->subsystem_name)+
420Sstevel@tonic-gate 			  strlen(infop->current_request)+
430Sstevel@tonic-gate 			  4));
440Sstevel@tonic-gate 	cp = ret_val;
450Sstevel@tonic-gate 	cp1 = infop->subsystem_name;
460Sstevel@tonic-gate 	while (*cp1)
470Sstevel@tonic-gate 	    *cp++ = *cp1++;
480Sstevel@tonic-gate 	*cp++ = ' ';
490Sstevel@tonic-gate 	*cp++ = '(';
500Sstevel@tonic-gate 	cp1 = infop->current_request;
510Sstevel@tonic-gate 	while (*cp1)
520Sstevel@tonic-gate 	    *cp++ = *cp1++;
530Sstevel@tonic-gate 	*cp++ = ')';
540Sstevel@tonic-gate 	*cp = '\0';
550Sstevel@tonic-gate 	return(ret_val);
560Sstevel@tonic-gate     }
570Sstevel@tonic-gate }
580Sstevel@tonic-gate 
ss_error(int sci_idx,long code,const char * fmt,...)590Sstevel@tonic-gate void ss_error (int sci_idx, long code, const char * fmt, ...)
600Sstevel@tonic-gate {
610Sstevel@tonic-gate     register char *whoami;
620Sstevel@tonic-gate     va_list pvar;
630Sstevel@tonic-gate     va_start (pvar, fmt);
640Sstevel@tonic-gate     whoami = ss_name (sci_idx);
650Sstevel@tonic-gate     com_err_va (whoami, code, fmt, pvar);
660Sstevel@tonic-gate     free (whoami);
670Sstevel@tonic-gate     va_end(pvar);
680Sstevel@tonic-gate }
690Sstevel@tonic-gate 
ss_perror(sci_idx,code,msg)700Sstevel@tonic-gate void ss_perror (sci_idx, code, msg) /* for compatibility */
710Sstevel@tonic-gate     int sci_idx;
720Sstevel@tonic-gate     long code;
730Sstevel@tonic-gate     char const *msg;
740Sstevel@tonic-gate {
750Sstevel@tonic-gate     ss_error (sci_idx, code, "%s", msg);
760Sstevel@tonic-gate }
77