2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 Desc: Diskfont initialization code.
9 #include <exec/types.h>
10 #include <exec/memory.h>
11 #include <graphics/text.h>
12 #include <diskfont/diskfont.h>
13 #include <aros/symbolsets.h>
14 #include <proto/exec.h>
15 #include <proto/dos.h>
16 #include <proto/graphics.h>
18 #include LC_LIBDEFS_FILE
19 #include "diskfont_intern.h"
21 /****************************************************************************************/
23 #include <aros/debug.h>
25 /****************************************************************************************/
27 AROS_UFP3(int, CleanMem
,
28 AROS_UFPA(struct MemHandlerData
*, mhdata
, A0
),
29 AROS_UFPA(LIBBASETYPEPTR
, LIBBASE
, A1
),
30 AROS_UFPA(struct ExecBase
*, SysBase
, A6
)
33 /****************************************************************************************/
35 static int Init(LIBBASETYPEPTR LIBBASE
)
37 /* This function is single-threaded by exec by calling Forbid. */
38 D(bug("Inside initfunc\n"));
40 NEWLIST(&LIBBASE
->diskfontlist
);
41 NEWLIST(&LIBBASE
->fontsdirentrylist
);
42 InitSemaphore(&LIBBASE
->fontssemaphore
);
44 /* Insert the fonthooks into the DiskfontBase */
46 LIBBASE
->dsh
.h_Entry
= (void *)AROS_ASMSYMNAME(dosstreamhook
);
47 LIBBASE
->dsh
.h_Data
= DOSBase
;
49 LIBBASE
->memint
.is_Data
= (APTR
) LIBBASE
;
50 LIBBASE
->memint
.is_Code
= (VOID (*)()) CleanMem
;
51 LIBBASE
->memint
.is_Node
.ln_Pri
= 1; /* Just above RamLib */
52 AddMemHandler(&LIBBASE
->memint
);
54 D(bug("diskfont.library initialized succesfully\n"));
59 /****************************************************************************************/
62 static int Expunge(LIBBASETYPEPTR LIBBASE
)
65 This function is single-threaded by exec by calling Forbid.
66 Never break the Forbid() or strange things might happen.
68 D(bug("Inside expungefunc\n"));
70 RemMemHandler(&LIBBASE
->memint
);
72 CleanUpFontsDirEntryList(LIBBASE
);
74 D(bug("diskfont.library expunged\n"));
79 /****************************************************************************************/
81 AROS_UFH3(int, CleanMem
,
82 AROS_UFHA(struct MemHandlerData
*, mhdata
, A0
),
83 AROS_UFHA(LIBBASETYPEPTR
, LIBBASE
, A1
),
84 AROS_UFHA(struct ExecBase
*, SysBase
, A6
)
89 struct DiskFontHeader
*dfh
, *dfh2
;
91 D(bug("Inside CleanMem\n"));
93 ForeachNodeSafe(&LIBBASE
->diskfontlist
, dfh
, dfh2
)
95 if (dfh
->dfh_TF
.tf_Accessors
< 1)
97 /* Possible paranoia check */
98 if (!(dfh
->dfh_TF
.tf_Flags
& FPF_REMOVED
))
100 /* Unlink from GfxBase->TextFonts */
101 REMOVE(&dfh
->dfh_TF
.tf_Message
.mn_Node
);
103 StripFont(&dfh
->dfh_TF
);
105 /* Unlink from DiskfontBase->diskfontlist */
107 REMOVE(&dfh
->dfh_DF
);
109 UnLoadSeg(dfh
->dfh_Segment
);
114 D(bug("CleanMem Finished\n"));
121 /****************************************************************************************/
123 ADD2INITLIB(Init
, 0);
124 ADD2EXPUNGELIB(Expunge
, 0);