diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-11-17 15:22:56 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-11-17 15:22:56 +0000 |
commit | a5ed0b5f4e2e8f1cf089e9d0cf0f15af143ad70e (patch) | |
tree | 1f2b37da05a1d9b7be78912dc2a95bdb85457fe9 | |
parent | e165d8783c41a673b24b579917dae6c5f46fedae (diff) |
off to the bitbucket in the sky
-rw-r--r-- | usr.sbin/lpr/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/lpr/lptest/Makefile | 7 | ||||
-rw-r--r-- | usr.sbin/lpr/lptest/lptest.1 | 75 | ||||
-rw-r--r-- | usr.sbin/lpr/lptest/lptest.c | 70 | ||||
-rw-r--r-- | usr.sbin/lpr/pac/Makefile | 11 | ||||
-rw-r--r-- | usr.sbin/lpr/pac/pac.8 | 130 | ||||
-rw-r--r-- | usr.sbin/lpr/pac/pac.c | 463 | ||||
-rw-r--r-- | usr.sbin/ypserv/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/ypserv/yptest/Makefile | 6 | ||||
-rw-r--r-- | usr.sbin/ypserv/yptest/yptest.8 | 58 | ||||
-rw-r--r-- | usr.sbin/ypserv/yptest/yptest.c | 124 |
11 files changed, 4 insertions, 948 deletions
diff --git a/usr.sbin/lpr/Makefile b/usr.sbin/lpr/Makefile index 5072e4afda2..3079ef51c0f 100644 --- a/usr.sbin/lpr/Makefile +++ b/usr.sbin/lpr/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.5 2010/01/04 17:50:39 deraadt Exp $ +# $OpenBSD: Makefile,v 1.6 2015/11/17 15:22:55 deraadt Exp $ -SUBDIR= lpc lpd lpq lpr lprm lptest pac filters +SUBDIR= lpc lpd lpq lpr lprm filters CFLAGS+= -Wall .include <bsd.subdir.mk> diff --git a/usr.sbin/lpr/lptest/Makefile b/usr.sbin/lpr/lptest/Makefile deleted file mode 100644 index ca3431ddbb5..00000000000 --- a/usr.sbin/lpr/lptest/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# from: @(#)Makefile 8.1 (Berkeley) 6/6/93 -# $OpenBSD: Makefile,v 1.2 1997/01/17 16:12:48 millert Exp $ - -PROG= lptest - -.include "../../Makefile.inc" -.include <bsd.prog.mk> diff --git a/usr.sbin/lpr/lptest/lptest.1 b/usr.sbin/lpr/lptest/lptest.1 deleted file mode 100644 index 181e3a31477..00000000000 --- a/usr.sbin/lpr/lptest/lptest.1 +++ /dev/null @@ -1,75 +0,0 @@ -.\" $OpenBSD: lptest.1,v 1.7 2007/05/31 19:20:25 jmc Exp $ -.\" $NetBSD: lptest.1,v 1.7 1999/03/22 18:44:00 garbled Exp $ -.\" -.\" Copyright (c) 1985, 1990, 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. 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. -.\" -.\" @(#)lptest.1 8.2 (Berkeley) 12/30/93 -.\" -.Dd $Mdocdate: May 31 2007 $ -.Dt LPTEST 1 -.Os -.Sh NAME -.Nm lptest -.Nd generate lineprinter ripple pattern -.Sh SYNOPSIS -.Nm lptest -.Op Ar length -.Op Ar count -.Sh DESCRIPTION -.Nm lptest -writes the traditional -.Dq ripple test -pattern on standard output. -In 96 lines, -this pattern will print all 96 printable -.Tn ASCII -characters -in each position. -While originally created to test printers, it is quite -useful for testing terminals, -driving terminal ports for debugging purposes, -or any other task where a quick supply of random data is needed. -.Pp -The -.Ar length -argument specifies the output line length if the default -length of 79 is inappropriate. -.Pp -The -.Ar count -argument specifies the number of output lines to be generated if -the default count of 200 is inappropriate. -Note that if -.Ar count -is to be specified, -.Ar length -must also be specified. -.Sh HISTORY -.Nm -appeared in -.Bx 4.3 . diff --git a/usr.sbin/lpr/lptest/lptest.c b/usr.sbin/lpr/lptest/lptest.c deleted file mode 100644 index b91214d31dc..00000000000 --- a/usr.sbin/lpr/lptest/lptest.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: lptest.c,v 1.9 2015/11/04 21:27:03 tedu Exp $ */ -/* $NetBSD: lptest.c,v 1.6 1996/12/09 09:57:50 mrg Exp $ */ - -/* - * Copyright (c) 1983, 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. 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. - */ - -#include <stdlib.h> -#include <stdio.h> - -/* - * lptest -- line printer test program (and other devices). - */ -int -main(int argc, char **argv) -{ - int len, count; - int i, j, fc, nc; - char outbuf[BUFSIZ]; - - setvbuf(stdout, outbuf, _IOFBF, sizeof outbuf); - if (argc >= 2) - len = atoi(argv[1]); - else - len = 79; - if (argc >= 3) - count = atoi(argv[2]); - else - count = 200; - fc = ' '; - for (i = 0; i < count; i++) { - if (++fc == 0177) - fc = ' '; - nc = fc; - for (j = 0; j < len; j++) { - putchar(nc); - if (++nc == 0177) - nc = ' '; - } - putchar('\n'); - } - (void)fflush(stdout); - exit(0); -} diff --git a/usr.sbin/lpr/pac/Makefile b/usr.sbin/lpr/pac/Makefile deleted file mode 100644 index 41fd7878bb1..00000000000 --- a/usr.sbin/lpr/pac/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# from: @(#)Makefile 8.1 (Berkeley) 6/6/93 -# $OpenBSD: Makefile,v 1.3 2002/05/20 23:13:50 millert Exp $ - -PROG= pac -CFLAGS+=-I${.CURDIR}/../common_source -MAN= pac.8 -SRCS= pac.c common.c common_vars.c -.PATH: ${.CURDIR}/../common_source - -.include "../../Makefile.inc" -.include <bsd.prog.mk> diff --git a/usr.sbin/lpr/pac/pac.8 b/usr.sbin/lpr/pac/pac.8 deleted file mode 100644 index 3856e74e26b..00000000000 --- a/usr.sbin/lpr/pac/pac.8 +++ /dev/null @@ -1,130 +0,0 @@ -.\" $OpenBSD: pac.8,v 1.9 2007/05/31 19:20:25 jmc Exp $ -.\" $NetBSD: pac.8,v 1.9 2002/01/19 03:24:14 wiz Exp $ -.\" -.\" Copyright (c) 1983, 1991, 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. 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. -.\" -.\" @(#)pac.8 8.1 (Berkeley) 6/6/93 -.\" -.Dd $Mdocdate: May 31 2007 $ -.Dt PAC 8 -.Os -.Sh NAME -.Nm pac -.Nd printer/plotter accounting information -.Sh SYNOPSIS -.Nm pac -.Op Fl cmrs -.Bk -words -.Op Fl P Ns Ar printer -.Ek -.Bk -words -.Op Fl p Ns Ar price -.Ek -.Op Ar user ... -.Sh DESCRIPTION -.Nm pac -reads the printer/plotter accounting files, accumulating the number -of pages (the usual case) or feet (for raster devices) -of paper consumed by each named -.Ar user , -and prints out how much each user consumed in pages or feet and dollars. -.Pp -When no -.Ar user -arguments are given, statistics are printed for every user who has used any -paper. -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl P Ns Ar printer -Accounting is done for the named printer. -Normally, accounting is done for the default printer (site dependent) or -the value of the environment variable -.Ev PRINTER -is used. -.It Fl c -Causes the output to be sorted by cost; usually the -output is sorted alphabetically by name. -.It Fl m -Causes the host name to be ignored in the accounting file. -This allows for a user on multiple machines to have all of his printing -charges grouped together. -.It Fl p Ns Ar price -The value -.Ar price -is used for the cost in dollars instead of the default value of 0.02 -or the price specified in -.Pa /etc/printcap . -.It Fl r -Reverse the sorting order. -.It Fl s -Accounting information is summarized on the -summary accounting file; this summarization is necessary since on a -busy system, the accounting file can grow by several lines per day. -.El -.Sh OUTPUT FORMAT -.Nm -formats the output into a simple table, using four columns: -.Bl -enum -.It -The host name followed by the user's login name (column "Login"). -If the -.Fl m -option was specified, the host name will be omitted. -.It -The number of pages or feet printed (column "pages/feet"). -.It -The number of copies made (column "runs"). -.It -The total price for the user (column "price"). -.El -.Pp -If no -.Ar user -argument was specified, -.Nm -will print a summary line with print totals. -.Sh FILES -.Bl -tag -width /var/account/?_sum -compact -.It Pa /var/account/?acct -raw accounting files -.It Pa /var/account/?_sum -summary accounting files -.It Pa /etc/printcap -printer capability database -.El -.Sh SEE ALSO -.Xr printcap 5 -.Sh HISTORY -The -.Nm -command appeared in -.Bx 4.0 . -.Sh BUGS -The relationship between the computed price and reality is -as yet unknown. diff --git a/usr.sbin/lpr/pac/pac.c b/usr.sbin/lpr/pac/pac.c deleted file mode 100644 index a5d811bcd4f..00000000000 --- a/usr.sbin/lpr/pac/pac.c +++ /dev/null @@ -1,463 +0,0 @@ -/* $OpenBSD: pac.c,v 1.25 2015/08/20 22:46:32 deraadt Exp $ */ -/* $NetBSD: pac.c,v 1.14 2000/04/27 13:40:18 msaitoh Exp $ */ - -/* - * Copyright (c) 1983, 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. 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. - */ - -/* - * Do Printer accounting summary. - * Currently, usage is - * pac [-Pprinter] [-pprice] [-s] [-r] [-c] [-m] [user ...] - * to print the usage information for the named people. - */ - -#include <ctype.h> -#include <signal.h> -#include <dirent.h> -#include <err.h> -#include <errno.h> -#include <stdlib.h> -#include <unistd.h> -#include <limits.h> -#include <stdio.h> -#include <string.h> - -#include "lp.h" -#include "lp.local.h" - -static char *acctfile; /* accounting file (input data) */ -static int allflag = 1; /* Get stats on everybody */ -static int errs; -static int hcount; /* Count of hash entries */ -static int mflag = 0; /* disregard machine names */ -static int pflag = 0; /* 1 if -p on cmd line */ -static float price = 0.02; /* cost per page (or what ever) */ -static long price100; /* per-page cost in 100th of a cent */ -static int reverse; /* Reverse sort order */ -static int sort; /* Sort by cost */ -static char *sumfile; /* summary file */ -static int summarize; /* Compress accounting file */ - -volatile sig_atomic_t gotintr; - -/* - * Grossness follows: - * Names to be accumulated are hashed into the following - * table. - */ - -#define HSHSIZE 97 /* Number of hash buckets */ - -struct hent { - struct hent *h_link; /* Forward hash link */ - char *h_name; /* Name of this user */ - float h_feetpages; /* Feet or pages of paper */ - int h_count; /* Number of runs */ -}; - -static struct hent *hashtab[HSHSIZE]; /* Hash table proper */ - -static void account(FILE *); -static int chkprinter(const char *); -static void dumpit(void); -static int hash(const char *); -static struct hent *enter(const char *); -static struct hent *lookup(const char *); -static int qucmp(const void *, const void *); -static void rewrite(void); -__dead void usage(void); - -int -main(int argc, char **argv) -{ - FILE *acct; - int ch; - - /* these aren't actually used in pac(1) */ - effective_uid = geteuid(); - real_uid = getuid(); - effective_gid = getegid(); - real_gid = getgid(); - - while ((ch = getopt(argc, argv, "P:p:scmr")) != -1) { - switch (ch) { - case 'P': - /* - * Printer name. - */ - printer = optarg; - continue; - - case 'p': - /* - * get the price. - */ - price = atof(optarg); - pflag = 1; - continue; - - case 's': - /* - * Summarize and compress accounting file. - */ - summarize = 1; - continue; - - case 'c': - /* - * Sort by cost. - */ - sort = 1; - continue; - - case 'm': - /* - * disregard machine names for each user - */ - mflag = 1; - continue; - - case 'r': - /* - * Reverse sorting order. - */ - reverse = 1; - continue; - - default: - usage(); - /* NOTREACHED */ - } - } - argc -= optind; - argv += optind; - - /* - * If there are any arguments left, they're names of users - * we want to print info for. In that case, put them in the hash - * table and unset allflag. - */ - for( ; argc > 0; argc--, argv++) { - (void)enter(*argv); - allflag = 0; - } - - if (printer == NULL && (printer = getenv("PRINTER")) == NULL) - printer = DEFLP; - if (!chkprinter(printer)) - errx(2, "unknown printer: %s", printer); - - if ((acct = fopen(acctfile, "r")) == NULL) - err(1, "%s", acctfile); - account(acct); - fclose(acct); - if ((acct = fopen(sumfile, "r")) != NULL) { - account(acct); - fclose(acct); - } - if (summarize) - rewrite(); - else - dumpit(); - exit(errs); -} - -/* - * Read the entire accounting file, accumulating statistics - * for the users that we have in the hash table. If allflag - * is set, then just gather the facts on everyone. - * Note that we must accommodate both the active and summary file - * formats here. - * The Format of the accounting file is: - * feet_per_page [runs_count] [hostname:]username - * Some software relies on whitespace between runs_count and hostname:username - * being optional (such as Ghostscript's unix-lpr.sh). - * - * Host names are ignored if the -m flag is present. - */ -static void -account(FILE *acct) -{ - char linebuf[BUFSIZ]; - double t; - long l; - char *cp, *cp2, *ep; - struct hent *hp; - int ic; - - while (fgets(linebuf, sizeof(linebuf), acct) != NULL) { - cp = linebuf; - while (isspace((unsigned char)*cp)) - cp++; - - /* get t, feet_per_page */ - errno = 0; - t = strtod(cp, &ep); - if (!isspace((unsigned char)*ep) || errno == ERANGE) - continue; - - /* get ic, runs_count (optional) */ - for (cp = ep + 1; isspace((unsigned char)*cp); ) - cp++; - l = strtol(cp, &ep, 10); - if (cp == ep) - l = 0; /* runs_count not specified */ - else if (l < 0 || l >= INT_MAX) - continue; - ic = (int)l; - - /* get [hostname:]username */ - for (cp = ep; isspace((unsigned char)*cp); cp++) - ; - for (cp2 = cp; *cp2 && !isspace((unsigned char)*cp2); cp2++) - ; - *cp2 = '\0'; - /* if -m was specified, don't use the hostname part */ - if (mflag && (cp2 = strchr(cp, ':')) != NULL) - cp = cp2 + 1; - - hp = lookup(cp); - if (hp == NULL) { - if (!allflag) - continue; - hp = enter(cp); - } - hp->h_feetpages += t; - if (ic) - hp->h_count += ic; - else - hp->h_count++; - } -} - -/* - * Sort the hashed entries by name or footage - * and print it all out. - */ -static void -dumpit(void) -{ - struct hent **base; - struct hent *hp, **ap; - int hno, c, runs; - float feet; - - hp = hashtab[0]; - hno = 1; - base = calloc(hcount, sizeof(hp)); - if (base == NULL) - err(1, NULL); - for (ap = base, c = hcount; c--; ap++) { - while (hp == NULL) - hp = hashtab[hno++]; - *ap = hp; - hp = hp->h_link; - } - qsort(base, hcount, sizeof hp, qucmp); - printf(" Login pages/feet runs price\n"); - feet = 0.0; - runs = 0; - for (ap = base, c = hcount; c--; ap++) { - hp = *ap; - runs += hp->h_count; - feet += hp->h_feetpages; - printf("%-24s %7.2f %4d $%6.2f\n", hp->h_name, - hp->h_feetpages, hp->h_count, hp->h_feetpages * price); - } - if (allflag) { - printf("\n"); - printf("%-24s %7.2f %4d $%6.2f\n", "total", feet, - runs, feet * price); - } - - free(base); -} - -/* - * Rewrite the summary file with the summary information we have accumulated. - */ -static void -rewrite(void) -{ - struct hent *hp; - int i; - FILE *acctf; - - if ((acctf = fopen(sumfile, "w")) == NULL) { - warn("%s", sumfile); - errs++; - return; - } - for (i = 0; i < HSHSIZE; i++) { - hp = hashtab[i]; - while (hp != NULL) { - fprintf(acctf, "%7.2f\t%s\t%d\n", hp->h_feetpages, - hp->h_name, hp->h_count); - hp = hp->h_link; - } - } - fflush(acctf); - if (ferror(acctf)) { - warn("%s", sumfile); - errs++; - } - fclose(acctf); - if ((acctf = fopen(acctfile, "w")) == NULL) - warn("%s", acctfile); - else - fclose(acctf); -} - -/* - * Hashing routines. - */ - -/* - * Enter the name into the hash table and return the pointer allocated. - */ - -static struct hent * -enter(const char *name) -{ - struct hent *hp; - int h; - - if ((hp = lookup(name)) != NULL) - return(hp); - h = hash(name); - hcount++; - hp = malloc(sizeof *hp); - if (hp == NULL) - err(1, NULL); - hp->h_name = strdup(name); - if (hp->h_name == NULL) - err(1, NULL); - hp->h_feetpages = 0.0; - hp->h_count = 0; - hp->h_link = hashtab[h]; - hashtab[h] = hp; - return(hp); -} - -/* - * Lookup a name in the hash table and return a pointer - * to it. - */ - -static struct hent * -lookup(const char *name) -{ - int h; - struct hent *hp; - - h = hash(name); - for (hp = hashtab[h]; hp != NULL; hp = hp->h_link) - if (strcmp(hp->h_name, name) == 0) - return(hp); - return(NULL); -} - -/* - * Hash the passed name and return the index in - * the hash table to begin the search. - */ -static int -hash(const char *name) -{ - int h; - const char *cp; - - for (cp = name, h = 0; *cp; h = (h << 2) + *cp++) - ; - return((h & 0x7fffffff) % HSHSIZE); -} - -/* - * The qsort comparison routine. - * The comparison is ascii collating order - * or by feet of typesetter film, according to sort. - */ -static int -qucmp(const void *a, const void *b) -{ - struct hent *h1, *h2; - int r; - - h1 = *(struct hent **)a; - h2 = *(struct hent **)b; - if (sort) - r = h1->h_feetpages < h2->h_feetpages ? - -1 : h1->h_feetpages > h2->h_feetpages; - else - r = strcmp(h1->h_name, h2->h_name); - return(reverse ? -r : r); -} - -/* - * Perform lookup for printer name or abbreviation -- - */ -static int -chkprinter(const char *s) -{ - int stat; - int len; - - if ((stat = cgetent(&bp, printcapdb, s)) == -2) { - printf("pac: can't open printer description file\n"); - exit(3); - } else if (stat == -1) - return(0); - else if (stat == -3) - fatal("potential reference loop detected in printcap file"); - - if (cgetstr(bp, "af", &acctfile) == -1) { - printf("accounting not enabled for printer %s\n", printer); - exit(2); - } - if (!pflag && (cgetnum(bp, "pc", &price100) == 0)) - price = price100/10000.0; - len = strlen(acctfile) + 5; - sumfile = malloc(len); - if (sumfile == NULL) - err(1, "pac"); - strlcpy(sumfile, acctfile, len); - strlcat(sumfile, "_sum", len); - return(1); -} - -__dead void -usage(void) -{ - extern char *__progname; - - fprintf(stderr, "usage: %s [-cmrs] [-Pprinter] [-pprice] [user ...]\n", - __progname); - exit(1); -} diff --git a/usr.sbin/ypserv/Makefile b/usr.sbin/ypserv/Makefile index 2c99ca31d0c..43f4b44dccd 100644 --- a/usr.sbin/ypserv/Makefile +++ b/usr.sbin/ypserv/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.6 1997/07/26 12:12:26 maja Exp $ +# $OpenBSD: Makefile,v 1.7 2015/11/17 15:22:55 deraadt Exp $ SUBDIR= makedbm mkalias mknetid revnetgroup stdethers stdhosts \ - ypinit ypserv yptest yppush ypxfr + ypinit ypserv yppush ypxfr .include <bsd.subdir.mk> diff --git a/usr.sbin/ypserv/yptest/Makefile b/usr.sbin/ypserv/yptest/Makefile deleted file mode 100644 index f0d197a2b7f..00000000000 --- a/usr.sbin/ypserv/yptest/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# $OpenBSD: Makefile,v 1.2 1996/05/30 09:53:31 deraadt Exp $ - -PROG= yptest -MAN= yptest.8 - -.include <bsd.prog.mk> diff --git a/usr.sbin/ypserv/yptest/yptest.8 b/usr.sbin/ypserv/yptest/yptest.8 deleted file mode 100644 index d5978b36b25..00000000000 --- a/usr.sbin/ypserv/yptest/yptest.8 +++ /dev/null @@ -1,58 +0,0 @@ -.\" $OpenBSD: yptest.8,v 1.14 2013/07/16 11:13:34 schwarze Exp $ -.\" -.\" Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> -.\" 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. -.\" -.Dd $Mdocdate: July 16 2013 $ -.Dt YPTEST 8 -.Os -.Sh NAME -.Nm yptest -.Nd calls different YP routines -.Sh SYNOPSIS -.Nm yptest -.\".Op Fl u Ar file -.\".Nm /usr/sbin/makedbm -.\".Op Fl bls -.\".Op Fl i Ar yp_input_file -.\".Op Fl o Ar yp_output_file -.\".Op Fl d Ar yp_domain_name -.\".Op Fl m Ar yp_master_name -.\".Ar infile -.\".Ar outfile -.Sh DESCRIPTION -.Nm -checks various YP functions to see if the YP server works as expected. -.\".Pp -.\"The options are as follows: -.\".Bl -tag -width Ds -.\".It Fl d Ar yp_domain_name -.\"Include an entry the in the map with the key YP_DOMAIN_NAME and the argument -.\"as value. -.\".El -.Sh SEE ALSO -.Xr yp 8 , -.Xr ypserv 8 -.Sh AUTHORS -.An Mats O Jansson Aq Mt moj@stacken.kth.se diff --git a/usr.sbin/ypserv/yptest/yptest.c b/usr.sbin/ypserv/yptest/yptest.c deleted file mode 100644 index c0ead320f7a..00000000000 --- a/usr.sbin/ypserv/yptest/yptest.c +++ /dev/null @@ -1,124 +0,0 @@ -/* $OpenBSD: yptest.c,v 1.18 2009/11/21 19:31:40 ian Exp $ */ - -/* - * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - */ - -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <rpc/rpc.h> -#include <rpc/xdr.h> -#include <rpcsvc/yp.h> -#include <rpcsvc/ypclnt.h> - -static int -yptest_foreach(u_long status, char *key, int keylen, char *val, int vallen, - void *data) -{ - if (status == 2) - return(0); - - key[keylen] = '\0'; - val[vallen] = '\0'; - printf("%s %s\n", key, val); - return 0; -} - -int -main(int argc, char *argv[]) -{ - char *Domain, *Value, *Key2; - char *Map = "hosts.byname", *Key = "localhost"; - int ValLen, Status, Order, KeyLen; - struct ypall_callback Callback; - struct ypmaplist *ypml, *y; - - Status = yp_get_default_domain(&Domain); - if (Status) - printf("yp error: %s\n", yperr_string(Status)); - - printf("Test 1: yp_match %s %s\n", Key, Map); - KeyLen = strlen(Key); - Status = yp_match(Domain, Map, Key, KeyLen, &Value, &ValLen); - if (Status) - printf("yp error: %s\n", yperr_string(Status)); - else - printf("%*.*s\n", ValLen, ValLen, Value); - - printf("\nTest 2: yp_first\n"); - Status = yp_first(Domain, Map, &Key2, &KeyLen, &Value, &ValLen); - if (Status) - printf("yp error: %s\n", yperr_string(Status)); - else - printf("%*.*s %*.*s\n", KeyLen, KeyLen, Key2, ValLen, ValLen, Value); - - printf("\nTest 3: yp_next\n"); - while (Status == 0) { - Status = yp_next(Domain, Map, Key2, KeyLen, &Key2, - &KeyLen, &Value, &ValLen); - if (Status) - printf("yp error: %s\n", yperr_string(Status)); - else - printf("%*.*s %*.*s\n", KeyLen, KeyLen, Key2, - ValLen, ValLen, Value); - } - - printf("\nTest 4: yp_master\n"); - Status = yp_master(Domain, Map, &Key2); - if (Status) - printf("yp error: %s\n", yperr_string(Status)); - else - printf("%s\n", Key2); - - printf("\nTest 5: yp_order\n"); - Status = yp_order(Domain, Map, &Order); - if (Status) - printf("yp error: %s\n", yperr_string(Status)); - else - printf("%d\n", Order); - - printf("\nTest 6: yp_maplist\n"); - ypml = NULL; - switch (yp_maplist(Domain, &ypml)) { - case 0: - for (y = ypml; y; ) { - ypml = y; - printf("%s\n", ypml->map); - y = ypml->next; - } - break; - default: - printf("yp error: %s\n", yperr_string(Status)); - break; - } - - printf("\nTest 7: yp_all\n"); - Callback.foreach = yptest_foreach; - Status = yp_all(Domain, Map, &Callback); - if (Status) - printf("yp error: %s\n", yperr_string(Status)); - return 0; -} |