Add READSTRINGL and WRITESTRINGL macros

This commit is contained in:
LJ Sonic 2022-01-10 18:57:18 +01:00 committed by toaster
parent c7e495bf8b
commit 8558323c44

View file

@ -149,6 +149,15 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
WRITECHAR(p, '\0'); \
})
#define WRITESTRINGL(p, s, n) ({ \
size_t tmp_i; \
\
for (tmp_i = 0; tmp_i < n - 1 && s[tmp_i] != '\0'; tmp_i++) \
WRITECHAR(p, s[tmp_i]); \
\
WRITECHAR(p, '\0'); \
})
#define WRITESTRING(p, s) ({ \
size_t tmp_i; \
\
@ -181,6 +190,15 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
s[tmp_i] = '\0'; \
})
#define READSTRINGL(p, s, n) ({ \
size_t tmp_i = 0; \
\
while (tmp_i < n - 1 && (s[tmp_i] = READCHAR(p)) != '\0') \
tmp_i++; \
\
s[tmp_i] = '\0'; \
})
#define READSTRING(p, s) ({ \
size_t tmp_i = 0; \
\