mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-12-03 21:04:39 +02:00
ubbctl/ubbctl.c (main): add command line processing and usage display
This commit is contained in:
parent
e6a0e42296
commit
33085cee44
@ -12,7 +12,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ubb/ubb.h>
|
||||
|
||||
@ -44,14 +46,36 @@ static void show_pins(void)
|
||||
printf("%d", !!(PDDAT & p->mask));
|
||||
else
|
||||
putchar(PDPULL & p->mask ? 'Z' : 'R');
|
||||
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s\n"
|
||||
, name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = getopt(argc, argv, "")) != EOF)
|
||||
switch (c) {
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
|
||||
switch (argc-optind) {
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
|
||||
ubb_open(UBB_ALL);
|
||||
show_pins();
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user