static int createdb(const char *f) { char *line, *eq; s = sdb_new (NULL, f, 0); if (!s || !sdb_create (s)) { fprintf (stderr, "Cannot create database\n"); return 1; } for (;(line = stdin_gets ());) { if ((eq = strchr (line, '='))) { *eq = 0; sdb_append (s, line, eq+1); } free (line); } sdb_finish (s); return 0; }
static void createdb(const char *f) { char line[SDB_VSZ]; char *eq; s = sdb_new (f, 0); if (!sdb_create (s)) { printf ("Cannot create database\n"); exit (1); } for (;;) { if (!fgets (line, sizeof line, stdin) || feof (stdin)) break; line[strlen (line)-1] = 0; if ((eq = strchr (line, '='))) { *eq = 0; sdb_append (s, line, eq+1); } } sdb_finish (s); }