Patch: Elm ME+ 2.5 PLalpha62 -> Elm ME+ 2.5 PLalpha63 [6/7] (2/5)
From
Kari Hurtta@21:1/5 to
All on Wed Jan 3 13:53:20 2024
[continued from previous message]
+ return ret;
+ }
+
+ /* enriched ------------------------------ */
+
+ struct tagfilter_tags text_enriched_tags = {
+ TAGFILTER_TAGS_magic,
+
+ "text/enriched tags",
+
+ &(tagfilter_enriched_cmds[0]),
+ NULL
+ };
+
+ E_(give_top_stack_item_f give_top_text_enriched)
+ struct tagfilter_stack_item * give_top_text_enriched
+ P_((mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ const struct decode_opts * decode_opt,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ struct tagfilter_stack_item * give_top_text_enriched(body,state_in,state_out, + decode_opt,text_charset,tagfilter)
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ const struct decode_opts * decode_opt;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+ struct tagfilter_stack_item * ret = NULL;
+ struct pager_range * enriched_body_range = NULL;
+
+ if (MIME_magic != body->magic)
+ mime_panic(__FILE__,__LINE__,"give_top_text_enriched",
+ "Bad magic number (mime_t)");
+
+ if (decode_opt)
+ enriched_body_range =
+ state_add_simple_pager_range(state_out,
+ /* Handles quote prefix */
+ decode_opt->range,
+ PR_WORD_WRAP|PR_JOIN_LINES|
+ PR_ADD_SPACE,0,0);
+ else
+ enriched_body_range =
+ state_add_simple_pager_range(state_out,
+ NULL,
+ PR_WORD_WRAP|PR_JOIN_LINES|
+ PR_ADD_SPACE,0,0);
+
+ ret = tagfilter_new_stack_item(enriched_body_range,
+ 0,
+ &text_enriched_tags,
+ NULL);
+
+ if (TAGFILTER_STACK_ITEM_magic != ret->magic)
+ mime_panic(__FILE__,__LINE__,"give_top_text_enriched",
+ "Bad magic number (tagfilter_stack_item)");
+
+ free_pager_range(&enriched_body_range);
+
+ return ret;
+ }
+
+ static struct pager_range * give_prev_range
+ P_((struct tagfilter_stack_item **stack,
+ size_t stack_len,
+ int * inherit_pg_flags_p,
+ int * text_visible_p
+ ));
+ static struct pager_range * give_prev_range(stack,stack_len,
+ inherit_pg_flags_p,
+ text_visible_p)
+ struct tagfilter_stack_item ** stack;
+ size_t stack_len;
+ int * inherit_pg_flags_p;
+ int * text_visible_p;
+ {
+ struct pager_range * prev_range = NULL;
+
+ if (stack && stack_len > 0) {
+ size_t i = stack_len;
+
+ int is_reset = 0;
+
+ while (i > 0) {
+ i--;
+
+ if (stack[i]) {
+ if (TAGFILTER_STACK_ITEM_magic != stack[i]->magic)
+ mime_panic(__FILE__,__LINE__,
+ "give_prev_range",
+ "Bad magic number (tagfilter_stack_item)");
+ if (! prev_range)
+ prev_range = stack[i]->range;
+
+ if (! is_reset && inherit_pg_flags_p)
+ *inherit_pg_flags_p |= stack[i]->pg_flags;
+
+ if (stack[i]->reset_pg_flags)
+ is_reset = 1;
+
+ if (prev_range && is_reset)
+ break;
+ if (prev_range && ! inherit_pg_flags_p)
+ break;
+ }
+ }
+
+ if (TAGFILTER_STACK_ITEM_magic != stack[stack_len-1]->magic)
+ mime_panic(__FILE__,__LINE__,
+ "give_prev_range",
+ "Bad magic number (tagfilter_stack_item)");
+
+ if (text_visible_p)
+ *text_visible_p = stack[stack_len-1]->text_visible;
+
+ }
+
+ return prev_range;
+ }
+
+
+
+ E_(give_stack_item_f give_item_text_enriched)
+ struct tagfilter_tag_state *
+ give_item_text_enriched P_((struct tagfilter_stack_item **new_item,
+ struct tagfilter_tags * tags,
+ struct string * tag_name,
+ struct tagfilter_stack_item **stack,
+ size_t stack_len,
+ size_t * stack_pos,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ const struct decode_opts * decode_opt,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter,
+ struct tagfilter_global * counter));
+ struct tagfilter_tag_state *give_item_text_enriched(new_item,tags,
+ tag_name,
+ stack,stack_len,
+ stack_pos,
+ body,state_in,
+ state_out,
+ decode_opt,
+ text_charset,
+ tagfilter,
+ counter)
+ struct tagfilter_stack_item **new_item;
+ struct tagfilter_tags * tags;
+ struct string * tag_name;
+ struct tagfilter_stack_item **stack;
+ size_t stack_len;
+ size_t * stack_pos;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ const struct decode_opts * decode_opt;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ struct tagfilter_global * counter;
+ {
+
+ struct tagfilter_cmd * current_tag = NULL;
+ struct tagfilter_tag_state * ret = NULL;
+
+ int text_visible = 1;
+
+ /* Allocates new tagfilter_tag_state
+ (also NULL return possible) --
+ gives struct tagfilter_stack_item if
+ push_stack_item() needs not be used */
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"give_item_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+ if (new_item && *new_item)
+ tagfilter_free_stack_item(new_item,tagfilter);
+
+ * stack_pos = stack_len;
+
+ if (tags) {
+ struct pager_range * prev_range =
+ give_prev_range(stack,
+ stack_len,
+ NULL,
+ & text_visible
+ );
+ struct pager_range * new_range = NULL;
+
+ if (TAGFILTER_TAGS_magic != tags->magic)
+ mime_panic(__FILE__,__LINE__,"give_item_text_enriched",
+ "Bad magic number (tagfilter_tags)");
+
+ if (tag_name)
+ current_tag = locate_command(tags,tag_name,tagfilter);
+
+ /* <ParaIndent> command requires <param>
+ and is not now supported
+ */
+
+ if (current_tag) {
+
+ if (TAGFILTER_CMD_magic != current_tag->magic)
+ mime_panic(__FILE__,__LINE__,"give_item_text_enriched",
+ "Bad magic number (tagfilter_cmd)");
+
+ if (text_visible && ison(current_tag->cmd_mode,
+ TAGFLT_CMD_hide_text))
+ text_visible = 0;
+ else if (ison(current_tag->cmd_mode,
+ TAGFLT_CMD_show_text))
+ text_visible = 1;
+
+ switch (current_tag->code.enriched) {
+
+ case tfc_enriched_unsupported:
+
+
+ tagfilter_add_unknown_tag(counter,current_tag,tagfilter);
+
+ break;
+
+ case tfc_enriched_none: break;
+
+ case tfc_center:
+
+ /* Print new pager range
+
+ quote level, range flags, indent are automatically
+ incremented with prev_range
+
+ */
+
+ new_range = state_add_simple_pager_range(state_out,
+ prev_range,
+ /* Not work very well */
+ PR_CENTER_THIS,
+ 0 /* quote level */,
+ 0 /* indent */);
+
+ break;
+
+ case tfc_nojoin: {
+
+ /* Calculate absolute range flags */
+ int range_flags = PR_FLAGS_ABSOLUTE;
+
+ if (prev_range)
+ setit(range_flags,get_pager_range_flags(prev_range));
+ clearit(range_flags,PR_JOIN_LINES);
+ clearit(range_flags,PR_ADD_SPACE);
+ clearit(range_flags,PR_SAME_LINE);
+
+
+ new_range = state_add_simple_pager_range(state_out,
+ prev_range,
+ range_flags,
+ 0,
+ 0);
+ }
+ break;
+
+ case tfc_quote:
+
+ /* Print new pager range
+
+ quote level, range flags, indent are automatically
+ incremented with prev_range
+
+ */
+
+ new_range = state_add_simple_pager_range(state_out,
+ prev_range,
+ 0 /* range flags */,
+ 1 /* quote level */,
+ 0 /* indent */);
+ break;
+ }
+
+
+ if (!new_range &&
+ ison(current_tag->cmd_mode,TAGFLT_CMD_force_newline)) {
+
+ DPRINT(Debug,21,(&Debug,
+ "give_item_text_enriched: %S -- TAGFLT_CMD_force_newline set, forcing new range\n",
+ tag_name));
+
+ new_range = state_add_simple_pager_range(state_out,
+ prev_range,
+ 0,0,0);
+
+ }
+
+ if (new_item) {
+
+ DPRINT(Debug,21,(&Debug,
+ "give_item_text_enriched: %S pg_flags %d %s\n",
+ tag_name,current_tag->pg_flags,
+ give_pg_flags(current_tag->pg_flags)));
+
+ *new_item =
+ tagfilter_new_stack_item(new_range,
+ current_tag->pg_flags,
+ tags /* PASSTRU for enriched */,
+ current_tag);
+
+ if (TAGFILTER_STACK_ITEM_magic != (*new_item)->magic)
+ mime_panic(__FILE__,__LINE__,"give_item_text_enriched",
+ "Bad magic number (tagfilter_stack_item)");
+
+ (*new_item)->text_visible = text_visible;
+ }
+
+ switch (current_tag->code.enriched) {
+ case tfc_enriched_unsupported:
+ case tfc_enriched_none: break;
+
+
+ case tfc_center:
+ break;
+
+ case tfc_nojoin:
+ break;
+
+ case tfc_quote:
+ break;
+ }
+
+ if (new_range)
+ free_pager_range(& new_range);
+
+ }
+ } else {
+ if (tag_name) {
+ DPRINT(Debug,21,(&Debug,
+ "give_item_text_enriched: %S - no tags\n",
+ tag_name));
+ }
+ }
+
+ if (!current_tag && tag_name) {
+ struct pager_range * prev_range UNUSED_VAROK =
+ give_prev_range(stack,
+ stack_len,
+ NULL,
+ & text_visible
+ );
+ if (counter)
+ current_tag = tagfilter_give_unknown_tag(counter,tag_name,
+ tagfilter,
+ tfc_unsupported,0
+ );
+
+ if (!current_tag)
+ current_tag = tagfilter_cmd_from_string(tag_name,
+ tfc_unsupported,0);
+
+
+ if (TAGFILTER_CMD_magic != current_tag->magic)
+ mime_panic(__FILE__,__LINE__,"give_item_text_enriched",
+ "Bad magic number (tagfilter_cmd)");
+
+ if (new_item) {
+
+ DPRINT(Debug,21,(&Debug,
+ "give_item_text_enriched: %S pg_flags %d %s\n",
+ tag_name,current_tag->pg_flags,
+ give_pg_flags(current_tag->pg_flags)));
+
+ *new_item =
+ tagfilter_new_stack_item(NULL,
+ current_tag->pg_flags,
+ tags /* PASHTRU for enriched */,
+ current_tag);
+
+ if (TAGFILTER_STACK_ITEM_magic != (*new_item)->magic)
+ mime_panic(__FILE__,__LINE__,"give_item_text_enriched",
+ "Bad magic number (tagfilter_stack_item)");
+
+ (*new_item)->text_visible = text_visible;
+ }
+ }
+
+ if (current_tag)
+ ret = tagfilter_new_tag_state(current_tag);
+
+ if (new_item && *new_item && current_tag) {
+ if (TAGFILTER_STACK_ITEM_magic != (*new_item)->magic)
+ mime_panic(__FILE__,__LINE__,"give_item_text_enriched",
+ "Bad magic number ( tagfilter_stack_item)");
+ if (TAGFILTER_CMD_magic != current_tag->magic)
+ mime_panic(__FILE__,__LINE__,"give_item_text_enriched",
+ "Bad magic number (tagfilter_cmd)");
+
+ (*new_item)->force_eoln =
+ ison(current_tag->cmd_mode,TAGFLT_CMD_force_newline);
+
+ }
+
+ if (current_tag)
+ tagfilter_release_cmd(& current_tag);
+
+ return ret;
+
+ }
+
+ static struct tagfilter_tag_state * tagfilter_locate_stack_item
+ P_((struct tagfilter_selection * tagfilter,
+ struct string_sort ** res_tag_name_X,
+ struct string * tag_name,
+ struct tagfilter_stack_item **stack,
+ size_t stack_len,
+ size_t * stack_pos));
+ static struct tagfilter_tag_state *
+ tagfilter_locate_stack_item(tagfilter,res_tag_name_X,
+ tag_name,stack,stack_len,stack_pos)
+ struct tagfilter_selection * tagfilter;
+ struct string_sort ** res_tag_name_X;
+ struct string * tag_name;
+ struct tagfilter_stack_item ** stack;
+ size_t stack_len;
+ size_t * stack_pos;
+ {
+ struct tagfilter_tag_state * ret = NULL;
+ struct string_sort * tag_name_X = * res_tag_name_X;
+ int ignore_case = 0;
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"tagfilter_locate_stack_item",
+ "Bad magic number (tagfilter_selection)");
+
+ ignore_case = ison(tagfilter->tagflt_mode,TAGFLT_MODE_lowerascii);
+
+ * stack_pos = stack_len;
+
+ if (tag_name && stack && stack_len > 0) {
+ size_t i = stack_len;
+
+ while (i > 0) {
+ i--;
+
+ if (stack[i]) {
+ if (TAGFILTER_STACK_ITEM_magic != stack[i]->magic)
+ mime_panic(__FILE__,__LINE__,
+ "tagfilter_locate_stack_item",
+ "Bad magic number (tagfilter_stack_item)");
+
+ if (stack[i]->current_tag) {
+ struct tagfilter_cmd *cmd;
+
+ if (TAGFILTER_CMD_magic !=
+ stack[i]->current_tag->magic)
+ mime_panic(__FILE__,__LINE__,
+ "tagfilter_locate_stack_item",
+ "Bad magic number (tagfilter_cmd)");
+
+ cmd = stack[i]->current_tag;
+
+ if (cmd->ascii_command) {
+ if (string_matches_ascii(tag_name,
+ s2us(cmd->ascii_command),
+ ignore_case ? SMA_ignore_case : 0,
+ SMA_op_normal)) {
+
+ * stack_pos = i;
+ ret = tagfilter_new_tag_state(cmd);
+
+ break;
+ }
+
+ } else if (cmd->string_command) {
+
+ /* Increments refcount and shares string! */
+ if (!tag_name_X)
+ tag_name_X = new_string_sort(tag_name);
+
+ if (0 == string_sort_cmp(cmd->string_command,
+ tag_name_X)) {
+
+ * stack_pos = i;
+ ret = tagfilter_new_tag_state(cmd);
+
+ break;
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+
+ * res_tag_name_X = tag_name_X ;
+
+ return ret;
+ }
+
+
+ E_(locate_stack_item_f locate_item_text_enriched)
+ struct tagfilter_tag_state *
+ locate_item_text_enriched P_((struct string * tag_name,
+ struct tagfilter_stack_item **stack,
+ size_t stack_len,
+ size_t * stack_pos
+ /* or stack_len if not found */,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ struct tagfilter_tag_state * locate_item_text_enriched(tag_name,
+ stack,stack_len,
+ stack_pos,body,
+ state_in,state_out,
+ text_charset,tagfilter) + struct string * tag_name;
+ struct tagfilter_stack_item **stack;
+ size_t stack_len;
+ size_t * stack_pos
+ /* or stack_len if not found */;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+ /* Allocates new tagfilter_tag_state
+ (also NULL return possible) */
+
+ struct tagfilter_tag_state * ret = NULL;
+
+ struct string_sort * tag_name_X = NULL; /* Possible lowercased
+ already
+ */
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"locate_item_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+ ret = tagfilter_locate_stack_item(tagfilter,
+ &tag_name_X,
+ tag_name,
+ stack,stack_len,stack_pos);
+
+ if (tag_name_X)
+ free_string_sort(& tag_name_X);
+
+
+ return ret;
+
+ }
+
+ E_(end_tag_state_f end_tag_text_enriched)
+ void end_tag_text_enriched P_((struct tagfilter_tag_state **tag_state,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ void end_tag_text_enriched(tag_state,body,state_in,state_out,text_charset,tagfilter)
+ struct tagfilter_tag_state **tag_state;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"end_tag_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+
+ if (TAGFILTER_TAG_STATE_magic != (*tag_state)->magic)
+ mime_panic(__FILE__,__LINE__,"end_tag_text_enriched",
+ "Bad magic number (tagfilter_tag_state)");
+
+ /* Free enriched specific parts */
+ if ((*tag_state)->u.dummy) {
+
+ DPRINT(Debug,1,(&Debug,
+ "end_tag_text_enriched: (*tag_state)->u.dummy is not NULL\n"));
+ }
+ tagfilter_free_tag_state_common (tag_state);
+ }
+
+ E_(push_stack_item_f push_tag_text_enriched)
+ struct tagfilter_stack_item *
+ push_tag_text_enriched P_((struct tagfilter_tag_state *tag_state,
+ struct tagfilter_stack_item **stack,
+ size_t stack_len,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ const struct decode_opts * decode_opt,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ struct tagfilter_stack_item *push_tag_text_enriched(tag_state,stack, stack_len,
+ body,state_in,state_out,
+ decode_opt,
+ text_charset,tagfilter)
+ struct tagfilter_tag_state *tag_state;
+ struct tagfilter_stack_item **stack;
+ size_t stack_len;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ const struct decode_opts * decode_opt;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"push_tag_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+
+ if (TAGFILTER_TAG_STATE_magic != tag_state->magic)
+ mime_panic(__FILE__,__LINE__,"push_tag_text_enriched",
+ "Bad magic number (tagfilter_tag_state)");
+
+
+ /* No implicit stack items now */
+
+ return NULL;
+ }
+
+ E_(close_stack_item_f close_tag_text_enriched)
+ int close_tag_text_enriched P_((struct tagfilter_tag_state *tag_state,
+ struct tagfilter_stack_item **stack,
+ size_t stack_len,
+ size_t idx,
+ enum stack_close_mode close_pos,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ int close_tag_text_enriched(tag_state,stack,stack_len,idx,close_pos,
+ body,state_in,state_out,text_charset,
+ tagfilter)
+ struct tagfilter_tag_state *tag_state;
+ struct tagfilter_stack_item **stack;
+ size_t stack_len;
+ size_t idx;
+ enum stack_close_mode close_pos;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+
+ /* tagfilter_free_stack_item() is called by caller -
+ return 1 (or true) if item need to be free'ed
+ */
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"close_tag_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+
+ if (TAGFILTER_TAG_STATE_magic != tag_state->magic)
+ mime_panic(__FILE__,__LINE__,"close_tag_text_enriched",
+ "Bad magic number (tagfilter_tag_state)");
+
+
+ /* Nothing to do */
+
+ return 1;
+ }
+
+ E_(start_attribute_f start_atr_text_enriched)
+ struct tagfilter_atr_state *
+ start_atr_text_enriched P_((struct string * atr_name,
+ struct tagfilter_tag_state * tag_state,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ struct tagfilter_atr_state *start_atr_text_enriched(atr_name,tag_state,
+ body,state_in,
+ state_out,
+ text_charset,
+ tagfilter)
+ struct string * atr_name;
+ struct tagfilter_tag_state * tag_state;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"start_atr_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+ if (TAGFILTER_TAG_STATE_magic != tag_state->magic)
+ mime_panic(__FILE__,__LINE__,"start_atr_text_enriched",
+ "Bad magic number (tagfilter_tag_state)");
+
+
+ /* text/enriched do not have attributes */
+
+ return NULL;
+ }
+
+ E_(end_attribute_f end_atr_text_enriched)
+ void end_atr_text_enriched P_((struct tagfilter_atr_state **atr_state,
+ struct tagfilter_tag_state * tag_state,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ void end_atr_text_enriched(atr_state,tag_state,body,state_in,state_out,
+ text_charset,tagfilter)
+ struct tagfilter_atr_state **atr_state;
+ struct tagfilter_tag_state * tag_state;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"end_atr_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+ if (TAGFILTER_TAG_STATE_magic != tag_state->magic)
+ mime_panic(__FILE__,__LINE__,"end_atr_text_enriched",
+ "Bad magic number (tagfilter_tag_state)");
+
+
+ /* text/enriched do not have attributes */
+
+
+ free(atr_state);
+ *atr_state = NULL;
+ }
+
+ E_(start_end_atrvalue_f start_end_atrval_text_enriched)
+ void start_end_atrval_text_enriched
+ P_((struct tagfilter_atr_state * atr_state,
+ enum atrvalue_start_end start_end,
+ struct tagfilter_tag_state * tag_state,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ void start_end_atrval_text_enriched(atr_state,start_end,tag_state,
+ body,state_in,state_out,
+ text_charset,tagfilter)
+ struct tagfilter_atr_state * atr_state;
+ enum atrvalue_start_end start_end;
+ struct tagfilter_tag_state * tag_state;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"start_end_atrval_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+ if (TAGFILTER_TAG_STATE_magic != tag_state->magic)
+ mime_panic(__FILE__,__LINE__,"start_end_atrval_text_enriched",
+ "Bad magic number (tagfilter_tag_state)");
+
+
+ /* text/enriched do not have attributes */
+
+ }
+
+ E_(atrvalue_seg_string_f atrvalue_seg_str_text_enriched)
+ void atrvalue_seg_str_text_enriched
+ P_((struct tagfilter_atr_state * atr_state,
+ struct string * atr_value_segment,
+ struct tagfilter_tag_state * tag_state,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ void atrvalue_seg_str_text_enriched(atr_state,atr_value_segment,
+ tag_state,body,state_in,
+ state_out,text_charset,tagfilter)
+ struct tagfilter_atr_state * atr_state;
+ struct string * atr_value_segment;
+ struct tagfilter_tag_state * tag_state;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"atrvalue_seg_str_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+ if (TAGFILTER_TAG_STATE_magic != tag_state->magic)
+ mime_panic(__FILE__,__LINE__,"atrvalue_seg_str_text_enriched",
+ "Bad magic number (tagfilter_tag_state)");
+
+ /* text/enriched do not have attributes */
+ }
+
+ E_(atrvalue_seg_ent_f atrvalue_seg_ent_text_enriched)
+ void atrvalue_seg_ent_text_enriched
+ P_((struct tagfilter_atr_state * atr_state,
+ struct out_entity * atr_value_segment,
+ struct tagfilter_tag_state * tag_state,
+ mime_t * body,
+ struct in_state * state_in,
+ struct out_state * state_out,
+ charset_t text_charset,
+ struct tagfilter_selection * tagfilter));
+ void atrvalue_seg_ent_text_enriched(atr_state,atr_value_segment,
+ tag_state,body,state_in,state_out,
+ text_charset,tagfilter)
+ struct tagfilter_atr_state * atr_state;
+ struct out_entity * atr_value_segment;
+ struct tagfilter_tag_state * tag_state;
+ mime_t * body;
+ struct in_state * state_in;
+ struct out_state * state_out;
+ charset_t text_charset;
+ struct tagfilter_selection * tagfilter;
+ {
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"atrvalue_seg_ent_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+ if (TAGFILTER_TAG_STATE_magic != tag_state->magic)
+ mime_panic(__FILE__,__LINE__,"atrvalue_seg_ent_text_enriched",
+ "Bad magic number (tagfilter_tag_state)");
+
+ /* text/enriched do not have attributes */
+ }
+
+ E_(stack_item_clear_f stack_item_clear_text_enriched)
+ void stack_item_clear_text_enriched
+ P_((struct tagfilter_stack_item * item,
+ struct tagfilter_selection * tagfilter));
+ void stack_item_clear_text_enriched(item,tagfilter)
+ struct tagfilter_stack_item * item;
+ struct tagfilter_selection * tagfilter;
+ {
+ if (TAGFILTER_STACK_ITEM_magic != item->magic)
+ mime_panic(__FILE__,__LINE__,
+ "stack_item_clear_text_enriched",
+ "Bad magic number (tagfilter_stack_item)");
+
+ if (TAGFILTER_SELECTION_magic != tagfilter->magic)
+ mime_panic(__FILE__,__LINE__,"stack_item_clear_text_enriched",
+ "Bad magic number (tagfilter_selection)");
+
+ /* Nothing to clear */
+
+ }
+
+
+ /* html ------------------------------------ */
+
+ #define TAGFILTER_HTML_STATE_magic 0xFD19
+
+ static struct tagfilter_html_state {
+ unsigned short magic;
+
+ struct tagfilter_push_tag {
+ struct tagfilter_cmd * cmd;
+ struct tagfilter_tags * used_tags; /* static */
+ } * push_tag;
+
+ int push_tag_len;
+
+ } * tagfilter_new_html_state P_((void));
+ static struct tagfilter_html_state * tagfilter_new_html_state()
+ {
+ struct tagfilter_html_state * ret =
+ safe_zero_alloc(sizeof (*ret));
+
+ ret->push_tag = NULL;
+ ret->push_tag_len = 0;
+
+ ret->magic = TAGFILTER_HTML_STATE_magic;
+ return ret;
+ }
+
+ static void tagfilter_free_html_state P_((struct tagfilter_html_state **ptr));
+ static void tagfilter_free_html_state(ptr)
+ struct tagfilter_html_state **ptr;
+ {
+ if (TAGFILTER_HTML_STATE_magic != (*ptr)->magic)
+ mime_panic(__FILE__,__LINE__,"tagfilter_free_html_state",
+ "Bad magic number (tagfilter_selection)");
+
+ if ((*ptr)->push_tag) {
+ int i;
+
+ for (i = 0; i < (*ptr)->push_tag_len; i++) {
+ if ((*ptr)->push_tag[i].cmd)
+ tagfilter_release_cmd(& ((*ptr)->push_tag[i].cmd));
+ (*ptr)->push_tag[i].used_tags = 0;
+ }
+
+ free((*ptr)->push_tag);
+ (*ptr)->push_tag = NULL;
+ }
+ (*ptr)->push_tag_len = 0;
+
+ free(*ptr);
+ *ptr = NULL;
+ }
+
+ static void tagfilter_html_state_push_command
+ P_((struct tagfilter_html_state * html_state,
+ struct tagfilter_cmd * cmd,
+ struct tagfilter_tags * used_tags
+ ));
+ static void tagfilter_html_state_push_command(html_state,cmd,used_tags)
+ struct tagfilter_html_state * html_state;
+ struct tagfilter_cmd * cmd;
+ struct tagfilter_tags * used_tags;
+ {
+ if (TAGFILTER_HTML_STATE_magic != html_state->magic)
+ mime_panic(__FILE__,__LINE__,
+ "tagfilter_html_state_push_command",
+ "Bad magic number (tagfilter_selection)");
+
+ if (TAGFILTER_CMD_magic != cmd->magic)
+ mime_panic(__FILE__,__LINE__,
+ "tagfilter_html_state_push_command",
+ "Bad magic number (tagfilter_cmd)");
+
+ html_state->push_tag =
+ safe_array_realloc(html_state->push_tag,
+ html_state->push_tag_len+1,
+ sizeof (html_state->push_tag[0]));
+
+ html_state->push_tag[html_state->push_tag_len].cmd = cmd;
+ tagfilter_inc_cmd_refcount(html_state->
+ push_tag[html_state->push_tag_len].cmd);
+ html_state->push_tag[html_state->push_tag_len].used_tags =
+ used_tags;
+
+ html_state->push_tag_len++;
+ }
+
+ struct tagfilter_tags text_html_top = { /* <html> .... </html> */
+ TAGFILTER_TAGS_magic,
+
+ "text/html document root",
+
+ &(tagfilter_html_top[0]),
+ NULL
+ };
+ struct tagfilter_tags text_html_head_body = {
+ TAGFILTER_TAGS_magic,
+
+ "text/html head and body",
+
+ &(tagfilter_html_head_body[0]),
+ NULL
+ };
+ struct tagfilter_tags text_html_metadata = {
+ TAGFILTER_TAGS_magic,
+
+ "text/html metadata",
+
+ &(tagfilter_html_metadata[0]),
+ NULL
+ };
+ struct tagfilter_tags text_html_flow = {
+ TAGFILTER_TAGS_magic,
+
+ "text/html flow content",
+
+ &(tagfilter_html_flow[0]),
+ NULL
+ };
+
+ struct tagfilter_tags text_html_phrasing = {
+ TAGFILTER_TAGS_magic,
+
+ "text/html phrasing content",
+
+ &(tagfilter_html_phrasing[0]),
+ NULL
+ };
+
+
+ struct tagfilter_tags text_html_close_head = {
+ /* Not really working */
+ TAGFILTER_TAGS_magic,
+
+ "text/html closing tags for <head>",
+
+ &(tagfilter_html_close_head[0]),
+ NULL
+ };
+
[continued in next message]
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)