/*
- * Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1983 Eric P. Allman. All rights reserved.
* Copyright (c) 1988, 1993
#ifndef lint
static char copyright[] =
-"@(#) Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers.\n\
+"@(#) Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers.\n\
All rights reserved.\n\
Copyright (c) 1983 Eric P. Allman. All rights reserved.\n\
Copyright (c) 1988, 1993\n\
#endif /* ! lint */
#ifndef lint
-static char id[] = "@(#)$Sendmail: praliases.c,v 8.57 1999/10/13 03:35:16 ca Exp $";
+static char id[] = "@(#)$Sendmail: praliases.c,v 8.59 2000/03/17 07:32:47 gshapiro Exp $";
#endif /* ! lint */
#include <sys/types.h>
goto fatal;
}
- memset(&db_key, '\0', sizeof db_key);
- memset(&db_value, '\0', sizeof db_value);
-
- result = database->smdb_cursor(database, &cursor, 0);
- if (result != SMDBE_OK)
+ if (argc == 0)
{
- fprintf(stderr, "praliases: %s: set cursor: %s\n",
- db_name, errstring(result));
- goto fatal;
- }
+ memset(&db_key, '\0', sizeof db_key);
+ memset(&db_value, '\0', sizeof db_value);
- while ((result = cursor->smdbc_get(cursor, &db_key, &db_value,
- SMDB_CURSOR_GET_NEXT)) == SMDBE_OK)
- {
+ result = database->smdb_cursor(database, &cursor, 0);
+ if (result != SMDBE_OK)
+ {
+ fprintf(stderr, "praliases: %s: set cursor: %s\n",
+ db_name, errstring(result));
+ goto fatal;
+ }
+
+ while ((result = cursor->smdbc_get(cursor, &db_key, &db_value,
+ SMDB_CURSOR_GET_NEXT)) ==
+ SMDBE_OK)
+ {
#if 0
- /* skip magic @:@ entry */
- if (db_key.data.size == 2 &&
- db_key.data.data[0] == '@' &&
- db_key.data.data[1] == '\0' &&
- db_value.data.size == 2 &&
- db_value.data.data[0] == '@' &&
- db_value.data.data[1] == '\0')
- continue;
+ /* skip magic @:@ entry */
+ if (db_key.data.size == 2 &&
+ db_key.data.data[0] == '@' &&
+ db_key.data.data[1] == '\0' &&
+ db_value.data.size == 2 &&
+ db_value.data.data[0] == '@' &&
+ db_value.data.data[1] == '\0')
+ continue;
#endif /* 0 */
- printf("%.*s:%.*s\n",
- (int) db_key.data.size,
- (char *) db_key.data.data,
- (int) db_value.data.size,
- (char *) db_value.data.data);
- }
+ printf("%.*s:%.*s\n",
+ (int) db_key.data.size,
+ (char *) db_key.data.data,
+ (int) db_value.data.size,
+ (char *) db_value.data.data);
+ }
- if (result != SMDBE_OK && result != SMDBE_LAST_ENTRY)
+ if (result != SMDBE_OK && result != SMDBE_LAST_ENTRY)
+ {
+ fprintf(stderr,
+ "praliases: %s: get value at cursor: %s\n",
+ db_name, errstring(result));
+ goto fatal;
+ }
+ }
+ else for (; *argv != NULL; ++argv)
{
- fprintf(stderr, "praliases: %s: get value at cursor: %s\n",
- db_name, errstring(result));
- goto fatal;
+ memset(&db_key, '\0', sizeof db_key);
+ memset(&db_value, '\0', sizeof db_value);
+ db_key.data.data = *argv;
+ db_key.data.size = strlen(*argv) + 1;
+ if (database->smdb_get(database, &db_key,
+ &db_value, 0) == SMDBE_OK)
+ {
+ printf("%.*s:%.*s\n",
+ (int) db_key.data.size,
+ (char *) db_key.data.data,
+ (int) db_value.data.size,
+ (char *) db_value.data.data);
+ }
+ else
+ printf("%s: No such key\n", (char *) db_key.data.data);
}
fatal: