summaryrefslogtreecommitdiff
path: root/string.h
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-08-19 09:31:22 +0000
committertruelight <truelight@openttd.org>2006-08-19 09:31:22 +0000
commit83d56d6d798a28169f00a4c67323a407037c0b0a (patch)
tree99ae4703fae7e532aba0086cf644ec2230755e2e /string.h
parentee0daa0a4fdbafba224f48d7749ba13b79fa3fdc (diff)
downloadopenttd-83d56d6d798a28169f00a4c67323a407037c0b0a.tar.xz
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
allow certain patterns (like numbers only)
Diffstat (limited to 'string.h')
-rw-r--r--string.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/string.h b/string.h
index 39be2309b..eb928c519 100644
--- a/string.h
+++ b/string.h
@@ -32,16 +32,16 @@ void str_validate(char *str);
/** Convert the given string to lowercase */
void strtolower(char *str);
+typedef enum CharSetFilter { //valid char filtering
+ CS_ALPHANUMERAL, //both numeric and alphabetic
+ CS_NUMERAL, //only numeric ones.
+ CS_ALPHA, //only alphabetic values
+} CharSetFilter;
+
/** Only allow valid ascii-function codes. Filter special codes like BELL and
* so on [we need a special filter here later]
* @param key character to be checked
* @return true or false depending if the character is printable/valid or not */
-static inline bool IsValidAsciiChar(byte key)
-{
- // XXX This filter stops certain crashes, but may be too restrictive.
- return (key >= ' ' && key < 127) || (key >= 160 &&
- key != 0xAA && key != 0xAC && key != 0xAD && key != 0xAF &&
- key != 0xB5 && key != 0xB6 && key != 0xB7 && key != 0xB9);
-}
+bool IsValidAsciiChar(byte key, CharSetFilter afilter);
#endif /* STRING_H */