From: Richard Russon Date: Thu, 27 Sep 2018 19:20:20 +0000 (+0100) Subject: rename header_cache_t vars X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7025a661b81fbe25cb21c0d220f7a75c5c1aad3c;p=neomutt rename header_cache_t vars --- diff --git a/hcache/hcache.c b/hcache/hcache.c index ddac47334..44d1360f3 100644 --- a/hcache/hcache.c +++ b/hcache/hcache.c @@ -258,7 +258,7 @@ header_cache_t *mutt_hcache_open(const char *path, const char *folder, hcache_na if (!ops) return NULL; - header_cache_t *h = mutt_mem_calloc(1, sizeof(header_cache_t)); + header_cache_t *hc = mutt_mem_calloc(1, sizeof(header_cache_t)); /* Calculate the current hcache version from dynamic configuration */ if (hcachever == 0x0) @@ -296,32 +296,32 @@ header_cache_t *mutt_hcache_open(const char *path, const char *folder, hcache_na hcachever = digest.intval; } - h->folder = get_foldername(folder); - h->crc = hcachever; + hc->folder = get_foldername(folder); + hc->crc = hcachever; if (!path || path[0] == '\0') { - FREE(&h->folder); - FREE(&h); + FREE(&hc->folder); + FREE(&hc); return NULL; } - path = hcache_per_folder(path, h->folder, namer); + path = hcache_per_folder(path, hc->folder, namer); - h->ctx = ops->open(path); - if (h->ctx) - return h; + hc->ctx = ops->open(path); + if (hc->ctx) + return hc; else { /* remove a possibly incompatible version */ if (unlink(path) == 0) { - h->ctx = ops->open(path); - if (h->ctx) - return h; + hc->ctx = ops->open(path); + if (hc->ctx) + return hc; } - FREE(&h->folder); - FREE(&h); + FREE(&hc->folder); + FREE(&hc); return NULL; } @@ -330,31 +330,31 @@ header_cache_t *mutt_hcache_open(const char *path, const char *folder, hcache_na /** * mutt_hcache_close - Multiplexor for HcacheOps::close */ -void mutt_hcache_close(header_cache_t *h) +void mutt_hcache_close(header_cache_t *hc) { const struct HcacheOps *ops = hcache_get_ops(); - if (!h || !ops) + if (!hc || !ops) return; - ops->close(&h->ctx); - FREE(&h->folder); - FREE(&h); + ops->close(&hc->ctx); + FREE(&hc->folder); + FREE(&hc); } /** * mutt_hcache_fetch - Multiplexor for HcacheOps::fetch */ -void *mutt_hcache_fetch(header_cache_t *h, const char *key, size_t keylen) +void *mutt_hcache_fetch(header_cache_t *hc, const char *key, size_t keylen) { - void *data = mutt_hcache_fetch_raw(h, key, keylen); + void *data = mutt_hcache_fetch_raw(hc, key, keylen); if (!data) { return NULL; } - if (!crc_matches(data, h->crc)) + if (!crc_matches(data, hc->crc)) { - mutt_hcache_free(h, &data); + mutt_hcache_free(hc, &data); return NULL; } @@ -363,51 +363,51 @@ void *mutt_hcache_fetch(header_cache_t *h, const char *key, size_t keylen) /** * mutt_hcache_fetch_raw - Find the data for a key in a database backend - * @param h Header cache handle + * @param hc Header cache handle * @param key A message identification string * @param keylen The length of the string pointed to by key */ -void *mutt_hcache_fetch_raw(header_cache_t *h, const char *key, size_t keylen) +void *mutt_hcache_fetch_raw(header_cache_t *hc, const char *key, size_t keylen) { char path[PATH_MAX]; const struct HcacheOps *ops = hcache_get_ops(); - if (!h || !ops) + if (!hc || !ops) return NULL; - keylen = snprintf(path, sizeof(path), "%s%s", h->folder, key); + keylen = snprintf(path, sizeof(path), "%s%s", hc->folder, key); - return ops->fetch(h->ctx, path, keylen); + return ops->fetch(hc->ctx, path, keylen); } /** * mutt_hcache_free - Multiplexor for HcacheOps::free */ -void mutt_hcache_free(header_cache_t *h, void **data) +void mutt_hcache_free(header_cache_t *hc, void **data) { const struct HcacheOps *ops = hcache_get_ops(); - if (!h || !ops) + if (!hc || !ops) return; - ops->free(h->ctx, data); + ops->free(hc->ctx, data); } /** * mutt_hcache_store - Multiplexor for HcacheOps::store */ -int mutt_hcache_store(header_cache_t *h, const char *key, size_t keylen, +int mutt_hcache_store(header_cache_t *hc, const char *key, size_t keylen, struct Email *e, unsigned int uidvalidity) { char *data = NULL; int dlen; int ret; - if (!h) + if (!hc) return -1; - data = mutt_hcache_dump(h, e, &dlen, uidvalidity); - ret = mutt_hcache_store_raw(h, key, keylen, data, dlen); + data = mutt_hcache_dump(hc, e, &dlen, uidvalidity); + ret = mutt_hcache_store_raw(hc, key, keylen, data, dlen); FREE(&data); @@ -416,7 +416,7 @@ int mutt_hcache_store(header_cache_t *h, const char *key, size_t keylen, /** * mutt_hcache_store_raw - Store some data in a database backend - * @param h Header cache handle + * @param hc Header cache handle * @param key A message identification string * @param keylen The length of the string pointed to by key * @param data Binary blob @@ -424,34 +424,34 @@ int mutt_hcache_store(header_cache_t *h, const char *key, size_t keylen, * @retval 0 Success * @retval num Generic or backend-specific error code otherwise */ -int mutt_hcache_store_raw(header_cache_t *h, const char *key, size_t keylen, +int mutt_hcache_store_raw(header_cache_t *hc, const char *key, size_t keylen, void *data, size_t dlen) { char path[PATH_MAX]; const struct HcacheOps *ops = hcache_get_ops(); - if (!h || !ops) + if (!hc || !ops) return -1; - keylen = snprintf(path, sizeof(path), "%s%s", h->folder, key); + keylen = snprintf(path, sizeof(path), "%s%s", hc->folder, key); - return ops->store(h->ctx, path, keylen, data, dlen); + return ops->store(hc->ctx, path, keylen, data, dlen); } /** * mutt_hcache_delete - Multiplexor for HcacheOps::delete */ -int mutt_hcache_delete(header_cache_t *h, const char *key, size_t keylen) +int mutt_hcache_delete(header_cache_t *hc, const char *key, size_t keylen) { char path[PATH_MAX]; const struct HcacheOps *ops = hcache_get_ops(); - if (!h) + if (!hc) return -1; - keylen = snprintf(path, sizeof(path), "%s%s", h->folder, key); + keylen = snprintf(path, sizeof(path), "%s%s", hc->folder, key); - return ops->delete (h->ctx, path, keylen); + return ops->delete (hc->ctx, path, keylen); } /** diff --git a/hcache/hcache.h b/hcache/hcache.h index 0aefeb4e6..bae0e443c 100644 --- a/hcache/hcache.h +++ b/hcache/hcache.h @@ -104,13 +104,13 @@ header_cache_t *mutt_hcache_open(const char *path, const char *folder, hcache_na /** * mutt_hcache_close - close the connection to the header cache - * @param h Pointer to the header_cache_t structure got by mutt_hcache_open + * @param hc Pointer to the header_cache_t structure got by mutt_hcache_open */ -void mutt_hcache_close(header_cache_t *h); +void mutt_hcache_close(header_cache_t *hc); /** * mutt_hcache_fetch - fetch and validate a message's header from the cache - * @param h Pointer to the header_cache_t structure got by mutt_hcache_open + * @param hc Pointer to the header_cache_t structure got by mutt_hcache_open * @param key Message identification string * @param keylen Length of the string pointed to by key * @retval ptr Succees, data if found and valid @@ -122,11 +122,11 @@ void mutt_hcache_close(header_cache_t *h); * @note The returned pointer must be freed by calling mutt_hcache_free. This * must be done before closing the header cache with mutt_hcache_close. */ -void *mutt_hcache_fetch(header_cache_t *h, const char *key, size_t keylen); +void *mutt_hcache_fetch(header_cache_t *hc, const char *key, size_t keylen); /** * mutt_hcache_fetch_raw - fetch a message's header from the cache - * @param h Pointer to the header_cache_t structure got by mutt_hcache_open + * @param hc Pointer to the header_cache_t structure got by mutt_hcache_open * @param key Message identification string * @param keylen Length of the string pointed to by key * @retval ptr Success, the data if found @@ -137,14 +137,14 @@ void *mutt_hcache_fetch(header_cache_t *h, const char *key, size_t keylen); * @note The returned pointer must be freed by calling mutt_hcache_free. This * must be done before closing the header cache with mutt_hcache_close. */ -void *mutt_hcache_fetch_raw(header_cache_t *h, const char *key, size_t keylen); +void *mutt_hcache_fetch_raw(header_cache_t *hc, const char *key, size_t keylen); /** * mutt_hcache_free - free previously fetched data - * @param h Pointer to the header_cache_t structure got by mutt_hcache_open + * @param hc Pointer to the header_cache_t structure got by mutt_hcache_open * @param data Pointer to the data got using hcache_fetch or hcache_fetch_raw */ -void mutt_hcache_free(header_cache_t *h, void **data); +void mutt_hcache_free(header_cache_t *hc, void **data); /** * mutt_hcache_restore - restore a Header from data retrieved from the cache @@ -158,7 +158,7 @@ struct Email *mutt_hcache_restore(const unsigned char *d); /** * mutt_hcache_store - store a Header along with a validity datum - * @param h Pointer to the header_cache_t structure got by mutt_hcache_open + * @param hc Pointer to the header_cache_t structure got by mutt_hcache_open * @param key Message identification string * @param keylen Length of the string pointed to by key * @param e Email to store @@ -166,12 +166,12 @@ struct Email *mutt_hcache_restore(const unsigned char *d); * @retval 0 Success * @retval num Generic or backend-specific error code otherwise */ -int mutt_hcache_store(header_cache_t *h, const char *key, size_t keylen, +int mutt_hcache_store(header_cache_t *hc, const char *key, size_t keylen, struct Email *e, unsigned int uidvalidity); /** * mutt_hcache_store_raw - store a key / data pair - * @param h Pointer to the header_cache_t structure got by mutt_hcache_open + * @param hc Pointer to the header_cache_t structure got by mutt_hcache_open * @param key Message identification string * @param keylen Length of the string pointed to by key * @param data Payload to associate with key @@ -179,18 +179,18 @@ int mutt_hcache_store(header_cache_t *h, const char *key, size_t keylen, * @retval 0 success * @retval num Generic or backend-specific error code otherwise */ -int mutt_hcache_store_raw(header_cache_t *h, const char *key, size_t keylen, +int mutt_hcache_store_raw(header_cache_t *hc, const char *key, size_t keylen, void *data, size_t dlen); /** * mutt_hcache_delete - delete a key / data pair - * @param h Pointer to the header_cache_t structure got by mutt_hcache_open + * @param hc Pointer to the header_cache_t structure got by mutt_hcache_open * @param key Message identification string * @param keylen Length of the string pointed to by key * @retval 0 Success * @retval num Generic or backend-specific error code otherwise */ -int mutt_hcache_delete(header_cache_t *h, const char *key, size_t keylen); +int mutt_hcache_delete(header_cache_t *hc, const char *key, size_t keylen); /** * mutt_hcache_backend_list - get a list of backend identification strings diff --git a/hcache/serialize.c b/hcache/serialize.c index 2b81f23dd..b12a3a62f 100644 --- a/hcache/serialize.c +++ b/hcache/serialize.c @@ -563,7 +563,7 @@ void serial_restore_envelope(struct Envelope *e, const unsigned char *d, int *of /** * mutt_hcache_dump - Serialise a Header object - * @param h Header cache handle + * @param hc Header cache handle * @param e Email to serialise * @param off Size of the binary blob * @param uidvalidity IMAP server identifier @@ -572,7 +572,7 @@ void serial_restore_envelope(struct Envelope *e, const unsigned char *d, int *of * This function transforms a e into a char so that it is useable by * db_store. */ -void *mutt_hcache_dump(header_cache_t *h, const struct Email *e, int *off, unsigned int uidvalidity) +void *mutt_hcache_dump(header_cache_t *hc, const struct Email *e, int *off, unsigned int uidvalidity) { struct Email nh; bool convert = !CharsetIsUtf8; @@ -590,7 +590,7 @@ void *mutt_hcache_dump(header_cache_t *h, const struct Email *e, int *off, unsig memcpy(d, &uidvalidity, sizeof(uidvalidity)); *off += sizeof(union Validate); - d = serial_dump_int(h->crc, d, off); + d = serial_dump_int(hc->crc, d, off); lazy_realloc(&d, *off + sizeof(struct Email)); memcpy(&nh, e, sizeof(struct Email)); diff --git a/hcache/serialize.h b/hcache/serialize.h index efdb18ece..42e7d4345 100644 --- a/hcache/serialize.h +++ b/hcache/serialize.h @@ -57,7 +57,7 @@ void serial_restore_int(unsigned int *i, const unsigned char *d, int * void serial_restore_parameter(struct ParameterList *p, const unsigned char *d, int *off, bool convert); void serial_restore_stailq(struct ListHead *l, const unsigned char *d, int *off, bool convert); -void * mutt_hcache_dump(header_cache_t *h, const struct Email *e, int *off, unsigned int uidvalidity); +void * mutt_hcache_dump(header_cache_t *hc, const struct Email *e, int *off, unsigned int uidvalidity); struct Email *mutt_hcache_restore(const unsigned char *d); #endif /* MUTT_HCACHE_SERIALIZE_H */