]> Creatis software - gdcm.git/blobdiff - src/gdcmjpegls/Decoder/global.c
ENH: Change the unsafe type char to the full enum type. Much safer, and special flags...
[gdcm.git] / src / gdcmjpegls / Decoder / global.c
index 62922b4fb062516dfee600232420bbd58f295599..5ec5c37d8f0f6bb92c9836e694edf073a2343760 100644 (file)
 
 #include <time.h>
 #include "global.h"
 
 #include <time.h>
 #include "global.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#else
+#include <io.h>
+#endif
 
 
 
 
 
 
-char *disclaimer = "\
+char disclaimer[] = "\
 This program is Copyright (c) University of British Columbia.\n\
 All rights reserved. It may be freely redistributed in its\n\
 entirety provided that this copyright notice is not removed.\n\
 This program is Copyright (c) University of British Columbia.\n\
 All rights reserved. It may be freely redistributed in its\n\
 entirety provided that this copyright notice is not removed.\n\
@@ -69,7 +74,7 @@ without the written permission of the copyright holder.\n\
 FILE *in, *out;
 FILE *c_in[MAX_COMPONENTS];
 FILE *c_out[MAX_COMPONENTS];
 FILE *in, *out;
 FILE *c_in[MAX_COMPONENTS];
 FILE *c_out[MAX_COMPONENTS];
-FILE *msgfile = stdout;
+FILE *msgfile = NULL; /* = stdout;*/
 
 /* Context quantization thresholds  - initially unset */
 int     T3 = -1,
 
 /* Context quantization thresholds  - initially unset */
 int     T3 = -1,
@@ -98,14 +103,10 @@ int bpp,    /* bits per sample */
     limit_reduce;  /* reduction on above for EOR states */
 
 
     limit_reduce;  /* reduction on above for EOR states */
 
 
-/* define color mode strings */
-char *plane_int_string = "plane by plane",
-   *line_int_string = "line intlv",
-   *pixel_int_string = "sample intlv";
 
 
 /* function to print out error messages */
 
 
 /* function to print out error messages */
-void error(char *msg) {
+void error(const char *msg) {
   fprintf(stderr, msg);
   exit(-1);
 }
   fprintf(stderr, msg);
   exit(-1);
 }
@@ -140,14 +141,15 @@ void *safecalloc(size_t numels, size_t size) {
 
 double get_utime()
 {
 
 double get_utime()
 {
-  clock_t c;
+  /*clock_t c;
+  (void)c;*/
 
   return (double)clock()/CLOCKS_PER_SEC;
 }
 
 
 /* Set thresholds to default unless specified by header: */
 
   return (double)clock()/CLOCKS_PER_SEC;
 }
 
 
 /* Set thresholds to default unless specified by header: */
-set_thresholds(int alfa, int NEAR, int *T1p, int *T2p, int *T3p)
+int set_thresholds(int alfa, int NEAR, int *T1p, int *T2p, int *T3p)
 {
   int lambda,
       ilambda = 256/alfa,
 {
   int lambda,
       ilambda = 256/alfa,
@@ -155,6 +157,8 @@ set_thresholds(int alfa, int NEAR, int *T1p, int *T2p, int *T3p)
       T1 = *T1p, 
       T2 = *T2p, 
       T3 = *T3p;
       T1 = *T1p, 
       T2 = *T2p, 
       T3 = *T3p;
+  /* Unused */
+  (void)quant;
   
   if (alfa<4096)
      lambda = (alfa+127)/256;
   
   if (alfa<4096)
      lambda = (alfa+127)/256;
@@ -220,7 +224,7 @@ set_thresholds(int alfa, int NEAR, int *T1p, int *T2p, int *T3p)
 
 /* We first check compatibility with JPEG-LS, then with this implementation */
 
 
 /* We first check compatibility with JPEG-LS, then with this implementation */
 
-void check_compatibility(jpeg_ls_header *head_frame, jpeg_ls_header *head_scan, int n_s) 
+void check_compatibility(jpeg_ls_header *head_frame, jpeg_ls_header *head_scan, int n_s)
 {
 
     int  number_of_scans,i;  
 {
 
     int  number_of_scans,i;  
@@ -318,35 +322,35 @@ void check_compatibility(jpeg_ls_header *head_frame, jpeg_ls_header *head_scan,
 
 /* for writing disclaimer to command line in DOS */
 
 
 /* for writing disclaimer to command line in DOS */
 
-char *ttyfilename = "CON";
+char ttyfilename[] = "CON";
 
 #define PAUSE  20
 
 
 #define PAUSE  20
 
-fprint_disclaimer(FILE *fp, int nopause)
+void fprint_disclaimer(FILE *fp, int nopause)
 {
 {
-    char *p0, *p1;
-    FILE *ttyf;
-    int  i, c;
+  char *p0, *p1;
+  FILE *ttyf = NULL;
+  int  i; /*, c;*/
 
 
-    nopause = nopause | !isatty(fileno(fp));
+  nopause = nopause | !isatty(fileno(fp));
 
 
-    if ( !nopause && (ttyf=fopen(ttyfilename,"r"))==NULL ) {
-  nopause = 1;
-    }
+  if ( !nopause && (ttyf=fopen(ttyfilename,"r"))==NULL ) {
+    nopause = 1;
+  }
 
 
-    for ( i=1, p0=disclaimer; ; i++ ) {
-  if ( !(*p0)  ) break;
-  if ( !nopause && i%PAUSE==0 ) {
+  for ( i=1, p0=disclaimer; ; i++ ) {
+    if ( !(*p0)  ) break;
+    if ( !nopause && i%PAUSE==0 ) {
       fflush(fp);
       fprintf(stderr, "--- (press RETURN to continue) ---"); 
       fflush(stderr);
       fflush(fp);
       fprintf(stderr, "--- (press RETURN to continue) ---"); 
       fflush(stderr);
-      c = getc(ttyf);
-  }
-  for ( p1=p0; (*p1 != '\n') && (*p1 != 0); p1++ );
-  *p1 = 0;
-  fprintf(fp,"%s\n",p0);
-  p0 = p1+1;
+/*      c = getc(ttyf);*/
     }
     }
-    fprintf(fp,"\n"); fflush(fp);
-    if ( !nopause) fclose(ttyf);
+    for ( p1=p0; (*p1 != '\n') && (*p1 != 0); p1++ );
+    *p1 = 0;
+    fprintf(fp,"%s\n",p0);
+    p0 = p1+1;
+  }
+  fprintf(fp,"\n"); fflush(fp);
+  if ( !nopause) fclose(ttyf);
 }
 }