summaryrefslogtreecommitdiff
path: root/applications
diff options
context:
space:
mode:
authorAntonin Descampe <antonin@gmail.com>2015-09-15 18:00:52 +0200
committerAntonin Descampe <antonin@gmail.com>2015-09-15 18:00:52 +0200
commit31e35fcf7b1023335d4658d65d4a75be83bae0fb (patch)
tree7629b1e06a306bdb5f0cdb3c0eb0e26b8ee9ba9f /applications
parent2d47938b25526e29b88d379057cc9ffa293e6dfd (diff)
preventde seg fault when unknown long options and fixed ability to use USE_SYSTEM_GETOPT
Diffstat (limited to 'applications')
-rw-r--r--applications/codec/image_to_j2k.c14
-rw-r--r--applications/codec/j2k_dump.c6
-rw-r--r--applications/codec/j2k_to_image.c10
3 files changed, 18 insertions, 12 deletions
diff --git a/applications/codec/image_to_j2k.c b/applications/codec/image_to_j2k.c
index d9cafd6a..297d19a2 100644
--- a/applications/codec/image_to_j2k.c
+++ b/applications/codec/image_to_j2k.c
@@ -591,7 +591,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
{"POC",REQ_ARG, NULL ,'P'},
{"ROI",REQ_ARG, NULL ,'R'},
{"jpip",NO_ARG, NULL, 'J'},
- {0,0,0,0} /* GNU getopt_long requirement */
+#ifdef USE_SYSTEM_GETOPT
+ {0,0,0,0} /* GNU getopt_long requirement */
+#endif
};
/* parse the command line */
@@ -601,7 +603,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
#endif /* USE_JPWL */
"h";
- totlen=sizeof(long_option)-1;
+ totlen=sizeof(long_option);
img_fol->set_out_format=0;
raw_cp->rawWidth = 0;
@@ -1391,10 +1393,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
- default:
- fprintf(stderr, "ERROR -> Command line not valid\n");
- return 1;
- }
+ default:
+ fprintf(stderr, "[WARNING] An invalid option has been ignored\n");
+ break;
+ }
}while(c != -1);
/* check for possible errors */
diff --git a/applications/codec/j2k_dump.c b/applications/codec/j2k_dump.c
index 63cce3a2..3b321a45 100644
--- a/applications/codec/j2k_dump.c
+++ b/applications/codec/j2k_dump.c
@@ -201,13 +201,15 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
int totlen, c;
opj_option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'},
+#ifdef USE_SYSTEM_GETOPT
{0,0,0,0} /* GNU getopt_long requirement */
+#endif
};
const char optlist[] = "i:o:h";
OPJ_ARG_NOT_USED(indexfilename);
- totlen=sizeof(long_option)-1;
+ totlen=sizeof(long_option);
img_fol->set_out_format = 0;
do {
#ifdef USE_SYSTEM_GETOPT
@@ -265,7 +267,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
/* ----------------------------------------------------- */
default:
- fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
+ fprintf(stderr,"[WARNING] An invalid option has been ignored\n");
break;
}
}while(c != -1);
diff --git a/applications/codec/j2k_to_image.c b/applications/codec/j2k_to_image.c
index 6f215a2c..43dc7c35 100644
--- a/applications/codec/j2k_to_image.c
+++ b/applications/codec/j2k_to_image.c
@@ -242,8 +242,10 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
int totlen, c;
opj_option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'},
- {"OutFor",REQ_ARG, NULL ,'O'},
- {0,0,0,0} /* GNU getopt_long requirement */
+ {"OutFor",REQ_ARG, NULL ,'O'},
+#ifdef USE_SYSTEM_GETOPT
+ {0,0,0,0} /* GNU getopt_long requirement */
+#endif
};
const char optlist[] = "i:o:r:l:x:"
@@ -254,7 +256,7 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
#endif /* USE_JPWL */
/* <<UniPG */
"h" ;
- totlen=sizeof(long_option) - 1;
+ totlen=sizeof(long_option);
img_fol->set_out_format = 0;
do {
#ifdef USE_SYSTEM_GETOPT
@@ -461,7 +463,7 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param
/* ----------------------------------------------------- */
default:
- fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg);
+ fprintf(stderr,"[WARNING] An invalid option has been ignored\n");
break;
}
}while(c != -1);