Add libbroken.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@417 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
78
lib/roken/Makefile.in
Normal file
78
lib/roken/Makefile.in
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
|
SHELL = /bin/sh
|
||||||
|
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
|
||||||
|
CC = @CC@
|
||||||
|
AR = ar
|
||||||
|
RANLIB = @RANLIB@
|
||||||
|
DEFS = @DEFS@
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
|
||||||
|
INSTALL = @INSTALL@
|
||||||
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
|
MKDIRHIER = @top_srcdir@/mkdirhier-sh
|
||||||
|
|
||||||
|
prefix = @prefix@
|
||||||
|
exec_prefix = $(prefix)
|
||||||
|
libdir = $(exec_prefix)/lib
|
||||||
|
|
||||||
|
PICFLAGS = @PICFLAGS@
|
||||||
|
|
||||||
|
LIBNAME = libbroken
|
||||||
|
LIBEXT = @LIBEXT@
|
||||||
|
SHLIBEXT = @SHLIBEXT@
|
||||||
|
LIB = $(LIBNAME).$(LIBEXT)
|
||||||
|
|
||||||
|
|
||||||
|
OBJECTS = @LIBOBJS@
|
||||||
|
|
||||||
|
all: $(LIB)
|
||||||
|
|
||||||
|
Wall:
|
||||||
|
make CFLAGS="-g -Wall -Wmissing-prototypes -Wmissing-declarations -D__USE_FIXED_PROTOTYPES__"
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) -c $(CPPFLAGS) $(DEFS) -I../.. -I../../include -I$(srcdir) -I$(srcdir)/../../include $(CFLAGS) $(PICFLAGS) $<
|
||||||
|
|
||||||
|
install: all
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
|
||||||
|
TAGS: $(SOURCES)
|
||||||
|
etags $(SOURCES)
|
||||||
|
|
||||||
|
check:
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(LIB) *.o *.a
|
||||||
|
|
||||||
|
mostlyclean: clean
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -f Makefile *.tab.c *~
|
||||||
|
rm -rf CVS
|
||||||
|
|
||||||
|
realclean: distclean
|
||||||
|
rm -f TAGS
|
||||||
|
|
||||||
|
dist: $(DISTFILES)
|
||||||
|
for file in $(DISTFILES); do \
|
||||||
|
ln $$file ../`cat ../.fname`/lib \
|
||||||
|
|| cp -p $$file ../`cat ../.fname`/lib; \
|
||||||
|
done
|
||||||
|
|
||||||
|
$(LIBNAME).a: $(OBJECTS)
|
||||||
|
rm -f $@
|
||||||
|
$(AR) cr $@ $(OBJECTS)
|
||||||
|
-$(RANLIB) $@
|
||||||
|
|
||||||
|
$(LIBNAME).$(SHLIBEXT): $(OBJECTS)
|
||||||
|
rm -f $@
|
||||||
|
$(CC) $(CFLAGS) $(PICFLAGS) -shared -o $@ $(OBJECTS) -L../../util/et -lcom_err
|
||||||
|
|
||||||
|
$(OBJECTS): ../../config.h
|
16
lib/roken/err.c
Normal file
16
lib/roken/err.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "err.h"
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
void
|
||||||
|
err(int eval, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
verr(eval, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
21
lib/roken/err.h
Normal file
21
lib/roken/err.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef __ERR_H__
|
||||||
|
#define __ERR_H__
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
extern char *__progname;
|
||||||
|
|
||||||
|
void verr(int eval, const char *fmt, va_list ap);
|
||||||
|
void err(int eval, const char *fmt, ...);
|
||||||
|
void verrx(int eval, const char *fmt, va_list ap);
|
||||||
|
void errx(int eval, const char *fmt, ...);
|
||||||
|
void vwarn(const char *fmt, va_list ap);
|
||||||
|
void warn(const char *fmt, ...);
|
||||||
|
void vwarnx(const char *fmt, va_list ap);
|
||||||
|
void warnx(const char *fmt, ...);
|
||||||
|
|
||||||
|
#endif /* __ERR_H__ */
|
21
lib/roken/err.hin
Normal file
21
lib/roken/err.hin
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef __ERR_H__
|
||||||
|
#define __ERR_H__
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
extern char *__progname;
|
||||||
|
|
||||||
|
void verr(int eval, const char *fmt, va_list ap);
|
||||||
|
void err(int eval, const char *fmt, ...);
|
||||||
|
void verrx(int eval, const char *fmt, va_list ap);
|
||||||
|
void errx(int eval, const char *fmt, ...);
|
||||||
|
void vwarn(const char *fmt, va_list ap);
|
||||||
|
void warn(const char *fmt, ...);
|
||||||
|
void vwarnx(const char *fmt, va_list ap);
|
||||||
|
void warnx(const char *fmt, ...);
|
||||||
|
|
||||||
|
#endif /* __ERR_H__ */
|
16
lib/roken/errx.c
Normal file
16
lib/roken/errx.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "err.h"
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
void
|
||||||
|
errx(int eval, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
verrx(eval, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
50
lib/roken/getdtablesize.c
Normal file
50
lib/roken/getdtablesize.c
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_SYSCTL_H
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int getdtablesize(void)
|
||||||
|
{
|
||||||
|
int files = -1;
|
||||||
|
#if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
|
||||||
|
files = sysconf(_SC_OPEN_MAX);
|
||||||
|
|
||||||
|
#elif definded(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
|
||||||
|
struct rlimit res;
|
||||||
|
if(getrlimit(RLIMIT_NOFILE, &res) == 0)
|
||||||
|
files = res.rlim_cur;
|
||||||
|
|
||||||
|
#elif defined(HAVE_SYSCTL) && defined(CTL_KERN) && defined(KERN_MAXFILES)
|
||||||
|
int mib[2];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
mib[0] = CTL_KERN;
|
||||||
|
mib[1] = KERN_MAXFILES;
|
||||||
|
len = sizeof(files);
|
||||||
|
sysctl(&mib, 2, &files, sizeof(nfil), NULL, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OPEN_MAX
|
||||||
|
if(files < 0)
|
||||||
|
files = OPEN_MAX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NOFILE
|
||||||
|
if(files < 0)
|
||||||
|
files = NOFILE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return files;
|
||||||
|
}
|
149
lib/roken/getusershell.c
Normal file
149
lib/roken/getusershell.c
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/* $NetBSD: getusershell.c,v 1.5 1995/02/27 04:13:27 cgd Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1985, 1993
|
||||||
|
* The Regents of the University of California. 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. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
#ifndef HAVE_GETUSERSHELL
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <paths.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#ifndef __P
|
||||||
|
#define __P(X) X
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PATH_SHELLS
|
||||||
|
#define _PATH_SHELLS "/etc/shells"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Local shells should NOT be added here. They should be added in
|
||||||
|
* /etc/shells.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static char *okshells[] = { _PATH_BSHELL, _PATH_CSHELL, NULL };
|
||||||
|
static char **curshell, **shells, *strings;
|
||||||
|
static char **initshells __P((void));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get a list of shells from _PATH_SHELLS, if it exists.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
getusershell()
|
||||||
|
{
|
||||||
|
char *ret;
|
||||||
|
|
||||||
|
if (curshell == NULL)
|
||||||
|
curshell = initshells();
|
||||||
|
ret = *curshell;
|
||||||
|
if (ret != NULL)
|
||||||
|
curshell++;
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
endusershell()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (shells != NULL)
|
||||||
|
free(shells);
|
||||||
|
shells = NULL;
|
||||||
|
if (strings != NULL)
|
||||||
|
free(strings);
|
||||||
|
strings = NULL;
|
||||||
|
curshell = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setusershell()
|
||||||
|
{
|
||||||
|
|
||||||
|
curshell = initshells();
|
||||||
|
}
|
||||||
|
|
||||||
|
static char **
|
||||||
|
initshells()
|
||||||
|
{
|
||||||
|
register char **sp, *cp;
|
||||||
|
register FILE *fp;
|
||||||
|
struct stat statb;
|
||||||
|
|
||||||
|
if (shells != NULL)
|
||||||
|
free(shells);
|
||||||
|
shells = NULL;
|
||||||
|
if (strings != NULL)
|
||||||
|
free(strings);
|
||||||
|
strings = NULL;
|
||||||
|
if ((fp = fopen(_PATH_SHELLS, "r")) == NULL)
|
||||||
|
return (okshells);
|
||||||
|
if (fstat(fileno(fp), &statb) == -1) {
|
||||||
|
(void)fclose(fp);
|
||||||
|
return (okshells);
|
||||||
|
}
|
||||||
|
if ((strings = malloc((u_int)statb.st_size)) == NULL) {
|
||||||
|
(void)fclose(fp);
|
||||||
|
return (okshells);
|
||||||
|
}
|
||||||
|
shells = calloc((unsigned)statb.st_size / 3, sizeof (char *));
|
||||||
|
if (shells == NULL) {
|
||||||
|
(void)fclose(fp);
|
||||||
|
free(strings);
|
||||||
|
strings = NULL;
|
||||||
|
return (okshells);
|
||||||
|
}
|
||||||
|
sp = shells;
|
||||||
|
cp = strings;
|
||||||
|
while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
|
||||||
|
while (*cp != '#' && *cp != '/' && *cp != '\0')
|
||||||
|
cp++;
|
||||||
|
if (*cp == '#' || *cp == '\0')
|
||||||
|
continue;
|
||||||
|
*sp++ = cp;
|
||||||
|
while (!isspace(*cp) && *cp != '#' && *cp != '\0')
|
||||||
|
cp++;
|
||||||
|
*cp++ = '\0';
|
||||||
|
}
|
||||||
|
*sp = NULL;
|
||||||
|
(void)fclose(fp);
|
||||||
|
return (shells);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_GETUSERSHELL */
|
26
lib/roken/hstrerror.c
Normal file
26
lib/roken/hstrerror.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_HSTRERROR
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
|
static char *msg[] = {
|
||||||
|
"No error",
|
||||||
|
"Authoritative Answer Host not found",
|
||||||
|
"Non-Authoritive Host not found, or SERVERFAIL",
|
||||||
|
"Non recoverable errors, FORMERR, REFUSED, NOTIMP",
|
||||||
|
"Valid name, no data record of requested type"
|
||||||
|
};
|
||||||
|
|
||||||
|
char *hstrerror(int herr)
|
||||||
|
{
|
||||||
|
if(herr >= 0 && herr <= 4)
|
||||||
|
return msg[herr];
|
||||||
|
return "Error number out of range (hstrerror)";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
38
lib/roken/inet_aton.c
Normal file
38
lib/roken/inet_aton.c
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
|
||||||
|
/* Minimal implementation of inet_aton. Doesn't handle hex numbers. */
|
||||||
|
|
||||||
|
int inet_aton(char *cp, struct in_addr *adr)
|
||||||
|
{
|
||||||
|
unsigned int a, b, c, d;
|
||||||
|
|
||||||
|
int num;
|
||||||
|
|
||||||
|
num = sscanf(cp, "%u.%u.%u.%u", &a, &b, &c, &d);
|
||||||
|
|
||||||
|
if(num < 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if(num == 2){
|
||||||
|
c = b & 0xffff;
|
||||||
|
b = b >> 16;
|
||||||
|
}
|
||||||
|
if(num < 4){
|
||||||
|
d = c & 0xff;
|
||||||
|
c = c >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(a > 255 || b > 255 || c > 255 || d > 255)
|
||||||
|
return 0;
|
||||||
|
adr->s_addr = htonl((a << 24) | (b << 16) | (c << 8) | d);
|
||||||
|
return 1;
|
||||||
|
}
|
33
lib/roken/memmove.c
Normal file
33
lib/roken/memmove.c
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* memmove for systems that doesn't have it
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
void* memmove(void *s1, const void *s2, size_t n)
|
||||||
|
{
|
||||||
|
char *s=(char*)s2, *d=(char*)s1;
|
||||||
|
|
||||||
|
if(d > s){
|
||||||
|
s+=n-1;
|
||||||
|
d+=n-1;
|
||||||
|
while(n){
|
||||||
|
*d--=*s--;
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
}else if(d < s)
|
||||||
|
while(n){
|
||||||
|
*d++=*s++;
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
return s1;
|
||||||
|
}
|
44
lib/roken/putenv.c
Normal file
44
lib/roken/putenv.c
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
extern char **environ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* putenv --
|
||||||
|
* String points to a string of the form name=value.
|
||||||
|
*
|
||||||
|
* Makes the value of the environment variable name equal to
|
||||||
|
* value by altering an existing variable or creating a new one.
|
||||||
|
*/
|
||||||
|
int putenv(const char *string)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = string - strchr(string, '=') + 1;
|
||||||
|
|
||||||
|
if(environ == NULL){
|
||||||
|
environ = malloc(sizeof(char*));
|
||||||
|
if(environ == NULL)
|
||||||
|
return 1;
|
||||||
|
environ[0] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = 0; environ[i]; i++)
|
||||||
|
if(strncmp(string, environ[i], len)){
|
||||||
|
environ[len] = string;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
environ = realloc(environ, sizeof(char*) * (i + 1));
|
||||||
|
if(environ == NULL)
|
||||||
|
return 1;
|
||||||
|
environ[i] = string;
|
||||||
|
environ[i+1] = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
31
lib/roken/setenv.c
Normal file
31
lib/roken/setenv.c
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the easy way out, use putenv to implement setenv. We might
|
||||||
|
* leak some memory but that is ok since we are usally about to exec
|
||||||
|
* anyway.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
setenv(const char *var, const char *val, int rewrite)
|
||||||
|
{
|
||||||
|
char *t;
|
||||||
|
|
||||||
|
if (!rewrite && getenv(var) != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if ((t = malloc(strlen(var) + strlen(val) + 2)) == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
strcpy(t, var);
|
||||||
|
strcat(t, "=");
|
||||||
|
strcat(t, val);
|
||||||
|
if (putenv(t) == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
18
lib/roken/snprintf.c
Normal file
18
lib/roken/snprintf.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
int snprintf(char *s, int n, char *fmt, ...)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
ret = vsprintf(s, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
return ret;
|
||||||
|
}
|
21
lib/roken/strerror.c
Normal file
21
lib/roken/strerror.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
static char emsg[1024];
|
||||||
|
|
||||||
|
char*
|
||||||
|
strerror(int eno)
|
||||||
|
{
|
||||||
|
if(eno < 0 || eno >= sys_nerr)
|
||||||
|
sprintf(emsg, "Error %d occurred.", eno);
|
||||||
|
else
|
||||||
|
strcpy(emsg, sys_errlist[eno]);
|
||||||
|
|
||||||
|
return emsg;
|
||||||
|
}
|
22
lib/roken/verr.c
Normal file
22
lib/roken/verr.c
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "err.h"
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
void
|
||||||
|
verr(int eval, const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
int sverrno;
|
||||||
|
|
||||||
|
sverrno = errno;
|
||||||
|
fprintf(stderr, "%s: ", __progname);
|
||||||
|
if (fmt != NULL) {
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, ": ");
|
||||||
|
}
|
||||||
|
fprintf(stderr, "%s\n", strerror(sverrno));
|
||||||
|
exit(eval);
|
||||||
|
}
|
17
lib/roken/verrx.c
Normal file
17
lib/roken/verrx.c
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "err.h"
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
void
|
||||||
|
verrx(int eval, const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: ", __progname);
|
||||||
|
if (fmt != NULL)
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
exit(eval);
|
||||||
|
}
|
21
lib/roken/vwarn.c
Normal file
21
lib/roken/vwarn.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "err.h"
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
void
|
||||||
|
vwarn(const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
int sverrno;
|
||||||
|
|
||||||
|
sverrno = errno;
|
||||||
|
fprintf(stderr, "%s: ", __progname);
|
||||||
|
if (fmt != NULL) {
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, ": ");
|
||||||
|
}
|
||||||
|
fprintf(stderr, "%s\n", strerror(sverrno));
|
||||||
|
}
|
16
lib/roken/vwarnx.c
Normal file
16
lib/roken/vwarnx.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "err.h"
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
void
|
||||||
|
vwarnx(const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: ", __progname);
|
||||||
|
if (fmt != NULL)
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
16
lib/roken/warn.c
Normal file
16
lib/roken/warn.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "err.h"
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
void
|
||||||
|
warn(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vwarn(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
16
lib/roken/warnx.c
Normal file
16
lib/roken/warnx.c
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "err.h"
|
||||||
|
|
||||||
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
void
|
||||||
|
warnx(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vwarnx(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
Reference in New Issue
Block a user