diff options
Diffstat (limited to 'src/macros.h')
| -rw-r--r-- | src/macros.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/macros.h b/src/macros.h index 8be48dd..00e80a6 100644 --- a/src/macros.h +++ b/src/macros.h @@ -9,7 +9,9 @@ #include <alloca.h> #include <string.h> +#include <stdio.h> +/* I LOVE ALLOCA */ #define L2_ASTRCAT2(_var, _s1, _len1, _s2, _len2) do { \ _var = alloca(_len1 + _len2 + 1); \ memcpy(_var, (_s1), (_len1)); \ @@ -17,6 +19,12 @@ (_var)[((_len1) + (_len2))] = '\0'; \ } while (0) +#define L2_ASPRINTF(_var, _tmp, _fmt, ...) do { \ + _tmp = snprintf(NULL, 0, _fmt, __VA_ARGS__); \ + _var = alloca(_tmp + 1); \ + snprintf(_var, _tmp + 1, _fmt, __VA_ARGS__); \ +} while (0) + #define L2_USER_AGENT PROJECT_NAME "/0.1.0 <[email protected]>" #define L2_URL_META_BASE "https://piston-meta.mojang.com" |
