/* pathalias -- by steve bellovin, as told to peter honeyman */
static char *sccsid
= "@(#)makedb.c 8.1 (down!honey) 86/01/19";
char *Ofile
= ALIASDB
, *ProgName
;
#define USAGE "%s [-o dbmname] [-a] [file ...]"
while ((c
= getopt(argc
, argv
, "o:av")) != EOF
)
case 'o': /* dbm output file */
case 'a': /* append mode */
fprintf(stderr
, USAGE
, ProgName
);
if ((ofptr
= rindex(Ofile
, '/')) != 0)
if (strlen(ofptr
) > 10) {
fprintf(stderr
, "%s: using %s for dbm output\n", ProgName
, Ofile
);
if (append
== 0 && dbfile(Ofile
) != 0) {
if (dbminit(Ofile
) < 0) {
else for ( ; optind
< argc
; optind
++)
return (dbcreat(dbf
, "dir") != 0 || dbcreat(dbf
, "pag") != 0);
(void) sprintf(buf
, "%s.%s", dbf
, suffix
);
if ((fd
= creat(buf
, 0666)) < 0)
if (ifile
&& (freopen(ifile
, "r", stdin
) == NULL
)) {
* keys and values are 0 terminated. this wastes time and (disk) space,
* but does lend simplicity and backwards compatibility.
while (fgets(line
, sizeof(line
), stdin
) != NULL
) {
end
= line
+ strlen(line
);
end
[-1] = 0; /* kill newline, stuff null terminator */
key
.dsize
= op
- line
; /* 0 terminated */
val
.dsize
= end
- op
; /* 0 terminated */
key
.dsize
= end
- line
; /* 0 terminated */
val
.dptr
= "\0"; /* why must i do this? */
fprintf(stderr
, "%s: ", ProgName
);