aboutsummaryrefslogtreecommitdiffstats
path: root/src/macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/macros.h')
-rw-r--r--src/macros.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/macros.h b/src/macros.h
index 71aa137..f15cdd7 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -25,6 +25,20 @@
snprintf(_var, _tmp + 1, _fmt, __VA_ARGS__); \
} while (0)
+/* astrdup is a gnu extension */
+/* _var: the variable to which the duplicated string is assigned
+ * _sz: the length of the string duplicated (contractually)
+ * _in: the NUL-terminated string to duplicate */
+#define L2_ASTRDUP(_var, _sz, _in) do { \
+ _sz = strlen(_in); \
+ _var = alloca(_sz + 1); \
+ memcpy(_var, _in, _sz); \
+ (_var)[(_sz)] = '\0'; \
+} while (0)
+
+#define L2_BADMIN(_v1, _v2) (((_v1) < (_v2)) ? (_v1) : (_v2))
+#define L2_BADMAX(_v1, _v2) (((_v1) > (_v2)) ? (_v1) : (_v2))
+
#define L2_USER_AGENT PROJECT_NAME "/0.1.0 <[email protected]>"
#define L2_URL_META_BASE "https://piston-meta.mojang.com"