コード例 #1
0
ファイル: msgcookie.c プロジェクト: Doap/transports
/**
 * aim_cachecookie - appends a cookie to the cookie list
 * @sess: session to add to
 * @cookie: pointer to struct to append
 *
 * if cookie->cookie for type cookie->type is found, updates the
 * ->addtime of the found structure; otherwise adds the given cookie
 * to the cache
 *
 * returns -1 on error, 0 on append, 1 on update.  the cookie you pass
 * in may be free'd, so don't count on its value after calling this!
 * 
 */
faim_internal int aim_cachecookie(aim_session_t *sess, aim_msgcookie_t *cookie)
{
	aim_msgcookie_t *newcook;

	if (!sess || !cookie)
		return -EINVAL;

	newcook = aim_checkcookie(sess, cookie->cookie, cookie->type);
	
	if (newcook == cookie) {
		newcook->addtime = time(NULL);
		return 1;
	} else if (newcook)
		aim_cookie_free(sess, newcook);

	cookie->addtime = time(NULL);  

	cookie->next = sess->msgcookies;
	sess->msgcookies = cookie;

	return 0;
}
コード例 #2
0
ファイル: msgcookie.c プロジェクト: Mons/libpurple-mini
/**
 * aim_cachecookie - appends a cookie to the cookie list
 *
 * if cookie->cookie for type cookie->type is found, updates the
 * ->addtime of the found structure; otherwise adds the given cookie
 * to the cache
 *
 * @param od session to add to
 * @param cookie pointer to struct to append
 * @return returns -1 on error, 0 on append, 1 on update.  the cookie you pass
 *         in may be free'd, so don't count on its value after calling this!
 */
int aim_cachecookie(OscarData *od, IcbmCookie *cookie)
{
	IcbmCookie *newcook;

	if (!od || !cookie)
		return -EINVAL;

	newcook = aim_checkcookie(od, cookie->cookie, cookie->type);

	if (newcook == cookie) {
		newcook->addtime = time(NULL);
		return 1;
	} else if (newcook)
		aim_cookie_free(od, newcook);

	cookie->addtime = time(NULL);

	cookie->next = od->msgcookies;
	od->msgcookies = cookie;

	return 0;
}