summaryrefslogtreecommitdiffstats
path: root/src/utils.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:54:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:54:31 +0000
commit3b4936b6f2b870f9f2444ebb6ce1ca2de3f49d9f (patch)
treec91ab0ac9447b25f91c05e901212c2142fb95953 /src/utils.h
parentInitial commit. (diff)
downloadttyd-3b4936b6f2b870f9f2444ebb6ce1ca2de3f49d9f.tar.xz
ttyd-3b4936b6f2b870f9f2444ebb6ce1ca2de3f49d9f.zip
Adding upstream version 1.7.4.upstream/1.7.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/utils.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..826bb94
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,39 @@
+#ifndef TTYD_UTIL_H
+#define TTYD_UTIL_H
+
+#define container_of(ptr, type, member) \
+ ({ \
+ const typeof(((type *)0)->member) *__mptr = (ptr); \
+ (type *)((char *)__mptr - offsetof(type, member)); \
+ })
+
+// malloc with NULL check
+void *xmalloc(size_t size);
+
+// realloc with NULL check
+void *xrealloc(void *p, size_t size);
+
+// Convert a string to upper case
+char *uppercase(char *s);
+
+// Convert a string to lower case
+char *lowercase(char *s);
+
+// Check whether str ends with suffix
+bool endswith(const char *str, const char *suffix);
+
+// Get human readable signal string
+int get_sig_name(int sig, char *buf, size_t len);
+
+// Get signal code from string like SIGHUP
+int get_sig(const char *sig_name);
+
+// Open uri with the default application of system
+int open_uri(char *uri);
+
+#ifdef _WIN32
+char *strsep(char **sp, char *sep);
+const char *quote_arg(const char *arg);
+void print_error(char *func);
+#endif
+#endif // TTYD_UTIL_H