Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / network / stacks / AROSTCP / syslog / str.c
blob72f7d534a89162d183afabff89d96fc1c4bb1a0f
1 #define __NOLIBBASE__
3 #include <proto/exec.h>
4 #if defined(__AROS__)
5 #include <stdio.h>
6 #include <string.h>
7 #else
8 #include <exec/rawfmt.h>
9 #endif
11 #include <stdarg.h>
13 extern struct Library *SysBase;
16 STRPTR strnew(APTR pool, STRPTR original)
18 ULONG l = 1;
19 STRPTR copy, p, s = original;
21 if (original) {
22 while (*original++) l++;
24 if (copy = AllocVecPooled(pool, l))
26 p = copy;
27 p--;
28 s--;
30 while (*++p = *++s);
32 } else {
33 copy = AllocVecPooled(pool, 1);
34 if (copy)
35 *copy = '\0';
37 return copy;
41 STRPTR vfmtnew(APTR pool, STRPTR fmt, ...)
43 ULONG l = 0;
44 STRPTR s;
46 va_list args;
48 #if defined(__AROS__)
49 va_start(args, fmt);
50 static UBYTE strng_tmp[1024];
51 sprintf((STRPTR)strng_tmp, fmt, args);
52 va_end(args);
53 l = strlen(strng_tmp);
54 #else
55 va_list copy;
57 __va_copy(copy, args);
59 VNewRawDoFmt(fmt, (APTR(*)(APTR, UBYTE))RAWFMTFUNC_COUNT, (STRPTR)&l, args);
60 #endif
62 if (s = AllocVecPooled(pool, l + 1))
64 #if defined(__AROS__)
65 strcpy(s, strng_tmp);
66 #else
67 VNewRawDoFmt(fmt, RAWFMTFUNC_STRING, s, copy);
68 #endif
70 return s;
74 STRPTR fmtnew(APTR pool, STRPTR fmt, ...)
76 STRPTR s;
77 va_list args;
79 va_start(args, fmt);
80 s = vfmtnew(pool, fmt, args);
81 va_end(args);
82 return s;