home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / cli / cliutils_mra.lha / Sources / RequestString.a < prev   
Encoding:
Text File  |  1998-09-02  |  3.7 KB  |  207 lines

  1. ;
  2. ; $VER: RequestString.a v39.2 (c) 1998 by Mauro Panigada
  3. ;
  4. ; Started:  1998.07.20
  5. ; Finished: 1998.07.20
  6. ;
  7. ; Requirements: OS2.1 (#37), 020+ and reqtools.library v38
  8. ; Purpose: replace the known RequestString (by Thomas Kessler)
  9. ; Note: PURE
  10. ;
  11. ; Template: TITLE/A,BODY/A,STRING/K,PUBSCREEN/K,NOLINE/S,NOQUOTE/S,NOEMPTY/S,PASSWORD/S,
  12. ;   REQPOS/N/K
  13. ;
  14. ; Just to say: my rs is shorter, even if the $VER string is longer and also the
  15. ; template (about this, Kessler's RS has surely a bug)
  16. ;
  17.  
  18.  
  19.         incdir    "inc:"
  20.         include    "exec/types.i"
  21.         include    "exec/memory.i"
  22.         include    "exec/libraries.i"
  23.         include    "exec/exec_lib.i"
  24.         include    "dos/dos.i"
  25.         include    "dos/dosextens.i"
  26.         include    "dos/dos_lib.i"
  27.         include    "reqtools/reqtools.i"
  28.         include    "reqtools/reqtools_lib.i"
  29.  
  30.  
  31. CALL        MACRO
  32.         jsr    (_LVO\1,a6)
  33.         ENDM
  34.  
  35.     STRUCTURE internal,0
  36.         LONG    dosbase
  37.         LONG    reqtoolsbase
  38.  
  39.         LABEL    array
  40.         LONG    title
  41.         LONG    body
  42.         LONG    string
  43.         LONG    pubscreen
  44.         LONG    noline
  45.         LONG    noquote
  46.         LONG    noempty
  47.         LONG    password
  48.         LONG    reqpos
  49.  
  50.         LONG    oldstack
  51.  
  52.         WORD    garce
  53.         WORD    returncode
  54.  
  55.         STRUCT    buffer,40
  56.  
  57.         LABEL    s_size
  58.  
  59.  
  60.         opt    p=68020        ; try with new style
  61.  
  62. LIBVERSION    EQU    37
  63.  
  64. REQTOOLSVER    EQU    38
  65.  
  66.  
  67.     SECTION    reqfile,CODE
  68.  
  69.         bra.s    start
  70.  
  71.         dc.b    "$VER: RequestString 39.2 [020+] (1998.07.20) "
  72.         dc.b    "by Mauro Panigada",13,10,0
  73.         even
  74.  
  75. start        
  76.         move.l    sp,a0
  77.         move.w    #(s_size/2)-1,d0
  78. lup        clr.w    -(sp)
  79.         dbf    d0,lup
  80.         move.l    sp,a5
  81.         move.l    a0,(oldstack,a5)
  82.  
  83.         move.b    #20,(returncode+1,a5)
  84.         move.l    (4).w,a6
  85.         lea    (dosname,pc),a1
  86.         moveq    #LIBVERSION,d0
  87.         CALL    OpenLibrary
  88.         move.l    d0,(a5)
  89.         beq    exit0
  90.         lea    (reqtoolsname,pc),a1
  91.         moveq    #REQTOOLSVER,d0
  92.         CALL    OpenLibrary
  93.         move.l    d0,(reqtoolsbase,a5)
  94.         beq    exit0
  95.  
  96.         move.l    (a5),a6
  97.         lea    (template,pc),a0
  98.         move.l    a0,d1
  99.         move.l    a5,d2
  100.         addq.l    #array,d2
  101.         moveq    #0,d3
  102.         CALL    ReadArgs
  103.         move.l    d0,d7            ; d7 = readargs
  104.         beq    doserror
  105.  
  106.         move.l    (reqtoolsbase,a5),a6
  107.  
  108.         move.l    sp,a4            ; old stack (medio)
  109.         clr.l    -(sp)            ; tag_end
  110.         moveq    #0,d0
  111.         bset    #GSREQB_CENTERTEXT,d0
  112.         move.l    d0,-(sp)
  113.         move.l    #RTGS_Flags,-(sp)
  114.         move.l    (noempty,a5),-(sp)
  115.         not.l    (sp)
  116.         move.l    #RTGS_AllowEmpty,-(sp)
  117.         move.l    (body,a5),-(sp)
  118.         move.l    #RTGS_TextFmt,-(sp)
  119.         move.l    (pubscreen,a5),d0
  120.         beq.s    nopubscreen
  121.         move.l    d0,-(sp)
  122.         move.l    #RT_PubScrName,-(sp)
  123. nopubscreen    move.l    (password,a5),-(sp)
  124.         move.l    #RTGS_Invisible,-(sp)
  125.         move.l    (reqpos,a5),d0
  126.         beq.s    noreqpos
  127.         move.l    (d0.l),-(sp)
  128.         move.l    #RT_ReqPos,-(sp)
  129. noreqpos
  130.         tst.l    (string,a5)
  131.         beq.s    nostring
  132.  
  133.         lea    (buffer,a5),a1
  134.         move.l    (string,a5),a0
  135.         moveq    #37,d0
  136. loop1        move.b    (a0)+,(a1)+
  137.         tst.b    -1(a0)
  138.         dbeq    d0,loop1
  139.  
  140. nostring    move.b    #5,(returncode+1,a5)
  141.         move.l    sp,a0
  142.         lea    (buffer,a5),a1
  143.         moveq    #38,d0
  144.         move.l    (title,a5),a2
  145.         suba.l    a3,a3
  146.         CALL    rtGetStringA
  147.         move.l    a4,sp
  148.         tst.l    d0
  149.         beq    exit
  150.  
  151.         clr.b    (returncode+1,a5)
  152.         lea    (replacet,pc),a0
  153.         tst.l    (noquote,a5)
  154.         beq.s    yesquote
  155.         lea    (replacet0,pc),a0
  156. yesquote    move.l    a0,d1
  157.         lea    (buffer,a5),a0
  158.         move.l    a0,-(sp)
  159.         move.l    sp,d2
  160.         move.l    (a5),a6
  161.         CALL    VPrintf
  162.         addq.l    #4,sp
  163.  
  164.         tst.l    (noline,a5)
  165.         bne.s    exit
  166.  
  167.         lea    (accapo,pc),a0
  168.         move.l    a0,d1
  169.         CALL    PutStr
  170.  
  171. exit
  172.         move.l    d7,d1
  173.         move.l    (dosbase,a5),a6
  174.         CALL    FreeArgs
  175. exit0
  176.         move.l    (4).w,a6
  177.         move.l    (a5),a1
  178.         CALL    CloseLibrary
  179.         move.l    (reqtoolsbase,a5),a1
  180.         CALL    CloseLibrary
  181.         move.l    (oldstack,a5),sp
  182.         move.l    (returncode-2,a5),d0
  183.         rts
  184.  
  185. doserror
  186.         CALL    IoErr
  187.         move.l    d0,d1
  188.         moveq    #0,d2
  189.         CALL    PrintFault
  190. frega0        move.b    #20,(returncode+1,a5)
  191.         bra.s    exit0
  192.  
  193.  
  194. ;====================================================================================
  195.  
  196. template
  197.         dc.b    "TITLE/A,BODY/A,STRING/K,PUBSCREEN/K,NOLINE/S,NOQUOTE/S,NOEMPTY/S,PASSWORD/S,REQPOS/N/K",0
  198.  
  199. dosname        dc.b    "dos.library",0
  200. reqtoolsname    dc.b    "reqtools.library",0
  201.  
  202. replacet    dc.b    '"%s"',0
  203. replacet0    dc.b    '%s',0
  204. accapo        dc.b    10,0
  205.  
  206.  
  207.         END