From b662128708cefc75a84e6b0d1b257a17ea957e2a Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 12 May 2019 16:14:25 +1000 Subject: [PATCH] [c-host] linux: implemented `getValues` support for shmDevice option --- VERSION | 2 +- c-host/platform/Linux/src/platform.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 5980e52f..28c08d81 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -a12-184-g5d69d2aba9+1 \ No newline at end of file +a12-185-ge22f33a44b+1 \ No newline at end of file diff --git a/c-host/platform/Linux/src/platform.c b/c-host/platform/Linux/src/platform.c index 24db6813..5c79dcae 100644 --- a/c-host/platform/Linux/src/platform.c +++ b/c-host/platform/Linux/src/platform.c @@ -141,12 +141,13 @@ static bool shmDeviceValidator(struct Option * opt, const char ** error) return true; } -static void shmDevicePrintHelp() +static StringList shmDeviceGetValues(struct Option * option) { - printf("Valid devices are:\n\n"); + StringList sl = stringlist_new(true); + DIR * d = opendir("/sys/class/uio"); if (!d) - return; + return sl; struct dirent * dir; while((dir = readdir(d)) != NULL) @@ -159,12 +160,13 @@ static void shmDevicePrintHelp() continue; if (strcmp(name, "KVMFR") == 0) - printf(" * %s\n", dir->d_name); + stringlist_push(sl, strdup(dir->d_name)); free(name); } closedir(d); + return sl; } int main(int argc, char * argv[]) @@ -180,7 +182,7 @@ int main(int argc, char * argv[]) .type = OPTION_TYPE_STRING, .value.x_string = "uio0", .validator = shmDeviceValidator, - .printHelp = shmDevicePrintHelp + .getValues = shmDeviceGetValues }, {0} };