1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
10 #ifndef __OS_INTERNAL_H
11 #define __OS_INTERNAL_H
13 /* Prototype for the _OsMatch */
14 int _OS_Match(const char *pattern, const char *str, size_t str_len, size_t size) __attribute__((nonnull));
15 int _os_strncmp(const char *pattern, const char *str, size_t str_len, size_t size) __attribute__((nonnull));
16 int _os_strcmp_last(const char *pattern, const char *str, size_t str_len, size_t size) __attribute__((nonnull));
17 int _os_strcmp(const char *pattern, const char *str, size_t str_len, size_t size) __attribute__((nonnull));
18 int _os_strmatch(const char *pattern, const char *str, size_t str_len, size_t size) __attribute__((nonnull));
20 #define BACKSLASH '\\'
23 #define BEGINREGEX '^'
32 #define BEGIN_SET 0000200
33 #define END_SET 0000400
36 typedef unsigned char uchar;
38 /* _IsD Returns 1 if it is a number */
39 #define _IsD(x) ((x >= 48) && (x <= 57))
45 #define _IsW(x) ((x >= 48 && x <= 57 )|| \
46 (x >= 65 && x <= 90 )|| \
47 (x >= 97 && x <= 122))
49 /* Is it a ' ' (blank)
53 #define _IsS(x) (x == 32)
55 /* Check for parenthesis */
56 #define prts(x) (x == '(')
59 * Returns 1 on success
61 #define isPlus(x) ((x == '+') || (x == '*'))
66 /* Is "y" a valid "x"?.
67 * Returns 1 on success
69 #define Regex(x,y) (regexmap[x][y] == TRUECHAR)
70 #define Regex2(x,y) (x == 'd' && y >= 48 && y <= 57)|| \
71 (x == 's' && y == 32)|| \
73 ((y >= 40 && y <= 46)|| \
74 (y >= 58 && y <= 63)))|| \
77 (y >= 48 && y <= 57)|| \
78 (y >= 65 && y <= 90)|| \
79 (y >= 97 && y <= 122)))|| \
81 ((x == '\\') && (y == '\\'))|| \
82 ((x == 'n') && (y == '\n'))|| \
83 (x == 'S' && y != 32)|| \
84 (x == 'D' && (y < 48 || y > 57))|| \
85 (x == 'W' && (y < 48 || y > 122 || \
86 (y > 57 && y <65)||(y > 90 && y< 97)))
88 /* Charmap for case insensitive search */
89 extern const uchar charmap[256];
109 extern const uchar regexmap[][256];
111 #endif /* __OS_INTERNAL_H */