xref: /titanic_41/usr/src/lib/krb5/ss/error.c (revision 56a424cca6b3f91f31bdab72a4626c48c779fe8b)
17c478bd9Sstevel@tonic-gate /*
2*56a424ccSmp153739  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3*56a424ccSmp153739  * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate  */
57c478bd9Sstevel@tonic-gate 
67c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
77c478bd9Sstevel@tonic-gate 
87c478bd9Sstevel@tonic-gate /*
97c478bd9Sstevel@tonic-gate  * Copyright 1987, 1988, 1989 by MIT Student Information Processing
107c478bd9Sstevel@tonic-gate  * Board
117c478bd9Sstevel@tonic-gate  *
127c478bd9Sstevel@tonic-gate  * For copyright information, see copyright.h.
137c478bd9Sstevel@tonic-gate  */
147c478bd9Sstevel@tonic-gate 
157c478bd9Sstevel@tonic-gate #include <stdio.h>
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate #include "copyright.h"
187c478bd9Sstevel@tonic-gate #include "com_err.h"
197c478bd9Sstevel@tonic-gate #include "ss_internal.h"
207c478bd9Sstevel@tonic-gate 
ss_name(sci_idx)217c478bd9Sstevel@tonic-gate char * ss_name(sci_idx)
227c478bd9Sstevel@tonic-gate     int sci_idx;
237c478bd9Sstevel@tonic-gate {
247c478bd9Sstevel@tonic-gate     register char *ret_val;
257c478bd9Sstevel@tonic-gate     register ss_data *infop;
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate     infop = ss_info(sci_idx);
287c478bd9Sstevel@tonic-gate     if (infop->current_request == (char const *)NULL) {
297c478bd9Sstevel@tonic-gate 	ret_val = malloc((unsigned)
307c478bd9Sstevel@tonic-gate 			 (strlen(infop->subsystem_name)+1)
317c478bd9Sstevel@tonic-gate 			 * sizeof(char));
327c478bd9Sstevel@tonic-gate 	if (ret_val == (char *)NULL)
337c478bd9Sstevel@tonic-gate 	    return((char *)NULL);
347c478bd9Sstevel@tonic-gate 	strcpy(ret_val, infop->subsystem_name);
357c478bd9Sstevel@tonic-gate 	return(ret_val);
367c478bd9Sstevel@tonic-gate     }
377c478bd9Sstevel@tonic-gate     else {
387c478bd9Sstevel@tonic-gate 	register char *cp;
397c478bd9Sstevel@tonic-gate 	register char const *cp1;
407c478bd9Sstevel@tonic-gate 	ret_val = malloc((unsigned)sizeof(char) *
417c478bd9Sstevel@tonic-gate 			 (strlen(infop->subsystem_name)+
427c478bd9Sstevel@tonic-gate 			  strlen(infop->current_request)+
437c478bd9Sstevel@tonic-gate 			  4));
447c478bd9Sstevel@tonic-gate 	cp = ret_val;
457c478bd9Sstevel@tonic-gate 	cp1 = infop->subsystem_name;
467c478bd9Sstevel@tonic-gate 	while (*cp1)
477c478bd9Sstevel@tonic-gate 	    *cp++ = *cp1++;
487c478bd9Sstevel@tonic-gate 	*cp++ = ' ';
497c478bd9Sstevel@tonic-gate 	*cp++ = '(';
507c478bd9Sstevel@tonic-gate 	cp1 = infop->current_request;
517c478bd9Sstevel@tonic-gate 	while (*cp1)
527c478bd9Sstevel@tonic-gate 	    *cp++ = *cp1++;
537c478bd9Sstevel@tonic-gate 	*cp++ = ')';
547c478bd9Sstevel@tonic-gate 	*cp = '\0';
557c478bd9Sstevel@tonic-gate 	return(ret_val);
567c478bd9Sstevel@tonic-gate     }
577c478bd9Sstevel@tonic-gate }
587c478bd9Sstevel@tonic-gate 
ss_error(int sci_idx,long code,const char * fmt,...)597c478bd9Sstevel@tonic-gate void ss_error (int sci_idx, long code, const char * fmt, ...)
607c478bd9Sstevel@tonic-gate {
617c478bd9Sstevel@tonic-gate     register char *whoami;
627c478bd9Sstevel@tonic-gate     va_list pvar;
637c478bd9Sstevel@tonic-gate     va_start (pvar, fmt);
647c478bd9Sstevel@tonic-gate     whoami = ss_name (sci_idx);
657c478bd9Sstevel@tonic-gate     com_err_va (whoami, code, fmt, pvar);
667c478bd9Sstevel@tonic-gate     free (whoami);
677c478bd9Sstevel@tonic-gate     va_end(pvar);
687c478bd9Sstevel@tonic-gate }
697c478bd9Sstevel@tonic-gate 
ss_perror(sci_idx,code,msg)707c478bd9Sstevel@tonic-gate void ss_perror (sci_idx, code, msg) /* for compatibility */
717c478bd9Sstevel@tonic-gate     int sci_idx;
727c478bd9Sstevel@tonic-gate     long code;
737c478bd9Sstevel@tonic-gate     char const *msg;
747c478bd9Sstevel@tonic-gate {
757c478bd9Sstevel@tonic-gate     ss_error (sci_idx, code, "%s", msg);
767c478bd9Sstevel@tonic-gate }
77