1
/* @(#)serrmsg.c 1.3 03/06/15 Copyright 1985, 2000-2003 J. Schilling */
3
* Routines for printing command errors
5
* Copyright (c) 1985, 2000-2003 J. Schilling
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2, or (at your option)
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License along with
19
* this program; see the file COPYING. If not, write to the Free Software
20
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
#include <unixstd.h> /* include <sys/types.h> try to get size_t */
25
#include <stdio.h> /* Try again for size_t */
26
#include <stdxlib.h> /* Try again for size_t */
33
extern char *sys_errlist[];
37
EXPORT int serrmsg __PR((char *buf, size_t maxcnt, const char *, ...));
38
EXPORT int serrmsgno __PR((int, char *buf, size_t maxcnt, const char *, ...));
39
LOCAL int _serrmsg __PR((int, char *buf, size_t maxcnt, const char *, va_list));
44
serrmsg(char *buf, size_t maxcnt, const char *msg, ...)
46
serrmsg(buf, maxcnt, msg, va_alist)
61
ret = _serrmsg(geterrno(), buf, maxcnt, msg, args);
69
serrmsgno(int err, char *buf, size_t maxcnt, const char *msg, ...)
71
serrmsgno(err, buf, maxcnt, msg, va_alist)
87
ret = _serrmsg(err, buf, maxcnt, msg, args);
93
_serrmsg(err, buf, maxcnt, msg, args)
103
char *prognam = get_progname();
106
ret = js_snprintf(buf, maxcnt, "%s: %r", prognam, msg, args);
108
errnam = errmsgstr(err);
109
if (errnam == NULL) {
110
(void) js_snprintf(errbuf, sizeof (errbuf),
114
ret = js_snprintf(buf, maxcnt,
115
"%s: %s. %r", prognam, errnam, msg, args);