Deleted Added
full compact
yp_mkdb.c (50746) yp_mkdb.c (90297)
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 50746 1999-09-01 12:42:00Z sheldonh $";
35 "$FreeBSD: head/usr.sbin/yp_mkdb/yp_mkdb.c 90297 2002-02-06 13:30:31Z 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>

--- 39 unchanged lines hidden (view full) ---

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;
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>

--- 39 unchanged lines hidden (view full) ---

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)
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;

--- 14 unchanged lines hidden (view full) ---

114 DB *dbp;
115 DBT key, data;
116 char buf[10240];
117 char *keybuf, *datbuf;
118 FILE *ifp;
119 char hname[MAXHOSTNAMELEN + 2];
120
121 while ((ch = getopt(argc, argv, "uhcbsfd:i:o:m:")) != -1) {
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;

--- 14 unchanged lines hidden (view full) ---

114 DB *dbp;
115 DBT key, data;
116 char buf[10240];
117 char *keybuf, *datbuf;
118 FILE *ifp;
119 char hname[MAXHOSTNAMELEN + 2];
120
121 while ((ch = getopt(argc, argv, "uhcbsfd:i:o:m:")) != -1) {
122 switch(ch) {
122 switch (ch) {
123 case 'f':
124 filter_plusminus++;
125 break;
126 case 'u':
127 un++;
128 break;
129 case 'c':
130 clear++;

--- 114 unchanged lines hidden (view full) ---

245 if (domain) {
246 key.data = "YP_DOMAIN_NAME";
247 key.size = sizeof("YP_DOMAIN_NAME") - 1;
248 data.data = domain;
249 data.size = strlen(domain);
250 yp_put_record(dbp, &key, &data, 0);
251 }
252
123 case 'f':
124 filter_plusminus++;
125 break;
126 case 'u':
127 un++;
128 break;
129 case 'c':
130 clear++;

--- 114 unchanged lines hidden (view full) ---

245 if (domain) {
246 key.data = "YP_DOMAIN_NAME";
247 key.size = sizeof("YP_DOMAIN_NAME") - 1;
248 data.data = domain;
249 data.size = strlen(domain);
250 yp_put_record(dbp, &key, &data, 0);
251 }
252
253 while(fgets((char *)&buf, sizeof(buf), ifp)) {
253 while (fgets((char *)&buf, sizeof(buf), ifp)) {
254 char *sep = NULL;
255 int rval;
256
257 /* NUL terminate */
258 if ((sep = strchr(buf, '\n')))
259 *sep = '\0';
260
261 /* handle backslash line continuations */
254 char *sep = NULL;
255 int rval;
256
257 /* NUL terminate */
258 if ((sep = strchr(buf, '\n')))
259 *sep = '\0';
260
261 /* handle backslash line continuations */
262 while(buf[strlen(buf) - 1] == '\\') {
262 while (buf[strlen(buf) - 1] == '\\') {
263 fgets((char *)&buf[strlen(buf) - 1],
264 sizeof(buf) - strlen(buf), ifp);
265 if ((sep = strchr(buf, '\n')))
266 *sep = '\0';
267 }
268
269 /* find the separation between the key and data */
270 if ((sep = strpbrk(buf, " \t")) == NULL) {

--- 36 unchanged lines hidden (view full) ---

307 }
308
309 key.data = keybuf;
310 key.size = strlen(keybuf);
311 data.data = datbuf;
312 data.size = strlen(datbuf);
313
314 if ((rval = yp_put_record(dbp, &key, &data, 0)) != YP_TRUE) {
263 fgets((char *)&buf[strlen(buf) - 1],
264 sizeof(buf) - strlen(buf), ifp);
265 if ((sep = strchr(buf, '\n')))
266 *sep = '\0';
267 }
268
269 /* find the separation between the key and data */
270 if ((sep = strpbrk(buf, " \t")) == NULL) {

--- 36 unchanged lines hidden (view full) ---

307 }
308
309 key.data = keybuf;
310 key.size = strlen(keybuf);
311 data.data = datbuf;
312 data.size = strlen(datbuf);
313
314 if ((rval = yp_put_record(dbp, &key, &data, 0)) != YP_TRUE) {
315 switch(rval) {
315 switch (rval) {
316 case YP_FALSE:
317 warnx("duplicate key '%s' - skipping", keybuf);
318 break;
319 case YP_BADDB:
320 default:
321 err(1,"failed to write new record - exiting");
322 break;
323 }

--- 22 unchanged lines hidden ---
316 case YP_FALSE:
317 warnx("duplicate key '%s' - skipping", keybuf);
318 break;
319 case YP_BADDB:
320 default:
321 err(1,"failed to write new record - exiting");
322 break;
323 }

--- 22 unchanged lines hidden ---