Withdraw old DBM support. Fix style issues.
Showing
2 changed files
with
13 additions
and
122 deletions
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2002, 2006, 2007 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001, 2002, 2006, |
3 | 2007 Free Software Foundation, Inc. | ||
3 | 4 | ||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | 5 | GNU Mailutils is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
... | @@ -39,6 +40,8 @@ mu_fcheck_perm (int fd, int mode) | ... | @@ -39,6 +40,8 @@ mu_fcheck_perm (int fd, int mode) |
39 | { | 40 | { |
40 | struct stat st; | 41 | struct stat st; |
41 | 42 | ||
43 | if (mode == 0) | ||
44 | return 0; | ||
42 | if (fstat (fd, &st) == -1) | 45 | if (fstat (fd, &st) == -1) |
43 | { | 46 | { |
44 | if (errno == ENOENT) | 47 | if (errno == ENOENT) |
... | @@ -142,12 +145,15 @@ mu_dbm_open (char *name, DBM_FILE *db, int flags, int mode) | ... | @@ -142,12 +145,15 @@ mu_dbm_open (char *name, DBM_FILE *db, int flags, int mode) |
142 | case MU_STREAM_CREAT: | 145 | case MU_STREAM_CREAT: |
143 | f = GDBM_NEWDB; | 146 | f = GDBM_NEWDB; |
144 | break; | 147 | break; |
148 | |||
145 | case MU_STREAM_READ: | 149 | case MU_STREAM_READ: |
146 | f = GDBM_READER; | 150 | f = GDBM_READER; |
147 | break; | 151 | break; |
152 | |||
148 | case MU_STREAM_RDWR: | 153 | case MU_STREAM_RDWR: |
149 | f = GDBM_WRCREAT; | 154 | f = GDBM_WRCREAT; |
150 | break; | 155 | break; |
156 | |||
151 | default: | 157 | default: |
152 | free (pfname); | 158 | free (pfname); |
153 | errno = EINVAL; | 159 | errno = EINVAL; |
... | @@ -239,12 +245,15 @@ mu_dbm_open (char *name, DBM_FILE *dbm, int flags, int mode) | ... | @@ -239,12 +245,15 @@ mu_dbm_open (char *name, DBM_FILE *dbm, int flags, int mode) |
239 | case MU_STREAM_CREAT: | 245 | case MU_STREAM_CREAT: |
240 | f = DB_CREATE|DB_TRUNCATE; | 246 | f = DB_CREATE|DB_TRUNCATE; |
241 | break; | 247 | break; |
248 | |||
242 | case MU_STREAM_READ: | 249 | case MU_STREAM_READ: |
243 | f = DB_RDONLY; | 250 | f = DB_RDONLY; |
244 | break; | 251 | break; |
252 | |||
245 | case MU_STREAM_RDWR: | 253 | case MU_STREAM_RDWR: |
246 | f = DB_CREATE; | 254 | f = DB_CREATE; |
247 | break; | 255 | break; |
256 | |||
248 | default: | 257 | default: |
249 | free (pfname); | 258 | free (pfname); |
250 | errno = EINVAL; | 259 | errno = EINVAL; |
... | @@ -389,12 +398,15 @@ mu_dbm_open (char *name, DBM_FILE *db, int flags, int mode) | ... | @@ -389,12 +398,15 @@ mu_dbm_open (char *name, DBM_FILE *db, int flags, int mode) |
389 | case MU_STREAM_CREAT: | 398 | case MU_STREAM_CREAT: |
390 | f = O_CREAT|O_TRUNC|O_RDWR; | 399 | f = O_CREAT|O_TRUNC|O_RDWR; |
391 | break; | 400 | break; |
401 | |||
392 | case MU_STREAM_READ: | 402 | case MU_STREAM_READ: |
393 | f = O_RDONLY; | 403 | f = O_RDONLY; |
394 | break; | 404 | break; |
405 | |||
395 | case MU_STREAM_RDWR: | 406 | case MU_STREAM_RDWR: |
396 | f = O_CREAT|O_RDWR; | 407 | f = O_CREAT|O_RDWR; |
397 | break; | 408 | break; |
409 | |||
398 | default: | 410 | default: |
399 | errno = EINVAL; | 411 | errno = EINVAL; |
400 | return -1; | 412 | return -1; |
... | @@ -458,117 +470,5 @@ mu_dbm_datum_free (DBM_DATUM *datum) | ... | @@ -458,117 +470,5 @@ mu_dbm_datum_free (DBM_DATUM *datum) |
458 | { | 470 | { |
459 | /* empty */ | 471 | /* empty */ |
460 | } | 472 | } |
461 | #elif defined(WITH_OLD_DBM) | ||
462 | |||
463 | #define DB_SUFFIX ".pag" | ||
464 | |||
465 | int | ||
466 | mu_dbm_stat (char *name, struct stat *sb) | ||
467 | { | ||
468 | int rc; | ||
469 | char *pfname = make_db_name (name, DB_SUFFIX); | ||
470 | rc = stat (pfname, sb); | ||
471 | free (pfname); | ||
472 | return rc; | ||
473 | } | ||
474 | |||
475 | /*ARGSUSED*/ | ||
476 | int | ||
477 | mu_dbm_open (char *name, DBM_FILE *db, int flags, int mode) | ||
478 | { | ||
479 | int f; | ||
480 | char *pfname; | ||
481 | |||
482 | switch (flags) | ||
483 | { | ||
484 | case MU_STREAM_CREAT: | ||
485 | f = O_CREAT|O_TRUNC|O_RDWR; | ||
486 | break; | ||
487 | case MU_STREAM_READ: | ||
488 | f = O_RDONLY; | ||
489 | break; | ||
490 | case MU_STREAM_RDWR: | ||
491 | f = O_CREAT|O_RDWR; | ||
492 | break; | ||
493 | default: | ||
494 | errno = EINVAL; | ||
495 | return -1; | ||
496 | } | ||
497 | pfname = strip_suffix (name, DB_SUFFIX); | ||
498 | if (f & O_CREAT) | ||
499 | { | ||
500 | char *p; | ||
501 | int fd; | ||
502 | |||
503 | p = make_db_name (pfname, ".pag"); | ||
504 | fd = open (p, f, mode); | ||
505 | free (p); | ||
506 | if (fd < 0) | ||
507 | { | ||
508 | free (pfname); | ||
509 | return -1; | ||
510 | } | ||
511 | close(fd); | ||
512 | |||
513 | p = make_db_name (pfname, ".dir"); | ||
514 | fd = open (p, f, mode); | ||
515 | free (p); | ||
516 | if (fd < 0) | ||
517 | { | ||
518 | free (pfname); | ||
519 | return -1; | ||
520 | } | ||
521 | close (fd); | ||
522 | } | ||
523 | rc = dbminit (pfname); | ||
524 | free (pfname); | ||
525 | return rc; | ||
526 | } | ||
527 | |||
528 | /*ARGSUSED*/ | ||
529 | int | ||
530 | mu_dbm_close (DBM_FILE db) | ||
531 | { | ||
532 | dbmclose (); | ||
533 | return 0; | ||
534 | } | ||
535 | |||
536 | /*ARGSUSED*/ | ||
537 | int | ||
538 | mu_dbm_fetch (DBM_FILE db, DBM_DATUM key, DBM_DATUM *ret) | ||
539 | { | ||
540 | *ret = fetch (key); | ||
541 | return ret->dptr == NULL; | ||
542 | } | ||
543 | |||
544 | int | ||
545 | mu_dbm_delete (DBM_FILE db, DBM_DATUM key) | ||
546 | { | ||
547 | return delete (key); | ||
548 | } | ||
549 | |||
550 | int | ||
551 | mu_dbm_insert (DBM_FILE db, DBM_DATUM key, DBM_DATUM contents, int replace) | ||
552 | { | ||
553 | return store (key, contents); | ||
554 | } | ||
555 | |||
556 | DBM_DATUM | ||
557 | mu_dbm_firstkey (DBM_FILE db) | ||
558 | { | ||
559 | return firstkey (); | ||
560 | } | ||
561 | |||
562 | DBM_DATUM | ||
563 | mu_dbm_nextkey (DBM_FILE db, DBM_DATUM key) | ||
564 | { | ||
565 | return nextkey (key); | ||
566 | } | ||
567 | |||
568 | void | ||
569 | mu_dbm_datum_free (DBM_DATUM *datum) | ||
570 | { | ||
571 | /* empty */ | ||
572 | } | ||
573 | #endif | 473 | #endif |
574 | 474 | ... | ... |
... | @@ -52,15 +52,6 @@ typedef datum DBM_DATUM; | ... | @@ -52,15 +52,6 @@ typedef datum DBM_DATUM; |
52 | #define MU_DATUM_SIZE(d) (d).dsize | 52 | #define MU_DATUM_SIZE(d) (d).dsize |
53 | #define MU_DATUM_PTR(d) (d).dptr | 53 | #define MU_DATUM_PTR(d) (d).dptr |
54 | 54 | ||
55 | #elif defined(WITH_OLD_DBM) | ||
56 | |||
57 | #include <dbm.h> | ||
58 | #define USE_DBM | ||
59 | typedef int DBM_FILE; | ||
60 | typedef datum DBM_DATUM; | ||
61 | #define MU_DATUM_SIZE(d) (d).dsize | ||
62 | #define MU_DATUM_PTR(d) (d).dptr | ||
63 | |||
64 | #endif | 55 | #endif |
65 | 56 | ||
66 | #ifdef USE_DBM | 57 | #ifdef USE_DBM | ... | ... |
-
Please register or sign in to post a comment