view src/protocols/zephyr/ZhmStat.c @ 7431:643cbc9a6035

[gaim-migrate @ 8036] This is good enough for CVS. This is new logging. It centers around the highly modular "GaimLogLogger," which controls how to write the log. Currently I only have the plain text logger. I wrote the beginning of an XML logger, but decided I didn't think it was that great an idea. Plugins can implement loggers themselves, so you can have, like, an SQL logger or something. The default logger writes to a file unique to the conversation, and they're saved on disk in a heirarchical fashion: ~/.gaim/logs/aim/seanegn/robflynn-date.log would be a conversation I had with Rob on date. What doesn't work: System logging The search button in the log viewer. Oh, chats probably don't log either, I didn't test. You can only log in plain text right now. Obviously, it's not done yet. But you can play around with it, and give it some love. I'll get back to it tomorrow after school, maybe. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 05 Nov 2003 06:15:49 +0000
parents 7ba69b8e0de5
children 43d6c08d7e96
line wrap: on
line source

/* This file is part of the Project Athena Zephyr Notification System.
 * It contains the ZhmStat() function.
 *
 *      Created by:     Marc Horowitz
 *
 *      $Id: ZhmStat.c 2432 2001-10-03 19:38:28Z warmenhoven $
 *
 *      Copyright (c) 1996 by the Massachusetts Institute of Technology.
 *      For copying and distribution information, see the file
 *      "mit-copyright.h". 
 */

#include <internal.h>
#include <sys/socket.h>

#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7f000001
#endif

Code_t ZhmStat(hostaddr, notice)
    struct in_addr *hostaddr;
    ZNotice_t *notice;
{
    struct servent *sp;
    struct sockaddr_in sin;
    ZNotice_t req;
    Code_t code;
    struct timeval tv;
    fd_set readers;

    (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in));

    sp = getservbyname(HM_SVCNAME, "udp");

    sin.sin_port = (sp) ? sp->s_port : HM_SVC_FALLBACK;
    sin.sin_family = AF_INET;

    if (hostaddr)
	sin.sin_addr = *hostaddr;
    else
	sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);

    (void) memset((char *)&req, 0, sizeof(req));
    req.z_kind = STAT;
    req.z_port = 0;
    req.z_class = HM_STAT_CLASS;
    req.z_class_inst = HM_STAT_CLIENT;
    req.z_opcode = HM_GIMMESTATS;
    req.z_sender = "";
    req.z_recipient = "";
    req.z_default_format = "";
    req.z_message_len = 0;
	
    if ((code = ZSetDestAddr(&sin)) != ZERR_NONE)
	return(code);

    if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE)
	return(code);

    /* Wait up to ten seconds for a response. */
    FD_ZERO(&readers);
    FD_SET(ZGetFD(), &readers);
    tv.tv_sec = 10;
    tv.tv_usec = 0;
    code = select(ZGetFD() + 1, &readers, NULL, NULL, &tv);
    if (code < 0 && errno != EINTR)
	return(errno);
    if (code == 0 || (code < 0 && errno == EINTR) || ZPending() == 0)
	return(ZERR_HMDEAD);

    return(ZReceiveNotice(notice, (struct sockaddr_in *) 0));
}