Index: /trunk/SophyaExt/FitsIOServer/fitsfile.cc
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fitsfile.cc	(revision 1770)
+++ /trunk/SophyaExt/FitsIOServer/fitsfile.cc	(revision 1771)
@@ -350,5 +350,5 @@
       else hdunum_++;
     }
-  getHeader();
+  getHeaderWithSophyaObject();
   if ( hdutype_ == FitsExtensionType_NULL )
     {
@@ -356,5 +356,5 @@
 	{
 	  hdunum_++;
-	  getHeader();
+	  getHeaderWithSophyaObject();
 	}
       else 
@@ -425,4 +425,66 @@
      }
 
+void FitsInFile::GetKeywordsFromHeader (int hdunum, list<FitsKeyword>& mots_cles) const
+{
+  int status = 0;
+  int hdutype;
+  fits_movabs_hdu(fptr_,hdunum,&hdutype,&status);
+  if( status ) fits_report_error(stderr,status);
+
+  // get number of keywords
+  int nkeys,keypos;
+  fits_get_hdrpos(fptr_, &nkeys, &keypos,&status);
+  if( status ) fits_report_error(stderr,status);
+  // shift with the number of mandatory keywords
+  int num= 0;
+  // if primary header
+    if (hdunum == 1) 
+      {
+	// read NAXIS
+	int naxis=0;
+	fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status);
+	// number of mandatory keywords
+	num = naxis+3;
+      }
+    // extensions
+    else
+      {
+	if (hdutype == IMAGE_HDU)
+	  {
+	    // read NAXIS
+	    int naxis=0;
+	    fits_read_key(fptr_,TINT,"NAXIS",&naxis,NULL,&status);
+	    // number of mandatory keywords
+	    num = naxis+5;
+	  }
+	else
+	  if(hdutype == ASCII_TBL || hdutype == BINARY_TBL)
+	    {
+	      // number of mandatory keywords
+	      num = 8;
+	    }
+      }
+  int j;
+  char keyname[LEN_KEYWORD];  
+  char value[FLEN_VALUE];
+  char comment[FLEN_COMMENT];
+  for(j = num+1; j <= nkeys; j++)
+    {
+      char dtype;
+      fits_read_keyn(fptr_,j,keyname,value,comment,&status);
+      if(status) 
+	{
+	  fits_report_error(stderr,status);
+	  status=0;
+	}
+      string  kn(keyname);
+      string  cm(comment);
+      string  val(value);
+      FitsKeyword kw(kn, val, cm);
+      mots_cles.push_back(kw);
+    }
+  if (hdunum_ > 0) fits_movabs_hdu(fptr_,hdunum_,&hdutype,&status);
+
+}
 void FitsInFile::GetImageParameters (fitsfile* fileptr,FitsDataType& dataType,int& naxis,vector<int>& naxisn)
 {
@@ -482,5 +544,5 @@
    }
 
-void FitsInFile::getHeader()
+void FitsInFile::getHeaderWithSophyaObject()
 {
   // si hdunum_ > 1 lit le header correspondant
@@ -526,5 +588,5 @@
 	  else
 	    {
-	      cout << "WARNING (FitsInFile::getHeader) : error during movabs" << endl;
+	      cout << "WARNING (FitsInFile::getHeaderWithSophyaObject) : error during movabs" << endl;
 	      hdutype_= FitsExtensionType_ERROR;
 	      status =0;
@@ -567,5 +629,5 @@
   int status = 0;
   hdunum_++;
-  getHeader();
+  getHeaderWithSophyaObject();
   if ( hdutype_ == FitsExtensionType_NULL )
     {
@@ -1928,4 +1990,7 @@
 void FitsOutFile::appendInputHeader(FitsInFile& infits, int hdunum)
 {
+
+  infits.GetKeywordsFromHeader(hdunum, mots_cles_);
+  /*
   int status = 0;
   int hdutype;
@@ -1986,4 +2051,5 @@
       mots_cles_.push_back(kw);
     }
+  */
 }
 void FitsOutFile::writeAppendedHeaderOnFits()
Index: /trunk/SophyaExt/FitsIOServer/fitsfile.h
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fitsfile.h	(revision 1770)
+++ /trunk/SophyaExt/FitsIOServer/fitsfile.h	(revision 1771)
@@ -105,15 +105,23 @@
    inline void firstImageOnPrimaryHeader(bool choice) {imageOnPrimary_=choice;}
    inline int currentHeaderIndex() {return hdunum_;}
-   inline fitsfile* fitsfilePtr() {return fptr_;}
  
 
  protected:
 
-   void         ResetStatus(int& status) ; 
-   static  void printerror(int&) ;
-   static  void printerror(int&,char* texte) ;
-   static  void printerrorAndContinue(int& status, char* texte);
-   inline void  InitNull() {fptr_ = NULL; hdutype_= FitsExtensionType_NULL; hdunum_ = 0; 
-   fits_status_ = 0; imageOnPrimary_ = true;}
+void         ResetStatus(int& status) ; 
+static  void printerror(int&) ;
+static  void printerror(int&,char* texte) ;
+static  void printerrorAndContinue(int& status, char* texte);
+inline void  InitNull() 
+  {
+    fptr_ = NULL; 
+    hdutype_= FitsExtensionType_NULL; 
+    hdunum_ = 0; 
+    fits_status_ = 0; imageOnPrimary_ = true;
+  }
+inline fitsfile* fitsfilePtr() const {return fptr_;}
+
+
+
    fitsfile *fptr_;     /**<  pointer to the FITS file, defined in fitsio.h */
    FitsExtensionType hdutype_;        /**<  image or bintable ? */
@@ -145,4 +153,7 @@
   inline const DVList& DVListFromFits() const { return dvl_;}
 
+  void GetKeywordsFromHeader (int hdunum, list<FitsKeyword>& mots_cles) const;
+
+
   DVList  DVListFromPrimaryHeader() const;
   void    moveToFollowingHeader();
@@ -179,4 +190,5 @@
 /*! \return data type of the current IMAGE extension */
 inline FitsFile::FitsDataType ImageType() const {return imageDataType_;}
+
 
 
@@ -237,5 +249,5 @@
 
 void InitNull();
-void getHeader();
+void getHeaderWithSophyaObject();
 static void KeywordsIntoDVList(fitsfile* fileptr, DVList& dvl, int hdunum); 
 static  void GetImageParameters (fitsfile* fileptr,FitsDataType& dataType,int& naxis,vector<int>& naxisn);
