Index: pkpgcounter/trunk/pkpgpdls/ldl.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/zjstream.py (revision 463)
+++ pkpgcounter/trunk/pkpgpdls/ldl.py (revision 482)
@@ -21,5 +21,5 @@
 #
 
-"""This modules implements a page counter for ZjStream documents."""
+"""This modules implements a page counter for HP LIDIL format."""
 
 import sys
@@ -31,76 +31,26 @@
 
 class Parser(pdlparser.PDLParser) :
-    """A parser for ZjStream documents."""
+    """A parser for HP LIDIL documents."""
     def isValid(self) :    
-        """Returns True if data is ZjStream, else False."""
-        if self.firstblock[:4] == "ZJZJ" :
-            self.logdebug("DEBUG: Input file is in the Zenographics ZjStream (little endian) format.")
-            self.littleEndian()
-            return True
-        elif self.firstblock[:4] == "JZJZ" :    
-            self.logdebug("DEBUG: Input file is in the Zenographics ZjStream (big endian) format.")
-            self.bigEndian()
+        """Returns True if data is LIDIL, else False."""
+	# Beginning Of File marker is a Sync packet, followed with
+	# a Sync Complete packet followed with a Reset packet.
+	# We just look at the start of the Sync packet for simplicity's sake.
+	BOFMarker = "$\x01\x00\x00\x07"
+	# End Of File marker is a Sync Complete packet followed
+	# with a Reset packet. We ignore the preceding Sync packet
+	# for simplicity's sake.
+        EOFMarker = "$\x00\x10\x00\x08\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$$\x00\x10\x00\x06\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$" 
+        if self.firstblock.startswith(BOFMarker) \
+	   and self.lastblock.endswith(EOFMarker) :
+            self.logdebug("DEBUG: Input file is in the Hewlett-Packard LIDIL format.")
             return True
         else :    
             return False
         
-    def littleEndian(self) :
-        """Toggles to little endianness."""
-        self.unpackType = { 1 : "B", 2 : "<H", 4 : "<I" }
-        self.unpackShort = self.unpackType[2]
-        self.unpackLong = self.unpackType[4]
+    def getJobSize(self) :
+        """Computes the number of pages in a HP LIDIL document."""
         return 0
-        
-    def bigEndian(self) :
-        """Toggles to big endianness."""
-        self.unpackType = { 1 : "B", 2 : ">H", 4 : ">I" }
-        self.unpackShort = self.unpackType[2]
-        self.unpackLong = self.unpackType[4]
-        return 0
-        
-    def getJobSize(self) :
-        """Computes the number of pages in a ZjStream document."""
-        infileno = self.infile.fileno()
-        minfile = mmap.mmap(infileno, os.fstat(infileno)[6], prot=mmap.PROT_READ, flags=mmap.MAP_SHARED)
-        pos = 4
-        startpagecount = endpagecount = 0
-        try :
-            try :
-                while 1 :
-                    header = minfile[pos:pos+16]
-                    if len(header) != 16 :
-                        break
-                    totalChunkSize = unpack(self.unpackLong, header[:4])[0]
-                    chunkType = unpack(self.unpackLong, header[4:8])[0]
-                    numberOfItems = unpack(self.unpackLong, header[8:12])[0]
-                    reserved = unpack(self.unpackShort, header[12:14])[0]
-                    signature = unpack(self.unpackShort, header[14:])[0]
-                    pos += totalChunkSize
-                    if chunkType == 0 :
-                        self.logdebug("startDoc")
-                    elif chunkType == 1 :    
-                        self.logdebug("endDoc")
-                    elif chunkType == 2 :    
-                        self.logdebug("startPage")
-                        startpagecount += 1
-                    elif chunkType == 3 :
-                        self.logdebug("endPage")
-                        endpagecount += 1
-                        
-                    #self.logdebug("Chunk size : %s" % totalChunkSize)
-                    #self.logdebug("Chunk type : 0x%08x" % chunkType)
-                    #self.logdebug("# items : %s" % numberOfItems)
-                    #self.logdebug("reserved : 0x%04x" % reserved)
-                    #self.logdebug("signature : 0x%04x" % signature)
-                    #self.logdebug("\n")
-            except IndexError : # EOF ?
-                pass 
-        finally :        
-            minfile.close()
-            
-        if startpagecount != endpagecount :    
-            sys.stderr.write("ERROR: Incorrect ZjStream datas.\n")
-        return max(startpagecount, endpagecount)
-        
+
 if __name__ == "__main__" :    
     pdlparser.test(Parser)
