2020-06-05 00:17:17 +02:00
|
|
|
/*
|
|
|
|
tentatives de lecture des OBJ
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2023-03-30 05:39:36 +02:00
|
|
|
#include <libgen.h> // for basename(3)
|
2023-04-27 23:59:59 +02:00
|
|
|
#include <unistd.h>
|
2023-03-30 05:39:36 +02:00
|
|
|
|
2020-06-05 00:17:17 +02:00
|
|
|
#include "../bubulles.h"
|
2023-04-20 22:55:46 +02:00
|
|
|
#include "../edges.h"
|
2020-06-05 00:17:17 +02:00
|
|
|
|
2023-04-22 10:31:50 +02:00
|
|
|
#include "objtrucs.h"
|
2023-03-30 05:39:36 +02:00
|
|
|
|
|
|
|
int verbosity = 0;
|
2020-06-05 01:05:01 +02:00
|
|
|
|
2023-04-27 23:59:59 +02:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
void help(void)
|
|
|
|
{
|
2023-05-02 10:06:24 +02:00
|
|
|
printf("### READ_OBJ 0X%X TALKING\n", getpid());
|
2023-05-01 11:57:07 +02:00
|
|
|
puts("usage:");
|
2023-05-02 10:06:24 +02:00
|
|
|
puts("\t-h\t\tthis help (use -v -h for more");
|
2023-05-01 11:57:07 +02:00
|
|
|
puts("\t-o fname\tfix the output filename");
|
2023-05-02 10:06:24 +02:00
|
|
|
puts("\t-v\t\tincrease verbosity");
|
2023-05-01 11:57:07 +02:00
|
|
|
|
2023-04-27 23:59:59 +02:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
2020-06-05 00:17:17 +02:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2023-04-27 23:59:59 +02:00
|
|
|
int foo, opt;
|
2023-04-30 01:03:49 +02:00
|
|
|
char *ofname = NULL;
|
2020-06-05 00:17:17 +02:00
|
|
|
|
2023-05-02 10:06:24 +02:00
|
|
|
fprintf(stderr, "### READ_OBJ compiled %s at %s\n", __DATE__, __TIME__);
|
2023-04-03 00:52:09 +02:00
|
|
|
|
2023-04-27 23:59:59 +02:00
|
|
|
if (1 == argc) {
|
2020-06-05 00:17:17 +02:00
|
|
|
bubulles_version(1);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2023-04-30 01:03:49 +02:00
|
|
|
while ((opt = getopt(argc, argv, "ho:v")) != -1) {
|
2023-04-27 23:59:59 +02:00
|
|
|
switch(opt) {
|
|
|
|
case 'h':
|
|
|
|
help(); break;
|
2023-04-30 01:03:49 +02:00
|
|
|
case 'o':
|
|
|
|
ofname = optarg;
|
|
|
|
break;
|
2023-04-27 23:59:59 +02:00
|
|
|
case 'v':
|
|
|
|
verbosity++; break;
|
|
|
|
default:
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-03-30 05:39:36 +02:00
|
|
|
|
2023-04-27 23:59:59 +02:00
|
|
|
if (optind < argc) {
|
2023-05-02 10:06:24 +02:00
|
|
|
if (verbosity) fprintf(stderr, " arg[%d] = %s\n",
|
|
|
|
optind, argv[optind]);
|
2023-04-30 01:03:49 +02:00
|
|
|
foo = try_to_read_an_OBJ_file(argv[optind], ofname, 0);
|
2023-04-27 23:59:59 +02:00
|
|
|
if (foo) {
|
2023-05-02 10:06:24 +02:00
|
|
|
fprintf(stderr, "Error number %d on '%s'\n",
|
|
|
|
foo, argv[optind]);
|
2023-04-27 23:59:59 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "%s need a input filename\n", argv[0]);
|
|
|
|
exit(1);
|
|
|
|
}
|
2020-06-05 00:17:17 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|