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