-
Notifications
You must be signed in to change notification settings - Fork 3
/
emptycache.e
62 lines (47 loc) · 1.46 KB
/
emptycache.e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
-> EmptyCache by Leif Salomonsson [ecx tele2 se] is Copyrigh (c) 2003-2007.
-> Released under ECX TOOLS LICENSE, see ECXTOOLSLICENSE.TXT
-> February 2009: called InStr() with a zero rempat, FIXED.
MODULE '*binary'
MODULE 'dos/dos'
MODULE 'exec/lists'
MODULE 'exec/nodes'
PROC main() HANDLE
DEF modulecache=NIL:PTR TO modulecache
DEF cmh:PTR TO moduleheader, succ, rempat=NIL, rem
IF StrLen(arg) THEN rempat := arg
Forbid()
modulecache := FindSemaphore('EcxCache')
Permit()
IF modulecache = NIL THEN Raise("NOCA")
IF modulecache.ident <> "MC" THEN Raise("MCC")
IF AttemptSemaphore(modulecache) = NIL THEN Raise("ASEM")
cmh := modulecache.modlist.head
PrintF('EmptyCache 1.4 by LS 2003-2009\n')
WHILE cmh.succ
->WriteF('cmh=$\h, cmh.mnamelen=\d, cmh.mname=$\h, cmh.mname="\s"\n',
->cmh, cmh.mnamelen, cmh.mname, cmh.mname)
succ := cmh.succ
rem := FALSE
IF rempat = 0
rem := TRUE
ELSEIF InStr(cmh.mname, rempat) <> -1
rem := TRUE
ELSE
rem := FALSE
ENDIF
IF rem
Remove(cmh)
FreeMem(cmh.mname, cmh.mnamelen+1)
FreeMem(cmh, cmh.modsize)
ENDIF
cmh := succ
ENDWHILE
PrintF('done.\n')
ReleaseSemaphore(modulecache)
EXCEPT DO
SELECT exception
CASE "NOCA" ; PrintF('no cache available!\n')
CASE "ASEM" ; PrintF('semaphore is blocked!\n')
CASE "MCC" ; PrintF('modulecache is corrupt!\n') -> 1.8.0
ENDSELECT
ENDPROC