Esempio n. 1
0
static void show_part(const char *ptr, size_t cnt)
{
	unicode_char *uc;
	size_t ucsize;
	int conv_err;

	if (libmail_u_convert_tou_tobuf(ptr, cnt,
					sqwebmail_content_charset,
					&uc,
					&ucsize,
					&conv_err) == 0)
	{
		if (conv_err)
		{
			free(uc);
			uc=NULL;
		}
	}


	if (uc)
	{

		struct filter_info info;

		filter_start(&info, sqwebmail_content_charset,
			     &showfunc, NULL);
		filter(&info, uc, ucsize);
		filter_end(&info);

		free(uc);
	}
}
Esempio n. 2
0
std::vector<std::string>
getRequiredTags( const Context& context, const std::string& pattern )
{
    std::string prefix = context.tag() + ".Requires.";
    std::vector<std::string> tags = getFieldsForPrefix( context, prefix );

    if ( !pattern.empty() )
        filter_start( tags, pattern );

    return tags;
}
Esempio n. 3
0
File: newmsg.c Progetto: zixia/wmail
static void show_preview(const char *filename)
{
char	*header, *value;
struct	rfc2045	*rfcp;
FILE	*fp;
int	fd;

	fp=0;
	fd=maildir_safeopen(filename, O_RDONLY, 0);
	if (fd >= 0)
		if ((fp=fdopen(fd, "r")) == 0)
			close(fd);

	if (!fp)	return;

	while ((header=maildir_readheader(fp, &value, 1)) != 0)
	{
		/* Don't show X-, From, and Content- headers in preview */

		if (strncmp(header, "x-", 2) == 0)	continue;
		if (strcmp(header, "mime-version") == 0)	continue;
		if (strncmp(header, "content-", 8) == 0)	continue;

		printf("%c", toupper(*header));
		output_attrencoded_oknl(header+1);
		printf(": ");

		value=rfc2047_decode_enhanced(value, sqwebmail_content_charset);
		if (value)
		{
			output_attrencoded_oknl(value);
			free(value);
		}
		printf("\n");
	}
	printf("\n");

	rfcp=rfc2045_fromfp(fp);
	if (!rfcp)	return;

	filter_start(FILTER_FOR_PREVIEW, &preview_show_func_s);
	{
		struct rfc2045 *q=
			rfc2045_searchcontenttype(rfcp, "text/plain");

		if (q)
			rfc2045_decodemimesection(fileno(fp), q,
						  &filter_stub, NULL);
	}
	rfc2045_free(rfcp);
	filter_end();
}
Esempio n. 4
0
char *
filter_uid(char *uid)
{
	if (uid == (char *)0)
		return 0;

	if (!filter_start(&filter)  ||
	    !stralloc_copys(&filter,"(") ||
	    !stralloc_cats(&filter, LDAP_UID) ||
	    !stralloc_cats(&filter, "=") ||
	    !filter_escape(&filter, uid, str_len(uid)) ||
	    !stralloc_cats(&filter, ")") ||
	    !filter_end(&filter))
		return (char *)0;

	return filter.s;
}
Esempio n. 5
0
void spell_show()
{
const char *draftmessage=cgi("draftmessage");
struct ispell_misspelled *msp;
struct ispell_suggestion *isps;
size_t	p, l=strlen(ispellline), n;
const char *ignorelab=getarg("IGNORE");
const char *ignorealllab=getarg("IGNOREALL");
const char *replacelab=getarg("REPLACE");
const char *replacealllab=getarg("REPLACEALL");
const char *insertlab=getarg("INSERT");
const char *continuelab=getarg("CONTINUE");
const char *finishlab=getarg("FINISH");

	if (!ispellptr)	enomem();

	if (!ignorelab)		ignorelab="";
	if (!ignorealllab)	ignorealllab="";
	if (!replacelab)	replacelab="";
	if (!replacealllab)	replacealllab="";
	if (!continuelab)	continuelab="";
	if (!finishlab)		finishlab="";

	for (msp=ispellptr->first_misspelled; msp; msp=msp->next)
		if (msp->misspelled_word)	break;
	if (!msp)	enomem();

	CHECKFILENAME(draftmessage);

	printf("<INPUT TYPE=HIDDEN NAME=form VALUE=\"spellchk\">\n");
	printf("<INPUT TYPE=HIDDEN NAME=pos VALUE=\"%s\">\n", cgi("pos"));
	if (*cgi("globignore"))
	{
		printf("<INPUT TYPE=HIDDEN NAME=globignore VALUE=\"");
		output_attrencoded(cgi("globignore"));
		printf("\">\n");
	}
	if (*cgi("globreplace"))
	{
		printf("<INPUT TYPE=HIDDEN NAME=globreplace VALUE=\"");
		output_attrencoded(cgi("globreplace"));
		printf("\">\n");
	}

	printf("<INPUT TYPE=HIDDEN NAME=draftmessage VALUE=\"");
	output_attrencoded(draftmessage);
	printf("\">");
	printf("<INPUT TYPE=HIDDEN NAME=row VALUE=\"%u\"><INPUT TYPE=HIDDEN NAME=col VALUE=\"%u\"><INPUT TYPE=HIDDEN NAME=word VALUE=\"",
		(unsigned)paragraph,
		(unsigned)msp->word_pos);
	output_attrencoded(msp->misspelled_word);

	printf("\"><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=1 "
	       "CLASS=\"box-small-outer\"><TR><TD>");
	printf("<TABLE BORDER=0 CELLSPACING=0 CLASS=\"spellcheck-background\"><TR><TD>");

	printf("<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=8 CLASS=\"spellcheck-excerpt\"><TR><TD ALIGN=CENTER><TT><FONT COLOR=\"#000000\" class=\"spellcheck-excerpt\">");

	if (msp->word_pos > 30)
	{
		p=msp->word_pos-30;
		for (n=p; n<msp->word_pos; n++)
			if (ispellline[n] == ' ')
			{
				while (n < p && ispellline[n] == ' ')
					++n;
				p=n;
				break;
			}
		printf("...&nbsp;");
	}
	else
		p=0;
	filter_start(FILTER_FOR_DISPLAY, &showfunc);
	filter(ispellline+p, msp->word_pos-p);
	filter_end();
	printf("<B>");
	filter_start(FILTER_FOR_DISPLAY, &showfunc);
	filter(ispellline+msp->word_pos, strlen(msp->misspelled_word));
	filter_end();
	printf("</B>");
	p=msp->word_pos+strlen(msp->misspelled_word);
	if (l-p < 30)
	{
		n=l-p;
	}
	else	n=30;

	while (n)
	{
		if (ispellline[n+p] != ' ')
		{
			--n;
			continue;
		}
		while (n && ispellline[n+p-1] == ' ')
			--n;
		break;
	}
	filter_start(FILTER_FOR_DISPLAY, &showfunc);
	filter(ispellline+p, n);
	filter_end();
	if (n != l-p)
		printf("&nbsp;...");
	printf("</FONT></TT></TD></TR></TABLE><BR>");
	printf("<TABLE BORDER=1 CELLPADDING=8 CLASS=\"spellcheck-main\"><TR><TD>");

	printf("<TABLE BORDER=0><TR><TD>");
	for (isps=msp->first_suggestion; isps; isps=isps->next)
	{
		printf("<TR><TD>%s</TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"%s\"></TD><TD>%s</TD></TR>\n",
			replacelab,
			isps->suggested_word,
			isps->suggested_word);
		replacelab=" ";
	}
	printf("<TR><TD>%s</TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#other\"></TD><TD><INPUT TYPE=TEXT NAME=OTHER WIDTH=20></TD></TR>\n",
		replacelab);
	printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#insert\"></TD><TD>%s</TD></TR>\n",
		insertlab);

	printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=CHECKBOX NAME=REPLACEALL></TD><TD>%s</TD></TR>\n",
		replacealllab);
	printf("<TR><TD> </TD><TD COLSPAN=2><HR WIDTH=\"100%%\"></TD></TR>\n");
	printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#ignore\"></TD><TD>%s</TD></TR>\n",
		ignorelab);
	printf("<TR><TD> </TD><TD><INPUT BORDER=0 TYPE=RADIO NAME=REPLACE VALUE=\"#ignoreall\"></TD><TD>%s</TD></TR>\n",
		ignorealllab);
	printf("</TABLE>");
	printf("</TD></TR></TABLE><BR>");
	printf("<TABLE BORDER=1 CELLPADDING=8 CLASS=\"spellcheck-continue\"><TR><TD>");
	printf("<INPUT TYPE=SUBMIT NAME=\"continue\" VALUE=\"%s\">\n",
			continuelab);
	printf("<INPUT TYPE=SUBMIT NAME=\"finish\" VALUE=\"%s\">\n",
			finishlab);
	printf("</TD></TR></TABLE>\n");
	printf("</TD></TR></TABLE>\n");
	printf("</TD></TR></TABLE>\n");
}
Esempio n. 6
0
File: newmsg.c Progetto: zixia/wmail
void preview_start()
{
	printf("<TT CLASS=\"message-text-plain\">");
	filter_start(FILTER_FOR_PREVIEW, &preview_show_func_s);
}
Esempio n. 7
0
char *
filter_mail(char *mail, int *done)
{
	char			*domain, *alias;
	unsigned int		at;
	int			round;
#ifdef DASH_EXT
	unsigned int 		i;
#endif

	if (mail == (char *)0) {
		ext = 0;
		return 0;
	}

	at = str_rchr(mail, '@');
	if (at == 0 || mail[at] != '@') {
		ext = 0;
		return 0;
	}
	domain = mail + at + 1;

	if (adok) {
		alias = constmap(&ad_map, domain, str_len(domain));
		if (alias && *alias)
			domain = alias;
	}

	if (ext == 0) {
		ext = at;
		extcnt = -1;
		*done = 0;
	} else {
		if (extcnt == 0) {
			*done = 1;
			ext = 0;
			return 0;
		}
#ifdef DASH_EXT
		/*
		 * limit ext to the first DASH_EXT_LEVELS extensions.
		 * We will only check for (DASH_EXT_LEVELS = 4):
		 * [email protected]
		 * [email protected]
		 * [email protected]
		 * [email protected]
		 * [email protected]
		 * [email protected]
		 */
		if (ext == at)
			for (i = 0, ext = 0, extcnt = 1;
			    ext < at && extcnt <= DASH_EXT_LEVELS; ext++)
				if (mail[ext] == *auto_break) extcnt++;
		while (ext != 0 && --ext > 0) {
			if (mail[ext] == *auto_break) break;
		}
		extcnt--;
#else
#error XXX XXX 
		/* basic qmail-ldap behavior test for [email protected] and
		   [email protected] */
		ext = 0;
		extcnt = 0;
#endif
	}
	
	for (round = 0; round < 2; round++) {
		switch (round) {
		case 0:
			/* build the search string for the email address */
			/* mail address */
			if (!filter_start(&filter) ||
			    !stralloc_cats(&filter, "(|(") ||
			    !stralloc_cats(&filter, LDAP_MAIL) ||
			    !stralloc_cats(&filter, "="))
				return 0;
			break;
		case 1:
			/* mailalternate address */
			if (!stralloc_cats(&filter, ")(") ||
			    !stralloc_cats(&filter, LDAP_MAILALTERNATE) ||
			    !stralloc_cats(&filter, "="))
				return 0;
			break;
		}

		/* username till current '-' or '@' */
		if (!filter_escape(&filter, mail, ext))
			return 0;
		/* do not append catchall in the first round */
		if (ext != at) {
			/* catchall or default */
			if (extcnt > 0) /* add '-' */
				if (!stralloc_cats(&filter, auto_break))
					return 0;
			if (!stralloc_cats(&filter, LDAP_CATCH_ALL))
				return 0;
		}
		/* @domain.com */
		if (!stralloc_append(&filter, "@") ||
		    !filter_escape(&filter, domain, str_len(domain)))
			return 0;
	}

	if (!stralloc_cats(&filter, "))") ||
	    !filter_end(&filter))
		return 0;

	if (extcnt == 0)
		*done = 1;

	if (mail[0] == *auto_break) *done = 1; // OSC: do not do DASH_EXT loop if first char is auto_break
	return filter.s;
}