src/gedlib/dblist.c
/*==================================================
 * add_dbs_to_list -- Add all dbs in specified dir to list
 *  dblist: [I/O] list of databases found
 *  dir:    [IN]  directory to be searched for more databases
 *================================================*/
- Add all dbs in specified dir to list
dblist: [I/O] list of databases found
dir:    [IN]  directory to be searched for more databases
- Add all dbs in specified dir to list dblist : [ I / O ] list of databases found dir : [ IN ] directory to be searched for more databases
static void
add_dbs_to_list (LIST dblist, LIST dbdesclist, STRING dir)
{
	int n=0;
	struct dirent **programs=0;
	char candidate[MAXPATHLEN];
	char userpath[MAXPATHLEN];
	CNSTRING dbstr=0;
	char dirbuf[MAXPATHLEN];
	llstrncpy(dirbuf, dir, sizeof(dirbuf), 0);
	if (!expand_special_fname_chars(dirbuf, sizeof(dirbuf), uu8))
		return;
	n = scandir(dirbuf, &programs, 0, 0);
	if (n < 0) return;
	while (n--) {
		concat_path(dirbuf, programs[n]->d_name, uu8, candidate, sizeof(candidate));
		concat_path(dir, programs[n]->d_name, uu8, userpath, sizeof(userpath));
		if ((dbstr = getdbdesc(candidate, userpath)) != NULL) {
			back_list(dblist, strsave(userpath));
			back_list(dbdesclist, (STRING)dbstr);
		}
		stdfree(programs[n]);
	}
	stdfree(programs);
}
static void add_dbs_to_list ( LIST dblist , LIST dbdesclist , STRING dir ) { int n = 0 ; struct dirent * * programs = 0 ; char candidate [ MAXPATHLEN ] ; char userpath [ MAXPATHLEN ] ; CNSTRING dbstr = 0 ; char dirbuf [ MAXPATHLEN ] ; llstrncpy ( dirbuf , dir , sizeof ( dirbuf ) , 0 ) ; if ( ! expand_special_fname_chars ( dirbuf , sizeof ( dirbuf ) , uu8 ) ) return ; n = scandir ( dirbuf , & programs , 0 , 0 ) ; if ( n < 0 ) return ; while ( n -- ) { concat_path ( dirbuf , programs [ n ] -> d_name , uu8 , candidate , sizeof ( candidate ) ) ; concat_path ( dir , programs [ n ] -> d_name , uu8 , userpath , sizeof ( userpath ) ) ; if ( ( dbstr = getdbdesc ( candidate , userpath ) ) != NULL ) { back_list ( dblist , strsave ( userpath ) ) ; back_list ( dbdesclist , ( STRING ) dbstr ) ; } stdfree ( programs [ n ] ) ; } stdfree ( programs ) ; }
add_dbs_to_list -- Add all dbs in specified dir to list
  dblist: [I/O] list of databases found
  dir:    [IN]  directory to be searched for more databases
add_dbs_to_list -- Add all dbs in specified dir to list dblist : [ I / O ] list of databases found dir : [ IN ] directory to be searched for more databases