dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / gss_mechs / mech_spnego / mech / spnego_kerrs.c
blob48a2bb29665b4d1936f95723a7ab1a89f4ab6333
1 /*
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * lib/krb5/krb/kerrs.c
7 * Copyright 2006 Massachusetts Institute of Technology.
8 * All Rights Reserved.
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>
32 #include <unistd.h>
33 #include <assert.h>
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include <k5-int.h>
38 #include <krb5.h>
39 #include <mglueP.h>
40 #include "gssapiP_spnego.h"
41 #include "gssapiP_generic.h"
42 #include <gssapi_err_generic.h>
44 #ifdef DEBUG
45 static int error_message_debug = 0;
46 #ifndef ERROR_MESSAGE_DEBUG
47 #define ERROR_MESSAGE_DEBUG() (error_message_debug != 0)
48 #endif
49 #endif
51 void
52 spnego_set_error_message (spnego_gss_ctx_id_t ctx, spnego_error_code code,
53 const char *fmt, ...)
55 va_list args;
56 if (ctx == NULL)
57 return;
58 va_start (args, fmt);
59 #ifdef DEBUG
60 if (ERROR_MESSAGE_DEBUG())
61 fprintf(stderr,
62 "spnego_set_error_message(ctx=%p/err=%p, code=%ld, ...)\n",
63 ctx, &ctx->err, (long) code);
64 #endif
65 krb5int_vset_error (&ctx->err, code, fmt, args);
66 #ifdef DEBUG
67 if (ERROR_MESSAGE_DEBUG())
68 fprintf(stderr, "->%s\n", ctx->err.msg);
69 #endif
70 va_end (args);
73 void
74 spnego_vset_error_message (spnego_gss_ctx_id_t ctx, spnego_error_code code,
75 const char *fmt, va_list args)
77 #ifdef DEBUG
78 if (ERROR_MESSAGE_DEBUG())
79 fprintf(stderr, "spnego_vset_error_message(ctx=%p, code=%ld, ...)\n",
80 ctx, (long) code);
81 #endif
82 if (ctx == NULL)
83 return;
84 krb5int_vset_error (&ctx->err, code, fmt, args);
85 #ifdef DEBUG
86 if (ERROR_MESSAGE_DEBUG())
87 fprintf(stderr, "->%s\n", ctx->err.msg);
88 #endif
91 const char *
92 spnego_get_error_message (spnego_gss_ctx_id_t ctx, spnego_error_code code)
94 #ifdef DEBUG
95 if (ERROR_MESSAGE_DEBUG())
96 fprintf(stderr, "spnego_get_error_message(%p, %ld)\n", ctx, (long) code);
97 #endif
98 if (ctx == NULL)
99 return error_message(code);
100 return krb5int_get_error (&ctx->err, code);
103 void
104 spnego_free_error_message (spnego_gss_ctx_id_t ctx, const char *msg)
106 #ifdef DEBUG
107 if (ERROR_MESSAGE_DEBUG())
108 fprintf(stderr, "spnego_free_error_message(%p, %p)\n", ctx, msg);
109 #endif
110 if (ctx == NULL)
111 return;
112 krb5int_free_error (&ctx->err, msg);
115 void
116 spnego_clear_error_message (spnego_gss_ctx_id_t ctx)
118 #ifdef DEBUG
119 if (ERROR_MESSAGE_DEBUG())
120 fprintf(stderr, "spnego_clear_error_message(%p)\n", ctx);
121 #endif
122 if (ctx == NULL)
123 return;
124 krb5int_clear_error (&ctx->err);