| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | #define E0 (1 << 16) |
|---|
| 28 | #define E1 (2 << 16) |
|---|
| 29 | #define E2 (3 << 16) |
|---|
| 30 | #define E3 (4 << 16) |
|---|
| 31 | #define EUNKNOWN (E0) |
|---|
| 32 | #define EDOSHUTDOWN (E0 + 1) |
|---|
| 33 | #define EDOGRACEFUL (E0 + 2) |
|---|
| 34 | #define EDOTIMEOUT (E0 + 3) |
|---|
| 35 | #define ECLIENTRESET (E0 + 4) |
|---|
| 36 | #define ESYNTAX (E0 + 5) |
|---|
| 37 | #define EREDIRECTOR (E0 + 6) |
|---|
| 38 | #define EDNS_HOST_NOT_FOUND (E1) |
|---|
| 39 | #define EDNS_NO_ADDRESS (E1 + 1) |
|---|
| 40 | #define EDNS_NO_RECOVERY (E1 + 2) |
|---|
| 41 | #define EDNS_TRY_AGAIN (E1 + 3) |
|---|
| 42 | #define EDNS_INVALID (E1 + 4) |
|---|
| 43 | #define EDNS_UNSUPPORTED (E1 + 5) |
|---|
| 44 | #define EDNS_FORMAT (E1 + 6) |
|---|
| 45 | #define EDNS_REFUSED (E1 + 7) |
|---|
| 46 | #define EDNS_CNAME_LOOP (E1 + 8) |
|---|
| 47 | #define ESOCKS_PROTOCOL (E2) |
|---|
| 48 | |
|---|
| 49 | #define ESOCKS_REJECT_FAIL (E2 + 1) |
|---|
| 50 | #define ESOCKS_REJECT_IDENTD (E2 + 2) |
|---|
| 51 | #define ESOCKS_REJECT_UID_MISMATCH (E2 + 3) |
|---|
| 52 | |
|---|
| 53 | #define ESOCKS5_BASE (E3) |
|---|
| 54 | |
|---|
| 55 | typedef struct _IntRange { |
|---|
| 56 | int from; |
|---|
| 57 | int to; |
|---|
| 58 | } IntRangeRec, *IntRangePtr; |
|---|
| 59 | |
|---|
| 60 | typedef struct _IntList { |
|---|
| 61 | int length; |
|---|
| 62 | int size; |
|---|
| 63 | IntRangePtr ranges; |
|---|
| 64 | } IntListRec, *IntListPtr; |
|---|
| 65 | |
|---|
| 66 | char *strdup_n(const char *restrict buf, int n) ATTRIBUTE ((malloc)); |
|---|
| 67 | int snnprintf(char *restrict buf, int n, int len, const char *format, ...) |
|---|
| 68 | ATTRIBUTE ((format (printf, 4, 5))); |
|---|
| 69 | int snnprint_n(char *restrict buf, int n, int len, const char *s, int slen); |
|---|
| 70 | int strcmp_n(const char *string, const char *buf, int n) ATTRIBUTE ((pure)); |
|---|
| 71 | int digit(char) ATTRIBUTE ((const)); |
|---|
| 72 | int letter(char) ATTRIBUTE ((const)); |
|---|
| 73 | char lwr(char) ATTRIBUTE ((const)); |
|---|
| 74 | char* lwrcpy(char *restrict dst, const char *restrict src, int n); |
|---|
| 75 | int lwrcmp(const char *as, const char *bs, int n) ATTRIBUTE ((pure)); |
|---|
| 76 | int strcasecmp_n(const char *string, const char *buf, int n) |
|---|
| 77 | ATTRIBUTE ((pure)); |
|---|
| 78 | int atoi_n(const char *restrict string, int n, int len, int *value_return); |
|---|
| 79 | int isWhitespace(const char *string) ATTRIBUTE((pure)); |
|---|
| 80 | #ifndef HAVE_MEMRCHR |
|---|
| 81 | void *memrchr(const void *s, int c, size_t n) ATTRIBUTE ((pure)); |
|---|
| 82 | #endif |
|---|
| 83 | int h2i(char h) ATTRIBUTE ((const)); |
|---|
| 84 | char i2h(int i) ATTRIBUTE ((const)); |
|---|
| 85 | int log2_floor(int x) ATTRIBUTE ((const)); |
|---|
| 86 | int log2_ceil(int x) ATTRIBUTE ((const)); |
|---|
| 87 | char* vsprintf_a(const char *f, va_list args) |
|---|
| 88 | ATTRIBUTE ((malloc, format (printf, 1, 0))); |
|---|
| 89 | char* sprintf_a(const char *f, ...) |
|---|
| 90 | ATTRIBUTE ((malloc, format (printf, 1, 2))); |
|---|
| 91 | unsigned int hash(unsigned seed, const void *restrict key, int key_size, |
|---|
| 92 | unsigned int hash_size) |
|---|
| 93 | ATTRIBUTE ((pure)); |
|---|
| 94 | char *pstrerror(int e); |
|---|
| 95 | time_t mktime_gmt(struct tm *tm) ATTRIBUTE ((pure)); |
|---|
| 96 | AtomPtr expandTilde(AtomPtr filename); |
|---|
| 97 | void do_daemonise(int noclose); |
|---|
| 98 | void writePid(char *pidfile); |
|---|
| 99 | int b64cpy(char *restrict dst, const char *restrict src, int n, int fss); |
|---|
| 100 | int b64cmp(const char *restrict a, int an, const char *restrict b, int bn) |
|---|
| 101 | ATTRIBUTE ((pure)); |
|---|
| 102 | IntListPtr makeIntList(int size) ATTRIBUTE ((malloc)); |
|---|
| 103 | void destroyIntList(IntListPtr list); |
|---|
| 104 | int intListMember(int n, IntListPtr list) ATTRIBUTE ((pure)); |
|---|
| 105 | int intListCons(int from, int to, IntListPtr list); |
|---|