added timestamp parameter to cmdln, but it is not used, yet

This commit is contained in:
tkarrass 2013-11-02 19:55:55 +01:00
parent 69580b7b29
commit 4cf5b1c5f4
2 changed files with 23 additions and 1 deletions

View File

@ -15,9 +15,17 @@ int parseArgs(struct prog_info *pinfo, int argc, char **argv) {
pinfo->mode = MODE_SERVER;
pinfo->client_num = 1;
pinfo->port = 4711;
pinfo->fps = 10;
if (argc <= 1) {
printf("usage: %s [-s|-c <num>] [-p <port>]\n", argv[0]);
printf("usage: %s [-s|-c <off>] [-p <port>] [-t <fps>]\n", argv[0]);
printf("where:\n -s run in server mode\n");
printf( " -c <num> run in client mode\n");
printf( " num is the column offset to use.\n");
printf( " -p <port> use the specified port\n");
printf( " -t <fps> when in server mode: update <fps> times per second\n");
printf( " no use in client mode\n");
printf("\n\n");
return -1;
}
int i;
@ -51,6 +59,19 @@ int parseArgs(struct prog_info *pinfo, int argc, char **argv) {
}
continue;
}
if (strncmp(argv[i], "-t", 2) == 0) {
if (argc <= i+1) {
printf("fps not specified\n");
return -6;
}
pinfo->fps = (int)strtol(argv[++i], NULL, 10);
if (pinfo->fps <= 0 || 50 <= pinfo->fps) {
printf("fps invalid!\n");
return -7;
}
continue;
}
printf("unknown argument %s\n", argv[i]);
return -6;
}

View File

@ -5,6 +5,7 @@ struct prog_info {
int mode;
int client_num;
int port;
int fps;
} prog_info;
#endif