aboutsummaryrefslogtreecommitdiff
path: root/db2/makedb.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-08-21 17:22:56 +0000
committerUlrich Drepper <drepper@redhat.com>1998-08-21 17:22:56 +0000
commit5148d49f37ad2648ef77159b0b2d1b332c584ed9 (patch)
tree5db7d9cb4929ea18160d7adb37d1635c63f59f03 /db2/makedb.c
parent1ddf537f074f453f4d8b70c1b5df3f9ac728bec4 (diff)
downloadglibc-5148d49f37ad2648ef77159b0b2d1b332c584ed9.tar
glibc-5148d49f37ad2648ef77159b0b2d1b332c584ed9.tar.gz
glibc-5148d49f37ad2648ef77159b0b2d1b332c584ed9.tar.bz2
glibc-5148d49f37ad2648ef77159b0b2d1b332c584ed9.zip
Update.
1998-08-21 17:21 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/glob64.c: Define __stat using __xstat64. 1998-08-20 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makefile (elf/ldso_install): Put back. The problem still persists. * elf/Makefile (ldso_install): Likewise. 1998-08-20 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * db2/db/db.c (db_open) [_LIBC]: Rename to __nss_db_open and create weak alias. * include/db.h: Declare __nss_db_open. * db2/Versions: Export it. * db2/makedb.c: Convert to use db2 API. * nss/nss_db/db-XXX.c: Likewise. * nss/nss_db/db-netgrp.c: Likewise. * nss/nss_db/db-alias.c: Likewise. (_nss_db_getaliasent_r): Allow retrying with a larger buffer. 1998-08-19 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove sys_setresuid, already built automatically (or not). * sysdeps/unix/sysv/linux/syscalls.list: Define __setresuid instead of __syscall_setresuid and add back setresuid. * sysdeps/unix/sysv/linux/seteuid.c: Use __setresuid instead of __syscall_setresuid. 1998-08-21 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/sys/mount.h: Fix typo. * libio/libioP.c (FILEBUF_LITERAL): Also initialize new _offset
Diffstat (limited to 'db2/makedb.c')
-rw-r--r--db2/makedb.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/db2/makedb.c b/db2/makedb.c
index d20befc053..f50b3b09b2 100644
--- a/db2/makedb.c
+++ b/db2/makedb.c
@@ -20,7 +20,7 @@
#include <argp.h>
#include <ctype.h>
-#include <db_185.h>
+#include <db.h>
#include <errno.h>
#include <error.h>
#include <fcntl.h>
@@ -140,16 +140,17 @@ main (argc, argv)
/* Special handling if we are asked to print the database. */
if (do_undo)
{
- db_file = dbopen (input_name, O_RDONLY, 0666, DB_BTREE, NULL);
- if (db_file == NULL)
+ status = db_open (input_name, DB_BTREE, DB_RDONLY, 0666, NULL, NULL,
+ &db_file);
+ if (status != 0)
error (EXIT_FAILURE, 0, gettext ("cannot open database file `%s': %s"),
input_name,
- errno == EINVAL ? gettext ("incorrectly formatted file")
- : strerror (errno));
+ (status == EINVAL ? gettext ("incorrectly formatted file")
+ : strerror (status)));
status = print_database (db_file);
- db_file->close (db_file);
+ db_file->close (db_file, 0);
return status;
}
@@ -174,10 +175,10 @@ main (argc, argv)
/* Open output file. This must not be standard output so we don't
handle "-" and "/dev/stdout" special. */
- db_file = dbopen (output_name, O_CREAT | O_RDWR | O_TRUNC, mode,
- DB_BTREE, NULL);
- if (db_file == NULL)
- error (EXIT_FAILURE, errno, gettext ("cannot open output file `%s'"),
+ status = db_open (output_name, DB_BTREE, DB_CREATE | DB_TRUNCATE, mode,
+ NULL, NULL, &db_file);
+ if (status != 0)
+ error (EXIT_FAILURE, status, gettext ("cannot open output file `%s'"),
output_name);
/* Start the real work. */
@@ -187,7 +188,7 @@ main (argc, argv)
/* Close files. */
if (input_file != stdin)
fclose (input_file);
- db_file->close (db_file);
+ db_file->close (db_file, 0);
return status;
}
@@ -307,18 +308,20 @@ process_input (input, inname, output, to_lowercase, be_quiet)
continue;
key.size = cp - (char *) key.data;
+ key.flags = 0;
while (isspace (*cp))
++cp;
val.data = cp;
val.size = (&line[n] - cp) + 1;
+ val.flags = 0;
/* Store the value. */
- status = output->put (output, &key, &val, R_NOOVERWRITE);
+ status = output->put (output, NULL, &key, &val, DB_NOOVERWRITE);
if (status != 0)
{
- if (status == 1)
+ if (status == DB_KEYEXIST)
{
if (!be_quiet)
error_at_line (0, 0, inname, linenr,
@@ -328,7 +331,7 @@ process_input (input, inname, output, to_lowercase, be_quiet)
continue;
}
else
- error (0, errno, gettext ("while writing database file"));
+ error (0, status, gettext ("while writing database file"));
status = EXIT_FAILURE;
@@ -353,20 +356,30 @@ print_database (db)
{
DBT key;
DBT val;
- int no_more;
+ DBC *cursor;
+ int status;
+
+ status = db->cursor (db, NULL, &cursor);
+ if (status != 0)
+ {
+ error (0, status, gettext ("while reading database"));
+ return EXIT_FAILURE;
+ }
- no_more = db->seq (db, &key, &val, R_FIRST);
- while (!no_more)
+ key.flags = 0;
+ val.flags = 0;
+ status = cursor->c_get (cursor, &key, &val, DB_FIRST);
+ while (status == 0)
{
printf ("%.*s %s\n", (int) key.size, (char *) key.data,
(char *) val.data);
- no_more = db->seq (db, &key, &val, R_NEXT);
+ status = cursor->c_get (cursor, &key, &val, DB_NEXT);
}
- if (no_more == -1)
+ if (status != DB_NOTFOUND)
{
- error (0, errno, gettext ("while reading database"));
+ error (0, status, gettext ("while reading database"));
return EXIT_FAILURE;
}