summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Malaterre <mathieu.malaterre@gmail.com>2012-04-20 11:15:48 +0000
committerMathieu Malaterre <mathieu.malaterre@gmail.com>2012-04-20 11:15:48 +0000
commit6b649f3bf6319543d6e2c73d7b6d54d222da8b67 (patch)
tree3b4c761c930935a203ddb5c22eac5f8ed92da339
parent65f8ae765ee8a5bceec442641209658bef17da83 (diff)
[1.5] Need to compile/install tool to embed XML file in JP2 for jpip server
-rw-r--r--applications/jpip/util/CMakeLists.txt8
-rw-r--r--applications/jpip/util/addXMLinJP2.c20
2 files changed, 18 insertions, 10 deletions
diff --git a/applications/jpip/util/CMakeLists.txt b/applications/jpip/util/CMakeLists.txt
index 060d3c98..dbce6e48 100644
--- a/applications/jpip/util/CMakeLists.txt
+++ b/applications/jpip/util/CMakeLists.txt
@@ -4,6 +4,14 @@ INCLUDE_DIRECTORIES(
${FCGI_INCLUDE_DIRS}
)
+# Tool to embed metadata into JP2 file
+ADD_EXECUTABLE(addXMLinJP2 addXMLinJP2.c)
+# Install exe
+INSTALL(TARGETS addXMLinJP2
+ EXPORT OpenJPEGTargets
+ DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
+ )
+
IF(BUILD_JPIP_SERVER)
SET(OPJ_SERVER_SRCS
diff --git a/applications/jpip/util/addXMLinJP2.c b/applications/jpip/util/addXMLinJP2.c
index 6cb3c83e..a12445bd 100644
--- a/applications/jpip/util/addXMLinJP2.c
+++ b/applications/jpip/util/addXMLinJP2.c
@@ -73,15 +73,15 @@ char * read_xmlfile( char filename[], long *fsize);
int main(int argc, char *argv[])
{
+ FILE *fp;
+ char *xmldata, type[]="xml ";
+ long fsize, boxsize;
+
if( argc<3){
fprintf( stderr, "USAGE: ./addXMLinJP2 modifing.jp2 adding.xml\n");
return -1;
}
- FILE *fp;
- char *xmldata, type[]="xml ";
- long fsize, boxsize;
-
fp = open_jp2file( argv[1]);
if( !fp)
return -1;
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
fputc( (boxsize>>8)&0xff, fp);
fputc( boxsize&0xff, fp);
fwrite( type, 4, 1, fp);
- fwrite( xmldata, fsize, 1, fp);
+ fwrite( xmldata, (size_t)fsize, 1, fp);
free( xmldata);
fclose(fp);
@@ -111,14 +111,14 @@ FILE * open_jp2file( char filename[])
fprintf( stderr, "Original JP2 %s not found\n", filename);
return NULL;
}
- // Check resource is a JP family file.
+ /* Check resource is a JP family file. */
if( fseek( fp, 0, SEEK_SET)==-1){
fclose(fp);
fprintf( stderr, "Original JP2 %s broken (fseek error)\n", filename);
return NULL;
}
- data = (char *)malloc( 12); // size of header
+ data = (char *)malloc( 12); /* size of header */
if( fread( data, 12, 1, fp) != 1){
free( data);
fclose(fp);
@@ -142,7 +142,7 @@ char * read_xmlfile( char filename[], long *fsize)
FILE *fp;
char *data;
- // fprintf( stderr, "open %s\n", filename);
+ /* fprintf( stderr, "open %s\n", filename); */
if(!(fp = fopen( filename, "r"))){
fprintf( stderr, "XML file %s not found\n", filename);
return NULL;
@@ -166,9 +166,9 @@ char * read_xmlfile( char filename[], long *fsize)
return NULL;
}
- data = (char *)malloc( *fsize);
+ data = (char *)malloc( (size_t)*fsize);
- if( fread( data, *fsize, 1, fp) != 1){
+ if( fread( data, (size_t)*fsize, 1, fp) != 1){
fprintf( stderr, "XML file %s broken (read error)\n", filename);
free( data);
fclose(fp);