Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=0785abf27ffe87fb444a49eb8aa901999c4f6771
commit 0785abf27ffe87fb444a49eb8aa901999c4f6771 Author: James Buren <[email protected]> Date: Wed Dec 5 06:09:47 2012 -0600 add utility function for determining if a string is pure ASCII diff --git a/src/local.h b/src/local.h index e1b52f0..99cf491 100644 --- a/src/local.h +++ b/src/local.h @@ -74,6 +74,7 @@ struct module }; extern bool isrootpath(const char *path); +extern bool isasciistring(const char *s); extern bool mkdir_recurse(const char *path); extern bool size_to_string(char *s,size_t n,long long size,bool pad); extern int get_text_length(const char *s); diff --git a/src/utility.c b/src/utility.c index 5c152ab..28ebde6 100644 --- a/src/utility.c +++ b/src/utility.c @@ -25,6 +25,32 @@ extern bool isrootpath(const char *path) return match; } +extern bool isasciistring(const char *s) +{ + const unsigned char *p = (unsigned char *) s; + bool ascii = true; + + if(s == 0) + { + errno = EINVAL; + error(strerror(errno)); + return false; + } + + while(*p != 0) + { + if(*p > 0x7F) + { + ascii = false; + break; + } + + ++p; + } + + return ascii; +} + extern bool mkdir_recurse(const char *path) { char buf[PATH_MAX] = {0}; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
