home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / vms / 18238 < prev    next >
Encoding:
Text File  |  1992-11-19  |  4.3 KB  |  125 lines

  1. Path: sparky!uunet!news.claremont.edu!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
  2. From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
  3. Newsgroups: comp.os.vms
  4. Subject: Symbiont to requeue files
  5. Date: 19 Nov 1992 20:09:25 GMT
  6. Organization: HST Wide Field/Planetary Camera
  7. Lines: 113
  8. Message-ID: <1egs9lINNhmm@gap.caltech.edu>
  9. Reply-To: carl@SOL1.GPS.CALTECH.EDU
  10. NNTP-Posting-Host: sol1.gps.caltech.edu
  11.  
  12. Another question that comes up from time to time is regarding how to set up a
  13. symbiont that requeues files to another symbiont.  Here's something that does
  14. something along those lines.  It copies the input file, then submits it to
  15. another queue for processing.  Please note that this program does NOT preserve
  16. ownership of the job, so it would be a *BAD* idea to set it up to resubmit jobs
  17. to a batch queue.
  18.  
  19. The program, as written, takes the device name passed to the output routine and
  20. uses it to determine which queue and which form to use as it resubmits jobs. 
  21. It expects to be initialized with a command of the form:
  22.     $ INIT/QUEUE/ON=formname_queuename/PROCESSOR=this_images_name queue_name
  23. E.g., if you want it to forward jobs to queue TXA5 using form WIDE, you'd
  24.     $ INIT/QUEUE/ON=WIDE_TXA5/PROCESSOR=this_images_name queue_name.
  25. Hope someone finds it useful, at least as a simple example of using the PSM
  26. routines.  By the way, it uses the routine NOTLIB_COPY I posted yesterday, and
  27. copies the files it's working on to SYS$SYSDEVICE:[SPOOL].  The include file
  28. "$psmdef.h" can be derived from the $PSMDEF module of SYS$LIBRARY:LIB.MLB.
  29.  
  30. #include descrip
  31. #include psmmsgdef
  32. #include "$psmdef.h"
  33. long stat;
  34. #define ckstat(x) if(((stat = x) & 7) != 1) return stat
  35. char queue_name[80], form_name[80];
  36. int queue_name_length, form_name_length;
  37. long seqnum = 0;
  38. char format[80];
  39.  
  40. modify()
  41. {    long code1 = PSM$K_MAIN_INPUT, ps_main_input();
  42.     long code2 = PSM$K_OUTPUT, ps_output();
  43.     PSM$REPLACE(&code1, ps_main_input);
  44.     PSM$REPLACE(&code2, ps_output);
  45.     PSM$PRINT(0, 0, 0);
  46. }
  47.  
  48. ps_main_input(long *request_id, long *work_area, long *func, 
  49.     struct dsc$descriptor *funcdesc, long *funcarg)
  50. {    if (*func == PSM$K_OPEN)
  51.      {    char buffer[256];
  52.         $DESCRIPTOR(out_file, buffer);
  53.         
  54.         sprintf(buffer, format, seqnum++);
  55.         out_file.dsc$w_length = strlen(buffer);
  56.         ckstat(notlib_copy(funcdesc, &out_file));
  57.         ckstat(queue_it(&out_file));
  58.     }
  59.     else if (*func == PSM$K_READ)
  60.         return PSM$_EOF;
  61.     else if (*func == PSM$K_READ)
  62.         return 1;
  63.     else
  64.         return PSM$_FUNNOTSUP;
  65. }
  66.  
  67. #include jpidef
  68. ps_output(long *request_id, long *work_area, long *func, 
  69.     struct dsc$descriptor *funcdesc, long *funcarg)
  70. {    char *ptr1, *ptr2;
  71.     if (*func == PSM$K_OPEN)
  72.      {    long iosb[2], pid;
  73.         struct item_code_3
  74.         {    unsigned short buflen, itmcod;
  75.             void *bufadr, *lenadr;
  76.         } itmlst[] =
  77.         {
  78.             {    4,    JPI$_PID,    &pid,    0 },
  79.             {    0,    0,        0,    0 }
  80.         };
  81.  
  82.         ckstat(SYS$GETJPIW(0, 0, 0, itmlst, iosb, 0, 0));
  83.         ckstat(iosb[0]);
  84.         sprintf(format, "SYS$SYSDEVICE:[SPOOL]%08X.%%08X", pid);
  85.         for(ptr1 = form_name, ptr2 = funcdesc->dsc$a_pointer; 
  86.             ((ptr2 - funcdesc->dsc$a_pointer) <
  87.             funcdesc->dsc$w_length) && *ptr2 != '_'; ++ptr2)
  88.             *ptr1++ = *ptr2;
  89.         form_name_length = ptr1 - form_name;
  90.         for(ptr1 = queue_name, ++ptr2;
  91.             (ptr2 - funcdesc->dsc$a_pointer) <
  92.             funcdesc->dsc$w_length; ++ptr2)
  93.             *ptr1++ = *ptr2;
  94.         queue_name_length = ptr1 - queue_name;
  95.     }
  96.     return 1;
  97. }
  98.  
  99. #include sjcdef
  100. queue_it(struct dsc$descriptor *file)
  101. {    long iosb[2];
  102.     struct item_list_3
  103.     {    unsigned short buflen, itmcod;
  104.         void *bufadr, *lenadr;
  105.  
  106.     } itmlst1[] =
  107.     {   {    queue_name_length,    SJC$_QUEUE,    queue_name,    0},
  108.         {file->dsc$w_length,SJC$_FILE_SPECIFICATION,file->dsc$a_pointer,0},
  109.         {    form_name_length,    SJC$_FORM_NAME,    form_name,    0},
  110.         {    0,            SJC$_DELETE_FILE,    0,    0},
  111.         {    0,            0,        0,        0}
  112.     };
  113.  
  114.     ckstat(SYS$SNDJBCW(0, SJC$_ENTER_FILE, 0, itmlst1, iosb, 0, 0));
  115.     return iosb[0];
  116. }
  117. --------------------------------------------------------------------------------
  118. Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
  119.  
  120. Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
  121. understanding of astronomy is purely at the amateur level (or below).  So
  122. unless what I'm saying is directly related to VAX/VMS, don't hold me or my
  123. organization responsible for it.  If it IS related to VAX/VMS, you can try to
  124. hold me responsible for it, but my organization had nothing to do with it.
  125.