# Correct the needed linklibs in curl-config also.
[AROS-Contrib.git] / vpdf / util.h
blob3a42897b12fd8c1555db9a93d534011d1eab8d32
1 #ifndef UTIL_H
2 #define UTIL_H
4 #include <libraries/mui.h>
5 #include <proto/dos.h>
6 #include <proto/intuition.h>
7 #include <dos/dosextens.h>
9 #ifndef _parent
10 #define _parent(obj) ((Object*)xget(obj, MUIA_Parent))
11 #endif
13 #if defined(__AROS__)
14 IPTR DoSuperNew(struct IClass *cl, Object *obj, IPTR tag1, ...);
15 #endif
17 static inline LONG xget(void *object, ULONG attr)
19 LONG a = 0;
20 get(object,attr,&a);
21 return a;
24 static inline int sxget(void *object, LONG attr)
26 int a[ 0 ];
27 get(object, attr, a);
28 return a[ 0 ];
31 #if !defined(__AROS__)
32 #define nfset(obj, attr, val) \
33 SetAttrs(obj, MUIA_Group_Forward, FALSE, \
34 attr, val, \
35 TAG_DONE)
36 #endif
38 #define getstr(obj) ((char *)xget(obj, MUIA_String_Contents))
41 #define isDir(fib) ((fib)->fib_DirEntryType > 0)
43 static inline LONG isDirPath(char *path)
45 BPTR lock = Lock(path, ACCESS_READ);
46 if (lock != BNULL)
48 struct FileInfoBlock fib;
49 if (Examine(lock, &fib))
51 UnLock(lock);
52 return isDir(&fib);
55 return FALSE;
58 /* find container (parent object) which contains object with given attribute supported */
60 static inline Object *objFindContainerByAttribute(Object *obj, ULONG attribute)
62 unsigned int v;
64 while (obj != NULL)
66 unsigned int ret = get(obj, attribute, &v);
67 if (ret)
68 return obj;
70 obj = _parent(obj);
72 return NULL;
76 /// Morphos specific hook stuff
79 * Hook, called with the following:
80 * n - name of the hook (_hook appened at the end)
81 * y - a2
82 * z - a1
84 * return type is LONG
87 #ifdef __MORPHOS__
89 #define M_RHOOK(n, y, z) \
90 static int n##_GATE(void); \
91 static int n##_GATE2(struct Hook *h, y, z); \
92 static struct EmulLibEntry n = { \
93 TRAP_LIB, 0, (void (*)(void))n##_GATE }; \
94 static int n##_GATE(void) { \
95 return (n##_GATE2((void *)REG_A0, (void *)REG_A2, (void *)REG_A1)); } \
96 static struct Hook n##Hook = { {0, 0}, (void *)&n , NULL , NULL }; \
97 static int n##_GATE2(struct Hook *h, y, z)
99 #define M_HOOK(n, y, z) \
100 static void n##_GATE(void); \
101 static void n##_GATE2(struct Hook *h, y, z); \
102 static struct EmulLibEntry n = { \
103 TRAP_LIB, 0, (void (*)(void))n##_GATE }; \
104 static void n##_GATE(void) { \
105 return (n##_GATE2((void *)REG_A0, (void *)REG_A2, (void *)REG_A1)); } \
106 static struct Hook n##Hook = { {0, 0}, (void *)&n , NULL , NULL }; \
107 static void n##_GATE2(struct Hook *h, y, z)
109 /* simple version */
111 #define S_HOOK(n) \
112 static struct EmulLibEntry n ## Func = { \
113 TRAP_LIB, 0, (void (*)(void))n }; \
114 static const struct Hook n ## Hook = { { NULL,NULL }, (void*)&n ## Func,NULL,NULL };\
115 void n(void)
117 #elif __AROS__
119 #define M_HOOK(n, y, z) \
120 static void n##_func(struct Hook *h, y, z); \
121 static struct Hook n ## Hook = \
123 0, 0, HookEntry, ( HOOKFUNC ) n##_func \
124 }; \
126 static void n##_func( struct Hook *h, y, z )
128 #else
129 #define M_HOOK(n, y, z) \
130 static void ASM SAVEDS n##_func(__reg(a0, struct Hook *h), \
131 __reg(a2, y), __reg(a1, z)); \
132 static struct Hook n ## Hook = \
134 0, 0, ( HOOKFUNC ) n##_func \
138 static void ASM SAVEDS n##_func( __reg( a0, struct Hook *h ), \
139 __reg( a2, y ), __reg( a1, z ) )
140 #endif /* !__MORPHOS__ */
142 ////
144 #define FORTAG(_tagp) \
146 struct TagItem *tag, *_tags = _tagp; \
147 while ((tag = NextTagItem(&_tags))) switch ((int)tag->ti_Tag)
148 #define NEXTTAG }
150 #define FORCHILD(_o, _a) \
152 APTR child, _cstate = (APTR)((struct MinList *)xget(_o, _a))->mlh_Head; \
153 while ((child = NextObject(&_cstate)))
155 #define NEXTCHILD }
157 #define SUCCCHILD ({ APTR _succcstate = _cstate; \
158 NextObject(&_succcstate);})
160 #define INITTAGS (((struct opSet *)msg)->ops_AttrList)
162 #undef NextObject
163 #define NextObject(cstate) \
165 struct Node **nptr = (struct Node **)cstate;\
166 struct Node *this = *nptr;\
167 APTR next = this->ln_Succ;\
168 if (next)\
170 *nptr = next;\
171 next = BASEOBJECT(this);\
173 next;\
176 #ifndef MADF_VISIBLE
177 #define MADF_VISIBLE (1<<14)
178 #endif
180 #ifndef MADF_DISABLED
181 #define MADF_DISABLED (1<<15)
182 #endif
184 #ifndef _isvibible
185 #define _isvisible(obj) (_flags(obj) & MADF_VISIBLE)
186 #endif
188 #define METHOD static ULONG
189 #define PUBLIC_METHOD ULONG
191 #if !defined(__AROS__)
192 struct MUI_RGBcolor
194 ULONG red;
195 ULONG green;
196 ULONG blue;
198 #endif
200 #ifndef MUIA_Pendisplay_RGBcolor
201 #define MUIA_Pendisplay_RGBcolor 0x8042a1a9 /* V11 isg struct MUI_RGBcolor * */
202 #endif
204 #ifndef MUIM_Text
205 #define MUIM_Text 0x8042ee70 /* private */ /* V20 */
206 #define MUIM_TextDim 0x80422ad7 /* private */ /* V20 */
208 struct MUIP_Text { ULONG MethodID; LONG left;LONG top;LONG width;LONG height;STRPTR text;LONG len;STRPTR preparse;ULONG flags; }; /* private */
209 struct MUIP_TextDim { ULONG MethodID; STRPTR text;LONG len;STRPTR preparse;ULONG flags; }; /* private */
210 #endif
212 #ifndef MUIA_List_AutoLineHeight
213 #define MUIA_List_AutoLineHeight 0x8042bc08 /* V20 i.. BOOL */ /* private */
214 #endif
216 #ifndef MUIM_Group_GetChild
217 #define MUIM_Group_GetChild 0x8042c556 /* private */ /* V20 */
219 #define MUIV_Group_GetChild_First MUIV_Family_GetChild_First
220 #define MUIV_Group_GetChild_Last MUIV_Family_GetChild_Last
221 #define MUIV_Group_GetChild_Next MUIV_Family_GetChild_Next
222 #define MUIV_Group_GetChild_Previous MUIV_Family_GetChild_Previous
223 #define MUIV_Group_GetChild_Iterate MUIV_Family_GetChild_Iterate
224 #endif
226 #ifndef MUIM_Group_ExitChange2
227 #define MUIM_Group_ExitChange2 0x8042e541 /* private */ /* V12 */
228 #endif
230 #ifndef MUIA_CustomBackfill
231 #define MUIA_CustomBackfill 0x80420a63 /* V11 isg BOOL */ /* private */
232 #endif
234 #ifndef MUIA_Window_OverrideStoredDimension
235 #define MUIA_Window_OverrideStoredDimension 0x8042c0f5 /* V20 is. BOOL */ /* private */
236 #endif
238 #ifndef MUIM_Backfill
239 #define MUIM_Backfill 0x80428d73 /* private */ /* V11 */
240 struct MUIP_Backfill { ULONG MethodID; LONG left; LONG top; LONG right; LONG bottom; LONG xoffset; LONG yoffset; LONG brightness; }; /* private */
241 #endif
243 #ifndef MUIA_Image_FontMatchString
244 #define MUIA_Image_FontMatchString 0x804263c1 /* V20 is. char * */ /* private */
245 #endif
247 // this one is really internal
248 #ifndef MUIM_Group_Balance
249 #define MUIM_Group_Balance 0x80425906 /* private */ /* V11 */
250 struct MUIP_Group_Balance { ULONG MethodID; Object *bal; LONG clickx; LONG clicky; LONG mode; LONG mousex; LONG mousey; }; /* private */
251 #endif
253 #ifndef MUIM_Window_HandleRMB
254 #define MUIM_Window_HandleRMB 0x80421786 /* private */ /* V20 */
255 #endif
257 #ifndef MUIM_Application_KillPushMethod
258 #define MUIM_Application_KillPushMethod 0x80429954 /* private */ /* V15 */
259 #endif
261 #ifndef MUIM_Virtgroup_MakeVisible
262 #define MUIM_Virtgroup_MakeVisible 0x8042d2d2 /* private */ /* V4 */
263 struct MUIP_Virtgroup_MakeVisible { ULONG MethodID; Object *obj; ULONG flags; }; /* private */
264 #endif
266 #ifndef MUIA_Title_Sortable
267 #define MUIA_Title_Sortable 0x804211f1 /* V20 isg BOOL */ /* private */
268 #endif
270 #ifndef MUIA_Window_OverrideStoredPosition
271 #define MUIA_Window_OverrideStoredPosition 0x8042fc00 /* V20 is. BOOL */ /* private */
272 #endif
274 #ifndef MUIA_Group_ChildCount
275 #define MUIA_Group_ChildCount 0x80420322 /* V20 ..g LONG */ /* private */
276 #endif
278 #ifndef MUIA_Alpha
279 #define MUIA_Alpha 0x8042c819 /* V20 isg LONG */ /* private */
280 #endif
282 #ifndef MUIF_PUSHMETHOD_VERIFY
283 // FIXME: AROS
284 #define MUIF_PUSHMETHOD_VERIFY (1<<30UL)
285 #endif
287 #ifndef MUIA_Menuitem_CopyStrings
288 // FIXME: AROS
289 #define MUIA_Menuitem_CopyStrings 0x8042dc1b /* V16 ..g BOOL */
290 #endif
292 #ifndef CODESET_UTF8
293 // FIXME: AROS
294 #define CODESET_UTF8 1
295 #endif
297 #endif