mirror of
https://github.com/troglobit/libite.git
synced 2026-11-03 13:18:33 +00:00
tests/dir.c: Remove nested checker function
Move nested check function is_startup_config() outside main(). Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
efae15416c
commit
23703c75da
1 file changed
+18
-17
+18
-17
@@ -39,28 +39,29 @@ static int cfg_dir_filter(const char *file)
|
|||||||
return ! !strcmp(file, STARTUP_CONFIG);
|
return ! !strcmp(file, STARTUP_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int is_startup_config(const char *entry)
|
||||||
|
{
|
||||||
|
static int once = 1;
|
||||||
|
static char file[80];
|
||||||
|
|
||||||
|
if (once) {
|
||||||
|
int len = readlink(STARTUP_CONFIG, file, sizeof(file));
|
||||||
|
|
||||||
|
if (len == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
file[len] = 0;
|
||||||
|
once = 0; /* Only once per call to dir() */
|
||||||
|
}
|
||||||
|
//printf ("Comparing link %s with entry %s\n", file, entry);
|
||||||
|
return !strcmp(file, entry);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int i, num;
|
int i, num;
|
||||||
char *type = DIR_TYPE_CONFIG;
|
char *type = DIR_TYPE_CONFIG;
|
||||||
char **files;
|
char **files;
|
||||||
int once = 1;
|
|
||||||
|
|
||||||
int is_startup_config(const char *entry) {
|
|
||||||
static char file[80];
|
|
||||||
|
|
||||||
if (once) {
|
|
||||||
int len = readlink(STARTUP_CONFIG, file, sizeof(file));
|
|
||||||
|
|
||||||
if (len == -1)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
file[len] = 0;
|
|
||||||
once = 0; /* Only once per call to dir() */
|
|
||||||
}
|
|
||||||
//printf ("Comparing link %s with entry %s\n", file, entry);
|
|
||||||
return !strcmp(file, entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
simulate_files(1);
|
simulate_files(1);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user