add -o option (output filename)
This commit is contained in:
parent
7cefa36d62
commit
b12bdfe306
@ -175,9 +175,9 @@ return 0;
|
|||||||
}
|
}
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
/*
|
/*
|
||||||
*
|
* The main procedure, who contains a lot of things.
|
||||||
*/
|
*/
|
||||||
int try_to_read_an_OBJ_file(char *infname, int outstyle)
|
int try_to_read_an_OBJ_file(char *infname, char *ofname, int outstyle)
|
||||||
{
|
{
|
||||||
FILE *fpin;
|
FILE *fpin;
|
||||||
char line[LINE_SZ+1], *cptr, *token;
|
char line[LINE_SZ+1], *cptr, *token;
|
||||||
@ -188,7 +188,8 @@ Bubulle bubulle;
|
|||||||
char *outfname, *baseptr;
|
char *outfname, *baseptr;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, ">>> %s ( '%s' %d )\n\n", __func__, infname, outstyle);
|
fprintf(stderr, ">>> %s ( '%s' '%s' %d )\n\n", __func__,
|
||||||
|
infname, ofname, outstyle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* get memory for generated output filename(s) */
|
/* get memory for generated output filename(s) */
|
||||||
@ -314,8 +315,8 @@ fclose(fpin);
|
|||||||
fprintf(stderr, " ***************************************\n");
|
fprintf(stderr, " ***************************************\n");
|
||||||
|
|
||||||
if(verbosity) {
|
if(verbosity) {
|
||||||
fprintf(stderr, "%s(): %d vertices loaded\n", __func__, bublist->fidx);
|
fprintf(stderr, "%s(): %9d vertices loaded\n", __func__, bublist->fidx);
|
||||||
fprintf(stderr, "%s(): %d edges loaded\n", __func__, edges->fidx);
|
fprintf(stderr, "%s(): %9d edges loaded\n", __func__, edges->fidx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbosity > 1) {
|
if (verbosity > 1) {
|
||||||
@ -323,7 +324,7 @@ if (verbosity > 1) {
|
|||||||
print_edgelist_desc(edges, 0);
|
print_edgelist_desc(edges, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outstyle) { /* two ascii files */
|
if (outstyle) { /* two ascii files */
|
||||||
strcpy(outfname, infname);
|
strcpy(outfname, infname);
|
||||||
cptr = rindex(outfname, '.');
|
cptr = rindex(outfname, '.');
|
||||||
fprintf(stderr, "rindex -> [%s]\n", cptr);
|
fprintf(stderr, "rindex -> [%s]\n", cptr);
|
||||||
@ -331,15 +332,23 @@ if (outstyle) { /* two ascii files */
|
|||||||
bubulles_to_data(outfname, NULL, bublist, 0);
|
bubulles_to_data(outfname, NULL, bublist, 0);
|
||||||
// edges_to_data(file_edges, edges, 0);
|
// edges_to_data(file_edges, edges, 0);
|
||||||
}
|
}
|
||||||
else { /* one 'evblob' file */
|
else { /* one 'evblob' file */
|
||||||
strcpy(outfname, infname);
|
if (NULL == ofname) {
|
||||||
/* see manpage basename(3) */
|
strcpy(outfname, infname);
|
||||||
baseptr = basename(outfname);
|
/* see manpage basename(3) */
|
||||||
// fprintf(stderr, "baseptr -> [%s]\n", baseptr);
|
baseptr = basename(outfname);
|
||||||
cptr = rindex(baseptr, '.');
|
// fprintf(stderr, "baseptr -> [%s]\n", baseptr);
|
||||||
strcpy(cptr, ".evblob");
|
cptr = rindex(baseptr, '.');
|
||||||
// fprintf(stderr, "baseptr-> [%s]\n", baseptr);
|
strcpy(cptr, ".evblob");
|
||||||
foo = x_write_vertedges(baseptr, bublist, edges);
|
fprintf(stderr, "baseptr-> [%s]\n", baseptr);
|
||||||
|
cptr = baseptr;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cptr = ofname;
|
||||||
|
fprintf(stderr, "writing to %s\n", cptr);
|
||||||
|
}
|
||||||
|
foo = x_write_vertedges(cptr, bublist, edges);
|
||||||
|
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "Err #%d when writing edges&vertices file\n", foo);
|
fprintf(stderr, "Err #%d when writing edges&vertices file\n", foo);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ typedef struct {
|
|||||||
} EdgesAndVertices;
|
} EdgesAndVertices;
|
||||||
|
|
||||||
/* in importobj.c */
|
/* in importobj.c */
|
||||||
int try_to_read_an_OBJ_file(char *fname, int outstyle);
|
int try_to_read_an_OBJ_file(char *fname, char *oname, int outstyle);
|
||||||
|
|
||||||
/* in rdwredges.c */
|
/* in rdwredges.c */
|
||||||
int x_write_vertedges (char *filename, BBList *bblist, EdgeList *edges);
|
int x_write_vertedges (char *filename, BBList *bblist, EdgeList *edges);
|
||||||
|
@ -25,7 +25,7 @@ exit(0);
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int foo, opt;
|
int foo, opt;
|
||||||
// char *fname; /* see manpage basename(3) */
|
char *ofname = NULL;
|
||||||
|
|
||||||
fprintf(stderr, "\n### READ_OBJ compiled %s at %s\n", __DATE__, __TIME__);
|
fprintf(stderr, "\n### READ_OBJ compiled %s at %s\n", __DATE__, __TIME__);
|
||||||
|
|
||||||
@ -34,10 +34,13 @@ if (1 == argc) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "hv")) != -1) {
|
while ((opt = getopt(argc, argv, "ho:v")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
help(); break;
|
help(); break;
|
||||||
|
case 'o':
|
||||||
|
ofname = optarg;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbosity++; break;
|
verbosity++; break;
|
||||||
default:
|
default:
|
||||||
@ -48,8 +51,8 @@ while ((opt = getopt(argc, argv, "hv")) != -1) {
|
|||||||
|
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
// fprintf(stderr, "ARG = %s\n", argv[optind]);
|
fprintf(stderr, "arg = %s\n", argv[optind]);
|
||||||
foo = try_to_read_an_OBJ_file(argv[optind], 0);
|
foo = try_to_read_an_OBJ_file(argv[optind], ofname, 0);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "Error number %d on '%s'\n", foo, argv[optind]);
|
fprintf(stderr, "Error number %d on '%s'\n", foo, argv[optind]);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user