1
0
mirror of git://projects.qi-hardware.com/ben-blinkenlights.git synced 2024-12-28 03:46:48 +02:00

ubbctl/ubbctl.c (main): add command line processing and usage display

This commit is contained in:
Werner Almesberger 2013-01-06 09:54:54 -03:00
parent e6a0e42296
commit 33085cee44

View File

@ -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;