cap_mkdb.c (142109) | cap_mkdb.c (142262) |
---|---|
1/*- 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. 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 --- 30 unchanged lines hidden (view full) --- 39 40#if 0 41#ifndef lint 42static char sccsid[] = "@(#)cap_mkdb.c 8.2 (Berkeley) 4/27/95"; 43#endif 44#endif 45 46#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. 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 --- 30 unchanged lines hidden (view full) --- 39 40#if 0 41#ifndef lint 42static char sccsid[] = "@(#)cap_mkdb.c 8.2 (Berkeley) 4/27/95"; 43#endif 44#endif 45 46#include <sys/cdefs.h> |
47__FBSDID("$FreeBSD: head/usr.bin/cap_mkdb/cap_mkdb.c 142109 2005-02-19 23:59:49Z ru $"); | 47__FBSDID("$FreeBSD: head/usr.bin/cap_mkdb/cap_mkdb.c 142262 2005-02-22 23:29:54Z ru $"); |
48 49#include <sys/param.h> 50#include <sys/stat.h> 51 52#include <db.h> 53#include <err.h> 54#include <fcntl.h> 55#include <stdio.h> --- 23 unchanged lines hidden (view full) --- 79 * records. The database contains 2 types of entries: records and references 80 * marked by the first byte in the data. A record entry contains the actual 81 * capability record whereas a reference contains the name (key) under which 82 * the correct record is stored. 83 */ 84int 85main(int argc, char *argv[]) 86{ | 48 49#include <sys/param.h> 50#include <sys/stat.h> 51 52#include <db.h> 53#include <err.h> 54#include <fcntl.h> 55#include <stdio.h> --- 23 unchanged lines hidden (view full) --- 79 * records. The database contains 2 types of entries: records and references 80 * marked by the first byte in the data. A record entry contains the actual 81 * capability record whereas a reference contains the name (key) under which 82 * the correct record is stored. 83 */ 84int 85main(int argc, char *argv[]) 86{ |
87 int c; | 87 int byteorder, c; |
88 89 capname = NULL; | 88 89 capname = NULL; |
90 while ((c = getopt(argc, argv, "f:v")) != -1) { | 90 byteorder = 0; 91 while ((c = getopt(argc, argv, "bf:lv")) != -1) { |
91 switch(c) { | 92 switch(c) { |
93 case 'b': 94 case 'l': 95 if (byteorder != 0) 96 usage(); 97 byteorder = c == 'b' ? 4321 : 1234; 98 break; |
|
92 case 'f': 93 capname = optarg; 94 break; 95 case 'v': 96 verbose = 1; 97 break; 98 case '?': 99 default: 100 usage(); 101 } 102 } 103 argc -= optind; 104 argv += optind; 105 106 if (*argv == NULL) 107 usage(); 108 | 99 case 'f': 100 capname = optarg; 101 break; 102 case 'v': 103 verbose = 1; 104 break; 105 case '?': 106 default: 107 usage(); 108 } 109 } 110 argc -= optind; 111 argv += optind; 112 113 if (*argv == NULL) 114 usage(); 115 |
116 /* Set byte order. */ 117 openinfo.lorder = byteorder; 118 |
|
109 /* 110 * The database file is the first argument if no name is specified. 111 * Make arrangements to unlink it if exit badly. 112 */ 113 (void)snprintf(buf, sizeof(buf), "%s.db", capname ? capname : *argv); 114 if ((capname = strdup(buf)) == NULL) 115 errx(1, "strdup failed"); 116 if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR, --- 135 unchanged lines hidden (view full) --- 252 if (verbose) 253 (void)printf("cap_mkdb: %d capability records\n", reccnt); 254} 255 256void 257usage(void) 258{ 259 (void)fprintf(stderr, | 119 /* 120 * The database file is the first argument if no name is specified. 121 * Make arrangements to unlink it if exit badly. 122 */ 123 (void)snprintf(buf, sizeof(buf), "%s.db", capname ? capname : *argv); 124 if ((capname = strdup(buf)) == NULL) 125 errx(1, "strdup failed"); 126 if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR, --- 135 unchanged lines hidden (view full) --- 262 if (verbose) 263 (void)printf("cap_mkdb: %d capability records\n", reccnt); 264} 265 266void 267usage(void) 268{ 269 (void)fprintf(stderr, |
260 "usage: cap_mkdb [-v] [-f outfile] file [file ...]\n"); | 270 "usage: cap_mkdb [-b | -l] [-v] [-f outfile] file ...\n"); |
261 exit(1); 262} | 271 exit(1); 272} |