revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / reqtools / misc.c
blobe5fe9acc736eea17d2ae69cfd4bd9cfca39a1c50
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 APTR retval;
121 char *str = buff;
122 #ifdef __AROS__
123 va_list ap;
125 /* Some AROS architectures don't have uniform varadics
126 * (ie an array of IPTR), so they can't use RawDoFmt()
127 * - we will use VNewRawDoFmt() instead.
129 va_start(ap, fmt);
130 retval = VNewRawDoFmt(fmt, (VOID_FUNC)RAWFMTFUNC_STRING, &str, ap);
131 va_end(ap);
132 #else
133 retval = RawDoFmt(fmt, &fmt + 1, (VOID_FUNC)puttostr, &str);
134 #endif
136 return retval;
139 /****************************************************************************************/
141 APTR Dofmt (char *buff, char *fmt, APTR args)
143 char *str = buff;
145 return RawDoFmt(fmt, args, (VOID_FUNC)puttostr, &str);
149 /****************************************************************************************/
151 APTR DofmtCount (char *fmt, APTR args, ULONG *ptr, int mode)
153 ptr[0] = ptr[1] = 1;
155 return RawDoFmt(fmt,
156 args,
157 (mode ? ((VOID_FUNC)CountBarsAndChars) : ((VOID_FUNC)CountNewLinesAndChars) ),
158 ptr);
161 /****************************************************************************************/
163 void ShortDelay(void)
165 Delay(5);
168 /****************************************************************************************/
170 IPTR LoopReqHandler(struct rtHandlerInfo *rthi)
172 IPTR handler_retval, sigs;
176 if (rthi->DoNotWait)
177 sigs = 0;
178 else
179 sigs = Wait(rthi->WaitMask);
181 handler_retval = rtReqHandlerA(rthi, sigs, NULL);
183 } while (handler_retval == CALL_HANDLER);
185 return handler_retval;
189 /****************************************************************************************/
191 void DoWaitPointer(struct Window *win, int doit, int setpointer)
193 if (win && doit)
195 if (setpointer)
196 rtSetWaitPointer(win);
197 else
198 ClearPointer(win);
203 /****************************************************************************************/
205 APTR DoLockWindow(struct Window *win, int doit, APTR lock, int lockit)
207 if (!doit || !win) return NULL;
209 if (lockit) return rtLockWindow(win);
211 rtUnlockWindow(win, lock);
213 return NULL;
216 /****************************************************************************************/
218 void SetWinTitleFlash(struct Window *win, char *str)
220 DisplayBeep(win->WScreen);
221 SetWindowTitles(win, str, (UBYTE *)-1);
224 /****************************************************************************************/
225 /****************************************************************************************/
226 /****************************************************************************************/
227 /****************************************************************************************/
228 /****************************************************************************************/
229 /****************************************************************************************/