Deleted Added
full compact
com_err.c (127807) com_err.c (178846)
1/*
2 * Copyright (c) 1997 - 2002 Kungliga Tekniska H�gskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 16 unchanged lines hidden (view full) ---

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
1/*
2 * Copyright (c) 1997 - 2002 Kungliga Tekniska H�gskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 16 unchanged lines hidden (view full) ---

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33/* $FreeBSD: head/contrib/com_err/com_err.c 127807 2004-04-03 21:17:01Z nectar $ */
33/* $FreeBSD: head/contrib/com_err/com_err.c 178846 2008-05-08 11:01:46Z dfr $ */
34
35#ifdef HAVE_CONFIG_H
36#include <config.h>
34
35#ifdef HAVE_CONFIG_H
36#include <config.h>
37RCSID("$Id: com_err.c,v 1.18 2002/03/10 23:07:01 assar Exp $");
37RCSID("$Id: com_err.c 14930 2005-04-24 19:43:06Z lha $");
38#endif
39#include <stdio.h>
40#include <stdlib.h>
41#include <string.h>
42#include "com_err.h"
43
44struct et_list *_et_list = NULL;
45
46
47const char *
48error_message (long code)
49{
50 static char msg[128];
51 const char *p = com_right(_et_list, code);
52 if (p == NULL) {
53 if (code < 0)
38#endif
39#include <stdio.h>
40#include <stdlib.h>
41#include <string.h>
42#include "com_err.h"
43
44struct et_list *_et_list = NULL;
45
46
47const char *
48error_message (long code)
49{
50 static char msg[128];
51 const char *p = com_right(_et_list, code);
52 if (p == NULL) {
53 if (code < 0)
54 sprintf(msg, "Unknown error %ld", code);
54 snprintf(msg, sizeof(msg), "Unknown error %ld", code);
55 else
56 p = strerror(code);
57 }
58 if (p != NULL && *p != '\0') {
55 else
56 p = strerror(code);
57 }
58 if (p != NULL && *p != '\0') {
59 strncpy(msg, p, sizeof(msg) - 1);
60 msg[sizeof(msg) - 1] = 0;
59 strlcpy(msg, p, sizeof(msg));
61 } else
60 } else
62 sprintf(msg, "Unknown error %ld", code);
61 snprintf(msg, sizeof(msg), "Unknown error %ld", code);
63 return msg;
64}
65
66int
67init_error_table(const char **msgs, long base, int count)
68{
69 initialize_error_table_r(&_et_list, msgs, count, base);
70 return 0;

--- 103 unchanged lines hidden ---
62 return msg;
63}
64
65int
66init_error_table(const char **msgs, long base, int count)
67{
68 initialize_error_table_r(&_et_list, msgs, count, base);
69 return 0;

--- 103 unchanged lines hidden ---