#include <getopt.h>
static const struct option longopts[] = {
- { "help", no_argument, NULL, 'h' },
+ { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'v' },
{ 0 },
};
-static const char *const shortopts = "+h";
+static const char *const shortopts = "+hv";
static void print_help(void)
{
printf("List all GPIO chips\n");
printf("Options:\n");
printf(" -h, --help:\t\tdisplay this message and exit\n");
+ printf(" -v, --version:\tdisplay the version and exit\n");
}
int main(int argc, char **argv)
case 'h':
print_help();
return EXIT_SUCCESS;
+ case 'v':
+ print_version();
+ return EXIT_SUCCESS;
case '?':
die("try %s --help", get_progname());
default:
#include <getopt.h>
static const struct option longopts[] = {
- { "help", no_argument, NULL, 'h' },
+ { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'v' },
{ 0 },
};
-static const char *const shortopts = "+h";
+static const char *const shortopts = "+hv";
static void print_help(void)
{
printf("Find a GPIO line by name.\n");
printf("Options:\n");
printf(" -h, --help:\t\tdisplay this message and exit\n");
+ printf(" -v, --version:\tdisplay the version and exit\n");
}
int main(int argc, char **argv)
case 'h':
print_help();
return EXIT_SUCCESS;
+ case 'v':
+ print_version();
+ return EXIT_SUCCESS;
case '?':
die("try %s --help", get_progname());
default:
static const struct option longopts[] = {
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'v' },
{ "active-low", no_argument, NULL, 'l' },
{ 0 },
};
-static const char *const shortopts = "hl";
+static const char *const shortopts = "hvl";
static void print_help(void)
{
printf("Read value from a GPIO line\n");
printf("Options:\n");
printf(" -h, --help:\t\tdisplay this message and exit\n");
+ printf(" -v, --version:\tdisplay the version and exit\n");
printf(" -l, --active-low:\tset the line active state to low\n");
}
case 'h':
print_help();
return EXIT_SUCCESS;
+ case 'v':
+ print_version();
+ return EXIT_SUCCESS;
case 'l':
active_low = true;
break;
};
static const struct option longopts[] = {
- { "help", no_argument, NULL, 'h' },
+ { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'v' },
{ 0 },
};
-static const char *const shortopts = "+h";
+static const char *const shortopts = "+hv";
static void print_help(void)
{
printf("List all lines of a GPIO chip.\n");
printf("Options:\n");
printf(" -h, --help:\t\tdisplay this message and exit\n");
+ printf(" -v, --version:\tdisplay the version and exit\n");
}
static PRINTF(3, 4) void prinfo(bool *overflow,
case 'h':
print_help();
return EXIT_SUCCESS;
+ case 'v':
+ print_version();
+ return EXIT_SUCCESS;
case '?':
die("try %s --help", get_progname());
default:
static const struct option longopts[] = {
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'v' },
{ "active-low", no_argument, NULL, 'l' },
{ 0 },
};
-static const char *const shortopts = "hl";
+static const char *const shortopts = "hvl";
static void print_help(void)
{
printf("Wait for events on a GPIO line\n");
printf("Options:\n");
printf(" -h, --help:\t\tdisplay this message and exit\n");
+ printf(" -v, --version:\tdisplay the version and exit\n");
printf(" -l, --active-low:\tset the line active state to low\n");
}
case 'h':
print_help();
return EXIT_SUCCESS;
+ case 'v':
+ print_version();
+ return EXIT_SUCCESS;
case 'l':
active_low = true;
break;
static const struct option longopts[] = {
{ "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'v' },
{ "active-low", no_argument, NULL, 'l' },
{ 0 },
};
-static const char *const shortopts = "hl";
+static const char *const shortopts = "hvl";
static void print_help(void)
{
printf("Set value of a GPIO line\n");
printf("Options:\n");
printf(" -h, --help:\t\tdisplay this message and exit\n");
+ printf(" -v, --version:\tdisplay the version and exit\n");
printf(" -l, --active-low:\tset the line active state to low\n");
printf("\n");
printf("This program reserves the GPIO line, sets its value and waits for the user to press ENTER before releasing the line\n");
case 'h':
print_help();
return EXIT_SUCCESS;
+ case 'v':
+ print_version();
+ return EXIT_SUCCESS;
case 'l':
active_low = true;
break;