Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / reqtools / misc.c
blobd9f9d38d517658e8ba35391bce5a72b70e717c32
1 #include <exec/rawfmt.h>
3 #include "filereq.h"
5 #include <string.h>
6 #include <stdarg.h>
8 #ifndef __AROS__
9 typedef void (*VOID_FUNC)();
10 #endif
12 /****************************************************************************************/
14 void StrCat(char *s, char *s2)
16 strcat(s, s2);
19 /****************************************************************************************/
21 static void filltable(char **table, char *buff, char fill)
23 static char c;
25 *table++ = buff;
27 for(;;)
29 c = *buff++;
30 if (c == '\0') break;
31 if (c == fill)
33 buff[-1] = '\0';
34 *table++ = buff;
39 /****************************************************************************************/
41 void FillNewLineTable (char **table, char *buff)
43 filltable(table, buff, '\n');
46 /****************************************************************************************/
48 void FillBarTable (char **table, char *buff)
50 filltable(table, buff, '|');
53 /****************************************************************************************/
55 #ifdef __AROS__
56 AROS_UFH2 (void, puttostr,
57 AROS_UFHA(UBYTE, chr, D0),
58 AROS_UFHA(STRPTR *,strPtrPtr,A3)
61 AROS_USERFUNC_INIT
62 #else
63 void puttostr(REGPARAM(d0, UBYTE, chr),
64 REGPARAM(a3, STRPTR *, strPtrPtr))
66 #endif
67 *(*strPtrPtr)= chr;
68 (*strPtrPtr) ++;
69 #ifdef __AROS__
70 AROS_USERFUNC_EXIT
71 #endif
74 /****************************************************************************************/
76 #ifdef __AROS__
77 AROS_UFH2 (void, CountBarsAndChars,
78 AROS_UFHA(UBYTE, chr, D0),
79 AROS_UFHA(ULONG *,ptr,A3)
82 AROS_USERFUNC_INIT
83 #else
84 void CountBarsAndChars(REGPARAM(d0, UBYTE, chr),
85 REGPARAM(a3, ULONG *, ptr))
87 #endif
88 if (chr == '|') (ptr[0])++;
89 (ptr[1])++;
90 #ifdef __AROS__
91 AROS_USERFUNC_EXIT
92 #endif
95 /****************************************************************************************/
97 #ifdef __AROS__
98 AROS_UFH2 (void, CountNewLinesAndChars,
99 AROS_UFHA(UBYTE, chr, D0),
100 AROS_UFHA(ULONG *,ptr,A3)
103 AROS_USERFUNC_INIT
104 #else
105 void CountNewLinesAndChars(REGPARAM(d0, UBYTE, chr),
106 REGPARAM(a3, ULONG *, ptr))
108 #endif
109 if (chr == '\n') (ptr[0])++;
110 (ptr[1])++;
111 #ifdef __AROS__
112 AROS_USERFUNC_EXIT
113 #endif
116 /****************************************************************************************/
118 APTR DofmtArgs (char *buff, char *fmt ,...)
120 #ifdef __AROS__
121 va_list ap;
123 /* Some AROS architectures don't have uniform varadics
124 * (ie an array of IPTR), so they can't use RawDoFmt()
125 * - we will use VNewRawDoFmt() instead.
127 va_start(ap, fmt);
128 VNewRawDoFmt(fmt, (VOID_FUNC)RAWFMTFUNC_STRING, buff, ap);
129 va_end(ap);
130 #else
131 RawDoFmt(fmt, &fmt + 1, (VOID_FUNC)puttostr, &str);
132 #endif
134 return NULL;
137 /****************************************************************************************/
139 APTR Dofmt (char *buff, char *fmt, APTR args)
141 char *str = buff;
143 return RawDoFmt(fmt, args, (VOID_FUNC)puttostr, &str);
147 /****************************************************************************************/
149 APTR DofmtCount (char *fmt, APTR args, ULONG *ptr, int mode)
151 ptr[0] = ptr[1] = 1;
153 return RawDoFmt(fmt,
154 args,
155 (mode ? ((VOID_FUNC)CountBarsAndChars) : ((VOID_FUNC)CountNewLinesAndChars) ),
156 ptr);
159 /****************************************************************************************/
161 void ShortDelay(void)
163 Delay(5);
166 /****************************************************************************************/
168 IPTR LoopReqHandler(struct rtHandlerInfo *rthi)
170 IPTR handler_retval, sigs;
174 if (rthi->DoNotWait)
175 sigs = 0;
176 else
177 sigs = Wait(rthi->WaitMask);
179 handler_retval = (ULONG)rtReqHandlerA(rthi, sigs, NULL);
181 } while (handler_retval == CALL_HANDLER);
183 return handler_retval;
187 /****************************************************************************************/
189 void DoWaitPointer(struct Window *win, int doit, int setpointer)
191 if (win && doit)
193 if (setpointer)
194 rtSetWaitPointer(win);
195 else
196 ClearPointer(win);
201 /****************************************************************************************/
203 APTR DoLockWindow(struct Window *win, int doit, APTR lock, int lockit)
205 if (!doit || !win) return NULL;
207 if (lockit) return rtLockWindow(win);
209 rtUnlockWindow(win, lock);
211 return NULL;
214 /****************************************************************************************/
216 void SetWinTitleFlash(struct Window *win, char *str)
218 DisplayBeep(win->WScreen);
219 SetWindowTitles(win, str, (UBYTE *)-1);
222 /****************************************************************************************/
223 /****************************************************************************************/
224 /****************************************************************************************/
225 /****************************************************************************************/
226 /****************************************************************************************/
227 /****************************************************************************************/