- W segsize;
- TC ch, lang = 0xFE21, nest = 0;
- UB segid, *data;
- LTADSEG *seg;
- taditerator_t iterator;
- TADITERATOR_RESULT_T result;
- TC header_from[] = {TK_F, TK_R, TK_O, TK_M, TK_COLN, TNULL};
- TC header_mail[] = {TK_m, TK_a, TK_i, TK_l, TK_COLN, TNULL};
- W read_fieldname_index = 0;
- UB chratio_seg[] = {0xA2, 0xFF, 0x06, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00};
- W chratio_seg_len = sizeof(chratio_seg);
- Bool is_hankaku = False, is_chratio;
- RATIO w_ratio;
- W ratio_a, ratio_b;
- enum {
- SEARCH_HEADER,
- SKIP_HEADER,
- READ_HEADER_FIELDNAME_FROM,
- READ_HEADER_FIELDVALUE_FROM,
- READ_HEADER_FIELDNAME_mail,
- READ_HEADER_FIELDVALUE_mail,
- READ_VALUE_MESSAGE
- } state = SEARCH_HEADER;
-
- taditerator_initialize(&iterator, str, len);
- for (;;) {
- result = taditerator_next(&iterator, NULL, &ch, &seg, &segsize, &data);
- if (result == TADITERATOR_RESULT_SEGMENT) {
- segid = ch;
-
- if ((segid == TS_TEXT)||(segid == TS_FIG)) {
- nest++;
- } else if ((segid == TS_TEXTEND)||(segid == TS_FIGEND)) {
- nest--;
- }
-
- is_chratio = is_chratio_fusen(seg, &w_ratio);
- if (is_chratio == True) {
- memcpy(chratio_seg, seg, chratio_seg_len);
- ratio_a = w_ratio >> 8;
- ratio_b = w_ratio & 0xFF;
- if ((ratio_a * 2 > ratio_b)||(ratio_b == 0)) {
- is_hankaku = False;
- } else {
- is_hankaku = True;
- }
- switch (state) {
- case READ_HEADER_FIELDVALUE_FROM:
- postresdata_appendstring(&(post->from), &(post->from_len), (TC*)chratio_seg, chratio_seg_len/sizeof(TC));
- break;
- case READ_HEADER_FIELDVALUE_mail:
- postresdata_appendstring(&(post->mail), &(post->mail_len), (TC*)chratio_seg, chratio_seg_len/sizeof(TC));
- break;
- case READ_VALUE_MESSAGE:
- postresdata_appendstring(&(post->message), &(post->message_len), (TC*)chratio_seg, chratio_seg_len/sizeof(TC));
- break;
- case SEARCH_HEADER:
- case SKIP_HEADER:
- case READ_HEADER_FIELDNAME_FROM:
- case READ_HEADER_FIELDNAME_mail:
- default:
- break;
- }
- }
- } else if (result == TADITERATOR_RESULT_CHARCTOR) {
- if (nest > 1) {
- continue;
- }