adding command line options
This commit is contained in:
parent
a823bdae0c
commit
9c336eed8c
@ -5,6 +5,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libgen.h> // for basename(3)
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../bubulles.h"
|
||||
#include "../edges.h"
|
||||
@ -13,22 +14,51 @@
|
||||
|
||||
int verbosity = 0;
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
void help(void)
|
||||
{
|
||||
printf("nothing to say...\n");
|
||||
exit(0);
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo;
|
||||
char *fname; /* see manpage basename(3) */
|
||||
int foo, opt;
|
||||
// char *fname; /* see manpage basename(3) */
|
||||
|
||||
fprintf(stderr, "\n### READ_OBJ compiled %s at %s\n", __DATE__, __TIME__);
|
||||
|
||||
if (2 != argc) {
|
||||
if (1 == argc) {
|
||||
bubulles_version(1);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
verbosity = 0;
|
||||
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
||||
switch(opt) {
|
||||
case 'h':
|
||||
help(); break;
|
||||
case 'v':
|
||||
verbosity++; break;
|
||||
default:
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foo = try_to_read_an_OBJ_file(argv[1], 0);
|
||||
fprintf(stderr, "try to read '%s' -> %d\n", argv [1], foo);
|
||||
|
||||
if (optind < argc) {
|
||||
// fprintf(stderr, "ARG = %s\n", argv[optind]);
|
||||
foo = try_to_read_an_OBJ_file(argv[optind], 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "Error number %d on '%s'\n", foo, argv[optind]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s need a input filename\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user