Import libcom_err from Heimdal 0.6.1.

This commit is contained in:
Jacques Vidrine 2004-04-03 21:08:58 +00:00
parent 847a74626b
commit f054c1df3f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/com_err/dist/; revision=127804
svn path=/vendor/com_err/0.6.1/; revision=127806; tag=vendor/com_err/0.6.1
13 changed files with 751 additions and 538 deletions

View File

@ -1,3 +1,63 @@
2002-08-20 Johan Danielsson <joda@pdc.kth.se>
* compile_et.c: don't add comma after last enum member
2002-08-12 Johan Danielsson <joda@pdc.kth.se>
* compile_et.c: just declare er_list directly instead of including
com_right in generated header files
2002-03-11 Assar Westerlund <assar@sics.se>
* Makefile.am (libcom_err_la_LDFLAGS): set version to 2:1:1
2002-03-10 Assar Westerlund <assar@sics.se>
* com_err.c (error_message): do not call strerror with a negative error
2001-05-17 Assar Westerlund <assar@sics.se>
* Makefile.am: bump version to 2:0:1
2001-05-11 Assar Westerlund <assar@sics.se>
* com_err.h (add_to_error_table): add prototype
* com_err.c (add_to_error_table): new function, from Derrick J
Brashear <shadow@dementia.org>
2001-05-06 Assar Westerlund <assar@sics.se>
* com_err.h: add printf formats for gcc
2001-02-28 Johan Danielsson <joda@pdc.kth.se>
* error.c (initialize_error_table_r): put table at end of the list
2001-02-15 Assar Westerlund <assar@sics.se>
* com_err.c (default_proc): add printf attributes
2000-08-16 Assar Westerlund <assar@sics.se>
* Makefile.am: bump version to 1:1:0
2000-07-31 Assar Westerlund <assar@sics.se>
* com_right.h (initialize_error_table_r): fix prototype
2000-04-05 Assar Westerlund <assar@sics.se>
* com_err.c (_et_lit): explicitly initialize it to NULL to make
dyld on Darwin/MacOS X happy
2000-01-16 Assar Westerlund <assar@sics.se>
* com_err.h: remove __P definition (now in com_right.h). this
file always includes com_right.h so that's where it should reside.
* com_right.h: moved __P here and added it to the function
prototypes
* com_err.h (error_table_name): add __P
1999-07-03 Assar Westerlund <assar@sics.se>
* parse.y (statement): use asprintf

View File

