static void each_part_show (MuMsg *msg, MuMsgPart *part, gboolean color) { /* index */ g_print (" %u ", part->index); /* filename */ color_maybe (MU_COLOR_GREEN); { gchar *fname; fname = mu_msg_part_get_filename (part, FALSE); mu_util_fputs_encoded (fname ? fname : "<none>", stdout); g_free (fname); } /* content-type */ color_maybe (MU_COLOR_BLUE); mu_util_print_encoded ( " %s/%s ", part->type ? part->type : "<none>", part->subtype ? part->subtype : "<none>"); /* /\* disposition *\/ */ color_maybe (MU_COLOR_MAGENTA); mu_util_print_encoded ("[%s]", disp_str(part->part_type)); /* size */ if (part->size > 0) { color_maybe (MU_COLOR_CYAN); g_print (" (%s)", mu_str_size_s (part->size)); } color_maybe (MU_COLOR_DEFAULT); fputs ("\n", stdout); }
static void match_filename_rx (MuMsg *msg, MuMsgPart *mpart, RxMatchData *mdata) { char *fname; fname = mu_msg_part_get_filename (mpart, FALSE); if (!fname) return; if (g_regex_match (mdata->_rx, fname, 0, NULL)) mdata->_lst = g_slist_prepend (mdata->_lst, GUINT_TO_POINTER(mpart->index)); g_free (fname); }
static void each_part (MuMsg *msg, MuMsgPart *part, gchar **attach) { char *fname, *tmp; if (!mu_msg_part_maybe_attachment (part)) return; fname = mu_msg_part_get_filename (part, FALSE); if (!fname) return; tmp = *attach; *attach = g_strdup_printf ("%s%s'%s'", *attach ? *attach : "", *attach ? ", " : "", fname); g_free (tmp); }
static void each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo) { char *name, *tmpfile; pinfo->bob = json_builder_begin_object(pinfo->bob); name = mu_msg_part_get_filename (part, TRUE); tmpfile = get_temp_file_maybe (msg, part, pinfo->opts); add_int_member (pinfo->bob, "index", part->index); add_string_member (pinfo->bob, "name", name); if (part->type && part->subtype) { char *mime_type = g_strdup_printf ("%s/%s", part->type, part->subtype); add_string_member (pinfo->bob, "mime-type", mime_type); g_free(mime_type); } add_string_member (pinfo->bob, "temp", tmpfile); add_part_type (pinfo->bob, part->part_type); if (mu_msg_part_maybe_attachment (part)) add_bool_member (pinfo->bob, "attachment", TRUE); add_string_member (pinfo->bob, "cid", mu_msg_part_get_content_id(part)); add_int_member (pinfo->bob, "size", part->size); add_part_crypto (pinfo->bob, part, pinfo); g_free (name); g_free (tmpfile); pinfo->bob = json_builder_end_object(pinfo->bob); }