PyBalsa?

Nhi Vanye offer at sgi.com
Tue May 9 00:50:20 CEST 2000


$ from hschroeder at gmx.net -#89489 | sed "1,$s/^/> /"
>
>
>Nhi Vanye <offer at sgi.com> wrote:
>> I started working on a python binding to the UoW C-Client library, but....
>Could you *please* share your code. The Python community would really
>benefit from such a module for serious (and fast!) mail applications.

Yes it would benefit, but I never finished it, in fact I never really
got beyond a proof of concept.


>I tried it myself but I don't have any experience with Swig.

SWIG would be easy if it worked, but the C-Client headers aren't clean
enough. What I ended up doing was hand-crafting an interface between
C-Client and python. This had the advantage of being able to tidy up
the c-client API.

Okay, this is what i had when I abandoned it (bear in mind that this
was as much a case of learning python as anything else, now of course
I'd do it differently :-)

There's a python test harness (also useful as the API doc).

The module (megan.c, megan.h)

The C-Client interface (c-client-wrap.c). Basically provides a bunch of
stub functions needed to link against the c-client library.


That's all there is, the rest of the stuff is still sitting on my
whiteboard, I can send that if you feel it maybe of help (basically its
the python API I was working towards).

The Makefile is Irix and my installation specific, but just in case
anyone wants to check build flags....

[ morgaine 6.5.7f-MR ] cat Makefile 

PYTHON = /usr/local/Python152

CCLIENT=/usr/local/c-client

OBJS = megan.o c-client-wrap.o

MODULE = Megan

DEBUG =-g


#
# Dont remove -all, Python willnot load the module otherwise.
#
dso: $(OBJS)
        $(LD) $(DEBUG) -woff 15 -all -shared -no_unresolved -o $(MODULE).so -soname $(MODULE).so $(OBJS) -L$(PYTHON)/lib/python1.5/config -lpython1.5 -L$(CCLIENT)/lib -lc-client -lpthread -lm -lc

megan.o: megan.c
        $(CC) $(DEBUG) -c megan.c -I$(CCLIENT)/include -I$(PYTHON)/include/python1.5

c-client-wrap.o: c-client-wrap.c
        $(CC) $(DEBUG) -c c-client-wrap.c -I$(CCLIENT)/include 

clean:
        rm -f $(OBJS) $(MODULE).so





This is a shar file, as its not even worth tarring it up and putting it
on a web-site.



#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2000-05-08 15:38 PDT by <offer at fey.engr.sgi.com>.
# Source directory was `/hosts_usr_people/morgaine/offer/src/personal/python/megan'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#    542 -rwxr-xr-x test.py
#   2820 -rw-r--r-- c-client-wrap.c
#   9610 -rw-r--r-- megan.c
#    487 -rw-r--r-- megan.h
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then
  shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$2 "$8"'
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
#
if mkdir _sh01664; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= test.py ==============
if test -f 'test.py' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'test.py' '(file already exists)'
else
  $echo 'x -' extracting 'test.py' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'test.py' &&
#! /usr/local/Python152/bin/python
X
print "importing Megan"
import Megan
X
print "c=Megan.MailBox()"
c=Megan.MailBox()
X
print
print 'c.open("jokes", "r")'
c.open("jokes", "r")
X
print
print "print c"
print c
X
print
print "d = c.message(1)"
d = c.message(1)
X
print
print "print d"
print d
X
print
print "e = d.envelope()"
e = d.envelope()
X
print
print "f = e.frm()"
f = e.frm()
X
print
print "print f"
print f
X
print
print "t = e.to()"
t = e.to()
X
print
print "print t"
print t
X
print
X
print 'print t[0][2],"@",t[0][3]'
print t[0][2],"@",t[0][3]
X
SHAR_EOF
  (set 20 00 05 08 15 17 45 'test.py'; eval "$shar_touch") &&
  chmod 0755 'test.py' ||
  $echo 'restore of' 'test.py' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'test.py:' 'MD5 check failed'
3f2b0dfc481a9700876be415ffe8fd60  test.py
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'test.py'`"
    test 542 -eq "$shar_count" ||
    $echo 'test.py:' 'original size' '542,' 'current size' "$shar_count!"
  fi
fi
# ============= c-client-wrap.c ==============
if test -f 'c-client-wrap.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'c-client-wrap.c' '(file already exists)'
else
  $echo 'x -' extracting 'c-client-wrap.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'c-client-wrap.c' &&
X
#include <stdio.h>
X
#include <mail.h>
X
#define NEED_UNIX
#define NEED_MBX
X
X
#ifdef DEBUG
#define TRACE() \
X	{ fprintf(stderr,"File: %s ; Line: %d\n",__FILE__,__LINE__); }
#else
#define TRACE()
#endif
X	
void
init_cclient_mail_handlers()
{
#ifdef NEED_MBOX
X	TRACE();
X    mail_link (&mboxdriver);      /* link in the mbox driver */
#endif
#ifdef NEED_IMAP
X	TRACE();
X    mail_link (&imapdriver);      /* link in the imap driver */
#endif
#ifdef NEED_NNTP
X	TRACE();
X    mail_link (&nntpdriver);      /* link in the nntp driver */
#endif
#ifdef NEED_POP3
X	TRACE();
X    mail_link (&pop3driver);      /* link in the pop3 driver */
#endif
#ifdef NEED_MH
X	TRACE();
X    mail_link (&mhdriver);        /* link in the mh driver */
#endif
#ifdef NEED_MX
X	TRACE();
X    mail_link (&mxdriver);        /* link in the mx driver */
#endif
#ifdef NEED_MBX
X	TRACE();
X    mail_link (&mbxdriver);       /* link in the mbx driver */
#endif
#ifdef NEED_TENEX
X	TRACE();
X    mail_link (&tenexdriver);     /* link in the tenex driver */
#endif
#ifdef NEED_MTX
X	TRACE();
X    mail_link (&mtxdriver);       /* link in the mtx driver */
#endif
#ifdef NEED_MMDF
X	TRACE();
X    mail_link (&mmdfdriver);      /* link in the mmdf driver */
#endif
#ifdef NEED_UNIX
X	TRACE();
X    mail_link (&unixdriver);      /* link in the unix driver */
#endif
#ifdef NEED_NEWS
X	TRACE();
X    mail_link (&newsdriver);      /* link in the news driver */
#endif
#ifdef NEED_LINK
X	TRACE();
X    mail_link (&philedriver);     /* link in the phile driver */
#endif
X
X	TRACE();
X    mail_link (&dummydriver);     /* link in the dummy driver */
X 
X    auth_link (&auth_log);        /* link in the log authenticator */
X	
X	
}
X
void mm_searched (MAILSTREAM *stream,unsigned long number)
{
}
X
X
void mm_exists (MAILSTREAM *stream,unsigned long number)
{
}
X
X
void mm_expunged (MAILSTREAM *stream,unsigned long number)
{
}
X
X
void mm_flags (MAILSTREAM *stream,unsigned long number)
{
}
X
X
void mm_notify (MAILSTREAM *stream,char *string,long errflg)
{
X  mm_log (string,errflg);
}
X
X
void mm_list (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
{
}
X
X
void mm_lsub (MAILSTREAM *stream,int delimiter,char *mailbox,long attributes)
{
}
X
X
void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status)
{
}
X
X
void mm_log (char *string,long errflg)
{
X  switch ((short) errflg) {
X  case NIL:
X    break;
X  case PARSE:
X    break;
X  case WARN:
X    break;
X  case ERROR:
X    printf ("?%s\n",string);
X    break;
X  }
}
X
X
void mm_dlog (char *string)
{
X  fprintf (stderr, "%s\n",string);
}
X
X
void mm_login (NETMBX *mb,char *user,char *pwd,long trial)
{
X
}
X
X
void mm_critical (MAILSTREAM *stream)
{
}
X
X
void mm_nocritical (MAILSTREAM *stream)
{
}
X
X
long mm_diskerror (MAILSTREAM *stream,long errcode,long serious)
{
X
}
X
X
void mm_fatal (char *string)
{
X  fprintf (stderr,"?%s\n",string);
}
X
X
SHAR_EOF
  (set 19 99 07 07 13 15 46 'c-client-wrap.c'; eval "$shar_touch") &&
  chmod 0644 'c-client-wrap.c' ||
  $echo 'restore of' 'c-client-wrap.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'c-client-wrap.c:' 'MD5 check failed'
6bc6d9c235736b9b6247df092557f13b  c-client-wrap.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'c-client-wrap.c'`"
    test 2820 -eq "$shar_count" ||
    $echo 'c-client-wrap.c:' 'original size' '2820,' 'current size' "$shar_count!"
  fi
fi
# ============= megan.c ==============
if test -f 'megan.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'megan.c' '(file already exists)'
else
  $echo 'x -' extracting 'megan.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'megan.c' &&
/*
X * $Id$
X *
X * Copyright (c) 1999 Richard Offer. All rights reserved.
X *
X */
X
#include <stdio.h>
X
X
#include <Python.h>
X
#include <mail.h>
#include "megan.h"
X
static PyObject *MeganErrorObj;
X
staticforward PyTypeObject MeganMailBox;
staticforward PyTypeObject MeganMessage;
staticforward PyTypeObject MeganEnvelope;
X
#define is_mMB(v) ((v)->ob_type == &MeganMailBox)
X
static meganMessage * new_msg();
static meganEnvelope * new_env();
X
X
X
/*
X * #     #
X * ##   ##  ######   #####  #    #   ####   #####    ####
X * # # # #  #          #    #    #  #    #  #    #  #
X * #  #  #  #####      #    ######  #    #  #    #   ####
X * #     #  #          #    #    #  #    #  #    #       #
X * #     #  #          #    #    #  #    #  #    #  #    #
X * #     #  ######     #    #    #   ####   #####    ####
X * 
X */
X
X
static PyObject *
mmb_open(meganMailBox *self, PyObject *args)
{
X
X	char *mbox, *mode;
X	int _mode = OP_READONLY ;
X
X	if ( self->mail_stream ) { 
X		PyErr_SetString(MeganErrorObj,"MailBox object already opened."); 
X		return NULL;
X	}
X	
X	if ( ! PyArg_ParseTuple(args,"ss", &mbox, &mode) )
X		return NULL;
X	
X	if ( mode && ! strcmp(mode, "r"))
X		_mode = OP_READONLY;
X
X	self->mail_stream = mail_open(self->mail_stream, mbox, _mode | OP_DEBUG );
X
X	if ( self->mail_stream == NULL ) {
X		PyErr_SetString(MeganErrorObj,"Cannot open Mailbox.");
X		return NULL;
X	}
X	
X	return Py_None;	
X	
}
X
static PyObject *
mmb_close(meganMailBox *self, PyObject *args)
{
X	if ( self->mail_stream == NULL ) { 
X		PyErr_SetString(MeganErrorObj,"MailBox object not open."); 
X		return NULL;
X	}
X	
X	if ( ! PyArg_ParseTuple(args, "") ) {
X		PyErr_SetString(MeganErrorObj,"Close() does not take any arguments."); 
X		return NULL;
X	}
X
X	mail_close(self->mail_stream);
X	
X	Py_INCREF(Py_None);
X
X	return Py_None;	
}
X
X
static PyObject *
mmb_count(meganMailBox *self, PyObject *args)
{
X	
X	if ( ! PyArg_ParseTuple(args, "") ) {
X		PyErr_SetString(MeganErrorObj,"Count() does not take any arguments."); 
X		return NULL;
X	}
X
X	return Py_BuildValue("i", self->mail_stream->nmsgs);
}
X
X
static PyObject *
mmb_msg(meganMailBox *self, PyObject *args)
{
X
X	int	n;
X	meganMessage *msg;
X
X	if ( ! PyArg_ParseTuple(args,"i", &n) )
X		return NULL;
X	
X	if ( self->mail_stream == NULL ) {
X		PyErr_SetString(MeganErrorObj,"Mailbox not open.");
X		return NULL;
X	}
X	
X	msg = new_msg();
X	
X	msg->envelope = mail_fetch_structure(
X			self->mail_stream, (unsigned long) n,
X			&msg->body, 0);
X
X	return (PyObject *) msg;
X	
}
X
static PyObject *
msg_env(meganMessage *self, PyObject *args)
{
X
X	int	n;
X	meganEnvelope *env;
X
X	if ( ! PyArg_ParseTuple(args,"") )
X		return NULL;
X	
X	if ( self->envelope == NULL ) {
X		PyErr_SetString(MeganErrorObj,"no ENVELOPE");
X		return NULL;
X	}
X	
X	env = new_env(self->envelope);
X	
X
X	Py_INCREF(env);
X	return (PyObject *) env;
X	
}
X
static PyObject *
env_from(meganEnvelope *self, PyObject *args)
{
X
X	int	n;
X	PyObject *from = PyTuple_New(5); 
X
X	if ( ! PyArg_ParseTuple(args,"") )
X		return NULL;
X	
X	if ( self->envelope->from == NULL ) {
X		PyErr_SetString(MeganErrorObj,"no FROM");
X		return NULL;
X	}
X	
X	if ( PyTuple_SetItem (from, 0,
X				PyString_FromString(self->envelope->from->personal ?
X					self->envelope->from->personal : ""	)) ) {
X		return NULL;
X	}
X		
X	if ( PyTuple_SetItem (from, 1,
X				PyString_FromString(self->envelope->from->adl ?
X					self->envelope->from->adl : "" )) ) {
X		return NULL;
X	}
X		
X	if ( PyTuple_SetItem (from, 2,
X				PyString_FromString(self->envelope->from->mailbox ?
X					self->envelope->from->mailbox : "" )) ) {
X		return NULL;
X	}
X		
X	if ( PyTuple_SetItem (from, 3,
X				PyString_FromString(self->envelope->from->host ?
X					self->envelope->from->host : "" )) ) {
X		return NULL;
X	}
X		
X	if ( PyTuple_SetItem (from, 4,
X				PyString_FromString(self->envelope->from->error ?
X					self->envelope->from->error : "" )) ) {
X		return NULL;
X	}
X		
X	Py_INCREF(from);
X	return (PyObject *) from;
X	
}
X
static PyObject *
env_to(meganEnvelope *self, PyObject *args)
{
X
X	int	n;
X	PyObject *t, *l;
X	ADDRESS *addr = NULL;
X
X	if ( ! PyArg_ParseTuple(args,"") )
X		return NULL;
X	
X	if ( self->envelope->from == NULL ) {
X		PyErr_SetString(MeganErrorObj,"no TO");
X		return NULL;
X	}
X	
X	l = PyList_New(0);
X
X	addr = self->envelope->to;
X
X	while ( addr ) {
X		t = PyTuple_New(5);
X		
X		if ( PyTuple_SetItem(t, 0,
X				PyString_FromString(addr->personal ?  addr->personal : "")) ) {
X			return NULL;
X		}
X		
X		if ( PyTuple_SetItem(t, 1,
X					PyString_FromString(addr->adl ?  addr->adl : "")) ) {
X			return NULL;
X		}
X		
X		if ( PyTuple_SetItem(t, 2,
X					PyString_FromString(addr->mailbox ? addr->mailbox : "")) ) {
X			return NULL;
X		}
X		
X		if ( PyTuple_SetItem(t, 3,
X					PyString_FromString(addr->host ?  addr->host : "" )) ) {
X			return NULL;
X		}
X		
X		if ( PyTuple_SetItem (t, 4,
X				PyString_FromString(addr->error ?  addr->error : "" )) ) {
X			return NULL;
X		}
X		
X		PyList_Append(l, t);
X		
X		addr = addr->next;
X		
X	}
X	
X	Py_INCREF(l);
X	return (PyObject *) l;
X	
}
X
static struct PyMethodDef mmb_methods[] = {
X	{ "open",	mmb_open,	1 },
X	{ "close",	mmb_close,	1 },
X	{ "count",	mmb_count,	1 },
X	{ "message",mmb_msg,	1 },
X	{ NULL, NULL, NULL },
};
X	
static struct PyMethodDef mmsg_methods[] = {
X	{ "envelope",msg_env,	1 },
#ifdef not_yet
X	{ "body",msg_env,	1 },
#endif
X	{ NULL, NULL, NULL },
};
X
static struct PyMethodDef env_methods[] = {
X	{ "frm", env_from,	1 },
X	{ "to", env_to,	1 },
X	{ NULL, NULL, NULL },
};
X
X
/* 
X * #######
X * #     #  #####        #  ######   ####    #####
X * #     #  #    #       #  #       #    #     #
X * #     #  #####        #  #####   #          #
X * #     #  #    #       #  #       #          #
X * #     #  #    #  #    #  #       #    #     #
X * #######  #####    ####   ######   ####      #
X * 
*/
X
static meganMailBox *
new_mmb()
{
X
X	meganMailBox *mmb;
X	
X	mmb = PyObject_NEW(meganMailBox, &MeganMailBox);
X	
X	if ( mmb == NULL )
X		return NULL;
X	
X
X	mmb->mail_stream = NULL;
X	
X	return mmb;
}
X
X
static void
delete_mmb(meganMailBox *self)
{
X
X	PyMem_DEL(self);	
}
X
static PyObject *
getattr_mmb(meganMailBox *self, char *name)
{
X
X	if ( ! strcmp(name, "__methods__")) {
X			
X		return Py_BuildValue("[ssss]", "open", "close", "count", "message");
X	}
X	else
X		return Py_FindMethod(mmb_methods, (PyObject *) self, name);	
X	
}
X
static int
print_mmb(meganMailBox *self, FILE *fp, int flags)
{
X
X	if ( self->mail_stream == NULL )
X		fprintf(fp,"MailBox not opened\n");
X		
X	else
X		fprintf(fp,"MailBox '%s' has %d messages\n",
X			self->mail_stream->mailbox,
X			self->mail_stream->nmsgs);
X
X	return 0;
}
X
X
X
X
X
static meganMessage *
new_msg()
{
X
X	meganMessage *mmsg;
X	
X	mmsg = PyObject_NEW(meganMessage, &MeganMessage);
X	
X	if ( mmsg == NULL )
X		return NULL;
X	
X	return mmsg;
}
X
static meganEnvelope *
new_env(ENVELOPE *envelope)
{
X
X	meganEnvelope *env;
X	
X	env = PyObject_NEW(meganEnvelope, &MeganEnvelope);
X	
X	if ( env == NULL )
X		return NULL;
X	
X	env->envelope = envelope;
X
X	return env;
}
X
static void
delete_msg(meganMessage *self)
{
X
X	PyMem_DEL(self);	
}
X
static PyObject *
getattr_msg(meganMessage *self, char *name)
{
X
X	if ( ! strcmp(name, "__methods__")) {
X			
X		return Py_BuildValue("[s]", "envelope");
X	}
X	else
X		return Py_FindMethod(mmsg_methods, (PyObject *) self, name);	
X	
}
X
static void
delete_env(meganMessage *self)
{
X
X	PyMem_DEL(self);	
}
X
static PyObject *
getattr_env(meganMessage *self, char *name)
{
X
X	if ( ! strcmp(name, "__methods__")) {
X			
X		return Py_BuildValue("[ss]", "frm", "to");
X	}
X	else
X		return Py_FindMethod(env_methods, (PyObject *) self, name);	
X	
}
X
X
X
static PyTypeObject MeganMailBox = {
X	PyObject_HEAD_INIT(&PyType_Type)
X	0,
X	"MailBox",
X	sizeof(meganMailBox),
X	0,
X	
/* Standard Methods */	
X	(destructor)	delete_mmb,
X	(printfunc)		NULL,
X	(getattrfunc)	getattr_mmb,
X	(setattrfunc)	NULL,			/* TODO */
X	(cmpfunc)		NULL,			/* TODO */
X	(reprfunc)		NULL,			/* TODO */
X	
/* type categories */
X	NULL,
X	NULL,
X	NULL,
X	
/* more methods */
X	NULL,
X	NULL,
X	NULL,
X	
};
X		
X		
static PyTypeObject MeganMessage = {
X	PyObject_HEAD_INIT(&PyType_Type)
X	0,
X	"Message",
X	sizeof(meganMessage),
X	0,
X	
/* Standard Methods */	
X	(destructor)	delete_msg,
X	(printfunc)		NULL,
X	(getattrfunc)	getattr_msg,
X	(setattrfunc)	NULL,			/* TODO */
X	(cmpfunc)		NULL,			/* TODO */
X	(reprfunc)		NULL,			/* TODO */
X	
/* type categories */
X	NULL,
X	NULL,
X	NULL,
X	
/* more methods */
X	NULL,
X	NULL,
X	NULL,
X	
};
X
static PyTypeObject MeganEnvelope = {
X	PyObject_HEAD_INIT(&PyType_Type)
X	0,
X	"Envelope",
X	sizeof(meganEnvelope),
X	0,
X	
/* Standard Methods */	
X	(destructor)	delete_env,
X	(printfunc)		NULL,
X	(getattrfunc)	getattr_env,
X	(setattrfunc)	NULL,			/* TODO */
X	(cmpfunc)		NULL,			/* TODO */
X	(reprfunc)		NULL,			/* TODO */
X	
/* type categories */
X	NULL,
X	NULL,
X	NULL,
X	
/* more methods */
X	NULL,
X	NULL,
X	NULL,
X	
};
X
X
X	
/*
X * ######
X * #     #   #   #   #####  #    #   ####   #    #
X * #     #    # #      #    #    #  #    #  ##   #
X * ######      #       #    ######  #    #  # #  #
X * #           #       #    #    #  #    #  #  # #
X * #           #       #    #    #  #    #  #   ##
X * #           #       #    #    #   ####   #    #
X *
X */
X
X
X
static PyObject *
mmbtype_new(PyObject *self, PyObject *args)
{
X
X	if ( ! PyArg_ParseTuple(args, ""))
X		return NULL;
X	
X	return (PyObject *) new_mmb();
}
X
X
X
static struct PyMethodDef mmbtype_methods[] = {
X
X	{ "MailBox", mmbtype_new, 1 },
X	{ NULL, NULL },	
X	
};
X
void
initMegan()
{
X
X	PyObject *m, *d;
X
X	m = Py_InitModule("Megan", mmbtype_methods);
X	
X	d = PyModule_GetDict(m);
X	
X	MeganErrorObj = Py_BuildValue("s", "megan.error");
X	
X	PyDict_SetItemString(d, "error", MeganErrorObj ); 
X	
X	if ( PyErr_Occurred() ) {
X		Py_FatalError("can't init megan module.");
X	}
X
X	/* set up all the mail handlers */
X	init_cclient_mail_handlers();
X
}
SHAR_EOF
  (set 19 99 07 20 21 43 04 'megan.c'; eval "$shar_touch") &&
  chmod 0644 'megan.c' ||
  $echo 'restore of' 'megan.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'megan.c:' 'MD5 check failed'
12c8c09a88f03d537d6a0bb64ddcb4f0  megan.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'megan.c'`"
    test 9610 -eq "$shar_count" ||
    $echo 'megan.c:' 'original size' '9610,' 'current size' "$shar_count!"
  fi
fi
# ============= megan.h ==============
if test -f 'megan.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'megan.h' '(file already exists)'
else
  $echo 'x -' extracting 'megan.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'megan.h' &&
X
X
typedef struct _meganMailBox {
X	
X	PyObject_HEAD
X	
X	MAILSTREAM	*mail_stream;	
X	
} meganMailBox;
X
typedef struct _meganMessage {
X	
X	PyObject_HEAD
X	
X	ENVELOPE	*envelope;	
X	BODY	*body;	
X	
X	/* will be a full python object eventually */
X	int flags;
X	
} meganMessage;
X
typedef struct _meganEnvelope {
X	
X	PyObject_HEAD
X	
X	ENVELOPE	*envelope;	
X
} meganEnvelope;
X
typedef struct _meganBody {
X	
X	PyObject_HEAD
X	
} meganBody;
X
/* c-client-wrap functions */
X
void init_cclient_mail_handlers(void);
SHAR_EOF
  (set 19 99 07 09 13 42 16 'megan.h'; eval "$shar_touch") &&
  chmod 0644 'megan.h' ||
  $echo 'restore of' 'megan.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'megan.h:' 'MD5 check failed'
10a834a4e037c64f572e9e15451dc112  megan.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'megan.h'`"
    test 487 -eq "$shar_count" ||
    $echo 'megan.h:' 'original size' '487,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh01664
exit 0


>Regards
>  Henning

richard.
-- 
Richard Offer           Widget FAQ --> http://reality.sgi.com/widgetFAQ
MTS-Core Design (Motif)
___________________________________________http://reality.sgi.com/offer




More information about the Python-list mailing list