diff options
Diffstat (limited to 'plugins/t')
0 files changed, 0 insertions, 0 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 284cf4e..c37d45d 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -37,6 +37,7 @@ const char *progname = "check_curl"; | |||
37 | const char *copyright = "2006-2019"; | 37 | const char *copyright = "2006-2019"; |
38 | const char *email = "devel@monitoring-plugins.org"; | 38 | const char *email = "devel@monitoring-plugins.org"; |
39 | 39 | ||
40 | #include <stdbool.h> | ||
40 | #include <ctype.h> | 41 | #include <ctype.h> |
41 | 42 | ||
42 | #include "common.h" | 43 | #include "common.h" |
@@ -131,14 +132,14 @@ regmatch_t pmatch[REGS]; | |||
131 | char regexp[MAX_RE_SIZE]; | 132 | char regexp[MAX_RE_SIZE]; |
132 | int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; | 133 | int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; |
133 | int errcode; | 134 | int errcode; |
134 | int invert_regex = 0; | 135 | bool invert_regex = false; |
135 | 136 | ||
136 | char *server_address = NULL; | 137 | char *server_address = NULL; |
137 | char *host_name = NULL; | 138 | char *host_name = NULL; |
138 | char *server_url = 0; | 139 | char *server_url = 0; |
139 | char server_ip[DEFAULT_BUFFER_SIZE]; | 140 | char server_ip[DEFAULT_BUFFER_SIZE]; |
140 | struct curl_slist *server_ips = NULL; | 141 | struct curl_slist *server_ips = NULL; |
141 | int specify_port = FALSE; | 142 | bool specify_port = false; |
142 | unsigned short server_port = HTTP_PORT; | 143 | unsigned short server_port = HTTP_PORT; |
143 | unsigned short virtual_port = 0; | 144 | unsigned short virtual_port = 0; |
144 | int host_name_length; | 145 | int host_name_length; |
@@ -150,8 +151,8 @@ int days_till_exp_warn, days_till_exp_crit; | |||
150 | thresholds *thlds; | 151 | thresholds *thlds; |
151 | char user_agent[DEFAULT_BUFFER_SIZE]; | 152 | char user_agent[DEFAULT_BUFFER_SIZE]; |
152 | int verbose = 0; | 153 | int verbose = 0; |
153 | int show_extended_perfdata = FALSE; | 154 | bool show_extended_perfdata = false; |
154 | int show_body = FALSE; | 155 | bool show_body = false; |
155 | int min_page_len = 0; | 156 | int min_page_len = 0; |
156 | int max_page_len = 0; | 157 | int max_page_len = 0; |
157 | int redir_depth = 0; | 158 | int redir_depth = 0; |
@@ -160,16 +161,16 @@ char *http_method = NULL; | |||
160 | char *http_post_data = NULL; | 161 | char *http_post_data = NULL; |
161 | char *http_content_type = NULL; | 162 | char *http_content_type = NULL; |
162 | CURL *curl; | 163 | CURL *curl; |
163 | int curl_global_initialized = 0; | 164 | bool curl_global_initialized = false; |
164 | int curl_easy_initialized = 0; | 165 | bool curl_easy_initialized = false; |
165 | struct curl_slist *header_list = NULL; | 166 | struct curl_slist *header_list = NULL; |
166 | int body_buf_initialized = 0; | 167 | bool body_buf_initialized = false; |
167 | curlhelp_write_curlbuf body_buf; | 168 | curlhelp_write_curlbuf body_buf; |
168 | int header_buf_initialized = 0; | 169 | bool header_buf_initialized = false; |
169 | curlhelp_write_curlbuf header_buf; | 170 | curlhelp_write_curlbuf header_buf; |
170 | int status_line_initialized = 0; | 171 | bool status_line_initialized = false; |
171 | curlhelp_statusline status_line; | 172 | curlhelp_statusline status_line; |
172 | int put_buf_initialized = 0; | 173 | bool put_buf_initialized = false; |
173 | curlhelp_read_curlbuf put_buf; | 174 | curlhelp_read_curlbuf put_buf; |
174 | char http_header[DEFAULT_BUFFER_SIZE]; | 175 | char http_header[DEFAULT_BUFFER_SIZE]; |
175 | long code; | 176 | long code; |
@@ -192,14 +193,14 @@ char user_auth[MAX_INPUT_BUFFER] = ""; | |||
192 | char proxy_auth[MAX_INPUT_BUFFER] = ""; | 193 | char proxy_auth[MAX_INPUT_BUFFER] = ""; |
193 | char **http_opt_headers; | 194 | char **http_opt_headers; |
194 | int http_opt_headers_count = 0; | 195 | int http_opt_headers_count = 0; |
195 | int display_html = FALSE; | 196 | bool display_html = false; |
196 | int onredirect = STATE_OK; | 197 | int onredirect = STATE_OK; |
197 | int followmethod = FOLLOW_HTTP_CURL; | 198 | int followmethod = FOLLOW_HTTP_CURL; |
198 | int followsticky = STICKY_NONE; | 199 | int followsticky = STICKY_NONE; |
199 | int use_ssl = FALSE; | 200 | bool use_ssl = false; |
200 | int use_sni = TRUE; | 201 | bool use_sni = true; |
201 | int check_cert = FALSE; | 202 | bool check_cert = false; |
202 | int continue_after_check_cert = FALSE; | 203 | bool continue_after_check_cert = false; |
203 | typedef union { | 204 | typedef union { |
204 | struct curl_slist* to_info; | 205 | struct curl_slist* to_info; |
205 | struct curl_certinfo* to_certinfo; | 206 | struct curl_certinfo* to_certinfo; |
@@ -209,20 +210,20 @@ int ssl_version = CURL_SSLVERSION_DEFAULT; | |||
209 | char *client_cert = NULL; | 210 | char *client_cert = NULL; |
210 | char *client_privkey = NULL; | 211 | char *client_privkey = NULL; |
211 | char *ca_cert = NULL; | 212 | char *ca_cert = NULL; |
212 | int verify_peer_and_host = FALSE; | 213 | bool verify_peer_and_host = false; |
213 | int is_openssl_callback = FALSE; | 214 | bool is_openssl_callback = false; |
214 | #if defined(HAVE_SSL) && defined(USE_OPENSSL) | 215 | #if defined(HAVE_SSL) && defined(USE_OPENSSL) |
215 | X509 *cert = NULL; | 216 | X509 *cert = NULL; |
216 | #endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */ | 217 | #endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */ |
217 | int no_body = FALSE; | 218 | bool no_body = false; |
218 | int maximum_age = -1; | 219 | int maximum_age = -1; |
219 | int address_family = AF_UNSPEC; | 220 | int address_family = AF_UNSPEC; |
220 | curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN; | 221 | curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN; |
221 | int curl_http_version = CURL_HTTP_VERSION_NONE; | 222 | int curl_http_version = CURL_HTTP_VERSION_NONE; |
222 | int automatic_decompression = FALSE; | 223 | bool automatic_decompression = false; |
223 | char *cookie_jar_file = NULL; | 224 | char *cookie_jar_file = NULL; |
224 | 225 | ||
225 | int process_arguments (int, char**); | 226 | bool process_arguments (int, char**); |
226 | void handle_curl_option_return_code (CURLcode res, const char* option); | 227 | void handle_curl_option_return_code (CURLcode res, const char* option); |
227 | int check_http (void); | 228 | int check_http (void); |
228 | void redir (curlhelp_write_curlbuf*); | 229 | void redir (curlhelp_write_curlbuf*); |
@@ -276,10 +277,10 @@ main (int argc, char **argv) | |||
276 | progname, NP_VERSION, VERSION, curl_version()); | 277 | progname, NP_VERSION, VERSION, curl_version()); |
277 | 278 | ||
278 | /* parse arguments */ | 279 | /* parse arguments */ |
279 | if (process_arguments (argc, argv) == ERROR) | 280 | if (process_arguments (argc, argv) == false) |
280 | usage4 (_("Could not parse arguments")); | 281 | usage4 (_("Could not parse arguments")); |
281 | 282 | ||
282 | if (display_html == TRUE) | 283 | if (display_html) |
283 | printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">", | 284 | printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">", |
284 | use_ssl ? "https" : "http", | 285 | use_ssl ? "https" : "http", |
285 | host_name ? host_name : server_address, | 286 | host_name ? host_name : server_address, |
@@ -423,17 +424,17 @@ static void | |||
423 | cleanup (void) | 424 | cleanup (void) |
424 | { | 425 | { |
425 | if (status_line_initialized) curlhelp_free_statusline(&status_line); | 426 | if (status_line_initialized) curlhelp_free_statusline(&status_line); |
426 | status_line_initialized = 0; | 427 | status_line_initialized = false; |
427 | if (curl_easy_initialized) curl_easy_cleanup (curl); | 428 | if (curl_easy_initialized) curl_easy_cleanup (curl); |
428 | curl_easy_initialized = 0; | 429 | curl_easy_initialized = false; |
429 | if (curl_global_initialized) curl_global_cleanup (); | 430 | if (curl_global_initialized) curl_global_cleanup (); |
430 | curl_global_initialized = 0; | 431 | curl_global_initialized = false; |
431 | if (body_buf_initialized) curlhelp_freewritebuffer (&body_buf); | 432 | if (body_buf_initialized) curlhelp_freewritebuffer (&body_buf); |
432 | body_buf_initialized = 0; | 433 | body_buf_initialized = false; |
433 | if (header_buf_initialized) curlhelp_freewritebuffer (&header_buf); | 434 | if (header_buf_initialized) curlhelp_freewritebuffer (&header_buf); |
434 | header_buf_initialized = 0; | 435 | header_buf_initialized = false; |
435 | if (put_buf_initialized) curlhelp_freereadbuffer (&put_buf); | 436 | if (put_buf_initialized) curlhelp_freereadbuffer (&put_buf); |
436 | put_buf_initialized = 0; | 437 | put_buf_initialized = false; |
437 | } | 438 | } |
438 | 439 | ||
439 | int | 440 | int |
@@ -450,18 +451,18 @@ check_http (void) | |||
450 | /* initialize curl */ | 451 | /* initialize curl */ |
451 | if (curl_global_init (CURL_GLOBAL_DEFAULT) != CURLE_OK) | 452 | if (curl_global_init (CURL_GLOBAL_DEFAULT) != CURLE_OK) |
452 | die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_global_init failed\n"); | 453 | die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_global_init failed\n"); |
453 | curl_global_initialized = 1; | 454 | curl_global_initialized = true; |
454 | 455 | ||
455 | if ((curl = curl_easy_init()) == NULL) { | 456 | if ((curl = curl_easy_init()) == NULL) { |
456 | die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_easy_init failed\n"); | 457 | die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_easy_init failed\n"); |
457 | } | 458 | } |
458 | curl_easy_initialized = 1; | 459 | curl_easy_initialized = true; |
459 | 460 | ||
460 | /* register cleanup function to shut down libcurl properly */ | 461 | /* register cleanup function to shut down libcurl properly */ |
461 | atexit (cleanup); | 462 | atexit (cleanup); |
462 | 463 | ||
463 | if (verbose >= 1) | 464 | if (verbose >= 1) |
464 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_VERBOSE, TRUE), "CURLOPT_VERBOSE"); | 465 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_VERBOSE, 1), "CURLOPT_VERBOSE"); |
465 | 466 | ||
466 | /* print everything on stdout like check_http would do */ | 467 | /* print everything on stdout like check_http would do */ |
467 | handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_STDERR, stdout), "CURLOPT_STDERR"); | 468 | handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_STDERR, stdout), "CURLOPT_STDERR"); |
@@ -476,14 +477,14 @@ check_http (void) | |||
476 | /* initialize buffer for body of the answer */ | 477 | /* initialize buffer for body of the answer */ |
477 | if (curlhelp_initwritebuffer(&body_buf) < 0) | 478 | if (curlhelp_initwritebuffer(&body_buf) < 0) |
478 | die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for body\n"); | 479 | die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for body\n"); |
479 | body_buf_initialized = 1; | 480 | body_buf_initialized = true; |
480 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_WRITEFUNCTION"); | 481 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_WRITEFUNCTION"); |
481 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEDATA, (void *)&body_buf), "CURLOPT_WRITEDATA"); | 482 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEDATA, (void *)&body_buf), "CURLOPT_WRITEDATA"); |
482 | 483 | ||
483 | /* initialize buffer for header of the answer */ | 484 | /* initialize buffer for header of the answer */ |
484 | if (curlhelp_initwritebuffer( &header_buf ) < 0) | 485 | if (curlhelp_initwritebuffer( &header_buf ) < 0) |
485 | die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for header\n" ); | 486 | die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for header\n" ); |
486 | header_buf_initialized = 1; | 487 | header_buf_initialized = true; |
487 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_HEADERFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_HEADERFUNCTION"); | 488 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_HEADERFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_HEADERFUNCTION"); |
488 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEHEADER, (void *)&header_buf), "CURLOPT_WRITEHEADER"); | 489 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEHEADER, (void *)&header_buf), "CURLOPT_WRITEHEADER"); |
489 | 490 | ||
@@ -544,7 +545,7 @@ check_http (void) | |||
544 | 545 | ||
545 | /* disable body for HEAD request */ | 546 | /* disable body for HEAD request */ |
546 | if (http_method && !strcmp (http_method, "HEAD" )) { | 547 | if (http_method && !strcmp (http_method, "HEAD" )) { |
547 | no_body = TRUE; | 548 | no_body = true; |
548 | } | 549 | } |
549 | 550 | ||
550 | /* set HTTP protocol version */ | 551 | /* set HTTP protocol version */ |
@@ -641,7 +642,7 @@ check_http (void) | |||
641 | #ifdef USE_OPENSSL | 642 | #ifdef USE_OPENSSL |
642 | /* libcurl and monitoring plugins built with OpenSSL, good */ | 643 | /* libcurl and monitoring plugins built with OpenSSL, good */ |
643 | handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION"); | 644 | handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION"); |
644 | is_openssl_callback = TRUE; | 645 | is_openssl_callback = true; |
645 | #else /* USE_OPENSSL */ | 646 | #else /* USE_OPENSSL */ |
646 | #endif /* USE_OPENSSL */ | 647 | #endif /* USE_OPENSSL */ |
647 | /* libcurl is built with OpenSSL, monitoring plugins, so falling | 648 | /* libcurl is built with OpenSSL, monitoring plugins, so falling |
@@ -770,7 +771,7 @@ check_http (void) | |||
770 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READFUNCTION, (curl_read_callback)curlhelp_buffer_read_callback), "CURLOPT_READFUNCTION"); | 771 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READFUNCTION, (curl_read_callback)curlhelp_buffer_read_callback), "CURLOPT_READFUNCTION"); |
771 | if (curlhelp_initreadbuffer (&put_buf, http_post_data, strlen (http_post_data)) < 0) | 772 | if (curlhelp_initreadbuffer (&put_buf, http_post_data, strlen (http_post_data)) < 0) |
772 | die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating read buffer for PUT\n"); | 773 | die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating read buffer for PUT\n"); |
773 | put_buf_initialized = 1; | 774 | put_buf_initialized = true; |
774 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READDATA, (void *)&put_buf), "CURLOPT_READDATA"); | 775 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READDATA, (void *)&put_buf), "CURLOPT_READDATA"); |
775 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_INFILESIZE, (curl_off_t)strlen (http_post_data)), "CURLOPT_INFILESIZE"); | 776 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_INFILESIZE, (curl_off_t)strlen (http_post_data)), "CURLOPT_INFILESIZE"); |
776 | } | 777 | } |
@@ -801,15 +802,15 @@ check_http (void) | |||
801 | 802 | ||
802 | /* certificate checks */ | 803 | /* certificate checks */ |
803 | #ifdef LIBCURL_FEATURE_SSL | 804 | #ifdef LIBCURL_FEATURE_SSL |
804 | if (use_ssl == TRUE) { | 805 | if (use_ssl) { |
805 | if (check_cert == TRUE) { | 806 | if (check_cert) { |
806 | if (is_openssl_callback) { | 807 | if (is_openssl_callback) { |
807 | #ifdef USE_OPENSSL | 808 | #ifdef USE_OPENSSL |
808 | /* check certificate with OpenSSL functions, curl has been built against OpenSSL | 809 | /* check certificate with OpenSSL functions, curl has been built against OpenSSL |
809 | * and we actually have OpenSSL in the monitoring tools | 810 | * and we actually have OpenSSL in the monitoring tools |
810 | */ | 811 | */ |
811 | result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); | 812 | result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); |
812 | if (continue_after_check_cert == FALSE) { | 813 | if (!continue_after_check_cert) { |
813 | return result; | 814 | return result; |
814 | } | 815 | } |
815 | #else /* USE_OPENSSL */ | 816 | #else /* USE_OPENSSL */ |
@@ -851,7 +852,7 @@ GOT_FIRST_CERT: | |||
851 | } | 852 | } |
852 | BIO_free (cert_BIO); | 853 | BIO_free (cert_BIO); |
853 | result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); | 854 | result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); |
854 | if (continue_after_check_cert == FALSE) { | 855 | if (!continue_after_check_cert) { |
855 | return result; | 856 | return result; |
856 | } | 857 | } |
857 | #else /* USE_OPENSSL */ | 858 | #else /* USE_OPENSSL */ |
@@ -859,7 +860,7 @@ GOT_FIRST_CERT: | |||
859 | * so we use the libcurl CURLINFO data | 860 | * so we use the libcurl CURLINFO data |
860 | */ | 861 | */ |
861 | result = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit); | 862 | result = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit); |
862 | if (continue_after_check_cert == FALSE) { | 863 | if (!continue_after_check_cert) { |
863 | return result; | 864 | return result; |
864 | } | 865 | } |
865 | #endif /* USE_OPENSSL */ | 866 | #endif /* USE_OPENSSL */ |
@@ -887,7 +888,7 @@ GOT_FIRST_CERT: | |||
887 | perfd_time(total_time), | 888 | perfd_time(total_time), |
888 | perfd_size(page_len), | 889 | perfd_size(page_len), |
889 | perfd_time_connect(time_connect), | 890 | perfd_time_connect(time_connect), |
890 | use_ssl == TRUE ? perfd_time_ssl (time_appconnect-time_connect) : "", | 891 | use_ssl ? perfd_time_ssl (time_appconnect-time_connect) : "", |
891 | perfd_time_headers(time_headers - time_appconnect), | 892 | perfd_time_headers(time_headers - time_appconnect), |
892 | perfd_time_firstbyte(time_firstbyte - time_headers), | 893 | perfd_time_firstbyte(time_firstbyte - time_headers), |
893 | perfd_time_transfer(total_time-time_firstbyte) | 894 | perfd_time_transfer(total_time-time_firstbyte) |
@@ -910,7 +911,7 @@ GOT_FIRST_CERT: | |||
910 | /* we cannot know the major/minor version here for sure as we cannot parse the first line */ | 911 | /* we cannot know the major/minor version here for sure as we cannot parse the first line */ |
911 | die (STATE_CRITICAL, "HTTP CRITICAL HTTP/x.x %ld unknown - %s", code, msg); | 912 | die (STATE_CRITICAL, "HTTP CRITICAL HTTP/x.x %ld unknown - %s", code, msg); |
912 | } | 913 | } |
913 | status_line_initialized = 1; | 914 | status_line_initialized = true; |
914 | 915 | ||
915 | /* get result code from cURL */ | 916 | /* get result code from cURL */ |
916 | handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &code), "CURLINFO_RESPONSE_CODE"); | 917 | handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &code), "CURLINFO_RESPONSE_CODE"); |
@@ -1023,12 +1024,12 @@ GOT_FIRST_CERT: | |||
1023 | 1024 | ||
1024 | if (strlen (regexp)) { | 1025 | if (strlen (regexp)) { |
1025 | errcode = regexec (&preg, body_buf.buf, REGS, pmatch, 0); | 1026 | errcode = regexec (&preg, body_buf.buf, REGS, pmatch, 0); |
1026 | if ((errcode == 0 && invert_regex == 0) || (errcode == REG_NOMATCH && invert_regex == 1)) { | 1027 | if ((errcode == 0 && !invert_regex) || (errcode == REG_NOMATCH && invert_regex)) { |
1027 | /* OK - No-op to avoid changing the logic around it */ | 1028 | /* OK - No-op to avoid changing the logic around it */ |
1028 | result = max_state_alt(STATE_OK, result); | 1029 | result = max_state_alt(STATE_OK, result); |
1029 | } | 1030 | } |
1030 | else if ((errcode == REG_NOMATCH && invert_regex == 0) || (errcode == 0 && invert_regex == 1)) { | 1031 | else if ((errcode == REG_NOMATCH && !invert_regex) || (errcode == 0 && invert_regex)) { |
1031 | if (invert_regex == 0) | 1032 | if (!invert_regex) |
1032 | snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg); | 1033 | snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg); |
1033 | else | 1034 | else |
1034 | snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg); | 1035 | snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg); |
@@ -1167,7 +1168,10 @@ redir (curlhelp_write_curlbuf* header_buf) | |||
1167 | } | 1168 | } |
1168 | } | 1169 | } |
1169 | 1170 | ||
1170 | use_ssl = !uri_strcmp (uri.scheme, "https"); | 1171 | if (!uri_strcmp (uri.scheme, "https")) |
1172 | use_ssl = true; | ||
1173 | else | ||
1174 | use_ssl = false; | ||
1171 | 1175 | ||
1172 | /* we do a sloppy test here only, because uriparser would have failed | 1176 | /* we do a sloppy test here only, because uriparser would have failed |
1173 | * above, if the port would be invalid, we just check for MAX_PORT | 1177 | * above, if the port would be invalid, we just check for MAX_PORT |
@@ -1255,7 +1259,7 @@ test_file (char *path) | |||
1255 | usage2 (_("file does not exist or is not readable"), path); | 1259 | usage2 (_("file does not exist or is not readable"), path); |
1256 | } | 1260 | } |
1257 | 1261 | ||
1258 | int | 1262 | bool |
1259 | process_arguments (int argc, char **argv) | 1263 | process_arguments (int argc, char **argv) |
1260 | { | 1264 | { |
1261 | char *p; | 1265 | char *p; |
@@ -1321,7 +1325,7 @@ process_arguments (int argc, char **argv) | |||
1321 | }; | 1325 | }; |
1322 | 1326 | ||
1323 | if (argc < 2) | 1327 | if (argc < 2) |
1324 | return ERROR; | 1328 | return false; |
1325 | 1329 | ||
1326 | /* support check_http compatible arguments */ | 1330 | /* support check_http compatible arguments */ |
1327 | for (c = 1; c < argc; c++) { | 1331 | for (c = 1; c < argc; c++) { |
@@ -1401,7 +1405,7 @@ process_arguments (int argc, char **argv) | |||
1401 | if( strtol(optarg, NULL, 10) > MAX_PORT) | 1405 | if( strtol(optarg, NULL, 10) > MAX_PORT) |
1402 | usage2 (_("Invalid port number, supplied port number is too big"), optarg); | 1406 | usage2 (_("Invalid port number, supplied port number is too big"), optarg); |
1403 | server_port = (unsigned short)strtol(optarg, NULL, 10); | 1407 | server_port = (unsigned short)strtol(optarg, NULL, 10); |
1404 | specify_port = TRUE; | 1408 | specify_port = true; |
1405 | } | 1409 | } |
1406 | break; | 1410 | break; |
1407 | case 'a': /* authorization info */ | 1411 | case 'a': /* authorization info */ |
@@ -1435,10 +1439,10 @@ process_arguments (int argc, char **argv) | |||
1435 | http_opt_headers[http_opt_headers_count - 1] = optarg; | 1439 | http_opt_headers[http_opt_headers_count - 1] = optarg; |
1436 | break; | 1440 | break; |
1437 | case 'L': /* show html link */ | 1441 | case 'L': /* show html link */ |
1438 | display_html = TRUE; | 1442 | display_html = true; |
1439 | break; | 1443 | break; |
1440 | case 'n': /* do not show html link */ | 1444 | case 'n': /* do not show html link */ |
1441 | display_html = FALSE; | 1445 | display_html = false; |
1442 | break; | 1446 | break; |
1443 | case 'C': /* Check SSL cert validity */ | 1447 | case 'C': /* Check SSL cert validity */ |
1444 | #ifdef LIBCURL_FEATURE_SSL | 1448 | #ifdef LIBCURL_FEATURE_SSL |
@@ -1459,12 +1463,12 @@ process_arguments (int argc, char **argv) | |||
1459 | usage2 (_("Invalid certificate expiration period"), optarg); | 1463 | usage2 (_("Invalid certificate expiration period"), optarg); |
1460 | days_till_exp_warn = atoi (optarg); | 1464 | days_till_exp_warn = atoi (optarg); |
1461 | } | 1465 | } |
1462 | check_cert = TRUE; | 1466 | check_cert = true; |
1463 | goto enable_ssl; | 1467 | goto enable_ssl; |
1464 | #endif | 1468 | #endif |
1465 | case CONTINUE_AFTER_CHECK_CERT: /* don't stop after the certificate is checked */ | 1469 | case CONTINUE_AFTER_CHECK_CERT: /* don't stop after the certificate is checked */ |
1466 | #ifdef HAVE_SSL | 1470 | #ifdef HAVE_SSL |
1467 | continue_after_check_cert = TRUE; | 1471 | continue_after_check_cert = true; |
1468 | break; | 1472 | break; |
1469 | #endif | 1473 | #endif |
1470 | case 'J': /* use client certificate */ | 1474 | case 'J': /* use client certificate */ |
@@ -1487,13 +1491,13 @@ process_arguments (int argc, char **argv) | |||
1487 | #endif | 1491 | #endif |
1488 | #ifdef LIBCURL_FEATURE_SSL | 1492 | #ifdef LIBCURL_FEATURE_SSL |
1489 | case 'D': /* verify peer certificate & host */ | 1493 | case 'D': /* verify peer certificate & host */ |
1490 | verify_peer_and_host = TRUE; | 1494 | verify_peer_and_host = true; |
1491 | break; | 1495 | break; |
1492 | #endif | 1496 | #endif |
1493 | case 'S': /* use SSL */ | 1497 | case 'S': /* use SSL */ |
1494 | #ifdef LIBCURL_FEATURE_SSL | 1498 | #ifdef LIBCURL_FEATURE_SSL |
1495 | enable_ssl: | 1499 | enable_ssl: |
1496 | use_ssl = TRUE; | 1500 | use_ssl = true; |
1497 | /* ssl_version initialized to CURL_SSLVERSION_DEFAULT as a default. | 1501 | /* ssl_version initialized to CURL_SSLVERSION_DEFAULT as a default. |
1498 | * Only set if it's non-zero. This helps when we include multiple | 1502 | * Only set if it's non-zero. This helps when we include multiple |
1499 | * parameters, like -S and -C combinations */ | 1503 | * parameters, like -S and -C combinations */ |
@@ -1567,15 +1571,15 @@ process_arguments (int argc, char **argv) | |||
1567 | #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0) */ | 1571 | #endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0) */ |
1568 | if (verbose >= 2) | 1572 | if (verbose >= 2) |
1569 | printf(_("* Set SSL/TLS version to %d\n"), ssl_version); | 1573 | printf(_("* Set SSL/TLS version to %d\n"), ssl_version); |
1570 | if (specify_port == FALSE) | 1574 | if (!specify_port) |
1571 | server_port = HTTPS_PORT; | 1575 | server_port = HTTPS_PORT; |
1572 | break; | 1576 | break; |
1573 | #else /* LIBCURL_FEATURE_SSL */ | 1577 | #else /* LIBCURL_FEATURE_SSL */ |
1574 | /* -C -J and -K fall through to here without SSL */ | 1578 | /* -C -J and -K fall through to here without SSL */ |
1575 | usage4 (_("Invalid option - SSL is not available")); | 1579 | usage4 (_("Invalid option - SSL is not available")); |
1576 | break; | 1580 | break; |
1577 | case SNI_OPTION: /* --sni is parsed, but ignored, the default is TRUE with libcurl */ | 1581 | case SNI_OPTION: /* --sni is parsed, but ignored, the default is true with libcurl */ |
1578 | use_sni = TRUE; | 1582 | use_sni = true; |
1579 | break; | 1583 | break; |
1580 | #endif /* LIBCURL_FEATURE_SSL */ | 1584 | #endif /* LIBCURL_FEATURE_SSL */ |
1581 | case MAX_REDIRS_OPTION: | 1585 | case MAX_REDIRS_OPTION: |
@@ -1636,11 +1640,11 @@ process_arguments (int argc, char **argv) | |||
1636 | if (errcode != 0) { | 1640 | if (errcode != 0) { |
1637 | (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); | 1641 | (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); |
1638 | printf (_("Could Not Compile Regular Expression: %s"), errbuf); | 1642 | printf (_("Could Not Compile Regular Expression: %s"), errbuf); |
1639 | return ERROR; | 1643 | return false; |
1640 | } | 1644 | } |
1641 | break; | 1645 | break; |
1642 | case INVERT_REGEX: | 1646 | case INVERT_REGEX: |
1643 | invert_regex = 1; | 1647 | invert_regex = true; |
1644 | break; | 1648 | break; |
1645 | case '4': | 1649 | case '4': |
1646 | address_family = AF_INET; | 1650 | address_family = AF_INET; |
@@ -1675,7 +1679,7 @@ process_arguments (int argc, char **argv) | |||
1675 | break; | 1679 | break; |
1676 | } | 1680 | } |
1677 | case 'N': /* no-body */ | 1681 | case 'N': /* no-body */ |
1678 | no_body = TRUE; | 1682 | no_body = true; |
1679 | break; | 1683 | break; |
1680 | case 'M': /* max-age */ | 1684 | case 'M': /* max-age */ |
1681 | { | 1685 | { |
@@ -1698,10 +1702,10 @@ process_arguments (int argc, char **argv) | |||
1698 | } | 1702 | } |
1699 | break; | 1703 | break; |
1700 | case 'E': /* show extended perfdata */ | 1704 | case 'E': /* show extended perfdata */ |
1701 | show_extended_perfdata = TRUE; | 1705 | show_extended_perfdata = true; |
1702 | break; | 1706 | break; |
1703 | case 'B': /* print body content after status line */ | 1707 | case 'B': /* print body content after status line */ |
1704 | show_body = TRUE; | 1708 | show_body = true; |
1705 | break; | 1709 | break; |
1706 | case HTTP_VERSION_OPTION: | 1710 | case HTTP_VERSION_OPTION: |
1707 | curl_http_version = CURL_HTTP_VERSION_NONE; | 1711 | curl_http_version = CURL_HTTP_VERSION_NONE; |
@@ -1721,7 +1725,7 @@ process_arguments (int argc, char **argv) | |||
1721 | } | 1725 | } |
1722 | break; | 1726 | break; |
1723 | case AUTOMATIC_DECOMPRESSION: | 1727 | case AUTOMATIC_DECOMPRESSION: |
1724 | automatic_decompression = TRUE; | 1728 | automatic_decompression = true; |
1725 | break; | 1729 | break; |
1726 | case COOKIE_JAR: | 1730 | case COOKIE_JAR: |
1727 | cookie_jar_file = optarg; | 1731 | cookie_jar_file = optarg; |
@@ -1765,52 +1769,52 @@ process_arguments (int argc, char **argv) | |||
1765 | virtual_port = server_port; | 1769 | virtual_port = server_port; |
1766 | else { | 1770 | else { |
1767 | if ((use_ssl && server_port == HTTPS_PORT) || (!use_ssl && server_port == HTTP_PORT)) | 1771 | if ((use_ssl && server_port == HTTPS_PORT) || (!use_ssl && server_port == HTTP_PORT)) |
1768 | if(specify_port == FALSE) | 1772 | if(!specify_port) |
1769 | server_port = virtual_port; | 1773 | server_port = virtual_port; |
1770 | } | 1774 | } |
1771 | 1775 | ||
1772 | return TRUE; | 1776 | return true; |
1773 | } | 1777 | } |
1774 | 1778 | ||
1775 | char *perfd_time (double elapsed_time) | 1779 | char *perfd_time (double elapsed_time) |
1776 | { | 1780 | { |
1777 | return fperfdata ("time", elapsed_time, "s", | 1781 | return fperfdata ("time", elapsed_time, "s", |
1778 | thlds->warning?TRUE:FALSE, thlds->warning?thlds->warning->end:0, | 1782 | thlds->warning?true:false, thlds->warning?thlds->warning->end:0, |
1779 | thlds->critical?TRUE:FALSE, thlds->critical?thlds->critical->end:0, | 1783 | thlds->critical?true:false, thlds->critical?thlds->critical->end:0, |
1780 | TRUE, 0, TRUE, socket_timeout); | 1784 | true, 0, true, socket_timeout); |
1781 | } | 1785 | } |
1782 | 1786 | ||
1783 | char *perfd_time_connect (double elapsed_time_connect) | 1787 | char *perfd_time_connect (double elapsed_time_connect) |
1784 | { | 1788 | { |
1785 | return fperfdata ("time_connect", elapsed_time_connect, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | 1789 | return fperfdata ("time_connect", elapsed_time_connect, "s", false, 0, false, 0, false, 0, true, socket_timeout); |
1786 | } | 1790 | } |
1787 | 1791 | ||
1788 | char *perfd_time_ssl (double elapsed_time_ssl) | 1792 | char *perfd_time_ssl (double elapsed_time_ssl) |
1789 | { | 1793 | { |
1790 | return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | 1794 | return fperfdata ("time_ssl", elapsed_time_ssl, "s", false, 0, false, 0, false, 0, true, socket_timeout); |
1791 | } | 1795 | } |
1792 | 1796 | ||
1793 | char *perfd_time_headers (double elapsed_time_headers) | 1797 | char *perfd_time_headers (double elapsed_time_headers) |
1794 | { | 1798 | { |
1795 | return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | 1799 | return fperfdata ("time_headers", elapsed_time_headers, "s", false, 0, false, 0, false, 0, true, socket_timeout); |
1796 | } | 1800 | } |
1797 | 1801 | ||
1798 | char *perfd_time_firstbyte (double elapsed_time_firstbyte) | 1802 | char *perfd_time_firstbyte (double elapsed_time_firstbyte) |
1799 | { | 1803 | { |
1800 | return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | 1804 | return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", false, 0, false, 0, false, 0, true, socket_timeout); |
1801 | } | 1805 | } |
1802 | 1806 | ||
1803 | char *perfd_time_transfer (double elapsed_time_transfer) | 1807 | char *perfd_time_transfer (double elapsed_time_transfer) |
1804 | { | 1808 | { |
1805 | return fperfdata ("time_transfer", elapsed_time_transfer, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); | 1809 | return fperfdata ("time_transfer", elapsed_time_transfer, "s", false, 0, false, 0, false, 0, true, socket_timeout); |
1806 | } | 1810 | } |
1807 | 1811 | ||
1808 | char *perfd_size (int page_len) | 1812 | char *perfd_size (int page_len) |
1809 | { | 1813 | { |
1810 | return perfdata ("size", page_len, "B", | 1814 | return perfdata ("size", page_len, "B", |
1811 | (min_page_len>0?TRUE:FALSE), min_page_len, | 1815 | (min_page_len>0?true:false), min_page_len, |
1812 | (min_page_len>0?TRUE:FALSE), 0, | 1816 | (min_page_len>0?true:false), 0, |
1813 | TRUE, 0, FALSE, 0); | 1817 | true, 0, false, 0); |
1814 | } | 1818 | } |
1815 | 1819 | ||
1816 | void | 1820 | void |