summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorsteve <steve@FreeBSD.org>1998-02-28 03:57:05 +0000
committersteve <steve@FreeBSD.org>1998-02-28 03:57:05 +0000
commitf68a7e46445f73b94f84b31d82e15c91d3485571 (patch)
tree4d0379ac41c09ae4c74e61750f75a591961302ad /lib/libc/gen
parente33f0286b1a60286ca6a2e5253b4cf18ae529b12 (diff)
downloadFreeBSD-src-f68a7e46445f73b94f84b31d82e15c91d3485571.zip
FreeBSD-src-f68a7e46445f73b94f84b31d82e15c91d3485571.tar.gz
Remove the config_* routines with permission from Poul-Henning Kamp,
the original author. PR: 5834 Discussed with: phk, jkh
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/Makefile.inc8
-rw-r--r--lib/libc/gen/config.c187
-rw-r--r--lib/libc/gen/config_open.373
3 files changed, 3 insertions, 265 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 0b7abae..3d64201 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -1,11 +1,11 @@
# @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
-# $Id: Makefile.inc,v 1.42 1998/02/09 06:05:22 jdp Exp $
+# $Id: Makefile.inc,v 1.43 1998/02/12 23:52:23 bde Exp $
# machine-independent gen sources
.PATH: ${.CURDIR}/../libc/${MACHINE}/gen ${.CURDIR}/../libc/gen
SRCS+= _rand48.c alarm.c arc4random.c assert.c \
- clock.c closedir.c config.c confstr.c \
+ clock.c closedir.c confstr.c \
crypt.c ctermid.c daemon.c devname.c disklabel.c \
dlfcn.c drand48.c erand48.c err.c errlst.c \
exec.c fnmatch.c fstab.c fts.c getbootfile.c getbsize.c \
@@ -43,7 +43,7 @@ errlst.o errlst.po:
.endif
.if ${LIB} == "c"
-MAN3+= alarm.3 arc4random.3 clock.3 config_open.3 \
+MAN3+= alarm.3 arc4random.3 clock.3 \
confstr.3 crypt.3 ctermid.3 daemon.3 \
devname.3 directory.3 dladdr.3 dlopen.3 \
err.3 exec.3 fnmatch.3 frexp.3 fts.3 \
@@ -63,8 +63,6 @@ MAN3+= alarm.3 arc4random.3 clock.3 config_open.3 \
valloc.3 vis.3
MLINKS+=arc4random.3 arc4random_addrandom.3 arc4random.3 arc4random_stir.3
-MLINKS+=config_open.3 config_close.3 config_open.3 config_next.3 \
- config_open.3 config_skip.3
MLINKS+=crypt.3 des_cipher.3 crypt.3 des_setkey.3 crypt.3 encrypt.3 \
crypt.3 setkey.3
MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \
diff --git a/lib/libc/gen/config.c b/lib/libc/gen/config.c
deleted file mode 100644
index 2d1ed44..0000000
--- a/lib/libc/gen/config.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * $Id$
- *
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * This file contains four procedures used to read config-files.
- *
- * char * config_open(const char *filename,int contlines)
- * Will open the named file, read it into a private malloc'ed area,
- * and close the file again.
- * All lines where the first !isspace() char is '#' are deleted.
- * If contlines are non-zero lines where the first char is isspace()
- * will be joined to the preceeding line.
- * In case of trouble the name of the offending system call will be
- * returned. On success NULL is returned.
- *
- * void config_close()
- * This will free the internal malloc'ed area.
- *
- * char * config_next()
- * This will return a pointer to the next entry in the area. NULL is
- * returned at "end of file". The return value is '\0' terminated, and
- * can be modified, but the contents must be copied somewhere else for
- * permanent use.
- *
- * char * config_skip(char **p)
- * This will pick out the next word from the string. The return-value
- * points to the word found, and *p is advanced past the word. NULL is
- * returned at "end of string".
- *
- * Many programs have a n*100 bytes config-file and N*1000 bytes of source
- * to read it. Doing pointer-aerobics on files that small is a waste of
- * time, and bashing around with getchar/ungetc isn't much better. These
- * routines implement a simple algorithm and syntax.
- *
- * config_skip consider a contiguous string of !isspace() chars a word.
- *
- * 13nov1994 Poul-Henning Kamp phk@login.dknet.dk
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <string.h>
-
-static char *file_buf;
-static char *ptr;
-
-char *
-config_open(const char *filename, int contlines)
-{
- int fd;
- struct stat st;
- char *p, *q;
-
- if ((fd = open(filename, O_RDONLY)) < 0)
- return "open";
- if (fstat(fd, &st) < 0) {
- close(fd);
- return "fstat";
- }
- if (file_buf)
- free(file_buf);
- file_buf = malloc(st.st_size + 2);
- if (!file_buf) {
- close(fd);
- return "malloc";
- }
- if (st.st_size != read(fd, file_buf, st.st_size)) {
- free(file_buf);
- file_buf = (char *) 0;
- close(fd);
- return "read";
- }
- close(fd);
- file_buf[st.st_size] = '\n';
- file_buf[st.st_size + 1] = '\0';
-
- /*
- * /^[ \t]*#[^\n]*$/d
- *
- * Delete all lines where the first !isspace() char is '#'
- */
-
- ptr = file_buf;
- for (p = ptr; *p;) {
- for (q = p; *q != '\n' && isspace(*q); q++)
- continue;
- if (*q == '#') {
- p = strchr(p, '\n');
- if (p)
- p++;
- } else {
- q = strchr(p, '\n');
- q++;
- memcpy(ptr, p, q - p);
- ptr += q - p;
- p = q;
- }
- }
- *ptr = '\0';
- ptr = file_buf;
-
- if (!contlines)
- return 0;
-
- /* Join all lines starting with a isspace() char to the preceeding
- * line */
-
- for (p = ptr; *p;) {
- q = strchr(p, '\n');
- if (isspace(*(q + 1)))
- *q = ' ';
- p = q + 1;
- }
-
- return 0;
-}
-
-void
-config_close(void)
-{
- if (file_buf)
- free(file_buf);
- ptr = file_buf = 0;
-}
-
-/*
- * Get next entry. config_open did all the weird stuff, so just return
- * the next line.
- */
-
-char *
-config_next(void)
-{
- char *p;
-
- /* We might be done already ! */
- if (!ptr || !*ptr)
- return 0;
-
- while (isspace(*ptr))
- ptr++;
- p = ptr;
- ptr = strchr(p, '\n');
- if (ptr) {
- *ptr = '\0';
- ptr++;
- }
- return p;
-}
-
-/*
- * Return next word
- */
-
-char *
-config_skip(char **p)
-{
- char *q, *r;
-
- if (!*p || !**p)
- return 0;
- for (q = *p; isspace(*q); q++);
- if (!*q)
- return 0;
- for (r = q; *r && !isspace(*r); r++);
- if (*r)
- *r++ = '\0';
- *p = r;
- return q;
-}
diff --git a/lib/libc/gen/config_open.3 b/lib/libc/gen/config_open.3
deleted file mode 100644
index a2ef707..0000000
--- a/lib/libc/gen/config_open.3
+++ /dev/null
@@ -1,73 +0,0 @@
-.\" ----------------------------------------------------------------------------
-.\" "THE BEER-WARE LICENSE" (Revision 42):
-.\" <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
-.\" can do whatever you want with this stuff. If we meet some day, and you think
-.\" this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
-.\" ----------------------------------------------------------------------------
-.\"
-.\" $Id$
-.\"
-.Dd November 13, 1994
-.Dt config_open 3
-.Os FreeBSD
-.Sh NAME
-.Nm config_open ,
-.Nm config_close ,
-.Nm config_next ,
-.Nm config_skip
-.Nd read config files
-.Sh SYNOPSIS
-.Ft char *
-.Fn config_open "const char *filename" "int contlines"
-.Ft void
-.Fn config_close
-.Ft char *
-.Fn config_next
-.Ft char *
-.Fn config_skip "char **string"
-.Sh DESCRIPTION
-These functions are used to read config files with the following syntax:
-.Bl -bullet -compact
-.It
-All lines where the first
-.Sq !isspace()
-is '#' are comments which are discarded.
-.It
-If continuation-lines are enabled, any line starting with a
-.Sq isspace()
-character is joined to the preceding line and blank lines are discarded.
-.It
-An entry starts at the first
-.Sq !isspace()
-character and ends at the first
-.Sq Li \en
-.Li .
-.El
-.Pp
-.Fn config_open
-will open the specified
-.Fa filename
-and read it into a private malloced area, and close the file again. If
-.Fa contlines
-is non-zero, continuation lines will be allowed.
-In case of trouble, the name of the system-call causing the trouble will
-be returned. If successful,
-.Fn config_open
-returns NULL.
-.Pp
-.Fn config_close
-will free the malloced area.
-.Pp
-.Fn config_next
-returns the next entry in the area. NULL is returned to indicate End-of-file.
-The returned string is null-terminated.
-.Pp
-.Fn config_skip
-returns the next word from the string
-.Fa *string
-.Li .
-.Fa *string
-will be advanced to point to the next word.
-NULL is returned to indicate the end of the string.
-.Sh AUTHOR
-Poul-Henning Kamp <phk@login.dknet.dk>
OpenPOWER on IntegriCloud