]> Creatis software - gdcm.git/blobdiff - src/gdcmArgMgr.cxx
Forgot to update this one
[gdcm.git] / src / gdcmArgMgr.cxx
index d54aae7c3e85f7f6b1f7edf43bb31804c07babdf..6ec2636714bcd128bb419a48c8c38366a63058d3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmArgMgr.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/01/26 15:52:56 $
-  Version:   $Revision: 1.17 $
+  Date:      $Date: 2007/05/23 14:18:07 $
+  Version:   $Revision: 1.24 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #include <ctype.h>
 #include <string.h>  // For strlen
 
+// No strcasecmp in WIN32 world, but stricmp
+// http://www.opengroup.org/onlinepubs/007908799/xsh/strcasecmp.html
+#ifdef _WIN32
+#define strcasecmp stricmp
+#endif
+
 #include <string.h>  // For strtok and strlen
 #include <stdlib.h>  // For strtol and strtod
 
 #include "gdcmArgMgr.h"
 
-namespace gdcm 
+namespace GDCM_NAME_SPACE 
 {
 //-------------------------------------------------------------------------
 // Constructor / Destructor
@@ -93,8 +99,13 @@ namespace gdcm
    }
 
    /* Set labels to upper-case (labels are not case sensitive ) *********/
+   //char *secu;
    for ( i=0; i<ArgCount; i++)
+   {
+      //secu = ArgLab[i];
       ArgLab[i] = Majuscule ( ArgLab[i] ) ;
+      //free (secu); //we still need it in the caller pgm.
+   }
 
   /* Standard arguments are managed by ArgStdArgs **********************/
    ArgStdArgs(); 
@@ -131,6 +142,7 @@ int ArgMgr::ArgMgrDefined( const char *param )
     trouve = ( strcmp( ArgLab[i], temp )==0 ) ;
     if ( trouve )
     {
+      free (temp);
       ArgUsed[i] = true ;           
       for ( int j=1; j<i; j++)
       {                     
@@ -138,8 +150,9 @@ int ArgMgr::ArgMgrDefined( const char *param )
             ArgUsed[j] = i ;
       }
       return i ;
-    }
+    }   
   }
+  free (temp);
   return 0 ;
 }
 
@@ -162,7 +175,7 @@ char *ArgMgr::ArgMgrValue ( const char *param )
  * \brief  Search for the first not yet used label
  * @return Pointer to the char array holding the first non used label
  */
-char *ArgMgr::ArgMgrUnused ( )
+const char *ArgMgr::ArgMgrUnused ( )
 {
    int i ;
    for ( i=ArgCount-1; i>0; i-- )
@@ -182,7 +195,7 @@ char *ArgMgr::ArgMgrUnused ( )
  */
 int ArgMgr::ArgMgrPrintUnusedLabels ()
 {
-   char *label;
+   const char *label;
    int i=0;
    while ( (label=ArgMgrUnused())!=0 )
    {
@@ -217,7 +230,7 @@ int ArgMgr::ArgMgrUsage(const char **usage )
  * @param param  char. array that defines the parameter
  * @return   Entier correspondant au rang dans la liste de labels
  */
-int ArgMgr::ArgMgrSave ( char *param )
+int ArgMgr::ArgMgrSave ( const char *param )
 {
    static int   deja = 0;
    FILE         *fd;
@@ -295,7 +308,7 @@ const char *ArgMgr::ArgMgrGetString(const char *param, const char *defaultVal)
  * @param val  number of default value
  * @return   int : range of value amongst the values list
  */
-int ArgMgr::ArgMgrGetLabel (const char *param, char *liste, int val )
+int ArgMgr::ArgMgrGetLabel (const char *param, const char *liste, int val )
 {
   char *lab;
   const char *vallab;
@@ -327,6 +340,7 @@ int ArgMgr::ArgMgrGetLabel (const char *param, char *liste, int val )
  * @param liste  character Chain describing the various values.
  *               Labels are separated by  '\\'.
  *               No case sensitive.
+ *               WARNING this will be changed (not const)
  * @param usage Usage program (displayed if label not found)
  * @return   int : range of value amongst the values list
  */
@@ -762,7 +776,7 @@ char *ArgMgr::Majuscule (const char *chaine )
 * Valeur retournee . : false if OK.                                       *
 *                      true if KO.                                        *
 **************************************************************************/
-int ArgMgr::FiltreLong ( char *arg  )
+int ArgMgr::FiltreLong ( const char *arg  )
 {
   int  n = 0 ;
   while ( (n++<ARG_LONG_MAX) && (*(arg++) != '\0') ) ;
@@ -825,7 +839,7 @@ const char *ArgMgr::LoadedParam ( const char *param, FILE *fd )
  |              Role     : parameter File name
  |
  +------------------------------------------------------------------------*/
-int ArgMgr::ArgLoadFromFile ( char *filename )
+int ArgMgr::ArgLoadFromFile ( const char *filename )
 {
   int   nbl = 0;
   char  param[ARG_LONG_MAX+1];