@ -1,11 +1,11 @@
# $Id: Makefile.am,v 1.23 1999/04/09 18:26:55 assar Exp $
# $Id: Makefile.am,v 1.27 2002/03/10 23:52:41 assar Exp $
include $(top_srcdir)/Makefile.am.common
YFLAGS = -d
lib_LTLIBRARIES = libcom_err.la
libcom_err_la_LDFLAGS = -version-info 1:0:0
libcom_err_la_LDFLAGS = -version-info 2:1:1
bin_PROGRAMS = compile_et
@ -17,7 +17,7 @@ libcom_err_la_SOURCES = error.c com_err.c roken_rename.h
CLEANFILES = lex.c parse.c parse.h
$(compile_et_OBJECTS): parse.h
$(compile_et_OBJECTS): parse.h parse.c ## XXX broken automake 1.4s
compile_et_LDADD = \
$(LIB_roken) \

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan
* Copyright (c) 1997 - 2002 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -14,12 +14,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -38,7 +33,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
RCSID("$Id: com_err.c,v 1.13 1999/03/12 15:17:08 bg Exp $");
RCSID("$Id: com_err.c,v 1.18 2002/03/10 23:07:01 assar Exp $");
#endif
#include <stdio.h>
#include <stdlib.h>
@ -46,7 +41,7 @@ RCSID("$Id: com_err.c,v 1.13 1999/03/12 15:17:08 bg Exp $");
#include <roken.h>
#include "com_err.h"
struct et_list *_et_list;
struct et_list *_et_list = NULL;
const char *
@ -54,8 +49,12 @@ error_message (long code)
{
static char msg[128];
const char *p = com_right(_et_list, code);
if (p == NULL)
p = strerror(code);
if (p == NULL) {
if (code < 0)
sprintf(msg, "Unknown error %ld", code);
else
p = strerror(code);
}
if (p != NULL && *p != '\0') {
strncpy(msg, p, sizeof(msg) - 1);
msg[sizeof(msg) - 1] = 0;
@ -71,6 +70,10 @@ init_error_table(const char **msgs, long base, int count)
return 0;
}
static void
default_proc (const char *whoami, long code, const char *fmt, va_list args)
__attribute__((__format__(__printf__, 3, 0)));
static void
default_proc (const char *whoami, long code, const char *fmt, va_list args)
{
@ -154,3 +157,17 @@ error_table_name(int num)
*p = '\0';
return(buf);
}
void
add_to_error_table(struct et_list *new_table)
{
struct et_list *et;
for (et = _et_list; et; et = et->next) {
if (et->table->base == new_table->table->base)
return;
}
new_table->next = _et_list;
_et_list = new_table;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan
* Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -14,12 +14,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -36,38 +31,35 @@
* SUCH DAMAGE.
*/
/* $Id: com_err.h,v 1.3 1998/05/02 20:13:28 assar Exp $ */
/* $Id: com_err.h,v 1.9 2001/05/11 20:03:36 assar Exp $ */
/* MIT compatible com_err library */
#ifndef __COM_ERR_H__
#define __COM_ERR_H__
#ifdef __STDC__
#include <stdarg.h>
#endif
#ifndef __P
#ifdef __STDC__
#define __P(X) X
#else
#define __P(X) ()
#endif
#endif
#include <com_right.h>
#if !defined(__GNUC__) && !defined(__attribute__)
#define __attribute__(X)
#endif
typedef void (*errf) __P((const char *, long, const char *, va_list));
const char * error_message __P((long));
int init_error_table __P((const char**, long, int));
void com_err_va __P((const char *, long, const char *, va_list));
void com_err __P((const char *, long, const char *, ...));
void com_err_va __P((const char *, long, const char *, va_list))
__attribute__((format(printf, 3, 0)));
void com_err __P((const char *, long, const char *, ...))
__attribute__((format(printf, 3, 4)));
errf set_com_err_hook __P((errf));
errf reset_com_err_hook __P((void));
const char *error_table_name(int num);
const char *error_table_name __P((int num));
void add_to_error_table __P((struct et_list *new_table));
#endif /* __COM_ERR_H__ */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan
* Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -14,12 +14,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -36,11 +31,23 @@
* SUCH DAMAGE.
*/
/* $Id: com_right.h,v 1.8 1998/02/17 21:19:43 bg Exp $ */
/* $Id: com_right.h,v 1.11 2000/07/31 01:11:08 assar Exp $ */
#ifndef __COM_RIGHT_H__
#define __COM_RIGHT_H__
#ifdef __STDC__
#include <stdarg.h>
#endif
#ifndef __P
#ifdef __STDC__
#define __P(X) X
#else
#define __P(X) ()
#endif
#endif
struct error_table {
char const * const * msgs;
long base;
@ -52,8 +59,8 @@ struct et_list {
};
extern struct et_list *_et_list;
const char *com_right(struct et_list *list, long code);
void initialize_error_table_r(struct et_list **, const char **, int, long);
void free_error_table(struct et_list *);
const char *com_right __P((struct et_list *list, long code));
void initialize_error_table_r __P((struct et_list **, const char **, int, long));
void free_error_table __P((struct et_list *));
#endif /* __COM_RIGHT_H__ */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
* Copyright (c) 1998-2002 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -14,12 +14,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -40,7 +35,7 @@
#include "compile_et.h"
#include <getarg.h>
RCSID("$Id: compile_et.c,v 1.12 1999/04/01 09:13:52 joda Exp $");
RCSID("$Id: compile_et.c,v 1.16 2002/08/20 12:44:51 joda Exp $");
#include <roken.h>
#include <err.h>
@ -88,7 +83,7 @@ generate_c(void)
fprintf(c_file, "#include \"%s\"\n", hfn);
fprintf(c_file, "\n");
fprintf(c_file, "static const char *text[] = {\n");
fprintf(c_file, "static const char *%s_error_strings[] = {\n", name);
for(ec = codes, n = 0; ec; ec = ec->next, n++) {
while(n < ec->number) {
@ -103,20 +98,22 @@ generate_c(void)
fprintf(c_file, "\tNULL\n");
fprintf(c_file, "};\n");
fprintf(c_file, "\n");
fprintf(c_file, "#define num_errors %d\n", number);
fprintf(c_file, "\n");
fprintf(c_file,
"void initialize_%s_error_table_r(struct et_list **list)\n",
name);
fprintf(c_file, "{\n");
fprintf(c_file,
" initialize_error_table_r(list, text, "
"%s_num_errors, ERROR_TABLE_BASE_%s);\n", name, name);
" initialize_error_table_r(list, %s_error_strings, "
"num_errors, ERROR_TABLE_BASE_%s);\n", name, name);
fprintf(c_file, "}\n");
fprintf(c_file, "\n");
fprintf(c_file, "void initialize_%s_error_table(void)\n", name);
fprintf(c_file, "{\n");
fprintf(c_file,
" init_error_table(text, ERROR_TABLE_BASE_%s, "
"%s_num_errors);\n", name, name);
" init_error_table(%s_error_strings, ERROR_TABLE_BASE_%s, "
"num_errors);\n", name, name);
fprintf(c_file, "}\n");
fclose(c_file);
@ -146,7 +143,7 @@ generate_h(void)
fprintf(h_file, "#ifndef %s\n", fn);
fprintf(h_file, "#define %s\n", fn);
fprintf(h_file, "\n");
fprintf(h_file, "#include <com_right.h>\n");
fprintf(h_file, "struct et_list;\n");
fprintf(h_file, "\n");
fprintf(h_file,
"void initialize_%s_error_table_r(struct et_list **);\n",
@ -157,16 +154,16 @@ generate_h(void)
name, name);
fprintf(h_file, "\n");
fprintf(h_file, "typedef enum %s_error_number{\n", name);
fprintf(h_file, "\tERROR_TABLE_BASE_%s = %ld,\n", name, base);
fprintf(h_file, "\t%s_err_base = %ld,\n", name, base);
for(ec = codes; ec; ec = ec->next) {
fprintf(h_file, "\t%s = %ld,\n", ec->name, base + ec->number);
fprintf(h_file, "\t%s = %ld%s\n", ec->name, base + ec->number,
(ec->next != NULL) ? "," : "");
}
fprintf(h_file, "\t%s_num_errors = %d\n", name, number);
fprintf(h_file, "} %s_error_number;\n", name);
fprintf(h_file, "\n");
fprintf(h_file, "#define ERROR_TABLE_BASE_%s %ld\n", name, base);
fprintf(h_file, "\n");
fprintf(h_file, "#endif /* %s */\n", fn);
@ -201,7 +198,7 @@ main(int argc, char **argv)
char *p;
int optind = 0;
set_progname(argv[0]);
setprogname(argv[0]);
if(getarg(args, num_args, argc, argv, &optind))
usage(1);
if(help_flag)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998 Kungliga Tekniska Högskolan
* Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -14,12 +14,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -36,7 +31,7 @@
* SUCH DAMAGE.
*/
/* $Id: compile_et.h,v 1.3 1998/11/22 09:39:46 assar Exp $ */
/* $Id: compile_et.h,v 1.6 2000/07/01 20:21:48 assar Exp $ */
#ifndef __COMPILE_ET_H__
#define __COMPILE_ET_H__
@ -50,7 +45,6 @@
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <roken.h>
extern long base;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 1998 Kungliga Tekniska Högskolan
* Copyright (c) 1997, 1998, 2001 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -14,12 +14,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -38,7 +33,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
RCSID("$Id: error.c,v 1.13 1998/02/17 21:19:44 bg Exp $");
RCSID("$Id: error.c,v 1.15 2001/02/28 20:00:13 joda Exp $");
#endif
#include <stdio.h>
#include <stdlib.h>
@ -67,9 +62,9 @@ initialize_error_table_r(struct et_list **list,
int num_errors,
long base)
{
struct et_list *et;
struct et_list *et, **end;
struct foobar *f;
for (et = *list; et; et = et->next)
for (end = list, et = *list; et; end = &et->next, et = et->next)
if (et->table->msgs == messages)
return;
f = malloc(sizeof(*f));
@ -80,8 +75,8 @@ initialize_error_table_r(struct et_list **list,
et->table->msgs = messages;
et->table->n_msgs = num_errors;
et->table->base = base;
et->next = *list;
*list = et;
et->next = NULL;
*end = et;
}

39
contrib/com_err/lex.h Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* $Id: lex.h,v 1.1 2000/06/22 00:42:52 assar Exp $ */
void error_message (const char *, ...)
__attribute__ ((format (printf, 1, 2)));
int yylex(void);

View File

@ -1,6 +1,6 @@
%{
/*
* Copyright (c) 1998 Kungliga Tekniska Högskolan
* Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -15,12 +15,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -47,12 +42,16 @@
#include "compile_et.h"
#include "parse.h"
#include "lex.h"
RCSID("$Id: lex.l,v 1.4 1998/11/20 05:58:52 assar Exp $");
RCSID("$Id: lex.l,v 1.6 2000/06/22 00:42:52 assar Exp $");
static unsigned lineno = 1;
void error_message(char *, ...);
int getstring(void);
static int getstring(void);
#define YY_NO_UNPUT
#undef ECHO
%}
@ -83,7 +82,7 @@ yywrap ()
}
#endif
int
static int
getstring(void)
{
char x[128];
@ -115,7 +114,7 @@ getstring(void)
}
void
error_message (char *format, ...)
error_message (const char *format, ...)
{
va_list args;

View File

@ -1,6 +1,6 @@
%{
/*
* Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
* Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@ -15,12 +15,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -38,11 +33,12 @@
*/
#include "compile_et.h"
RCSID("$Id: parse.y,v 1.9 1999/07/04 14:54:58 assar Exp $");
#include "lex.h"
RCSID("$Id: parse.y,v 1.11 2000/06/22 00:42:52 assar Exp $");
void yyerror (char *s);
long name2number(const char *str);
void error_message(char *, ...);
static long name2number(const char *str);
extern char *yytext;
@ -139,7 +135,7 @@ statement : INDEX NUMBER
%%
long
static long
name2number(const char *str)
{
const char *p;

View File

@ -14,12 +14,7 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Kungliga Tekniska
* Högskolan and its contributors.
*
* 4. Neither the name of the Institute nor the names of its contributors
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -36,7 +31,7 @@
* SUCH DAMAGE.
*/
/* $Id: roken_rename.h,v 1.2 1999/03/11 18:14:53 bg Exp $ */
/* $Id: roken_rename.h,v 1.3 1999/12/02 16:58:38 joda Exp $ */
#ifndef __roken_rename_h__
#define __roken_rename_h__