Index: trunk/ippTasks/Makefile.am
===================================================================
--- trunk/ippTasks/Makefile.am	(revision 16570)
+++ trunk/ippTasks/Makefile.am	(revision 16598)
@@ -15,5 +15,6 @@
 	diff.pro \
 	stack.pro \
-	summit.copy.pro
+	summit.copy.pro \
+        pstamp.pro
 
 other_files = \
Index: trunk/ippTasks/pstamp.pro
===================================================================
--- trunk/ippTasks/pstamp.pro	(revision 16598)
+++ trunk/ippTasks/pstamp.pro	(revision 16598)
@@ -0,0 +1,265 @@
+
+# $VERBOSE = 3
+
+$pstampJob_DB = 0
+
+macro pstamp.reset
+    book init pstampRequest
+    book init pstampJob
+end
+
+pstamp.reset
+
+
+macro pstamp.on
+    task pstamp.request.find
+        active true
+    end
+    task pstamp.request.load
+        active true
+    end
+    task pstamp.request.run
+        active true
+    end
+    task pstamp.request.finish
+        active true
+    end
+
+    task pstamp.job.load
+        active true
+    end
+    task pstamp.job.run
+        active true
+    end
+end
+
+macro pstamp.off
+    task pstamp.request.find
+        active false
+    end
+    task pstamp.request.load
+        active false
+    end
+    task pstamp.request.run
+        active false
+    end
+    task pstamp.request.finish
+        active false
+    end
+
+    task pstamp.job.load
+        active false
+    end
+    task pstamp.job.run
+        active false
+    end
+end
+
+task pstamp.request.find
+    host        local
+
+    periods     -poll $LOADPOLL
+    periods     -exec 10
+    periods     -timeout 30
+    npending    1
+
+    task.exec
+        # echo pstamp_queue_requests.pl
+        command pstamp_queue_requests.pl
+    end
+
+    task.exit $EXIT_SUCCESS
+        # echo nothing to do
+    end
+
+    task.exit   default
+        showcommand failure
+    end
+
+    task.exit   timeout
+        showcommand timeout
+    end
+end
+
+task pstamp.request.load
+    host        local
+
+    periods     -poll $LOADPOLL
+    periods     -exec $LOADEXEC
+    periods     -timeout 300
+    npending    1
+
+    task.exec
+        command pstamptool  -pendingreq
+    end
+
+    task.exit $EXIT_SUCCESS
+        ipptool2book stdout pstampRequest -key req_id -uniq -setword pantaskState INIT
+
+        if ($VERBOSE > 2)
+            echo starting request
+            book listbook pstampRequest
+        end
+
+        process_cleanup pstampRequest
+    end
+
+    task.exit   default
+        showcommand failure
+    end
+
+    task.exit   timeout
+        showcommand timeout
+    end
+end
+
+task pstamp.request.run
+    periods     -poll $RUNPOLL
+    periods     -exec $RUNEXEC
+    periods     -timeout 30
+    npending    1
+
+    task.exec
+        book npages pstampRequest -var N
+        if ($N == 0) break
+        
+        book getpage pstampRequest 0 -var pageName -key pantaskState INIT
+        if ("$pageName" == "NULL") break
+
+        book setword pstampRequest $pageName pantaskState RUN
+        book getword pstampRequest $pageName req_id -var REQ_ID
+
+        $run = pstamp_parser_run.pl $REQ_ID
+
+        options $pageName
+
+        if ($VERBOSE > 1) 
+            echo command $run
+        end
+        command $run
+    end
+
+
+    task.exit default
+        echo pstamp.request.run task.exit status: $JOB_STATUS
+        process_exit pstampRequest $options:0 $JOB_STATUS
+    end
+
+    task.exit timeout
+        showcommand timeout
+        book setword pstampRequest $options:0 pantaskState TIMEOUT
+    end
+end
+
+task pstamp.request.finish
+    periods     -poll $RUNPOLL
+    periods     -exec $RUNEXEC
+    periods     -timeout 30
+    npending    1
+
+    task.exec
+        $run = pstamprequestfinish
+        command $run
+    end
+
+    task.exit default
+        # nothing to do
+    end
+
+    task.exit timeout
+        showcommand timeout
+    end
+end
+
+task pstamp.job.load
+    host        local
+
+    periods     -poll $LOADPOLL
+    periods     -exec $LOADEXEC
+    periods     -timeout 30
+    npending    1
+
+    task.exec
+        if ($DB:n == 0)
+            option DEFAULT
+            #echo command pstamptool -pendingjob -limit 10
+            command pstamptool -pendingjob -limit 10
+        else
+            option $DB:$pstampJob_DB
+            command pstamptool -pendingjob -limit 10 -dbname $DB:$pstampJob_DB
+            $pstampJob_DB ++
+            if ($pstampJob_DB >= $DB:n) set regPendingImfile_DB = 0
+        end
+    end
+
+    task.exit $EXIT_SUCCESS
+        # echo ipptool2book stdout pstampJob -key job_id -setword dbname $options:0 -setword pantaskState INIT
+        #ipptool2book stdout pstampJob -key job_id -setword dbname $options:0 -setword pantaskState INIT
+        ipptool2book stdout pstampJob -key job_id -uniq -setword pantaskState INIT
+
+        if ($VERBOSE > 2)
+            # echo book listbook pstampJob":"
+            echo starting job:
+            book listbook pstampJob
+        end
+
+        process_cleanup pstampJob
+    end
+
+    task.exit   default
+        showcommand failure
+    end
+
+    task.exit   timeout
+        showcommand timeout
+    end
+end
+
+task pstamp.job.run
+    periods     -poll $RUNPOLL
+    periods     -exec $RUNEXEC
+    periods     -timeout 1200
+    npending    1
+
+    task.exec
+        book npages pstampJob -var N
+        if ($N == 0) break
+        
+        book getpage pstampJob 0 -var pageName -key pantaskState INIT
+        if ("$pageName" == "NULL") break
+
+        #echo pageName: $pageName
+
+        book setword pstampJob $pageName pantaskState RUN
+        book getword pstampJob $pageName job_id -var JOB_ID
+
+        book listpage pstampJob $pageName
+
+        $run = ppstamp_run.pl $JOB_ID
+
+        # ppstamp_run udpates the state of the job now
+        #$run = pstamptool -processedjob -state stop -status 0 -job_id $JOB_ID
+
+        options $pageName
+
+        if ($VERBOSE > 1) 
+            echo command $run
+        end
+        command $run
+    end
+
+
+    task.exit default
+        if ($VERBOSE > 1)
+            echo pstamp.job.run task.exit $JOB_ID status: $JOB_STATUS
+        end
+        process_exit pstampJob $options:0 $JOB_STATUS
+    end
+
+    task.exit timeout
+        echo pstamp.job.run task.timeout $JOB_ID status: $JOB_STATUS
+        process_exit pstampJob $options:0 $JOB_STATUS
+        showcommand timeout
+        book setword pstampJob $options:0 pantaskState TIMEOUT
+    end
+end
