yp_mkdb.c (90297) | yp_mkdb.c (90298) |
---|---|
1/* 2 * Copyright (c) 1995, 1996 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#ifndef lint 34static const char rcsid[] = | 1/* 2 * Copyright (c) 1995, 1996 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 18 unchanged lines hidden (view full) --- 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33#ifndef lint 34static const char rcsid[] = |
35 "$FreeBSD: head/usr.sbin/yp_mkdb/yp_mkdb.c 90297 2002-02-06 13:30:31Z des $"; | 35 "$FreeBSD: head/usr.sbin/yp_mkdb/yp_mkdb.c 90298 2002-02-06 15:26:07Z des $"; |
36#endif /* not lint */ 37 38#include <err.h> 39#include <fcntl.h> 40#include <limits.h> 41#include <stdio.h> 42#include <stdlib.h> 43#include <string.h> --- 6 unchanged lines hidden (view full) --- 50#include <sys/stat.h> 51#include "yp_extern.h" 52#include "ypxfr_extern.h" 53 54char *yp_dir = ""; /* No particular default needed. */ 55int _rpcpmstart = 0; 56int debug = 1; 57 | 36#endif /* not lint */ 37 38#include <err.h> 39#include <fcntl.h> 40#include <limits.h> 41#include <stdio.h> 42#include <stdlib.h> 43#include <string.h> --- 6 unchanged lines hidden (view full) --- 50#include <sys/stat.h> 51#include "yp_extern.h" 52#include "ypxfr_extern.h" 53 54char *yp_dir = ""; /* No particular default needed. */ 55int _rpcpmstart = 0; 56int debug = 1; 57 |
58static void usage() | 58static void 59usage(void) |
59{ 60 fprintf(stderr, "%s\n%s\n%s\n%s\n", 61 "usage: yp_mkdb -c", 62 " yp_mkdb -u dbname", 63 " yp_mkdb [-c] [-b] [-s] [-f] [-i inputfile] [-o outputfile]", 64 " [-d domainname ] [-m mastername] inputfile dbname"); 65 exit(1); 66} 67 68#define PERM_SECURE (S_IRUSR|S_IWUSR) 69 | 60{ 61 fprintf(stderr, "%s\n%s\n%s\n%s\n", 62 "usage: yp_mkdb -c", 63 " yp_mkdb -u dbname", 64 " yp_mkdb [-c] [-b] [-s] [-f] [-i inputfile] [-o outputfile]", 65 " [-d domainname ] [-m mastername] inputfile dbname"); 66 exit(1); 67} 68 69#define PERM_SECURE (S_IRUSR|S_IWUSR) 70 |
70static DB *open_db(path, flags) 71 char *path; 72 int flags; | 71static DB * 72open_db(char *path, int flags) |
73{ 74 extern HASHINFO openinfo; 75 76 return(dbopen(path, flags, PERM_SECURE, DB_HASH, &openinfo)); 77} 78 | 73{ 74 extern HASHINFO openinfo; 75 76 return(dbopen(path, flags, PERM_SECURE, DB_HASH, &openinfo)); 77} 78 |
79static void unwind(map) 80 char *map; | 79static void 80unwind(char *map) |
81{ 82 DB *dbp; 83 DBT key, data; 84 85 dbp = open_db(map, O_RDONLY); 86 87 if (dbp == NULL) 88 err(1, "open_db(%s) failed", map); 89 90 key.data = NULL; 91 while (yp_next_record(dbp, &key, &data, 1, 1) == YP_TRUE) 92 printf("%.*s %.*s\n", key.size,key.data,data.size,data.data); 93 94 (void)(dbp->close)(dbp); 95 return; 96} 97 | 81{ 82 DB *dbp; 83 DBT key, data; 84 85 dbp = open_db(map, O_RDONLY); 86 87 if (dbp == NULL) 88 err(1, "open_db(%s) failed", map); 89 90 key.data = NULL; 91 while (yp_next_record(dbp, &key, &data, 1, 1) == YP_TRUE) 92 printf("%.*s %.*s\n", key.size,key.data,data.size,data.data); 93 94 (void)(dbp->close)(dbp); 95 return; 96} 97 |
98int main (argc, argv) 99 int argc; 100 char *argv[]; | 98int 99main(int argc, char *argv[]) |
101{ 102 int ch; 103 int un = 0; 104 int clear = 0; 105 int filter_plusminus = 0; 106 char *infile = NULL; 107 char *map = NULL; 108 char *domain = NULL; --- 237 unchanged lines hidden --- | 100{ 101 int ch; 102 int un = 0; 103 int clear = 0; 104 int filter_plusminus = 0; 105 char *infile = NULL; 106 char *map = NULL; 107 char *domain = NULL; --- 237 unchanged lines hidden --- |