1*30811Sbostic # include "sendmail.h" 2*30811Sbostic 3*30811Sbostic static char sccsid[] = "@(#)praliases.c 5.1 04/06/87"; 4*30811Sbostic 5*30811Sbostic typedef struct { char *dptr; int dsize; } datum; 6*30811Sbostic datum firstkey(), nextkey(), fetch(); 7*30811Sbostic char *filename = ALIASFILE; 8*30811Sbostic 9*30811Sbostic main(argc, argv) 10*30811Sbostic char **argv; 11*30811Sbostic { 12*30811Sbostic datum content, key; 13*30811Sbostic 14*30811Sbostic if (argc > 2 && strcmp(argv[1], "-f") == 0) 15*30811Sbostic { 16*30811Sbostic argv++; 17*30811Sbostic filename = *++argv; 18*30811Sbostic argc -= 2; 19*30811Sbostic } 20*30811Sbostic 21*30811Sbostic if (dbminit(filename) < 0) 22*30811Sbostic exit(EX_OSFILE); 23*30811Sbostic argc--, argv++; 24*30811Sbostic if (argc == 0) { 25*30811Sbostic for (key = firstkey(); key.dptr; key = nextkey(key)) { 26*30811Sbostic content = fetch(key); 27*30811Sbostic printf("\n%s:%s\n", key.dptr, content.dptr); 28*30811Sbostic } 29*30811Sbostic exit(EX_OK); 30*30811Sbostic } 31*30811Sbostic while (argc) { 32*30811Sbostic key.dptr = *argv; 33*30811Sbostic key.dsize = strlen(*argv)+1; 34*30811Sbostic content = fetch(key); 35*30811Sbostic if (content.dptr == 0) 36*30811Sbostic printf("%s: No such key\n"); 37*30811Sbostic else 38*30811Sbostic printf("\n%s:%s\n", key.dptr, content.dptr); 39*30811Sbostic argc--, argv++; 40*30811Sbostic } 41*30811Sbostic exit(EX_OK); 42*30811Sbostic } 43