Exemple #1
0
void tmplput_importantmessage(StrBuf *Target, WCTemplputParams *TP)
{
	wcsession *WCC = WC;
	
	if (WCC != NULL) {
		if (StrLength(WCC->ImportantMsg) > 0) {
			StrEscAppend(Target, WCC->ImportantMsg, NULL, 0, 0);
		}
	}
}
Exemple #2
0
void tmplput_nowstr(StrBuf *Target, WCTemplputParams *TP)
{
	char buf[64];
	long bufused;
	time_t now;
	
	now = time(NULL);
#ifdef HAVE_SOLARIS_LOCALTIME_R
	asctime_r(localtime(&now), buf, sizeof(buf));
#else
	asctime_r(localtime(&now), buf);
#endif
	bufused = strlen(buf);
	if ((bufused > 0) && (buf[bufused - 1] == '\n')) {
		buf[bufused - 1] = '\0';
		bufused --;
	}
	StrEscAppend(Target, NULL, buf, 0, 0);
}
static void TestEscEncodeStdin(void)
{
	int fdin = 0;// STDIN
	const char *Err;
	StrBuf *Target;
	StrBuf *Source;

	Source = NewStrBuf();

	while (fdin == 0) {

		StrBufTCP_read_line(Source, &fdin, 0, &Err);
		Target = NewStrBuf();
		
		StrEscAppend(Target, Source, NULL, 0, 0);
		
		TestRevalidateStrBuf(Target);
		printf("%s\n", ChrPtr(Target));
		FreeStrBuf(&Target);
	}
	FreeStrBuf(&Source);
}
Exemple #4
0
void tmpl_vcard_put_message(StrBuf *Target, WCTemplputParams *TP)
{
	struct vnote *v = (struct vnote *) CTX(CTX_VNOTE);
	StrEscAppend(Target, NULL, v->body, 0, 0); /*TODO?*/
}
Exemple #5
0
/* 
 * static wrapper for ecsputs1
 */
void escputs(const char *strbuf)
{
	StrEscAppend(WC->WBuf, NULL, strbuf, 0, 0);
}
Exemple #6
0
/*
 * This function handles the logging of instant messages to disk.
 */
void log_instant_message(struct CitContext *me, struct CitContext *them, char *msgtext, int serial_number)
{
	long usernums[2];
	long t;
	struct imlog *iptr = NULL;
	struct imlog *this_im = NULL;
	
	memset(usernums, 0, sizeof usernums);
	usernums[0] = me->user.usernum;
	usernums[1] = them->user.usernum;

	/* Always put the lower user number first, so we can use the array as a hash value which
	 * represents a pair of users.  For a broadcast message one of the users will be 0.
	 */
	if (usernums[0] > usernums[1]) {
		t = usernums[0];
		usernums[0] = usernums[1];
		usernums[1] = t;
	}

	begin_critical_section(S_IM_LOGS);

	/* Look for an existing conversation in the hash table.
	 * If not found, create a new one.
	 */

	this_im = NULL;
	for (iptr = imlist; iptr != NULL; iptr = iptr->next) {
		if ((iptr->usernums[0] == usernums[0]) && (iptr->usernums[1] == usernums[1])) {
			/* Existing conversation */
			this_im = iptr;
		}
	}
	if (this_im == NULL) {
		/* New conversation */
		this_im = malloc(sizeof(struct imlog));
		memset(this_im, 0, sizeof (struct imlog));
		this_im->usernums[0] = usernums[0];
		this_im->usernums[1] = usernums[1];
		/* usernames[] and usernums[] might not be in the same order.  This is not an error. */
		if (me) {
			safestrncpy(this_im->usernames[0], me->user.fullname, sizeof this_im->usernames[0]);
		}
		if (them) {
			safestrncpy(this_im->usernames[1], them->user.fullname, sizeof this_im->usernames[1]);
		}
		this_im->conversation = NewStrBuf();
		this_im->next = imlist;
		imlist = this_im;
		StrBufAppendBufPlain(this_im->conversation, HKEY(
			"<html><body>\r\n"
			), 0);
	}


	/* Since it's possible for this function to get called more than once if a user is logged
	 * in on multiple sessions, we use the message's serial number to keep track of whether
	 * we've already logged it.
	 */
	if (this_im->last_serial != serial_number)
	{
		this_im->lastmsg = time(NULL);		/* Touch the timestamp so we know when to flush */
		this_im->last_serial = serial_number;
		StrBufAppendBufPlain(this_im->conversation, HKEY("<p><b>"), 0);
		StrBufAppendBufPlain(this_im->conversation, me->user.fullname, -1, 0);
		StrBufAppendBufPlain(this_im->conversation, HKEY(":</b> "), 0);
		StrEscAppend(this_im->conversation, NULL, msgtext, 0, 0);
		StrBufAppendBufPlain(this_im->conversation, HKEY("</p>\r\n"), 0);
	}
	end_critical_section(S_IM_LOGS);
}