X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/d914d1cbfd541d1c1302ac989a8c5b7d57d25f55..0f3e9cfc4b5d0f13085c975e10c0e6c4c8e5fbc3:/src/tools.c diff --git a/src/tools.c b/src/tools.c index 981288b..a46ed50 100644 --- a/src/tools.c +++ b/src/tools.c @@ -982,3 +982,49 @@ char *time2str(time_t thetime) return(buf); } +char* x3_strtok(char **save, char *str, char *fs) +{ + char *pos = *save; /* keep last position across calls */ + char *tmp; + + if (str) + pos = str; /* new string scan */ + + while (pos && *pos && strchr(fs, *pos) != NULL) + pos++; /* skip leading separators */ + + if (!pos || !*pos) + return (pos = *save = NULL); /* string contains only sep's */ + + tmp = pos; /* now, keep position of the token */ + + while (*pos && strchr(fs, *pos) == NULL) + pos++; /* skip content of the token */ + + if (*pos) + *pos++ = '\0'; /* remove first sep after the token */ + else + pos = NULL; /* end of string */ + + *save = pos; + return (tmp); +} + +int valid_email(const char *email) +{ + unsigned int i; + for (i=0;i