mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-21 10:28:09 +01:00
util: run uncrustify
This is the result of running $ uncrustify --replace --config ../devel/uncrustify.cfg *.c *.h in the util directory
This commit is contained in:
parent
33382c2b5b
commit
1a8916786f
13 changed files with 81 additions and 63 deletions
|
@ -24,7 +24,8 @@
|
||||||
|
|
||||||
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
|
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
|
||||||
|
|
||||||
void _notmuch_crypto_cleanup (unused(_notmuch_crypto_t *crypto))
|
void
|
||||||
|
_notmuch_crypto_cleanup (unused(_notmuch_crypto_t *crypto))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ _notmuch_crypto_decrypt (bool *attempted,
|
||||||
GError **err)
|
GError **err)
|
||||||
{
|
{
|
||||||
GMimeObject *ret = NULL;
|
GMimeObject *ret = NULL;
|
||||||
|
|
||||||
if (decrypt == NOTMUCH_DECRYPT_FALSE)
|
if (decrypt == NOTMUCH_DECRYPT_FALSE)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -78,15 +80,15 @@ _notmuch_crypto_decrypt (bool *attempted,
|
||||||
GMimeDecryptFlags flags = GMIME_DECRYPT_NONE;
|
GMimeDecryptFlags flags = GMIME_DECRYPT_NONE;
|
||||||
if (decrypt == NOTMUCH_DECRYPT_TRUE && decrypt_result)
|
if (decrypt == NOTMUCH_DECRYPT_TRUE && decrypt_result)
|
||||||
flags |= GMIME_DECRYPT_EXPORT_SESSION_KEY;
|
flags |= GMIME_DECRYPT_EXPORT_SESSION_KEY;
|
||||||
ret = g_mime_multipart_encrypted_decrypt(part, flags, NULL,
|
ret = g_mime_multipart_encrypted_decrypt (part, flags, NULL,
|
||||||
decrypt_result, err);
|
decrypt_result, err);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_notmuch_message_crypto_destructor (_notmuch_message_crypto_t *msg_crypto)
|
_notmuch_message_crypto_destructor (_notmuch_message_crypto_t *msg_crypto)
|
||||||
{
|
{
|
||||||
if (!msg_crypto)
|
if (! msg_crypto)
|
||||||
return 0;
|
return 0;
|
||||||
if (msg_crypto->sig_list)
|
if (msg_crypto->sig_list)
|
||||||
g_object_unref (msg_crypto->sig_list);
|
g_object_unref (msg_crypto->sig_list);
|
||||||
|
@ -99,6 +101,7 @@ _notmuch_message_crypto_t *
|
||||||
_notmuch_message_crypto_new (void *ctx)
|
_notmuch_message_crypto_new (void *ctx)
|
||||||
{
|
{
|
||||||
_notmuch_message_crypto_t *ret = talloc_zero (ctx, _notmuch_message_crypto_t);
|
_notmuch_message_crypto_t *ret = talloc_zero (ctx, _notmuch_message_crypto_t);
|
||||||
|
|
||||||
talloc_set_destructor (ret, _notmuch_message_crypto_destructor);
|
talloc_set_destructor (ret, _notmuch_message_crypto_destructor);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +109,7 @@ _notmuch_message_crypto_new (void *ctx)
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
_notmuch_message_crypto_potential_sig_list (_notmuch_message_crypto_t *msg_crypto, GMimeSignatureList *sigs)
|
_notmuch_message_crypto_potential_sig_list (_notmuch_message_crypto_t *msg_crypto, GMimeSignatureList *sigs)
|
||||||
{
|
{
|
||||||
if (!msg_crypto)
|
if (! msg_crypto)
|
||||||
return NOTMUCH_STATUS_NULL_POINTER;
|
return NOTMUCH_STATUS_NULL_POINTER;
|
||||||
|
|
||||||
/* Signatures that arrive after a payload part during DFS are not
|
/* Signatures that arrive after a payload part during DFS are not
|
||||||
|
@ -139,7 +142,7 @@ _notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto
|
||||||
const char *forwarded = NULL;
|
const char *forwarded = NULL;
|
||||||
const char *subject = NULL;
|
const char *subject = NULL;
|
||||||
|
|
||||||
if (!msg_crypto || !payload)
|
if (! msg_crypto || ! payload)
|
||||||
return NOTMUCH_STATUS_NULL_POINTER;
|
return NOTMUCH_STATUS_NULL_POINTER;
|
||||||
|
|
||||||
/* only fire on the first payload part encountered */
|
/* only fire on the first payload part encountered */
|
||||||
|
@ -182,7 +185,7 @@ _notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto
|
||||||
} else {
|
} else {
|
||||||
/* Consider "memoryhole"-style protected headers as practiced by Enigmail and K-9 */
|
/* Consider "memoryhole"-style protected headers as practiced by Enigmail and K-9 */
|
||||||
protected_headers = g_mime_object_get_content_type_parameter (payload, "protected-headers");
|
protected_headers = g_mime_object_get_content_type_parameter (payload, "protected-headers");
|
||||||
if (protected_headers && strcasecmp("v1", protected_headers) == 0)
|
if (protected_headers && strcasecmp ("v1", protected_headers) == 0)
|
||||||
subject = g_mime_object_get_header (payload, "Subject");
|
subject = g_mime_object_get_header (payload, "Subject");
|
||||||
/* FIXME: handle more than just Subject: at some point */
|
/* FIXME: handle more than just Subject: at some point */
|
||||||
}
|
}
|
||||||
|
@ -200,12 +203,12 @@ _notmuch_message_crypto_potential_payload (_notmuch_message_crypto_t *msg_crypto
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
_notmuch_message_crypto_successful_decryption (_notmuch_message_crypto_t *msg_crypto)
|
_notmuch_message_crypto_successful_decryption (_notmuch_message_crypto_t *msg_crypto)
|
||||||
{
|
{
|
||||||
if (!msg_crypto)
|
if (! msg_crypto)
|
||||||
return NOTMUCH_STATUS_NULL_POINTER;
|
return NOTMUCH_STATUS_NULL_POINTER;
|
||||||
|
|
||||||
/* see the rationale for different values of
|
/* see the rationale for different values of
|
||||||
* _notmuch_message_decryption_status_t in util/crypto.h */
|
* _notmuch_message_decryption_status_t in util/crypto.h */
|
||||||
if (!msg_crypto->payload_encountered)
|
if (! msg_crypto->payload_encountered)
|
||||||
msg_crypto->decryption_status = NOTMUCH_MESSAGE_DECRYPTED_FULL;
|
msg_crypto->decryption_status = NOTMUCH_MESSAGE_DECRYPTED_FULL;
|
||||||
else if (msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_NONE)
|
else if (msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_NONE)
|
||||||
msg_crypto->decryption_status = NOTMUCH_MESSAGE_DECRYPTED_PARTIAL;
|
msg_crypto->decryption_status = NOTMUCH_MESSAGE_DECRYPTED_PARTIAL;
|
||||||
|
|
|
@ -50,7 +50,7 @@ typedef struct _notmuch_message_crypto {
|
||||||
/* signature status of the whole message (either the whole message
|
/* signature status of the whole message (either the whole message
|
||||||
* is signed, or it is not) -- this means that partially-signed
|
* is signed, or it is not) -- this means that partially-signed
|
||||||
* messages will get no signature status. */
|
* messages will get no signature status. */
|
||||||
GMimeSignatureList * sig_list;
|
GMimeSignatureList *sig_list;
|
||||||
/* if part of the message was signed, and the MUA is clever, it
|
/* if part of the message was signed, and the MUA is clever, it
|
||||||
* can determine on its own exactly which part and try to make
|
* can determine on its own exactly which part and try to make
|
||||||
* more sense of it. */
|
* more sense of it. */
|
||||||
|
@ -62,7 +62,7 @@ typedef struct _notmuch_message_crypto {
|
||||||
/* the value of any "Subject:" header in the cryptographic payload
|
/* the value of any "Subject:" header in the cryptographic payload
|
||||||
* (the top level part within the crypto envelope), converted to
|
* (the top level part within the crypto envelope), converted to
|
||||||
* UTF-8 */
|
* UTF-8 */
|
||||||
char * payload_subject;
|
char *payload_subject;
|
||||||
|
|
||||||
/* if both signed and encrypted, was the signature encrypted? */
|
/* if both signed and encrypted, was the signature encrypted? */
|
||||||
bool signature_encrypted;
|
bool signature_encrypted;
|
||||||
|
|
|
@ -44,8 +44,8 @@ _internal_error (const char *format, ...) PRINTF_ATTRIBUTE (1, 2) NORETURN_ATTRI
|
||||||
*
|
*
|
||||||
* Note that __location__ comes from talloc.h.
|
* Note that __location__ comes from talloc.h.
|
||||||
*/
|
*/
|
||||||
#define INTERNAL_ERROR(format, ...) \
|
#define INTERNAL_ERROR(format, ...) \
|
||||||
_internal_error (format " (%s).\n", \
|
_internal_error (format " (%s).\n", \
|
||||||
##__VA_ARGS__, __location__)
|
##__VA_ARGS__, __location__)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
static
|
static
|
||||||
GMimeStream *
|
GMimeStream *
|
||||||
_gzfile_maybe_filter (GMimeStream *file_stream) {
|
_gzfile_maybe_filter (GMimeStream *file_stream)
|
||||||
|
{
|
||||||
char buf[4];
|
char buf[4];
|
||||||
int bytes_read;
|
int bytes_read;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ _gzfile_maybe_filter (GMimeStream *file_stream) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* check for gzipped input */
|
/* check for gzipped input */
|
||||||
if (bytes_read >= 2 && buf[0] == 0x1f && (unsigned char)buf[1] == 0x8b) {
|
if (bytes_read >= 2 && buf[0] == 0x1f && (unsigned char) buf[1] == 0x8b) {
|
||||||
GMimeStream *gzstream;
|
GMimeStream *gzstream;
|
||||||
GMimeFilter *gzfilter;
|
GMimeFilter *gzfilter;
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ _gzfile_maybe_filter (GMimeStream *file_stream) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* ignore filter id */
|
/* ignore filter id */
|
||||||
(void)g_mime_stream_filter_add ((GMimeStreamFilter *)gzstream, gzfilter);
|
(void) g_mime_stream_filter_add ((GMimeStreamFilter *) gzstream, gzfilter);
|
||||||
return gzstream;
|
return gzstream;
|
||||||
} else {
|
} else {
|
||||||
return file_stream;
|
return file_stream;
|
||||||
|
@ -59,13 +60,13 @@ g_mime_stream_gzfile_open (const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
GMimeStream *
|
GMimeStream *
|
||||||
g_mime_stream_stdout_new()
|
g_mime_stream_stdout_new ()
|
||||||
{
|
{
|
||||||
GMimeStream *stream_stdout = NULL;
|
GMimeStream *stream_stdout = NULL;
|
||||||
GMimeStream *stream_buffered = NULL;
|
GMimeStream *stream_buffered = NULL;
|
||||||
|
|
||||||
stream_stdout = g_mime_stream_pipe_new (STDOUT_FILENO);
|
stream_stdout = g_mime_stream_pipe_new (STDOUT_FILENO);
|
||||||
if (!stream_stdout)
|
if (! stream_stdout)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
g_mime_stream_pipe_set_owner (GMIME_STREAM_PIPE (stream_stdout), FALSE);
|
g_mime_stream_pipe_set_owner (GMIME_STREAM_PIPE (stream_stdout), FALSE);
|
||||||
|
@ -80,10 +81,11 @@ g_mime_stream_stdout_new()
|
||||||
/**
|
/**
|
||||||
* copy a glib string into a talloc context, and free it.
|
* copy a glib string into a talloc context, and free it.
|
||||||
*/
|
*/
|
||||||
static char*
|
static char *
|
||||||
g_string_talloc_strdup (void *ctx, char *g_string)
|
g_string_talloc_strdup (void *ctx, char *g_string)
|
||||||
{
|
{
|
||||||
char *new_str = talloc_strdup (ctx, g_string);
|
char *new_str = talloc_strdup (ctx, g_string);
|
||||||
|
|
||||||
g_free (g_string);
|
g_free (g_string);
|
||||||
return new_str;
|
return new_str;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +95,7 @@ g_mime_certificate_get_valid_userid (GMimeCertificate *cert)
|
||||||
{
|
{
|
||||||
/* output user id only if validity is FULL or ULTIMATE. */
|
/* output user id only if validity is FULL or ULTIMATE. */
|
||||||
const char *uid = g_mime_certificate_get_user_id (cert);
|
const char *uid = g_mime_certificate_get_user_id (cert);
|
||||||
|
|
||||||
if (uid == NULL)
|
if (uid == NULL)
|
||||||
return uid;
|
return uid;
|
||||||
GMimeValidity validity = g_mime_certificate_get_id_validity (cert);
|
GMimeValidity validity = g_mime_certificate_get_id_validity (cert);
|
||||||
|
@ -101,10 +104,12 @@ g_mime_certificate_get_valid_userid (GMimeCertificate *cert)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char *
|
||||||
g_mime_certificate_get_fpr16 (GMimeCertificate *cert) {
|
g_mime_certificate_get_fpr16 (GMimeCertificate *cert)
|
||||||
|
{
|
||||||
const char *fpr = g_mime_certificate_get_fingerprint (cert);
|
const char *fpr = g_mime_certificate_get_fingerprint (cert);
|
||||||
if (!fpr || strlen (fpr) < 16)
|
|
||||||
|
if (! fpr || strlen (fpr) < 16)
|
||||||
return fpr;
|
return fpr;
|
||||||
|
|
||||||
return fpr + (strlen (fpr) - 16);
|
return fpr + (strlen (fpr) - 16);
|
||||||
|
@ -114,23 +119,25 @@ char *
|
||||||
g_mime_message_get_address_string (GMimeMessage *message, GMimeAddressType type)
|
g_mime_message_get_address_string (GMimeMessage *message, GMimeAddressType type)
|
||||||
{
|
{
|
||||||
InternetAddressList *list = g_mime_message_get_addresses (message, type);
|
InternetAddressList *list = g_mime_message_get_addresses (message, type);
|
||||||
|
|
||||||
return internet_address_list_to_string (list, NULL, 0);
|
return internet_address_list_to_string (list, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
|
g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
|
||||||
{
|
{
|
||||||
GDateTime* parsed_date = g_mime_message_get_date (message);
|
GDateTime *parsed_date = g_mime_message_get_date (message);
|
||||||
|
|
||||||
if (parsed_date) {
|
if (parsed_date) {
|
||||||
char *date = g_mime_utils_header_format_date (parsed_date);
|
char *date = g_mime_utils_header_format_date (parsed_date);
|
||||||
return g_string_talloc_strdup (ctx, date);
|
return g_string_talloc_strdup (ctx, date);
|
||||||
} else {
|
} else {
|
||||||
return talloc_strdup(ctx, "Thu, 01 Jan 1970 00:00:00 +0000");
|
return talloc_strdup (ctx, "Thu, 01 Jan 1970 00:00:00 +0000");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InternetAddressList *
|
InternetAddressList *
|
||||||
g_mime_message_get_reply_to_list(GMimeMessage *message)
|
g_mime_message_get_reply_to_list (GMimeMessage *message)
|
||||||
{
|
{
|
||||||
return g_mime_message_get_reply_to (message);
|
return g_mime_message_get_reply_to (message);
|
||||||
}
|
}
|
||||||
|
@ -145,6 +152,7 @@ char *
|
||||||
g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
|
g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
|
||||||
{
|
{
|
||||||
InternetAddressList *list = g_mime_message_get_reply_to (message);
|
InternetAddressList *list = g_mime_message_get_reply_to (message);
|
||||||
|
|
||||||
return g_string_talloc_strdup (ctx, internet_address_list_to_string (list, NULL, 0));
|
return g_string_talloc_strdup (ctx, internet_address_list_to_string (list, NULL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,23 +169,27 @@ g_mime_parser_set_scan_from (GMimeParser *parser, gboolean flag)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_mime_signature_status_good (GMimeSignatureStatus status) {
|
g_mime_signature_status_good (GMimeSignatureStatus status)
|
||||||
return ((status & (GMIME_SIGNATURE_STATUS_RED | GMIME_SIGNATURE_STATUS_ERROR_MASK)) == 0);
|
{
|
||||||
|
return ((status & (GMIME_SIGNATURE_STATUS_RED | GMIME_SIGNATURE_STATUS_ERROR_MASK)) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_mime_signature_status_bad (GMimeSignatureStatus status) {
|
g_mime_signature_status_bad (GMimeSignatureStatus status)
|
||||||
|
{
|
||||||
return (status & GMIME_SIGNATURE_STATUS_RED);
|
return (status & GMIME_SIGNATURE_STATUS_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
g_mime_signature_status_error (GMimeSignatureStatus status) {
|
g_mime_signature_status_error (GMimeSignatureStatus status)
|
||||||
|
{
|
||||||
return (status & GMIME_SIGNATURE_STATUS_ERROR_MASK);
|
return (status & GMIME_SIGNATURE_STATUS_ERROR_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint64
|
gint64
|
||||||
g_mime_utils_header_decode_date_unix (const char *date) {
|
g_mime_utils_header_decode_date_unix (const char *date)
|
||||||
GDateTime* parsed_date = g_mime_utils_header_decode_date (date);
|
{
|
||||||
|
GDateTime *parsed_date = g_mime_utils_header_decode_date (date);
|
||||||
time_t ret;
|
time_t ret;
|
||||||
|
|
||||||
if (parsed_date) {
|
if (parsed_date) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GMimeStream *g_mime_stream_stdout_new(void);
|
GMimeStream *g_mime_stream_stdout_new (void);
|
||||||
|
|
||||||
/* Return a GMime stream for this open file descriptor, un-gzipping if
|
/* Return a GMime stream for this open file descriptor, un-gzipping if
|
||||||
* necessary */
|
* necessary */
|
||||||
|
@ -27,7 +27,7 @@ const char *g_mime_certificate_get_fpr16 (GMimeCertificate *cert);
|
||||||
*/
|
*/
|
||||||
char *g_mime_message_get_address_string (GMimeMessage *message, GMimeAddressType type);
|
char *g_mime_message_get_address_string (GMimeMessage *message, GMimeAddressType type);
|
||||||
|
|
||||||
InternetAddressList * g_mime_message_get_addresses (GMimeMessage *message, GMimeAddressType type);
|
InternetAddressList *g_mime_message_get_addresses (GMimeMessage *message, GMimeAddressType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return talloc allocated date string
|
* return talloc allocated date string
|
||||||
|
@ -39,21 +39,21 @@ char *g_mime_message_get_date_string (void *ctx, GMimeMessage *message);
|
||||||
* glib allocated list of From: addresses
|
* glib allocated list of From: addresses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
InternetAddressList * g_mime_message_get_from (GMimeMessage *message);
|
InternetAddressList *g_mime_message_get_from (GMimeMessage *message);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return string for From: address
|
* return string for From: address
|
||||||
* (owned by gmime)
|
* (owned by gmime)
|
||||||
*/
|
*/
|
||||||
const char * g_mime_message_get_from_string (GMimeMessage *message);
|
const char *g_mime_message_get_from_string (GMimeMessage *message);
|
||||||
|
|
||||||
InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
|
InternetAddressList *g_mime_message_get_reply_to_list (GMimeMessage *message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return talloc allocated reply-to string
|
* return talloc allocated reply-to string
|
||||||
*/
|
*/
|
||||||
char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
|
char *g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
|
||||||
|
|
||||||
void g_mime_parser_set_scan_from (GMimeParser *parser, gboolean flag);
|
void g_mime_parser_set_scan_from (GMimeParser *parser, gboolean flag);
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ gint64 g_mime_utils_header_decode_date_unix (const char *date);
|
||||||
/**
|
/**
|
||||||
* Return string for valid User ID (or NULL if no valid User ID exists)
|
* Return string for valid User ID (or NULL if no valid User ID exists)
|
||||||
*/
|
*/
|
||||||
const char * g_mime_certificate_get_valid_userid (GMimeCertificate *cert);
|
const char *g_mime_certificate_get_valid_userid (GMimeCertificate *cert);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ hex_encode (void *ctx, const char *in, char **out, size_t *out_size)
|
||||||
if (*out == NULL)
|
if (*out == NULL)
|
||||||
*out_size = 0;
|
*out_size = 0;
|
||||||
|
|
||||||
if (!maybe_realloc (ctx, needed, out, out_size))
|
if (! maybe_realloc (ctx, needed, out, out_size))
|
||||||
return HEX_OUT_OF_MEMORY;
|
return HEX_OUT_OF_MEMORY;
|
||||||
|
|
||||||
q = *out;
|
q = *out;
|
||||||
|
@ -82,7 +82,7 @@ hex_encode (void *ctx, const char *in, char **out, size_t *out_size)
|
||||||
if (is_output (*p)) {
|
if (is_output (*p)) {
|
||||||
*q++ = *p++;
|
*q++ = *p++;
|
||||||
} else {
|
} else {
|
||||||
sprintf (q, "%%%02x", (unsigned char)*p++);
|
sprintf (q, "%%%02x", (unsigned char) *p++);
|
||||||
q += 3;
|
q += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,8 +105,8 @@ hex_decode_internal (const char *in, unsigned char *out)
|
||||||
char *endp;
|
char *endp;
|
||||||
|
|
||||||
/* This also handles unexpected end-of-string. */
|
/* This also handles unexpected end-of-string. */
|
||||||
if (!isxdigit ((unsigned char) in[1]) ||
|
if (! isxdigit ((unsigned char) in[1]) ||
|
||||||
!isxdigit ((unsigned char) in[2]))
|
! isxdigit ((unsigned char) in[2]))
|
||||||
return HEX_SYNTAX_ERROR;
|
return HEX_SYNTAX_ERROR;
|
||||||
|
|
||||||
buf[0] = in[1];
|
buf[0] = in[1];
|
||||||
|
@ -139,10 +139,10 @@ hex_decode_inplace (char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
hex_status_t
|
hex_status_t
|
||||||
hex_decode (void *ctx, const char *in, char **out, size_t * out_size)
|
hex_decode (void *ctx, const char *in, char **out, size_t *out_size)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
size_t needed = 1; /* for the NUL */
|
size_t needed = 1; /* for the NUL */
|
||||||
|
|
||||||
assert (ctx); assert (in); assert (out); assert (out_size);
|
assert (ctx); assert (in); assert (out); assert (out_size);
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ hex_decode (void *ctx, const char *in, char **out, size_t * out_size)
|
||||||
else
|
else
|
||||||
needed += 1;
|
needed += 1;
|
||||||
|
|
||||||
if (!maybe_realloc (ctx, needed, out, out_size))
|
if (! maybe_realloc (ctx, needed, out, out_size))
|
||||||
return HEX_OUT_OF_MEMORY;
|
return HEX_OUT_OF_MEMORY;
|
||||||
|
|
||||||
return hex_decode_internal (in, (unsigned char *) *out);
|
return hex_decode_internal (in, (unsigned char *) *out);
|
||||||
|
|
|
@ -29,11 +29,11 @@ typedef enum hex_status {
|
||||||
|
|
||||||
hex_status_t
|
hex_status_t
|
||||||
hex_encode (void *talloc_ctx, const char *in, char **out,
|
hex_encode (void *talloc_ctx, const char *in, char **out,
|
||||||
size_t *out_size);
|
size_t *out_size);
|
||||||
|
|
||||||
hex_status_t
|
hex_status_t
|
||||||
hex_decode (void *talloc_ctx, const char *in, char **out,
|
hex_decode (void *talloc_ctx, const char *in, char **out,
|
||||||
size_t *out_size);
|
size_t *out_size);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Non-allocating hex decode to decode 's' in-place. The length of the
|
* Non-allocating hex decode to decode 's' in-place. The length of the
|
||||||
|
|
|
@ -42,7 +42,7 @@ strtok_len_c (const char *s, const char *delim, size_t *len)
|
||||||
{
|
{
|
||||||
/* strtok_len is already const-safe, but we can't express both
|
/* strtok_len is already const-safe, but we can't express both
|
||||||
* versions in the C type system. */
|
* versions in the C type system. */
|
||||||
return strtok_len ((char*)s, delim, len);
|
return strtok_len ((char *) s, delim, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -60,7 +60,7 @@ sanitize_string (const void *ctx, const char *str)
|
||||||
for (loop = out; *loop; loop++) {
|
for (loop = out; *loop; loop++) {
|
||||||
if (*loop == '\t' || *loop == '\n')
|
if (*loop == '\t' || *loop == '\n')
|
||||||
*loop = ' ';
|
*loop = ' ';
|
||||||
else if ((unsigned char)(*loop) < 32)
|
else if ((unsigned char) (*loop) < 32)
|
||||||
*loop = '?';
|
*loop = '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,9 +87,9 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,
|
||||||
* beginning, and anything containing non-ASCII text. */
|
* beginning, and anything containing non-ASCII text. */
|
||||||
if (! term[0])
|
if (! term[0])
|
||||||
need_quoting = 1;
|
need_quoting = 1;
|
||||||
for (in = term; *in && !need_quoting; in++)
|
for (in = term; *in && ! need_quoting; in++)
|
||||||
if (is_unquoted_terminator (*in) || *in == '"' || *in == '('
|
if (is_unquoted_terminator (*in) || *in == '"' || *in == '('
|
||||||
|| (unsigned char)*in > 127)
|
|| (unsigned char) *in > 127)
|
||||||
need_quoting = 1;
|
need_quoting = 1;
|
||||||
|
|
||||||
if (need_quoting)
|
if (need_quoting)
|
||||||
|
@ -141,7 +141,7 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char *
|
||||||
skip_space (const char *str)
|
skip_space (const char *str)
|
||||||
{
|
{
|
||||||
while (*str && isspace ((unsigned char) *str))
|
while (*str && isspace ((unsigned char) *str))
|
||||||
|
@ -154,6 +154,7 @@ parse_boolean_term (void *ctx, const char *str,
|
||||||
char **prefix_out, char **term_out)
|
char **prefix_out, char **term_out)
|
||||||
{
|
{
|
||||||
int err = EINVAL;
|
int err = EINVAL;
|
||||||
|
|
||||||
*prefix_out = *term_out = NULL;
|
*prefix_out = *term_out = NULL;
|
||||||
|
|
||||||
/* Parse prefix */
|
/* Parse prefix */
|
||||||
|
@ -193,7 +194,7 @@ parse_boolean_term (void *ctx, const char *str,
|
||||||
}
|
}
|
||||||
/* Did the term terminate without a closing quote or is there
|
/* Did the term terminate without a closing quote or is there
|
||||||
* trailing text after the closing quote? */
|
* trailing text after the closing quote? */
|
||||||
if (!closed || *pos)
|
if (! closed || *pos)
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,7 +216,7 @@ parse_boolean_term (void *ctx, const char *str,
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
FAIL:
|
FAIL:
|
||||||
talloc_free (*prefix_out);
|
talloc_free (*prefix_out);
|
||||||
talloc_free (*term_out);
|
talloc_free (*term_out);
|
||||||
errno = err;
|
errno = err;
|
||||||
|
@ -230,9 +231,9 @@ strcmp_null (const char *s1, const char *s2)
|
||||||
else if (! s1 && ! s2)
|
else if (! s1 && ! s2)
|
||||||
return 0;
|
return 0;
|
||||||
else if (s1)
|
else if (s1)
|
||||||
return 1; /* s1 (non-NULL) is greater than s2 (NULL) */
|
return 1; /* s1 (non-NULL) is greater than s2 (NULL) */
|
||||||
else
|
else
|
||||||
return -1; /* s1 (NULL) is less than s2 (non-NULL) */
|
return -1; /* s1 (NULL) is less than s2 (non-NULL) */
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -248,6 +249,7 @@ strcase_hash (const void *ptr)
|
||||||
|
|
||||||
/* This is the djb2 hash. */
|
/* This is the djb2 hash. */
|
||||||
unsigned int hash = 5381;
|
unsigned int hash = 5381;
|
||||||
|
|
||||||
while (s && *s) {
|
while (s && *s) {
|
||||||
hash = ((hash << 5) + hash) + tolower (*s);
|
hash = ((hash << 5) + hash) + tolower (*s);
|
||||||
s++;
|
s++;
|
||||||
|
|
|
@ -77,7 +77,7 @@ unsigned int strcase_hash (const void *ptr);
|
||||||
|
|
||||||
void strip_trailing (char *str, char ch);
|
void strip_trailing (char *str, char ch);
|
||||||
|
|
||||||
const char* skip_space (const char *str);
|
const char *skip_space (const char *str);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "unicode-util.h"
|
#include "unicode-util.h"
|
||||||
|
|
||||||
/* Based on Xapian::Unicode::is_wordchar, to avoid forcing clients to
|
/* Based on Xapian::Unicode::is_wordchar, to avoid forcing clients to
|
||||||
link directly to libxapian.
|
* link directly to libxapian.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
unicode_is_wordchar (notmuch_unichar ch)
|
unicode_is_wordchar (notmuch_unichar ch)
|
||||||
|
|
|
@ -19,6 +19,6 @@ util_error_string (util_status_t errnum)
|
||||||
/* we lack context to be more informative here */
|
/* we lack context to be more informative here */
|
||||||
return "zlib error";
|
return "zlib error";
|
||||||
default:
|
default:
|
||||||
INTERNAL_ERROR("unexpected error status %d", errnum);
|
INTERNAL_ERROR ("unexpected error status %d", errnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ xregcomp (regex_t *preg, const char *regex, int cflags)
|
||||||
|
|
||||||
regerror (rerr, preg, error, error_size);
|
regerror (rerr, preg, error, error_size);
|
||||||
fprintf (stderr, "compiling regex %s: %s\n",
|
fprintf (stderr, "compiling regex %s: %s\n",
|
||||||
regex, error);
|
regex, error);
|
||||||
free (error);
|
free (error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,13 +70,14 @@ gz_getline (void *talloc_ctx, char **bufptr, ssize_t *bytes_read, gzFile stream)
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return UTIL_OUT_OF_MEMORY;
|
return UTIL_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
SUCCESS:
|
SUCCESS:
|
||||||
*bufptr = buf;
|
*bufptr = buf;
|
||||||
*bytes_read = offset;
|
*bytes_read = offset;
|
||||||
return UTIL_SUCCESS;
|
return UTIL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *gz_error_string (util_status_t status, gzFile file)
|
const char *
|
||||||
|
gz_error_string (util_status_t status, gzFile file)
|
||||||
{
|
{
|
||||||
if (status == UTIL_GZERROR)
|
if (status == UTIL_GZERROR)
|
||||||
return gzerror (file, NULL);
|
return gzerror (file, NULL);
|
||||||
|
|
Loading…
Reference in a new issue