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