2 ** Copyright 1998 - 1999 Double Precision, Inc.
3 ** See COPYING for distribution information.
18 static int addgdbm(char *p
, struct dbobj
*o
)
26 if ( (val
=strchr(p
, '\t')) == 0) val
="";
32 if (dbobj_store(o
, key
, strlen(key
), val
, strlen(val
), "I"))
34 fprintf(stderr
, "Cannot store record for %s - duplicate or out of disk space.\n", key
);
41 static int buildgdbm(FILE *i
, struct dbobj
*o
)
44 size_t bufsize
, buflen
;
56 if (buflen
>= bufsize
)
59 buf
= buf
? realloc(buf
, bufsize
):
68 if (c
== '\n' || c
== EOF
) break;
72 if (c
== EOF
) return (-1);
74 if (strcmp(buf
, ".") == 0) return (0);
75 if (addgdbm(buf
, o
)) return (-1);
79 int main(int argc
, char **argv
)
86 fprintf(stderr
, "Usage: %s textfile tmpfile gdbmfile\n",
90 if (strcmp(argv
[1], "-") == 0)
94 if ((i
=fopen(argv
[1], "r")) == 0)
103 if (dbobj_open(&obj
, argv
[2], "N"))
105 fprintf(stderr
, "Cannot create %s\n", argv
[2]);
109 if (buildgdbm(i
, &obj
))
118 if (rename(argv
[2], argv
[3]))