static int web_key_check_img(struct web *opt) { const char *__function_name = "web_key_check_img"; char *content_type = NULL; char *curl_err_str = NULL; int curl_err; if (opt->required_response == WEB_CHECK_IMG_DEF_RESP) { if ((curl_err = curl_easy_getinfo(opt->curl->handler, CURLINFO_CONTENT_TYPE, &content_type))) { curl_err_str = zbx_strdup(curl_err_str, curl_easy_strerror(curl_err)); zabbix_log(LOG_LEVEL_ERR, "%s(): Error during curl_easy_getinfo: %s for key %s", __function_name, curl_err_str, opt->item->key); opt->result = (zbx_uint64_t) WEB_ERR_CURL; goto failed; } if (!zbx_strcasestr(content_type, WEB_CHECK_IMG_MATCH_CTYPE)) { zabbix_log(LOG_LEVEL_WARNING, "%s(): Required content type %s not found for key %s", __function_name, WEB_CHECK_IMG_MATCH_CTYPE, opt->item->key); opt->result = (zbx_uint64_t) WEB_ERR_CONTENT_TYPE; goto failed; } } return SUCCEED; failed: zbx_free(curl_err_str); return FAIL; }
/********************************************************************************** * * * Function: regexp_match_ex_substring * * * * Purpose: Test if the string contains substring with the specified case * * sensitivity option. * * * * Parameters: string - [IN] the string to check * * pattern - [IN] the substring to search * * case_sensitive - [IN] ZBX_IGNORE_CASE - case insensitive search * * ZBX_CASE_SENSITIVE - case sensitive search * * * * Return value: SUCCEED - string contains the specified substring * * FAIL - string does not contain the specified substring * * * **********************************************************************************/ static int regexp_match_ex_substring(const char *string, const char *pattern, int case_sensitive) { char *ptr = NULL; switch (case_sensitive) { case ZBX_CASE_SENSITIVE: ptr = strstr(string, pattern); break; case ZBX_IGNORE_CASE: ptr = zbx_strcasestr(string, pattern); break; } return NULL != ptr ? SUCCEED : FAIL; }