add strspn to static lib
[AROS.git] / test / availfonts.c
blob34823e5765bb711ba34bad03dd9f908348a3a1ee
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <diskfont/diskfont.h>
7 #include <proto/exec.h>
8 #include <proto/dos.h>
9 #include <proto/diskfont.h>
10 #include <proto/utility.h>
12 #include <string.h>
13 #include <stdlib.h>
14 #include <stdio.h>
16 struct Library *DiskfontBase;
17 struct UtilityBase *UtilityBase;
19 UBYTE *buf;
21 void cleanup(char *msg)
23 if (msg) printf("aftest: %s\n", msg);
25 FreeVec(buf);
27 if (UtilityBase) CloseLibrary((struct Library *)UtilityBase);
28 if (DiskfontBase) CloseLibrary(DiskfontBase);
30 exit(0);
33 void openlibs(void)
35 DiskfontBase = OpenLibrary("diskfont.library", 0);
36 if (!DiskfontBase) cleanup("Cant open diskfont.library!");
37 UtilityBase = (struct UtilityBase *) OpenLibrary("utility.library", 0);
38 if (!UtilityBase) cleanup("Cant open utility.library!");
41 void action(void)
43 struct AvailFontsHeader *afh;
44 struct TAvailFonts *af;
46 ULONG bufsize = 10000, shortage;
47 ULONG numentries;
48 ULONG i;
50 buf = AllocVec(bufsize, MEMF_ANY);
51 if (!buf) cleanup("out of memory!");
55 shortage = AvailFonts(buf, bufsize, AFF_MEMORY | AFF_DISK | AFF_BITMAP | AFF_TAGGED);
56 if (shortage)
58 bufsize += shortage;
60 FreeVec(buf);
61 buf = AllocVec(bufsize, MEMF_ANY);
62 if (!buf) cleanup("out of memory!");
64 } while (shortage);
66 afh = (struct AvailFontsHeader *)buf;
67 numentries = afh->afh_NumEntries;
69 printf("numentries = %ld\n", (long)numentries);
71 af = (struct TAvailFonts *)(buf + 2);
73 for(i = 0; i < numentries;i++)
75 #if 1
76 printf("%s/%d [%d] flags = %x style = %x\n",
77 af->taf_Attr.tta_Name,
78 af->taf_Attr.tta_YSize,
79 af->taf_Type,
80 af->taf_Attr.tta_Flags,
81 af->taf_Attr.tta_Style);
83 printf(" tags = %p istagged = %d\n", af->taf_Attr.tta_Tags, (af->taf_Attr.tta_Style & FSF_TAGGED));
86 if ((af->taf_Attr.tta_Style & FSF_TAGGED) && (af->taf_Attr.tta_Tags))
88 struct TagItem *tag, *tstate = af->taf_Attr.tta_Tags;
90 printf("tags = %p\n", af->taf_Attr.tta_Tags);
91 //Delay(1*50);
93 while((tag = NextTagItem(&tstate)))
95 printf(" {%lx,%lx}\n", tag->ti_Tag, tag->ti_Data);
99 #else
100 printf("#%ld: %s/%d [%d] flags = %x style = %x\n",
102 af->taf_Attr.tta_Name,
103 af->taf_Attr.tta_YSize,
104 af->taf_Type,
105 af->taf_Attr.tta_Flags,
106 af->taf_Attr.tta_Style);
107 #endif
109 // Delay(10);
110 af++;
114 int main(void)
116 openlibs();
117 action();
118 cleanup(0);
120 return 0; /* keep compiler happy */