}
static char * get_file_name(char *name){
- char *fname;
- fname= (char*)malloc(OPJ_PATH_LEN*sizeof(char));
- fname= strtok(name,".");
+ char *fname = strtok(name,".");
return fname;
}
OPJ_UINT32 numlayers = 0, numresolution = 0, matrix_width = 0;
char *s = opj_optarg;
- sscanf(s, "%d", &numlayers);
+ sscanf(s, "%ud", &numlayers);
s++;
if (numlayers > 9)
s++;
int res_spec = 0;
char *s = opj_optarg;
+ int ret;
do {
sep = 0;
- sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
+ ret = sscanf(s, "[%d,%d]%c", ¶meters->prcw_init[res_spec],
¶meters->prch_init[res_spec], &sep);
+ if( !(ret == 2 && sep == 0) && !(ret == 3 && sep == ',') )
+ {
+ fprintf(stderr,"\nError: could not parse precinct dimension: '%s' %x\n", s, sep);
+ fprintf(stderr,"Example: -i lena.raw -o lena.j2k -c [128,128],[128,128]\n");
+ return 1;
+ }
parameters->csty |= 0x01;
res_spec++;
s = strpbrk(s, "]") + 2;
char *s = opj_optarg;
POC = parameters->POC;
- while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%4s", &POC[numpocs].tile,
+ while (sscanf(s, "T%ud=%ud,%ud,%ud,%ud,%ud,%4s", &POC[numpocs].tile,
&POC[numpocs].resno0, &POC[numpocs].compno0,
&POC[numpocs].layno1, &POC[numpocs].resno1,
&POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
float *lCurrentDoublePtr;
float *lSpace;
int *l_int_ptr;
- int lNbComp = 0, lTotalComp, lMctComp, i, lStrLen;
+ int lNbComp = 0, lTotalComp, lMctComp, i; long int lStrLen, lStrFread;
/* Open file */
FILE * lFile = fopen(lFilename,"r");
lStrLen = ftell(lFile);
fseek(lFile,0,SEEK_SET);
lMatrix = (char *) malloc(lStrLen + 1);
- fread(lMatrix, lStrLen, 1, lFile);
+ lStrFread = fread(lMatrix, 1, lStrLen, lFile);
fclose(lFile);
+ if( lStrLen != lStrFread ) return 1;
lMatrix[lStrLen] = 0;
lCurrentPtr = lMatrix;
/* -------------------------------------------------------------------------- */
-/**
-sample error callback expecting a FILE* client object
-*/
-static void error_file_callback(const char *msg, void *client_data) {
- FILE *stream = (FILE*)client_data;
- fprintf(stream, "[ERROR] %s", msg);
-}
-/**
-sample warning callback expecting a FILE* client object
-*/
-static void warning_file_callback(const char *msg, void *client_data) {
- FILE *stream = (FILE*)client_data;
- fprintf(stream, "[WARNING] %s", msg);
-}
-/**
-sample debug callback expecting a FILE* client object
-*/
-static void info_file_callback(const char *msg, void *client_data) {
- FILE *stream = (FILE*)client_data;
- fprintf(stream, "[INFO] %s", msg);
-}
-
/**
sample error debug callback expecting no client object
*/