2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
7 * Copyright 2006 Massachusetts Institute of Technology.
10 * Export of this software from the United States of America may
11 * require a specific license from the United States Government.
12 * It is the responsibility of any person or organization contemplating
13 * export to obtain such a license before exporting.
15 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
16 * distribute this software and its documentation for any purpose and
17 * without fee is hereby granted, provided that the above copyright
18 * notice appear in all copies and that both that copyright notice and
19 * this permission notice appear in supporting documentation, and that
20 * the name of M.I.T. not be used in advertising or publicity pertaining
21 * to distribution of the software without specific, written prior
22 * permission. Furthermore if you modify this software you must label
23 * your software as modified software and not distribute it in such a
24 * fashion that it might be confused with the original M.I.T. software.
25 * M.I.T. makes no representations about the suitability of
26 * this software for any purpose. It is provided "as is" without express
27 * or implied warranty.
29 * error-message functions
31 #include <sys/param.h>
40 #include "gssapiP_spnego.h"
41 #include "gssapiP_generic.h"
42 #include <gssapi_err_generic.h>
45 static int error_message_debug
= 0;
46 #ifndef ERROR_MESSAGE_DEBUG
47 #define ERROR_MESSAGE_DEBUG() (error_message_debug != 0)
52 spnego_set_error_message (spnego_gss_ctx_id_t ctx
, spnego_error_code code
,
60 if (ERROR_MESSAGE_DEBUG())
62 "spnego_set_error_message(ctx=%p/err=%p, code=%ld, ...)\n",
63 ctx
, &ctx
->err
, (long) code
);
65 krb5int_vset_error (&ctx
->err
, code
, fmt
, args
);
67 if (ERROR_MESSAGE_DEBUG())
68 fprintf(stderr
, "->%s\n", ctx
->err
.msg
);
74 spnego_vset_error_message (spnego_gss_ctx_id_t ctx
, spnego_error_code code
,
75 const char *fmt
, va_list args
)
78 if (ERROR_MESSAGE_DEBUG())
79 fprintf(stderr
, "spnego_vset_error_message(ctx=%p, code=%ld, ...)\n",
84 krb5int_vset_error (&ctx
->err
, code
, fmt
, args
);
86 if (ERROR_MESSAGE_DEBUG())
87 fprintf(stderr
, "->%s\n", ctx
->err
.msg
);
92 spnego_get_error_message (spnego_gss_ctx_id_t ctx
, spnego_error_code code
)
95 if (ERROR_MESSAGE_DEBUG())
96 fprintf(stderr
, "spnego_get_error_message(%p, %ld)\n", ctx
, (long) code
);
99 return error_message(code
);
100 return krb5int_get_error (&ctx
->err
, code
);
104 spnego_free_error_message (spnego_gss_ctx_id_t ctx
, const char *msg
)
107 if (ERROR_MESSAGE_DEBUG())
108 fprintf(stderr
, "spnego_free_error_message(%p, %p)\n", ctx
, msg
);
112 krb5int_free_error (&ctx
->err
, msg
);
116 spnego_clear_error_message (spnego_gss_ctx_id_t ctx
)
119 if (ERROR_MESSAGE_DEBUG())
120 fprintf(stderr
, "spnego_clear_error_message(%p)\n", ctx
);
124 krb5int_clear_error (&ctx
->err
);