Exemplo n.º 1
0
static	void	parsefile (const char *file, dki_t **listp, int sub_before)
{
	char	path[MAX_PATHSIZE+1];
	dki_t	*dkp;

	/* file arg contains path ? ... */
	file = splitpath (path, sizeof (path), file);	/* ... then split of */

	if ( is_keyfilename (file) )	/* plain file name looks like DNS key file ? */
	{
		if ( (dkp = dki_read (path, file)) )	/* read DNS key file ... */
#if defined (USE_TREE) && USE_TREE
			dki_tadd (listp, dkp, sub_before);		/* ... and add to tree */
#else
			dki_add (listp, dkp);		/* ... and add to list */
#endif
		else
			error ("error parsing %s: (%s)\n", file, dki_geterrstr());
	}
Exemplo n.º 2
0
static int parsedirectory (const char *dir, dki_t ** listp)
{
    dki_t *dkp;

    DIR *dirp;

    struct dirent *dentp;

    char path[MAX_PATHSIZE + 1];

    if (dirflag)
        return 0;

    dbg_val ("directory: opendir(%s)\n", dir);
    if ((dirp = opendir (dir)) == NULL)
        return 0;

    while ((dentp = readdir (dirp)) != NULL)
    {
        if (is_dotfilename (dentp->d_name))
            continue;

        dbg_val ("directory: check %s\n", dentp->d_name);
        pathname (path, sizeof (path), dir, dentp->d_name, NULL);
        if (is_directory (path) && recflag)
        {
            dbg_val ("directory: recursive %s\n", path);
            parsedirectory (path, listp);
        }
        else if (is_keyfilename (dentp->d_name))
            if ((dkp = dki_read (dir, dentp->d_name)))
            {
                // fprintf (stderr, "parsedir: tssearch (%d %s)\n", dkp, dkp->name);
#if defined (USE_TREE) && USE_TREE
                dki_tadd (listp, dkp, 1);
#else
                dki_add (listp, dkp);
#endif
            }
    }
    closedir (dirp);
    return 1;
}