dslinux/user/bitchx/dll/qmail Makefile.in qmail.c

stsp stsp at user.in-berlin.de
Sun Jul 2 15:18:37 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/bitchx/dll/qmail
In directory antilope:/tmp/cvs-serv9280/dll/qmail

Added Files:
	Makefile.in qmail.c 
Log Message:
Adding pristine copy of BitchX so I can branch from it.


--- NEW FILE: Makefile.in ---
SHELL = @SHELL@

srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
topdir = @topdir@
prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = @oldincludedir@

local_dir = $(HOME)

# Where the BitchX binary will be installed.
# "make install" will compile and install the program.
INSTALL_IRC = @INSTALL_IRC@

# Where the BitchX library will be. Generally this is the place that
# you put the scripts, help pages and translation tables. It is
# very important that you set this correctly.
IRCLIB = @IRCLIB@

CC = @CC@
DEFS = @INCLUDES@
LIBS = @LIBS@

# Tcl library.
TCL_LIBS = @TCL_LIBS@

# These are for Tcl support.
TCL_OBJS = @TCL_OBJS@
# You don't have the following, so you'll want to leave this blank.
TCL_SRCS = @TCL_SRCS@

# Set this to -g if you want to be able to debug the client, otherwise
# use -O to have the compiler do some optimization instead.
CFLAGS = @CFLAGS@

# Set this to -s if you want the binary to be stripped.
LDFLAGS = @LDFLAGS@

# These are for the cd device player.
CD_SRCS = @CD_SRCS@
CD_OBJS = @CD_OBJS@

# This is the executable suffix for the target operating system.
EXEEXT = @EXEEXT@

# Extra files.
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@

# Full path of the directory for BitchX help files.
HELPDIR = @HELPDIR@

# Full path of the directory for the BitchX scripts.
INSTALL_SCRIPT = @INSTALL_SCRIPT@

# Default setting for IRCPATH where BitchX will look for
# its script files if the environment variable is undefined.
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
# the Makefile, but it can contain multiple path elements
# separated by colons. The path MUST lead to an existing directory,
# because the 'global' script is expected to be found there.
IRCPATH = @IRCPATH@

# Path for TRANSLATION variable.
TRANSLATION_PATH = @TRANSLATION_PATH@

# This command will be used to install the BitchX help files. If you don't
# want to install them, replace with the following:
# INSTALL_HELP_CMD = @echo The help files have not been installed.
INSTALL_HELP_CMD = @INSTALL_HELP_CMD@

# This is where the optional plugins will be copied to.
PLUGINDIR = @PLUGINDIR@

# Plugin flags.
SHLIB_LD = @SHLIB_LD@
SHLIB_CFLAGS = @SHLIB_CFLAGS@
SHLIB_SUFFIX = @SHLIB_SUFFIX@

# This command will be used to install the BitchX files on Win32/OS2EMX
# systems.
WINNT_INSTALL = @WINNT_INSTALL@

# This program allows you to use screen/xterm's to put new BitchX windows
# on new screen/xterm windows.
INSTALL_WSERV = @INSTALL_WSERV@

# This program allows you to screen BitchX and reattach to it later.
INSTALL_SCRBX = @INSTALL_SCRBX@

# Set gzip and bzip2 options.
GZIP_ENV = @GZIP_ENV@
BZIP2 = @BZIP2@

# Standard programs.
RM = @RM@
LN = @LN_S@
CP = @CP@
MV = @MV@

INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@

VERSION = @VERSION@
_VERSION_ = @_VERSION_@

MAKE_BIN = @MAKE@
MAKE = $(MAKE_BIN) $(MFLAGS)
MFLAGS = \
	'local_dir=$(HOME)'			\
	'INSTALL_IRC=$(INSTALL_IRC)'		\
	'IRCLIB=$(IRCLIB)'			\
	'CC=$(CC)'				\
	'CFLAGS=$(CFLAGS)'			\
	'HELPDIR=$(HELPDIR)'			\
        'INSTALL_WSERV=$(INSTALL_WSERV)'	\
	'IRCPATH=$(IRCPATH)'			\
	'TRANSLATION_PATH=$(TRANSLATION_PATH)'	\
	'LDFLAGS=$(LDFLAGS)'			\
	'LIBS=$(LIBS)'				\
	'LN=$(LN)'				\
	'RM=$(RM)'				\
	'TCL_SRCS=$(TCL_SRCS)'			\
	'TCL_OBJS=$(TCL_OBJS)'			\
	'CD_PLAY=$(CD_PLAY)'			\
	'CD_SRCS=$(CD_SRCS)'			\
	'CD_OBJS=$(CD_OBJS)'			\
	'TCL_LIBS=$(TCL_LIBS)'			\
	'PLUGINDIR=$(PLUGINDIR)'		\
	'_VERSION_=$(_VERSION_)'		\
	'VERSION=$(VERSION)'			\
	'INSTALL_DATA=$(INSTALL_DATA)'		\
	'INSTALL_SCRIPT=$(INSTALL_SCRIPT)'	\
	'EXEEXT=$(EXEEXT)'			\
	'SHLIB_CFLAGS=$(SHLIB_CFLAGS)'		\
	'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'

