Index: /trunk/FACT++/src/fitsdump.cc
===================================================================
--- /trunk/FACT++/src/fitsdump.cc	(revision 17258)
+++ /trunk/FACT++/src/fitsdump.cc	(revision 17259)
@@ -72,4 +72,5 @@
     /// Lists all columns of an open file
     void List();                          
+    void ListFileContent(const string& filename);
     void ListHeader(const string& filename);
     void ListKeywords(ostream &);
@@ -165,4 +166,45 @@
 }
 
+void FitsDumper::ListFileContent(const string& filename)
+{
+    ofstream fout(filename=="-"?"/dev/stdout":filename);
+    if (!fout)
+    {
+        cerr << "Cannot open file " << filename << ": " << strerror(errno) << endl;
+        return;
+    }
+
+    int table_id = 0;
+
+    vector<string> table_names;
+    vector<uint32_t> table_rows;
+    try
+    {
+
+        while (true)
+        {
+            clear();
+            seekg(0);
+            fTable = Table();
+            Constructor(fFilename, "", "", false, table_id);
+
+            table_names.push_back(fTable.Get<string>("EXTNAME"));
+            table_rows.push_back(GetNumRows());
+
+            table_id++;
+        }
+    }
+    catch (runtime_error e)
+    {
+        //nothing to see here, just catching the error thrown by EOF
+    }
+
+    fout << "File " << fFilename << " has " << table_names.size() << " tables: " << endl;
+    for (uint32_t i=0; i<table_names.size(); i++)
+    {
+        fout << "#" << i << ": \"" << table_names[i];
+        fout << "\" num. rows = " << table_rows[i] << endl;
+    }
+}
 void FitsDumper::ListHeader(const string& filename)
 {
@@ -929,9 +971,12 @@
         List();
 
+    if (conf.Get<bool>("filecontent"))
+        ListFileContent(conf.Get<string>("outfile"));
+
     if (conf.Get<bool>("header"))
         ListHeader(conf.Get<string>("outfile"));
 
 
-    if (conf.Get<bool>("header") || conf.Get<bool>("list"))
+    if (conf.Get<bool>("header") || conf.Get<bool>("list") || conf.Get<bool>("filecontent"))
         return 1;
 
@@ -1110,4 +1155,5 @@
         ("limit",       var<size_t>(size_t(0)), "Limit for the maximum number of rows to read (0=unlimited)")
         ("tablename,t", var<string>(""),        "Name of the table to open. If not specified, first binary table is opened")
+        ("filecontent", po_switch(),            "List the number of tables in the file, along with their name")
 #ifdef HAVE_ROOT
         ("root,r",      po_switch(),            "Enable root mode")
Index: /trunk/Mars/mcore/fits.h
===================================================================
--- /trunk/Mars/mcore/fits.h	(revision 17258)
+++ /trunk/Mars/mcore/fits.h	(revision 17259)
@@ -564,5 +564,5 @@
     }
 
-    void Constructor(const string &fname, string fout, const string& tableName, bool force)
+    void Constructor(const string &fname, string fout, const string& tableName, bool force, int tableNumber=-1)
     {
         char simple[10];
@@ -570,4 +570,6 @@
         if (!good())
             return;
+
+        int current_table = 0;
 
         if (memcmp(simple, "SIMPLE  = ", 10))
@@ -649,10 +651,19 @@
                 // skip the current table?
                 if ((!tableName.empty() &&         tableName!=fTable.Get<string>("EXTNAME")) ||
-                    ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<string>("EXTNAME")))
+                    ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<string>("EXTNAME")) ||
+                    (tableNumber != -1))
                 {
+                    if (current_table == tableNumber)
+                    {
+                        fBufferRow.resize(fTable.bytes_per_row + 8-fTable.bytes_per_row%4);
+                        fBufferDat.resize(fTable.bytes_per_row);
+
+                        break;
+                    }
                     const streamoff skip = fTable.GetTotalBytes();
                     seekg(skip, ios_base::cur);
 
                     fChkHeader.reset();
+                    current_table++;
 
                     continue;
