xref: /freebsd/crypto/krb5/src/util/ss/error.c (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  * Copyright 2007 Massachusetts Institute of Technology.
4  * All Rights Reserved.
5  *
6  * Export of this software from the United States of America may
7  *   require a specific license from the United States Government.
8  *   It is the responsibility of any person or organization contemplating
9  *   export to obtain such a license before exporting.
10  *
11  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
12  * distribute this software and its documentation for any purpose and
13  * without fee is hereby granted, provided that the above copyright
14  * notice appear in all copies and that both that copyright notice and
15  * this permission notice appear in supporting documentation, and that
16  * the name of M.I.T. not be used in advertising or publicity pertaining
17  * to distribution of the software without specific, written prior
18  * permission.  Furthermore if you modify this software you must label
19  * your software as modified software and not distribute it in such a
20  * fashion that it might be confused with the original M.I.T. software.
21  * M.I.T. makes no representations about the suitability of
22  * this software for any purpose.  It is provided "as is" without express
23  * or implied warranty.
24  */
25 /*
26  * Copyright 1987, 1988, 1989 by MIT Student Information Processing
27  * Board
28  *
29  * For copyright information, see copyright.h.
30  */
31 
32 #include "ss_internal.h"
33 #include "com_err.h"
34 #include "copyright.h"
35 
ss_name(sci_idx)36 char * ss_name(sci_idx)
37     int sci_idx;
38 {
39     ss_data *infop;
40 
41     infop = ss_info(sci_idx);
42     if (infop->current_request == (char const *)NULL) {
43         return strdup(infop->subsystem_name);
44     } else {
45         char *ret_val;
46         if (asprintf(&ret_val, "%s (%s)",
47                      infop->subsystem_name, infop->current_request) < 0)
48             return NULL;
49         return ret_val;
50     }
51 }
52 
ss_error(int sci_idx,long code,const char * fmt,...)53 void ss_error (int sci_idx, long code, const char * fmt, ...)
54 {
55     char *whoami;
56     va_list pvar;
57     va_start (pvar, fmt);
58     whoami = ss_name (sci_idx);
59     com_err_va (whoami, code, fmt, pvar);
60     free (whoami);
61     va_end(pvar);
62 }
63 
ss_perror(sci_idx,code,msg)64 void ss_perror (sci_idx, code, msg) /* for compatibility */
65     int sci_idx;
66     long code;
67     char const *msg;
68 {
69     ss_error (sci_idx, code, "%s", msg);
70 }
71