From 9c8bc93a8babf7f1316d7758b8cd73f28e794f9a Mon Sep 17 00:00:00 2001 From: Ralph Corderoy Date: Sun, 3 Sep 2017 23:29:36 +0100 Subject: [PATCH] Replace boolean with bool everywhere. boolean's comment said it existed to ensure storage was a char and not an int so it could be packed in a struct, but the only struct using it doesn't care about the space taken. --- h/crawl_folders.h | 2 +- h/mh.h | 1 - h/oauth.h | 10 +++++----- sbr/oauth.c | 46 +++++++++++++++++++++++----------------------- sbr/oauth_prof.c | 4 ++-- uip/folder.c | 8 ++++---- uip/new.c | 4 ++-- 7 files changed, 37 insertions(+), 38 deletions(-) diff --git a/h/crawl_folders.h b/h/crawl_folders.h index 7633b2e0..dac08f8b 100644 --- a/h/crawl_folders.h +++ b/h/crawl_folders.h @@ -5,7 +5,7 @@ /* Callbacks return TRUE crawl_folders should crawl the children of `folder'. * Callbacks need not duplicate folder, as crawl_folders does not free it. */ -typedef boolean (crawl_callback_t)(char *folder, void *baton); +typedef bool (crawl_callback_t)(char *folder, void *baton); /* Crawl the folder hierarchy rooted at the relative path `dir'. For each * folder, pass `callback' the folder name (as a path relative to the current diff --git a/h/mh.h b/h/mh.h index 7673d2a8..8823d919 100644 --- a/h/mh.h +++ b/h/mh.h @@ -28,7 +28,6 @@ #ifndef TRUE #define TRUE true #endif -typedef unsigned char boolean; /* not int so we can pack in a structure */ /* If we're using gcc then tell it extra information so it can do more * compile-time checks. */ diff --git a/h/oauth.h b/h/oauth.h index 1ba53149..3d5826d9 100644 --- a/h/oauth.h +++ b/h/oauth.h @@ -130,7 +130,7 @@ mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res, * * On error, return FALSE and set an error in ctx; ctx is always allocated. */ -boolean +bool mh_oauth_new(mh_oauth_ctx **ctx, const char *svc_name); /* @@ -198,13 +198,13 @@ mh_oauth_authorize(const char *code, mh_oauth_ctx *ctx); * * On error, return FALSE and leave cred untouched. */ -boolean +bool mh_oauth_refresh(mh_oauth_cred *cred); /* * Return whether access token is present and not expired at time T. */ -boolean +bool mh_oauth_access_token_valid(time_t t, const mh_oauth_cred *cred) PURE; /* @@ -228,7 +228,7 @@ mh_oauth_cred_fn(const char *svc_name); * * On error, return FALSE. */ -boolean +bool mh_oauth_cred_save(FILE *fp, mh_oauth_cred *cred, const char *user); /* @@ -257,6 +257,6 @@ mh_oauth_sasl_client_response(size_t *res_len, * Retrieve the various entries for the OAuth mechanism */ -boolean +bool mh_oauth_get_service_info(const char *svc_name, mh_oauth_service_info *svcinfo, char *errbuf, size_t errbuflen); diff --git a/sbr/oauth.c b/sbr/oauth.c index 3a8d2918..a792729f 100755 --- a/sbr/oauth.c +++ b/sbr/oauth.c @@ -110,7 +110,7 @@ struct curl_ctx { /* Whether the response was too big; if so, the rest of the output fields * are undefined. */ - boolean too_big; + bool too_big; /* HTTP response code */ long res_code; @@ -125,9 +125,9 @@ struct curl_ctx { char res_body[RESPONSE_BODY_MAX]; }; -static boolean get_json_strings(const char *, size_t, FILE *, ...) ENDNULL; -static boolean make_query_url(char *, size_t, CURL *, const char *, ...) ENDNULL; -static boolean post(struct curl_ctx *, const char *, const char *); +static bool get_json_strings(const char *, size_t, FILE *, ...) ENDNULL; +static bool make_query_url(char *, size_t, CURL *, const char *, ...) ENDNULL; +static bool post(struct curl_ctx *, const char *, const char *); int mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res, @@ -195,7 +195,7 @@ mh_oauth_do_xoauth(const char *user, const char *svc, unsigned char **oauth_res, return OK; } -static boolean +static bool is_json(const char *content_type) { return content_type != NULL @@ -248,7 +248,7 @@ make_user_agent(void) return concat(user_agent, " libcurl/", curl, NULL); } -boolean +bool mh_oauth_new(mh_oauth_ctx **result, const char *svc_name) { mh_oauth_ctx *ctx; @@ -393,11 +393,11 @@ mh_oauth_get_authorize_url(mh_oauth_ctx *ctx) return ctx->buf; } -static boolean +static bool cred_from_response(mh_oauth_cred *cred, const char *content_type, const char *input, size_t input_len) { - boolean result = FALSE; + bool result = FALSE; char *access_token, *expires_in, *refresh_token; const mh_oauth_ctx *ctx = cred->ctx; @@ -456,7 +456,7 @@ cred_from_response(mh_oauth_cred *cred, const char *content_type, return result; } -static boolean +static bool do_access_request(mh_oauth_cred *cred, const char *req_body) { mh_oauth_ctx *ctx = cred->ctx; @@ -515,10 +515,10 @@ mh_oauth_authorize(const char *code, mh_oauth_ctx *ctx) return result; } -boolean +bool mh_oauth_refresh(mh_oauth_cred *cred) { - boolean result; + bool result; mh_oauth_ctx *ctx = cred->ctx; if (cred->refresh_token == NULL) { @@ -546,7 +546,7 @@ mh_oauth_refresh(mh_oauth_cred *cred) return result; } -boolean +bool mh_oauth_access_token_valid(time_t t, const mh_oauth_cred *cred) { return cred->access_token != NULL && t + EXPIRY_FUDGE < cred->expires_at; @@ -610,10 +610,10 @@ free_user_creds(struct user_creds *user_creds) free(user_creds); } -static boolean +static bool load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx) { - boolean success = FALSE; + bool success = FALSE; char name[NAMESZ], value_buf[BUFSIZ]; int state; m_getfld_state_t getfld_ctx; @@ -703,7 +703,7 @@ load_creds(struct user_creds **result, FILE *fp, mh_oauth_ctx *ctx) return success; } -static boolean +static bool save_user(FILE *fp, const char *user, const char *access, const char *refresh, long expires_at) { @@ -721,7 +721,7 @@ save_user(FILE *fp, const char *user, const char *access, const char *refresh, return TRUE; } -boolean +bool mh_oauth_cred_save(FILE *fp, mh_oauth_cred *cred, const char *user) { struct user_creds *user_creds; @@ -831,10 +831,10 @@ mh_oauth_sasl_client_response(size_t *res_len, * building the entire URL. Some of URL may already have been written into the * result array in that case. */ -static boolean +static bool make_query_url(char *s, size_t size, CURL *curl, const char *base_url, ...) { - boolean result = FALSE; + bool result = FALSE; size_t len; char *prefix; va_list ap; @@ -930,7 +930,7 @@ write_callback(const char *ptr, size_t size, size_t nmemb, void *userdata) return size; } -static boolean +static bool post(struct curl_ctx *ctx, const char *url, const char *req_body) { CURL *curl = ctx->curl; @@ -997,7 +997,7 @@ post(struct curl_ctx *ctx, const char *url, const char *req_body) * * Even in that case, tokens has been allocated and must be freed. */ -static boolean +static bool parse_json(jsmntok_t **tokens, size_t *tokens_len, const char *input, size_t input_len, FILE *log) { @@ -1043,7 +1043,7 @@ get_json_string(char **val, const char *input, const jsmntok_t *tokens, int skip_tokens = 0; /* whether the current token represents a field name */ /* The next token will be the value. */ - boolean is_key = TRUE; + bool is_key = TRUE; int i; for (i = 1; i <= token_count; i++) { @@ -1106,10 +1106,10 @@ get_json_string(char **val, const char *input, const jsmntok_t *tokens, * * log may be used for debug-logging if not NULL. */ -static boolean +static bool get_json_strings(const char *input, size_t input_len, FILE *log, ...) { - boolean result = FALSE; + bool result = FALSE; jsmntok_t *tokens; size_t tokens_len; va_list ap; diff --git a/sbr/oauth_prof.c b/sbr/oauth_prof.c index ab1338e0..1da1eb3f 100644 --- a/sbr/oauth_prof.c +++ b/sbr/oauth_prof.c @@ -76,7 +76,7 @@ update_svc_field(char **field, const char *base_name, const char *svc) } /* Update all service_info fields that are overridden in profile. */ -static boolean +static bool update_svc(mh_oauth_service_info *svc, const char *svc_name, char *errbuf, size_t errbuflen) { @@ -106,7 +106,7 @@ update_svc(mh_oauth_service_info *svc, const char *svc_name, char *errbuf, return TRUE; } -boolean +bool mh_oauth_get_service_info(const char *svc_name, mh_oauth_service_info *svcinfo, char *errbuf, size_t errbuflen) { diff --git a/uip/folder.c b/uip/folder.c index 8db9e3e6..f21ddcab 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -376,7 +376,7 @@ main (int argc, char **argv) } static int -get_folder_info_body (char *fold, char *msg, boolean *crawl_children) +get_folder_info_body (char *fold, char *msg, bool *crawl_children) { int i, retval = 1; struct msgs *mp = NULL; @@ -440,10 +440,10 @@ get_folder_info_body (char *fold, char *msg, boolean *crawl_children) return retval; } -static boolean +static bool get_folder_info_callback (char *fold, void *baton) { - boolean crawl_children; + bool crawl_children; NMH_UNUSED (baton); get_folder_info_body (fold, NULL, &crawl_children); @@ -454,7 +454,7 @@ get_folder_info_callback (char *fold, void *baton) static int get_folder_info (char *fold, char *msg) { - boolean crawl_children; + bool crawl_children; int retval; retval = get_folder_info_body (fold, msg, &crawl_children); diff --git a/uip/new.c b/uip/new.c index 080f065f..137f2bcb 100644 --- a/uip/new.c +++ b/uip/new.c @@ -76,7 +76,7 @@ count_messages(char *field) } /* Return TRUE if the sequence 'name' is in 'sequences'. */ -static boolean +static bool seq_in_list(char *name, char *sequences[]) { int i; @@ -225,7 +225,7 @@ check_folder(char *folder, size_t len, struct list_state *b) } } -static boolean +static bool crawl_callback(char *folder, void *baton) { check_folder(folder, strlen(folder), baton); -- 2.56.0