Index: trunk/SophyaExt/FitsIOServer/fitsioserver.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsioserver.cc	(revision 674)
+++ trunk/SophyaExt/FitsIOServer/fitsioserver.cc	(revision 676)
@@ -32,5 +32,5 @@
   nbcols=n2;
   if (naxis == 1) nbcols=1;
-  if (naxis > 2) 
+  if (naxis > 2 && n3>1) 
     {
       cout<<"  FitsIOServer : le fichier fits n'est pas une matrice, naxis= " <<naxis<< endl;
@@ -40,8 +40,8 @@
   if (mat.NRows() != nbrows || mat.NCols() != nbcols )
     {
-      cout << " found " << nbrows << " rows ";
-      cout << "  expected " << mat.NRows()  << endl;
-      cout << " found " << nbcols << " columns " ;
-      cout << "  expected " <<  mat.NCols()  << endl;
+      //    cout << " found " << nbrows << " rows ";
+      //   cout << "  expected " << mat.NRows()  << endl;
+      //  cout << " found " << nbcols << " columns " ;
+      // cout << "  expected " <<  mat.NCols()  << endl;
       mat.ReSize(nbrows,nbcols);
       cout << " resize the vector to nbrows=  " << nbrows  << " nbcols= " << nbcols << endl;
@@ -65,5 +65,5 @@
   nbcols=n2;
   if (naxis == 1) nbcols=1;
-  if (naxis > 2) 
+  if (naxis > 2 && n3>1) 
     {
       cout<<"  FitsIOServer : le fichier fits n'est pas une matrice, naxis= " <<naxis<< endl;
@@ -73,8 +73,8 @@
   if (mat.NRows() != nbrows || mat.NCols() != nbcols )
     {
-      cout << " found " << nbrows << " rows ";
-      cout << "  expected " << mat.NRows()  << endl;
-      cout << " found " << nbcols << " columns " ;
-      cout << "  expected " <<  mat.NCols()  << endl;
+      //      cout << " found " << nbrows << " rows ";
+      //    cout << "  expected " << mat.NRows()  << endl;
+      //  cout << " found " << nbcols << " columns " ;
+      //  cout << "  expected " <<  mat.NCols()  << endl;
       mat.ReSize(nbrows,nbcols);
       cout << " resize the vector to nbrows=  " << nbrows  << " nbcols= " << nbcols << endl;
@@ -98,5 +98,5 @@
   nbcols=n2;
   if (naxis == 1) nbcols=1;
-  if (naxis > 2) 
+  if (naxis > 2 && n3>1) 
     {
       cout<<"  FitsIOServer : le fichier fits n'est pas une matrice, naxis= " <<naxis<< endl;
@@ -106,8 +106,8 @@
   if (mat.NRows() != nbrows || mat.NCols() != nbcols )
     {
-      cout << " found " << nbrows << " rows ";
-      cout << "  expected " << mat.NRows()  << endl;
-      cout << " found " << nbcols << " columns " ;
-      cout << "  expected " <<  mat.NCols()  << endl;
+      //     cout << " found " << nbrows << " rows ";
+      //   cout << "  expected " << mat.NRows()  << endl;
+      //  cout << " found " << nbcols << " columns " ;
+      //  cout << "  expected " <<  mat.NCols()  << endl;
       mat.ReSize(nbrows,nbcols);
       cout << " resize the vector to nbrows=  " << nbrows  << " nbcols= " << nbcols << endl;
@@ -290,4 +290,5 @@
        strip (keyname, 'B',' '); 
        strip(strval, 'B',' ');
+       strip(strval, 'B','\'');
        
        switch( dtype ) 
@@ -376,6 +377,6 @@
   nside= dvl.GetI("NSIDE");
   const char* ordering= dvl.GetS("ORDERING").c_str();
-  char* ring = "'RING";
-  if (  strncmp(ordering, ring,3) != 0) 
+  char* ring = "RING";
+  if (  strncmp(ordering, ring,4) != 0) 
 
     //  if (ordering!="RING    ")
@@ -420,6 +421,6 @@
   nside= dvl.GetI("NSIDE");
   const char* ordering= dvl.GetS("ORDERING").c_str();
-  char* ring = "'RING";
-  if (  strncmp(ordering, ring,3) != 0) 
+  char* ring = "RING";
+  if (  strncmp(ordering, ring,4) != 0) 
 
     //  if (ordering!="RING    ")
@@ -1426,4 +1427,5 @@
       fits_read_img(fptr, TFLOAT, 1, nelements,  &fnullval, r_4tab_, 
 		    &anynull, &status);
+      for (int kk=0; kk<nelements; kk++) cout << r_4tab_[kk] << endl;
       if( status )  printerror( status );
       break;
@@ -1450,74 +1452,51 @@
   status = 0;
   char card[FLEN_CARD];
-  int num = 0;
-  char comment2[FLEN_COMMENT] = "x";
-  char keyname[16];
-  char * datekey= "DATE";
-  char * endkey= "END";
-  char typ='x';
-  int ival;
-  double dval;
-  char strval[90];
-  // on a convenu que les mots cles utilisateur sont apres le mot cle DATE
-  // on va jusqu'au mot cle DATE
-  int flen_keyword = 9;
-  // FLEN_KEYWORD est la longueur max d'un mot-cle. Il doit y avoir une 
-  // erreur dans la librairie fits qui donne FLEN_KEYWORD=72 
-  // contrairement a la notice qui donne FLEN_KEYWORD=9 (ch. 5, p.39)
-  while (status == 0 &&  strncmp(keyname, datekey,4) != 0 ) 
-    {
-      num++;
-      fits_read_record(fptr, num, card, &status);
-      strncpy(keyname,card,flen_keyword-1); keyname[10] = '\0';
-    }
-  if (status != 0 ) 
-    {
-      cout << " fitsio::planck_read_img : erreur, mot cle DATE absent " << endl;
-    }
-  // on recupere la liste des mots-cles utilisateurs
-  while (status == 0) 
-    {
-      num++;
-      // on lit un record pour recuperer le nom du mot-cle
-      fits_read_record(fptr, num, card, &status);
-      strncpy(keyname,card,flen_keyword-1);  keyname[10] = '\0';
-      char value[FLEN_VALUE];
-      // on recupere le premier caractere du commentaire, qui contient 
-      // le code du type de la valeur
-      // (tant que ce n est pas le mot cle END)
-      fits_read_keyword(fptr, keyname, value, comment2, &status);
-      if (  strncmp(keyname, endkey,flen_keyword-1) != 0) 
-	{
-	  typ = comment2[0];
-	  // quand le type est connu, on lit la valeur
-	  switch (typ) 
-	    {
-	    case 'I' :
-	      fits_read_key(fptr, TINT, keyname, &ival, comment2, &status);
-	      if( status )  printerror( status );
-	      strip (keyname, 'B',' '); 
-	      dvl[keyname] = (int_4)ival;
-	      break;
-	    case 'D' : 
-	      fits_read_key(fptr, TDOUBLE, keyname, &dval, comment2, &status);
-	      if( status )  printerror( status );
-	      strip (keyname, 'B',' '); 
-	      dvl[keyname] = dval;
-	      break;
-	    case 'S' : 
-	      fits_read_key(fptr, TSTRING, keyname, strval, comment2, &status);
-	      if( status )  printerror( status );
-	      strip (keyname, 'B',' '); 
-	      strip(strval, 'B',' ');
-	      dvl[keyname]=strval;
-	      break;
-	    default :
-	      //	      cout << " FITSIOSERVER::planck_read_img -> DVList Type ? for key " 
-	      //                   << (string)keyname << endl;
-	      break;
-	    }
-	}
-    }
-
+  char keyname[LEN_KEYWORD]= "";
+  char strval[FLEN_VALUE];
+  char comment1[FLEN_COMMENT];
+  char dtype;
+  char * comkey = "COMMENT";
+  int keypos;
+   fits_get_hdrpos(fptr,&nkeys,&keypos,&status);
+   if( status )  printerror( status );
+   //   cout << " planck_read_img : nombre de mots-cles : " << nkeys << endl;
+   for(int j = 1; j <= nkeys; j++)
+     {
+       fits_read_keyn(fptr,j,card,strval,comment1,&status);
+       strncpy(keyname,card,LEN_KEYWORD-1);
+        if ( strncmp(keyname,comkey ,LEN_KEYWORD-1) != 0)
+	  {
+	    fits_get_keytype(strval,&dtype,&status);
+	    //	    	cout<<" keyname= "<< keyname <<" dtype= "<<dtype <<endl; 
+	    strip (keyname, 'B',' '); 
+	    strip(strval, 'B',' ');
+	    strip(strval, 'B','\'');
+	    switch( dtype ) 
+	      {
+	      case 'C':
+		dvl[keyname]= strval;	  
+		break;
+	      case 'I':
+		int ival;
+		ctoi(strval,&ival);
+		dvl[keyname]= (int_4)ival;
+		break;
+	      case 'L':
+		int ilog;
+		if (strncmp(strval,"T" ,1) ==0) ilog=1;
+		else ilog=0;
+		dvl[keyname]= (int_4)ilog;
+		break;
+	      case 'F':
+		double dval;
+		ctof(strval,&dval);
+		dvl[keyname]= dval;
+		break;
+	      default :
+		cout << " FitsIOServer : type de mot-cle bizarre: " << keyname  <<" dtype= "<<dtype << endl;
+		break;
+	      }
+	  }
+     }
 
   // close the file
@@ -1681,6 +1660,7 @@
 	    strip (keyname, 'B',' '); 
 	    strip(strval, 'B',' ');
-	    switch( dtype ) 
-	      {
+	    strip(strval, 'B','\'');
+	    switch( dtype )  
+	      { 
 	      case 'C':
 		dvl[keyname]= strval;	  
@@ -1691,4 +1671,10 @@
 		dvl[keyname]= (int_4)ival;
 		break;
+	      case 'L':
+		int ilog;
+		if (strncmp(strval,"T" ,1) ==0) ilog=1;
+		else ilog=0;
+		dvl[keyname]= (int_4)ilog;
+		break;
 	      case 'F':
 		double dval;
@@ -1697,5 +1683,5 @@
 		break;
 	      default :
-		cout << " FitsIOServer : mot-cle bizarre " << endl;
+		cout << " FitsIOServer : type de mot-cle bizarre: "  << keyname <<" dtype= "<<dtype << endl;
 		break;
 	      }
