X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/dee9951d5f32dee38cf29861acdb4a347931e147..0f3e9cfc4b5d0f13085c975e10c0e6c4c8e5fbc3:/src/tools.c diff --git a/src/tools.c b/src/tools.c index b1e7b62..a46ed50 100644 --- a/src/tools.c +++ b/src/tools.c @@ -470,6 +470,21 @@ is_gline(const char *text) return !*text; } +int +is_shun(const char *text) +{ + if (*text == '@') + return 0; + text += strcspn(text, "@!% \t\r\n"); + if (*text++ != '@') + return 0; + if (!*text) + return 0; + while (*text && (isalnum((char)*text) || strchr(".-?*:", *text))) + text++; + return !*text; +} + int split_ircmask(char *text, char **nick, char **ident, char **host) { @@ -967,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