~ubuntu-branches/ubuntu/wily/sup/wily

« back to all changes in this revision

Viewing changes to errmsg.c

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2006-11-02 15:03:30 UTC
  • mfrom: (1.1.1 upstream) (3.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20061102150330-yt4yavw4rj1hz8yj
Tags: 20060803-2
Fix CFLAGS, so libwrap is built into sup again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*      $NetBSD: errmsg.c,v 1.8 2003/04/03 17:14:24 christos Exp $      */
 
2
 
1
3
/*
2
4
 * Copyright (c) 1991 Carnegie Mellon University
3
5
 * All Rights Reserved.
4
 
 * 
 
6
 *
5
7
 * Permission to use, copy, modify and distribute this software and its
6
8
 * documentation is hereby granted, provided that both the copyright
7
9
 * notice and this permission notice appear in all copies of the
30
32
 *      negative value to indicate using the current errno value...the
31
33
 *      BBN uses a negative OR zero value.
32
34
 */
33
 
#include <string.h>
34
 
#include <errno.h>
35
 
 
36
 
extern int      errno;
37
 
extern int      sys_nerr;
38
 
extern char     *sys_errlist[];
39
 
 
40
 
static char *itoa(p,n)
41
 
char *p;
42
 
unsigned n;
 
35
 
 
36
#include "supcdefs.h"
 
37
#include "supextern.h"
 
38
 
 
39
#ifndef __NetBSD__
 
40
static char *itoa(char *, unsigned);
 
41
 
 
42
static char *
 
43
itoa(char *p, unsigned n)
43
44
{
44
 
    if (n >= 10)
45
 
        p =itoa(p,n/10);
46
 
    *p++ = (n%10)+'0';
47
 
    return(p);
 
45
        if (n >= 10)
 
46
                p = itoa(p, n / 10);
 
47
        *p++ = (n % 10) + '0';
 
48
        return (p);
48
49
}
 
50
#endif
49
51
 
50
 
char *
 
52
const char *
51
53
errmsg(int cod)
52
54
{
 
55
#ifndef errno
 
56
        extern int errno;
 
57
        extern int sys_nerr;
 
58
        extern char *sys_errlist[];
 
59
        static char unkmsg[] = "Unknown error ";
 
60
        static char unk[sizeof(unkmsg) + 11];   /* trust us */
 
61
#endif
 
62
 
53
63
        if (cod < 0)
54
64
                cod = errno;
55
65
 
 
66
#ifndef errno
 
67
        if ((cod >= 0) && (cod < sys_nerr))
 
68
                return (sys_errlist[cod]);
 
69
 
 
70
        strcpy(unk, unkmsg);
 
71
        *itoa(&unk[sizeof(unkmsg) - 1], cod) = '\0';
 
72
 
 
73
        return (unk);
 
74
#else
56
75
        return strerror(cod);
 
76
#endif
57
77
}