From 948235c3d1076dbe6ed2e57a24c16a083bbd9f01 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 27 May 2009 10:29:19 -0400 Subject: Prefer GLib basic types over C types. --- em-format/em-format-quote.c | 50 +++++++++---------- em-format/em-format-quote.h | 2 +- em-format/em-format.c | 110 ++++++++++++++++++++--------------------- em-format/em-format.h | 48 +++++++++--------- em-format/em-stripsig-filter.c | 26 +++++----- 5 files changed, 118 insertions(+), 118 deletions(-) (limited to 'em-format') diff --git a/em-format/em-format-quote.c b/em-format/em-format-quote.c index 7918b94d88..bb56670f24 100644 --- a/em-format/em-format-quote.c +++ b/em-format/em-format-quote.c @@ -42,14 +42,14 @@ #include "em-format-quote.h" struct _EMFormatQuotePrivate { - int dummy; + gint dummy; }; -static void emfq_format_clone(EMFormat *, CamelFolder *, const char *, CamelMimeMessage *, EMFormat *); -static void emfq_format_error(EMFormat *emf, CamelStream *stream, const char *txt); +static void emfq_format_clone(EMFormat *, CamelFolder *, const gchar *, CamelMimeMessage *, EMFormat *); +static void emfq_format_error(EMFormat *emf, CamelStream *stream, const gchar *txt); static void emfq_format_message(EMFormat *, CamelStream *, CamelMimePart *, const EMFormatHandler *); static void emfq_format_source(EMFormat *, CamelStream *, CamelMimePart *); -static void emfq_format_attachment(EMFormat *, CamelStream *, CamelMimePart *, const char *, const EMFormatHandler *); +static void emfq_format_attachment(EMFormat *, CamelStream *, CamelMimePart *, const gchar *, const EMFormatHandler *); static void emfq_builtin_init(EMFormatQuoteClass *efhc); @@ -153,7 +153,7 @@ emfq_format_empty_line(EMFormat *emf, CamelStream *stream, CamelMimePart *part, } static void -emfq_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeMessage *msg, EMFormat *src) +emfq_format_clone(EMFormat *emf, CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, EMFormat *src) { EMFormatQuote *emfq = (EMFormatQuote *) emf; const EMFormatHandler *handle; @@ -180,16 +180,16 @@ emfq_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMime } static void -emfq_format_error(EMFormat *emf, CamelStream *stream, const char *txt) +emfq_format_error(EMFormat *emf, CamelStream *stream, const gchar *txt) { /* FIXME: should we even bother writing error text for quoting? probably not... */ } static void -emfq_format_text_header (EMFormatQuote *emfq, CamelStream *stream, const char *label, const char *value, guint32 flags, int is_html) +emfq_format_text_header (EMFormatQuote *emfq, CamelStream *stream, const gchar *label, const gchar *value, guint32 flags, gint is_html) { - const char *fmt, *html; - char *mhtml = NULL; + const gchar *fmt, *html; + gchar *mhtml = NULL; if (value == NULL) return; @@ -220,7 +220,7 @@ static const gchar *addrspec_hdrs[] = { #if 0 /* FIXME: include Sender and Resent-* headers too? */ /* For Translators only: The following strings are used in the header table in the preview pane */ -static char *i18n_hdrs[] = { +static gchar *i18n_hdrs[] = { N_("From"), N_("Reply-To"), N_("To"), N_("Cc"), N_("Bcc") }; #endif @@ -229,7 +229,7 @@ static void emfq_format_address (GString *out, struct _camel_header_address *a) { guint32 flags = CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES; - char *name, *mailto, *addr; + gchar *name, *mailto, *addr; while (a) { if (a->name) @@ -240,11 +240,11 @@ emfq_format_address (GString *out, struct _camel_header_address *a) switch (a->type) { case CAMEL_HEADER_ADDRESS_NAME: if (name && *name) { - char *real, *mailaddr; + gchar *real, *mailaddr; g_string_append_printf (out, "%s <", name); /* rfc2368 for mailto syntax and url encoding extras */ - if ((real = camel_header_encode_phrase ((unsigned char *)a->name))) { + if ((real = camel_header_encode_phrase ((guchar *)a->name))) { mailaddr = g_strdup_printf ("%s <%s>", real, a->v.addr); g_free (real); mailto = camel_url_encode (mailaddr, "?=&()"); @@ -282,9 +282,9 @@ emfq_format_address (GString *out, struct _camel_header_address *a) } static void -canon_header_name (char *name) +canon_header_name (gchar *name) { - char *inptr = name; + gchar *inptr = name; /* canonicalise the header name... first letter is * capitalised and any letter following a '-' also gets @@ -306,15 +306,15 @@ canon_header_name (char *name) } static void -emfq_format_header (EMFormat *emf, CamelStream *stream, CamelMedium *part, const char *namein, guint32 flags, const char *charset) +emfq_format_header (EMFormat *emf, CamelStream *stream, CamelMedium *part, const gchar *namein, guint32 flags, const gchar *charset) { CamelMimeMessage *msg = (CamelMimeMessage *) part; EMFormatQuote *emfq = (EMFormatQuote *) emf; - char *name, *buf, *value = NULL; - const char *txt, *label; + gchar *name, *buf, *value = NULL; + const gchar *txt, *label; gboolean addrspec = FALSE; - int is_html = FALSE; - int i; + gint is_html = FALSE; + gint i; name = g_alloca (strlen (namein) + 1); strcpy (name, namein); @@ -388,7 +388,7 @@ emfq_format_headers (EMFormatQuote *emfq, CamelStream *stream, CamelMedium *part { EMFormat *emf = (EMFormat *) emfq; CamelContentType *ct; - const char *charset; + const gchar *charset; EMFormatHeader *h; if (!part) @@ -456,10 +456,10 @@ emfq_format_source(EMFormat *emf, CamelStream *stream, CamelMimePart *part) } static void -emfq_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const char *mime_type, const EMFormatHandler *handle) +emfq_format_attachment(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const gchar *mime_type, const EMFormatHandler *handle) { if (handle && em_format_is_inline(emf, emf->part_id->str, part, handle)) { - char *text, *html; + gchar *text, *html; camel_stream_write_string(stream, "
\n"); @@ -489,7 +489,7 @@ emfq_text_plain(EMFormatQuote *emfq, CamelStream *stream, CamelMimePart *part, E CamelMimeFilter *html_filter; CamelMimeFilter *sig_strip; CamelContentType *type; - const char *format; + const gchar *format; guint32 rgb = 0x737373, flags; if (!part) @@ -579,7 +579,7 @@ static EMFormatHandler type_builtin_table[] = { static void emfq_builtin_init(EMFormatQuoteClass *efhc) { - int i; + gint i; for (i=0;ipart_id->str)); @@ -511,7 +511,7 @@ em_format_pull_level(EMFormat *emf) * Return value: **/ EMFormatPURI * -em_format_find_visible_puri(EMFormat *emf, const char *uri) +em_format_find_visible_puri(EMFormat *emf, const gchar *uri) { EMFormatPURI *pw; struct _EMFormatPURITree *ptree; @@ -545,7 +545,7 @@ em_format_find_visible_puri(EMFormat *emf, const char *uri) **/ EMFormatPURI * -em_format_find_puri(EMFormat *emf, const char *uri) +em_format_find_puri(EMFormat *emf, const gchar *uri) { return g_hash_table_lookup(emf->pending_uri_table, uri); } @@ -614,12 +614,12 @@ em_format_clear_puri_tree(EMFormat *emf) /* use mime_type == NULL to force showing as application/octet-stream */ void -em_format_part_as(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const char *mime_type) +em_format_part_as(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const gchar *mime_type) { const EMFormatHandler *handle = NULL; - const char *snoop_save = emf->snoop_mime_type, *tmp; + const gchar *snoop_save = emf->snoop_mime_type, *tmp; CamelURL *base_save = emf->base, *base = NULL; - char *basestr = NULL; + gchar *basestr = NULL; d(printf("format_part_as()\n")); @@ -677,7 +677,7 @@ finish: void em_format_part(EMFormat *emf, CamelStream *stream, CamelMimePart *part) { - char *mime_type; + gchar *mime_type; CamelDataWrapper *dw; dw = camel_medium_get_content_object((CamelMedium *)part); @@ -691,7 +691,7 @@ em_format_part(EMFormat *emf, CamelStream *stream, CamelMimePart *part) } static void -emf_clone_inlines(void *key, void *val, void *data) +emf_clone_inlines(gpointer key, gpointer val, gpointer data) { struct _EMFormatCache *emfc = val, *new; @@ -704,7 +704,7 @@ emf_clone_inlines(void *key, void *val, void *data) } static void -emf_format_clone(EMFormat *emf, CamelFolder *folder, const char *uid, CamelMimeMessage *msg, EMFormat *emfsource) +emf_format_clone(EMFormat *emf, CamelFolder *folder, const gchar *uid, CamelMimeMessage *msg, EMFormat *emfsource) { em_format_clear_puri_tree(emf); @@ -761,7 +761,7 @@ static void emf_format_secure(EMFormat *emf, CamelStream *stream, CamelMimePart *part, CamelCipherValidity *valid) { CamelCipherValidity *save = emf->valid_parent; - int len; + gint len; /* Note that this also requires support from higher up in the class chain - validity needs to be cleared when you start output @@ -874,7 +874,7 @@ em_format_set_mode(EMFormat *emf, em_format_mode_t type) * required. **/ void -em_format_set_charset(EMFormat *emf, const char *charset) +em_format_set_charset(EMFormat *emf, const gchar *charset) { if ((emf->charset && charset && g_ascii_strcasecmp(emf->charset, charset) == 0) || (emf->charset == NULL && charset == NULL) @@ -898,7 +898,7 @@ em_format_set_charset(EMFormat *emf, const char *charset) * when it isn't). **/ void -em_format_set_default_charset(EMFormat *emf, const char *charset) +em_format_set_default_charset(EMFormat *emf, const gchar *charset) { if ((emf->default_charset && charset && g_ascii_strcasecmp(emf->default_charset, charset) == 0) || (emf->default_charset == NULL && charset == NULL) @@ -930,7 +930,7 @@ em_format_clear_headers(EMFormat *emf) /* note: also copied in em-mailer-prefs.c */ static const struct { - const char *name; + const gchar *name; guint32 flags; } default_headers[] = { { N_("From"), EM_FORMAT_HEADER_BOLD }, @@ -955,7 +955,7 @@ static const struct { void em_format_default_headers(EMFormat *emf) { - int i; + gint i; em_format_clear_headers(emf); for (i=0; ipart_id->len; + gint len = emf->part_id->len; g_string_append_printf(emf->part_id, ".alternative.%d", bestid); em_format_part(emf, stream, best); @@ -1451,7 +1451,7 @@ emf_multipart_encrypted(EMFormat *emf, CamelStream *stream, CamelMimePart *part, { CamelCipherContext *context; CamelException *ex; - const char *protocol; + const gchar *protocol; CamelMimePart *opart; CamelCipherValidity *valid; CamelMultipartEncrypted *mpe; @@ -1518,9 +1518,9 @@ emf_multipart_related(EMFormat *emf, CamelStream *stream, CamelMimePart *part, c CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part); CamelMimePart *body_part, *display_part = NULL; CamelContentType *content_type; - const char *start; - int i, nparts, partidlen, displayid = 0; - char *oldpartid; + const gchar *start; + gint i, nparts, partidlen, displayid = 0; + gchar *oldpartid; struct _EMFormatPURITree *ptree; EMFormatPURI *puri, *purin; @@ -1534,8 +1534,8 @@ emf_multipart_related(EMFormat *emf, CamelStream *stream, CamelMimePart *part, c content_type = camel_mime_part_get_content_type(part); start = camel_content_type_param (content_type, "start"); if (start && strlen(start)>2) { - int len; - const char *cid; + gint len; + const gchar *cid; /* strip <>'s */ len = strlen (start) - 2; @@ -1674,7 +1674,7 @@ emf_message_rfc822(EMFormat *emf, CamelStream *stream, CamelMimePart *part, cons { CamelDataWrapper *dw = camel_medium_get_content_object((CamelMedium *)part); const EMFormatHandler *handle; - int len; + gint len; if (!CAMEL_IS_MIME_MESSAGE(dw)) { em_format_format_source(emf, stream, part); @@ -1709,7 +1709,7 @@ emf_inlinepgp_signed(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart, E CamelMimePart *opart; CamelStream *ostream; CamelException *ex; - char *type; + gchar *type; if (!ipart) { em_format_format_error(emf, stream, _("Unknown error verifying signature")); @@ -1787,7 +1787,7 @@ emf_inlinepgp_encrypted(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart CamelException *ex; CamelMimePart *opart; CamelDataWrapper *dw; - char *mime_type; + gchar *mime_type; cipher = camel_gpg_context_new(emf->session); ex = camel_exception_new(); @@ -1811,7 +1811,7 @@ emf_inlinepgp_encrypted(EMFormat *emf, CamelStream *stream, CamelMimePart *ipart /* this ensures to show the 'opart' as inlined, if possible */ if (mime_type && g_ascii_strcasecmp (mime_type, "application/octet-stream") == 0) { - const char *snoop = em_format_snoop_type (opart); + const gchar *snoop = em_format_snoop_type (opart); if (snoop) camel_data_wrapper_set_mime_type (dw, snoop); @@ -1857,7 +1857,7 @@ static EMFormatHandler type_builtin_table[] = { static void emf_builtin_init(EMFormatClass *class) { - int i; + gint i; for (i=0;itype_handlers, type_builtin_table[i].mime_type, &type_builtin_table[i]); @@ -1871,14 +1871,14 @@ emf_builtin_init(EMFormatClass *class) * * Return value: NULL if unknown (more likely application/octet-stream). **/ -const char * +const gchar * em_format_snoop_type (CamelMimePart *part) { - /* cache is here only to be able still return const char * */ + /* cache is here only to be able still return const gchar * */ static GHashTable *types_cache = NULL; - const char *filename; - char *name_type = NULL, *magic_type = NULL, *res, *tmp; + const gchar *filename; + gchar *name_type = NULL, *magic_type = NULL, *res, *tmp; CamelDataWrapper *dw; filename = camel_mime_part_get_filename (part); @@ -1890,7 +1890,7 @@ em_format_snoop_type (CamelMimePart *part) CamelStreamMem *mem = (CamelStreamMem *)camel_stream_mem_new(); if (camel_data_wrapper_decode_to_stream(dw, (CamelStream *)mem) > 0) { - char *ct = g_content_type_guess (filename, mem->buffer->data, mem->buffer->len, NULL); + gchar *ct = g_content_type_guess (filename, mem->buffer->data, mem->buffer->len, NULL); if (ct) magic_type = g_content_type_get_mime_type (ct); diff --git a/em-format/em-format.h b/em-format/em-format.h index a9d9356778..652ec33ae8 100644 --- a/em-format/em-format.h +++ b/em-format/em-format.h @@ -140,14 +140,14 @@ struct _EMFormatPURI { void (*free)(struct _EMFormatPURI *p); /* optional callback for freeing user-fields */ struct _EMFormat *format; - char *uri; /* will be the location of the part, may be empty */ - char *cid; /* will always be set, a fake one created if needed */ - char *part_id; /* will always be set, emf->part_id->str for this part */ + gchar *uri; /* will be the location of the part, may be empty */ + gchar *cid; /* will always be set, a fake one created if needed */ + gchar *part_id; /* will always be set, emf->part_id->str for this part */ EMFormatPURIFunc func; CamelMimePart *part; - unsigned int use_count; /* used by multipart/related to see if it was accessed */ + guint use_count; /* used by multipart/related to see if it was accessed */ }; /** @@ -176,7 +176,7 @@ struct _EMFormatHeader { struct _EMFormatHeader *next, *prev; guint32 flags; /* E_FORMAT_HEADER_* */ - char name[1]; + gchar name[1]; }; #define EM_FORMAT_HEADER_BOLD (1<<0) @@ -218,7 +218,7 @@ struct _EMFormat { CamelMimeMessage *message; /* the current message */ CamelFolder *folder; - char *uid; + gchar *uid; GString *part_id; /* current part id prefix, for identifying parts directly */ @@ -227,7 +227,7 @@ struct _EMFormat { CamelSession *session; /* session, used for authentication when required */ CamelURL *base; /* content-base header or absolute content-location, for any part */ - const char *snoop_mime_type; /* if we snooped an application/octet-stream type, what we snooped */ + const gchar *snoop_mime_type; /* if we snooped an application/octet-stream type, what we snooped */ /* for validity enveloping */ CamelCipherValidity *valid; @@ -245,8 +245,8 @@ struct _EMFormat { struct _EMFormatPURITree *pending_uri_level; em_format_mode_t mode; /* source/headers/etc */ - char *charset; /* charset override */ - char *default_charset; /* charset fallback */ + gchar *charset; /* charset override */ + gchar *default_charset; /* charset fallback */ gboolean composer; /* Formatting from composer ?*/ gboolean print; }; @@ -257,16 +257,16 @@ struct _EMFormatClass { GHashTable *type_handlers; /* lookup handler, default falls back to hashtable above */ - const EMFormatHandler *(*find_handler)(EMFormat *, const char *mime_type); + const EMFormatHandler *(*find_handler)(EMFormat *, const gchar *mime_type); /* start formatting a message */ - void (*format_clone)(EMFormat *, CamelFolder *, const char *uid, CamelMimeMessage *, EMFormat *); + void (*format_clone)(EMFormat *, CamelFolder *, const gchar *uid, CamelMimeMessage *, EMFormat *); /* some internel error/inconsistency */ - void (*format_error)(EMFormat *, CamelStream *, const char *msg); + void (*format_error)(EMFormat *, CamelStream *, const gchar *msg); /* use for external structured parts */ - void (*format_attachment)(EMFormat *, CamelStream *, CamelMimePart *, const char *mime_type, const struct _EMFormatHandler *info); + void (*format_attachment)(EMFormat *, CamelStream *, CamelMimePart *, const gchar *mime_type, const struct _EMFormatHandler *info); /* use for unparsable content */ void (*format_source)(EMFormat *, CamelStream *, CamelMimePart *); @@ -287,9 +287,9 @@ struct _EMFormatClass { void em_format_set_mode (EMFormat *emf, em_format_mode_t type); void em_format_set_charset (EMFormat *emf, - const char *charset); + const gchar *charset); void em_format_set_default_charset (EMFormat *emf, - const char *charset); + const gchar *charset); /* also indicates to show all headers */ void em_format_clear_headers (EMFormat *emf); @@ -306,15 +306,15 @@ int em_format_is_attachment (EMFormat *emf, CamelMimePart *part); int em_format_is_inline (EMFormat *emf, - const char *partid, + const gchar *partid, CamelMimePart *part, const EMFormatHandler *handle); void em_format_set_inline (EMFormat *emf, - const char *partid, - int state); + const gchar *partid, + gint state); -char * em_format_describe_part (CamelMimePart *part, - const char *mime_type); +gchar * em_format_describe_part (CamelMimePart *part, + const gchar *mime_type); /* for implementers */ GType em_format_get_type (void); @@ -333,13 +333,13 @@ const EMFormatHandler * /* puri is short for pending uri ... really */ EMFormatPURI * em_format_add_puri (EMFormat *emf, size_t size, - const char *uri, + const gchar *uri, CamelMimePart *part, EMFormatPURIFunc func); EMFormatPURI * em_format_find_visible_puri (EMFormat *emf, - const char *uri); + const gchar *uri); EMFormatPURI * em_format_find_puri (EMFormat *emf, - const char *uri); + const gchar *uri); void em_format_clear_puri_tree (EMFormat *emf); void em_format_push_level (EMFormat *emf); void em_format_pull_level (EMFormat *emf); @@ -396,7 +396,7 @@ void em_format_part (EMFormat *emf, void em_format_merge_handler (EMFormat *new, EMFormat *old); -const char * em_format_snoop_type (CamelMimePart *part); +const gchar * em_format_snoop_type (CamelMimePart *part); G_END_DECLS diff --git a/em-format/em-stripsig-filter.c b/em-format/em-stripsig-filter.c index 1600eeaed0..1b977e975f 100644 --- a/em-format/em-stripsig-filter.c +++ b/em-format/em-stripsig-filter.c @@ -34,10 +34,10 @@ static void em_stripsig_filter_class_init (EMStripSigFilterClass *klass); static void em_stripsig_filter_init (EMStripSigFilter *filter, EMStripSigFilterClass *klass); -static void filter_filter (CamelMimeFilter *filter, char *in, size_t len, size_t prespace, - char **out, size_t *outlen, size_t *outprespace); -static void filter_complete (CamelMimeFilter *filter, char *in, size_t len, size_t prespace, - char **out, size_t *outlen, size_t *outprespace); +static void filter_filter (CamelMimeFilter *filter, gchar *in, size_t len, size_t prespace, + gchar **out, size_t *outlen, size_t *outprespace); +static void filter_complete (CamelMimeFilter *filter, gchar *in, size_t len, size_t prespace, + gchar **out, size_t *outlen, size_t *outprespace); static void filter_reset (CamelMimeFilter *filter); @@ -83,13 +83,13 @@ em_stripsig_filter_init (EMStripSigFilter *filter, EMStripSigFilterClass *klass) } static void -strip_signature (CamelMimeFilter *filter, char *in, size_t len, size_t prespace, - char **out, size_t *outlen, size_t *outprespace, int flush) +strip_signature (CamelMimeFilter *filter, gchar *in, size_t len, size_t prespace, + gchar **out, size_t *outlen, size_t *outprespace, gint flush) { EMStripSigFilter *stripsig = (EMStripSigFilter *) filter; - register const char *inptr = in; - const char *inend = in + len; - const char *start = NULL; + register const gchar *inptr = in; + const gchar *inend = in + len; + const gchar *start = NULL; if (stripsig->midline) { while (inptr < inend && *inptr != '\n') @@ -132,15 +132,15 @@ strip_signature (CamelMimeFilter *filter, char *in, size_t len, size_t prespace, } static void -filter_filter (CamelMimeFilter *filter, char *in, size_t len, size_t prespace, - char **out, size_t *outlen, size_t *outprespace) +filter_filter (CamelMimeFilter *filter, gchar *in, size_t len, size_t prespace, + gchar **out, size_t *outlen, size_t *outprespace) { strip_signature (filter, in, len, prespace, out, outlen, outprespace, FALSE); } static void -filter_complete (CamelMimeFilter *filter, char *in, size_t len, size_t prespace, - char **out, size_t *outlen, size_t *outprespace) +filter_complete (CamelMimeFilter *filter, gchar *in, size_t len, size_t prespace, + gchar **out, size_t *outlen, size_t *outprespace) { strip_signature (filter, in, len, prespace, out, outlen, outprespace, TRUE); } -- cgit v1.2.3