home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / cli / breakname / breakname.asm < prev    next >
Assembly Source File  |  1994-05-24  |  8KB  |  332 lines

  1.         NOLIST
  2.  
  3. *AUTO:        genam    <file>.asm
  4.  
  5.         opt    o+,ow-,ow6+,NODEBUG,NOLINE
  6.  
  7.  
  8. ;* $Revision Header built automatically *************** (do not edit) ************
  9. ;*
  10. ;* © Copyright by GuntherSoft
  11. ;*
  12. ;* File             : SnakeSYS:ASMPrgs/Utils/BreakName.Asm
  13. ;* Created on       : Sunday, 20.03.94 14:39:32
  14. ;* Created by       : Kai Iske
  15. ;* Current revision : V37.2
  16. ;*
  17. ;*
  18. ;* Purpose
  19. ;* -------
  20. ;*   - Break a cli process by name. Enhancement to C:Break
  21. ;*     Only Task/Process name needed; no pathnames required
  22. ;*     BreakName is PURE
  23. ;*
  24. ;* Revision V37.2
  25. ;* --------------
  26. ;* created on Tuesday, 24.05.94 17:17:05  by  Kai Iske.   LogMessage :
  27. ;*  -*-  changed on Tuesday, 24.05.94 17:18:47  by  Kai Iske.   LogMessage :
  28. ;*   - Permit was only called when the process was not found
  29. ;*     (Reported by: David Jameson)
  30. ;*  -*-  created on Tuesday, 24.05.94 17:17:05  by  Kai Iske.   LogMessage :
  31. ;*   - Didn`t check for length of name to copy
  32. ;*     (Reported by: David Jameson)
  33. ;*
  34. ;* Revision V37.1
  35. ;* --------------
  36. ;* created on Monday, 18.04.94 19:57:29  by  Kai Iske.   LogMessage :
  37. ;*   - FindTask was called with A0=NULL instead of A1=NULL ;)
  38. ;*     Whoops, better check registers next time
  39. ;*   - ReturnCode wasn`t set correctly
  40. ;*
  41. ;* Revision V37.0
  42. ;* --------------
  43. ;* created on Sunday, 20.03.94 14:39:32  by  Kai Iske.   LogMessage :
  44. ;*     --- Initial release ---
  45. ;*
  46. ;*********************************************************************************
  47. REVISION  MACRO
  48.           dc.b "37.2"
  49.           ENDM
  50. REVDATE   MACRO
  51.           dc.b "24.05.94"
  52.           ENDM
  53. REVTIME   MACRO
  54.           dc.b "17:18:47"
  55.           ENDM
  56. AUTHOR    MACRO
  57.           dc.b "Kai Iske"
  58.           ENDM
  59. VERNUM    EQU  37
  60. REVNUM    EQU  2
  61.  
  62.  
  63.  
  64.         INCLUDE    Exec/Types.i
  65.         INCLUDE    Exec/Memory.i
  66.         INCLUDE    Exec/Exec_Lib.i
  67.         INCLUDE    Dos/DosExtens.i
  68.         INCLUDE    Dos/Dos_Lib.i
  69.         INCLUDE    Utility/Utility_Lib.i
  70.         INCLUDE    Misc/MyMacros.i
  71.  
  72.  
  73.  
  74. **********************************************************************
  75. *                              Let`s go                              *
  76. **********************************************************************
  77.         CARGS    #-(2048+16),_DOSBase.L,_UtilityBase.L,Vecs.L,Args.L,CopiedName.B
  78.  
  79. START        movem.l    d1-d7/a0-a6,-(sp)
  80.  
  81.         link    a4,#-(2048+16)                ; Get space for vars
  82.  
  83.         move.l    #((2048+16)>>1),d0            ; Clear local areas
  84.         moveq    #0,d1
  85.         move.l    a4,a0
  86. .Clr        move.w    d1,-(a0)
  87.         dbf    d0,.Clr
  88.  
  89.         sub.l    a1,a1                    ; Don`t launch from WB
  90.         CALLSYS    FindTask
  91.         move.l    d0,a3
  92.         tst.l    pr_CLI(a3)
  93.         bne.s    .FromCLI
  94.         DOLIB    Forbid
  95.  
  96.         lea    pr_MsgPort(a3),a0
  97.         DOLIB    WaitPort
  98.  
  99.         lea    pr_MsgPort(a3),a0
  100.         DOLIB    GetMsg
  101.  
  102.         move.l    d0,a1
  103.         DOLIB    ReplyMsg
  104.  
  105.         unlk    a4
  106.         movem.l    (sp)+,d1-d7/a0-a6
  107.         moveq    #0,d0
  108.         rts
  109.  
  110. .FromCLI    lea    DosName(pc),a1                ; Open some libraries
  111.         move.l    #0,d0
  112.         CALLSYS    OpenLibrary
  113.         tst.l    d0
  114.         beq    .EndPrg
  115.         move.l    d0,_DOSBase(a4)
  116.  
  117.         cmp.w    #37,LIB_VERSION(a6)            ; Check system we`re running on
  118.         bge.s    .OSOk
  119.         RELLIB    Output,_DOSBase                ; Issue error
  120.         move.l    d0,d1
  121.         lea    OSErr(pc),a0
  122.         move.l    a0,d2
  123.         move.l    #61,d3
  124.         DOLIB    Write 
  125.         move.l    _DOSBase(a4),a1
  126.         CALLSYS    CloseLibrary
  127.         unlk    a4
  128.         movem.l    (sp)+,d1-d7/a0-a6
  129.         moveq    #20,d0
  130.         rts
  131.  
  132.  
  133. .OSOk        lea    UtilName(pc),a1
  134.         move.l    #37,d0
  135.         CALLSYS    OpenLibrary
  136.         tst.l    d0
  137.         beq    .EndPrg
  138.         move.l    d0,_UtilityBase(a4)
  139.  
  140.         move.l    #((F_ARG+1)<<2),d0            ; Alloc buffer for Arguments
  141.         move.l    #MEMF_CLEAR|MEMF_PUBLIC,d1
  142.         CALLSYS    AllocVec
  143.         tst.l    d0
  144.         beq    .EndPrg
  145.         bne.s    .GotVecs
  146.         move.l    #ERROR_NO_FREE_STORE,d0
  147.         bra    .Error2
  148. .GotVecs    move.l    d0,Vecs(a4)
  149.  
  150.         lea    Template(pc),a0                ; Parse command line
  151.         move.l    a0,d1
  152.         move.l    d0,d2
  153.         moveq    #0,d3
  154.         RELLIB    ReadArgs,_DOSBase
  155.         tst.l    d0
  156.         beq    .Error
  157.         move.l    d0,Args(a4)
  158.  
  159.         move.l    Vecs(a4),a0                ; All flag set ???
  160.         tst.l    (ALL_ARG*4)(a0)
  161.         beq.s    .StartLoop                ; Set all other flags regardless
  162.         moveq    #1,d0                    ; of what was specified
  163.         move.l    d0,(C_ARG*4)(a0)
  164.         move.l    d0,(D_ARG*4)(a0)
  165.         move.l    d0,(E_ARG*4)(a0)
  166.         move.l    d0,(F_ARG*4)(a0)
  167.  
  168. .StartLoop    CALLSYS    Forbid                    ; Please no other tasks at the moment
  169.  
  170.         RELLIB    MaxCli,_DOSBase                ; Get number of CLI processes
  171.         move.l    d0,d7
  172.  
  173. .LoopProc    move.l    d7,d1                    ; Get Process for this CLI number
  174.         RELLIB    FindCliProc,_DOSBase
  175.         tst.l    d0
  176.         beq    .NoProc
  177.         move.l    d0,a3                    ; Copy address of process
  178.  
  179.         move.l    pr_CLI(a3),d0                ; Get pointer to CLI structure
  180.         lsl.l    #2,d0
  181.         move.l    d0,d1
  182.         beq    .NoProc
  183.         move.l    d0,a1
  184.  
  185.         move.l    cli_CommandName(a1),d0            ; Get it`s commandname
  186.         lsl.l    #2,d0
  187.         move.l    d0,d1
  188.         beq    .NoProc
  189.         move.l    d0,a1
  190.  
  191.         moveq    #0,d0
  192.         move.b    (a1)+,d0                ; Get length of name of process to check with
  193.         beq    .NoProc
  194.         subq.w    #1,d0
  195.         lea    CopiedName(a4),a0            ; Get Address of Name buffer
  196.  
  197. .CopyName    move.b    (a1)+,(a0)+                ; Copy Name
  198.         dbf    d0,.CopyName
  199.         move.b    #0,(a0)
  200.  
  201.         lea    CopiedName(a4),a1            ; Check name (absolute)
  202.         move.l    Vecs(a4),a0                ; Get name of process to break
  203.         move.l    (PROC_ARG*4)(a0),a0
  204.         RELLIB    Stricmp,_UtilityBase            ; Check names
  205.         tst.l    d0
  206.         beq.s    .GotProc
  207.  
  208.         lea    CopiedName(a4),a0            ; Check name (only filepart)
  209.         move.l    a0,d1
  210.         RELLIB    FilePart,_DOSBase
  211.         move.l    d0,d1                    ; Store pointer of filepart
  212.         beq    .NoProc
  213.         move.l    d0,a1
  214.  
  215.         move.l    Vecs(a4),a0                ; Get name of process to break
  216.         move.l    (PROC_ARG*4)(a0),a0
  217.  
  218.         RELLIB    Stricmp,_UtilityBase            ; Check names
  219.         tst.l    d0
  220.         bne.s    .NoProc
  221.  
  222. .GotProc    move.l    Vecs(a4),a5                ; Which signals to send ???
  223.  
  224.         tst.l    (C_ARG*4)(a5)                ; Send C ???
  225.         bne.s    .DoC
  226.         tst.l    (D_ARG*4)(a5)                ; Send D ???
  227.         bne.s    .NoC
  228.         tst.l    (E_ARG*4)(a5)                ; Send E ???
  229.         bne.s    .NoC
  230.         tst.l    (F_ARG*4)(a5)                ; Send F ???
  231.         bne.s    .NoC
  232.  
  233. .DoC        move.l    a3,a1
  234.         move.l    #SIGBREAKF_CTRL_C,d0
  235.         CALLSYS    Signal
  236.  
  237. .NoC        tst.l    (D_ARG*4)(a5)
  238.         beq.s    .NoD
  239.         move.l    a3,a1
  240.         move.l    #SIGBREAKF_CTRL_D,d0
  241.         CALLSYS    Signal
  242.  
  243. .NoD        tst.l    (E_ARG*4)(a5)
  244.         beq.s    .NoE
  245.         move.l    a3,a1
  246.         move.l    #SIGBREAKF_CTRL_E,d0
  247.         CALLSYS    Signal
  248.  
  249. .NoE        tst.l    (F_ARG*4)(a5)
  250.         beq.s    .Done
  251.         move.l    a3,a1
  252.         move.l    #SIGBREAKF_CTRL_F,d0
  253.         CALLSYS    Signal
  254.         bra.s    .Done
  255.  
  256. .NoProc        subq.l    #1,d7                    ; Loop
  257.         bne    .LoopProc
  258.  
  259. .Done        CALLSYS    Permit
  260.         moveq    #0,d7                    ; Set returncode
  261.         bra.s    .EndPrg2
  262.  
  263. .Error        RELLIB    IoErr,_DOSBase                ; Issue error
  264.         move.l    d0,d1
  265. .Error2        lea    FaultStr(pc),a0
  266.         move.l    a0,d2
  267.         RELLIB    PrintFault,_DOSBase
  268.  
  269. .EndPrg        moveq    #20,d7                    ; Set returncode
  270.  
  271. .EndPrg2    tst.l    Args(a4)                ; Args there ???
  272.         beq.s    .NoArgs
  273.         move.l    Args(a4),d1
  274.         RELLIB    FreeArgs,_DOSBase
  275.  
  276. .NoArgs        tst.l    Vecs(a4)                ; Vecs there ???
  277.         beq.s    .NoVecs
  278.         move.l    Vecs(a4),a1
  279.         CALLSYS    FreeVec
  280.  
  281. .NoVecs        tst.l    _UtilityBase(a4)            ; Close libs
  282.         beq.s    .NoUtil
  283.         move.l    _UtilityBase(a4),a1
  284.         CALLSYS    CloseLibrary
  285.  
  286. .NoUtil        tst.l    _DOSBase(a4)
  287.         beq.s    .NoDOS
  288.         move.l    _DOSBase(a4),a1
  289.         CALLSYS    CloseLibrary
  290.  
  291. .NoDOS        unlk    a4
  292.         move.l    d7,d0
  293.         movem.l    (sp)+,d1-d7/a0-a6
  294.         rts
  295.  
  296.  
  297.  
  298.  
  299.  
  300. **********************************************************************
  301. *                          Our data section                          *
  302. **********************************************************************
  303. DosName        dc.b    "dos.library",0
  304. UtilName    dc.b    "utility.library",0
  305. FaultStr    dc.b    "BreakName ",0
  306. OSErr        dc.b    "You must use KickStart 2.04 (37.175) or higher for BreakName",10,0
  307.         EVEN
  308.  
  309.  
  310.  
  311. **********************************************************************
  312. *                           Version string                           *
  313. **********************************************************************
  314. Ver        dc.b    0,"$VER: BreakName "
  315.         REVISION
  316.         dc.b    " ("
  317.         REVDATE
  318.         dc.b    ")",0
  319.         EVEN
  320.  
  321. **********************************************************************
  322. *                         Template settings                          *
  323. **********************************************************************
  324. Template    dc.b    "PROCESS/A,ALL/S,C/S,D/S,E/S,F/S",0
  325. PROC_ARG    EQU    0
  326. ALL_ARG        EQU    1
  327. C_ARG        EQU    2
  328. D_ARG        EQU    3
  329. E_ARG        EQU    4
  330. F_ARG        EQU    5
  331.         END
  332.