Beispiel #1
0
static void read_pkginfo(struct archive *archive, pkg_t *pkg)
{
    _cleanup_free_ struct archive_reader *reader = archive_reader_new(archive);
    ssize_t nbytes_r = 0;
    char line[LINE_MAX];

    for (;;) {
        nbytes_r = archive_fgets(reader, line, sizeof(line));
        if (nbytes_r < 0)
            break;

        if (nbytes_r == 0)
            continue;
        nbytes_r = strcspn(line, "#");
        if (nbytes_r == 0)
            continue;

        line[nbytes_r] = '\0';
        char *e = memchr(line, '=', nbytes_r);
        if (!e)
            err(EXIT_FAILURE, "failed to find '='");

        *e++ = 0;
        pkginfo_assignment(strstrip(line), strstrip(e), pkg);
    }
}
Beispiel #2
0
char *	epic_fgets(char *s, int n, struct epic_loadfile *elf)
{
    if ((elf->fp)!=NULL) {
        return fgets(s, n, elf->fp);
    }
#ifdef HAVE_LIBARCHIVE
    else if ((elf->a)!=NULL) {
        return archive_fgets(s, n, elf->a);
    } 
#endif
    else {
        return NULL;
    }
}