adding help() to test program

This commit is contained in:
tth 2019-02-22 15:55:50 +01:00
parent c0f3e128aa
commit c381b61b60

View File

@ -51,6 +51,14 @@ for (count=0; count<iters; count++) {
return 0; return 0;
} }
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
void help(int k)
{
puts("options : ");
puts("\t-d\tserial device to read.");
puts("\t-n\tnumber of records to grab.");
puts("\t-v\tincrease verbosity.");
}
/* ---------------------------------------------------------------- */
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
int serial_in; int serial_in;
@ -62,12 +70,12 @@ verbosity = 0;
nbre = 25; nbre = 25;
speed = 9600; speed = 9600;
while ((opt = getopt(argc, argv, "d:n:v")) != -1) { while ((opt = getopt(argc, argv, "d:n:vh")) != -1) {
switch (opt) { switch (opt) {
case 'v': verbosity++; break; case 'v': verbosity++; break;
case 'n': nbre = atoi(optarg); break; case 'n': nbre = atoi(optarg); break;
case 'd': device = optarg; break; case 'd': device = optarg; break;
case 'h': help(0); exit(0);
default: default:
fprintf(stderr, "%s : uh ?", argv[0]); fprintf(stderr, "%s : uh ?", argv[0]);
exit(1); exit(1);