2N/A/*
2N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A/*
2N/A * lib/krb5/krb/kerrs.c
2N/A *
2N/A * Copyright 2006 Massachusetts Institute of Technology.
2N/A * All Rights Reserved.
2N/A *
2N/A * Export of this software from the United States of America may
2N/A * require a specific license from the United States Government.
2N/A * It is the responsibility of any person or organization contemplating
2N/A * export to obtain such a license before exporting.
2N/A *
2N/A * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
2N/A * distribute this software and its documentation for any purpose and
2N/A * without fee is hereby granted, provided that the above copyright
2N/A * notice appear in all copies and that both that copyright notice and
2N/A * this permission notice appear in supporting documentation, and that
2N/A * the name of M.I.T. not be used in advertising or publicity pertaining
2N/A * to distribution of the software without specific, written prior
2N/A * permission. Furthermore if you modify this software you must label
2N/A * your software as modified software and not distribute it in such a
2N/A * fashion that it might be confused with the original M.I.T. software.
2N/A * M.I.T. makes no representations about the suitability of
2N/A * this software for any purpose. It is provided "as is" without express
2N/A * or implied warranty.
2N/A *
2N/A * error-message functions
2N/A */
2N/A#include <sys/param.h>
2N/A#include <unistd.h>
2N/A#include <assert.h>
2N/A#include <stdio.h>
2N/A#include <stdlib.h>
2N/A#include <string.h>
2N/A#include <k5-int.h>
2N/A#include <krb5.h>
2N/A#include <mglueP.h>
2N/A#include "gssapiP_spnego.h"
2N/A#include "gssapiP_generic.h"
2N/A#include <gssapi_err_generic.h>
2N/A
2N/A#ifdef DEBUG
2N/Astatic int error_message_debug = 0;
2N/A#ifndef ERROR_MESSAGE_DEBUG
2N/A#define ERROR_MESSAGE_DEBUG() (error_message_debug != 0)
2N/A#endif
2N/A#endif
2N/A
2N/Avoid
2N/Aspnego_set_error_message (spnego_gss_ctx_id_t ctx, spnego_error_code code,
2N/A const char *fmt, ...)
2N/A{
2N/A va_list args;
2N/A if (ctx == NULL)
2N/A return;
2N/A va_start (args, fmt);
2N/A#ifdef DEBUG
2N/A if (ERROR_MESSAGE_DEBUG())
2N/A fprintf(stderr,
2N/A "spnego_set_error_message(ctx=%p/err=%p, code=%ld, ...)\n",
2N/A ctx, &ctx->err, (long) code);
2N/A#endif
2N/A krb5int_vset_error (&ctx->err, code, fmt, args);
2N/A#ifdef DEBUG
2N/A if (ERROR_MESSAGE_DEBUG())
2N/A fprintf(stderr, "->%s\n", ctx->err.msg);
2N/A#endif
2N/A va_end (args);
2N/A}
2N/A
2N/Avoid
2N/Aspnego_vset_error_message (spnego_gss_ctx_id_t ctx, spnego_error_code code,
2N/A const char *fmt, va_list args)
2N/A{
2N/A#ifdef DEBUG
2N/A if (ERROR_MESSAGE_DEBUG())
2N/A fprintf(stderr, "spnego_vset_error_message(ctx=%p, code=%ld, ...)\n",
2N/A ctx, (long) code);
2N/A#endif
2N/A if (ctx == NULL)
2N/A return;
2N/A krb5int_vset_error (&ctx->err, code, fmt, args);
2N/A#ifdef DEBUG
2N/A if (ERROR_MESSAGE_DEBUG())
2N/A fprintf(stderr, "->%s\n", ctx->err.msg);
2N/A#endif
2N/A}
2N/A
2N/Aconst char *
2N/Aspnego_get_error_message (spnego_gss_ctx_id_t ctx, spnego_error_code code)
2N/A{
2N/A#ifdef DEBUG
2N/A if (ERROR_MESSAGE_DEBUG())
2N/A fprintf(stderr, "spnego_get_error_message(%p, %ld)\n", ctx, (long) code);
2N/A#endif
2N/A if (ctx == NULL)
2N/A return error_message(code);
2N/A return krb5int_get_error (&ctx->err, code);
2N/A}
2N/A
2N/Avoid
2N/Aspnego_free_error_message (spnego_gss_ctx_id_t ctx, const char *msg)
2N/A{
2N/A#ifdef DEBUG
2N/A if (ERROR_MESSAGE_DEBUG())
2N/A fprintf(stderr, "spnego_free_error_message(%p, %p)\n", ctx, msg);
2N/A#endif
2N/A if (ctx == NULL)
2N/A return;
2N/A krb5int_free_error (&ctx->err, msg);
2N/A}
2N/A
2N/Avoid
2N/Aspnego_clear_error_message (spnego_gss_ctx_id_t ctx)
2N/A{
2N/A#ifdef DEBUG
2N/A if (ERROR_MESSAGE_DEBUG())
2N/A fprintf(stderr, "spnego_clear_error_message(%p)\n", ctx);
2N/A#endif
2N/A if (ctx == NULL)
2N/A return;
2N/A krb5int_clear_error (&ctx->err);
2N/A}