+ if ((fp = fopen(file, "rb")) == NULL) {
+ FILE_OP_ERROR(file, "fopen");
+ return ENC_UNKNOWN;
+ }
+
+ while ((len = fread(buf, sizeof(gchar), sizeof(buf), fp)) > 0) {
+ guchar *p;
+ gint i;
+
+ for (p = buf, i = 0; i < len; p++, i++) {
+ if (*p & 0x80) {
+ fclose(fp);
+ return ENC_BASE64;
+ }
+ }
+ }
+
+ fclose(fp);
+ return ENC_7BIT;
+}
+
+struct EncodingTable
+{
+ gchar *str;
+ EncodingType enc_type;
+};
+
+struct EncodingTable encoding_table[] = {
+ {"7bit", ENC_7BIT},
+ {"8bit", ENC_8BIT},
+ {"binary", ENC_BINARY},
+ {"quoted-printable", ENC_QUOTED_PRINTABLE},
+ {"base64", ENC_BASE64},
+ {"x-uuencode", ENC_UNKNOWN},
+ {NULL, ENC_UNKNOWN},
+};
+
+const gchar *procmime_get_encoding_str(EncodingType encoding)
+{
+ struct EncodingTable *enc_table;
+
+ for (enc_table = encoding_table; enc_table->str != NULL; enc_table++) {
+ if (enc_table->enc_type == encoding)
+ return enc_table->str;
+ }
+ return NULL;