home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8710 / vms-vi / 2 < prev    next >
Encoding:
Internet Message Format  |  1990-07-13  |  17.3 KB

  1. Path: uunet!husc6!necntc!ncoast!allbery
  2. From: gregg@a.cs.okstate.edu@mandrill.CWRU.Edu (Gregg Wonderly)
  3. Newsgroups: comp.sources.misc
  4. Subject: VI in TPU part 2/13
  5. Message-ID: <4851@ncoast.UUCP>
  6. Date: 13 Oct 87 02:49:13 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Organization: Oklahoma State Univ., Stillwater
  9. Lines: 885
  10. Approved: allbery@ncoast.UUCP
  11. X-Archive: comp.sources.misc/8710/vms-vi/2
  12.  
  13. $ show default
  14. $ if f$search("SRC.DIR;1") .eqs. "" then -
  15.      CREATE/LOG/DIRECTORY [.SRC]
  16. $ write sys$output "Creating [.SRC]TPUSUBS.MAR"
  17. $ create [.SRC]TPUSUBS.MAR
  18. $ DECK/DOLLARS="*$*$*EOD*$*$*"
  19.         .TITLE    TPUSUBS
  20.  
  21. ;
  22. ;    This file contains TPU CALL_USER support routines for VI.
  23. ;
  24. ;    Written by Gregg Wonderly, June, 1987
  25. ;
  26.  
  27.         $ssdef
  28.         $rmsdef
  29.         $lnmdef
  30.         $iodef
  31.         $qiodef
  32.         $trmdef
  33.         $ttdef
  34.          $dcdef
  35.  
  36. TPU_CWD=1
  37. TPU_TRNLNM_JOB=2
  38. TPU_TRNLNM_PROC=3
  39. TPU_TRNLNM_SYS=4
  40. TPU_TRNLNM_GROUP=5
  41. TPU_GETMSG=6
  42. TPU_SET_SYSDISK=7
  43. TPU_SLEEP=8
  44. TPU_PASTHRU_ON=9
  45. TPU_PASTHRU_OFF=10
  46.  
  47.         .psect    data,rd,wrt,noexe
  48.  
  49.         .macro    trnlnm_item,code,len,bufaddr,retlenaddr
  50.         .word    len
  51.         .word    code
  52.         .address -
  53.             bufaddr
  54.         .address -
  55.             retlenaddr
  56.         .endm
  57.  
  58.         .macro    put_item,buf,code,len,bufaddr,retlenaddr
  59.         movw    len,buf
  60.         movw    code,buf+2
  61.         moval    bufaddr,buf+4
  62.         moval    retlenaddr,buf+8
  63.         .endm
  64.  
  65. sysc_descr:
  66.         .ASCID    /SYS$COMMAND/
  67.  
  68. iochan:
  69.         .word    0
  70.  
  71. newchar_buf:
  72.         .blkl    3
  73. newchar_buf_len = .-newchar_buf
  74. ;
  75. tempchar_buf:
  76.         .blkb    newchar_buf_len
  77. ;
  78. par_settings:
  79.         .long    0
  80.  
  81. tt_descr:
  82.         .ASCID    /TT:/
  83. job_descr:
  84.         .ASCID    /LNM$JOB/
  85. sys_descr:
  86.         .ASCID    /LNM$SYSTEM/
  87. proc_descr:
  88.         .ASCID    /LNM$PROCESS/
  89. group_descr:
  90.         .ASCID    /LNM$GROUP/
  91. sysdisk_descr:
  92.         .ASCID    /SYS$DISK/
  93.  
  94. itemlist:
  95.         trnlnm_item    0,0,0,0
  96. itemlist_2:
  97.         trnlnm_item    0,0,0,0
  98.  
  99. msgnum:
  100.         .long    0
  101. stat:
  102.         .long    0
  103. i_parm_descr:
  104.         .blkb    8
  105. i_res_descr:
  106.         .blkb    8
  107. i_parm:
  108.         .blkb    512
  109. i_res:
  110.         .blkb    512
  111.  
  112. timebuf:
  113.         .long    0
  114.         .long    0
  115.  
  116. dummy:
  117.         .long    0
  118.  
  119. tenths=-1000000
  120.  
  121.         .psect    code,exe,rd,nowrt,pic
  122. ;
  123. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  124. ;
  125. ;
  126. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  127. ;
  128.  
  129.         .entry    sleep,^m<r2,r3,r4,r5,r6>
  130.         movl    4(ap),r0
  131.         mull3    r0,#tenths,r1
  132.         movl    r1,timebuf
  133.         movl    #-1,timebuf+4
  134.         $schdwk_s -
  135.             daytim=timebuf
  136.         blbc    r0,10$
  137.         $hiber_s
  138.         blbs    r0,20$
  139. 10$:
  140.         pushl    r0
  141.         calls    #1,g^lib$signal
  142. 20$:
  143.         ret
  144. ;
  145. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  146. ;
  147. ;
  148. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  149. ;
  150.  
  151.         .entry    atoi,^m<r2,r3,r4,r5>
  152.         movl    4(ap),r0        ;Get the descriptor address
  153.         clrl    r1            ;Clear the accumulator
  154.         movl    4(r0),r2        ;Get the string address
  155.         cvtwl    (r0),r0            ;Get the length
  156. 10$:
  157.         mull2    #10,r1            ;multiply by 10
  158.         cvtbl    (r2)+,r3
  159.         addl3    r3,#-48,r4        ;Add in digit
  160.         addl    r4,r1
  161.         sobgtr    r0,10$
  162.         movl    r1,r0
  163.         ret
  164.  
  165. ;
  166. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  167. ;
  168. ;
  169. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  170. ;
  171.         .entry    tpu$calluser,^m<r2,r3,r4,r5>
  172.  
  173.         movl    #512,i_res_descr
  174.         movab    i_res,i_res_descr+4
  175.  
  176.         movl    #512,i_parm_descr
  177.         movab    i_parm,i_parm_descr+4
  178.  
  179.         pushl    8(ap)
  180.         pushab    i_parm_descr
  181.         calls    #2,g^str$copy_dx
  182.  
  183.         pushab    dummy
  184.         pushab    i_parm_descr
  185.         pushl    8(ap)
  186.         calls    #3,g^str$analyze_sdesc
  187.  
  188.         put_item -
  189.             itemlist,#lnm$_string,#512,i_res,i_res_descr
  190.  
  191.         put_item -
  192.             itemlist_2,#0,#0,#0,#0
  193.  
  194.         movl    4(ap),r1
  195.         casew    (r1),#TPU_CWD,#TPU_PASTHRU_OFF
  196. case_1:
  197.         .word    do_cwd - case_1
  198.         .word    do_trnlnm_job - case_1
  199.         .word    do_trnlnm_proc - case_1
  200.         .word    do_trnlnm_sys - case_1
  201.         .word    do_trnlnm_group - case_1
  202.         .word    do_getmsg - case_1
  203.         .word    do_set_sysdisk - case_1
  204.         .word    do_sleep - case_1
  205.         .word    do_pasthru_on - case_1
  206.         .word    do_pasthru_off - case_1
  207. ;
  208.         .word    case_2 - case_1
  209. case_2:
  210.         movl    #SS$_BADPARAM,r0
  211.         ret
  212.  
  213. ;
  214. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  215. ;
  216. ;
  217. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  218. ;
  219. do_cwd:
  220.         movw    i_parm_descr,r1        ;Get the length of parameter
  221.         tstl    r1            ;If zero, then get current dir
  222.         bneq    10$
  223.         pushal    i_res_descr        ;Push args
  224.         pushal    i_res_descr
  225.         pushl    #0
  226.         calls    #3,g^sys$setddir
  227.         brw    out
  228. 10$:                        ;Otherwise set the current dir
  229.         pushal    i_res_descr
  230.         pushal    i_res_descr
  231.         pushal    i_parm_descr
  232.         calls    #3,g^sys$setddir
  233.         brw    out
  234.         
  235. ;
  236. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  237. ;
  238. ;
  239. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  240. ;
  241. do_trnlnm_job:
  242.         $trnlnm_s -
  243.             attr=#LNM$M_CASE_BLIND,-
  244.             tabnam=job_descr,-
  245.             lognam=i_parm_descr,-
  246.             itmlst=itemlist
  247.         brw    out
  248.  
  249. ;
  250. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  251. ;
  252. ;
  253. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  254. ;
  255. do_trnlnm_proc:
  256.         $trnlnm_s -
  257.             attr=#LNM$M_CASE_BLIND,-
  258.             tabnam=proc_descr,-
  259.             lognam=i_parm_descr,-
  260.             itmlst=itemlist
  261.         brw    out
  262.  
  263. ;
  264. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  265. ;
  266. ;
  267. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  268. ;
  269. do_trnlnm_sys:
  270.         $trnlnm_s -
  271.             attr=#LNM$M_CASE_BLIND,-
  272.             tabnam=sys_descr,-
  273.             lognam=i_parm_descr,-
  274.             itmlst=itemlist
  275.         brw    out
  276.  
  277. ;
  278. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  279. ;
  280. ;
  281. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  282. ;
  283. do_trnlnm_group:
  284.         $trnlnm_s -
  285.             attr=#LNM$M_CASE_BLIND,-
  286.             tabnam=group_descr,-
  287.             lognam=i_parm_descr,-
  288.             itmlst=itemlist
  289.         brw    out
  290.  
  291. ;
  292. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  293. ;
  294. ;
  295. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  296. ;
  297. do_getmsg:
  298.         pushal    i_parm_descr        ;Convert the string to a number
  299.         calls    #1,atoi
  300.         movl    r0,msgnum        ;Store the result
  301.         movl    #512,i_res_descr
  302.         $getmsg_s -
  303.             msgid=msgnum,-
  304.             msglen=i_res_descr,-
  305.             bufadr=i_res_descr
  306.         brw    out
  307.  
  308. ;
  309. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  310. ;
  311. ;
  312. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  313. ;
  314. do_set_sysdisk:
  315.         pushal    i_parm_descr
  316.         pushal    sysdisk_descr
  317.         calls    #2,g^lib$set_logical
  318.         clrl    i_res_descr
  319.         brw    out
  320.  
  321. ;
  322. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  323. ;
  324. ;
  325. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  326. ;
  327. do_sleep:
  328.         pushal    i_parm_descr        ;Convert the string to a number
  329.         calls    #1,atoi
  330.         pushl    r0
  331.         calls    #1,sleep
  332.         clrl    i_res_descr
  333.         brw    out
  334.  
  335. ;
  336. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  337. ;
  338. ;
  339. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  340. ;
  341. do_pasthru_on:
  342.         $assign_s -
  343.             devnam=tt_descr,-
  344.             chan=iochan
  345.         blbs    r0,10$
  346. 5$:
  347.         pushl    r0
  348.         pushl    r0
  349.         calls    #1,g^lib$signal
  350.         movl    (sp)+,r0
  351.         brw    out
  352. 10$:
  353.         movab    dassign,(fp)
  354.         $qiow_s -
  355.             chan=iochan,-
  356.             func=#IO$_SENSEMODE,-
  357.             p1=newchar_buf,-
  358.             p2=#newchar_buf_len
  359.         blbs    r0,20$
  360. 15$:
  361.         movl    r0,r2
  362.         $dassgn_s -
  363.             chan=iochan
  364.         clrw    iochan
  365.         movl    r2,r0
  366.         brw    5$
  367. ;
  368. 20$:
  369.         bisl2    #TT2$M_PASTHRU,newchar_buf+8
  370.         $qiow_s -
  371.             chan=iochan,-
  372.             func=#IO$_SETMODE,-
  373.             p1=newchar_buf,-
  374.             p2=#newchar_buf_len
  375.         blbc    r0,15$
  376.  
  377.         $dassgn_s -
  378.             chan=iochan
  379.         clrw    iochan
  380.         clrl    (fp)
  381.         clrl    i_res_descr
  382.         brw    out
  383.  
  384. ;
  385. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  386. ;
  387. ;
  388. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  389. ;
  390.         .entry    dassign,^m<>
  391.         tstw    iochan
  392.         beql    10$
  393.         $dassgn_s -
  394.             chan=iochan
  395.         clrw    iochan
  396. 10$:
  397.         clrl    i_res_descr
  398.         ret
  399.  
  400. ;
  401. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  402. ;
  403. ;
  404. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  405. ;
  406. do_pasthru_off:
  407.         $assign_s -
  408.             devnam=tt_descr,-
  409.             chan=iochan
  410.         blbs    r0,10$
  411. 5$:
  412.         pushl    r0
  413.         pushl    r0
  414.         calls    #1,g^lib$signal
  415.         movl    -(sp),r0
  416.         brw    out
  417. 10$:
  418.         movab    dassign,(fp)
  419.         $qiow_s -
  420.             chan=iochan,-
  421.             func=#IO$_SENSEMODE,-
  422.             p1=newchar_buf,-
  423.             p2=#newchar_buf_len
  424.         blbs    r0,20$
  425. 15$:
  426.         movl    r0,r2
  427.         $dassgn_s -
  428.             chan=iochan
  429.         clrw    iochan
  430.         movl    r2,r0
  431.         brw    5$
  432. ;
  433. 20$:
  434.         bicl2    #TT2$M_PASTHRU,newchar_buf+8
  435.         $qiow_s -
  436.             chan=iochan,-
  437.             func=#IO$_SETMODE,-
  438.             p1=newchar_buf,-
  439.             p2=#newchar_buf_len
  440.         blbc    r0,15$
  441.  
  442.         $dassgn_s -
  443.             chan=iochan
  444.         clrw    iochan
  445.         clrl    (fp)
  446.         clrl    i_res_descr
  447.         brw    out
  448.  
  449. ;
  450. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  451. ;
  452. ;
  453. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  454. ;
  455. out:
  456.         blbc    r0,err
  457.         pushal    i_res_descr
  458.         pushl    12(ap)
  459.         calls    #2,g^str$copy_dx
  460.  
  461.         movl    12(ap),r1
  462.         movw    i_res_descr,(r1)
  463.         movl    #SS$_NORMAL,r0
  464. err:
  465.         ret
  466.         .end
  467. *$*$*EOD*$*$*
  468. $ if f$search("SRC.DIR;1") .eqs. "" then -
  469.      CREATE/LOG/DIRECTORY [.SRC]
  470. $ write sys$output "Creating [.SRC]VI.MAR"
  471. $ create [.SRC]VI.MAR
  472. $ DECK/DOLLARS="*$*$*EOD*$*$*"
  473. ;
  474. ;    This file contains the source to a program that exercises callable
  475. ;    TPU.  You will be interested in using this program ONLY if you
  476. ;    make use of more than ONE TPU utility that requires a CALL_USER
  477. ;    routine, and/or you like to define TPUSECINI as opposed to using
  478. ;    the /SECTION quailfier of EDIT/TPU.
  479. ;
  480. ;    This program expects to be able to use the VI$CALLUSER logical
  481. ;    to find the call_user routines for VI.  It also uses VISECINI
  482. ;    for the name of the TPU section file.  Just to be complete, it will
  483. ;    also use TPU$CALLUSER and TPUSECINI if the VI logicals do not exist.
  484. ;
  485. ;    Written by Gregg Wonderly, 10-jul-1987
  486. ;
  487.         $ssdef
  488.         $lnmdef
  489.         $psldef
  490.         $fabdef
  491.         $rabdef
  492.         $namdef
  493.         .macro    item,code,blen,badr,radr
  494.         .word    blen
  495.         .word    code
  496.         .address -
  497.             badr
  498.         .address -
  499.             radr
  500.         .endm
  501.  
  502. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  503. ;
  504. ;    Program data section
  505. ;
  506. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  507.  
  508.         .psect    rwdata,rd,wrt,noexe
  509.  
  510. fabdef:
  511.         $fab
  512. fablen=.-fabdef
  513.  
  514. rabdef:
  515.         $rab
  516. rablen=.-rabdef
  517.  
  518. namdef:
  519.         $nam
  520. namlen=.-namdef
  521.  
  522. blkdescr:
  523.         .address    0
  524. exit_h:
  525.         .long    0
  526.         .address exit_handler
  527.         .long    0
  528.         .address exit_stat
  529. ;
  530. exit_stat:
  531.         .long    0
  532. ;
  533. clean_flags:
  534.         .long    TPU$M_DELETE_JOURNAL!-
  535.             TPU$M_DELETE_EXITH!-
  536.             TPU$M_RESET_TERMINAL!-
  537.             TPU$M_KILL_PROCESSES!-
  538.             TPU$M_LAST_TIME
  539. bvpval:
  540.         .long    0
  541. ;
  542. bvp:
  543.         .address -
  544.             tpu_init
  545.         .long    0
  546. ;
  547. calluserd:
  548.         .long    0
  549.         .long    0
  550. ;
  551. fileiod:
  552.         .address -
  553.             TPU$FILEIO
  554.         .long    0
  555. ;
  556. crelnm_items:
  557.         item    LNM$_STRING,0,trnlnm_string,dummy
  558.         .long    0
  559. dummy:
  560.         .long    0
  561.  
  562. trnlnm_items:
  563.         item    LNM$_STRING,512,trnlnm_string,string_len
  564.         .long    0
  565.         .long    0
  566.  
  567. trnlnm_string:
  568.         .blkb    512
  569.  
  570. sectdescr:
  571. string_len:
  572.         .long
  573.         .address -
  574.             trnlnm_string
  575.  
  576. vicalldescr:
  577.         .ascid    /VI$CALLUSER/
  578.  
  579. tpucalldescr:
  580.         .ascid    /TPU$CALLUSER/
  581.  
  582. visectdescr:
  583.         .ascid    /VISECINI/
  584.  
  585. tpusectdescr:
  586.         .ascid    /TPUSECINI/
  587.  
  588. procdescr:
  589.         .ascid    /LNM$PROCESS_TABLE/
  590.  
  591. badvicall:
  592.         .ascid    /%VI-F-BADTPUCALL, improper definition of VI$CALLUSER/
  593.  
  594. badtpucall:
  595.         .ascid    /%VI-F-BADTPUCALL, improper definition of TPU$CALLUSER/
  596.  
  597. nocalluser:
  598.         .ascid    /%VI-F-NOCALLUSER, no calluser routine could be loaded/
  599.  
  600.         .psect    code,rd,exe,nowrt
  601.  
  602.         .entry    noerr,^m<>
  603.         ret
  604.  
  605. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  606. ;
  607. ;    The program itself, straight forward no?
  608. ;
  609. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  610.  
  611.         .entry    viedit,^m<r2,r3,r4,r5,r6>
  612.  
  613.         movab    noerr,(fp)        ;Forget about errors we will
  614.                         ;handle them
  615.         pushal    calluserd        ;Push return address location
  616.         pushab    tpucalldescr        ;Routine name
  617.         pushab    vicalldescr        ;Image to search through
  618.         calls    #3,g^lib$find_image_symbol    ;Find the symbol
  619.         blbs    r0,10$            ;Branch on success
  620. ;
  621.         cmpl    r0,#RMS$_FNF        ;If FNF then try TPU$CALLUSER
  622.         beql    5$
  623.         pushl    r0            ;Save the exit value
  624.         pushab    badvicall        ;Pass the right message
  625.         brw    8$            ;Join the other code
  626. 5$:
  627. ;
  628. ;    There is no VI$CALLUSER image, so try TPU$CALLUSER.
  629. ;
  630.         pushal    calluserd        ;Push return address location
  631.         pushab    tpucalldescr        ;Routine name
  632.         pushab    tpucalldescr        ;Image to search through
  633.         calls    #3,g^lib$find_image_symbol    ;Find the symbol
  634.         blbs    r0,10$            ;Branch if we got that
  635.  
  636.         pushl    r0            ;Save the status
  637.  
  638.         cmpl    r0,#RMS$_FNF        ;If FNF then say the right thin
  639. g
  640.         beql    7$            ;Go set up the right parameter
  641.  
  642.         pushab    badtpucall        ;Push the message descr
  643.         brb    8$            ;Join other code
  644. ;
  645. 7$:
  646.         pushab    nocalluser        ;Push the message descr
  647. ;
  648. 8$:
  649.         calls    #1,g^lib$put_output    ;Output the message
  650.         calls    #1,g^lib$stop        ;Stop with the status pushed
  651. ;
  652. ;    Got the calluser routine, continue processing
  653. ;
  654. 10$:
  655.         clrl    (fp)            ;Remove condition handler
  656.  
  657.         $trnlnm_s -
  658.             tabnam=procdescr,-
  659.             lognam=visectdescr,-
  660.             itmlst=trnlnm_items    ;Get the VISECINI defintion
  661.         blbc    r0,20$            ;If that fails then don't worry
  662.                         ;If /SECTION is not there, then
  663.                         ;TPU will bark for us.
  664.  
  665.         pushaq    sectdescr        ;On success, redefine TPUSECINI
  666.         pushaq    tpusectdescr        ;to be VISECINI's value
  667.         calls    #2,g^lib$set_logical
  668.         blbs    r0,20$
  669.         pushl    r0
  670.         calls    #1,g^lib$signal        ;Signal the condition
  671. 20$:
  672.         movab    g^tpu$handler,(fp)    ;Establish tpu$handler
  673.  
  674.         pushab    calluserd        ;Pass the BVP's to parseinfo
  675.         pushab    fileiod            ;Use TPU$FILEIO
  676.         calls    #2,g^tpu$parseinfo    ;Get the command line stuff
  677.         movl    r0,bvpval        ;This is the value for the
  678.                         ;call back routine to return
  679.                         ;to tpu$initialize, so save it.
  680.  
  681.         pushab    bvp            ;Pass the BVP for the callback
  682.         calls    #1,g^tpu$initialize    ;Initialize TPU
  683.         blbc    r0,err            ;Branch on error
  684.  
  685.         $dclexh_s -
  686.             desblk=exit_h        ;Establish an exit handler
  687.         blbc    r0,err
  688.  
  689.         calls    #0,g^tpu$execute_inifile ;Execute the initialization
  690.  
  691.         blbc    r0,err
  692.         cmpl    r0,#TPU$_SUCCESS
  693.         bneq    done            ;Skip control if not SUCCESS
  694.  
  695.         calls    #0,g^tpu$control    ;Call control to do editing.
  696.         blbc    r0,err
  697. done:
  698.         brb    out
  699. err:
  700.         pushl    r0            ;Signal any error
  701.         calls    #1,g^lib$signal
  702.  
  703. out:
  704.         ret                ;Back to caller
  705. ;
  706. ;    Merely return the value that tpu$parseinfo returned to us
  707. ;
  708.         .entry    tpu_init,^m<>
  709.         movl    bvpval,r0
  710.         ret
  711.  
  712. ;
  713. ;    This exit handler is called at image exit to cleanup the things that
  714. ;    are of no more interest to us.  Sadly enough, there is not a perfect
  715. ;    policy for the journal file that satisfies everyone.  I have always
  716. ;    written out my changes from time to time, so I really don't ever use
  717. ;    the journal.  The current itemlist to tpu$cleanup causes the journal
  718. ;    to be deleted.  WARNING, don't $FORCEX a VI that you wish to have the
  719. ;    journal from.
  720. ;
  721.         .entry    exit_handler,^m<>
  722.         pushal    clean_flags
  723.         calls    #1,g^tpu$cleanup
  724.         movl    exit_stat,r0
  725.         ret
  726.  
  727. ;
  728. ;
  729. ;
  730. ;
  731.         .entry    vi$fileio,^m<r2,r3,r4,r5,r6,r7,r8,r9>
  732.  
  733.         movl    @4(ap),r1        ;Get the code
  734.         cmpl    r1,#TPU$K_OPEN
  735.         bneq    10$
  736.         jmp    tpu_open
  737. ;
  738. 10$:
  739.         cmpl    r1,#TPU$K_CLOSE
  740.         bneq    20$
  741.         jmp    tpu_close
  742. ;
  743. 20$:
  744.         cmpl    r1,#TPU$K_CLOSE_DELETE
  745.         bneq    30$
  746.         jmp    tpu_close_delete
  747. ;
  748. 30$:
  749.         cmpl    r1,#TPU$K_GET
  750.         bneq    40$
  751.         jmp    tpu_get
  752. ;
  753. 40$:
  754.         cmpl    r1,#TPU$K_PUT
  755.         beql    tpu_put
  756.         movl    #SS$_BADPARAM,r0
  757.         ret
  758. ;
  759. ;    $PUT routine for VI to use
  760. ;
  761. tpu_put:
  762.         
  763. ;
  764. ;    $GET routine for VI to use
  765. ;
  766. tpu_get:
  767.  
  768. ;
  769. ;    $CLOSE with delete for VI to use
  770. ;
  771. tpu_close_delete:
  772.  
  773. ;
  774. ;    $CLOSE for VI to use
  775. ;
  776. tpu_close:
  777.  
  778. ;
  779. ;    $OPEN for VI to use
  780. ;
  781. tpu_open:
  782.  
  783.  
  784.         ret
  785.         .end    viedit
  786. *$*$*EOD*$*$*
  787. $ if f$search("SRC.DIR;1") .eqs. "" then -
  788.      CREATE/LOG/DIRECTORY [.SRC]
  789. $ write sys$output "Creating [.SRC]TPUSUBS.OPT"
  790. $ create [.SRC]TPUSUBS.OPT
  791. $ DECK/DOLLARS="*$*$*EOD*$*$*"
  792. TPUSUBS.OBJ
  793. UNIVERSAL=TPU$CALLUSER
  794. *$*$*EOD*$*$*
  795. $ if f$search("SRC.DIR;1") .eqs. "" then -
  796.      CREATE/LOG/DIRECTORY [.SRC]
  797. $ write sys$output "Creating [.SRC]STEPWISE.TPU"
  798. $ create [.SRC]STEPWISE.TPU
  799. $ DECK/DOLLARS="*$*$*EOD*$*$*"
  800. PROCEDURE step_compile (fn)
  801.     LOCAL
  802.         pos,
  803.         buf,
  804.         spos,
  805.         epos,
  806.         rng;
  807.  
  808.     ON_ERROR
  809.         IF ERROR = TPU$_COMPILEFAIL THEN
  810.             QUIT;
  811.         ENDIF;
  812.     ENDON_ERROR
  813.  
  814.     buf := CREATE_BUFFER ("$$temp_buf$$", fn);
  815.     IF (buf = 0) THEN
  816.         MESSAGE ("Error loading file!!!");
  817.         RETURN;
  818.     ENDIF;
  819.  
  820.     POSITION (BEGINNING_OF (buf));
  821.     pos := MARK (NONE);
  822.     LOOP
  823.         rng := SEARCH (line_begin & "PROC", FORWARD, EXACT);
  824.         EXITIF (rng = 0);
  825.         spos := BEGINNING_OF (rng);
  826.         POSITION (spos);
  827.         MESSAGE (CURRENT_LINE);
  828.         rng := SEARCH (line_begin & "ENDPROC", FORWARD, EXACT);
  829.         EXITIF (rng = 0);
  830.         epos := BEGINNING_OF (rng);
  831.         POSITION (epos);
  832.         MOVE_VERTICAL (1);
  833.         pos := MARK (NONE);
  834.         MOVE_HORIZONTAL (-1);
  835.         COMPILE (CREATE_RANGE (spos, MARK (NONE), NONE));
  836.     ENDLOOP;
  837.  
  838.     POSITION (pos);
  839.     COMPILE ("PROCEDURE step_compile ENDPROCEDURE;");
  840.     EXECUTE (COMPILE (CREATE_RANGE (pos, END_OF (CURRENT_BUFFER), NONE)));
  841. ENDPROCEDURE;
  842.  
  843. step_compile (GET_INFO (COMMAND_LINE, "FILE_NAME"));
  844. quit;
  845. *$*$*EOD*$*$*
  846. $ if f$search("SRC.DIR;1") .eqs. "" then -
  847.      CREATE/LOG/DIRECTORY [.SRC]
  848. $ write sys$output "Creating [.SRC]MAKE.COM"
  849. $ create [.SRC]MAKE.COM
  850. $ DECK/DOLLARS="*$*$*EOD*$*$*"
  851. $ do="@[-.exe]do"
  852. $ if f$logical ("vi$root") .nes. "" THEN do="@[exe]do"
  853. $ if p1 .eqs. "ALL" then p1="TPUSUBS,EXE,VI"
  854. $ if p1 .eqs. "" then p1 = "VI"
  855. $ opers =","+p1+","
  856. $ i = 1
  857. $!
  858. $ NEXT_ELEM:
  859. $    next = f$element (i, ",", opers)
  860. $    i = i + 1
  861. $    if (next .eqs. "") .or. (next .eqs. ",") then goto done
  862. $    write sys$output "* Making ''next'"
  863. $    on warning then goto go_err
  864. $    goto 'next'
  865. $ go_err:
  866. $    write sys$output "   \''next'\"
  867. $    goto next_elem 
  868. $!
  869. $ VI:
  870. $    on warning then stop
  871. $    do edit/tpu/command=stepwise.tpu/nodispay/nosection vi.tpu
  872. $    do rename vi.gbl [-.exe]
  873. $    goto next_elem
  874. $!
  875. $ TPUSUBS:
  876. $    on warning then stop
  877. $    do macro tpusubs
  878. $    do link/share/exe=[-.exe]tpusubs tpusubs/opt
  879. $    goto next_elem
  880. $!
  881. $ EXE:
  882. $    on warning then stop
  883. $    do macro vi
  884. $    do link/exe=[-.exe]vi vi
  885. $    goto next_elem
  886. $!
  887. $ CLEAN:
  888. $    on warning then stop
  889. $    do purge/log VI$ROOT:[*...]*.*
  890. $    do delete/log VI$ROOT:[SRC]*.obj;,VI$ROOT:[SRC]MAKE.OUT;
  891. $    goto next_elem
  892. $!
  893. $ DONE:
  894. $    on warning then stop
  895. $    exit
  896. *$*$*EOD*$*$*
  897. $ exit
  898.