diff options
| author | 2022-12-11 09:46:27 +0100 | |
|---|---|---|
| committer | 2022-12-11 09:46:27 +0100 | |
| commit | 0337c71cf45e9b646c1cd4cb39426073623267f2 (patch) | |
| tree | 95c0ee6d991342c8057e0705d55526967282477b | |
| parent | Log the response date in send_to_inbox() errors. (diff) | |
| download | penes-snac2-0337c71cf45e9b646c1cd4cb39426073623267f2.tar.gz penes-snac2-0337c71cf45e9b646c1cd4cb39426073623267f2.tar.xz penes-snac2-0337c71cf45e9b646c1cd4cb39426073623267f2.zip | |
Backport from xs.
| -rw-r--r-- | xs.h | 18 | ||||
| -rw-r--r-- | xs_httpd.h | 8 | ||||
| -rw-r--r-- | xs_version.h | 2 |
3 files changed, 22 insertions, 6 deletions
| @@ -90,6 +90,7 @@ d_char *xs_number_new(double f); | |||
| 90 | double xs_number_get(const char *v); | 90 | double xs_number_get(const char *v); |
| 91 | const char *xs_number_str(const char *v); | 91 | const char *xs_number_str(const char *v); |
| 92 | 92 | ||
| 93 | void *xs_memmem(const char *haystack, int h_size, const char *needle, int n_size); | ||
| 93 | 94 | ||
| 94 | #ifdef XS_IMPLEMENTATION | 95 | #ifdef XS_IMPLEMENTATION |
| 95 | 96 | ||
| @@ -907,6 +908,23 @@ const char *xs_number_str(const char *v) | |||
| 907 | } | 908 | } |
| 908 | 909 | ||
| 909 | 910 | ||
| 911 | void *xs_memmem(const char *haystack, int h_size, const char *needle, int n_size) | ||
| 912 | /* clone of memmem */ | ||
| 913 | { | ||
| 914 | char *p, *r = NULL; | ||
| 915 | int offset = 0; | ||
| 916 | |||
| 917 | while (!r && h_size - offset > n_size && (p = strchr(haystack + offset, *needle))) { | ||
| 918 | if (memcmp(p, needle, n_size) == 0) | ||
| 919 | r = p; | ||
| 920 | else | ||
| 921 | offset = p - haystack + 1; | ||
| 922 | } | ||
| 923 | |||
| 924 | return r; | ||
| 925 | } | ||
| 926 | |||
| 927 | |||
| 910 | #endif /* XS_IMPLEMENTATION */ | 928 | #endif /* XS_IMPLEMENTATION */ |
| 911 | 929 | ||
| 912 | #endif /* _XS_H */ | 930 | #endif /* _XS_H */ |
| @@ -69,8 +69,6 @@ d_char *xs_url_vars(char *str) | |||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | 71 | ||
| 72 | void *memmem(const void *, size_t, const void *, size_t); | ||
| 73 | |||
| 74 | d_char *_xs_multipart_form_data(char *payload, int p_size, char *header) | 72 | d_char *_xs_multipart_form_data(char *payload, int p_size, char *header) |
| 75 | /* parses a multipart/form-data payload */ | 73 | /* parses a multipart/form-data payload */ |
| 76 | { | 74 | { |
| @@ -94,7 +92,7 @@ d_char *_xs_multipart_form_data(char *payload, int p_size, char *header) | |||
| 94 | d_char *p_vars = xs_dict_new(); | 92 | d_char *p_vars = xs_dict_new(); |
| 95 | 93 | ||
| 96 | /* iterate searching the boundaries */ | 94 | /* iterate searching the boundaries */ |
| 97 | while ((p = memmem(payload + offset, p_size - offset, boundary, bsz)) != NULL) { | 95 | while ((p = xs_memmem(payload + offset, p_size - offset, boundary, bsz)) != NULL) { |
| 98 | xs *s1 = NULL; | 96 | xs *s1 = NULL; |
| 99 | xs *l1 = NULL; | 97 | xs *l1 = NULL; |
| 100 | char *vn = NULL; | 98 | char *vn = NULL; |
| @@ -133,13 +131,13 @@ d_char *_xs_multipart_form_data(char *payload, int p_size, char *header) | |||
| 133 | } | 131 | } |
| 134 | 132 | ||
| 135 | /* find the start of the part content */ | 133 | /* find the start of the part content */ |
| 136 | if ((p = memmem(p, p_size - offset, "\r\n\r\n", 4)) == NULL) | 134 | if ((p = xs_memmem(p, p_size - offset, "\r\n\r\n", 4)) == NULL) |
| 137 | break; | 135 | break; |
| 138 | 136 | ||
| 139 | p += 4; | 137 | p += 4; |
| 140 | 138 | ||
| 141 | /* find the next boundary */ | 139 | /* find the next boundary */ |
| 142 | if ((q = memmem(p, p_size - offset, boundary, bsz)) == NULL) | 140 | if ((q = xs_memmem(p, p_size - offset, boundary, bsz)) == NULL) |
| 143 | break; | 141 | break; |
| 144 | 142 | ||
| 145 | po = p - payload; | 143 | po = p - payload; |
diff --git a/xs_version.h b/xs_version.h index a579266..5b9a4cf 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* ad1c7ba748725abdecc1f1124d697f9130c49e87 */ | /* 3aa82bc4fc310ec95194602bed88a9767e100350 */ | ||