home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / cli / cliutils_mra.lha / Sources / RequestFile / RequestFile2.a < prev   
Encoding:
Text File  |  1999-02-22  |  10.2 KB  |  334 lines

  1. ;
  2. ; $VER: RequestFile.a v36.2 (c) 1998 by Mauro Panigada
  3. ;
  4. ; Started:  1998.07.16
  5. ; Finished: 1998.07.16
  6. ;
  7. ; Requirements: OS2.0 (#36), 020+
  8. ; Purpose: replace the known RequestFile
  9. ; Note: PURE
  10. ;
  11. ; Template: DRAWER,FILE/K,PATTERN/K,TITLE/K,POSITIVE/K,NEGATIVE/K,ACCEPTPATTERN/K,
  12. ;   REJECTPATTERN/K,SAVEMODE/S,MULTISELECT/S,DRAWERSONLY/S,NOICONS/S,PUBSCREEN/K,
  13. ;   NOQUOTES/S
  14. ;
  15. ; Note: * when in multiselect mode, the last drawers/file will have a space after
  16. ;   him; but the program which analyzes that line, should not have any problem, if
  17. ;   it is well written.
  18. ;
  19. ; History:     1998.07.16         v36.1
  20. ;              1998.10.21         added NOQUOTES and enlarged AddPart buffer.
  21. ;                                 v36.2
  22. ;              1998.11.06         (first on Aminet release)
  23. ;
  24.  
  25.                 incdir  "inc:"
  26.                 include "exec/types.i"
  27.                 include "exec/memory.i"
  28.                 include "exec/libraries.i"
  29.                 include "exec/exec_lib.i"
  30.                 include "dos/dos.i"
  31.                 include "dos/dosextens.i"
  32.                 include "dos/dos_lib.i"
  33.                 include "intuition/intuition.i"
  34.                 include "intuition/intuition_lib.i"
  35.                 include "libraries/asl.i"
  36.                 include "libraries/asl_lib.i"
  37.  
  38.  
  39. call            MACRO
  40.                 jsr     (_LVO\1,a6)
  41.                 ENDM
  42.  
  43.         STRUCTURE internal,0
  44.                 LONG    execbase
  45.                 LONG    dosbase
  46.                 LONG    aslbase
  47.  
  48.                 LABEL   array
  49.                 LONG    drawer
  50.                 LONG    file
  51.                 LONG    pattern
  52.                 LONG    title
  53.                 LONG    positive
  54.                 LONG    negative
  55.                 LONG    acceptpattern
  56.                 LONG    rejectpattern
  57.                 LONG    savemode
  58.                 LONG    multiselect
  59.                 LONG    drawersonly
  60.                 LONG    noicons
  61.                 LONG    pubscreen
  62.                 LONG    noquotes
  63.  
  64.                 LONG    oldstack
  65.  
  66.                 WORD    returncode
  67.  
  68.                 STRUCT  buffer,150
  69.  
  70.                 STRUCT  rejectbuffer,32
  71.                 STRUCT  acceptbuffer,32
  72.  
  73.                 LABEL   s_size
  74.  
  75.  
  76.                 opt     p=68020         ; try with new style
  77.  
  78. LIBVERSION      EQU     36
  79.  
  80.  
  81.         SECTION reqfile,CODE
  82.  
  83.                 bra.s   start
  84.  
  85.                 dc.b    "$VER: RequestFile 36.2 [020+] (1998.10.21) "
  86.                 dc.b    "by Mauro Panigada",13,10,0
  87.                 even
  88.  
  89. start           move.l  sp,a0
  90.                 move.w  #(s_size/2)-1,d0
  91. lup             clr.w   -(sp)
  92.                 dbf     d0,lup
  93.                 move.l  sp,a5
  94.                 move.l  a0,(oldstack,a5)
  95.  
  96.                 move.b  #30,(returncode+1,a5)
  97.                 move.l  (4).w,a6
  98.                 move.l  a6,(a5)
  99.                 lea     (dosname,pc),a1
  100.                 moveq   #LIBVERSION,d0
  101.                 call    OpenLibrary
  102.                 move.l  d0,(dosbase,a5)
  103.                 beq     exit0
  104.                 lea     (aslname,pc),a1
  105.                 moveq   #LIBVERSION,d0
  106.                 call    OpenLibrary
  107.                 move.l  d0,(aslbase,a5)
  108.                 beq     exit0
  109.  
  110.                 clr.b   (returncode+1,a5)
  111.                 move.l  (dosbase,a5),a6
  112.                 lea     (template,pc),a0
  113.                 move.l  a0,d1
  114.                 move.l  a5,d2
  115.                 add.l   #array,d2
  116.                 moveq   #0,d3
  117.                 call    ReadArgs
  118.                 move.l  d0,d7                   ; d7 = readargs
  119.                 beq     doserror
  120.  
  121. ; qui crea i tags per aprire il requester....
  122.  
  123.                 suba.l  a0,a0
  124.                 moveq   #ASL_FileRequest,d0
  125.                 move.l  (aslbase,a5),a6
  126.                 call    AllocAslRequest
  127.                 move.l  d0,d6                   ; d6 = asl request
  128.                 beq     aslerror
  129.  
  130.                 move.l  (dosbase,a5),a6
  131.                 move.l  sp,a4                   ; a4 = mediostack
  132.                 clr.l   -(sp)
  133.                 move.l  (pubscreen,a5),d0
  134.                 beq.s   nops
  135.                 move.l  d0,-(sp)
  136.                 move.l  #ASLFR_PubScreenName,-(sp)
  137. nops            move.l  (drawer,a5),d0
  138.                 beq.s   nodrawer
  139.                 move.l  d0,-(sp)
  140.                 move.l  #ASLFR_InitialDrawer,-(sp)
  141. nodrawer        move.l  (file,a5),d0
  142.                 beq.s   nofile
  143.                 move.l  d0,-(sp)
  144.                 move.l  #ASLFR_InitialFile,-(sp)
  145. nofile          move.l  (pattern,a5),d0
  146.                 beq.s   nopatt
  147.                 move.l  d0,-(sp)
  148.                 move.l  #ASLFR_InitialPattern,-(sp)
  149.                 move.l  #1,-(sp)
  150.                 move.l  #ASLFR_DoPatterns,-(sp)
  151. nopatt          move.l  (title,a5),d0
  152.                 beq.s   notit
  153.                 move.l  d0,-(sp)
  154.                 move.l  #ASLFR_TitleText,-(sp)
  155. notit           move.l  (positive,a5),d0
  156.                 beq.s   noposi
  157.                 move.l  d0,-(sp)
  158.                 move.l  #ASLFR_PositiveText,-(sp)
  159. noposi          move.l  (negative,a5),d0
  160.                 beq.s   nonega
  161.                 move.l  d0,-(sp)
  162.                 move.l  #ASLFR_NegativeText,-(sp)
  163. nonega          move.l  (acceptpattern,a5),d1
  164.                 beq.s   noap
  165.                 lea     (acceptbuffer,a5),a0
  166.                 move.l  a0,d2
  167.                 moveq   #32,d3
  168.                 call    ParsePatternNoCase
  169.                 lea     (acceptbuffer,a5),a0
  170.                 move.l  a0,-(sp)
  171.                 move.l  #ASLFR_AcceptPattern,-(sp)
  172. noap            move.l  (rejectpattern,a5),d1
  173.                 beq.s   norejp
  174.                 lea     (rejectbuffer,a5),a0
  175.                 move.l  a0,d2
  176.                 moveq   #32,d3
  177.                 call    ParsePatternNoCase
  178.                 lea     (rejectbuffer,a5),a0
  179.                 move.l  a0,-(sp)
  180.                 move.l  #ASLFR_RejectPattern,-(sp)
  181. norejp          move.l  (savemode,a5),d0
  182.                 beq.s   nosamo
  183.                 move.l  d0,-(sp)
  184.                 move.l  #ASLFR_DoSaveMode,-(sp)
  185. nosamo          move.l  (multiselect,a5),d0
  186.                 beq.s   nomusel
  187.                 move.l  d0,-(sp)
  188.                 move.l  #ASLFR_DoMultiSelect,-(sp)
  189. nomusel         move.l  (drawersonly,a5),d0
  190.                 beq.s   nodon
  191.                 move.l  d0,-(sp)
  192.                 move.l  #ASLFR_DrawersOnly,-(sp)
  193. nodon           move.l  (noicons,a5),d0
  194.                 beq.s   nonoi
  195.                 move.l  d0,-(sp)
  196.                 move.l  #ASLFR_RejectIcons,-(sp)
  197. nonoi
  198.  
  199.                 move.b  #20,(returncode+1,a5)
  200.                 move.l  d6,a0
  201.                 move.l  sp,a1
  202.                 move.l  (aslbase,a5),a6
  203.                 call    AslRequest
  204.                 move.l  a4,sp
  205.                 tst.l   d0
  206.                 beq     exit2
  207.  
  208.                 clr.b   (returncode+1,a5)
  209.                 move.l  d6,a0
  210.                 tst.l   (multiselect,a5)
  211.                 bne     yesmulsel
  212.  
  213.                 move.l  (fr_File,a0),d2
  214.                 bsr     CAddPart
  215.  
  216.                 lea     (replacet,pc),a0
  217.                 tst.l   (noquotes,a5)
  218.                 beq.s   rplnq
  219.                 lea     (replacetn,pc),a0
  220. rplnq           bsr     CWrite
  221.                 bra     exit2
  222.  
  223. yesmulsel
  224.                 move.l  (fr_NumArgs,a0),d4
  225.                 subq.w  #1,d4                   ; numero argomenti
  226.                 move.l  (fr_ArgList,a0),a4
  227.                 cmp.l   #0,a4
  228.                 beq     unknownerr
  229.  
  230. yms_loop        addq.l  #4,a4
  231.                 move.l  (a4)+,d2
  232.                 bsr     CAddPart
  233.                 lea     (replacet0,pc),a0
  234.                 tst.l   (noquotes,a5)
  235.                 beq.s   rplnq0
  236.                 lea     (replacetn0,pc),a0
  237. rplnq0          bsr     CWrite
  238.                 dbf     d4,yms_loop
  239.                 lea     (accapo,pc),a0
  240.                 move.l  a0,d1
  241.                 call    PutStr
  242.  
  243.  
  244. exit2
  245.                 move.l  d6,a0
  246.                 move.l  (aslbase,a5),a6
  247.                 call    FreeAslRequest
  248. exit1
  249.                 move.l  d7,d1
  250.                 move.l  (dosbase,a5),a6
  251.                 call    FreeArgs
  252. exit0
  253.                 move.l  (a5),a6
  254.                 move.l  (dosbase,a5),a1
  255.                 call    CloseLibrary
  256.                 move.l  (aslbase,a5),a1
  257.                 call    CloseLibrary
  258.                 move.l  (oldstack,a5),sp
  259.                 moveq   #0,d0
  260.                 move.w  (returncode,a5),d0
  261.                 rts
  262.  
  263. doserror
  264.                 call    IoErr
  265.                 move.l  d0,d1
  266.                 moveq   #0,d2
  267.                 call    PrintFault
  268. frega0          move.b  #30,(returncode+1,a5)
  269.                 bra.s   exit0
  270.  
  271. aslerror
  272.                 move.l  (dosbase,a5),a6
  273.                 lea     (aslerrstr,pc),a0
  274.                 move.l  a0,d1
  275.                 call    PutStr
  276.                 move.b  #30,(returncode+1,a5)
  277.                 bra.s   exit1
  278.  
  279. unknownerr      move.b  #30,(returncode+1,a5)
  280.                 bra.s   exit2
  281.  
  282.  
  283. ; IN   a0 = fr struct
  284. ;      a5 = DO NOT TOUCH reserved base
  285. ;      d2 = file to append
  286. ;
  287. CAddPart        move.l  d6,a0
  288.                 move.l  (fr_Drawer,a0),a1
  289.                 lea     (buffer,a5),a2
  290.                 move.l  a2,d1
  291.                 moveq   #107,d3
  292.                 not.b   d3
  293.                 move.l  d3,d5
  294.                 subq.w  #1,d3
  295. clup            move.b  (a1)+,(a2)+
  296.                 tst.b   -1(a1)
  297.                 dbeq    d3,clup
  298.                 move.l  d5,d3
  299.                 move.l  (dosbase,a5),a6
  300.                 call    AddPart         ; quello che è uscito, è uscito!
  301.                 rts
  302.  
  303. ; IN  a0 = replacetx
  304. ;
  305. CWrite          lea     (buffer,a5),a1
  306.                 move.l  a1,-(sp)
  307.                 move.l  sp,d2
  308.                 move.l  a0,d1
  309.                 move.l  (dosbase,a5),a6
  310.                 call    VPrintf
  311.                 addq.l  #4,sp
  312.                 rts
  313.  
  314.  
  315. ;====================================================================================
  316.  
  317. template        dc.b    "DRAWER,FILE/K,PATTERN/K,TITLE/K,POSITIVE/K,NEGATIVE/K,ACCEPTPATTERN/K,"
  318.                 dc.b    "REJECTPATTERN/K,SAVEMODE/S,MULTISELECT/S,DRAWERSONLY/S,NOICONS/S,PUBSCREEN/K,NOQUOTES/S",0
  319.  
  320. dosname         dc.b    "dos.library",0
  321. aslname         dc.b    "asl.library",0
  322.  
  323. noicpatt        dc.b    "#?.info",0
  324.  
  325. aslerrstr       dc.b    "Error while allocating requester!",10,0
  326.  
  327. replacetn       dc.b    "%s",10,0
  328. replacet        dc.b    '"%s"'
  329. accapo          dc.b    10,0
  330. replacetn0      dc.b    "%s ",0
  331. replacet0       dc.b    '"%s" ',0
  332.  
  333.                 END
  334.