diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/bbs/string.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/common/bbs/string.c b/common/bbs/string.c index 60b03b37..22c93abb 100644 --- a/common/bbs/string.c +++ b/common/bbs/string.c @@ -1,6 +1,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <assert.h> +#include <ctype.h> #include "cmbbs.h" void obfuscate_ipstr(char *s) @@ -12,3 +14,30 @@ void obfuscate_ipstr(char *s) *s++ = '*'; *s = 0; } + +bool +is_valid_brdname(const char *brdname) +{ + int i; + char ch; + int len; + + assert(brdname); + + len = strlen(brdname); + if (len < 2 || len > IDLEN) + return false; + + for (i = 0; i < len; i++) { + char ch = brdname[i]; + if (i == 0) { + if (!isalpha((int)ch)) + return false; + } else { + if (!isalnum(ch) && ch != '_' && ch != '-' && ch != '.') + return false; + } + } + return true; +} + |