23 |
#endif |
#endif |
24 |
|
|
25 |
#include <string.h> |
#include <string.h> |
26 |
|
#include <stdlib.h> |
27 |
#include <stdio.h> |
#include <stdio.h> |
28 |
#include <ctype.h> |
#include <ctype.h> |
29 |
|
|
55 |
} |
} |
56 |
else /* Find the end of the token. */ |
else /* Find the end of the token. */ |
57 |
end = strpbrk (begin, delim); |
end = strpbrk (begin, delim); |
58 |
if ( end ){ |
if (end) { |
59 |
/* Terminate the token and set *STRINGP past NUL character. */ |
/* Terminate the token and set *STRINGP past NUL character. */ |
60 |
*end++ = '\0'; |
*end++ = '\0'; |
61 |
*stringp = end; |
*stringp = end; |
95 |
int |
int |
96 |
check_email_address (const char *email) |
check_email_address (const char *email) |
97 |
{ |
{ |
98 |
const char *allowed = "@._-%+"; |
const char *allowed = "@._-%+;"; |
99 |
size_t i; |
size_t i; |
100 |
|
|
101 |
if (!strchr (email, '@')) |
if (!strchr (email, '@')) |
109 |
} |
} |
110 |
return 0; |
return 0; |
111 |
} |
} |
112 |
|
|
113 |
|
|
114 |
|
/* Return a substring of @str from the position @begin |
115 |
|
to position @end. */ |
116 |
|
char* |
117 |
|
substr (const char *str, unsigned int begin, unsigned int end) |
118 |
|
{ |
119 |
|
char *p; |
120 |
|
size_t i, pos; |
121 |
|
|
122 |
|
if (end > strlen (str) || begin > strlen (str) || (end-begin) < 0) |
123 |
|
return NULL; |
124 |
|
|
125 |
|
/*p = new char[end-begin+1]; XXX: fixme*/ |
126 |
|
p = (char*)calloc (1, end-begin+1); |
127 |
|
if (!p) |
128 |
|
abort (); |
129 |
|
|
130 |
|
for (i = begin, pos=0; i < end; i++) |
131 |
|
p[pos++] = str[i]; |
132 |
|
p[pos] = '\0'; |
133 |
|
return p; |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
/* Remove %AB sequences from the input buffer @in |
138 |
|
and store the raw data in @out. */ |
139 |
|
void |
140 |
|
unhexify_buffer (const char *in, char **out) |
141 |
|
{ |
142 |
|
char temp[3]; |
143 |
|
size_t pos, i=0; |
144 |
|
|
145 |
|
*out = (char*)calloc (1, strlen (in)+1); |
146 |
|
if (!*out) |
147 |
|
abort (); |
148 |
|
for (pos = 0; pos < strlen (in); pos++) { |
149 |
|
if (in[pos] == '%' && in[pos+1] == '%') |
150 |
|
(*out)[i++] = '%'; |
151 |
|
else if (in[pos] == '%') { |
152 |
|
temp[0] = in[++pos]; |
153 |
|
temp[1] = in[++pos]; |
154 |
|
temp[2] = 0; |
155 |
|
(*out)[i++] = (char)strtoul (temp, NULL, 16); |
156 |
|
} |
157 |
|
else |
158 |
|
(*out)[i++] = in[pos]; |
159 |
|
} |
160 |
|
(*out)[i] = 0; |
161 |
|
} |