Ejemplo n.º 1
0
void Header_HandleXFF(StrBuf *Line, ParsedHttpHdrs *hdr)
{
	hdr->HR.browser_host = Line;

	while (StrBufNum_tokens(hdr->HR.browser_host, ',') > 1) {
		StrBufRemove_token(hdr->HR.browser_host, 0, ',');
	}
	StrBufTrim(hdr->HR.browser_host);
}
Ejemplo n.º 2
0
/*
 * Callback function for perform_openid2_discovery()
 * We're interested in the X-XRDS-Location: header.
 */
size_t yadis_headerfunction(void *ptr, size_t size, size_t nmemb, void *userdata) {
	char hdr[1024];
	StrBuf **x_xrds_location = (StrBuf **) userdata;

	memcpy(hdr, ptr, (size*nmemb));
	hdr[size*nmemb] = 0;

	if (!strncasecmp(hdr, "X-XRDS-Location:", 16)) {
		*x_xrds_location = NewStrBufPlain(&hdr[16], ((size*nmemb)-16));
		StrBufTrim(*x_xrds_location);
	}

	return(size * nmemb);
}
Ejemplo n.º 3
0
HashList *iterate_get_ical_attendees(StrBuf *Target, WCTemplputParams *TP)
{
	icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL);
	icalparameter *partstat_param;
	icalproperty *p;
	CalAttendee *Att;
	HashList *Attendees = NULL;
	const char *ch;
	int n = 0;

	/* If the component has attendees, iterate through them. */
	for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); 
	     (p != NULL); 
	     p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
		ch = icalproperty_get_attendee(p);
		if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) {
			Att = (CalAttendee*) malloc(sizeof(CalAttendee));

			/** screen name or email address */
			Att->AttendeeStr = NewStrBufPlain(ch + 7, -1);
			StrBufTrim(Att->AttendeeStr);

			/** participant status */
			partstat_param = icalproperty_get_first_parameter(
				p,
				ICAL_PARTSTAT_PARAMETER
				);
			if (partstat_param == NULL) {
				Att->partstat = ICAL_PARTSTAT_X;
			}
			else {
				Att->partstat = icalparameter_get_partstat(partstat_param);
			}
			if (Attendees == NULL)
				Attendees = NewHash(1, Flathash);
			Put(Attendees, IKEY(n), Att, DeleteAtt);
			n++;
		}
	}
	return Attendees;
}
Ejemplo n.º 4
0
eNextState SMTPC_read_data_body_reply(SmtpOutMsg *Msg)
{
	AsyncIO *IO = &Msg->IO;
	SMTP_DBG_READ();

	if (!SMTP_IS_STATE('2')) {
		if (SMTP_IS_STATE('4'))
			SMTP_VERROR(4);
		else
			SMTP_VERROR(5);
	}

	SetSMTPState(IO, eSTMPsmtpdone);
	/* We did it! */
	StrBufPlain(Msg->MyQEntry->StatusMessage,
		    &ChrPtr(Msg->IO.RecvBuf.Buf)[4],
		    StrLength(Msg->IO.RecvBuf.Buf) - 4);
	StrBufTrim(Msg->MyQEntry->StatusMessage);
	Msg->MyQEntry->Status = 2;
	return eSendReply;
}
Ejemplo n.º 5
0
void network_process_digest(SpoolControl *sc, struct CtdlMessage *omsg, long *delete_after_send)
{

	struct CtdlMessage *msg = NULL;

	if (sc->Users[digestrecp] == NULL)
		return;

	/* If there are digest recipients, we have to build a digest */
	if (sc->digestfp == NULL) {
		
		sc->digestfp = create_digest_file(&sc->room, 1);

		if (sc->digestfp == NULL)
			return;

		sc->haveDigest = ftell(sc->digestfp) > 0;
		if (!sc->haveDigest) {
			fprintf(sc->digestfp, "Content-type: text/plain\n\n");
		}
		sc->haveDigest = 1;
	}

	msg = CM_Duplicate(omsg);
	if (msg != NULL) {
		sc->haveDigest = 1;
		fprintf(sc->digestfp,
			" -----------------------------------"
			"------------------------------------"
			"-------\n");
		fprintf(sc->digestfp, "From: ");
		if (!CM_IsEmpty(msg, eAuthor)) {
			fprintf(sc->digestfp,
				"%s ",
				msg->cm_fields[eAuthor]);
		}
		if (!CM_IsEmpty(msg, erFc822Addr)) {
			fprintf(sc->digestfp,
				"<%s> ",
				msg->cm_fields[erFc822Addr]);
		}
		else if (!CM_IsEmpty(msg, eNodeName)) {
			fprintf(sc->digestfp,
				"@%s ",
				msg->cm_fields[eNodeName]);
		}
		fprintf(sc->digestfp, "\n");
		if (!CM_IsEmpty(msg, eMsgSubject)) {
			fprintf(sc->digestfp,
				"Subject: %s\n",
				msg->cm_fields[eMsgSubject]);
		}

		CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);

		safestrncpy(CC->preferred_formats,
			    "text/plain",
			    sizeof CC->preferred_formats);

		CtdlOutputPreLoadedMsg(msg,
				       MT_CITADEL,
				       HEADERS_NONE,
				       0, 0, 0);

		StrBufTrim(CC->redirect_buffer);
		fwrite(HKEY("\n"), 1, sc->digestfp);
		fwrite(SKEY(CC->redirect_buffer), 1, sc->digestfp);
		fwrite(HKEY("\n"), 1, sc->digestfp);

		FreeStrBuf(&CC->redirect_buffer);

		sc->num_msgs_spooled += 1;
		CM_Free(msg);
	}
}