Index: trunk/SophyaProg/PrgUtil/Makefile
===================================================================
--- trunk/SophyaProg/PrgUtil/Makefile	(revision 1306)
+++ trunk/SophyaProg/PrgUtil/Makefile	(revision 1306)
@@ -0,0 +1,82 @@
+MODULECXXREPNAME :=  PrgUtil
+include ../Mgr/Makefile.h
+ 
+ifdef NOSHLIB
+LIBF =  $(LIB)libTArray.a $(LIB)libSysTools.a $(LIB)libNTools.a $(LIB)libSkyMap.a $(LIB)libSamba.a $(LIB)libSkyT.a $(LIB)lib.a $(LIB)lib.a
+LIBS = -L$(LIB) -lTArray -lSysTools -lNTools -lSkyMap -lSamba -lSkyT -l -l  -lm
+ifeq ($(CXX),cxx)
+# librairie des instances de templates cxx
+LIBS := $(LIBS) -lertcxx
+endif
+else
+LIBF =  $(SLB)libsophya.so $(SLB)libextsophya.so
+LIBS = -L$(SLB) -lsophya -lextsophya  -lm
+endif
+LIBSORA := $(LIBS)
+ifdef ORACLE_HOME
+LIBSORA := -L$(LIB) -lDb++ $(LIBS) -lErosDb -L$(ORACLE_HOME)/lib -lclntsh
+endif
+LDLIBS := $(LIBS) $(LDLIBS)
+PROGS = $(EXE)runcxx $(EXE)scanppf
+ 
+all: $(PROGS)
+
+clean:
+	rm -f $(PROGS)
+	if [ -d $(OBJ)cxxrep_PrgUtil ] ; then cd $(OBJ)cxxrep_PrgUtil ; rm -f *.o ; fi
+
+runcxx: $(EXE)runcxx
+	
+$(EXE)runcxx: $(OBJ)runcxx.o
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+  
+scanppf: $(EXE)scanppf
+	
+$(EXE)scanppf: $(OBJ)scanppf.o
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+  
+scanfits: $(EXE)scanfits
+	
+$(EXE)scanfits: $(OBJ)scanfits.o
+	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
+  
+$(OBJ)runcxx.o: runcxx.cc $(INC)sambainit.h \
+ $(INC)skymapinit.h \
+ $(INC)sophyainit.h \
+ $(INC)machdefs.h \
+ $(INC)ntoolsinit.h \
+ $(INC)tarrinit.h \
+ $(INC)skyinit.h \
+ $(INC)pexceptions.h \
+ $(INC)cxxcmplnk.h \
+ $(INC)pdlmgr.h \
+ $(INC)timing.h
+$(OBJ)scanfits.o: scanfits.cc $(INC)histinit.h \
+ $(INC)ntoolsinit.h \
+ $(INC)tarrinit.h \
+ $(INC)sophyainit.h \
+ $(INC)machdefs.h \
+ $(INC)dvlist.h \
+ $(INC)objfio.h \
+ $(INC)anydataobj.h \
+ $(INC)ppersist.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)mutyv.h \
+ $(INC)ntuple.h \
+ $(INC)ntupintf.h \
+ $(INC)xntuple.h \
+ $(INC)fitsxntuple.h \
+ $(INC)fitsfile.h \
+ $(INC)ndatablock.h \
+ $(INC)fitsntuple.h
+$(OBJ)scanppf.o: scanppf.cc $(INC)ppersist.h \
+ $(INC)machdefs.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)anydataobj.h \
+ $(INC)sambainit.h \
+ $(INC)skymapinit.h \
+ $(INC)sophyainit.h \
+ $(INC)ntoolsinit.h \
+ $(INC)tarrinit.h
Index: trunk/SophyaProg/PrgUtil/programs
===================================================================
--- trunk/SophyaProg/PrgUtil/programs	(revision 1306)
+++ trunk/SophyaProg/PrgUtil/programs	(revision 1306)
@@ -0,0 +1,3 @@
+runcxx runcxx.o
+scanppf scanppf.o
+scanfits scanfits.o
Index: trunk/SophyaProg/PrgUtil/runcxx.cc
===================================================================
--- trunk/SophyaProg/PrgUtil/runcxx.cc	(revision 1306)
+++ trunk/SophyaProg/PrgUtil/runcxx.cc	(revision 1306)
@@ -0,0 +1,246 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <iostream.h>
+#include <fstream.h>
+
+#include <string>
+#include <vector>
+
+#include <typeinfo>
+
+#include "sambainit.h"
+#include "skyinit.h"
+#include "tarrinit.h"
+
+#include "pexceptions.h"
+#include "cxxcmplnk.h"
+#include "pdlmgr.h"
+#include "timing.h"
+
+typedef void (* DlFunctionOfVecStr) (vector<string> & args, int & rc);
+
+static void Usage(bool fgerr);
+static int  GetInput(string & codeflnm);
+static int  FillCxxFile(string & codeflnm, string & cxxfile);
+
+/* --Fonction-- */
+void Usage(bool fgerr)
+{
+  if (fgerr) 
+    cout << " runcxx : Argument Error ! " << endl; 
+  else
+    cout << " runcxx : compiling and running of a piece of C++ code " << endl;
+ 
+  cout << "   Usage: runcxx [-compopt CompileOptions] [-linkopt LinkOptions] \n"
+       << "                 [-tmpdir TmpDirectory] [-f C++CodeFileName] \n"
+       << "                 [-uarg UserArg1 UserArg2 ...] \n"
+       << "   if no file name is specified, read from standard input \n" << endl;
+  exit(0);
+}
+
+
+
+/* --Main-- */
+int main(int narg, char *arg[])
+{
+  if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
+
+  // Decoding options   
+  string codefile;
+  string compoption;
+  string linkoption;
+  string tmpdir;
+
+  bool fgco = false;
+  bool fglo = false;
+  bool fgcofn = false;
+  bool fgtmp = false;
+
+  vector<string> uarg;
+  
+  cout << " runcxx: Decoding command line options ... " << endl;
+  for (int k=1; k<narg; k++)   {
+    if (strcmp(arg[k], "-compopt") == 0)  {
+      if (k == narg-1) Usage(true);
+      fgco = true;  k++;
+      compoption = arg[k];
+    }
+    else if (strcmp(arg[k], "-linkopt") == 0) {
+      if (k == narg-1) Usage(true);
+      fglo = true;  k++;
+      linkoption = arg[k];
+    }
+    else if (strcmp(arg[k], "-tmpdir") == 0) {
+      if (k == narg-1) Usage(true);
+      fgtmp = true;  k++;
+      tmpdir = arg[k];
+    }
+    else if (strcmp(arg[k], "-f") == 0) {
+      if (k == narg-1) Usage(true);
+      fgcofn = true;  k++;
+      codefile = arg[k];
+    }
+    else if (strcmp(arg[k], "-uarg") == 0) {
+      if (k == narg-1) Usage(true);
+      for(int kk=k+1; kk<narg; kk++)
+	uarg.push_back(arg[kk]);
+      break;
+    }
+    else Usage(true);
+  }
+
+  // Checking TMPDIR
+  if (!fgtmp) {  // TMPDIR pas defini par option de ligne de commande
+    char* varenv;
+    if ( (varenv=getenv("TMPDIR")) != NULL )  { 
+      tmpdir = varenv;
+      fgtmp = true;
+    }
+  }
+  if (tmpdir.length() > 0)
+    if (tmpdir[tmpdir.length()-1] != '/') tmpdir += '/';
+  
+  int rc = 0;
+
+  try {
+    SophyaInit();
+    InitTim();
+
+    if (!fgcofn) {  // Pas de fichier specifie - Lecture de fichier sur stdin
+      codefile = tmpdir + "aucode.icc";
+      rc = GetInput(codefile);
+    }
+    string flnm;
+    if (rc == 0) {
+      flnm = tmpdir + "acxxrun.cc";
+      rc = FillCxxFile(codefile, flnm);
+    }
+
+    PrtTim(" End of FillCxxFile ");
+
+    string oname, soname;
+    if (rc == 0) {
+
+      CxxCompilerLinker cxx;
+      if (fgtmp) cxx.SetTmpDir(tmpdir);
+      if (fgco) cxx.AddCompileOptions(compoption);
+      if (fglo) cxx.AddLinkOptions(linkoption);
+      cxx.SetVerbose(true);
+
+      rc = cxx.Compile(flnm, oname);
+      cout << " RC from cxx.Compile() = " << rc << " oname= " << oname << endl;
+      rc = cxx.BuildSO(oname, soname);
+      cout << " RC from cxx.BuildSO() = " << rc << " soname= " << soname << endl;
+      PrtTim(" End of Compile-Link ");
+    }
+    if (rc == 0) {
+      string funcname = "runcxx_usercode";
+      if (fgtmp) PDynLinkMgr::SetTmpDir(tmpdir);
+      PDynLinkMgr dyl(soname);
+      DlFunction f = dyl.GetFunction(funcname);  
+      if (f != NULL) {
+	cout << "DlFunctionOfVecStr  f linked OK - calling f(uarg) ... \n" << endl;
+	DlFunctionOfVecStr fvs = (DlFunctionOfVecStr)f;
+	int rcu = 0;
+	fvs(uarg, rcu);
+	cout << "\n RC from UserCode() = " << rcu << endl;
+	rc = rcu;
+      } 
+      else {
+	cout << " ERROR linking DlFunction f !!! " << endl;
+      }
+    }
+  } 
+ 
+  catch (PThrowable & exc) {
+    cerr << " Catched Exception " << (string)typeid(exc).name()
+         << " - Msg= " << exc.Msg() << endl;
+  }
+  catch (...) {
+    cerr << " some other exception was caught ! " << endl;
+  }
+
+  PrtTim(" End of runcxx ");
+  return(rc);
+}
+
+/* --Fonction-- */
+int  GetInput(string & codeflnm)
+{
+  cout << " runcxx/GetInput() : Type in your C++ code, \n" 
+       << "     end with a blanck line OR <Cntl>D " << endl;
+  int line = 0;
+  ofstream os(codeflnm.c_str(),ios::out); 
+  os << "\n" ; 
+  bool fg = true;
+  char buff[512];
+  char * ret;
+  while (fg) {
+    printf("L%d ? ", line+1);
+    fflush(stdout);
+    buff[0] = '\0';
+    ret = fgets(buff, 512, stdin);
+    buff[511] = '\0';
+    if (ret && ( (buff[0] != '\0') && (buff[0] != '\n') && (buff[0] != '\r')) ) { 
+      os << buff << endl;  line++;
+    }
+    else fg = false;
+  }
+  os << "\n" ; 
+  cout << " \n Total " << line << " lines copied to file " <<  codeflnm << endl;
+  if (line > 0) return(0);
+  else return(1);
+}
+
+/* --Fonction-- */
+int  FillCxxFile(string & code, string & cxxfile)
+{
+  ofstream os(cxxfile.c_str(),ios::out); 
+  
+  os<<"#include \"machdefs.h\" \n"<<endl;
+
+  os<<"//---- System et stdc++ include files \n"
+    <<"#include <stdio.h> \n"
+    <<"#include <stdlib.h> \n"
+    <<"#include <math.h> \n"
+    <<"#include <ctype.h> \n"
+    <<"#include <string.h> \n"
+    <<"#include <iostream.h> \n"
+    <<"#include <fstream.h> \n"
+    <<"#include <complex> \n"
+    <<endl
+
+    <<"#include <typeinfo> \n"
+    <<"#include <string> \n"
+    <<"#include <vector> \n"
+    <<"#include <map> \n"
+    <<"#include <functional> \n"
+    <<"#include <list> \n"
+    <<endl
+    
+    <<"//---- Sophya include files \n"
+    <<"#include \"systools.h\" \n"
+    <<"#include \"ntools.h\" \n"
+    <<"#include \"array.h\" \n"
+    <<"#include \"histats.h\" \n"
+    <<"#include \"skymap.h\" \n"
+    <<"#include \"samba.h\" \n"
+    <<"#include \"skyt.h\" \n"
+    <<endl;
+
+  os << "extern \"C\" { \n" 
+     << " void runcxx_usercode(vector<string>& arg, int & rc); \n" 
+    //     << " void runcxx_usercode(); \n"
+     << " } \n " << endl;
+  
+  os << "// ---- User Code function ----- \n" 
+     << " void runcxx_usercode(vector<string>& arg, int & rc) \n" 
+    //     << " void runcxx_usercode() \n" 
+     << "{ \n"
+     << "#include \"" << code << "\" \n"
+     << "} \n" << endl;
+
+  return(0);
+}
+
Index: trunk/SophyaProg/PrgUtil/scanfits.cc
===================================================================
--- trunk/SophyaProg/PrgUtil/scanfits.cc	(revision 1306)
+++ trunk/SophyaProg/PrgUtil/scanfits.cc	(revision 1306)
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <iostream.h>
+
+#include "histinit.h"
+#include "dvlist.h"
+#include "ntuple.h"
+#include "xntuple.h"
+#include "fitsxntuple.h"
+#include "fitsntuple.h"
+
+int main(int narg, char *arg[])
+{
+  if (narg < 2) {
+    cerr << "scanfits/Erreur arg - Usage scanfits nomfits \n" << endl;
+    exit(0);
+  }
+  try {
+    SophyaInit();
+    string flnm = arg[1];
+    int nbblk = FitsInFile::NbBlocks(arg[1]);
+    cout << " :::: File " << flnm << " has " << nbblk << " blocks " << endl;
+    DVList header;
+    FitsFile::FitsExtensionType exttype;
+    FitsFile::FitsDataType datatype;
+
+    cout << " FitsFile::FitsExtensionType : FitsExtensionType_IMAGE= " <<
+      (int)FitsFile::FitsExtensionType_IMAGE << 
+      "  FitsExtensionType_ASCII_TBL= " << (int)FitsFile::FitsExtensionType_ASCII_TBL <<
+      "  FitsExtensionType_BINARY_TBL= " << (int)FitsFile::FitsExtensionType_BINARY_TBL << endl;
+    cout << " FitsFile::FitsDataType: FitsDataType_double= " <<
+      (int)FitsFile::FitsDataType_double << 
+      " FitsDataType_float= " << (int)FitsFile::FitsDataType_float <<
+      " FitsDataType_int= " << (int)FitsFile::FitsDataType_int <<
+      " FitsDataType_char= " << (int)FitsFile::FitsDataType_char <<
+      " FitsDataType_ASCII= " << (int)FitsFile::FitsDataType_ASCII << endl << endl;
+
+    int naxis;
+    vector<int> axis;
+    for(int i=1; i<=nbblk; i++) {
+      FitsInFile::GetBlockType(arg[1], i, exttype, naxis, axis, datatype, header);
+      cout << " --------- Header Num " << i << " Type " << (int)exttype 
+	   << " NAxis= " << naxis << " (" << axis.size() << " )" 
+	   << " DataType= " << (int)datatype << endl;
+      for(int j=0; j<axis.size(); j++) cout  << axis[j] << " x "  ;
+      cout << endl;
+      cout << header << endl;
+      cout << "----------------------------------------------------" << endl;
+    } 
+ 
+  }
+  catch (PThrowable & exc) {
+    cerr << " Catched Exception " << (string)typeid(exc).name()
+         << " - Msg= " << exc.Msg() << endl;
+  }
+  catch (...) {
+    cerr << " some other exception was caught ! " << endl;
+  }
+
+}
Index: trunk/SophyaProg/PrgUtil/scanppf.cc
===================================================================
--- trunk/SophyaProg/PrgUtil/scanppf.cc	(revision 1306)
+++ trunk/SophyaProg/PrgUtil/scanppf.cc	(revision 1306)
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <typeinfo>
+#include <iostream.h>
+#include <string>
+
+#include "ppersist.h"
+#include "anydataobj.h"
+#include "sambainit.h"
+
+#ifdef __MWERKS__
+#include <console.h>
+#endif
+
+int main(int narg, char* arg[])
+{
+
+#ifdef __MWERKS__
+narg = ccommand(&arg);
+#endif
+
+SambaInitiator smbinit;
+
+if ((narg < 2) || (strcmp(arg[1],"-h") == 0) ) {
+  cerr << " Usage: scanppf filename [s/n/a0/a1/a2/a3] \n" 
+       << "   s[=default} : Sequential reading of objects \n" 
+       << "   n : Object reading at NameTags \n"
+       << "   a0...a3 : Tag List with PInPersist.AnalyseTags(0...3) \n" << endl;
+  exit(0);
+  }
+
+try {
+  string flnm = arg[1];
+  bool seq=true;
+  bool ana=false;
+  int analev = 0;
+  string opt = "s";
+  if (narg > 2) opt = arg[2];
+  
+  if (opt == "n")  seq = false;
+  else if (opt[0] == 'a') {  ana = true;  analev = opt[1]-'0'; }
+
+  if (ana)   cout << " Analyse PInPersist( " << flnm << ")  Level=" << analev << endl;
+  else { 
+    if (!seq) cout << "PInPersist( " << flnm << ") Object Reading at NameTags " << endl;
+    else  cout << "PInPersist( " << flnm << ") Sequential Object Reading " << endl;
+  }
+   
+  PPersist* op = NULL;
+  cout << " Opening PPF file " << flnm << endl; 
+  PInPersist s(flnm);
+
+  if (ana) s.AnalyseTags(analev);   // Analysing all tags in file 
+
+  else {
+    cout << " Version= " << s.Version() << " CreationDate= " << s.CreationDateStr() << endl;
+    int nt = s.NbTags();
+    cout << " Number of tags in file = " << nt << endl;
+    if ( seq || (nt < 1) ) {
+      while (1) {
+	op = s.ReadObject();
+	cout << " Object Type " << typeid(*op).name() << endl;
+	if (op) delete op;
+      }
+    }
+    for(int i=0; i<nt; i++) {
+      cout << ">>> TagNum= " << i << " TagName= " << s.GetTagName(i) << endl;
+      s.GotoTagNum(i);
+      op = s.ReadObject();
+      cout << " Object Type " << typeid(*op).name() << endl;
+      if (op) delete op;
+    }
+  }
+}
+catch (PThrowable pex) {
+  cerr << " scanppf/Error - Exception catched " << pex.Msg() << endl;
+}
+
+cout << " ----------- End of scanppf ------------- " << endl;
+}
Index: trunk/SophyaProg/PrgUtil/usedlibs
===================================================================
--- trunk/SophyaProg/PrgUtil/usedlibs	(revision 1306)
+++ trunk/SophyaProg/PrgUtil/usedlibs	(revision 1306)
@@ -0,0 +1,8 @@
+TArray
+SysTools
+NTools
+SkyMap
+Samba
+SkyT
+
+
Index: trunk/SophyaProg/PrgUtil/usedslibs
===================================================================
--- trunk/SophyaProg/PrgUtil/usedslibs	(revision 1306)
+++ trunk/SophyaProg/PrgUtil/usedslibs	(revision 1306)
@@ -0,0 +1,2 @@
+sophya
+extsophya
