pyg-0.9.8ubuntu2/0000755000000000000000000000000012057422631010544 5ustar pyg-0.9.8ubuntu2/whitelist.py0000644000000000000000000000657212057422101013134 0ustar """News to mail gateway script. Copyright 2000 Cosimo Alfarano Author: Cosimo Alfarano Date: June 11 2000 whitelist.py - Copyright 2000 by Cosimo Alfarano You can use this software under the terms of the GPL. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Thanks to md for this useful formula. Beer is beer. whitelist manage a list of trusted user. """ import sys import string import time import fcntl import pyginfo import wlp class whitelist: """whitelist handling class Do you really want anyone can post? Ah ah ah. """ wl = {} debug = None log = None # filedescriptor # constants DENY = 0 ACCEPT = 1 def __init__(self, wlfile='wl.pyg', logfile='pyg.log', debug=0): self.debug = debug try: wlp.setfilebyname(wlfile) except (Exception), (errno,message): print 'Opening %s: %s (errno %d)' % (wlfile,message,errno) sys.exit(0) # dict is a { ownername : {variable: value}} dictionary of dictionaries self.wl = wlp.mkdict() # print 'owner: option = value' # for owner in self.wl.keys(): # for option in self.wl[owner].keys(): # print '%s: %s = %s' % (owner,option,self.wl[owner][option]) try: self.log = open(logfile, 'a') self.lock() except (Exception), message: print '%s\nAre you authorized to use this program? ' % message sys.exit(1) def lock(self): fcntl.flock(self.log.fileno(),fcntl.LOCK_EX) # to unlock fd locked, usually fd are unlocked after process exit() def unlock(self): fcntl.flock(self.log.fileno(),fcntl.LOCK_UN) def checkfrom(self, fromhead): """have you permission to be here, sir?""" for owner in self.wl.keys(): # if(self.wl[owner]['From:'] == fromhead[:-1]): # remove '\n' if(string.find(fromhead[:-1],self.wl[owner]['From:']) >= 0): return owner else: return None def log(self, string): """Captain Diary, Astral Date 962555394 from epoch. it rawly write a line in logfile. Remeber to indent it, if you like. """ self.log.write(string + '\n') def logmsg(self, heads, ok=DENY,owner=None): """who are walking through my gate? log """ ltime = time.ctime(time.time()) if time.daylight: tzone = time.tzname[1] else: tzone = time.tzname[0] if(ok == self.ACCEPT): self.log.write('Permission Accorded ') else: self.log.write('Permission Denied ') self.log.write('at %s (%s)\n' % (ltime,tzone)) if(owner != None): self.log.write('\tWLOwner: ' + owner + '\n') self.log.write('\tFrom: ' + heads.get('From:','NOT PRESENT\n')) self.log.write('\tSubject: ' + heads.get('Subject:','NOT PRESENT\n')) self.log.write('\tSender: ' + heads.get('Sender:','NOT PRESENT\n')) self.log.write('\tDate: ' + heads.get('Date:','NOT PRESENT\n')) # some client create Message-Id other Message-ID. if(heads.has_key('Message-ID:')): self.log.write('\tMessage-ID: ' + heads.get('Message-ID:')) else: self.log.write('\tMessage-Id: ' + heads.get('Message-Id:','NOT PRESENT\n')) # X-Newsgroups: and To: are present if user is trusted, else # Newsgroup: exists since no changes on nntp headers are done. if(heads.has_key('X-Newsgroups:')): self.log.write('\tTo: ' + heads.get('To:','NOT PRESENT\n')) self.log.write('\tX-Newsgroups: ' + heads.get('X-Newsgroups:','NOT PRESENT\n')) else: self.log.write('\tNewsgroups: ' + heads.get('Newsgroups:','NOT PRESENT\n')) self.log.write('\n') pyg-0.9.8ubuntu2/mail2news.py.withtab0000644000000000000000000002030612057422101014451 0ustar """Mail to news gateway script. Copyright 2000 Cosimo Alfarano Author: Cosimo Alfarano Date: September 16 2000 mail2news.py - Copyright 2000 by Cosimo Alfarano You can use this software under the terms of the GPL. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Thanks to md for this useful formula. Beer is beer. Gets news email and sends it via SMTP. class mail2news is hopefully conform to rfc850. """ import sys from os import unlink, getpid from socket import gethostbyaddr, gethostname import string from re import findall import time import nntplib import pyginfo import tempfile class mail2news: """news to mail gateway class""" reader = None # mode reader # newsgroups = None # Newsgroups: local.test,local.moderated... # approved = None # Approved: kame@aragorn.lorien.org newsserver = 'localhost' # no comment :) port = 119 user = None password = None hostname = gethostbyaddr(gethostname())[0] heads_dict, smtpheads, nntpheads = {}, {}, {} email, headers, body = [], [], [] def readfile(self): for line in sys.stdin.readlines(): self.email.append(line) if(len(self.email) == 1 and self.email[0][0] == '/'): file = self.email[0][:-1] del self.email[0] for line in open(file,'r').readlines(): self.email.append(line) return 1 def parseemail(self): """get news email from file or stdin and separate heads from body REMEBER: headers value has '\n' as last char. Use string[:-1] to ignore newline. """ try: body = 0 # are we in body or in headers? for line in self.email: if not body and len(line) == 1: body = 1 # starts email body section if not body: try: # if it is a multi-line header like Received: if not line[0] in [' ','\t']: try: head, value = string.split(line, ' ', 1) except string.index_error: value = '' self.smtpheads[head] = value else: self.smtpheads[head] = '%s%s' % \ (self.smtpheads[head], line) except (string.index_error), message: print 'line: %s' % line print '(probably missing couple "Header: value" in %s)' % line sys.exit(1) elif len(line) > 0 and body: self.body.append(line) except (string.index_error), message: print message sys.exit(1) return self.smtpheads, self.body def puthead(self, dict, list, key): """private, transform dict entries in list entries Appends key of dict to list, deleting it from dict. """ if dict.has_key(key): list.append(key + ' ' + dict.get(key)) del dict[key] else: return 0 return 1 def sortheads(self): """make list sorted by heads: From: To: Subject: first, others, X-*, X-Resent-* last""" set = ('Newsgroups:','From:','To:','X-To:','Cc:','Subject:','Date:','Approved:','References:','Message-Id:') # put at top for k in set: self.puthead(self.heads_dict,self.headers,k) for k in self.heads_dict.keys(): if k[:2] != 'X-' and k[:9] != 'X-Resent-' and k not in set: self.puthead(self.heads_dict,self.headers,k) for k in self.heads_dict.keys(): if k[:2] == 'X-': self.puthead(self.heads_dict,self.headers,k) for k in self.heads_dict.keys(): if k[:9] == 'X-Resent-': self.puthead(self.heads_dict,self.headers,k) return self.headers def mergeheads(self): """make a unique headers dictionary from NNTP and SMTP single headers dictionaries.""" self.heads_dict = {} try: for header in self.smtpheads.keys(): # fill it w/ smtp old heads self.heads_dict[header] = self.smtpheads[header] for header in self.nntpheads.keys(): # and replace them w/ nntp new heads self.heads_dict[header] = self.nntpheads[header] except KeyError, message: print message return self.heads_dict def addheads(self): """add new header like X-Gateway: """ info = pyginfo.pygsinfo() try: self.heads_dict['X-Gateway:'] = info.PROGNAME + ' ' + \ info.PROGDESC + ' - Mail to News\n' # it is nntpheads stuff # if(self.newsgroups): # self.heads_dict['Newsgroups:'] = self.newsgroups # if(self.approved): # self.heads_dict['Approved:'] = self.approved except KeyError, message: print message return self.heads_dict def renameheads(self): """rename headers such as Resent-*: to X-Resent-*: headers renamed are useless or not rfc 977/850 copliant handles References/In-Reply-To headers """ try: ### test # if(post): # if(self.heads_dict.has_key(post)): # self.heads_dict['X-Original-' + post] = self.heads_dict[post] # # self.heads_dict[post] = self.heads_dict[pre] # del(self.heads_dict[pre]) # # else: # if(pre[0:2] == 'X-' and self.heads_dict.has_key(pre)): # self.heads_dict['X-Original-' + pre] = self.heads_dict[pre] # elif(not pre[0:2] == 'X-' and self.heads_dict.has_key('X-' + pre)): # self.heads_dict['X-' + pre] = self.heads_dict[pre] # del(self.heads_dict[pre]) ### end test for key in self.heads_dict.keys(): if(key[:7] in ['Resent-']): if(self.heads_dict.has_key('X-' + key)): self.heads_dict[ 'X-Original-' + key ] = self.heads_dict['X-' + key] self.heads_dict[ 'X-' + key ] = self.heads_dict[key] del self.heads_dict[key] # In rfc822 References: is considered, but many MUA doen't put it. if(not self.heads_dict.has_key('References:') and self.heads_dict.has_key('In-Reply-To:')): print self.heads_dict['In-Reply-To:'] # some MUA uses msgid without '<' '>' # ref = findall('([^\s<>\']+@[^\s<>;:\']+)', \ # but I prefer use RFC standards ref = findall('(<[^<>]+@[^<>]+>)', \ self.heads_dict['In-Reply-To:']) # if found, keep first element that seems a Msg-ID. if(ref and len(ref)): self.heads_dict['References:'] = '%s\n' % ref[0] # if(self.heads_dict.has_key('To:')): # self.heads_dict['X-To:'] = self.heads_dict['To:'] # del self.heads_dict['To:'] except KeyError, message: print message return self.heads_dict def removeheads(self, heads = None): """remove headers like Xref: Path: Lines: """ try: # removing some others useless headers .... (From is not From:) rmheads = ['Received:','From','NNTP-Posting-Host:','X-Trace'] if(heads): rmheads.append(heads) for head in rmheads: if self.heads_dict.has_key(head): del self.heads_dict[head] # if self.heads_dict.has_key('From'): # neither 'From ' nor 'From:' # del self.heads_dict['From'] # if self.heads_dict.has_key('NNTP-Posting-Host:'): # neither 'From ' nor 'From:' # del self.heads_dict[''] # if self.heads_dict.has_key('Lines:'): # del self.heads_dict['Lines:'] # it is usually set by INN, if ng is moderated... # if self.heads_dict.has_key('Sender:'): # del self.heads_dict['Sender:'] if self.heads_dict.has_key('Message-id:'): self.heads_dict['Message-Id:'] = self.heads_dict['Message-id:'] del(self.heads_dict['Message-id:']) if self.heads_dict.has_key('Message-ID:'): self.heads_dict['Message-Id:'] = self.heads_dict['Message-ID:'] del(self.heads_dict['Message-ID:']) # If message-id is not present, I generate it if not self.heads_dict.has_key('Message-Id:'): msgid = '\n' % (getpid()) self.heads_dict['Message-Id:'] = msgid except KeyError, message: print message return self.heads_dict def sendemail(self): """Talk to NNTP server and try to send email.""" try: msglist = [] n = nntplib.NNTP(self.newsserver, self.port, self.user, self.password) if(self.reader): n.putline('mode reader') resp = n.getline() print resp resp = n.shortcmd('POST') # sett RFC977 2.4.2 if resp[0] <> '3': raise n.error_reply, str(resp) for line in self.headers: if not line: break if line[-1] == '\n': line = line[:-1] if line[:1] == '.': line = '.' + line n.putline(line) for line in self.body: if not line: break if line[-1] == '\n': line = line[:-1] if line[:1] == '.': line = '.' + line n.putline(line) n.putline('.') n.quit() return None except (nntplib.error_reply, nntplib.error_temp, nntplib.error_perm, nntplib.error_proto, nntplib.error_data), message: return 'NNTP: ' + str(message) pyg-0.9.8ubuntu2/news2mail.py0000644000000000000000000001660312057422101013015 0ustar """News to mail gateway script. Copyright 2000 Cosimo Alfarano Author: Cosimo Alfarano Date: June 11 2000 news2mail.py - Copyright 2000 by Cosimo Alfarano You can use this software under the terms of the GPL. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Thanks to md for this useful formula. Beer is beer. Gets news article and sends it via SMTP. class news2mail is hopefully conform to rfc822. normal (what pygs does) operations flow is: 1) reads from stdin NNTP article (readfile) 2) divide headers and body (parsearticle) 3) merges NNTP and SMTP heads into a unique heads 4) adds, renames and removes some heads 5) sorts remaining headers starting at top with Received: From: To: Subject: Date:, normal headers ending with X-* and Resent-* headers. """ import sys import smtplib import string from re import compile #import getopt import time #import rfc822 from socket import gethostbyaddr, gethostname import tempfile import pyginfo class news2mail: """news to mail gateway class""" TMPFILE = tempfile.mktemp() wlfile = None logfile = None sender = '' rcpt = '' envelope = '' smtpserver = 'localhost' hostname = gethostbyaddr(gethostname())[0] heads_dict, smtpheads, nntpheads = {}, {}, {} article, headers, body = [], [], [] debug = 1 def readfile(self): for line in sys.stdin.readlines(): self.article.append(line) if (len(self.article) == 1 and self.article[0][0] == '/'): file = self.article[0][:-1] del self.article[0] for line in open(file,'r').readlines(): self.article.append(line) def parsearticle(self): """get news article from file or stdin and separate heads from body REMEBER: headers value has '\n' as last char. Use string[:-1] to ignore newline. """ try: body = 0 # are we in body or in headers? # voidline = compile('^$') # I need '\n', ^$ matches anything # spaceending = compile('\s*\n$') for line in self.article: if not body and len(line) == 1: body = 1 # starts article body section if not body: try: head, value = string.split(line, ' ', 1) self.nntpheads[head] = value except (string.index_error), message: print 'string error: %s' % message print '(probably missing couple "Header: value" in %s)' % line sys.exit(1) elif len(line) > 0 and body: self.body.append(line) return self.nntpheads, self.body # except (re.error, string.index_error), message: except (string.index_error), message: print message sys.exit(1) def puthead(self, dict, list, key): """private, x-form dict entries in list entries""" if dict.has_key(key): list.append(key + ' ' + dict.get(key)) else: return 0 return 1 def sortheads(self): """make list sorting heads, Received: From: To: Subject: first, others, X-*, Resent-* last""" set = ('Received:','From:','To:','Subject:','Date:') # put at top for k in set: self.puthead(self.heads_dict,self.headers,k) for k in self.heads_dict.keys(): if k[:2] != 'X-' and k[:7] != 'Resent-' and k not in set: self.puthead(self.heads_dict,self.headers,k) for k in self.heads_dict.keys(): if k[:2] == 'X-': self.puthead(self.heads_dict,self.headers,k) for k in self.heads_dict.keys(): if k[:7] == 'Resent-': self.puthead(self.heads_dict,self.headers,k) return self.headers def mergeheads(self): """make a unique headers dictionary from NNTP and SMTP single headers dictionaries.""" self.heads_dict = {} try: for header in self.nntpheads.keys(): # fill it w/ nntp old heads self.heads_dict[header] = self.nntpheads[header] for header in self.smtpheads.keys(): # and replace them w/ smtp new heads self.heads_dict[header] = self.smtpheads[header] except KeyError, message: print message return self.heads_dict def addheads(self): """add new header like X-Gateway: Received: """ info = pyginfo.pygsinfo() try: self.heads_dict['X-Gateway:'] = info.PROGNAME + ' ' + \ info.__doc__ + '\n' ##self.heads_dict['X-Gateway:'] = '%s %s\n' % (info.PROGNAME, info.__doc__) # to make Received: header t = time.ctime(time.time()) if time.daylight: tzone = time.tzname[1] else: tzone = time.tzname[0] # An exemple from debian-italian: # Received: from murphy.debian.org (murphy.debian.org [216.234.231.6]) # by smv04.iname.net (8.9.3/8.9.1SMV2) with SMTP id JAA26407 # for sent by # ; ' + \ t + ' (' + tzone +')\n' self.heads_dict['Received:'] = tmp except KeyError, message: print message return self.heads_dict def renameheads(self): """rename headers such as Newsgroups: to X-Newsgroups: headers renamed are useless or not rfc 822 copliant """ try: if self.heads_dict.has_key('Newsgroups:'): self.heads_dict['X-Newsgroups:'] = self.heads_dict['Newsgroups:'] del self.heads_dict['Newsgroups:'] if self.heads_dict.has_key('NNTP-Posting-Host:'): self.heads_dict['X-NNTP-Posting-Host:'] = self.heads_dict['NNTP-Posting-Host:'] del self.heads_dict['NNTP-Posting-Host:'] except KeyError, message: print message return self.heads_dict def removeheads(self): """remove headers like Xref: Path: Lines: """ try: # removing some others useless headers .... if self.heads_dict.has_key('Approved:'): del self.heads_dict['Approved:'] if self.heads_dict.has_key('From'): # neither 'From ' nor 'From:' del self.heads_dict['From'] if self.heads_dict.has_key('Xref:'): del self.heads_dict['Xref:'] if self.heads_dict.has_key('Path:'): del self.heads_dict['Path:'] if self.heads_dict.has_key('Lines:'): del self.heads_dict['Lines:'] # it is usually set by INN, if ng is moderated... if self.heads_dict.has_key('Sender:'): del self.heads_dict['Sender:'] if self.heads_dict.has_key('Message-id:'): self.heads_dict['Message-Id:'] = self.heads_dict['Message-id'] del(self.heads_dict['Message-id']) if self.heads_dict.has_key('Message-ID:'): self.heads_dict['Message-Id:'] = self.heads_dict['Message-ID'] del(self.heads_dict['Message-ID']) # If message-id is not present, I generate it if not self.heads_dict.has_key('Message-Id:'): # It should put a real user@domain msgid = 'pyg@puppapera.org' except KeyError, message: print message return self.heads_dict def sendarticle(self): """Talk to SMTP server and try to send email.""" try: msglist = [] s = smtplib.SMTP(self.smtpserver) # put real locahost domain name. s.helo(self.hostname) if s.helo_resp is None and s.ehlo_resp is None: print 'No helo resp' sys.exit(1) resp = s.mail(self.envelope) if resp[0] != 250: print 'SMTP error during MAIL cmd: %s %s' % (resp[0], resp[1]) print 'envelope %s gave problem?' % self.envelope sys.exit(1) resp = s.rcpt(self.rcpt) if resp[0] != 250: print 'SMTP error during MAIL cmd: %s %s' % (resp[0], resp[1]) sys.exit(1) msglist.append(string.join(self.headers,'')) msglist.append(string.join(self.body,'')) msg = string.join(msglist,'') s.data(msg) s.quit() return 1 except (smtplib.SMTPException), messaggio: print messaggio sys.exit(1) pyg-0.9.8ubuntu2/INSTALL0000644000000000000000000000110512057422101011562 0ustar For debian user: Make package as usual: $ dpkg-buildpackage -uc -us -rfakeroot and install .deb file made. For non debian user only: Simply run make: $ make and install file where you want: Something like: $ install -m 0755 -d /usr/local/lib/pyg to create /usr/local/lib/pyg with right permissions $ make install DESTDIR=/usr/local to install file in /usr/local as basedir /usr/local/sbin pygs (pyg frontend) /usr/local/lib/pyg *.py *.so (module classes) You may install manually documentation and examples in examples/ dir in /usr/local/share/doc or where you wish. pyg-0.9.8ubuntu2/README0000644000000000000000000000076012057422101011417 0ustar Pyg is a news to mail and mail to news gateway. It is under devel. List of file: mail2news.py mail to news python class module news2mail.py news to mail python class module pyginfo.py info about pygs python class module pygm2n mail to news gateway frontend pygn2m news to mail gateway frontend whitelist.py whitelist managing python class module wlp_test test script to test yout whitelist file wlp C backend for whitelist parser (wlp) directory examples documentation and exaples directory pyg-0.9.8ubuntu2/tags0000644000000000000000000010506712057422124011433 0ustar !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ !_TAG_PROGRAM_NAME Exuberant Ctags // !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ !_TAG_PROGRAM_VERSION 5.9~svn20110310 // ACCEPT whitelist.py /^ ACCEPT = 1 $/;" v class:whitelist ADDOBJS wlp/module/Makefile /^ADDOBJS= $(LIBPL)\/python.o config.o$/;" m AR wlp/C/Makefile /^AR=ar$/;" m AROPTS wlp/C/Makefile /^AROPTS=-rs$/;" m BASELIB wlp/module/Makefile /^BASELIB= $/;" m BASEMODLIBS wlp/module/Makefile /^BASEMODLIBS= -L$(exec_prefix)\/lib -lz $/;" m BASESETUP wlp/module/Makefile /^BASESETUP= $/;" m BEGIN wlp/C/lex.yy.c 125;" d file: BINDIR Makefile /^BINDIR=$(WLPDIR)$/;" m BINDIR wlp/C/Makefile /^BINDIR=.$/;" m BINDIR wlp/Makefile /^BINDIR=..$/;" m BINDIR wlp/module/Makefile /^BINDIR= $(exec_installdir)\/bin$/;" m BINLIBDEST wlp/module/Makefile /^BINLIBDEST= $(LIBDIR)\/python$(VERSION)$/;" m BLDSHARED wlp/module/Makefile /^BLDSHARED= $(CC) -shared -Wl,-O1 -Wl,-Bsymbolic-functions $(PY_LDFLAGS) $(PY_CFLAGS)$/;" m CC wlp/C/Makefile /^CC=gcc$/;" m CC wlp/module/Makefile /^CC= gcc -pthread$/;" m CCOPTS wlp/C/Makefile /^CCOPTS=-Wall -ansi$/;" m CCSHARED wlp/C/Makefile /^CCSHARED=-fPIC$/;" m CCSHARED wlp/module/Makefile /^CCSHARED= -fPIC$/;" m CFLAGS wlp/module/Makefile /^CFLAGS= $(OPT) -I$(INCLUDEPY) -I$(EXECINCLUDEPY) $(DEFS)$/;" m CONFIGC wlp/module/Makefile /^CONFIGC= $(LIBPL)\/config.c$/;" m CONFIGCIN wlp/module/Makefile /^CONFIGCIN= $(LIBPL)\/config.c.in$/;" m COREPYTHONPATH wlp/module/Makefile /^COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(MACHDEPPATH)$(STDWINPATH)$(TKPATH)$/;" m COREPYTHONPATH wlp/module/Makefile /^COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH)$(OLDPATH)$/;" m CSRCDIR Makefile /^CSRCDIR=$(WLPDIR)\/C$/;" m CSRCDIR wlp/Makefile /^CSRCDIR=C$/;" m CXX wlp/module/Makefile /^CXX= g++ -pthread$/;" m DBG wlp/C/macro.h 33;" d DBG wlp/C/macro.h 37;" d DEFS wlp/module/Makefile /^DEFS= $/;" m DENY whitelist.py /^ DENY = 0$/;" v class:whitelist DESTLIB wlp/module/Makefile /^DESTLIB=$(LIBDEST)$/;" m DESTPATH wlp/module/Makefile /^DESTPATH=$/;" m DESTSHARED wlp/module/Makefile /^DESTSHARED= $(BINLIBDEST)\/site-packages$/;" m E wlp/module/Makefile /^E=exec_prefix$/;" m ECHO wlp/C/lex.yy.c 581;" d file: EOB_ACT_CONTINUE_SCAN wlp/C/lex.yy.c 168;" d file: EOB_ACT_END_OF_FILE wlp/C/lex.yy.c 169;" d file: EOB_ACT_LAST_MATCH wlp/C/lex.yy.c 170;" d file: EOFTOK wlp/C/commands.tab.c /^ EOFTOK = 262$/;" e enum:yytokentype file: EOFTOK wlp/C/commands.tab.h /^ EOFTOK = 262$/;" e enum:yytokentype ERR wlp/C/macro.h 22;" d ERROR wlp/C/commands.tab.c /^ ERROR = 261,$/;" e enum:yytokentype file: ERROR wlp/C/commands.tab.h /^ ERROR = 261,$/;" e enum:yytokentype EXECINCLUDEPY wlp/module/Makefile /^EXECINCLUDEPY= $(exec_installdir)\/include\/python$(VERSION)$/;" m EXIT_SUCCESS wlp/C/commands.tab.c 253;" d file: EXIT_SUCCESS wlp/C/commands.tab.c 281;" d file: EXTRAMACHDEPPATH wlp/module/Makefile /^EXTRAMACHDEPPATH=$/;" m FALSE wlp/C/macro.h 15;" d FLEX wlp/C/Makefile /^FLEX=flex$/;" m FLEXINT_H wlp/C/lex.yy.c 29;" d file: FLEXOPTS wlp/C/Makefile /^FLEXOPTS=$/;" m FLEX_BETA wlp/C/lex.yy.c 13;" d file: FLEX_SCANNER wlp/C/lex.yy.c 8;" d file: GLHACK wlp/module/Makefile /^GLHACK=-Dclear=__GLclear$/;" m H wlp/module/Makefile /^H=Generated automatically from Makefile.pre.in by sedscript.$/;" m INCLUDEDIR wlp/module/Makefile /^INCLUDEDIR= $(installdir)\/include$/;" m INCLUDEPY wlp/module/Makefile /^INCLUDEPY= $(INCLUDEDIR)\/python$(VERSION)$/;" m INITIAL wlp/C/lex.yy.c 489;" d file: INSTALL wlp/module/Makefile /^INSTALL= $(LIBPL)\/install-sh -c$/;" m INSTALL_SHARED wlp/module/Makefile /^INSTALL_SHARED= ${INSTALL} -m 555$/;" m INT16_MAX wlp/C/lex.yy.c 71;" d file: INT16_MIN wlp/C/lex.yy.c 62;" d file: INT32_MAX wlp/C/lex.yy.c 74;" d file: INT32_MIN wlp/C/lex.yy.c 65;" d file: INT8_MAX wlp/C/lex.yy.c 68;" d file: INT8_MIN wlp/C/lex.yy.c 59;" d file: L wlp/module/Makefile /^L=LINKFORSHARED$/;" m LDFLAGS wlp/module/Makefile /^LDFLAGS= @LDFLAGS@$/;" m LDLAST wlp/module/Makefile /^LDLAST= $/;" m LDSHARED wlp/module/Makefile /^LDSHARED= $(CC) -shared -Wl,-O1 -Wl,-Bsymbolic-functions $(PY_LDFLAGS)$/;" m LIBC wlp/module/Makefile /^LIBC= $/;" m LIBDEST wlp/module/Makefile /^LIBDEST= $(SCRIPTDIR)\/python$(VERSION)$/;" m LIBDIR wlp/module/Makefile /^LIBDIR= $(exec_prefix)\/lib$/;" m LIBM wlp/module/Makefile /^LIBM= -lm$/;" m LIBP wlp/module/Makefile /^LIBP= $(exec_installdir)\/lib\/python$(VERSION)$/;" m LIBPL wlp/module/Makefile /^LIBPL= $(LIBP)\/config$/;" m LIBS wlp/module/Makefile /^LIBS= -lpthread -ldl -lutil$/;" m LINELEN wlp/C/macro.h 13;" d LINKCC wlp/module/Makefile /^LINKCC= $(PURIFY) $(MAINCC)$/;" m LINKFORSHARED wlp/module/Makefile /^LINKFORSHARED= -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions$/;" m LOCALMODLIBS wlp/module/Makefile /^LOCALMODLIBS=$/;" m MACHDEP wlp/module/Makefile /^MACHDEP= linux2$/;" m MACHDEPPATH wlp/module/Makefile /^MACHDEPPATH=:plat-$(MACHDEP)$/;" m MACHDESTLIB wlp/module/Makefile /^MACHDESTLIB=$(BINLIBDEST)$/;" m MAJOR pyginfo.py /^ MAJOR = '0'$/;" v class:pygsinfo MAKEFILE wlp/module/Makefile /^MAKEFILE= $(LIBPL)\/Makefile$/;" m MAKESETUP wlp/module/Makefile /^MAKESETUP= $(LIBPL)\/makesetup$/;" m MANDIR wlp/module/Makefile /^MANDIR= $(installdir)\/share\/man$/;" m MINOR pyginfo.py /^ MINOR = '7b'$/;" v class:pygsinfo MODLIBS wlp/module/Makefile /^MODLIBS= $(LOCALMODLIBS) $(BASEMODLIBS)$/;" m MODOBJS wlp/module/Makefile /^MODOBJS= $/;" m MODULEDIR Makefile /^MODULEDIR=$(WLPDIR)\/module$/;" m MODULEDIR wlp/Makefile /^MODULEDIR=module$/;" m OBJFILE wlp/C/Makefile /^OBJFILE=structs.o commands.tab.o lex.yy.o$/;" m OLDPATH wlp/module/Makefile /^OLDPATH=:lib-old$/;" m OPT wlp/module/Makefile /^OPT= -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes$/;" m OWNERID wlp/C/commands.tab.c /^ OWNERID = 260,$/;" e enum:yytokentype file: OWNERID wlp/C/commands.tab.h /^ OWNERID = 260,$/;" e enum:yytokentype P wlp/module/Makefile /^P=prefix$/;" m PROGDESC pyginfo.py /^ PROGDESC= 'The Python Gateway'$/;" v class:pygsinfo PROGNAME pyginfo.py /^ PROGNAME = 'pyg' $/;" v class:pygsinfo PYTHON wlp/module/Makefile /^PYTHON= python$/;" m PYTHONLIBS wlp/module/Makefile /^PYTHONLIBS= $(LIBPL)\/libpython$(VERSION).a$/;" m PYTHONPATH wlp/module/Makefile /^PYTHONPATH=$(COREPYTHONPATH)$/;" m RANLIB wlp/module/Makefile /^RANLIB= ranlib$/;" m REJECT wlp/C/lex.yy.c 475;" d file: SCRIPTDIR wlp/module/Makefile /^SCRIPTDIR= $(prefix)\/lib$/;" m SETUP wlp/module/Makefile /^SETUP= $(LIBPL)\/Setup.config $(LIBPL)\/Setup.local $(LIBPL)\/Setup$/;" m SGI_ABI wlp/module/Makefile /^SGI_ABI= $/;" m SHAREDMODS wlp/module/Makefile /^SHAREDMODS= .\/wlp$(SO)$/;" m SHELL wlp/module/Makefile /^SHELL= \/bin\/sh$/;" m SITEPATH wlp/module/Makefile /^SITEPATH=$/;" m SO wlp/module/Makefile /^SO= .so$/;" m SOLIST wlp/Makefile /^SOLIST=test.so$/;" m SRCDIR wlp/C/Makefile /^SRCDIR=.$/;" m SYSLIBS wlp/module/Makefile /^SYSLIBS= $(LIBM) $(LIBC)$/;" m TARGET wlp/module/Makefile /^TARGET= python$/;" m TESTPATH wlp/module/Makefile /^TESTPATH=$/;" m TKPATH wlp/module/Makefile /^TKPATH=:lib-tk$/;" m TMPFILE news2mail.py /^ TMPFILE = tempfile.mktemp()$/;" v class:news2mail TRUE wlp/C/macro.h 14;" d UINT16_MAX wlp/C/lex.yy.c 80;" d file: UINT32_MAX wlp/C/lex.yy.c 83;" d file: UINT8_MAX wlp/C/lex.yy.c 77;" d file: VALID wlp/C/commands.tab.c /^ VALID = 259,$/;" e enum:yytokentype file: VALID wlp/C/commands.tab.h /^ VALID = 259,$/;" e enum:yytokentype VARID wlp/C/commands.tab.c /^ VARID = 258,$/;" e enum:yytokentype file: VARID wlp/C/commands.tab.h /^ VARID = 258,$/;" e enum:yytokentype VDBG wlp/C/macro.h 35;" d VDBG wlp/C/macro.h 38;" d VERSION pyginfo.py /^ VERSION = MAJOR + '.' + MINOR$/;" v class:pygsinfo VERSION wlp/module/Makefile /^ VERSION=`$(PYTHON) -c "import sys; print sys.version[:3]"`; \\$/;" m VERSION wlp/module/Makefile /^VERSION= 2.7$/;" m VPATH wlp/module/Makefile /^VPATH= .$/;" m WLPDIR Makefile /^WLPDIR=wlp$/;" m WLPSRCDIR wlp/module/Makefile /^WLPSRCDIR=..\/C$/;" m YACC wlp/C/Makefile /^YACC=bison$/;" m YACCOPTS wlp/C/Makefile /^YACCOPTS=-d$/;" m YYABORT wlp/C/commands.tab.c 541;" d file: YYACCEPT wlp/C/commands.tab.c 540;" d file: YYBACKUP wlp/C/commands.tab.c 562;" d file: YYBISON wlp/C/commands.tab.c 44;" d file: YYBISON_VERSION wlp/C/commands.tab.c 47;" d file: YYCASE_ wlp/C/commands.tab.c 1004;" d file: YYCASE_ wlp/C/commands.tab.c 994;" d file: YYCOPY wlp/C/commands.tab.c 347;" d file: YYCOPY wlp/C/commands.tab.c 350;" d file: YYCOPY_NEEDED wlp/C/commands.tab.c 322;" d file: YYDEBUG wlp/C/commands.tab.c 82;" d file: YYDPRINTF wlp/C/commands.tab.c 632;" d file: YYDPRINTF wlp/C/commands.tab.c 781;" d file: YYEMPTY wlp/C/commands.tab.c 537;" d file: YYEOF wlp/C/commands.tab.c 538;" d file: YYERRCODE wlp/C/commands.tab.c 580;" d file: YYERROR wlp/C/commands.tab.c 542;" d file: YYERROR_VERBOSE wlp/C/commands.tab.c 87;" d file: YYERROR_VERBOSE wlp/C/commands.tab.c 88;" d file: YYERROR_VERBOSE wlp/C/commands.tab.c 90;" d file: YYFAIL wlp/C/commands.tab.c 552;" d file: YYFINAL wlp/C/commands.tab.c 363;" d file: YYFPRINTF wlp/C/commands.tab.c 629;" d file: YYFREE wlp/C/commands.tab.c 292;" d file: YYID wlp/C/commands.tab.c /^YYID (int yyi)$/;" f file: YYID wlp/C/commands.tab.c 216;" d file: YYINITDEPTH wlp/C/commands.tab.c 790;" d file: YYLAST wlp/C/commands.tab.c 365;" d file: YYLEX wlp/C/commands.tab.c 619;" d file: YYLEX wlp/C/commands.tab.c 621;" d file: YYLLOC_DEFAULT wlp/C/commands.tab.c 589;" d file: YYLSP_NEEDED wlp/C/commands.tab.c 62;" d file: YYMALLOC wlp/C/commands.tab.c 285;" d file: YYMAXDEPTH wlp/C/commands.tab.c 801;" d file: YYMAXUTOK wlp/C/commands.tab.c 378;" d file: YYNNTS wlp/C/commands.tab.c 370;" d file: YYNRULES wlp/C/commands.tab.c 372;" d file: YYNSTATES wlp/C/commands.tab.c 374;" d file: YYNTOKENS wlp/C/commands.tab.c 368;" d file: YYPACT_NINF wlp/C/commands.tab.c 492;" d file: YYPOPSTACK wlp/C/commands.tab.c 1165;" d file: YYPULL wlp/C/commands.tab.c 59;" d file: YYPURE wlp/C/commands.tab.c 53;" d file: YYPUSH wlp/C/commands.tab.c 56;" d file: YYRECOVERING wlp/C/commands.tab.c 560;" d file: YYRHSLOC wlp/C/commands.tab.c 587;" d file: YYSIZE_MAXIMUM wlp/C/commands.tab.c 193;" d file: YYSIZE_T wlp/C/commands.tab.c 181;" d file: YYSIZE_T wlp/C/commands.tab.c 183;" d file: YYSIZE_T wlp/C/commands.tab.c 187;" d file: YYSIZE_T wlp/C/commands.tab.c 189;" d file: YYSKELETON_NAME wlp/C/commands.tab.c 50;" d file: YYSTACK_ALLOC wlp/C/commands.tab.c 239;" d file: YYSTACK_ALLOC wlp/C/commands.tab.c 243;" d file: YYSTACK_ALLOC wlp/C/commands.tab.c 248;" d file: YYSTACK_ALLOC wlp/C/commands.tab.c 271;" d file: YYSTACK_ALLOC_MAXIMUM wlp/C/commands.tab.c 268;" d file: YYSTACK_ALLOC_MAXIMUM wlp/C/commands.tab.c 274;" d file: YYSTACK_BYTES wlp/C/commands.tab.c 318;" d file: YYSTACK_FREE wlp/C/commands.tab.c 262;" d file: YYSTACK_FREE wlp/C/commands.tab.c 272;" d file: YYSTACK_GAP_MAXIMUM wlp/C/commands.tab.c 314;" d file: YYSTACK_RELOCATE wlp/C/commands.tab.c 329;" d file: YYSTATE wlp/C/lex.yy.c 132;" d file: YYSTYPE wlp/C/commands.tab.c /^typedef union YYSTYPE$/;" u file: YYSTYPE wlp/C/commands.tab.c /^} YYSTYPE;$/;" t typeref:union:YYSTYPE file: YYSTYPE wlp/C/commands.tab.h /^typedef union YYSTYPE$/;" u YYSTYPE wlp/C/commands.tab.h /^} YYSTYPE;$/;" t typeref:union:YYSTYPE YYSTYPE_IS_DECLARED wlp/C/commands.tab.c 132;" d file: YYSTYPE_IS_DECLARED wlp/C/commands.tab.h 67;" d YYSTYPE_IS_TRIVIAL wlp/C/commands.tab.c 130;" d file: YYSTYPE_IS_TRIVIAL wlp/C/commands.tab.h 65;" d YYTABLES_NAME wlp/C/lex.yy.c 1823;" d file: YYTABLE_NINF wlp/C/commands.tab.c 508;" d file: YYTERROR wlp/C/commands.tab.c 579;" d file: YYTOKENTYPE wlp/C/commands.tab.c 101;" d file: YYTOKENTYPE wlp/C/commands.tab.h 36;" d YYTOKEN_TABLE wlp/C/commands.tab.c 95;" d file: YYTRANSLATE wlp/C/commands.tab.c 380;" d file: YYUNDEFTOK wlp/C/commands.tab.c 377;" d file: YYUSE wlp/C/commands.tab.c 209;" d file: YYUSE wlp/C/commands.tab.c 211;" d file: YY_ wlp/C/commands.tab.c 199;" d file: YY_ wlp/C/commands.tab.c 203;" d file: YY_AT_BOL wlp/C/lex.yy.c 339;" d file: YY_BREAK wlp/C/lex.yy.c 660;" d file: YY_BUFFER_EOF_PENDING wlp/C/lex.yy.c 255;" d file: YY_BUFFER_NEW wlp/C/lex.yy.c 243;" d file: YY_BUFFER_NORMAL wlp/C/lex.yy.c 244;" d file: YY_BUFFER_STATE wlp/C/lex.yy.c /^typedef struct yy_buffer_state *YY_BUFFER_STATE;$/;" t typeref:struct:yy_buffer_state file: YY_BUF_SIZE wlp/C/lex.yy.c 149;" d file: YY_BUF_SIZE wlp/C/lex.yy.c 151;" d file: YY_CHAR wlp/C/lex.yy.c /^typedef unsigned char YY_CHAR;$/;" t file: YY_CURRENT_BUFFER wlp/C/lex.yy.c 271;" d file: YY_CURRENT_BUFFER_LVALUE wlp/C/lex.yy.c 278;" d file: YY_DECL wlp/C/lex.yy.c 648;" d file: YY_DECL_IS_OURS wlp/C/lex.yy.c 644;" d file: YY_DO_BEFORE_ACTION wlp/C/lex.yy.c 367;" d file: YY_END_OF_BUFFER wlp/C/lex.yy.c 375;" d file: YY_END_OF_BUFFER_CHAR wlp/C/lex.yy.c 140;" d file: YY_EXIT_FAILURE wlp/C/lex.yy.c 1621;" d file: YY_EXTRA_TYPE wlp/C/lex.yy.c 500;" d file: YY_FATAL_ERROR wlp/C/lex.yy.c 635;" d file: YY_FLEX_MAJOR_VERSION wlp/C/lex.yy.c 9;" d file: YY_FLEX_MINOR_VERSION wlp/C/lex.yy.c 10;" d file: YY_FLEX_SUBMINOR_VERSION wlp/C/lex.yy.c 11;" d file: YY_FLUSH_BUFFER wlp/C/lex.yy.c 307;" d file: YY_INPUT wlp/C/lex.yy.c 588;" d file: YY_INT_ALIGNED wlp/C/lex.yy.c 4;" d file: YY_LESS_LINENO wlp/C/lex.yy.c 172;" d file: YY_LOCATION_PRINT wlp/C/commands.tab.c 612;" d file: YY_MORE_ADJ wlp/C/lex.yy.c 477;" d file: YY_NEW_FILE wlp/C/lex.yy.c 138;" d file: YY_NULL wlp/C/lex.yy.c 112;" d file: YY_NUM_RULES wlp/C/lex.yy.c 374;" d file: YY_READ_BUF_SIZE wlp/C/lex.yy.c 570;" d file: YY_READ_BUF_SIZE wlp/C/lex.yy.c 572;" d file: YY_REDUCE_PRINT wlp/C/commands.tab.c 771;" d file: YY_REDUCE_PRINT wlp/C/commands.tab.c 784;" d file: YY_RESTORE_YY_MORE_OFFSET wlp/C/lex.yy.c 478;" d file: YY_RULE_SETUP wlp/C/lex.yy.c 663;" d file: YY_SC_TO_UI wlp/C/lex.yy.c 119;" d file: YY_SKIP_YYWRAP wlp/C/lex.yy.c 344;" d file: YY_STACK_PRINT wlp/C/commands.tab.c 733;" d file: YY_STACK_PRINT wlp/C/commands.tab.c 783;" d file: YY_START wlp/C/lex.yy.c 131;" d file: YY_START_STACK_INCR wlp/C/lex.yy.c 630;" d file: YY_STATE_BUF_SIZE wlp/C/lex.yy.c 157;" d file: YY_STATE_EOF wlp/C/lex.yy.c 135;" d file: YY_STRUCT_YY_BUFFER_STATE wlp/C/lex.yy.c 196;" d file: YY_SYMBOL_PRINT wlp/C/commands.tab.c 638;" d file: YY_SYMBOL_PRINT wlp/C/commands.tab.c 782;" d file: YY_TYPEDEF_YY_BUFFER_STATE wlp/C/lex.yy.c 160;" d file: YY_TYPEDEF_YY_SIZE_T wlp/C/lex.yy.c 191;" d file: YY_USER_ACTION wlp/C/lex.yy.c 655;" d file: YY_USE_CONST wlp/C/lex.yy.c 100;" d file: YY_USE_CONST wlp/C/lex.yy.c 93;" d file: _PyImport_Inittab wlp/module/config.c /^struct _inittab _PyImport_Inittab[] = {$/;" v typeref:struct:_inittab __STDC_LIMIT_MACROS wlp/C/lex.yy.c 39;" d file: __init__ whitelist.py /^ def __init__(self, wlfile='wl.pyg', logfile='pyg.log', debug=0):$/;" m class:whitelist _macro_h_ wlp/C/macro.h 11;" d _structs_h_ wlp/C/structs.h 10;" d addheads mail2news.py /^ def addheads(self):$/;" m class:mail2news addheads news2mail.py /^ def addheads(self):$/;" m class:news2mail alloca wlp/C/commands.tab.c 246;" d file: block wlp/C/commands.y /^block:$/;" l blockstatement wlp/C/commands.y /^blockstatement:$/;" l c wlp/C/commands.tab.c /^ char c;$/;" m union:YYSTYPE file: c wlp/C/commands.tab.h /^ char c;$/;" m union:YYSTYPE checkfrom whitelist.py /^ def checkfrom(self, fromhead):$/;" m class:whitelist command wlp/C/commands.y /^command:$/;" l commandline wlp/C/commands.y /^commandline: $/;" l count wlp/C/structs.h /^ int count;$/;" m struct:wlp_list_t debug news2mail.py /^ debug = 1$/;" v class:news2mail debug whitelist.py /^ debug = None$/;" v class:whitelist dict wlp_test /^dict = wlp.mkdict()$/;" v envelope news2mail.py /^ envelope = ''$/;" v class:news2mail exec_installdir wlp/module/Makefile /^exec_installdir=\/usr$/;" m exec_prefix wlp/module/Makefile /^exec_prefix= ${prefix}$/;" m fd wlp/C/test.c /^static FILE *fd = NULL;$/;" v file: fd wlp/C/wlp.c /^static FILE *fd = NULL;$/;" v file: flex_int16_t wlp/C/lex.yy.c /^typedef int16_t flex_int16_t;$/;" t file: flex_int16_t wlp/C/lex.yy.c /^typedef short int flex_int16_t;$/;" t file: flex_int32_t wlp/C/lex.yy.c /^typedef int flex_int32_t;$/;" t file: flex_int32_t wlp/C/lex.yy.c /^typedef int32_t flex_int32_t;$/;" t file: flex_int8_t wlp/C/lex.yy.c /^typedef int8_t flex_int8_t;$/;" t file: flex_int8_t wlp/C/lex.yy.c /^typedef signed char flex_int8_t;$/;" t file: flex_uint16_t wlp/C/lex.yy.c /^typedef uint16_t flex_uint16_t;$/;" t file: flex_uint16_t wlp/C/lex.yy.c /^typedef unsigned short int flex_uint16_t;$/;" t file: flex_uint32_t wlp/C/lex.yy.c /^typedef uint32_t flex_uint32_t;$/;" t file: flex_uint32_t wlp/C/lex.yy.c /^typedef unsigned int flex_uint32_t;$/;" t file: flex_uint8_t wlp/C/lex.yy.c /^typedef uint8_t flex_uint8_t;$/;" t file: flex_uint8_t wlp/C/lex.yy.c /^typedef unsigned char flex_uint8_t; $/;" t file: found wlp/C/commands.tab.c /^int found(const char* left, const char* right, const char *owner)$/;" f head wlp/C/structs.h /^ struct wlp_node_t *head, *tail;$/;" m struct:wlp_list_t typeref:struct:wlp_list_t::wlp_node_t hostname mail2news.py /^ hostname = gethostbyaddr(gethostname())[0]$/;" v class:mail2news hostname news2mail.py /^ hostname = gethostbyaddr(gethostname())[0]$/;" v class:news2mail initwlp wlp/C/test.c /^void initwlp() {$/;" f initwlp wlp/C/wlp.c /^void initwlp() {$/;" f installdir wlp/module/Makefile /^installdir= \/usr$/;" m left wlp/C/commands.tab.c /^char left[80], right[80], owner[80];$/;" v left wlp/C/structs.h /^ char *left,*right;$/;" m struct:wlp_node_t list wlp/C/test.c /^struct wlp_list_t *list;$/;" v typeref:struct:wlp_list_t list wlp/C/wlp.c /^struct wlp_list_t *list;$/;" v typeref:struct:wlp_list_t list wlp/C/yytest.c /^struct wlp_list_t *list;$/;" v typeref:struct:wlp_list_t lock whitelist.py /^ def lock(self):$/;" m class:whitelist log pygn2m /^ log = n2m.logfile$/;" v log pygn2m /^ log = os.environ['HOME'] + '\/pyg.log'$/;" v log whitelist.py /^ def log(self, string):$/;" m class:whitelist log whitelist.py /^ log = None # filedescriptor$/;" v class:whitelist logfile news2mail.py /^ logfile = None$/;" v class:news2mail logmsg whitelist.py /^ def logmsg(self, heads, ok=DENY,owner=None):$/;" m class:whitelist m2n pygm2n /^ m2n = mail2news.mail2news()$/;" v mail2news mail2news.py /^class mail2news:$/;" c main wlp/C/yytest.c /^int main(int argc,char **argv) {$/;" f mergeheads mail2news.py /^ def mergeheads(self):$/;" m class:mail2news mergeheads news2mail.py /^ def mergeheads(self):$/;" m class:news2mail n2m pygn2m /^ n2m = news2mail.news2mail()$/;" v news2mail news2mail.py /^class news2mail:$/;" c newsserver mail2news.py /^ newsserver = 'localhost' # no comment :)$/;" v class:mail2news next wlp/C/structs.h /^ struct wlp_node_t *next, *prev;$/;" m struct:wlp_node_t typeref:struct:wlp_node_t::wlp_node_t node2dict wlp/C/test.c /^static PyObject *node2dict(struct wlp_node_t *node) {$/;" f file: node2dict wlp/C/wlp.c /^static PyObject *node2dict(struct wlp_node_t *node) {$/;" f file: opt pygm2n /^ opt = parse_cmdline(m2n)$/;" v options wlp_test /^ options = dict[owner]$/;" v owner pygm2n /^ owner = None$/;" v owner pygn2m /^ owner = None$/;" v owner pygn2m /^ owner = wl.checkfrom(n2m.nntpheads['From:'])$/;" v owner wlp/C/commands.tab.c /^char left[80], right[80], owner[80];$/;" v owner wlp/C/commands.y /^owner:$/;" l owner wlp/C/structs.h /^ char *owner;$/;" m struct:wlp_node_t parse wlp/C/lex.yy.c /^int parse(FILE *file)$/;" f parse_cmdline pygm2n /^def parse_cmdline(gw):$/;" f parse_cmdline pygn2m /^def parse_cmdline(gw):$/;" f parsearticle news2mail.py /^ def parsearticle(self):$/;" m class:news2mail parseemail mail2news.py /^ def parseemail(self):$/;" m class:mail2news password mail2news.py /^ password = None$/;" v class:mail2news port mail2news.py /^ port = 119$/;" v class:mail2news prefix wlp/module/Makefile /^prefix= \/usr$/;" m prev wlp/C/structs.h /^ struct wlp_node_t *next, *prev;$/;" m struct:wlp_node_t typeref:struct:wlp_node_t:: puthead mail2news.py /^ def puthead(self, dict, list, key):$/;" m class:mail2news puthead news2mail.py /^ def puthead(self, dict, list, key):$/;" m class:news2mail pygsinfo pyginfo.py /^class pygsinfo:$/;" c rcpt news2mail.py /^ rcpt = ''$/;" v class:news2mail reader mail2news.py /^ reader = None # mode reader$/;" v class:mail2news readfile mail2news.py /^ def readfile(self):$/;" m class:mail2news readfile news2mail.py /^ def readfile(self):$/;" m class:news2mail removeheads mail2news.py /^ def removeheads(self, heads = None):$/;" m class:mail2news removeheads news2mail.py /^ def removeheads(self):$/;" m class:news2mail renameheads mail2news.py /^ def renameheads(self):$/;" m class:mail2news renameheads news2mail.py /^ def renameheads(self):$/;" m class:news2mail resp pygm2n /^ resp = m2n.sendemail()$/;" v right wlp/C/commands.tab.c /^char left[80], right[80], owner[80];$/;" v right wlp/C/structs.h /^ char *left,*right;$/;" m struct:wlp_node_t sendarticle news2mail.py /^ def sendarticle(self):$/;" m class:news2mail sendemail mail2news.py /^ def sendemail(self):$/;" m class:mail2news sender news2mail.py /^ sender = ''$/;" v class:news2mail short wlp/C/commands.tab.c 149;" d file: smtpserver news2mail.py /^ smtpserver = 'localhost'$/;" v class:news2mail sortheads mail2news.py /^ def sortheads(self):$/;" m class:mail2news sortheads news2mail.py /^ def sortheads(self):$/;" m class:news2mail srcdir wlp/module/Makefile /^srcdir= .$/;" m tail wlp/C/structs.h /^ struct wlp_node_t *head, *tail;$/;" m struct:wlp_list_t typeref:struct:wlp_list_t:: text wlp/C/commands.tab.c /^ char *text;$/;" m union:YYSTYPE file: text wlp/C/commands.tab.h /^ char *text;$/;" m union:YYSTYPE type wlp/C/commands.tab.c /^char type = 0; \/*unused*\/$/;" v type wlp/C/structs.h /^ char type; \/* unused *\/$/;" m struct:wlp_node_t unlock whitelist.py /^ def unlock(self):$/;" m class:whitelist unput wlp/C/lex.yy.c 188;" d file: usage pygm2n /^def usage():$/;" f usage pygn2m /^def usage():$/;" f user mail2news.py /^ user = None$/;" v class:mail2news valpart wlp/C/commands.y /^valpart:$/;" l varpart wlp/C/commands.y /^varpart:$/;" l whitelist whitelist.py /^class whitelist:$/;" c wl pygn2m /^ wl = n2m.wlfile$/;" v wl pygn2m /^ wl = os.environ['HOME'] + '\/pyg.whitelist'$/;" v wl pygn2m /^ wl = whitelist.whitelist(wl,log)$/;" v wl whitelist.py /^ wl = {}$/;" v class:whitelist wlfile news2mail.py /^ wlfile = None$/;" v class:news2mail wlp_list_t wlp/C/structs.h /^typedef struct wlp_list_t {$/;" s wlp_list_t wlp/C/structs.h /^} wlp_list_t;$/;" t typeref:struct:wlp_list_t wlp_methods wlp/C/test.c /^static PyMethodDef wlp_methods[] = {$/;" v file: wlp_methods wlp/C/wlp.c /^static PyMethodDef wlp_methods[] = {$/;" v file: wlp_mkdict wlp/C/wlp.c /^static PyObject *wlp_mkdict(PyObject *self, PyObject *args) {$/;" f file: wlp_mklist wlp/C/test.c /^static PyObject *wlp_mklist(PyObject *self, PyObject *args) {$/;" f file: wlp_node_t wlp/C/structs.h /^typedef struct wlp_node_t {$/;" s wlp_node_t wlp/C/structs.h /^} wlp_node_t;$/;" t typeref:struct:wlp_node_t wlp_setfilebyfd wlp/C/test.c /^static PyObject *wlp_setfilebyfd(PyObject *self, PyObject *args) {$/;" f file: wlp_setfilebyfd wlp/C/wlp.c /^static PyObject *wlp_setfilebyfd(PyObject *self, PyObject *args) {$/;" f file: wlp_setfilebyname wlp/C/test.c /^static PyObject *wlp_setfilebyname(PyObject *self, PyObject *args) {$/;" f file: wlp_setfilebyname wlp/C/wlp.c /^static PyObject *wlp_setfilebyname(PyObject *self, PyObject *args) {$/;" f file: wlpl_init wlp/C/structs.c /^struct wlp_list_t *wlpl_init(struct wlp_node_t *node)$/;" f wlpn_add wlp/C/structs.c /^struct wlp_node_t *wlpn_add(struct wlp_list_t *list,struct wlp_node_t *node)$/;" f wlpn_alloc wlp/C/structs.c /^struct wlp_node_t *wlpn_alloc(const char empty)$/;" f wlpn_extract wlp/C/structs.c /^struct wlp_node_t *wlpn_extract(struct wlp_list_t *list,struct wlp_node_t *node)$/;" f wlpn_free wlp/C/structs.c /^void wlpn_free(struct wlp_node_t *node)$/;" f wlpn_searchowner wlp/C/structs.c /^struct wlp_node_t *wlpn_searchowner(struct wlp_list_t *mbl,const char *owner)$/;" f yy_accept wlp/C/lex.yy.c /^static yyconst flex_int16_t yy_accept[26] =$/;" v file: yy_at_bol wlp/C/lex.yy.c /^ int yy_at_bol;$/;" m struct:yy_buffer_state file: yy_base wlp/C/lex.yy.c /^static yyconst flex_int16_t yy_base[31] =$/;" v file: yy_bs_column wlp/C/lex.yy.c /^ int yy_bs_column; \/**< The column count. *\/$/;" m struct:yy_buffer_state file: yy_bs_lineno wlp/C/lex.yy.c /^ int yy_bs_lineno; \/**< The line count. *\/$/;" m struct:yy_buffer_state file: yy_buf_pos wlp/C/lex.yy.c /^ char *yy_buf_pos; \/* current position in input buffer *\/$/;" m struct:yy_buffer_state file: yy_buf_size wlp/C/lex.yy.c /^ yy_size_t yy_buf_size;$/;" m struct:yy_buffer_state file: yy_buffer_stack wlp/C/lex.yy.c /^static YY_BUFFER_STATE * yy_buffer_stack = 0; \/**< Stack as an array. *\/$/;" v file: yy_buffer_stack_max wlp/C/lex.yy.c /^static size_t yy_buffer_stack_max = 0; \/**< capacity of stack. *\/$/;" v file: yy_buffer_stack_top wlp/C/lex.yy.c /^static size_t yy_buffer_stack_top = 0; \/**< index of top of stack. *\/$/;" v file: yy_buffer_state wlp/C/lex.yy.c /^struct yy_buffer_state$/;" s file: yy_buffer_status wlp/C/lex.yy.c /^ int yy_buffer_status;$/;" m struct:yy_buffer_state file: yy_c_buf_p wlp/C/lex.yy.c /^static char *yy_c_buf_p = (char *) 0;$/;" v file: yy_ch_buf wlp/C/lex.yy.c /^ char *yy_ch_buf; \/* input buffer *\/$/;" m struct:yy_buffer_state file: yy_chk wlp/C/lex.yy.c /^static yyconst flex_int16_t yy_chk[75] =$/;" v file: yy_create_buffer wlp/C/lex.yy.c /^ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )$/;" f yy_def wlp/C/lex.yy.c /^static yyconst flex_int16_t yy_def[31] =$/;" v file: yy_delete_buffer wlp/C/lex.yy.c /^ void yy_delete_buffer (YY_BUFFER_STATE b )$/;" f yy_did_buffer_switch_on_eof wlp/C/lex.yy.c /^static int yy_did_buffer_switch_on_eof;$/;" v file: yy_ec wlp/C/lex.yy.c /^static yyconst flex_int32_t yy_ec[256] =$/;" v file: yy_fatal_error wlp/C/lex.yy.c /^static void yy_fatal_error (yyconst char* msg )$/;" f file: yy_fill_buffer wlp/C/lex.yy.c /^ int yy_fill_buffer;$/;" m struct:yy_buffer_state file: yy_flex_debug wlp/C/lex.yy.c /^int yy_flex_debug = 0;$/;" v yy_flex_strlen wlp/C/lex.yy.c /^static int yy_flex_strlen (yyconst char * s )$/;" f file: yy_flex_strncpy wlp/C/lex.yy.c /^static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )$/;" f file: yy_flush_buffer wlp/C/lex.yy.c /^ void yy_flush_buffer (YY_BUFFER_STATE b )$/;" f yy_get_next_buffer wlp/C/lex.yy.c /^static int yy_get_next_buffer (void)$/;" f file: yy_get_previous_state wlp/C/lex.yy.c /^ static yy_state_type yy_get_previous_state (void)$/;" f file: yy_hold_char wlp/C/lex.yy.c /^static char yy_hold_char;$/;" v file: yy_init wlp/C/lex.yy.c /^static int yy_init = 0; \/* whether we need to initialize *\/$/;" v file: yy_init_buffer wlp/C/lex.yy.c /^ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )$/;" f file: yy_init_globals wlp/C/lex.yy.c /^static int yy_init_globals (void)$/;" f file: yy_input_file wlp/C/lex.yy.c /^ FILE *yy_input_file;$/;" m struct:yy_buffer_state file: yy_is_interactive wlp/C/lex.yy.c /^ int yy_is_interactive;$/;" m struct:yy_buffer_state file: yy_is_our_buffer wlp/C/lex.yy.c /^ int yy_is_our_buffer;$/;" m struct:yy_buffer_state file: yy_last_accepting_cpos wlp/C/lex.yy.c /^static char *yy_last_accepting_cpos;$/;" v file: yy_last_accepting_state wlp/C/lex.yy.c /^static yy_state_type yy_last_accepting_state;$/;" v file: yy_load_buffer_state wlp/C/lex.yy.c /^static void yy_load_buffer_state (void)$/;" f file: yy_meta wlp/C/lex.yy.c /^static yyconst flex_int32_t yy_meta[18] =$/;" v file: yy_n_chars wlp/C/lex.yy.c /^ int yy_n_chars;$/;" m struct:yy_buffer_state file: yy_n_chars wlp/C/lex.yy.c /^static int yy_n_chars; \/* number of characters read into yy_ch_buf *\/$/;" v file: yy_new_buffer wlp/C/lex.yy.c 317;" d file: yy_nxt wlp/C/lex.yy.c /^ flex_int32_t yy_nxt;$/;" m struct:yy_trans_info file: yy_nxt wlp/C/lex.yy.c /^static yyconst flex_int16_t yy_nxt[75] =$/;" v file: yy_reduce_print wlp/C/commands.tab.c /^yy_reduce_print (YYSTYPE *yyvsp, int yyrule)$/;" f file: yy_scan_buffer wlp/C/lex.yy.c /^YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )$/;" f yy_scan_bytes wlp/C/lex.yy.c /^YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )$/;" f yy_scan_string wlp/C/lex.yy.c /^YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )$/;" f yy_set_bol wlp/C/lex.yy.c 329;" d file: yy_set_interactive wlp/C/lex.yy.c 319;" d file: yy_size_t wlp/C/lex.yy.c /^typedef size_t yy_size_t;$/;" t file: yy_stack_print wlp/C/commands.tab.c /^yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)$/;" f file: yy_start wlp/C/lex.yy.c /^static int yy_start = 0; \/* start state number *\/$/;" v file: yy_state_type wlp/C/lex.yy.c /^typedef int yy_state_type;$/;" t file: yy_switch_to_buffer wlp/C/lex.yy.c /^ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )$/;" f yy_symbol_print wlp/C/commands.tab.c /^yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)$/;" f file: yy_symbol_value_print wlp/C/commands.tab.c /^yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)$/;" f file: yy_trans_info wlp/C/lex.yy.c /^struct yy_trans_info$/;" s file: yy_try_NUL_trans wlp/C/lex.yy.c /^ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )$/;" f file: yy_verify wlp/C/lex.yy.c /^ flex_int32_t yy_verify;$/;" m struct:yy_trans_info file: yyalloc wlp/C/commands.tab.c /^union yyalloc$/;" u file: yyalloc wlp/C/lex.yy.c /^void *yyalloc (yy_size_t size )$/;" f yychar wlp/C/commands.tab.c /^int yychar;$/;" v yycheck wlp/C/commands.tab.c /^static const yytype_int8 yycheck[] =$/;" v file: yyclearin wlp/C/commands.tab.c 536;" d file: yyconst wlp/C/lex.yy.c 106;" d file: yyconst wlp/C/lex.yy.c 108;" d file: yydebug wlp/C/commands.tab.c /^int yydebug;$/;" v yydefact wlp/C/commands.tab.c /^static const yytype_uint8 yydefact[] =$/;" v file: yydefgoto wlp/C/commands.tab.c /^static const yytype_int8 yydefgoto[] =$/;" v file: yydestruct wlp/C/commands.tab.c /^yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)$/;" f file: yyensure_buffer_stack wlp/C/lex.yy.c /^static void yyensure_buffer_stack (void)$/;" f file: yyerrok wlp/C/commands.tab.c 535;" d file: yyerror wlp/C/commands.tab.c /^int yyerror (char *s) \/* Called by yyparse on error *\/$/;" f yyfree wlp/C/lex.yy.c /^void yyfree (void * ptr )$/;" f yyget_debug wlp/C/lex.yy.c /^int yyget_debug (void)$/;" f yyget_in wlp/C/lex.yy.c /^FILE *yyget_in (void)$/;" f yyget_leng wlp/C/lex.yy.c /^int yyget_leng (void)$/;" f yyget_lineno wlp/C/lex.yy.c /^int yyget_lineno (void)$/;" f yyget_out wlp/C/lex.yy.c /^FILE *yyget_out (void)$/;" f yyget_text wlp/C/lex.yy.c /^char *yyget_text (void)$/;" f yyin wlp/C/lex.yy.c /^FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;$/;" v yyinput wlp/C/lex.yy.c /^ static int yyinput (void)$/;" f file: yyleng wlp/C/lex.yy.c /^int yyleng;$/;" v yyless wlp/C/lex.yy.c 1632;" d file: yyless wlp/C/lex.yy.c 1633;" d file: yyless wlp/C/lex.yy.c 175;" d file: yylex_destroy wlp/C/lex.yy.c /^int yylex_destroy (void)$/;" f yylineno wlp/C/lex.yy.c /^int yylineno = 1;$/;" v yylval wlp/C/commands.tab.c /^YYSTYPE yylval;$/;" v yymore wlp/C/lex.yy.c 476;" d file: yynerrs wlp/C/commands.tab.c /^int yynerrs;$/;" v yyout wlp/C/lex.yy.c /^FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;$/;" v yypact wlp/C/commands.tab.c /^static const yytype_int8 yypact[] =$/;" v file: yypact_value_is_default wlp/C/commands.tab.c 515;" d file: yyparse wlp/C/commands.tab.c /^yyparse (void *YYPARSE_PARAM)$/;" f yypgoto wlp/C/commands.tab.c /^static const yytype_int8 yypgoto[] =$/;" v file: yypop_buffer_state wlp/C/lex.yy.c /^void yypop_buffer_state (void)$/;" f yyprhs wlp/C/commands.tab.c /^static const yytype_uint8 yyprhs[] =$/;" v file: yypush_buffer_state wlp/C/lex.yy.c /^void yypush_buffer_state (YY_BUFFER_STATE new_buffer )$/;" f yyr1 wlp/C/commands.tab.c /^static const yytype_uint8 yyr1[] =$/;" v file: yyr2 wlp/C/commands.tab.c /^static const yytype_uint8 yyr2[] =$/;" v file: yyrealloc wlp/C/lex.yy.c /^void *yyrealloc (void * ptr, yy_size_t size )$/;" f yyrestart wlp/C/lex.yy.c /^ void yyrestart (FILE * input_file )$/;" f yyrhs wlp/C/commands.tab.c /^static const yytype_int8 yyrhs[] =$/;" v file: yyrline wlp/C/commands.tab.c /^static const yytype_uint8 yyrline[] =$/;" v file: yyset_debug wlp/C/lex.yy.c /^void yyset_debug (int bdebug )$/;" f yyset_in wlp/C/lex.yy.c /^void yyset_in (FILE * in_str )$/;" f yyset_lineno wlp/C/lex.yy.c /^void yyset_lineno (int line_number )$/;" f yyset_out wlp/C/lex.yy.c /^void yyset_out (FILE * out_str )$/;" f yyss_alloc wlp/C/commands.tab.c /^ yytype_int16 yyss_alloc;$/;" m union:yyalloc file: yystos wlp/C/commands.tab.c /^static const yytype_uint8 yystos[] =$/;" v file: yystpcpy wlp/C/commands.tab.c /^yystpcpy (char *yydest, const char *yysrc)$/;" f file: yystpcpy wlp/C/commands.tab.c 832;" d file: yystrlen wlp/C/commands.tab.c /^yystrlen (const char *yystr)$/;" f file: yystrlen wlp/C/commands.tab.c 809;" d file: yystype wlp/C/commands.tab.c 131;" d file: yystype wlp/C/commands.tab.h 66;" d yysyntax_error wlp/C/commands.tab.c /^yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,$/;" f file: yytable wlp/C/commands.tab.c /^static const yytype_uint8 yytable[] =$/;" v file: yytable_value_is_error wlp/C/commands.tab.c 518;" d file: yyterminate wlp/C/lex.yy.c 625;" d file: yytext wlp/C/lex.yy.c /^char *yytext;$/;" v yytext_ptr wlp/C/lex.yy.c 357;" d file: yytname wlp/C/commands.tab.c /^static const char *const yytname[] =$/;" v file: yytnamerr wlp/C/commands.tab.c /^yytnamerr (char *yyres, const char *yystr)$/;" f file: yytokentype wlp/C/commands.tab.c /^ enum yytokentype {$/;" g file: yytokentype wlp/C/commands.tab.h /^ enum yytokentype {$/;" g yytoknum wlp/C/commands.tab.c /^static const yytype_uint16 yytoknum[] =$/;" v file: yytranslate wlp/C/commands.tab.c /^static const yytype_uint8 yytranslate[] =$/;" v file: yytype_int16 wlp/C/commands.tab.c /^typedef YYTYPE_INT16 yytype_int16;$/;" t file: yytype_int16 wlp/C/commands.tab.c /^typedef short int yytype_int16;$/;" t file: yytype_int8 wlp/C/commands.tab.c /^typedef YYTYPE_INT8 yytype_int8;$/;" t file: yytype_int8 wlp/C/commands.tab.c /^typedef short int yytype_int8;$/;" t file: yytype_int8 wlp/C/commands.tab.c /^typedef signed char yytype_int8;$/;" t file: yytype_uint16 wlp/C/commands.tab.c /^typedef YYTYPE_UINT16 yytype_uint16;$/;" t file: yytype_uint16 wlp/C/commands.tab.c /^typedef unsigned short int yytype_uint16;$/;" t file: yytype_uint8 wlp/C/commands.tab.c /^typedef YYTYPE_UINT8 yytype_uint8;$/;" t file: yytype_uint8 wlp/C/commands.tab.c /^typedef unsigned char yytype_uint8;$/;" t file: yyunput wlp/C/lex.yy.c /^ static void yyunput (int c, register char * yy_bp )$/;" f file: yyvs_alloc wlp/C/commands.tab.c /^ YYSTYPE yyvs_alloc;$/;" m union:yyalloc file: yywrap wlp/C/lex.yy.c 343;" d file: pyg-0.9.8ubuntu2/pygm2n0000755000000000000000000001157112057422101011703 0ustar #!/usr/bin/env python """News to mail gateway script. Copyright 2000 Cosimo Alfarano Author: Cosimo Alfarano Date: June 11 2000 pygs - Copyright 2000 by Cosimo Alfarano You can use this software under the terms of the GPL. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Thanks to md for this useful formula. Beer is beer. Gets news article and sends it via SMTP. """ import sys, os import getopt from string import split sys.path.append('/usr/lib/pyg') import pyginfo import mail2news def parse_cmdline(gw): """Parses cmdline with getopt. and returns a dictionary with smtp new header """ opt, arg = None, None test, verbose = 0, 0 # retnull = (None, None) retnull = None retval = { 'test': 0, 'verbose': 0 } try: opt, arg = getopt.getopt(sys.argv[1:],"a:s:n:u:p:P:hvVTM") except (getopt.error), message: print '%s: %s\n' % (sys.argv[0], message) sys.exit(1) if len(sys.argv) == 1 or opt == []: gw.smtpheads = None return retnull for i in range(len(opt)): if opt[i][0] == '-h': gw.nntpheads = None return retnull elif opt[i][0] == '-v': gw.nntpheads = None return retnull elif opt[i][0] == '-n': gw.nntpheads['Newsgroups:'] = opt[i][1] + '\n' elif opt[i][0] == '-a': gw.nntpheads['Approved:'] = opt[i][1] + '\n' elif opt[i][0] == '-s': gw.newsserver = opt[i][1] elif opt[i][0] == '-P': gw.port = int(opt[i][1]) # elif opt[i][0] == '-d': # gw.debug = 1 elif opt[i][0] == '-u': gw.user = opt[i][1] elif opt[i][0] == '-p': gw.password = opt[i][1] elif opt[i][0] == '-T': retval['test'] = 1 elif opt[i][0] == '-V': retval['verbose'] = 1 elif opt[i][0] == '-M': gw.reader = 1 if not gw.nntpheads.has_key('Newsgroups:'): print 'Error: Missing Newsgroups\n' return retnull # By rfc822 [Resent-]Sender: should be ever set, unless == From: # (not this case). Should be a human, while [Resent-]From: may be a program. # if gw.rcpt == '' or gw.sender == '': # print 'missing command line option' # gw.smtpheads = None # return retnull # if gw.envelope == '' and gw.sender != '': # gw.smtpheads['Resent-From:'] = gw.sender + '\n' # gw.envelope = gw.sender # elif gw.envelope == -1: # gw.smtpheads = None # return retnull sys.argv[1:] = arg # return (test, verbose) return retval def usage(): i = pyginfo.pygsinfo() print '%s version %s - Copyright 2000 Cosimo Alfarano' % (i.PROGNAME, i.VERSION) print i.PROGDESC + ' - Mail to News' print print 'usage: %s -n newsgroup [-h] [-a approver] [-n newsgroup] [-T] [-V]' % split(sys.argv[0],'/')[-1] print '-n newsgroup[s] (specified as comma separated without spaces list)' print '-u user | -p passwword (for auth to newsserver)' print '-a address of moderator/approver' print '-s servername' # print '-d for debug' print '-h or -v for this info' print '-T for test mode (not send article via NNTP)' print '-V for verbose output (usefull with -T option for debugging)' """main is structured in 4 phases: 1) check and set pyg's internal variables 2) check whitelist for users' permission 3) format rfc 822 headers from input article 4) open smtp connection and send e-mail """ try: """phase 1: check and set pyg's internal variables """ m2n = mail2news.mail2news() owner = None opt = parse_cmdline(m2n) if(opt == None): usage() sys.exit(0) # check if m2n has some file prefercences set on commandline # if(m2n.wlfile == None): # wl = os.environ['HOME'] + '/pyg.whitelist' # else: # wl = m2n.wlfile # # if(m2n.logfile == None): # log = os.environ['HOME'] + '/pyg.log' # else: # log = m2n.logfile # wl = whitelist.whitelist(wl,log) # reads stdin and parses article separating head from body m2n.readfile() m2n.parseemail() # for line in m2n.email: # print line[:-1] # for line in m2n.smtpheads.keys(): # print line # print m2n.smtpheads[line][:-1] """phase 2: check whitelist for user's permission """ # make a first check of From: address # owner = wl.checkfrom(m2n.nntpheads['From:']) # if(owner == None): # if(sys.stdin.isatty()==1 or test or verbose): # print ('"%s" is not in whitelist!' % (m2n.nntpheads['From:'][:-1])) # else: # wl.logmsg(m2n.nntpheads,wl.DENY) # sys.exit(1) """phase 3: format rfc 822 headers from input article """ m2n.mergeheads() # make unique dict from NNTP and SMTP dicts m2n.addheads() # add some important heads m2n.renameheads() # rename useless heads m2n.removeheads() # remove other heads m2n.sortheads() # sort remaining heads :) if(opt['verbose']): for line in m2n.headers: print line[:-1] """phase 4: open smtp connection and send e-mail """ if(len(m2n.headers) > 0 and len(m2n.body) > 0): # wl.logmsg(m2n.heads_dict,wl.ACCEPT,owner) if(not opt['test']): resp = m2n.sendemail() if resp: print resp except KeyboardInterrupt: print 'Keyboard Interrupt' sys.exit(0) pyg-0.9.8ubuntu2/mail2news.py0000644000000000000000000002472312057422101013017 0ustar """Mail to news gateway script. Copyright 2000 Cosimo Alfarano Author: Cosimo Alfarano Date: September 16 2000 mail2news.py - Copyright 2000 by Cosimo Alfarano You can use this software under the terms of the GPL. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Thanks to md for this useful formula. Beer is beer. Gets news email and sends it via SMTP. class mail2news is hopefully conform to rfc850. """ import sys from os import unlink, getpid from socket import gethostbyaddr, gethostname import string from re import findall import time import nntplib import pyginfo import tempfile class mail2news: """news to mail gateway class""" reader = None # mode reader # newsgroups = None # Newsgroups: local.test,local.moderated... # approved = None # Approved: kame@aragorn.lorien.org newsserver = 'localhost' # no comment :) port = 119 user = None password = None hostname = gethostbyaddr(gethostname())[0] heads_dict, smtpheads, nntpheads = {}, {}, {} email, headers, body = [], [], [] def readfile(self): for line in sys.stdin.readlines(): self.email.append(line) if(len(self.email) == 1 and self.email[0][0] == '/'): file = self.email[0][:-1] del self.email[0] for line in open(file,'r').readlines(): self.email.append(line) return 1 def parseemail(self): """get news email from file or stdin and separate heads from body REMEBER: headers value has '\n' as last char. Use string[:-1] to ignore newline. """ try: body = 0 # are we in body or in headers? for line in self.email: if not body and len(line) == 1: body = 1 # starts email body section if not body: try: # if it is a multi-line header like Received: if not line[0] in [' ','\t']: try: head, value = string.split(line, ' ', 1) except string.index_error: value = '' self.smtpheads[head] = value else: self.smtpheads[head] = '%s%s' % \ (self.smtpheads[head], line) except (string.index_error), message: print 'line: %s' % line print '(probably missing couple "Header: value" in %s)' % line sys.exit(1) elif len(line) > 0 and body: self.body.append(line) except (string.index_error), message: print message sys.exit(1) return self.smtpheads, self.body def puthead(self, dict, list, key): """private, transform dict entries in list entries Appends key of dict to list, deleting it from dict. """ if dict.has_key(key): list.append(key + ' ' + dict.get(key)) del dict[key] else: return 0 return 1 def sortheads(self): """make list sorted by heads: From: To: Subject: first, others, X-*, X-Resent-* last""" set = ('Newsgroups:','From:','To:','X-To:','Cc:','Subject:','Date:','Approved:','References:','Message-Id:') # put at top for k in set: self.puthead(self.heads_dict,self.headers,k) for k in self.heads_dict.keys(): if k[:2] != 'X-' and k[:9] != 'X-Resent-' and k not in set: self.puthead(self.heads_dict,self.headers,k) for k in self.heads_dict.keys(): if k[:2] == 'X-': self.puthead(self.heads_dict,self.headers,k) for k in self.heads_dict.keys(): if k[:9] == 'X-Resent-': self.puthead(self.heads_dict,self.headers,k) return self.headers def mergeheads(self): """make a unique headers dictionary from NNTP and SMTP single headers dictionaries.""" self.heads_dict = {} try: for header in self.smtpheads.keys(): # fill it w/ smtp old heads self.heads_dict[header] = self.smtpheads[header] for header in self.nntpheads.keys(): # and replace them w/ nntp new heads self.heads_dict[header] = self.nntpheads[header] except KeyError, message: print message return self.heads_dict def addheads(self): """add new header like X-Gateway: """ info = pyginfo.pygsinfo() try: self.heads_dict['X-Gateway:'] = info.PROGNAME + ' ' + \ info.PROGDESC + ' - Mail to News\n' # it is nntpheads stuff # if(self.newsgroups): # self.heads_dict['Newsgroups:'] = self.newsgroups # if(self.approved): # self.heads_dict['Approved:'] = self.approved except KeyError, message: print message return self.heads_dict def renameheads(self): """rename headers such as Resent-*: to X-Resent-*: headers renamed are useless or not rfc 977/850 copliant handles References/In-Reply-To headers """ try: ### test # if(post): # if(self.heads_dict.has_key(post)): # self.heads_dict['X-Original-' + post] = self.heads_dict[post] # # self.heads_dict[post] = self.heads_dict[pre] # del(self.heads_dict[pre]) # # else: # if(pre[0:2] == 'X-' and self.heads_dict.has_key(pre)): # self.heads_dict['X-Original-' + pre] = self.heads_dict[pre] # elif(not pre[0:2] == 'X-' and self.heads_dict.has_key('X-' + pre)): # self.heads_dict['X-' + pre] = self.heads_dict[pre] # del(self.heads_dict[pre]) ### end test for key in self.heads_dict.keys(): if(key[:7] in ['Resent-']): if(self.heads_dict.has_key('X-' + key)): self.heads_dict[ 'X-Original-' + key ] = self.heads_dict['X-' + key] self.heads_dict[ 'X-' + key ] = self.heads_dict[key] del self.heads_dict[key] # In rfc822 References: is considered, but many MUA doen't put it. if(not self.heads_dict.has_key('References:') and self.heads_dict.has_key('In-Reply-To:')): print self.heads_dict['In-Reply-To:'] # some MUA uses msgid without '<' '>' # ref = findall('([^\s<>\']+@[^\s<>;:\']+)', \ # but I prefer use RFC standards ref = findall('(<[^<>]+@[^<>]+>)', \ self.heads_dict['In-Reply-To:']) # if found, keep first element that seems a Msg-ID. if(ref and len(ref)): self.heads_dict['References:'] = '%s\n' % ref[0] # if(self.heads_dict.has_key('To:')): # self.heads_dict['X-To:'] = self.heads_dict['To:'] # del self.heads_dict['To:'] except KeyError, message: print message return self.heads_dict def removeheads(self, heads = None): """remove headers like Xref: Path: Lines: """ try: # removing some others useless headers .... (From is not From:) rmheads = ['Received:', 'From', 'NNTP-Posting-Host:', \ 'X-Trace:', 'X-Compliants-To:', 'NNTP-Posting-Date:'] if(heads): rmheads.append(heads) for head in rmheads: if self.heads_dict.has_key(head): del self.heads_dict[head] # if self.heads_dict.has_key('From'): # neither 'From ' nor 'From:' # del self.heads_dict['From'] # if self.heads_dict.has_key('NNTP-Posting-Host:'): # neither 'From ' nor 'From:' # del self.heads_dict[''] # if self.heads_dict.has_key('Lines:'): # del self.heads_dict['Lines:'] # it is usually set by INN, if ng is moderated... # if self.heads_dict.has_key('Sender:'): # del self.heads_dict['Sender:'] if self.heads_dict.has_key('Message-id:'): self.heads_dict['Message-Id:'] = self.heads_dict['Message-id:'] del(self.heads_dict['Message-id:']) if self.heads_dict.has_key('Message-ID:'): self.heads_dict['Message-Id:'] = self.heads_dict['Message-ID:'] del(self.heads_dict['Message-ID:']) # If message-id is not present, I generate it if not self.heads_dict.has_key('Message-Id:'): msgid = '\n' % (getpid()) self.heads_dict['Message-Id:'] = msgid except KeyError, message: print message return self.heads_dict def sendemail(self): """Talk to NNTP server and try to send email.""" try: msglist = [] n = nntplib.NNTP(self.newsserver, self.port, self.user, self.password) if(self.reader): n.putline('mode reader') resp = n.getline() print resp resp = n.shortcmd('POST') # sett RFC977 2.4.2 if resp[0] <> '3': raise n.error_reply, str(resp) for line in self.headers: if not line: break if line[-1] == '\n': line = line[:-1] if line[:1] == '.': line = '.' + line n.putline(line) for line in self.body: if not line: break if line[-1] == '\n': line = line[:-1] if line[:1] == '.': line = '.' + line n.putline(line) n.putline('.') n.quit() return None except (nntplib.error_reply, nntplib.error_temp, nntplib.error_perm, nntplib.error_proto, nntplib.error_data), message: return 'NNTP: ' + str(message) pyg-0.9.8ubuntu2/debian/0000755000000000000000000000000012130571377011772 5ustar pyg-0.9.8ubuntu2/debian/docs0000644000000000000000000000001312057422101012623 0ustar HOWTO TODO pyg-0.9.8ubuntu2/debian/copyright0000644000000000000000000000064412057422124013722 0ustar This package was debianized by Cosimo Alfarano on Sun, 25 Jun 2000 17:52:35 +0200. Current maintainer and author is Cosimo Alfarano. You can find this package at URL HTTP://www.students.cs.unibo.it/~alfarano Copyright: Copyright (C) 2000-2001,2012 Cosimo Alfarano A copy of the GNU General Public License, version 2, can be found in /usr/share/common-licenses/GPL-3 pyg-0.9.8ubuntu2/debian/changelog0000644000000000000000000001722312130571377013651 0ustar pyg (0.9.8ubuntu2) raring; urgency=low * Fix build failure with python in multiarch location. -- Matthias Klose Mon, 08 Apr 2013 18:40:05 +0200 pyg (0.9.8ubuntu1) raring; urgency=low * Merge from Debian unstable. Remaining changes: - adapt /wlp/C/Makefile for multiarched libfl.a - include required string.h in wlp/C/commands.l -- Logan Rosen Mon, 26 Nov 2012 17:28:37 -0500 pyg (0.9.8) unstable; urgency=low * Added string.h to avoid implicit declarations in yacc definitions. Closes: #689349 * Remove some compile-time warning from wlp/C/wlp.c * not ignore errors in clean targets on all Makefile * debian/compat bump to 5 (higher should be tested) * use dh_python2 -- Cosimo Alfarano Tue, 02 Oct 2012 14:04:01 +0100 pyg (0.9.7ubuntu1) quantal; urgency=low * adapt /wlp/C/Makefile for multiarched libfl.a * include required string.h in wlp/C/commands.{l,y} -- Julian Taylor Mon, 01 Oct 2012 21:10:48 +0200 pyg (0.9.7) unstable; urgency=low * Added maildrop as a possible deps (Closes: #385771) * Typos fixed in HOWTO. * Creating md5sum control file -- Cosimo Alfarano Fri, 18 Jul 2008 13:35:57 -0400 pyg (0.9.6-4.2) unstable; urgency=high * Non-maintainer upload. * Add BLDSHARED to Makefile.pre.in for python2.5 compatibility. Closes: #476160 * Add shlibs:Depends in debian/control. -- Thomas Viehmann Sun, 20 Apr 2008 16:49:23 +0200 pyg (0.9.6-4.1) unstable; urgency=low * Non-maintainer upload. * Update package to the last python policy (Closes: #380905). * Bump DH_COMPAT to 4. * Bump Standards-Version to 3.7.2. -- Pierre Habouzit Sat, 12 Aug 2006 14:01:38 +0200 pyg (0.9.6-4) unstable; urgency=low * added some more header to be stripepd in mail2news class closes:Bug#165322 -- Cosimo Alfarano Tue, 2 Mar 2004 21:40:59 +0100 pyg (0.9.6-3.1) unstable; urgency=low * apply the full (not modified) version of the Matt's patch, for compatibility reasons -- Cosimo Alfarano Thu, 6 Nov 2003 23:46:31 +0100 pyg (0.9.6-3) unstable; urgency=low * applied a modified version of patch from Matt Kraai sent in BTS closes:Bug#213936 -- Cosimo Alfarano Wed, 5 Nov 2003 11:59:29 +0100 pyg (0.9.6-2) unstable; urgency=low * typos in debian/control fixed (closes: #125276) -- Cosimo Alfarano Sat, 6 Apr 2002 18:52:57 +0200 pyg (0.9.6-1) unstable; urgency=low * minor changes to mail2news.py sendemail() method now does str(msg) on exception * addedd support for void header ('Cc: \n\r') even if it is not fully rfc conform. * addedd support for multiline header of the form "Received: \n\r" (closes: #124396) * fixed helo hostname sent, now it's the box name (closes: #122851) * sorry for the long fixing time, to everyone was waiting for them. -- Cosimo Alfarano Wed, 3 Apr 2002 22:39:47 +0200 pyg (0.9.5-1) unstable; urgency=low * compiled against python2.1 (wlp.c) * debian/control updated for dependancies python (>= 2.1), I want it to be usable on any 2.X the same for python-dev (closes: #119202) -- Cosimo Alfarano Mon, 12 Nov 2001 22:17:28 +0100 pyg (0.9.4-7) unstable; urgency=low * fixed some typos * fixed import of getopt module (thanks to zack@debian.org) * inverted 'if' and 'else' in line 78 of mail2news.py that's not a bug, but I do it for readability closes: #105922 -- Cosimo Alfarano Fri, 20 Jul 2001 00:49:26 +0200 pyg (0.9.4-6) unstable; urgency=low * added -P port option to pygm2n -- Cosimo Alfarano Sun, 11 Feb 2001 22:09:03 +0100 pyg (0.9.4-5) unstable; urgency=low * added suport for NNTP auth (thanks to Marc Sherman for his patch) closes: #84809 -- Cosimo Alfarano Sun, 11 Feb 2001 16:43:09 +0100 pyg (0.9.4-4) unstable; urgency=low * moved files from /usr/sbin to /usr/bin closes: #84806 * changed Maintainer: filed to kalfa@debian.org addr -- Cosimo Alfarano Sun, 04 Feb 2000 18:50:00 +0100 pyg (0.9.4-3) unstable; urgency=low * Sponsored upload. * fixed getopt problem with -M -- Davide Puricelli (evo) Sun, 30 Sep 2000 21:50:00 +0200 pyg (0.9.4-2) unstable; urgency=low * added Approved: header (pygm2n) * added selection of smtpserver for relay (pygn2m) * added conversion from In-Reply-To: to References: (pygm2n) * added Suggests: news-transport-system , mail-transport-agent * removed NNTP-Posting-Host, X-Trace * added TODO file * mail to news is working fine. -- Cosimo Alfarano Sun, 30 Sep 2000 21:50:00 +0200 pyg (0.9.4-1) unstable; urgency=low * Sponsored upload. * New upstream version. * mail to news gateway is working. Anyway testing it is adviced before use. -- Davide Puricelli (evo) Mon, 18 Sep 2000 19:45:19 +0200 pyg (0.9.3-1) unstable; urgency=low * started to write mail to news gateway module -- Cosimo Alfarano Sat, 16 Sep 2000 17:30:00 +0200 pyg (0.9.2-3) unstable; urgency=low * Sponsored upload. * Swapped binary-{indep,arch} in debian/rules, closes: #71446. * Added flex and bison to Build-Depends. -- Davide Puricelli (evo) Thu, 14 Sep 2000 16:34:10 +0200 pyg (0.9.2-2) unstable; urgency=low * debian/rules rewritten to a more readble dh_make style. * moved example files from debian/ to exaples/ * dh_stripped *.so * dh_undocumented *.py * Sponsored upload for Cosimo Alfarano * Initial Debian release. -- Davide Puricelli (evo) Sat, 2 Sep 2000 22:35:25 +0200 pyg (0.9.2-1) unstable; urgency=low * written the whitelist parser (wlp) in yacc+flex * written C funtions as python built-in module for wlp * fixed parsecommandline() return object * added -T opt for test mode and -V for verbose output -- Cosimo Alfarano Sun, 23 Jul 2000 19:30:00 +0200 pyg (0.9.1-5) unstable; urgency=low * added file locking on log * modified default location of whitelist and log file to homedir. log file will moved to /var/log as soon as possible -- Cosimo Alfarano Sun, 03 Jul 2000 18:00:00 +0200 pyg (0.9.1-4) unstable; urgency=low * Added Message-Id: logging in whitelist -- Cosimo Alfarano Sun, 02 Jul 2000 18:30:00 +0200 pyg (0.9.1-3) unstable; urgency=low * removed Sender: header from nntp article. It is usually set to news@news.domain -- Cosimo Alfarano Thu, 29 Jun 2000 16:30:00 +0200 pyg (0.9.1-2) unstable; urgency=low * modified copyright note in sources * moved parse_cmdline() from news2mail.py to pygs -- Cosimo Alfarano Thu, 29 Jun 2000 02:30:00 +0200 pyg (0.9.1-1) unstable; urgency=low * enriched whitelist log system -- Cosimo Alfarano Thu, 29 Jun 2000 01:30:00 +0200 pyg (0.9-3) unstable; urgency=low * corrected load path for modules in pygs. now points to /usr/lib/pyg -- Cosimo Alfarano Wed, 28 Jun 2000 00:45:00 +0200 pyg (0.9-2) unstable; urgency=low * added basic (and rudimental) whitelist functionality (whitelist.py) -- Cosimo Alfarano Wed, 28 Jun 2000 00:05:00 +0200 pyg (0.9-1) unstable; urgency=low * Initial release. -- Cosimo Alfarano Sun, 25 Jun 2000 17:52:35 +0200 pyg-0.9.8ubuntu2/debian/pygn2m.10000644000000000000000000000427612057422101013265 0ustar .\" wing requests are required for all man pages. .TH pygn2m 1 "Sun Sep 12 22:40:00 CEST 2000" "" "Python Gateway news to mail" .SH NAME pygn2m - Python Gateway news to mail .SH SYNOPSIS .B pygs .BR -t .IR recipient@domain1 .BR -s .IR sender@domain2 [ .BR -e .IR envelope@domain3 ] [ .BR -h ] .SH DESCRIPTION .B IMPORTANT: this man page is to be continued. The Whole pyg gateway is in .B devel.\ state. try -h option for more detailed option. pygn2m reads from stdin a nntp article, sending it to recipient@domain1 a rfc822 compliant email setting Resent-Sender: sender@domain2 and envelope envelope@domain3 if exists, else sender@domain2. If pygn2m reads from stdin a sigle line starting with /, it is considered an absolute path to an article (ie in a spool), so pygn2m will open and read it. \" The following requests should be uncommented and .\" used where appropriate. This next request is .\" for sections 2 and 3 function return values only. .\" .Sh RETURN VALUES .\" This next request is for sections 1, 6, 7 & 8 only .\" .Sh ENVIRONMENT .\" .Sh FILES .SH EXAMPLES There is some documetation in /urs/share/doc/pyg I created mailgate user (moderator of local.moderated ng). Every article posted in local.moderated is sent to mailgate, in its .procmailrc I've put: :0 bhc * ^To: *local-moderated | $HOME/pygs -t kalfa@localhost -e mailgate@students.cs.unibo.it -s 'cosimo@students.cs.unibo.it' where kalfa@localhost is the recipient (usually a mailing list) Here is an header extract from kalfa@localhost mbox: From mailgate@students.cs.unibo.it From: whosentnntparticle@domain4 To: kalfa@localhost Resent-Sender: cosimo@students.cs.unibo.it note that sender and envelope are different. rfc822 says that Sender: have to be a human user (not a program or similia). envelope can mailgate user. .\" This next request is for sections 1, 6, 7 & 8 only .\" (command return values (to shell) and .\" fprintf/stderr type diagnostics) .\" .Sh DIAGNOSTICS .\" The next request is for sections 2 and 3 error .\" and signal handling only. .\" .Sh ERRORS .\" .Sh SEE ALSO .\" .Sh STANDARDS .\" .Sh HISTORY .SH AUTHOR Cosimo Alfarano .SH BUGS Boh. send any bug to the author, please. pyg-0.9.8ubuntu2/debian/examples0000644000000000000000000000002412057422101013513 0ustar examples/* wlp_test pyg-0.9.8ubuntu2/debian/README.debian0000644000000000000000000000060012057422101014053 0ustar pyg for Debian -------------- pyg is a package to manage gateway from usenet to email and vice versa. It is written in python and is (hopefully) rfc compliant. My intent is to write a fully standardized gateway. Any help, advice or patch is accepted :) If you try pyg, send me your opinion, please. Cosimo Alfarano , Sun, 25 Jun 2000 17:52:35 +0200 pyg-0.9.8ubuntu2/debian/compat0000644000000000000000000000000212057422124013161 0ustar 5 pyg-0.9.8ubuntu2/debian/pygm2n.10000644000000000000000000000364512057422101013264 0ustar .\" wing requests are required for all man pages. .TH pygm2n 1 "Sun Sep 12 18:10:00 CEST 2000" "" "Python Gateway mail to news" .SH NAME pygm2n - Python Gateway mail to news .SH SYNOPSIS .B pygm2n .BR -n .IR newsgroups [ .BR -s .IR newsserver ] [ .BR -h ] .SH DESCRIPTION .B IMPORTANT: this man page is to be continued. The Whole pyg gateway is in .B devel.\ state. try -h option for more detailed option. pygm2n reads from stdin an email, sending it to newsgroups, a comma separated list without spaces of newsgroup names (at least one), rfc799 compliant. If pygm2n reads from stdin a sigle line starting with /, it is considered an absolute path to a single-email mailbox, so pygm2n will open and read it. .B Note that now pyg can't read a real mailbox, with many emails. If you give it in input, pyg will post the whole mailbox as a single email. \" The following requests should be uncommented and .\" used where appropriate. This next request is .\" for sections 2 and 3 function return values only. .\" .Sh RETURN VALUES .\" This next request is for sections 1, 6, 7 & 8 only .\" .Sh ENVIRONMENT .\" .Sh FILES .SH EXAMPLES There is some documetation in /urs/share/doc/pyg I created mailgate user (moderator of local.moderated ng). Subscribe to a list with this user (or simply email one message to). Every email posted to this user will send to newsgroups, in its .procmailrc I've put something like: :0 bh * ^From *mailinglist-request@lists.debian.org | $HOME/pygm2n -n local.debian.mailinglist .\" This next request is for sections 1, 6, 7 & 8 only .\" (command return values (to shell) and .\" fprintf/stderr type diagnostics) .\" .Sh DIAGNOSTICS .\" The next request is for sections 2 and 3 error .\" and signal handling only. .\" .Sh ERRORS .\" .Sh SEE ALSO .\" .Sh STANDARDS .\" .Sh HISTORY .SH AUTHORS Cosimo Alfarano .SH BUGS Boh. send any bug, advice or opinion to the author, please. pyg-0.9.8ubuntu2/debian/control0000644000000000000000000000217212057422124013370 0ustar Source: pyg Section: news Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Cosimo Alfarano Standards-Version: 3.9.3 Build-Depends: debhelper (>= 3.0), python-dev (>= 2.6.6-3~), flex, bison Package: pyg Architecture: any Depends: ${misc:Depends}, ${python:Depends}, ${shlibs:Depends} Suggests: news-transport-system , mail-transport-agent, procmail | maildrop | sensible-mda Description: Python Mail <-> News Gateway Python Gateway Script from news to mail and vice versa. . It is intended to be a full SMTP/NNTP rfc compliant gateway with whitelist manager. . You will probably have to install a mail-transport-agent and/or news-transport-system package to manage SMTP/NNTP traffic. . MTA is needed for mail2news service, since mail have to be processed on a box where pyg is installed. You can use a remote smtpserver for news2mail. . News system is useful but not needed, since you can send articles to a remote SMTP server (ie: moderated NG) where is installed pyg, otherwise you will need it. . It refers to rfc 822 (mail) and 850 (news). pyg-0.9.8ubuntu2/debian/whitelist.50000644000000000000000000000375312057422101014070 0ustar .\" wing requests are required for all man pages. .Dd July 23, 2000 .Os Debian GNU/Linux .Dt whitelist 5 .Sh NAME .Nm pygs .Nd the PYthon Gateway Script .Sh SYNOPSIS pygs -t recipient@domain1 -s sender@domain2 [-e envelope@domain3] [-d] [-T] [-V] [-l logfile] [-w whitelist] [-h] .Sh DESCRIPTION NOTE: this man page is to be continued :) pygs read from stdin a nntp article, sending it to recipient@domain1 a rfc822 compliant email setting Resent-Sender: sender@domain2 and envelope envelope@domain3 if exists, else sender@domain2. .Sh OPTIONS .Tp 0.5i .B \-t \" The following requests should be uncommented and .\" used where appropriate. This next request is .\" for sections 2 and 3 function return values only. .\" .Sh RETURN VALUES .\" This next request is for sections 1, 6, 7 & 8 only .\" .Sh ENVIRONMENT .\" .Sh FILES .Sh EXAMPLES There is some documetation in /urs/share/doc/pyg I created mailgate user (moderator of local.moderated ng). Every article posted in local.moderated is sent to mailgate, in its .procmailrc I've put: .Bd .Li :0 bhc .Li \ * ^To: *local-moderated .Li | $HOME/pygs -t kalfa@localhost -e mailgate@students.cs.unibo.it -s 'cosimo@students.cs.unibo.it' .Ed where kalfa@localhost is the recipient (it usually is a mailing list) an header extract from kalfa@localhost mbox: From mailgate@students.cs.unibo.it From: whosentnntparticle@domain4 To: kalfa@localhost Resent-Sender: cosimo@students.cs.unibo.it note that sender and envelope are different. rfc822 says that Sender: have to be a human user (not a program or similia). envelope can mailgate user. . .\" This next request is for sections 1, 6, 7 & 8 only .\" (command return values (to shell) and .\" fprintf/stderr type diagnostics) .\" .Sh DIAGNOSTICS .\" The next request is for sections 2 and 3 error .\" and signal handling only. .\" .Sh ERRORS .\" .Sh SEE ALSO .\" .Sh STANDARDS .\" .Sh HISTORY .Sh AUTHORS Cosimo Alfarano .Sh BUGS Boh. send any bug to the author .An , please. pyg-0.9.8ubuntu2/debian/dirs0000644000000000000000000000002412057422101012636 0ustar usr/bin usr/lib/pyg pyg-0.9.8ubuntu2/debian/rules0000755000000000000000000000304612057422124013046 0ustar #!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 export package=pyg export debdestdir=$(CURDIR)/debian/$(package) build: build-stamp build-arch: build build-indep: build build-stamp: dh_testdir $(MAKE) bin #CFLAGS="-O2 -g -Wall" touch build-stamp clean: dh_testdir rm -f build-stamp $(MAKE) clean dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs $(MAKE) install DESTDIR=$(debdestdir) binary-arch: build install dh_testdir dh_testroot dh_installdirs dh_installchangelogs dh_installdocs dh_installman $(CURDIR)/debian/pygn2m.1 $(CURDIR)/debian/pygm2n.1 # dh_installinfo # these are class modules, they don't need manpages, # undocumented link means I'm planning to document them. #dh_undocumented whitelist.py.3 news2mail.py.3 mail2news.py.3 pyginfo.py.3 dh_installexamples dh_fixperms # dh_fixperms doesn't fix perms in /usr/lib subdirs chmod 0644 $(debdestdir)/usr/lib/$(package)/*.py # make sure pyg executables have right permission chmod 0755 $(debdestdir)/usr/bin/pygn2m chmod 0755 $(debdestdir)/usr/bin/pygm2n # dh_fixperms doesn't fix perms in /usr/share/doc subdirs find $(debdestdir)/usr/share/doc/$(package) -type d -exec chmod 0755 {} \; dh_python2 dh_strip dh_compress dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb # no binary arch-indep is present binary-indep: build install dh_testdir dh_testroot binary: binary-indep binary-arch .PHONY: build build-arch build-indep binary binary-arch binary-indep clean install pyg-0.9.8ubuntu2/debian/notused/0000755000000000000000000000000012057422631013447 5ustar pyg-0.9.8ubuntu2/debian/notused/crontab.ex0000644000000000000000000000003712057422101015425 0ustar 0 4 * * * root pyg_maintenance pyg-0.9.8ubuntu2/debian/notused/inetd.conf.ex0000644000000000000000000000010112057422101016014 0ustar #:OTHER: pyg stream tcp nowait root /usr/sbin/tcpd /usr/sbin/pyg pyg-0.9.8ubuntu2/debian/notused/info.ex0000644000000000000000000000101612057422101014726 0ustar # This is a configuration files for installing a .info menu # The Description to be placed into the directory DESCR="Description" # The section this info file should be placed in (Regexp) followed by # the new section name to be created if the Regexp does not match # (Optional. If not given the .info will be appended to the directory) #SECTION_MATCH="Regexp" #SECTION_NAME="New Section Name" # The file referred to from the Info directory FILE=pyg.info # Optional. The files to be copied to /usr/share/info #FILES=*.info pyg-0.9.8ubuntu2/debian/notused/watch.ex0000644000000000000000000000040512057422101015102 0ustar # Example watch control file for uscan # Rename this file to "watch" and then you can run the "uscan" command # to check for upstream updates and more. # Site Directory Pattern Version Script sunsite.unc.edu /pub/Linux/Incomingu pyg-*.tar.gz debian uupdate pyg-0.9.8ubuntu2/debian/notused/diversions.ex0000644000000000000000000000004312057422101016157 0ustar pyg-0.9.8ubuntu2/debian/notused/init.d.ex0000644000000000000000000000275712057422101015175 0ustar #!/bin/sh # # This file was automatically customized by debmake on Sun, 25 Jun 2000 17:52:35 +0200 # # Written by Miquel van Smoorenburg . # Modified for Debian GNU/Linux by Ian Murdock . # Modified for Debian by Christoph Lameter PATH=/bin:/usr/bin:/sbin:/usr/sbin DAEMON=/usr/sbin/pyg # The following value is extracted by debstd to figure out how to generate # the postinst script. Edit the field to change the way the script is # registered through update-rc.d (see the manpage for update-rc.d!) FLAGS="defaults 50" test -f $DAEMON || exit 0 case "$1" in start) start-stop-daemon --start --verbose --exec $DAEMON ;; stop) start-stop-daemon --stop --verbose --exec $DAEMON ;; #reload) # # If the daemon can reload its config files on the fly # for example by sending it SIGHUP, do it here. # # If the daemon responds to changes in its config file # directly anyway, make this a do-nothing entry. # # start-stop-daemon --stop --signal 1 --verbose --exec $DAEMON # ;; restart|force-reload) # # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart". # start-stop-daemon --stop --verbose --exec $DAEMON sleep 1 start-stop-daemon --start --verbose --exec $DAEMON ;; *) echo "Usage: /etc/init.d/pyg {start|stop|restart|force-reload}" exit 1 ;; esac exit 0 pyg-0.9.8ubuntu2/debian/notused/menu.ex0000644000000000000000000000015112057422101014736 0ustar ?package(pyg):needs=X11|text|vc|wm section=Apps/see-menu-manual\ title="pygs" command="/usr/sbin/pygs" pyg-0.9.8ubuntu2/debian/notused/manpage.1.ex0000644000000000000000000000216512057422101015550 0ustar .TH NAME SECTION .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH NAME pyg \- programs to do something .SH SYNOPSIS .B pyg .I "[options] files ..." .br .B bar .I "[options] files ..." .SH "DESCRIPTION" This manual page documents briefly the .BR pyg , and .B bar commands. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. Instead, it has documentation in the GNU Info format; see below. .PP .B pyg is a program that... .SH OPTIONS The programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options are included below. For a complete description, see the Info files. .TP .B \-h, \-\-help Show summary of options. .TP .B \-v, \-\-version Show version of program. .SH "SEE ALSO" The programs are documented fully by .IR "The Rise and Fall of a Fooish Bar" , available via the Info system. .SH AUTHOR This manual page was written by Kame Alfa III , for the Debian GNU/Linux system (but may be used by others). pyg-0.9.8ubuntu2/examples/0000755000000000000000000000000012057422631012362 5ustar pyg-0.9.8ubuntu2/examples/articletest.denied0000644000000000000000000000077212057422101016055 0ustar Path: pyg.server.tld!gateway From: pyg@localhost (PYG) Newsgroups: local.moderated Subject: pyg's article test Date: 10 Jun 2000 23:20:47 +0200 Organization: Debian GNU/Linux Lines: 8 Sender: mailgate@pyg.server.tld Approved: mailgate@localhost NNTP-Posting-Host: pyg.server.tld Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: pyg.server.tld 960672047 927 192.168.1.2 (10 Jun 2000 21:20:47 GMT) Xref: pyg.server.tld local.moderated:4 test gateway . pyg-0.9.8ubuntu2/examples/articletest.accepted0000644000000000000000000000102212057422101016362 0ustar Path: pyg.server.tld!gateway From: pyg@pyg.server.tld (PYG) Newsgroups: local.moderated Subject: pyg's article test Date: 10 Jun 2000 23:20:47 +0200 Organization: Debian GNU/Linux Lines: 8 Sender: mailgate@localhost Approved: mailgate@localhost Reply-To: pyg@localhost NNTP-Posting-Host: pyg.server.tld Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: pyg.server.tld 960672047 927 192.168.1.2 (10 Jun 2000 21:20:47 GMT) Xref: pyg.server.tld local.moderated:4 test gateway . pyg-0.9.8ubuntu2/examples/mail0000644000000000000000000000077112057422101013224 0ustar From pyg@localhost Sun Oct 1 16:40:41 2000 Return-Path: Received: by pyg.server.tld (Postfix, from userid 1000) id 096A91838A; Sun, 1 Oct 2000 16:40:40 +0200 (CEST) Date: Sun, 1 Feb 2002 16:40:40 +0200 From: Pyg To: User X-Multiline: this header probably broke RFC, but is frequent. Subject: test Message-ID: <20001001164040.Aa8326@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.2.5i one line test pyg-0.9.8ubuntu2/examples/whitelist.example0000644000000000000000000000037212057422101015745 0ustar { From: = 'ME' Sender: = "Cosimo" Reply-to = "me" } { From: = 'Cosimo Alfarano' X-Firstname: = 'Cosimo' } { From: = 'kame@inwind.it' Reply-to: = "KA" Sender: = "Kalfa" } pyg-0.9.8ubuntu2/examples/README.example0000644000000000000000000000207312057422101014666 0ustar News2Mail: Using whitelist.example you can try to post articletest.accepted and articletest.denied. The first one will be accepted by pygs, second one rejected try to type something like (as normal user): $ pygn2m -TVt your@local.address -s your@local.address -e your@local.address \ -w /usr/share/doc/pyg/example/whitelist.example -l /tmp/pyg.log \ < /usr/share/doc/pyg/example/one_article_example It will reject to post articletest.denied because there are no 'From:' command in any section of whitelist.example. While it will post articletest.accepted because in the third section there is "From: = 'kame@inwind.it'" command. using -T option will only test, without opening a connection to your MTA. -V will change in verbose mode. see manpage for more info. Mail2News: /usr/share/doc/pyg/example/mail is a simple mail in unix mbox format, you can use it to test m2n functionality. $ pygm2n -TVn local.news.group < /usr/share/doc/pyg/example/mail format a news article to be posted to local.news.group newsgroup. Since -TV is present, it doen't open any connection. pyg-0.9.8ubuntu2/HOWTO0000644000000000000000000000144112057422101011357 0ustar MUST BE FINISHED! It is a (very) small HOWTO to make pyg working properly. pygm2n: Pre: a fully working MTA (ie postfix) where you can run procmail or any other MDA. A news server (local or remote) where you can create groups (admin privileges). Create a user, ie mailgate, set its procmail as: :0 bhc: | pygm2n -n local.test or its maildrop (thanks to Joy): dotlock pygm2n.`echo $$`.lock { `pygm2n -n local.test` } you can use -a your@address and -s nntphost if local.test is moderated, or nntphost isn't localhost [NOTE: if you've configuration for any other MDA, please file a wishlist bug against pyg] Create local.test (if it doen't exist). Now any mail you will write to mailgate user, will be sent to the server. Read local.test on localhost (or nntphost), you will see message. pyg-0.9.8ubuntu2/TODO0000644000000000000000000000043612057422101011227 0ustar pygm2n: Handle better socket errors (try: in sendemail) Let choose if remove (let server generate it), regenerete or leave Message-ID Post to many server (server list)? maybe. reads NNTPHOST environ var to set default host. both: try: for open() in readfile() finish to write HOWTO pyg-0.9.8ubuntu2/pyginfo.py0000644000000000000000000000116312057422101012562 0ustar """News to mail gateway script. Copyright 2000 Cosimo Alfarano Author: Cosimo Alfarano Date: June 11 2000 pyginfo.py - Copyright 2000 by Cosimo Alfarano You can use this software under the terms of the GPL. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Thanks to md for this useful formula. Beer is beer. Gets news article and sends it via SMTP. """ class pygsinfo: """The Python Gateway Script: news2mail mail2news gateway""" PROGNAME = 'pyg' PROGDESC= 'The Python Gateway' MAJOR = '0' MINOR = '7b' VERSION = MAJOR + '.' + MINOR pyg-0.9.8ubuntu2/pygn2m0000755000000000000000000001157312057422101011705 0ustar #!/usr/bin/env python """News to mail gateway script. Copyright 2000 Cosimo Alfarano Author: Cosimo Alfarano Date: June 11 2000 pygs - Copyright 2000 by Cosimo Alfarano You can use this software under the terms of the GPL. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return. Thanks to md for this useful formula. Beer is beer. Gets news article from stdin and sends it via SMTP. """ import sys, os import getopt from string import split sys.path.append('/usr/lib/pyg') import pyginfo import whitelist import news2mail #import mail2news def parse_cmdline(gw): """Parses cmdline with getopt. set a dictionary with smtp new header in gw parameter (gw.smtpheads) return (test,verbose) boolean tuple """ opt, arg = None, None test, verbose = 0, 0 retnull = (None, None) try: opt, arg = getopt.getopt(sys.argv[1:],"H:t:s:e:w:l:hdvVT") except (getopt.error), message: print '%s: %s\n' % (sys.argv[0], message) sys.exit(1) if len(sys.argv) == 1 or opt == []: gw.smtpheads = None return retnull for i in range(len(opt)): if opt[i][0] == '-h': gw.smtpheads = None return retnull elif opt[i][0] == '-v': gw.smtpheads = None return retnull elif opt[i][0] == '-H': gw.smtpserver = opt[i][1] elif opt[i][0] == '-s': gw.smtpheads['Resent-Sender:'] = opt[i][1] + '\n' gw.sender = opt[i][1] elif opt[i][0] == '-t' or opt[i][0] == '-r': gw.smtpheads['To:'] = opt[i][1] + '\n' gw.rcpt = opt[i][1] elif opt[i][0] == '-e': gw.smtpheads['Resent-From:'] = opt[i][1] + '\n' #envelope gw.envelope = opt[i][1] elif opt[i][0] == '-w': gw.wlfile = opt[i][1] elif opt[i][0] == '-l': gw.logfile = opt[i][1] elif opt[i][0] == '-d': gw.debug = 1 elif opt[i][0] == '-T': test = 1 elif opt[i][0] == '-V': verbose = 1 # By rfc822 [Resent-]Sender: should be ever set, unless == From: # (not this case). Should be a human, while [Resent-]From: may be a program. if gw.rcpt == '' or gw.sender == '': print 'missing command line option' gw.smtpheads = None return retnull if gw.envelope == '' and gw.sender != '': gw.smtpheads['Resent-From:'] = gw.sender + '\n' gw.envelope = gw.sender elif gw.envelope == -1: gw.smtpheads = None return retnull sys.argv[1:] = arg return (test, verbose) def usage(): i = pyginfo.pygsinfo() print '%s version %s - Copyright 2000 Cosimo Alfarano' % (i.PROGNAME, i.VERSION) print i.__doc__ print print 'usage: %s [-h] [-d] [-T] [-V] [-H smtphost] [-l logfile] [-w whitelist] -t recipient@... -s sender@... [-e envelope@...]' % split(sys.argv[0],'/')[-1] print '-t -s recipient, sender are necessary' print '-e envelope [default: same of sender]' print '-T for test mode (not send article via SMTP)' print '-V for verbose output' print '-d for debug' print '-h or -v for this info' """main is structured in 4 phases: 1) check and set pyg's internal variables 2) check whitelist for users' permission 3) format rfc 822 headers from input article 4) open smtp connection and send e-mail """ try: """phase 1: check and set pyg's internal variables """ n2m = news2mail.news2mail() owner = None # it returns only test, other parms are set directly in the actual parameter (test, verbose) = parse_cmdline(n2m) if (test, verbose) == (None, None): usage() sys.exit(0) # check if n2m has some file prefercences set on commandline if(n2m.wlfile == None): wl = os.environ['HOME'] + '/pyg.whitelist' else: wl = n2m.wlfile if(n2m.logfile == None): log = os.environ['HOME'] + '/pyg.log' else: log = n2m.logfile # print 'using %s %s\n' % (wl,log) wl = whitelist.whitelist(wl,log) # reads stdin and parses article separating head from body n2m.readfile() n2m.parsearticle() """phase 2: check whitelist for user's permission """ # make a first check of From: address owner = wl.checkfrom(n2m.nntpheads['From:']) if(owner == None): if(sys.stdin.isatty()==1 or test): print ('"%s" is not in whitelist!' % (n2m.nntpheads['From:'][:-1])) else: wl.logmsg(n2m.nntpheads,wl.DENY) # if verbose, I want to print out headers, so I can't # exit now. if(not verbose): sys.exit(1) """phase 3: format rfc 822 headers from input article """ n2m.mergeheads() # make unique dict from NNTP and SMTP dicts n2m.addheads() # add some important heads n2m.renameheads() # rename useless heads n2m.removeheads() # remove other heads n2m.sortheads() # sort remaining heads :) # prints formatted email message only (without send) if user wants if(verbose): for line in n2m.headers: print line[:-1] if(owner == None): sys.exit(1) """phase 4: open smtp connection and send e-mail """ if len(n2m.headers) > 0: wl.logmsg(n2m.heads_dict,wl.ACCEPT,owner) if(not test): n2m.sendarticle() else: print 'Error: No Headers!!!' except KeyboardInterrupt: print 'Keyboard Interrupt' sys.exit(1) pyg-0.9.8ubuntu2/wlp_test0000755000000000000000000000121012057422101012315 0ustar #!/usr/bin/python # Script to test if wlp.so works. It should parse confile without errors. import sys import wlp if(len(sys.argv) == 1): wlp.setfilebyname('./pyg.wl') else: wlp.setfilebyname(sys.argv[1]) # dict is a { ownername : {variable: value}} dictionary of dictionaries dict = wlp.mkdict() try: print 'owner: option = value' for owner in dict.keys(): options = dict[owner] for option in options.keys(): print '%s: %s = %s' % (owner,option,options[option]) except (Exception), message: print message for k in dict.keys(): if(dict[k]['From:'] == 'Cosimo Alfarano'): print '%s has %s' % (k,dict[k]['From:']) sys.exit(0) pyg-0.9.8ubuntu2/Makefile0000644000000000000000000000043412057422124012202 0ustar WLPDIR=wlp CSRCDIR=$(WLPDIR)/C MODULEDIR=$(WLPDIR)/module BINDIR=$(WLPDIR) bin: $(MAKE) -C $(WLPDIR) install: install pygm2n pygn2m $(DESTDIR)/usr/bin install *.py $(DESTDIR)/usr/lib/pyg install *.so $(DESTDIR)/usr/lib/pyg clean: $(MAKE) -C $(WLPDIR) clean rm -f *.pyc *.so pyg-0.9.8ubuntu2/wlp/0000755000000000000000000000000012057422631011346 5ustar pyg-0.9.8ubuntu2/wlp/C/0000755000000000000000000000000012057422631011530 5ustar pyg-0.9.8ubuntu2/wlp/C/wlp.c0000644000000000000000000000571712057422124012505 0ustar /* * wlp.c - Copyright 2000, 2001 by Cosimo Alfarano * You can use this software under the terms of the GPL. If we meet some day, * and you think this stuff is worth it, you can buy me a beer in return. * * Thanks to md for this useful formula. Beer is beer. */ #include #include #include #include "structs.h" #include "macro.h" static FILE *fd = NULL; struct wlp_list_t *list; static PyObject *node2dict(struct wlp_node_t *node); /* * wlp_setfilebyname(): get FILE* fd from filename string. */ static PyObject *wlp_setfilebyname(PyObject *self, PyObject *args) { char *file; DBG("setfilebyname\n"); if (!PyArg_ParseTuple(args, "s", &file)) return NULL; if((fd = fopen(file,"r"))) { return Py_None; } else { PyErr_SetFromErrno(PyExc_Exception); /* PyErr_SetString(PyExc_Exception, (errno<=sys_nerr-1)? sys_errlist[errno]: "Unknown Error on fopen() of confifuration file"); */ return NULL; } } /* * wlp_setfilebydf(): get FILE* fd from FileObject. */ static PyObject *wlp_setfilebyfd(PyObject *self, PyObject *args) { PyObject *file = NULL; if(!PyArg_ParseTuple(args, "O", &file)) return NULL; if(!file) return NULL; if(!PyFile_Check(file)) return NULL; fd = PyFile_AsFile(file); return Py_None; } /* * wlp_mkdict(): make a dictonary of the form * {ownername: {var1: val1, var2: val2,...}} */ static PyObject *wlp_mkdict(PyObject *self, PyObject *args) { PyObject *pydicttmp = NULL; PyObject *pydict = PyDict_New(); struct wlp_node_t *tmp; int count; if(!pydict) return NULL; /* fopen()*/ if(fd) parse(fd); else return Py_None; if(list) for(tmp = list->head, count = 0; tmp != list->head || count == 0; tmp = tmp->next, count++) { DBG("FOUND(%d) '%s' ('%s': '%s')\n",count,tmp->owner,tmp->left,tmp->right); pydicttmp = PyDict_GetItem(pydict, PyString_FromString(tmp->owner)); if(!pydicttmp) { DBG("%s: owner not found, create new item\n", tmp->owner); PyDict_SetItemString(pydict, tmp->owner, node2dict(tmp)); } else { DBG("%s: owner found,appendig items\n", tmp->owner); PyDict_SetItemString(pydicttmp, tmp->left, Py_BuildValue("s",tmp->right)); PyDict_SetItemString(pydict, tmp->owner, pydicttmp); } } return pydict; } /* * node2dict(): transoform a wlp_node_t node in a python dictionary of the form * { var: val } * to be used by mkdict() */ static PyObject *node2dict(struct wlp_node_t *node) { PyObject *dict = PyDict_New(); if(!dict) dict = Py_None; else { PyDict_SetItem(dict, Py_BuildValue("s",node->left), Py_BuildValue("s",node->right)); } return dict; } static PyMethodDef wlp_methods[] = { {"mkdict", wlp_mkdict, METH_VARARGS}, {"setfilebyname", wlp_setfilebyname, METH_VARARGS}, {"setfilebyfd", wlp_setfilebyfd, METH_VARARGS}, {NULL,NULL} }; void initwlp() { (void) Py_InitModule("wlp",wlp_methods); } pyg-0.9.8ubuntu2/wlp/C/test.c0000644000000000000000000000401612057422101012644 0ustar #include /* should be modified to be pythonX.Y */ #include #include #include "structs.h" #include "macro.h" /* first declare static functions */ struct wlp_list_t *list; static FILE *fd = NULL; static PyObject *node2dict(struct wlp_node_t *node); static PyObject *wlp_setfilebyname(PyObject *self, PyObject *args) { char *file; DBG("setfilebyname\n"); if (!PyArg_ParseTuple(args, "s", &file)) return NULL; fd = fopen(file,"r"); return Py_None; } static PyObject *wlp_setfilebyfd(PyObject *self, PyObject *args) { PyObject *file = NULL; if (!PyArg_ParseTuple(args, "O", &file)) return NULL; if(!file) return NULL; if(!PyFile_Check(file)) return NULL; fd = PyFile_AsFile(file); return Py_None; } static PyObject *wlp_mklist(PyObject *self, PyObject *args) { struct wlp_node_t *tmp; int count; PyObject *pylist = NULL; DBG("a\n"); parse(fd); DBG("count %d\n"list->count); pylist = PyList_New(0); DBG("a\n"); if(!pylist) return NULL; DBG("a\n"); if(list) for(tmp = list->head, count=0; tmp != list->head || count == 0; tmp = tmp->next, count++) { DBG("FOUND(%d) '%s' ('%s': '%s')\n",count,tmp->owner,tmp->left,tmp->right); if(PyList_Append(pylist,node2dict(tmp))==-1) { DBG("List failed\n"); return NULL; } DBG("a\n"); } return pylist; } static PyObject *node2dict(struct wlp_node_t *node) { PyObject *dict = PyDict_New(); if(!dict) return NULL; PyDict_SetItem(dict, Py_BuildValue("s","owner"), Py_BuildValue("s",node->owner)); PyDict_SetItem(dict, Py_BuildValue("s",node->left), Py_BuildValue("s",node->right)); return dict; } /* second a table with methods/functions matching */ static PyMethodDef wlp_methods[] = { {"mklist", wlp_mklist, METH_VARARGS}, {"setfilebyname", wlp_setfilebyname, METH_VARARGS}, {"setfilebyfd", wlp_setfilebyfd, METH_VARARGS}, {NULL,NULL} }; /* last the init function, the only one non-static */ void initwlp() { (void) Py_InitModule("wlp",wlp_methods); } pyg-0.9.8ubuntu2/wlp/C/yytest.c0000644000000000000000000000063012057422101013224 0ustar #include #include "structs.h" #include "macro.h" int parse(FILE *file); struct wlp_list_t *list; int main(int argc,char **argv) { struct wlp_node_t *tmp; int count; parse(NULL); if(list) for(tmp = list->head, count=0; tmp != list->head || count == 0; tmp = tmp->next, count++) printf("FOUND(%d) '%s' '%s' '%s'\n",count,tmp->left,tmp->right,tmp->owner); return(0); } pyg-0.9.8ubuntu2/wlp/C/macro.h0000644000000000000000000000152412057422101012774 0ustar /* * macro.h - Copyright 2000, 2001 Cosimo Alfarano * You can use this software under the terms of the GPL. If we meet some day, * and you think this stuff is worth it, you can buy me a beer in return. * * Thanks to md for this useful formula. Beer is beer. */ #ifndef _macro_h_ #define _macro_h_ #define LINELEN 2048 #define TRUE 1 #define FALSE 0 /* #define WITHQUOTES #define WITHANGBRACKETS */ #define ERR(a,b...) fprintf(stderr, a, ## b) /* Define it for debug info on stderr (better if in .c module ...) */ /* #ifndef DEBUG #define DEBUG #endif */ #ifdef DEBUG #define DBG(a...) fprintf(stderr, ## a) /* for a verbose debug*/ #define VDBG(a,b...) fprintf(stderr, "%s(): " a, __FUNCTION__ , ## b) #else #define DBG(a...) #define VDBG(a...) #endif #endif /* EOF */ pyg-0.9.8ubuntu2/wlp/C/commands.y0000644000000000000000000000321412057422124013520 0ustar %{ /*#define YYSTYPE char**/ /*#define DEBUG*/ #include "macro.h" #include "string.h" %} %union { char *text; char c; } %token VARID %token VALID %token OWNERID %token ERROR %token EOFTOK %{ char left[80], right[80], owner[80]; char type = 0; /*unused*/ %} %% block: blockstatement | block blockstatement ; blockstatement: owner '{' commandline '}' ; commandline: command | commandline command ; command: varpart '=' valpart { found(left,right,owner); } ; owner: OWNERID { DBG("Owner %s\n",$1); strncpy(owner,$1,strlen($1)+1); } ; varpart: VARID { DBG("Left %s\n",$1); strncpy(left,$1,strlen($1)+1); } ; valpart: VALID { DBG("Right %s\n",$1); strncpy(right,$1,strlen($1)+1); } ; %% #include #include #include "structs.h" extern struct wlp_list_t *list; int yyerror (char *s) /* Called by yyparse on error */ { printf ("error: %s\n", s); return 1; } int found(const char* left, const char* right, const char *owner) { static struct wlp_node_t *node; /* alloc node with non-empty fields (ie alloc them too)*/ node = wlpn_alloc(FALSE); if(!node) { DBG("wlpn_alloc in found returned NULL\n"); } strncpy(node->right,right,strlen(right)); strncpy(node->left,left,strlen(left)); strncpy(node->owner,owner,strlen(owner)); #ifndef WITHQUOTES /* remove quotes of value part */ node->right += 1; node->right[strlen(node->right)-1] = '\0'; #endif #ifndef WITHANGBRACKETS /* remove angle brackets of owner part */ node->owner += 1; node->owner[strlen(node->owner)-1] = '\0'; #endif if(!list) list = wlpl_init(node); else wlpn_add(list,node); } pyg-0.9.8ubuntu2/wlp/C/structs.h0000644000000000000000000000204412057422101013400 0ustar /* * structs.h - Copyright 2000, 2001 by Cosimo Alfarano * You can use this software under the terms of the GPL. If we meet some day, * and you think this stuff is worth it, you can buy me a beer in return. * * Thanks to md for this useful formula. Beer is beer. */ #ifndef _structs_h_ #define _structs_h_ typedef struct wlp_node_t { char *left,*right; char *owner; char type; /* unused */ struct wlp_node_t *next, *prev; } wlp_node_t; typedef struct wlp_list_t { int count; struct wlp_node_t *head, *tail; } wlp_list_t; /* white list parser data structure manipulation */ struct wlp_list_t *wlpl_init(struct wlp_node_t *node); struct wlp_node_t *wlpn_alloc(const char empty); void wlpn_free(struct wlp_node_t *node); struct wlp_node_t *wlpn_add(struct wlp_list_t *wlpl,struct wlp_node_t *wlpn); struct wlp_node_t *wlpn_extract(struct wlp_list_t *wlpl,struct wlp_node_t *wlpn); /*struct wlp_node_t *wlpn_search(struct wlp_list_t *wlpl,const char id);*/ #endif /* _structs_h_ */ /* EOF */ pyg-0.9.8ubuntu2/wlp/C/commands.l0000644000000000000000000000177112057422101013504 0ustar %{ /* Lex analyzer for bison grammar */ #include "commands.tab.h" /*#define DEBUG*/ #include "macro.h" #include %} OWNER "<"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9._-]+">" VAL ['`"][a-zA-Z0-9@_+.<>() -]+['`"] VAR [a-zA-Z0-9_<>-]+[:]? %option noyywrap %% {OWNER} { DBG("OWNER %s\n",yytext); yylval.text=yytext; return(OWNERID); } {VAL} { DBG("VAL %s\n",yytext); yylval.text=yytext; return(VALID); } {VAR} { DBG("VAR %s\n",yytext); yylval.text=yytext; return(VARID); } "{" | "}" | "=" { yylval.text=yytext; return(*yytext); } "#"[^\n]* | "\n" | [[:space:]] ; /* comments 'til EOL and strip all spaces and \n */ "." { DBG("NOTSTR %s\n",yytext); yylval.text=yytext; return(ERROR); } %% #include "structs.h" extern struct wlp_list_t *list; int parse(FILE *file) { struct wlp_node_t *tmp; int count; yyin=file; DBG("go!\n"); yyparse(); DBG("EOF found\n"); } pyg-0.9.8ubuntu2/wlp/C/structs.c0000644000000000000000000000577312057422101013407 0ustar /* * structs.c - Copyright 2000 by Cosimo Alfarano * You can use this software under the terms of the GPL. If we meet some day, * and you think this stuff is worth it, you can buy me a beer in return. * * Thanks to md for this useful formula. Beer is beer. */ #include #include #include #include #include "structs.h" #include "macro.h" struct wlp_node_t *wlpn_add(struct wlp_list_t *list,struct wlp_node_t *node) { struct wlp_node_t *ret; if(node) { node->next = list->head; node->prev = list->tail; list->tail->next = node; list->head->prev = node; list->tail = node; list->count++; ret = node; } else { DBG("cannot add %s %s to list. NULL pointer?\n", node->left,node->right); ret = NULL; } return ret; } void wlpn_free(struct wlp_node_t *node) { free(node->left); free(node->right); free(node->owner); free(node); } struct wlp_node_t *wlpn_alloc(const char empty) { static struct wlp_node_t *node; node = calloc(sizeof(struct wlp_node_t),1); if (!node) { perror("wlpn_create malloc"); /* calloc set *node to zero, it I don't want alloc anything, leave it untouched, else alloc fields */ } else if (!empty) { node->left = calloc(LINELEN+1,1); if (!node->left) { perror("wlpn_create malloc (left)"); free(node); node = NULL; } /*if node is NULL, previous calloc returned error...*/ if(node && !(node->right = calloc(LINELEN+1,1))) { perror("wlpn_create malloc (right)"); free(node); node = NULL; } if(node && !(node->owner = calloc(LINELEN+1,1))) { perror("wlpn_create malloc (owner)"); free(node); node = NULL; } } return node; } struct wlp_list_t *wlpl_init(struct wlp_node_t *node) { static struct wlp_list_t *list; list = malloc(sizeof(struct wlp_list_t)); if (list) { list->head = node; list->tail = list->head; list->head->next = list->head; list->head->prev = list->head; list->count=1; } else { perror("wlpl_init malloc"); return NULL; } return list; } struct wlp_node_t *wlpn_searchowner(struct wlp_list_t *mbl,const char *owner) { struct wlp_node_t *ret; DBG("searching for %s\n",owner); if(!mbl) ret = NULL; else { int found = FALSE; ret = mbl->head; do { if(!strcmp(owner,ret->owner)) { DBG("found!\n"); found = TRUE; } else { DBG("not found: %s\n",ret->onwer); ret = ret->next; } } while(ret != mbl->head && !found); if(!found) ret = NULL; } DBG("%s\n", (ret)?ret->owner:"not found"); return ret; } struct wlp_node_t *wlpn_extract(struct wlp_list_t *list,struct wlp_node_t *node) { struct wlp_node_t *ret; if(list && node) { node->prev->next = node->next; node->next->prev = node->prev; if(list->tail == node) list->tail = node->prev; if(list->head == node) list->head = node->next; list->count--; ret = node; } else { DBG("wlpn_extract: list addr %l and node %l (one is NULL)\n",list,addr) ret = NULL; } return ret; } pyg-0.9.8ubuntu2/wlp/C/Makefile0000644000000000000000000000224312057422124013166 0ustar CC=gcc AR=ar FLEX=flex YACC=bison CCOPTS=-Wall -ansi CCSHARED=-fPIC AROPTS=-rs FLEXOPTS= YACCOPTS=-d CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) CFLAGS:=$(shell dpkg-buildflags --get CFLAGS) CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) SRCDIR=. BINDIR=. DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) OBJFILE=structs.o commands.tab.o lex.yy.o all: archive bin # archive file for python module archive: structs bison flex macro.h structs.h commands.tab.h $(AR) $(AROPTS) $(BINDIR)/wlp.a $(OBJFILE) \ /usr/lib/$(DEB_HOST_MULTIARCH)/libfl.a # binary (executable) file for testing executable: bin bin: structs bison flex macro.h structs.h commands.tab.h $(CC) $(CCSHARED) $(CCOPTS) $(OBJFILE) \ yytest.c /usr/lib/$(DEB_HOST_MULTIARCH)/libfl.a -o ./yytest flex: $(FLEX) $(FLEXOPTS) commands.l $(CC) $(CCSHARED) -c lex.yy.c -o lex.yy.o bison: $(YACC) $(YACCOPTS) -d commands.y -b commands $(CC) $(CCSHARED) -c commands.tab.c -o commands.tab.o structs: $(CC) $(CCSHARED) $(CCOPTS) -c structs.c -o structs.o clean: rm -f $(OBJFILE) lex.yy.c commands.tab.h commands.tab.c wlp.a yytest pyg-0.9.8ubuntu2/wlp/README0000644000000000000000000000103312057422124012220 0ustar To make wlp python module extension type 'make', it should be sufficient. If it doesn't work, please, send a bug report with full make output to author or package maintainer and/or (better) try manually to do this steps and reporting output of the one which give error via email: make -C module -f Makefile.pre.in boot # to initialiaze python module Makefile make -C src archive # to compile python .c extension make -C module # to really make .so python module Please, remeber to report full output. Cosimo Alfarano pyg-0.9.8ubuntu2/wlp/module/0000755000000000000000000000000012130571343012630 5ustar pyg-0.9.8ubuntu2/wlp/module/makesetup0000755000000000000000000001427212057422101014555 0ustar #! /bin/sh # Convert templates into Makefile and config.c, based on the module # definitions found in the file Setup. # # Usage: makesetup [-s dir] [-c file] [-m file] [Setup] ... [-n [Setup] ...] # # Options: # -s directory: alternative source directory (default derived from $0) # -c file: alternative config.c template (default $srcdir/config.c.in) # -c -: don't write config.c # -m file: alternative Makefile template (default ./Makefile.pre) # -m -: don't write Makefile # # Remaining arguments are one or more Setup files (default ./Setup). # Setup files after a -n option are used for their variables, modules # and libraries but not for their .o files. # # See Setup.in for a description of the format of the Setup file. # # The following edits are made: # # Copying config.c.in to config.c: # - insert an identifying comment at the start # - for each mentioned in Setup before *noconfig*: # + insert 'extern void init();' before MARKER 1 # + insert '{"", initmodule},' before MARKER 2 # # Copying Makefile.pre to Makefile: # - insert an identifying comment at the start # - replace _MODOBJS_ by the list of objects from Setup (except for # Setup files after a -n option) # - replace _MODLIBS_ by the list of libraries from Setup # - for each object file mentioned in Setup, append a rule # '.o: .c; ' to the end of the Makefile # - for each module mentioned in Setup, append a rule # which creates a shared library version to the end of the Makefile # - for each variable definition found in Setup, insert the definition # before the comment 'Definitions added by makesetup' # Loop over command line options usage=' usage: makesetup [-s srcdir] [-c config.c.in] [-m Makefile.pre] [Setup] ... [-n [Setup] ...]' srcdir='' config='' makepre='' noobjects='' doconfig=yes while : do case $1 in -s) shift; srcdir=$1; shift;; -c) shift; config=$1; shift;; -m) shift; makepre=$1; shift;; --) shift; break;; -n) noobjects=yes;; -*) echo "$usage" 1>&2; exit 2;; *) break;; esac done # Set default srcdir and config if not set by command line # (Not all systems have dirname) case $srcdir in '') case $0 in */*) srcdir=`echo $0 | sed 's,/[^/]*$,,'`;; *) srcdir=.;; esac;; esac case $config in '') config=$srcdir/config.c.in;; esac case $makepre in '') makepre=Makefile.pre;; esac # Newline for sed i and a commands NL='\ ' # Main loop for i in ${*-Setup} do case $i in -n) echo '*noobjects*';; *) echo '*doconfig*'; cat "$i";; esac done | sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | ( rulesf="@rules.$$" trap 'rm -f $rulesf' 0 1 2 3 echo " # Rules appended by makedepend " >$rulesf DEFS= MODS= SHAREDMODS= OBJS= LIBS= LOCALLIBS= BASELIBS= while read line do # Output DEFS in reverse order so first definition overrides case $line in *=*) DEFS="$line$NL$DEFS"; continue;; 'include '*) DEFS="$line$NL$DEFS"; continue;; '*noobjects*') case $noobjects in yes) ;; *) LOCALLIBS=$LIBS; LIBS=;; esac noobjects=yes; continue;; '*doconfig*') doconfig=yes; continue;; '*static*') doconfig=yes; continue;; '*noconfig*') doconfig=no; continue;; '*shared*') doconfig=no; continue;; esac srcs= cpps= libs= mods= skip= for arg in $line do case $skip in libs) libs="$libs $arg"; skip=; continue;; cpps) cpps="$cpps $arg"; skip=; continue;; srcs) srcs="$srcs $arg"; skip=; continue;; esac case $arg in -[IDUC]*) cpps="$cpps $arg";; -Xlinker) libs="$libs $arg"; skip=libs;; -[A-Zl]*) libs="$libs $arg";; *.a) libs="$libs $arg";; *.so) libs="$libs $arg";; *.sl) libs="$libs $arg";; /*.o) libs="$libs $arg";; *.o) srcs="$srcs `basename $arg .o`.c";; *.[cC]) srcs="$srcs $arg";; *.cc) srcs="$srcs $arg";; *.c++) srcs="$srcs $arg";; *.cxx) srcs="$srcs $arg";; *.cpp) srcs="$srcs $arg";; \$*) libs="$libs $arg" cpps="$cpps $arg";; *.*) echo 1>&2 "bad word $arg in $line" exit 1;; -u) skip=libs; libs="$libs -u";; [a-zA-Z_]*) mods="$mods $arg";; *) echo 1>&2 "bad word $arg in $line" exit 1;; esac done case $doconfig in yes) LIBS="$LIBS $libs" MODS="$MODS $mods" ;; esac case $noobjects in yes) continue;; esac objs='' for src in $srcs do case $src in *.c) obj=`basename $src .c`.o; cc='$(CC)';; *.cc) obj=`basename $src .cc`.o; cc='$(CCC)';; *.c++) obj=`basename $src .c++`.o; cc='$(CCC)';; *.C) obj=`basename $src .C`.o; cc='$(CCC)';; *.cxx) obj=`basename $src .cxx`.o; cc='$(CCC)';; *.cpp) obj=`basename $src .cpp`.o; cc='$(CCC)';; *) continue;; esac objs="$objs $obj" case $src in glmodule.c) ;; /*) ;; *) src='$(srcdir)/'$src;; esac case $doconfig in no) cc="$cc \$(CCSHARED)";; esac rule="$obj: $src; $cc $cpps \$(CFLAGS) -c $src" echo "$rule" >>$rulesf done case $doconfig in yes) OBJS="$OBJS $objs";; esac for mod in $mods do case $objs in *$mod.o*) base=$mod;; *) base=${mod}module;; esac file="$base\$(SO)" case $doconfig in no) SHAREDMODS="$SHAREDMODS $file";; esac rule="$file: $objs" rule="$rule; \$(LDSHARED) $objs $libs -o $file" echo "$rule" >>$rulesf done done case $SHAREDMODS in '') ;; *) DEFS="SHAREDMODS=$SHAREDMODS$NL$DEFS";; esac case $noobjects in yes) BASELIBS=$LIBS;; *) LOCALLIBS=$LIBS;; esac LIBS='$(LOCALMODLIBS) $(BASEMODLIBS)' DEFS="BASEMODLIBS=$BASELIBS$NL$DEFS" DEFS="LOCALMODLIBS=$LOCALLIBS$NL$DEFS" EXTDECLS= INITBITS= for mod in $MODS do EXTDECLS="${EXTDECLS}extern void init$mod();$NL" INITBITS="${INITBITS} {\"$mod\", init$mod},$NL" done case $config in -) ;; *) sed -e " 1i$NL/* Generated automatically from $config by makesetup. */ /MARKER 1/i$NL$EXTDECLS /MARKER 2/i$NL$INITBITS " $config >config.c ;; esac case $makepre in -) ;; *) sedf="@sed.in.$$" trap 'rm -f $sedf' 0 1 2 3 echo "1i\\" >$sedf str="# Generated automatically from $makepre by makesetup." echo "$str" >>$sedf echo "s%_MODOBJS_%$OBJS%" >>$sedf echo "s%_MODLIBS_%$LIBS%" >>$sedf echo "/Definitions added by makesetup/a$NL$NL$DEFS" >>$sedf sed -f $sedf $makepre >Makefile cat $rulesf >>Makefile rm -f $sedf ;; esac rm -f $rulesf ) pyg-0.9.8ubuntu2/wlp/module/Makefile.pre.in0000644000000000000000000002460312130571343015467 0ustar # Universal Unix Makefile for Python extensions # ============================================= # Short Instructions # ------------------ # 1. Build and install Python (1.5 or newer). # 2. "make -f Makefile.pre.in boot" # 3. "make" # You should now have a shared library. # Long Instructions # ----------------- # Build *and install* the basic Python 1.5 distribution. See the # Python README for instructions. (This version of Makefile.pre.in # only withs with Python 1.5, alpha 3 or newer.) # Create a file Setup.in for your extension. This file follows the # format of the Modules/Setup.dist file; see the instructions there. # For a simple module called "spam" on file "spammodule.c", it can # contain a single line: # spam spammodule.c # You can build as many modules as you want in the same directory -- # just have a separate line for each of them in the Setup.in file. # If you want to build your extension as a shared library, insert a # line containing just the string # *shared* # at the top of your Setup.in file. # Note that the build process copies Setup.in to Setup, and then works # with Setup. It doesn't overwrite Setup when Setup.in is changed, so # while you're in the process of debugging your Setup.in file, you may # want to edit Setup instead, and copy it back to Setup.in later. # (All this is done so you can distribute your extension easily and # someone else can select the modules they actually want to build by # commenting out lines in the Setup file, without editing the # original. Editing Setup is also used to specify nonstandard # locations for include or library files.) # Copy this file (Misc/Makefile.pre.in) to the directory containing # your extension. # Run "make -f Makefile.pre.in boot". This creates Makefile # (producing Makefile.pre and sedscript as intermediate files) and # config.c, incorporating the values for sys.prefix, sys.exec_prefix # and sys.version from the installed Python binary. For this to work, # the python binary must be on your path. If this fails, try # make -f Makefile.pre.in Makefile VERSION=1.5 installdir= # where is the prefix used to install Python for installdir # (and possibly similar for exec_installdir=). # Note: "make boot" implies "make clobber" -- it assumes that when you # bootstrap you may have changed platforms so it removes all previous # output files. # If you are building your extension as a shared library (your # Setup.in file starts with *shared*), run "make" or "make sharedmods" # to build the shared library files. If you are building a statically # linked Python binary (the only solution of your platform doesn't # support shared libraries, and sometimes handy if you want to # distribute or install the resulting Python binary), run "make # python". # Note: Each time you edit Makefile.pre.in or Setup, you must run # "make Makefile" before running "make". # Hint: if you want to use VPATH, you can start in an empty # subdirectory and say (e.g.): # make -f ../Makefile.pre.in boot srcdir=.. VPATH=.. # === Bootstrap variables (edited through "make boot") === # The prefix used by "make inclinstall libainstall" of core python installdir= /usr/local # The exec_prefix used by the same exec_installdir=$(installdir) # Source directory and VPATH in case you want to use VPATH. # (You will have to edit these two lines yourself -- there is no # automatic support as the Makefile is not generated by # config.status.) srcdir= . VPATH= . # === Variables that you may want to customize (rarely) === # (Static) build target TARGET= python # Installed python binary (used only by boot target) PYTHON= python CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS) # Add more -I and -D options here CFLAGS=$(OPT) -I$(INCLUDEPY) -I$(EXECINCLUDEPY) $(DEFS) $(shell dpkg-buildflags --get CFLAGS) CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS) LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) # These two variables can be set in Setup to merge extensions. # See example[23]. BASELIB= BASESETUP= # === Variables set by makesetup === MODOBJS= _MODOBJS_ MODLIBS= _MODLIBS_ # === Definitions added by makesetup === # === Variables from configure (through sedscript) === VERSION= @VERSION@ CC= @CC@ LINKCC= @LINKCC@ SGI_ABI= @SGI_ABI@ OPT= @OPT@ LDFLAGS= @LDFLAGS@ LDLAST= @LDLAST@ DEFS= @DEFS@ LIBS= @LIBS@ LIBM= @LIBM@ LIBC= @LIBC@ RANLIB= @RANLIB@ MACHDEP= @MACHDEP@ SO= @SO@ LDSHARED= @LDSHARED@ BLDSHARED= @BLDSHARED@ CCSHARED= @CCSHARED@ LINKFORSHARED= @LINKFORSHARED@ CXX= @CXX@ # Install prefix for architecture-independent files prefix= /usr # Install prefix for architecture-dependent files exec_prefix= $(prefix) # Uncomment the following two lines for AIX #LINKCC= $(LIBPL)/makexp_aix $(LIBPL)/python.exp "" $(LIBRARY); $(PURIFY) $(CC) #LDSHARED= $(LIBPL)/ld_so_aix $(CC) -bI:$(LIBPL)/python.exp # === Fixed definitions === # Shell used by make (some versions default to the login shell, which is bad) SHELL= /bin/sh # Expanded directories BINDIR= $(exec_installdir)/bin LIBDIR= $(exec_prefix)/lib MANDIR= $(installdir)/share/man INCLUDEDIR= $(installdir)/include SCRIPTDIR= $(prefix)/lib # Detailed destination directories BINLIBDEST= $(LIBDIR)/python$(VERSION) LIBDEST= $(SCRIPTDIR)/python$(VERSION) INCLUDEPY= $(INCLUDEDIR)/python$(VERSION) EXECINCLUDEPY= $(exec_installdir)/include/python$(VERSION) LIBP= $(exec_installdir)/lib/python$(VERSION) DESTSHARED= $(BINLIBDEST)/site-packages LIBPL= $(LIBP)/config LIBPL= $(shell python$(VERSION)-config --configdir) PYTHONLIBS= $(LIBPL)/libpython$(VERSION).a MAKESETUP= $(LIBPL)/makesetup MAKEFILE= $(LIBPL)/Makefile CONFIGC= $(LIBPL)/config.c CONFIGCIN= $(LIBPL)/config.c.in SETUP= $(LIBPL)/Setup.config $(LIBPL)/Setup.local $(LIBPL)/Setup SYSLIBS= $(LIBM) $(LIBC) ADDOBJS= $(LIBPL)/python.o config.o # Portable install script (configure doesn't always guess right) INSTALL= $(LIBPL)/install-sh -c # Shared libraries must be installed with executable mode on some systems; # rather than figuring out exactly which, we always give them executable mode. # Also, making them read-only seems to be a good idea... INSTALL_SHARED= ${INSTALL} -m 555 # === Fixed rules === # Default target. This builds shared libraries only default: sharedmods # Build everything all: static sharedmods # Build shared libraries from our extension modules sharedmods: $(SHAREDMODS) # Build a static Python binary containing our extension modules static: $(TARGET) $(TARGET): $(ADDOBJS) lib.a $(PYTHONLIBS) Makefile $(BASELIB) $(LINKCC) $(LDFLAGS) $(LINKFORSHARED) \ $(ADDOBJS) lib.a $(PYTHONLIBS) \ $(LINKPATH) $(BASELIB) $(MODLIBS) $(LIBS) $(SYSLIBS) \ -o $(TARGET) $(LDLAST) install: sharedmods if test ! -d $(DESTSHARED) ; then \ mkdir $(DESTSHARED) ; else true ; fi -for i in X $(SHAREDMODS); do \ if test $$i != X; \ then $(INSTALL_SHARED) $$i $(DESTSHARED)/$$i; \ fi; \ done # Build the library containing our extension modules lib.a: $(MODOBJS) -rm -f lib.a ar cr lib.a $(MODOBJS) -$(RANLIB) lib.a # This runs makesetup *twice* to use the BASESETUP definition from Setup config.c Makefile: Makefile.pre Setup $(BASESETUP) $(MAKESETUP) $(MAKESETUP) \ -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP) $(MAKE) -f Makefile do-it-again # Internal target to run makesetup for the second time do-it-again: $(MAKESETUP) \ -m Makefile.pre -c $(CONFIGCIN) Setup -n $(BASESETUP) $(SETUP) # Make config.o from the config.c created by makesetup config.o: config.c $(CC) $(CFLAGS) -c config.c # Setup is copied from Setup.in *only* if it doesn't yet exist Setup: cp $(srcdir)/Setup.in Setup # Make the intermediate Makefile.pre from Makefile.pre.in Makefile.pre: Makefile.pre.in sedscript sed -f sedscript $(srcdir)/Makefile.pre.in >Makefile.pre # Shortcuts to make the sed arguments on one line P=prefix E=exec_prefix H=Generated automatically from Makefile.pre.in by sedscript. L=LINKFORSHARED # Make the sed script used to create Makefile.pre from Makefile.pre.in sedscript: $(MAKEFILE) sed -n \ -e '1s/.*/1i\\/p' \ -e '2s%.*%# $H%p' \ -e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \ -e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \ -e '/^CXX=/s/^CXX=[ ]*\(.*\)/s%@CXX[@]%\1%/p' \ -e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \ -e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \ -e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \ -e '/^LDLAST=/s/^LDLAST=[ ]*\(.*\)/s%@LDLAST[@]%\1%/p' \ -e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \ -e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \ -e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \ -e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \ -e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \ -e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \ -e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \ -e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \ -e '/^BLDSHARED=/s/^BLDSHARED=[ ]*\(.*\)/s%@BLDSHARED[@]%\1%/p' \ -e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \ -e '/^SGI_ABI=/s/^SGI_ABI=[ ]*\(.*\)/s%@SGI_ABI[@]%\1%/p' \ -e '/^$L=/s/^$L=[ ]*\(.*\)/s%@$L[@]%\1%/p' \ -e '/^$P=/s/^$P=\(.*\)/s%^$P=.*%$P=\1%/p' \ -e '/^$E=/s/^$E=\(.*\)/s%^$E=.*%$E=\1%/p' \ $(MAKEFILE) >sedscript echo "/^installdir=/s%=.*%= $(installdir)%" >>sedscript echo "/^exec_installdir=/s%=.*%=$(exec_installdir)%" >>sedscript echo "/^srcdir=/s%=.*%= $(srcdir)%" >>sedscript echo "/^VPATH=/s%=.*%= $(VPATH)%" >>sedscript echo "/^LINKPATH=/s%=.*%= $(LINKPATH)%" >>sedscript echo "/^BASELIB=/s%=.*%= $(BASELIB)%" >>sedscript echo "/^BASESETUP=/s%=.*%= $(BASESETUP)%" >>sedscript if grep 's%@DEFS' sedscript >/dev/null 2>&1; then \ :; \ else \ echo "s%@DEFS[@]%%" >>sedscript; \ fi # Bootstrap target boot: clobber VERSION=`$(PYTHON) -c "import sys; print sys.version[:3]"`; \ installdir=`$(PYTHON) -c "import sys; print sys.prefix"`; \ exec_installdir=`$(PYTHON) -c "import sys; print sys.exec_prefix"`; \ $(MAKE) -f $(srcdir)/Makefile.pre.in VPATH=$(VPATH) srcdir=$(srcdir) \ VERSION=$$VERSION \ installdir=$$installdir \ exec_installdir=$$exec_installdir \ Makefile # Handy target to remove intermediate files and backups clean: -rm -f *.o *~ # Handy target to remove everything that is easily regenerated clobber: clean -rm -f *.a tags TAGS config.c Makefile.pre $(TARGET) sedscript -rm -f *.so *.sl so_locations # Handy target to remove everything you don't want to distribute distclean: clobber -rm -f Makefile Setup pyg-0.9.8ubuntu2/wlp/module/Setup.in0000644000000000000000000000650312057422101014257 0ustar # -*- makefile -*- # The file Setup is used by the makesetup script to construct the files # Makefile and config.c, from Makefile.pre and config.c.in, # respectively. The file Setup itself is initially copied from # Setup.in; once it exists it will not be overwritten, so you can edit # Setup to your heart's content. Note that Makefile.pre is created # from Makefile.pre.in by the toplevel configure script. # (VPATH notes: Setup and Makefile.pre are in the build directory, as # are Makefile and config.c; the *.in files are in the source # directory.) # Each line in this file describes one or more optional modules. # Comment out lines to suppress modules. # Lines have the following structure: # # ... [ ...] [ ...] [ ...] # is anything ending in .c (.C, .cc, .c++ are C++ files) # is anything starting with -I, -D, -U or -C # is anything ending in .a or beginning with -l or -L # is anything else but should be a valid Python # identifier (letters, digits, underscores, beginning with non-digit) # # (As the makesetup script changes, it may recognize some other # arguments as well, e.g. *.so and *.sl as libraries. See the big # case statement in the makesetup script.) # # Lines can also have the form # # = # # which defines a Make variable definition inserted into Makefile.in # # Finally, if a line contains just the word "*shared*" (without the # quotes but with the stars), then the following modules will not be # included in the config.c file, nor in the list of objects to be # added to the library archive, and their linker options won't be # added to the linker options, but rules to create their .o files and # their shared libraries will still be added to the Makefile, and # their names will be collected in the Make variable SHAREDMODS. This # is used to build modules as shared libraries. (They can be # installed using "make sharedinstall", which is implied by the # toplevel "make install" target.) (For compatibility, # *noconfig* has the same effect as *shared*.) # # In addition, *static* reverses this effect (negating a previous # *shared* line). # NOTE: As a standard policy, as many modules as can be supported by a # platform should be present. The distribution comes with all modules # enabled that are supported by most platforms and don't require you # to ftp sources from elsewhere. *static* # Some special rules to define PYTHONPATH. # Edit the definitions below to indicate which options you are using. # Don't add any whitespace or comments! # Directories where library files get installed. # DESTLIB is for Python modules; MACHDESTLIB for shared libraries. DESTLIB=$(LIBDEST) MACHDESTLIB=$(BINLIBDEST) # NOTE: all the paths are now relative to the prefix that is computed # at run time! # Standard path -- don't edit. # No leading colon since this is the first entry. # Empty since this is now just the runtime prefix. DESTPATH= # Site specific path components -- should begin with : if non-empty SITEPATH= # Standard path components for test modules TESTPATH= # Path components for machine- or system-dependent modules and shared libraries MACHDEPPATH=:plat-$(MACHDEP) COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(MACHDEPPATH)$(STDWINPATH)$(TKPATH) PYTHONPATH=$(COREPYTHONPATH) *shared* WLPSRCDIR=../C wlp $(WLPSRCDIR)/wlp.c $(WLPSRCDIR)/wlp.a pyg-0.9.8ubuntu2/wlp/module/patch0000644000000000000000000000117212057422101013646 0ustar diff -ru pyg-0.9.6-old/wlp/module/Makefile.pre.in pyg-0.9.6/wlp/module/Makefile.pre.in --- pyg-0.9.6-old/wlp/module/Makefile.pre.in 2003-11-04 08:49:29.000000000 -0800 +++ pyg-0.9.6/wlp/module/Makefile.pre.in 2003-11-04 09:25:16.000000000 -0800 @@ -278,6 +278,9 @@ echo "/^LINKPATH=/s%=.*%= $(LINKPATH)%" >>sedscript echo "/^BASELIB=/s%=.*%= $(BASELIB)%" >>sedscript echo "/^BASESETUP=/s%=.*%= $(BASESETUP)%" >>sedscript + if ! grep 's%@DEFS' sedscript >/dev/null 2>&1; then \ + echo "s%@DEFS[@]%%" >>sedscript; \ + fi # Bootstrap target boot: clobber pyg-0.9.8ubuntu2/wlp/Makefile0000644000000000000000000000141012057422124012777 0ustar MODULEDIR=module CSRCDIR=C BINDIR=.. # modules name without $(MODULEDIR) SOLIST=test.so all: bin bin: initmodule wlp makemodule chmod 0644 $(MODULEDIR)/*.so mv $(MODULEDIR)/*.so $(BINDIR) # Init Makefile & Co. file for building python module initmodule: $(MAKE) -C $(MODULEDIR) -f Makefile.pre.in boot # The White List Parser Module wlp: $(MAKE) -C $(CSRCDIR) archive # Really make python module as .so makemodule: $(MAKE) -C $(MODULEDIR) clean: cleanmodule cleansrc rm -f $(BINDIR)/*.so cleansrc: $(MAKE) -C $(CSRCDIR) clean cleanmodule: @if test -f $(MODULEDIR)/Makefile; then $(MAKE) -C $(MODULEDIR) clean ;fi rm -f $(MODULEDIR)/Makefile.pre $(MODULEDIR)/Makefile rm -f $(MODULEDIR)/config.c rm -f $(MODULEDIR)/sedscript rm -f $(MODULEDIR)/Setup