fork repo
Some checks failed
backend / cross (aarch64) (push) Failing after 17s
backend / cross (armhf) (push) Failing after 31s
backend / cross (mips) (push) Failing after 31s
backend / cross (mips64) (push) Failing after 31s
backend / cross (mips64el) (push) Failing after 31s
frontend / build (push) Failing after 32s
backend / cross (arm) (push) Failing after 2m19s
backend / cross (i686) (push) Failing after 1s
backend / cross (mipsel) (push) Failing after 31s
backend / cross (s390x) (push) Failing after 31s
backend / cross (win32) (push) Failing after 31s
backend / cross (x86_64) (push) Failing after 32s
docker / build (push) Failing after 6m14s

This commit is contained in:
2025-09-02 21:03:35 +08:00
commit c79c776225
61 changed files with 45370 additions and 0 deletions

39
src/utils.h Normal file
View File

@@ -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