6 #include <clib/alib_protos.h>
7 #include <proto/exec.h>
8 #include <proto/intuition.h>
9 #include <proto/utility.h>
11 #include "support_amigaos.h"
13 /***************************************************************************/
17 /************************************************************
18 Like AllocVec() but for pools
19 *************************************************************/
20 APTR
AllocVecPooled(APTR pool
, ULONG size
)
24 if (pool
== NULL
) return NULL
;
27 memory
= AllocPooled(pool
, size
);
37 /************************************************************
38 Like FreeVec() but for pools
39 *************************************************************/
40 VOID
FreeVecPooled(APTR pool
, APTR memory
)
44 IPTR
*real
= (IPTR
*) memory
;
47 FreePooled(pool
, real
, size
);
57 /************************************************************
58 Snprintf function for RawDoFmt()
59 *************************************************************/
60 __asm
void snprintf_func(register __d0 UBYTE chr
, register __a3
struct snprintf_msg
*msg
)
69 /************************************************************
70 Snprintf via RawDoFmt()
71 *************************************************************/
72 int snprintf(char *buf
, int size
, const char *fmt
, ...)
74 struct snprintf_msg msg
;
80 RawDoFmt(fmt
, (((ULONG
*)&fmt
)+1), snprintf_func
, &msg
);
84 return (int)strlen(buf
);
87 /************************************************************
88 sprintf via RawDoFmt()
89 *************************************************************/
90 int sprintf(char *buf
, const char *fmt
, ...)
92 static const ULONG cpy_func
= 0x16c04e75; /* move.b d0,(a3)+ ; rts */
93 RawDoFmt(fmt
, (((ULONG
*)&fmt
)+1), (void(*)())&cpy_func
, buf
);
94 return (int)strlen(buf
);
97 Object
*VARARGS68K
DoSuperNewTags(struct IClass
*cl
, Object
*obj
, void *dummy
, ...)
100 va_start(argptr
,dummy
);
101 obj
= DoSuperNewTagList(cl
,obj
,dummy
,(struct TagItem
*)argptr
);
109 ASM ULONG
HookEntry(REG(a0
, struct Hook
*hook
),REG(a2
, APTR obj
), REG(a1
, APTR msg
))
111 return hook
->h_SubEntry(hook
,obj
,msg
);
114 Object
*VARARGS68K
DoSuperNewTags(struct IClass
*cl
, Object
*obj
, void *dummy
, ...)
117 struct TagItem
*tagList
;
119 va_startlinear(argptr
, dummy
);
120 tagList
= va_getlinearva(argptr
, struct TagItem
*);
121 obj
= DoSuperNewTagList(cl
,obj
,dummy
,tagList
);
126 int VARARGS68K
SPrintf(char *buf
, const char *fmt
, ...)
131 va_startlinear(argptr
, fmt
);
132 args
= va_getlinearva(argptr
, APTR
);
133 RawDoFmt((STRPTR
)fmt
, args
, NULL
, buf
);
136 return (int)strlen(buf
);
142 /***************************************************************************/
144 char *StrDup(const char *x
)
148 dup
= AllocVec(strlen(x
) + 1, MEMF_PUBLIC
);
149 if (dup
) CopyMem((char*)x
, dup
, strlen(x
) + 1);
153 Object
*DoSuperNewTagList(struct IClass
*cl
, Object
*obj
,void *dummy
, struct TagItem
*tags
)
155 return (Object
*)DoSuperMethod(cl
,obj
,OM_NEW
,tags
,NULL
);
158 size_t strlcat(char *buf
, const char *src
, size_t len
)
167 for (i
=0; i
< len
- 1 && *src
; i
++)
171 return 0; /* Actually don't know right rt here */