diff options
Diffstat (limited to 'src/sp_utils.h')
| -rw-r--r-- | src/sp_utils.h | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/sp_utils.h b/src/sp_utils.h index b5a1691..0e595d8 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h | |||
| @@ -23,16 +23,17 @@ | |||
| 23 | #define SHA256_SIZE 32 | 23 | #define SHA256_SIZE 32 |
| 24 | 24 | ||
| 25 | #define HOOK_FUNCTION(original_name, hook_table, new_function) \ | 25 | #define HOOK_FUNCTION(original_name, hook_table, new_function) \ |
| 26 | hook_function(original_name, SNUFFLEUPAGUS_G(hook_table), new_function) | 26 | hook_function(original_name, SPG(hook_table), new_function) |
| 27 | 27 | ||
| 28 | #define HOOK_FUNCTION_BY_REGEXP(regexp, hook_table, new_function) \ | 28 | #define HOOK_FUNCTION_BY_REGEXP(regexp, hook_table, new_function) \ |
| 29 | hook_regexp(regexp, SNUFFLEUPAGUS_G(hook_table), new_function) | 29 | hook_regexp(regexp, SPG(hook_table), new_function) |
| 30 | 30 | ||
| 31 | #define SP_TYPE_LOG (0) | 31 | #define SP_TYPE_LOG (0) |
| 32 | #define SP_TYPE_DROP (1) | 32 | #define SP_TYPE_DROP (1) |
| 33 | #define SP_TYPE_SIMULATION (2) | 33 | #define SP_TYPE_SIMULATION (2) |
| 34 | 34 | ||
| 35 | #define SP_LOG_DEBUG E_NOTICE | 35 | #define SP_LOG_DEBUG E_NOTICE |
| 36 | #define SP_LOG_INFO E_NOTICE | ||
| 36 | #define SP_LOG_ERROR E_ERROR | 37 | #define SP_LOG_ERROR E_ERROR |
| 37 | #define SP_LOG_WARN E_WARNING | 38 | #define SP_LOG_WARN E_WARNING |
| 38 | 39 | ||
| @@ -57,11 +58,11 @@ | |||
| 57 | #ifdef SP_DEBUG_STDERR | 58 | #ifdef SP_DEBUG_STDERR |
| 58 | extern int sp_debug_stderr; | 59 | extern int sp_debug_stderr; |
| 59 | #define sp_log_debug(fmt, ...) \ | 60 | #define sp_log_debug(fmt, ...) \ |
| 60 | dprintf(sp_debug_stderr, "[snuffleupagus][DEBUG] %s(): " fmt "\n", __FUNCTION__, ##__VA_ARGS__); | 61 | if (sp_debug_stderr > 0) dprintf(sp_debug_stderr, "[snuffleupagus][DEBUG] %s(): " fmt "\n", __FUNCTION__, ##__VA_ARGS__); |
| 61 | #else | 62 | #else |
| 62 | #define sp_log_debug(...) \ | 63 | #define sp_log_debug(fmt, ...) \ |
| 63 | sp_log_msgf("DEBUG", SP_LOG_DEBUG, SP_TYPE_LOG, __VA_ARGS__) | 64 | sp_log_msgf("DEBUG", SP_LOG_DEBUG, SP_TYPE_LOG, "%s(): " fmt, __FUNCTION__, ##__VA_ARGS__) |
| 64 | #endif | 65 | #endif |
| 65 | 66 | ||
| 66 | #else | 67 | #else |
| 67 | #define sp_log_debug(...) | 68 | #define sp_log_debug(...) |
| @@ -70,23 +71,21 @@ extern int sp_debug_stderr; | |||
| 70 | #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") | 71 | #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") |
| 71 | 72 | ||
| 72 | const char *get_ipaddr(void); | 73 | const char *get_ipaddr(void); |
| 73 | void sp_log_msgf(char const *restrict feature, int level, int type, | 74 | void sp_log_msgf(char const *restrict feature, int level, int type, const char *restrict fmt, ...); |
| 74 | const char *restrict fmt, ...); | ||
| 75 | int compute_hash(const char *const restrict filename, char *restrict file_hash); | 75 | int compute_hash(const char *const restrict filename, char *restrict file_hash); |
| 76 | const zend_string *sp_zval_to_zend_string(const zval *); | 76 | const zend_string *sp_zval_to_zend_string(const zval *); |
| 77 | bool sp_match_value(const zend_string *, const zend_string *, const sp_pcre *); | 77 | bool sp_match_value(const zend_string* value, const zend_string* to_match, const sp_regexp* rx); |
| 78 | bool sp_match_array_key(const zval *, const zend_string *, const sp_pcre *); | 78 | bool sp_match_array_key(const zval *, const zend_string *, const sp_regexp *); |
| 79 | bool sp_match_array_value(const zval *, const zend_string *, const sp_pcre *); | 79 | bool sp_match_array_value(const zval *, const zend_string *, const sp_regexp *); |
| 80 | void sp_log_disable(const char *restrict, const char *restrict, | 80 | void sp_log_disable(const char *restrict, const char *restrict, const zend_string *restrict, const sp_disabled_function *); |
| 81 | const zend_string *restrict, const sp_disabled_function *); | 81 | void sp_log_disable_ret(const char *restrict, const zend_string *restrict, const sp_disabled_function *); |
| 82 | void sp_log_disable_ret(const char *restrict, const zend_string *restrict, | ||
| 83 | const sp_disabled_function *); | ||
| 84 | bool hook_function(const char *, HashTable *, zif_handler); | 82 | bool hook_function(const char *, HashTable *, zif_handler); |
| 83 | void unhook_functions(HashTable *ht); | ||
| 85 | int hook_regexp(const sp_pcre *, HashTable *, zif_handler); | 84 | int hook_regexp(const sp_pcre *, HashTable *, zif_handler); |
| 86 | bool check_is_in_eval_whitelist(const zend_string *const function_name); | 85 | bool check_is_in_eval_whitelist(const char* function_name); |
| 87 | int sp_log_request(const zend_string *restrict folder, | 86 | int sp_log_request(const zend_string *restrict folder, const zend_string *restrict text_repr); |
| 88 | const zend_string *restrict text_repr, | 87 | #define sp_zend_string_equals(s1, s2) zend_string_equals((zend_string*)s1, (zend_string*)s2) |
| 89 | char const *const from); | 88 | static inline bool sp_zend_string_equals_str(const zend_string* s1, const char *str, size_t len) { |
| 90 | bool sp_zend_string_equals(const zend_string *s1, const zend_string *s2); | 89 | return (ZSTR_LEN(s1) == len && !memcmp(ZSTR_VAL(s1), str, len)); |
| 91 | 90 | } | |
| 92 | #endif /* SP_UTILS_H */ | 91 | #endif /* SP_UTILS_H */ |