## Makefile starts here.

PLUGIN_NAME = qmail

all: Makefile qmail$(SHLIB_SUFFIX)

Makefile: Makefile.in
	cd $(topdir) \
	  && ./config.status

qmail.o: $(srcdir)/qmail.c
	$(CC) $(DEFS) $(CFLAGS) -c $(srcdir)/qmail.c

qmail$(SHLIB_SUFFIX): qmail.o ../dllinit.o
	$(SHLIB_LD) qmail.o ../dllinit.o $(SHLIB_CFLAGS) -o qmail$(SHLIB_SUFFIX)

clean:
	$(RM) *~ *.o qmail$(SHLIB_SUFFIX) *.a *.dll *.so *.def .#*

distclean: clean
	$(RM) Makefile

install:
	$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(PLUGINDIR)

--- NEW FILE: qmail.c ---
/*
 * Mail check routines. Based on EPIC's mail check
 */

#include "irc.h"
#include "struct.h"

#include "hook.h"
#include "ircaux.h"
#include "output.h"
#include "lastlog.h"
#include "status.h"
#include "vars.h"
#include "window.h"
#include <sys/stat.h>

#include "module.h"
#define INIT_MODULE
#include "modval.h"

#ifndef UNIX_MAIL
#define UNIX_MAIL "~/Maildir"
#endif

/*
 * check_mail_status: returns 0 if mail status has not changed, 1 if mail
 * status has changed 
 */

int check_qmail_status(void)
{
	int count = 0;
	DIR *dp;
	struct dirent *dir;
	static int c = 0;
	char *m;
	char *mail_path = NULL;
	
	if (!get_int_var(MAIL_VAR))
		return 0;
	
	if (!(mail_path = get_dllstring_var("qmaildir")))
                m = m_sprintf("%s/new", UNIX_MAIL);
	else
		m = m_sprintf("%s/new", mail_path);
	mail_path = expand_twiddle(m);
	new_free(&m);

	if (!mail_path)
		return 0;
	if ((dp = opendir(mail_path)))
	{
		while ((dir = readdir(dp)))
		{
			if (!dir->d_ino || (dir->d_name[0] == '.'))
				continue;
			count++;
		}
		closedir(dp);
	}
	if (count > c)
	{
		c = count;
		return c;
	}
	else if (count <= c)
	{
		c = count;
		return -count;
	}
	return 0;
}

/*
 * check_mail: This here thing counts up the number of pieces of mail and
 * returns it as static string.  If there are no mail messages, null is
 * returned. 
 */

char	*check_qmail (void)
{
static 	int old_count = 0;
static	char ret_str[12];
static  int	i = 0;

	switch (get_int_var(MAIL_VAR))
	{
		case 0:
			return NULL;
		case 1:
		{
			char this[] = "\\|/-";
			int count;
			if ((count = check_qmail_status()) > 0)
			{
				set_display_target(NULL, LOG_CRAP);
				if (do_hook(MAIL_LIST, "%s %s", "Mail", "Yes"))
					put_it("%s", convert_output_format(fget_string_var(FORMAT_MAIL_FSET), "%s %s %s", update_clock(GET_TIME), "Mail", "Yes"));
				reset_display_target();
				if (i == 4)
					i = 0;
				sprintf(ret_str, "%c", this[i++]);
			}
			else if (count == 0)
				i = 0;
			return *ret_str ? ret_str : NULL;
		}
		case 2:
		{
			register int count = 0;
			count = check_qmail_status();
			if (count == 0)
			{
				old_count = 0;
				return NULL;
			}
			if  (count > 0)
			{
				if (count > old_count)
				{
					set_display_target(NULL, LOG_CRAP);
					if (do_hook(MAIL_LIST, "%d %d", count - old_count, count))
						put_it("%s", convert_output_format(fget_string_var(FORMAT_MAIL_FSET), "%s %s %s", update_clock(GET_TIME), "Mail", "Yes"));
					reset_display_target();
				}

				old_count = count;
				sprintf(ret_str, "%d", old_count);
				return ret_str;
			}
			else
			{
				if (*ret_str)
					return ret_str;
			}
		}
	}
	return NULL;
}

char *name = "Qmail";

int Qmail_Cleanup(IrcCommandDll **interp, Function_ptr *global_table)
{
	remove_module_proc(VAR_PROC, name, NULL, NULL);
	remove_module_proc(CHECK_EXT_MAIL_STATUS|TABLE_PROC, name, NULL, NULL);
	remove_module_proc(CHECK_EXT_MAIL|TABLE_PROC, name, NULL, NULL);
	return 3;
}

int Qmail_Init(IrcCommandDll **interp, Function_ptr *global_table)
{
	initialize_module(name);
	add_module_proc(VAR_PROC, name, "qmaildir", "~/Maildir", STR_TYPE_VAR, 0, NULL, NULL);
	global[CHECK_EXT_MAIL_STATUS] = (Function_ptr) check_qmail_status;
	global[CHECK_EXT_MAIL] = (Function_ptr) check_qmail;
	return 0;
}




More information about the dslinux-commit mailing list