/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 1997 by Massachusetts Institute of Technology
*
* Copyright 1987, 1988 by MIT Student Information Processing Board
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purpose and without fee is
* hereby granted, provided that the above copyright notice
* appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation,
* and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
* used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission.
* Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. and the M.I.T. S.I.P.B. make no representations about
* the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include "com_err.h"
#include "error_table.h"
#if defined(_WIN32)
#include <io.h>
#endif
static void default_com_err_proc
#if defined(_WIN32)
mypid = GetCurrentProcessId();
}
#endif
/*
* Solaris Kerberos:
* It is sometimes desirable to have more than a single hook called
* when com_err() is invoked. A number of new functions have been
* added which allow hooks to be added and removed:
* add_com_err_hook()
* add_default_com_err_hook()
* remove_com_err_hook()
* remove_default_com_err_hook()
* The existing functions:
* set_com_err_hook()
* reset_com_err_hook()
* com_err()
* have been modified to work with the new scheme. Applications using
* the original function calls are not affected.
*/
/* Solaris Kerberos specific fix start --------------------------- */
#define gettext(X) X
struct msg_map {
char *msgid;
char *c_msgstr;
};
#define MSG_WHILE 0
{ gettext("%s\n## com_err msg of format: 'while ...'"),
"%s\n" },
{ gettext("%s\n## com_err message of format: 'error msg ...'"),
"%s\n" },
{ gettext("%1$s %2$s\n## com_err message of format: "
"'error msg ... while ...'"),
"%1$s %2$s\n" },
{ gettext("%1$s: %2$s\n## com_err msg of format: 'whoami: while ...'"),
"%1$s: %2$s\n" },
{ gettext("%1$s: %2$s\n## com_err message of format: "
"'whoami: error msg ...'"),
"%1$s: %2$s\n" },
{ gettext("%1$s: %2$s %3$s\n## com_err message of format: "
"'whoami: error msg ... while ...'"),
"%1$s: %2$s %3$s\n" },
{ gettext("%s:\n ## com_err message of format: "
"'whoami: with no error msg or while ...'"),
"%s:\n " }
};
/*
* The idea is that we provide a unique message id that contains extra junk
* that we never want to display in the C locale. If dgettext() returns
* a string that is equal to the message id, then we return the c_msgstr,
* for display in the locale.
*/
static char *
{
return (c_msgstr);
else
return (msgstr);
}
/* Solaris Kerberos specific fix end --------------------------- */
/* Solaris Kerberos: this code is significantly altered from
* the MIT 1.2.1 version to work with internationalization */
{
*whilebuf = '\0';
/*
* Because 'while ...' message could contain a format string
* we have to intepret it now, in a buffer. We need to put it
* into a buffer so that the message can be juxtaposed in a locale
* meaningful manner. In some natural languages, the 'while ...' phrase
* must be first.
*/
if (fmt) {
}
/*
* There are 8 possible combinations here depending on whether
* a whoami string was provided, error code is non-zero, and if a
* a 'while ...' messge was provided.
*/
if (!whoami) {
whilebuf);
} else
return;
} else {
} else {
whoami);
}
}
}
const char *fmt,
{
int err;
int i;
err = com_err_finish_init();
if (err)
goto best_try;
if (err)
goto best_try;
for (i = 0; i < hook_count; i++) {
}
return;
/* Yikes. Our library initialization failed or we couldn't lock
the lock we want. We could be in trouble. Gosh, we should
probably print an error message. Oh, wait. That's what we're
trying to do. In fact, if we're losing on initialization here,
there's a good chance it has to do with failed initialization
of the caller. */
for (i = 0; i < hook_count; i++) {
}
abort();
}
const char *fmt, ...)
{
}
/* Make a separate function because the assert invocations below
use the macro expansion on some platforms, which may be insanely
long and incomprehensible. */
static int com_err_lock_hook_handle(void)
{
return k5_mutex_lock(&com_err_hook_lock);
}
{
int i;
/* Broken initialization? What can we do? */
assert(com_err_finish_init() == 0);
assert(com_err_lock_hook_handle() == 0);
x = com_err_hook[0];
for (i = 0; i < hook_count; i++)
com_err_hook[i] = NULL;
com_err_hook[0] = new_proc;
hook_count = 1;
return x;
}
{
int i;
/* Broken initialization? What can we do? */
assert(com_err_finish_init() == 0);
assert(com_err_lock_hook_handle() == 0);
x = com_err_hook[0];
for (i = 0; i < hook_count; i++)
com_err_hook[i] = NULL;
hook_count = 1;
return x;
}
/*
* Solaris Kerberos:
* Register a hook which will be called every time
* com_err() is called.
*/
int i;
if (hook_count < MAX_HOOKS) {
for (i = 0; i < hook_count; i++) {
if (com_err_hook[i] == NULL)
break;
}
com_err_hook[i] = f;
hook_count++;
}
}
/*
* Solaris Kerberos:
* Remove a logging hook. The first hook matching 'f' will
* be removed.
*/
int i, j;
for (i = 0; i < hook_count; i++) {
if (com_err_hook[i] == f) {
for (j = i; j < hook_count - 1; j++) {
}
com_err_hook[j] = NULL;
hook_count--;
}
}
}
/*
* Solaris Kerberos:
* Remove the default hook.
*/
void rem_default_com_err_hook() {
}
/*
* Solaris Kerberos:
* Add back the default hook
*/
void add_default_com_err_hook() {
}