added basic options handling

This commit is contained in:
tth 2018-12-05 18:14:52 +01:00
parent 15dd4f6296
commit 495a7cf3cf
2 changed files with 20 additions and 3 deletions

View File

@ -3,16 +3,33 @@
*/
#include <stdio.h>
#include <unistd.h>
#include "funcs.h"
int verbosity;
/* --------------------------------------------------------------- */
int main(int argc, char *argv[])
{
fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__);
int opt;
while ((opt = getopt(argc, argv, "v")) != -1) {
switch (opt) {
case 'v': verbosity++; break;
default: break;
}
}
if (verbosity > 1)
fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__);
verbosity = 1;
printf("%f %d\n", dtime(), random1000(0));
return 0;
}
/* --------------------------------------------------------------- */

View File

@ -16,7 +16,7 @@ int random1000(int foo)
{
int value;
if (verbosity)
fprintf(stderr, "%s(%d)\n", __func__, foo);
fprintf(stderr, ">>> %s(%d)\n", __func__, foo);
value = rand() % 1000;
return value;
}