// Text & html message processing & formatting functions moved from sw_prcc to sam so can be used both from 
// surgeweb and iphone code


void prcc_set_imsg(int (*fn)(const char *, ...));
void prcc_set_tmpfile(char* (*fn)(void*,char *));

FILE *prcc_wash_fordisplay_text(void *d, FILE *f, int keep_open, char *flow_header);
FILE *prcc_save_part_as_msg(void *d, FILE *f, SwPart *part, char* raw, int rawsize);
FILE *prcc_save_data_to_msg(void *d, char* raw, int rawsize);


int prcc_snippet_from_text(char *out, int max, char *hdr_in, int hdr_len, char *body_in, int body_len, char *dbg_email, char *dbg_fld, int dbg_uid);
int prcc_snippet_from_file(char *out, FILE *f, int max);
int prcc_snippet_from_file_keepf(char *out, FILE *f, int max, int keepf);	// MAX chars wanted in output. NOT BFSZ!!  (out=BFSZ)
int prcc_clean_quoted(char *out, char *in, int max);

int sw_isreply_line(char *pin);
int sw_isreply_line2(char *pin);

int prcc_decode_content(SwPart *prt, char *content);
int prcc_decode_content2(Pair **pr, char *content);

int prcc_file_to_mem(FILE *f, char **bf, int *size);
int prcc_fname_to_mem(char *fname, char **bf, int *out_size);

FILE *prcc_extract_part(void *d, FILE *f, char *part, Pair**prt_hdrs, int decode, char *fout_name);
FILE *prcc_extract_part_keepf(void *d, FILE *f, char *part, Pair**prt_hdrs, int decode, char *fout_name, int keepf);

int prcc_parse_charset(char *content, char *res, int bfsz);

char *mystrtok_ex(char *start, char *toks, char **upto);
int prcc_addresses(Pair **rcpts, char *txt, int for_display);

FILE *prcc_mime_encode_qp(void *d, FILE *f, int *prcc);
FILE *prcc_base64_mime(void *d, FILE *f);


// Reflow processing ** begin **
typedef struct REFLOW{
	FILE *f2;
	char buf[BFSZ*2], *start, *end;
	int qdepth_last, qdepth_cur, qdepth_new;
	int too_wide;
	int has_crlf, has_crlf_last;
	int flowed_some;
} Reflow;
#define MAX_QUOTE_DEPTH 10
enum {REFLOW_FIXED,REFLOW_FLOWED,REFLOW_NOCRLF};
int prcc_reflow_output_qdepth(FILE *f, int depth);
int prcc_reflow_write_line(Reflow *ff, char *cur, int fixed);
int prcc_reflow_write_flush(Reflow *ff);
FILE *prcc_reflow(void *d, FILE *f, int *too_wide);
FILE *prcc_reflow_real(void *d, FILE *f, int *too_wide, int top_level_unflowed);
// Reflow processing ** end **

int prcc_count_chars(FILE *f, int *total, int *high);
FILE *prcc_web_cleanup(void *d, FILE *f);
FILE *prcc_msg_to_ical(void *d, FILE *f);
FILE *prcc_msg_to_ical_raw(void *d, FILE *f, int close);

