1#ifndef __DILLO_MISC_H__
2#define __DILLO_MISC_H__
12#define d_isascii(c) (((c) & ~0x7f) == 0)
32 static const char tspecials_space[] =
"()<>@,;:\\\"/[]?= ";
33 const char terminators[] =
" ;\t";
37 if (!disposition || !type || !filename)
46 !strchr(tspecials_space, *s); s++) ;
56 if (!strchr(terminators, *s)) {
63 while (*s ==
' ' || *s ==
'\t')
72 const char key[] =
"filename";
80 if (s != str && !strchr(terminators, s[-1]))
87 while (*s ==
' ' || *s ==
'\t')
98 while (*s ==
' ' || *s ==
'\t')
112 size_t maxlen = strlen(s);
118 for (
size_t i = 1; i < maxlen; i++) {
120 if (s[i - 1] !=
'\\' && s[i] ==
'"') {
133 if ((len = strcspn(s, terminators))) {
139 if (*filename == NULL)
143 const char bad_characters[] =
"/\\|~";
146 char *src =
dStrndup(*filename, len);
147 char *dst = *filename;
151 for (
size_t i = 0; i < len; i++) {
153 if (i + 1 < len && c ==
'\\' && src[i + 1] ==
'\"') {
157 }
else if (strchr(bad_characters, c)) {
char * dStriAsciiStr(const char *haystack, const char *needle)
Case insensitive strstr.
char * dStrndup(const char *s, size_t sz)
int a_Misc_parse_search_url(char *source, char **label, char **urlstr)
Parse dillorc's search_url string ([<label> ]<url>) Return value: -1 on error, 0 on success (and labe...
static void a_Misc_parse_content_disposition(const char *disposition, char **type, char **filename)
Parse Content-Disposition string, e.g., "attachment; filename="file name.jpg"".
int a_Misc_content_type_check(const char *EntryType, const char *DetectedType)
Check the server-supplied 'Content-Type' against our detected type.
void a_Misc_parse_content_type(const char *str, char **major, char **minor, char **charset)
Parse Content-Type string, e.g., "text/html; charset=utf-8".
int a_Misc_expand_tabs(char **start, char *end, char *buf, int buflen)
Takes a string and converts any tabs to spaces.
Dstr * a_Misc_file2dstr(const char *filename)
Load a local file into a dStr.
char * a_Misc_encode_base64(const char *in)
Encodes string using base64 encoding.
char * a_Misc_escape_chars(const char *str, const char *esc_set)
Escape characters as XX sequences.
int a_Misc_parse_geometry(char *geom, int *x, int *y, int *w, int *h)
Parse a geometry string.
int a_Misc_content_type_cmp(const char *ct1, const char *ct2)
Compare two Content-Type strings.
int a_Misc_get_content_type_from_data(void *Data, size_t Size, const char **PT)
Detects 'Content-Type' from a data stream sample.