- /* Read alternate lines until end of data marker. */
- for (;;) {
- if (fgets (line, sizeof line, pp) == NULL) {
- error (g, _("unexpected end of output from db_dump command"));
- goto out;
- }
-
- len = strlen (line);
- if (len > 0 && line[len-1] == '\n') {
- line[len-1] = '\0';
- len--;
- }
-
- if (STREQ (line, "DATA=END"))
- break;
-
- char *p = line;
- if (len > 0 && line[0] == ' ')
- p = line+1;
- /* Ignore any application name that contains non-printable chars.
- * In the db_dump output these would be escaped with backslash, so
- * we can just ignore any such line.
- */
- if (strchr (p, '\\') == NULL)
- add_application (g, apps, p, "", 0, "", "", "", "", "", "");
-
- /* Discard next line. */
- if (fgets (line, sizeof line, pp) == NULL) {
- error (g, _("unexpected end of output from db_dump command"));
- goto out;
- }
- }
-
- /* Catch errors from the db_dump command. */
- if (pclose (pp) == -1) {
- perrorf (g, "pclose: %s", cmd);
- goto out;
- }
- pp = NULL;
-
- ret = apps;
-
- out:
- if (ret == NULL && apps != NULL)