home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 303.lha / AssemTools / Include / doslib.i < prev    next >
Text File  |  1980-12-03  |  19KB  |  884 lines

  1. * include file for Amiga metacc macro assembler *
  2. * created 21.01.89 TM - Supervisor Software *
  3. * for handling Dos events *
  4.  
  5. * Vers. 1.23 *
  6.  
  7. ;created "doslib, ioerr, isend" -> v1.0 21.01.89
  8. ;added "adddir, addpath" -> v1.01 21.01.89
  9. ;adapted "filelength" from JM -> v1.02 16.02.89
  10. ;debugt "filelength" -> v1.03 21.02.89
  11. ;created "followthread" -> v1.04 1.3.89
  12. ;added sortentry.comments -> v1.05 4.3.89
  13. ;"followthread" debugt -> v1.06 12.3.89
  14. ;"followthread" debugt -> v1.07 12.3.89
  15. ;created "typeout" -> v1.08 11.5.89
  16. ;edited "addpath" -> v1.09 15.5.89 by JM
  17. ;debugt "addpath", changed "followthread" not to
  18. ;  alloc FIB from stack -> v1.10 17.5.89
  19. ;"followthread" recursive -> v1.11 17.5.89
  20. ;"open" -> v1.115 18.5.89
  21. ;edited "filelength" -> v1.116 18.5.89 by jm
  22. ;debugt "open" -> v1.117 20.5.89
  23. ;debugt "open" -> v1.1175 21.5.89
  24. ;created "error, getcli, request, cmdname" -> v1.12 13.06.89
  25. ; -"- "infos" -> v1.121 13.6.89
  26. ;debugt "infos, open", "getdate" created -> v1.122 14.6.89
  27. ;debugt "filelength" by jm -> v1.123 16.6.89
  28. ;created "readfile, alloc, dpy_err, dpy_msg, err_lock",
  29. ;"err_mem, err_read" -> v1.13 20.06.89
  30. ;"open" debugt -> v1.2 26.06.89
  31. ;"err_#?" debugt -> v1.21 27.06.89
  32. ;"err_writ, close" created, empty files as default channels
  33. ;  added to "open" -> v1.22 14.07.89
  34. ;"open" debugt (quiet & append now work together) -> v1.23 03.08.89
  35.  
  36.  
  37. *T
  38. *T    DOSLIB.I * Metacc Include File
  39. *T         Version 1.23
  40. *T            Date 03.08.89
  41. *T
  42. *B
  43.  
  44. ;  ioerr    (get IoErr code and convert to string)
  45. ;  in:        a0=place_for_string;
  46. ;  call:    doslib    ioerr;
  47. ;  out:        a0=*(NULL); d0=ioerr;
  48. ;  notes:    /the format is as/
  49. ;        /sprintf(" - Error code %i",IoErr());/
  50. ;        /numlib, handler must be included/;
  51.  
  52. ;  isend    (skip blanks - end of command line? (0/";"))
  53. ;  in:        a0=ptr;
  54. ;  call:    doslib    isend;
  55. ;  out:        a0=ptr;
  56. ;  notes:    /strlib must be included/;
  57.  
  58. ;  adddir    (move to directory)
  59. ;  in:        a0=dir_name;
  60. ;  call:    doslib    adddir;
  61. ;  out:        a0=dir_name; d0=success (0=fail);
  62. ;  notes:    /locks the new, unlocks the old/;
  63.  
  64. ;  addpath    (add a dirname to path)
  65. ;  in:        a0=dir_name; a1=pathname_string;
  66. ;  call:    doslib    addpath;
  67. ;  out:        a0=dir_name; a1=pathname_string;
  68. ;  notes:    /a masterpiece - handles also parent-dirs,/
  69. ;         /device names, rootdirs, subdirectories and yet/
  70. ;         /all these together/
  71. ;        /strlib must be included/;
  72.  
  73. ;  filelength    (find out length of a file)
  74. ;  in:        a0=file_name;
  75. ;  call:    doslib    filelength;
  76. ;  out:        d0=file_length; /-1 = error/
  77.  
  78. ;  followthread    (follow the directory thread to root)
  79. ;  in:        d1=lock; a0=*name_buffer, d0=buf_length;
  80. ;  call:    doslib    followthread;
  81. ;  out:        p.c=error; (c=1 if failed)
  82. ;  notes:    /the lock is not unlock()ed during process/
  83.  
  84. ;  typeout    (type a text into the current default output file)
  85. ;  in:        a0=*text;
  86. ;  call:    doslib    typeout;
  87. ;  notes:    /if the Output() returns a NULL, no text
  88. ;           is output. The text is written line-by-
  89. ;           line, thus permitting the user to inter-
  90. ;           rupt the output by entering a character
  91. ;           into the console./
  92.  
  93. ;  open        (open a file and display possible errors)
  94. ;  in:        a0=*name, d0=access_mode;
  95. ;  call:    doslib    open;
  96. ;  out:        d0=file; /NULL==error/
  97. ;  notes:    /access_mode =    0:  Read
  98. ;                  1:  Write
  99. ;                  2:  Append
  100. ;                  8:  Quiet (or'ed with others)/
  101. ;          /if no filename is present, the default IO
  102. ;           channel (Input(), Output()) is used./
  103. ;          /doslib CLOSE should be used for closing the
  104. ;           file./
  105. ;        /needs execlib, handler/
  106.  
  107. ;  close    (close a file)
  108. ;  in:        d0=*file;
  109. ;  call:    doslib    close;
  110. ;  notes:    /does not attempt to close Input(), Output()
  111. ;         or NULL/
  112.  
  113. ;  getdate    (convert a datestamp)
  114. ;  in:        a0=*datestamp;
  115. ;  call:    doslib    getdate;
  116. ;  out:        d0=year, d1=month /1..12 Jan..Dec/,
  117. ;        d2=day_of_month, d3=day_of_week /0..6 Mon..Fri/;
  118.  
  119. ;  fmtdate    (format a date)
  120. ;  in:        a0=*datestamp; a1=*output_buffer;
  121. ;        a2=*format, a3=*parameters;
  122. ;  call:    doslib    fmtdate;
  123. ;  out:        a1=*NULL;
  124. ;  notes:    /"format" contains an ordinary "sformat" string
  125. ;        defining how the parameters are formatted/
  126. ;        /"parameters" is a character queue containing
  127. ;        the following characters:
  128. ;        y - number of year    Y - the last two digits
  129. ;        m - number of month    M - name of month
  130. ;        d - day-of-month    D - name of day-of-week
  131. ;        The characters M and D require a %s declaration
  132. ;        in the "format", the others a (word) %d./
  133.  
  134. ;  getcli    (get the address of CLIStruct)
  135. ;  call:    doslib    getcli;
  136. ;  out:        a0=*clistruct; /0 if not a cli process/
  137. ;  notes:    /flags set according to the result/
  138.  
  139. ;  error    (set/read the dos error return code)
  140. ;  in:        d0=error;
  141. ;  call:    doslib    error;
  142. ;  out:        d0=old_error;
  143. ;        p.c=failed /C is set if not a CLI process/
  144.  
  145. ;  findproc    (find a cli process by the number)
  146. ;  in:        d0=number;
  147. ;  call:    doslib    findproc;
  148. ;  out:        a0=d0=*task; /NULL if error/
  149.  
  150. ;  cmdname    (get the current command name)
  151. ;  in:        a0=*buffer;
  152. ;  call:    doslib    cmdname;
  153. ;  out:        a0=*end_of_name==*NULL;
  154.  
  155. ;  request    (set/read requester window pointer)
  156. ;  in:        d0=*window;
  157. ;  call:    doslib    request;
  158. ;  out:        d0=*old_window;
  159. ;  notes:    /the pointers are in data register because
  160. ;        there are two values with a special meaning:
  161. ;        0    No default window. The requesters ap-
  162. ;            pear into the WorkBench screen.
  163. ;        -1    No requesters are displayed./
  164.  
  165. ;  infos    (type info/finfo/sinfo texts)
  166. ;  in:        a0=*cmdlin, a1=*usage, a2=*finfo_info;
  167. ;  call:    doslib    infos;
  168. ;  out:        d0=flag /==0 if nothing done/
  169. ;  notes:    /at the address a2 is give the "finfotx",
  170. ;        then NULL, then "infotxt" and another null./
  171. ;        /The string at a1 does not contain the word
  172. ;        "usage" or the command name./
  173.  
  174. ;  alloc    (allocate memory and argue if not got)
  175. ;  in:        d0=bytesize, d1=requirements;
  176. ;  call:    doslib    alloc;
  177. ;  out:        a0=d0=location;
  178.  
  179. ;  readfile    (allocate a buffer and read a file into it)
  180. ;  in:        a0=*name; d0=mode; /d0=0 or d0=open_quiet/
  181. ;  call:    doslib    readfile;
  182. ;  out:        d0=*buffer /0=error/
  183.  
  184. ;  dpy_msg    (display a formatted message)
  185. ;  in:        a0=*format_string; d0..d7=parameters;
  186. ;  call:    doslib    dpy_msg;
  187.  
  188. ;  dpy_err    (display a formatted error message)
  189. ;  in:        a0=*format_string; d0..d7=parameters;
  190. ;  call:    doslib    dpy_err;
  191. ;  notes:    /" - error code %d\n" will be automatically
  192. ;        added before printing/
  193.  
  194. ;  err_lock    (display "unable to get information")
  195. ;  in:        a0=*name;
  196. ;  call:    doslib    err_lock;
  197.  
  198. ;  err_mem    (display "unable to allocate memory")
  199. ;  in:        d0=*size;
  200. ;  call:    doslib    err_mem;
  201.  
  202. ;  err_read    (display "error reading file")
  203. ;  in:        a0=*name;
  204. ;  call:    doslib    err_read;
  205.  
  206. ;  err_writ    (display "error writing file")
  207. ;  in:        a0=*name;
  208. ;  call:    doslib    err_writ;
  209.  
  210.  
  211. *E
  212.  
  213.  
  214. doslib        macro    routine
  215.         ifnc    '\1',''
  216.         bsr    _DOS\1
  217. _DOSF\1        set    -1
  218.         mexit
  219.         endc
  220.  
  221.         ifd    _DOSFreadfile
  222. _DOSreadfile    push    a0-a3/d1-d5
  223.         move.l    d0,d5
  224.         move.l    a0,a3
  225.         doslib    filelength
  226.         tst.l    d0
  227.         bmi    _DOSreadfile.e1
  228.         addq.l    #8,d0
  229.         move.l    d0,d2
  230.         moveq    #1,d1
  231.         tst.b    d5
  232.         bne.s    _DOSreadfile1
  233.         doslib    alloc
  234.         bra.s    _DOSreadfile2
  235. _DOSreadfile1    execlib    alloc
  236. _DOSreadfile2    move.l    d0,a2
  237.         tst.l    d0
  238.         beq.s    _DOSreadfile.e
  239.         move.l    d5,d0
  240.         and.b    #$f8,d0
  241.         move.l    a3,a0
  242.         doslib    open
  243.         move.l    d0,d4
  244.         beq.s    _DOSreadfile.e
  245.         move.l    d0,d1
  246.         move.l    d2,d3
  247.         move.l    a2,d2
  248.         lib    Dos,Read
  249.         ph    d0
  250.         move.l    d4,d1
  251.         lib    Dos,Close
  252.         pl    d0
  253.         bmi.s    _DOSreadfile.e2
  254.         move.l    d2,a0
  255.         clr.b    0(a0,d0.l)
  256.         move.l    a2,d0
  257. _DOSreadfile0    pull    a0-a3/d1-d5
  258.         rts
  259. _DOSreadfile.e    moveq    #0,d0
  260.         bra.s    _DOSreadfile0
  261. _DOSreadfile.e1    tst.b    d5
  262.         bne.s    _DOSreadfile.e
  263.         move.l    a3,a0
  264.         doslib    err_lock
  265.         bra.s    _DOSreadfile.e
  266. _DOSreadfile.e2    tst.b    d5
  267.         bne.s    _DOSreadfile.e
  268.         move.l    a3,a0
  269.         doslib    err_read
  270.         bra.s    _DOSreadfile.e
  271.         endc
  272.  
  273.         ifd    _DOSFalloc
  274. _DOSalloc    move.l    d0,-(sp)
  275.         execlib    alloc
  276.         tst.l    d0
  277.         bne.s    _DOSalloc0
  278.         move.l    (sp),d0
  279.         doslib    err_mem
  280.         moveq    #0,d0
  281.         sub.l    a0,a0
  282. _DOSalloc0    addq.w    #4,sp
  283.         rts
  284.         endc
  285.  
  286.         ifd    _DOSFerr_mem
  287. _DOSerr_mem    push    a0-a1/d0-d1
  288.         lstr    a0,<'Unable to allocate memory %ld bytes%'>
  289.         doslib    dpy_msg
  290.         pull    a0-a1/d0-d1
  291.         rts
  292.         endc
  293.  
  294.         ifd    _DOSFerr_lock
  295. _DOSerr_lock    push    a0-a1/d0-d1
  296.         move.l    a0,d0
  297.         lstr    a0,<'Unable to get information for "%s"'>
  298.         doslib    dpy_err
  299.         pull    a0-a1/d0-d1
  300.         rts
  301.         endc
  302.  
  303.         ifd    _DOSFerr_read
  304. _DOSerr_read    push    a0-a1/d0-d1
  305.         move.l    a0,d0
  306.         lstr    a0,<'Error reading file "%s"'>
  307.         doslib    dpy_err
  308.         pull    a0-a1/d0-d1
  309.         rts
  310.         endc
  311.  
  312.         ifd    _DOSFerr_writ
  313. _DOSerr_writ    push    a0-a1/d0-d1
  314.         move.l    a0,d0
  315.         lstr    a0,<'Error writing file "%s"'>
  316.         doslib    dpy_err
  317.         pull    a0-a1/d0-d1
  318.         rts
  319.         endc
  320.  
  321.         ifd    _DOSFdpy_msg
  322. _DOSdpy_msg    push    a0-a1/d0-d1
  323.         link    a2,#-256
  324.         move.l    sp,a1
  325.         execlib    sformat
  326.         move.l    sp,a0
  327.         doslib    typeout
  328.         unlk    a2
  329.         pull    a0/a1/d0-d1
  330.         rts
  331.         endc
  332.  
  333.         ifd    _DOSFdpy_err
  334. _DOSdpy_err    push    a0-a1/d0-d1
  335.         link    a2,#-256
  336.         move.l    sp,a1
  337.         execlib    sformat
  338.         doslib    ioerr
  339.         move.b    #10,(a0)+
  340.         clr.b    (a0)
  341.         move.l    sp,a0
  342.         doslib    typeout
  343.         unlk    a2
  344.         pull    a0/a1/d0-d1
  345.         rts
  346.         endc
  347.  
  348.         ifd    _DOSFfmtdate
  349. _DOSfmtdate    push    a0/a2-a5/d0-d7
  350.         doslib    getdate
  351.         move.l    a2,a0
  352.         lea.l    -32(sp),sp
  353.         move.l    sp,a2
  354. _DOSfmtdate1    move.b    (a3)+,d4
  355.         beq.s    _DOSfmtdate.f
  356.         cmp.b    #'y',d4
  357.         bne.s    _DOSfmtdate2
  358.         move.w    d0,(a2)+
  359.         bra.s    _DOSfmtdate1
  360. _DOSfmtdate2    cmp.b    #'Y',d4
  361.         bne.s    _DOSfmtdate3
  362.         move.l    d0,d4
  363.         divu.w    #100,d4
  364.         swap    d4
  365.         move.w    d4,(a2)+
  366.         bra.s    _DOSfmtdate1
  367. _DOSfmtdate3    cmp.b    #'m',d4
  368.         bne.s    _DOSfmtdate4
  369.         move.w    d1,(a2)+
  370.         bra.s    _DOSfmtdate1
  371. _DOSfmtdate4    cmp.b    #'M',d4
  372.         bne.s    _DOSfmtdate5
  373.         push    a0/d0
  374.         lea.l    _DOSfmtdate.t1(pc),a0
  375.         move.w    d1,d0
  376.         subq.w    #1,d0
  377. _DOSfmtdate4b    strlib    strnth
  378.         move.l    a0,(a2)+
  379.         pull    a0/d0
  380.         bra.s    _DOSfmtdate1
  381. _DOSfmtdate5    cmp.b    #'d',d4
  382.         bne.s    _DOSfmtdate6
  383.         move.w    d2,(a2)+
  384.         bra    _DOSfmtdate1
  385. _DOSfmtdate6    cmp.b    #'D',d4
  386.         bne.s    _DOSfmtdate.f
  387.         push    a0/d0
  388.         lea.l    _DOSfmtdate.t2(pc),a0
  389.         move.w    d3,d0
  390.         bra.s    _DOSfmtdate4b
  391. _DOSfmtdate.f    move.l    sp,a2
  392.         execlib    format
  393.         lea.l    32(sp),sp
  394.         pull    a0/a2-a5/d0-d7
  395.         rts
  396. _DOSfmtdate.t1    dc.b    'January',0,'February',0,'March',0,'April',0
  397.         dc.b    'May',0,'June',0,'July',0,'August',0
  398.         dc.b    'September',0,'October',0,'November',0,'December',0
  399. _DOSfmtdate.t2    dc.b    'Monday',0,'Tuesday',0,'Wednesday',0
  400.         dc.b    'Thursday',0,'Friday',0,'Saturday',0,'Sunday',0
  401.         ds.w    0
  402.         endc
  403.  
  404.         ifd    _DOSFopen
  405. _DOSopen    push    d1-d3/a0-a3
  406.         tst.b    (a0)
  407.         beq    _DOSopen_d
  408.         move.l    a0,d1
  409.         move.l    d0,d2
  410.         move.l    a0,a2
  411.         move.l    d0,d3
  412.         and.w    #3,d2
  413.         add.w    #1005,d2
  414.         cmp.w    #1007,d2
  415.         bne.s    _DOSopen_1
  416.         subq.l    #2,d2
  417. _DOSopen_1    lib    Dos,Open
  418. _DOSopen_.5    tst.l    d0
  419.         bne    _DOSopen0
  420.         btst    #3,d3
  421.         bne    _DOSopen1b
  422.         link    a3,#-256
  423.         move.l    sp,a1
  424.         move.l    a2,d0
  425.         lstr    a0,<'input'>
  426.         tst.b    d3
  427.         beq.s    _DOSopen1
  428.         lstr    a0,<'output'>
  429.         cmp.b    #1,d3
  430.         beq.s    _DOSopen1
  431.         lstr    a0,<'append'>
  432. _DOSopen1    move.l    a0,d1
  433.         lstr    a0,<'Unable to open "%s" for %s'>
  434.         execlib    sformat
  435.         doslib    ioerr
  436.         doslib    error
  437.         plf    a0
  438.         pnull    a0
  439.         move.l    sp,a0
  440.         printa    a0
  441.         unlk    a3
  442. _DOSopen1b    moveq    #0,d0
  443.         bra.s    _DOSopen00
  444. _DOSopen0    btst    #1,d3        ;append?
  445.         beq.s    _DOSopen00
  446.         ph    d0
  447.         move.l    d0,d1
  448.         moveq    #0,d2
  449.         moveq    #1,d3
  450.         lib    Dos,Seek
  451.         pl    d0
  452. _DOSopen00    pull    d1-d3/a0-a3
  453.         tst.l    d0
  454.         rts
  455. _DOSopen_d    ; open default channel
  456.         move.l    d0,d3
  457.         and.w    #3,d0
  458.         bne.s    1$
  459.         lib    Dos,Input
  460.         bra.s    2$
  461. 1$        lib    Dos,Output
  462. 2$        lea.l    3$(pc),a2
  463.         bra    _DOSopen_.5
  464. 3$        dc.b    '*',0    ;length even, no pad
  465.         endc
  466.  
  467.         ifd    _DOSFclose
  468. _DOSclose    push    d0-d2/a0-a1
  469.         move.l    d0,d2    ;if null, dnt close
  470.         beq.s    _DOSclose0
  471.         lib    Dos,Input
  472.         cmp.l    d0,d2    ;if deflt input, dnt close
  473.         beq.s    _DOSclose0
  474.         flib    Dos,Output
  475.         cmp.l    d0,d2    ;if deflt output, dnt close
  476.         beq.s    _DOSclose0
  477.         move.l    d2,d1
  478.         flib    Dos,Close    ;do close
  479. _DOSclose0    pull    d0-d2/a0-a1
  480.         rts
  481.         endc
  482.  
  483.         ifd    _DOSFinfos
  484. _DOSinfos    push    a0-a1/d0-d1
  485.         move.b    (a0),d0
  486.         cmp.b    #'*',d0
  487.         beq.s    _DOSinfos.s
  488.         cmp.b    #'!',d0
  489.         beq.s    _DOSinfos.f
  490.         cmp.b    #'?',d0
  491.         beq.s    _DOSinfos.i
  492.         pull    a0-a1/d0-d1
  493.         moveq    #0,d0
  494.         rts
  495. _DOSinfos.f    move.l    a2,a0
  496.         doslib    typeout
  497. _DOSinfos.i    bsr.s    _DOSinfos.s1
  498.         move.l    a2,a0
  499. _DOSinfos.i1    tst.b    (a0)+
  500.         bne.s    _DOSinfos.i1
  501.         doslib    typeout
  502. _DOSinfos.x    pull    a0-a1/d0-d1
  503.         moveq    #-1,d0
  504.         rts
  505. _DOSinfos.s    pea.l    _DOSinfos.x(pc)
  506. _DOSinfos.s1    push    a2-a3
  507.         move.l    a1,a3
  508.         move.l    #256,d0
  509.         moveq    #1,d1
  510.         lib    Exec,AllocMem
  511.         tst.l    d0
  512.         beq.s    _DOSinfos.s3
  513.         move.l    d0,a2
  514.         move.l    a2,a0
  515.         move.l    #'Usag',(a0)+
  516.         move.l    #'e: .',(a0)+
  517.         subq.w    #1,a0
  518.         doslib    cmdname
  519. _DOSinfos.s2    move.b    (a3)+,(a0)+
  520.         bne.s    _DOSinfos.s2
  521.         move.b    #LF,-1(a0)
  522.         clr.b    (a0)
  523.         move.l    a2,a0
  524.         doslib    typeout
  525.         move.l    a2,a1
  526.         move.l    #256,d0
  527.         lib    Exec,FreeMem
  528. _DOSinfos.s3    pull    a2-a3
  529.         rts
  530.         endc
  531.  
  532.         ifd    _DOSFgetdate
  533. _DOSgetdate    push    d4-d7    ;d7=n    d6=y    d5=m    d4=d
  534.         move.l    (a0),d0
  535.         sub.l    #2251,d0
  536.         move.l    d0,d7
  537.         add.l    d0,d0
  538.         add.l    d0,d0
  539.         addq.l    #3,d0
  540.         divs    #1461,d0
  541.         ext.l    d0
  542.         move.l    d0,d6
  543.         muls.w    #1461,d0
  544.         asr.l    #2,d0
  545.         sub.l    d0,d7
  546.         add.l    #1984,d6
  547.         move.l    d7,d0
  548.         muls.w    #5,d0
  549.         addq.l    #2,d0
  550.         divs.w    #153,d0
  551.         ext.l    d0
  552.         move.l    d0,d5
  553.         muls.w    #153,d0
  554.         addq.l    #2,d0
  555.         divs.w    #5,d0
  556.         move.l    d7,d1
  557.         sub.l    d0,d1
  558.         addq.l    #1,d1
  559.         move.l    d1,d4
  560.         addq.l    #3,d5
  561.         cmp.l    #12,d5
  562.         bls.s    _DOSgetdate1
  563.         addq.l    #1,d6
  564.         sub.l    #12,d5
  565. _DOSgetdate1    move.l    d6,d0    ;year
  566.         move.l    d5,d1    ;month
  567.         move.l    d4,d2    ;day-of-month
  568.         ext.l    d2
  569.         move.l    (a0),d3
  570.         subq.l    #1,d3
  571.         divu.w    #7,d3
  572.         swap    d3
  573.         ext.l    d3    ;day-of-week
  574.         pull    d4-d7
  575.         rts
  576.         endc
  577.  
  578.         ifd    _DOSFcmdname
  579. _DOScmdname    push    a1/d0-d1
  580.         move.l    a0,a1
  581.         doslib    getcli
  582.         beq.s    _DOScmdname0
  583.         move.l    16(a0),a0
  584.         add.l    a0,a0
  585.         add.l    a0,a0
  586.         move.b    (a0)+,d0
  587.         beq.s    _DOScmdname0
  588. _DOScmdname1    move.b    (a0)+,(a1)+
  589.         subq.b    #1,d0
  590.         bne.s    _DOScmdname1
  591. _DOScmdname0    move.l    a1,a0
  592.         clr.b    (a0)
  593.         pull    a1/d0-d1
  594.         rts
  595.         endc
  596.  
  597.         ifd    _DOSFfindproc
  598. _DOSfindproc    lbase    Dos,a0
  599.         move.l    34(a0),a0
  600.         move.l    (a0),a0
  601.         add.l    a0,a0
  602.         add.l    a0,a0
  603.         cmp.l    (a0),d0
  604.         bhi.s    _DOSfindproc0    ;proc #>max
  605.         add.l    d0,d0
  606.         add.l    d0,d0
  607.         move.l    0(a0,d0.l),d0
  608.         beq.s    _DOSfindproc0
  609.         sub.l    #92,d0
  610. _DOSfindproc1    move.l    d0,a0
  611.         rts
  612. _DOSfindproc0    moveq    #0,d0
  613.         bra.s    _DOSfindproc1
  614.         endc
  615.  
  616.         ifd    _DOSFrequest
  617. _DOSrequest    push    d1-d2/a0-a1
  618.         move.l    d0,d2
  619.         sub.l    a1,a1
  620.         lib    Exec,FindTask
  621.         move.l    d0,a0
  622.         move.l    $80+56(a0),d0
  623.         move.l    d2,$80+56(a0)
  624.         pull    d1-d2/a0-a1
  625.         tst.l    d0
  626.         rts
  627.         endc
  628.  
  629.         ifd    _DOSFtypeout
  630. _DOStypeout    push    d0-d3/a0-a2
  631.         move.l    a0,a2
  632. _DOStypeout1    tst.b    (a2)
  633.         beq.s    _DOStypeout0
  634.         lib    Dos,Output
  635.         move.l    d0,d1
  636.         beq.s    _DOStypeout0
  637.         move.l    a2,d2
  638.         moveq    #0,d3
  639. _DOStypeout2    move.b    (a2)+,d0
  640.         beq.s    _DOStypeout3
  641.         addq.l    #1,d3
  642.         cmp.b    #10,d0
  643.         bne.s    _DOStypeout2
  644.         addq.w    #1,a2
  645. _DOStypeout3    subq.w    #1,a2
  646.         lib    Dos,Write
  647.         bra.s    _DOStypeout1
  648. _DOStypeout0    pull    d0-d3/a0-a2
  649.         rts
  650.         endc
  651.  
  652.         ifd    _DOSFfollowthread
  653. _DOSfollowthread push    all
  654.         move.w    d0,d5    ;buf
  655.         move.l    a0,a5    ;buflen
  656.         bsr    _DOSfollthre.s
  657.         bcs.s    _DOSfollthre.re
  658.         tst.w    d5
  659.         beq.s    _DOSfollthre.re
  660.         clr.b    (a5)
  661.         clrc
  662.         pull    all
  663.         rts
  664. _DOSfollthre.re    setc
  665.         pull    all
  666.         rts
  667. _DOSfollthre.s    push    d0-d4/a0-a4
  668.         move.l    d1,d3    ;lock
  669.         move.l    #268,d0
  670.         moveq    #1,d1
  671.         lib    Exec,AllocMem
  672.         move.l    d0,d4
  673.         beq    _DOSfollthre.me
  674.         move.l    d3,d1
  675.         move.l    d4,d2
  676.         lib    Dos,Examine
  677.         tst.l    d0
  678.         beq    _DOSfollthre.e
  679.         move.l    d3,d1
  680.         lib    Dos,ParentDir
  681.         move.l    d0,d2
  682.         beq.s    _DOSfollthre.rt
  683.         move.l    d0,d1
  684.         bsr.s    _DOSfollthre.s    ;recall
  685.         bcc.s    _DOSfollthre.s3
  686.         move.l    d2,d1
  687.         lib    Dos,UnLock
  688.         bra.s    _DOSfollthre.e
  689. _DOSfollthre.s3    move.l    d4,a0
  690.         lea.l    8(a0),a1
  691. _DOSfollthre.s1    move.b    (a1)+,d0
  692.         beq.s    _DOSfollthre.s2
  693.         bsr    _DOSfollthre.pc
  694.         bra.s    _DOSfollthre.s1
  695. _DOSfollthre.s2    tst.l    4(a0)
  696.         bmi.s    _DOSfollthre.fi
  697.         moveq    #'/',d0
  698.         bsr    _DOSfollthre.pc
  699.         bra.s    _DOSfollthre.fi
  700. _DOSfollthre.rt    move.l    d4,a0
  701.         lea.l    8(a0),a1
  702. _DOSfollthre.r1    move.b    (a1)+,d0
  703.         beq.s    _DOSfollthre.r2
  704.         bsr    _DOSfollthre.pc
  705.         bra.s    _DOSfollthre.r1
  706. _DOSfollthre.r2 moveq    #':',d0
  707.         bsr    _DOSfollthre.pc
  708. _DOSfollthre.fi    move.l    d2,d1
  709.         lib    Dos,UnLock
  710.         move.l    d4,a1
  711.         move.l    #268,d0
  712.         lib    Exec,FreeMem
  713.         pull    d0-d4/a0-a4
  714.         clrc
  715.         rts
  716. _DOSfollthre.e    move.l    d4,a1
  717.         move.l    #268,d0
  718.         lib    Exec,FreeMem
  719. _DOSfollthre.me    pull    d0-d4/a0-a4
  720.         setc
  721.         rts
  722. _DOSfollthre.pc    tst.w    d5
  723.         beq.s    _DOSfollthre.pc1
  724.         move.b    d0,(a5)+
  725.         subq.w    #1,d5
  726. _DOSfollthre.pc1 rts
  727.         endc
  728.  
  729.         ifd    _DOSFioerr
  730. _DOSioerr    push    a1/d1
  731.         pstr    a0,<' - Error code '>
  732.         ph    a0
  733.         lib    Dos,IoErr
  734.         pl    a0
  735.         numlib    sput10
  736.         pull    a1/d1
  737.         rts
  738.         endc
  739.  
  740.         ifd    _DOSFerror
  741. _DOSerror    push    a0-a1/d1
  742.         move.l    d0,d1
  743.         doslib    getcli
  744.         setc
  745.         beq.s    _DOSerror0
  746.         move.l    (a0),d0
  747.         move.l    d1,(a0)
  748.         tst.l    d0
  749. _DOSerror0    pull    a0-a1/d1
  750.         rts
  751.         endc
  752.  
  753.         ifd    _DOSFgetcli
  754. _DOSgetcli    push    a1/d0-d1
  755.         sub.l    a1,a1
  756.         lib    Exec,FindTask
  757.         move.l    d0,a0
  758.         move.l    $80+44(a0),d0
  759.         add.l    d0,d0
  760.         add.l    d0,d0
  761.         move.l    d0,a0
  762.         pull    a1/d0-d1
  763.         rts
  764.         endc
  765.  
  766.         ifd    _DOSFisend
  767. _DOSisend    strlib    sblk
  768.         tst.b    (a0)
  769.         beq.s    _DOSisend1
  770.         cmp.b    #';',(a0)
  771. _DOSisend1    rts
  772.         endc
  773.  
  774.         ifd    _DOSFadddir
  775. _DOSadddir    move.l    a0,-(sp)
  776.         move.l    a0,d1
  777.         moveq    #-2,d2
  778.         lib    Dos,Lock
  779.         move.l    d0,d1
  780.         beq.s    _adddir1
  781.         lib    Dos,CurrentDir
  782.         move.l    d0,d1
  783.         lib    Dos,UnLock
  784.         moveq    #-1,d0
  785. _adddir1    move.l    (sp)+,a0
  786.         rts
  787.         endc
  788.  
  789.         ifd    _DOSFaddpath
  790. _DOSaddpath    push    a0-a2
  791. _addpath0    tst.b    (a0)
  792.         beq    _addpath9
  793.         cmp.b    #'/',(a0)
  794.         bne.s    _addpath1
  795.         exg    a0,a1        a0 begins with a /
  796.         move.l    a0,-(sp)
  797.         strlib    remslash    remove from a1
  798.         move.l    (sp),a0
  799.         strlib    extfname    remove last dirname from a1
  800.         tst.b    (a0)
  801.         beq.s    _addpath1b
  802.         lea    1(a1),a1    skip first / in a0
  803. _addpath1c    clr.b    (a0)
  804.         move.l    (sp)+,a0
  805.         exg    a1,a0
  806.         bra.s    _addpath0
  807. _addpath1b    move.b    (a1)+,(a0)+    if we could not remove latdir,
  808.         bra.s    _addpath1c    vanillacopy '/'
  809. _addpath1    cmp.b    #':',(a0)
  810.         bne.s    _addpath2    a0 begins with a :
  811.         move.b    (a0)+,(a1)    copy : to dest
  812.         clr.b    1(a1)
  813.         bra.s    _addpath0
  814. _addpath2    move.l    a0,a2
  815.         move.l    a1,-(sp)
  816.         exg    a0,a1
  817.         strlib    addslash    add slash to a1 if needed
  818.         exg    a0,a1
  819. _addpath3    move.b    (a0)+,d0    if not : or /
  820.         cmp.b    #'/',d0
  821.         beq.s    _addpath7
  822.         cmp.b    #':',d0
  823.         beq.s    _addpath6
  824.         move.b    d0,(a1)+    copy path to end of a1
  825.         bne.s    _addpath3
  826. _addpath5    move.l    (sp)+,a1
  827. _addpath9    pull    a0-a2
  828.         rts
  829. _addpath7    clr.b    (a1)
  830. _addpath4    move.l    (sp)+,a1    original a1
  831.         bra    _addpath0
  832. _addpath6    move.l    (sp),a1        original a1
  833.         move.l    a2,a0        original a0
  834. _addpath8    move.b    (a0)+,d0
  835.         move.b    d0,(a1)+    copy until : or NULL
  836.         beq.s    _addpath5
  837.         cmp.b    #':',d0
  838.         bne.s    _addpath8
  839.         bra.s    _addpath7
  840.         endc
  841.  
  842.         ifd    _DOSFfilelength
  843. _DOSfilelength    push    d1-d3/a0-a2/a6
  844.         move.l    a0,d3
  845.         ifnd    fib_SIZEOF
  846. fib_SIZEOF    set    260
  847.         endc
  848.         move.l    #fib_SIZEOF+8,d0
  849.         moveq    #1,d1
  850.         lib    Exec,AllocMem
  851.         tst.l    d0
  852.         beq.s    3$            -> no mem gotten
  853.         move.l    d0,a2            fib*
  854.         move.l    d3,d1            name*
  855.         moveq.l    #-2,d2            ACCESS_READ -> -2
  856.         lib    Dos,Lock
  857.         move.l    d0,d3            lock*
  858.         beq.s    2$
  859.         move.l    d3,d1
  860.         move.l    a2,d2
  861.         flib    Dos,Examine
  862.         move.l    d0,d2
  863.         move.l    d3,d1
  864.         flib    Dos,UnLock
  865.         tst.l    d2
  866.         beq.s    2$
  867.         move.l    124(a2),d3        file size, fib_Size -> 124
  868.         bra.s    1$
  869. 2$        moveq.l    #-1,d3            error: cannot examine
  870. 1$        move.l    a2,a1
  871.         move.l    #fib_SIZEOF+8,d0
  872.         lib    Exec,FreeMem
  873.         move.l    d3,d0
  874.         pull    d1-d3/a0-a2/a6
  875.         rts
  876. 3$        pull    d1-d3/a0-a2/a6
  877.         moveq    #-2,d0            error: no mem
  878.         rts
  879.         endc
  880.  
  881.         endm
  882.  
  883.  
  884.