Commit bdf39320 bdf393200a9cc7c04ae7b92be78a581681401e75 by Sergey Poznyakoff

(rfc2047_decode): Implemented charset recoding using iconv

1 parent df4fe98a
...@@ -69,7 +69,7 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr) ...@@ -69,7 +69,7 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr)
69 char *fromcode = NULL; 69 char *fromcode = NULL;
70 char *encoding_type = NULL; 70 char *encoding_type = NULL;
71 char *encoded_text = NULL; 71 char *encoded_text = NULL;
72 stream_t filter = NULL; 72 stream_t filter = NULL, cvt = NULL;
73 stream_t in_stream = NULL; 73 stream_t in_stream = NULL;
74 const char *filter_type = NULL; 74 const char *filter_type = NULL;
75 size_t nbytes = 0, size; 75 size_t nbytes = 0, size;
...@@ -116,19 +116,28 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr) ...@@ -116,19 +116,28 @@ rfc2047_decode (const char *tocode, const char *input, char **ptostr)
116 116
117 memory_stream_create (&in_stream, 0, 0); 117 memory_stream_create (&in_stream, 0, 0);
118 stream_write (in_stream, encoded_text, size, 0, NULL); 118 stream_write (in_stream, encoded_text, size, 0, NULL);
119 filter_create (&filter, in_stream, filter_type, MU_FILTER_DECODE, 119 status = filter_create (&filter, in_stream, filter_type,
120 MU_STREAM_READ); 120 MU_FILTER_DECODE, MU_STREAM_READ);
121 if (status != 0)
122 break;
121 123
122 while (stream_sequential_read (filter, buffer + bufpos, 124 status = filter_iconv_create (&cvt, filter, fromcode, tocode, 0);
125 if (status)
126 cvt = filter;
127 if (stream_open (cvt))
128 {
129 stream_destroy (cvt, stream_get_owner (cvt));
130 cvt = filter;
131 }
132 while (stream_sequential_read (cvt, buffer + bufpos,
123 bufsize - bufpos, 133 bufsize - bufpos,
124 &nbytes) == 0 && nbytes) 134 &nbytes) == 0 && nbytes)
125 { 135 {
126 /* FIXME: Need to convert character set */
127 bufpos += nbytes; 136 bufpos += nbytes;
128 } 137 }
129 138
130 stream_close (filter); 139 stream_close (cvt);
131 stream_destroy (&filter, stream_get_owner (filter)); 140 stream_destroy (&cvt, stream_get_owner (cvt));
132 141
133 fromstr = sp + 1; 142 fromstr = sp + 1;
134 run_count = 1; 143 run_count = 1;
......