Software bits
Some random code of mine you may find useful or amusing. All
this code is either GPLed
or LGPLed.
Although some bits of this code are updated rather frequently,
no effort is made to keep everything up to date, thus a lot of
what follows may suffer of Byte Decay (a desease more
common than tooth decay).
Warning. Whether any of these bits might be in some
way used to perpetrate an act of cracking (hacking,
for the jackass) or cyber-vandalism, I don't know. Just be
warned that, if you happen to live in Germany, according to
a recent
law, just the possession of such program constitutes a
crime.
What actually matches that definition of software is
anybody's guess. As far as I can tell, it could as well be
your web browser or your MP3 player, it all depends on how
it is used, and ultimately how the judge will get to like
you.
Yes, I know. It's like putting in prison those who carry a
screwdriver, because it could be used to break into a car.
It's ridiculous and anyone can see that. But I wouldn't be
so certain the judge will show more competence than the MPs
who crafted this idiocy. You may find yourself spending a
considerable part of your life in a prison while challenging
this law.
Donwload at your own peril.
Common Lisp
-
mpd4cl-20080417.src.tbz,
MPD4CL
is a library to write
MPD
client programs. It's currently under development together
with an unpublished GUI, therefore it may change substantially
anytime soon.
-
MeDaMa (or
MDM) is a meta-data
manager in general, and a picture manager in particular,
written to archive, sort and ultimately make sense of my
increasingly messy collection of photographs.
-
metafs-20080520.src.tbz,
MetaFS is a library to
transparently associate arbitrary meta-data information to
files.
-
demyltify-20071204.src.tbz,
Demyltify is a milter library for Common Lisp.
It doesn't require any external library because it
speaks the (undocumented) Sendmail/milter protocol. The code
is heavily commented so its use should be fairly
straightforward.
Example:
(use-package :milter)
(let ((message-counter 0)
(byte-counter 0))
(defclass my-context (milter-context)
((byte-count :accessor ctx-byte-count)))
(defmethod handle-event ((e event-body) (ctx my-context))
(incf (ctx-byte-count ctx) (length (event-body-data e)))
keep-going)
(defmethod handle-event ((e event-mail) (ctx my-context))
(setf (ctx-byte-count ctx) 0)
keep-going)
(defmethod handle-event ((e event-end-of-message) (ctx my-context))
(incf byte-counter (ctx-byte-count ctx))
(incf message-counter)
(format t "~
~:R message of ~A byte~:P~%~
the messages seen so far total ~A byte~:P~%~
for an average of ~A byte~:P per message~%"
message-counter (ctx-byte-count ctx)
byte-counter
(round byte-counter message-counter))
(finish-output)
accept))
(setf demyltify:*required-events* '(:mail :body))
(start-milter 20025 :context-class 'my-context))
Tested on SBCL, CMUCL and CLISP. Requires net4cl.
-
smta.lisp is a simple and lean SMTP
server written in CL. At the moment it's a very early stage
draft, but somehow promising.
-
clpmr-20080609.src.tbz,
CLPMR is
basically a rewrite of spmr with a
substantial refactoring of the code and a new client/server
design that makes it quite efficient.
CLPMR provides the same functionalities as procmail
but with much more flexibility and simplicity due to the fact
that the language you describe the rules with is Lisp and not
some obscure sequence of characters looking like line noise.
Using Lisp, it means that the implementation of things like
mailing list servers and document servers becomes trivial and
you don't even need external programs
(see this example). MIME
content is handled natively as well.
To compile CLPMR you need a handful of Common Lisp libraries
from this page
(mime4cl, net4cl,
smtp4cl and sclf)
and CMUCL. It doesn't depend on external C libraries.
-
binge-20070328.src.tbz,
BINGE is a FFI
generator for Common Lisp. It parses C source files (header
or code, it doesn't mind) and spits out a FFI for your Lisp
system of choice. Functions, global variables, types and
symbolic constants can be easily extracted just naming them.
It's written in a modular way so that adding a new FFI API is
a matter of few hours. Back-ends for SBCL, CMUCL, LispWorks,
UFFI and CLISP are provided.
It comes with a suite of
regression tests and
depends on NPG.
-
npg-20070521.src.tbz,
NPG
is a Naïve Parser Generator. It's a
small compiler of backtracking recursive descendant parsers
that accepts grammars in an extended BNF notation of arbitrary
complexity (excluding indirect left recursive rules).
It doesn't produce any file, it just compiles the grammar
internally, ready to be used. A couple of examples are
included: a VS-Cobol II and a Python grammar (both far from
complete).
-
termcap.lisp is a termcap library
for CL. All capabilities are accessible through
the
getcap primitive. Some other common
primitives are provided (goto, put); see the end of the file.
-
asdfa.lisp, a few
extensions to ASDF. This code adds five operations:
-
pack-op which creates
an archive (by default a tar archive) of all the files in the
system
-
tag-op which creates an Emacs/Vi tags
file
-
stat-op which prints some figures about
the system files (from Unix wc)
-
make-exe-op which writes an executable file
containing all the necessary modules required to run the
system (it works on SBCL and CMUCL, but for the latter you
may need my executable.lisp)
-
revert-op which removes the files produced by
another operation; by default it reverts the compilation,
which means the x86f/fasl files
Watch out that the make-exe-op was broken until
recently.
-
clusr-20050119.tbz2,
CLUSR is a
little program to batch-download fax and voice messages from
an US Robotics Message Modem and forward them via e-mail to
interested parties in a neat MIME attachment. The program
itself is small but makes use of a number of external
libraries: mime4cl,
cltio,
smtp4cl,
net4cl,
sclf, and
binary-types.
-
MArch (pronounced as the month) is a
daemon program that saves email going through a mail server
into a database. It plugs in the
Sendmail
mail delivery system as a milter.
-
mime4cl-20080614.src.tbz,
MIME4CL is a
MIME library for Common Lisp. It allows you to craft MIME
compliant messages or to parse and handle them
programmatically.
-
cltio-20050119.tbz2,
CLTIO is a
termio library for Common Lisp. It's a FFI to the Unix/Posix
library. Actually it's an UFFI module automatically generated
by BINGE starting
from cltio-gen.
-
smtp4cl-20070124.src.tbz,
SMTP4CL is a SMTP client library to send messages
to an MTA (Mail transport Agent). It
requires mime4cl
and net4cl.
-
net4cl-20070724.src.tbz,
NET4CL is a
collection of network functions, mostly encapsulation of
existing functions to uniform the interface between different
Lisp systems. Some other code in this page depends on it.
Currently only CMUCL and SBCL are supported.
-
gtka-20080417.src.tbz,
GTKA is a small collection of
functions that helped me writing code with CLG. You
probably don't need it for anything but to compile other code
from this page.
-
sclf-20080614.src.tbz,
SCLF is a
collection of functions and macros, too small or too unrelated
to deserve an own package. You need them to compile some code
on this page.
To indent properly the macros defined in SCLF you may want
to add the following lines to your .emacs file:
(defun cl-indent-be (path state indent-point sexp-column normal-indent)
(let ((sexp-start (cadr state))
(current-position (point)))
(save-excursion
(let ((calculate-indentation
(lambda (var-indent val-indent)
(let ((i 0))
(+ sexp-column
(catch 'return
(condition-case nil
(while (< (point) current-position)
(while (forward-comment 1))
(cond ((and (= 1 (logand i 1))
(looking-at "[\t\n ]*\\s("))
(throw 'return 2))
(t (setq i (1+ i))
(forward-sexp))))
(error nil))
(if (= 1 (logand i 1))
val-indent
var-indent)))))))
(goto-char sexp-start)
(forward-char)
(let ((tag (symbol-at-point)))
(cond ((eq tag 'be)
(funcall calculate-indentation 4 6))
((eq tag 'be*)
(funcall calculate-indentation 5 7))
(t nil)))))))
(put 'be 'common-lisp-indent-function 'cl-indent-be)
(put 'be* 'common-lisp-indent-function 'cl-indent-be)
(put 'awhen 'lisp-indent-function 1)
(put 'gcase 'lisp-indent-function 1)
(put 'acase 'lisp-indent-function 1)
(put 'acond 'lisp-indent-function 1)
(put 'until 'lisp-indent-function 1)
-
html-sugar-20071204.src.tbz,
HTML-sugar
is a collection of functions and macros that happened to pop
up here and there in my web-based programs written on AServe.
You need them to compile some other code from this page.
-
CLOT is a simple
library to plot data sets in charts of different types.
Currently it supports bar, histogram, line, and pie charts,
all with some optional graphic decorations.
-
cobstor-20080612.src.tbz,
Cobstor is a tool and an
API to seamlessly access legacy Cobol application files from
Common Lisp. The design is client/server; those familiar with
IPC architectures such as Corba or Java Beans, should
understand cobstor in no time.
Lisp proxy stubs talk via a simple IPC layer to Cobol agents
which in turn access the database for you. All you need is
the Cobol record declaration (the copy file, in Cobol
speak) and cobstor will automatically generate the Cobol agent
and the Lisp proxy for you.
It's been developed on CMUCL+AcuCobol but it should be easily
portable to other Lisp systems that support MOP, and Cobol
systems with socket primitives.
-
cliconv-20070124.src.tbz,
Cliconv
is a simple FFI interface to the
iconv library
that lets Common Lisp programs translate byte sequences
from/to different character sets, like this:
(cliconv:iconv (map '(vector (unsigned-byte 8)) #'char-code
"François, piña, böse, skøl")
:ISO-8859-1 :UTF-8)
This package uses UFFI, so it should be fairly portable.
-
currensea-20070124.src.tbz
is a currency conversion library based on AllegroServe and
WebserviceX.
CL-USER> (asdf:oos 'asdf:load-op :currensea)
; [...]
NIL
CL-USER> (currency:get-quote "USD")
1.2057
CL-USER> (currency:exchange-rate "JPY" "USD")
0.0084
CL-USER> (currency:convert-currency 10000 "BMD" "CNY")
80623.0
CL-USER>
-
ods4cl-20080312.src.tbz,
ODS4CL
can produce spreadsheets
in OpenDocument format (those suitable
for OpenOffice and other popular office
programs). It can produce multiple page sheets but cells
can't contain formulas (I've no need for those, yet). This
package depends on SCLF.
Here is an example:
(ods4cl:make-spreadsheet #P"/tmp/foo.ods"
'(("My Sheet"
(a b c)
(1.2 3.4 5.6)
("foo" "bar" "baz"))))
|
|
-
faxdb.tar.bz2,
FaxDB is a fax archiver
for Hylafax. It's been one of my first
occasions to play around with
UncommonSQL and
Portable Allegroserve. The code is rather
old, ugly and stale so it may not compile/work any longer.
Scheme
-
mark-selection.scm is a
Script-Fu module for Gimp to quickly highlight spots
of an image for didascalic purposes as in
this sample image. (The three
spots have been chosen randomly and therefore don't show
anything interesting.)
-
frame.scm is a Script-Fu module
for Gimp to
prepare my photographs for Internet publishing. It adds some
new commands you will find under
Image->Script-Fu->Decor.
Scsh
The following code samples have been tested under Scsh 0.5.3.
-
ppplog.scm is an example of use for
SCSH as report language. This scsh script prints some
statistics taken from the ppp.log files (the user-land ppp
daemon of FreeBSD). It prints, sorted by day, the on-line
time, input and output traffic. Something like this:
daemon# ppplog.scm
24/9 01:59:57 12M 8M
25/9 00:26:10 3M 2M
26/9 01:02:01 13M 1M
27/9 02:18:18 14M 4M
28/9 00:31:47 5M 2M
29/9 00:54:41 8M 3M
-
spmr.tar.bz2,
SPMR. Tired
of messing around with a brain damaged syntax akin at the
anachronistic sendmail cf files,
I eventually decided to write an MDA (Mail Delivery Agent)
that would let me sieve and handle my incoming mail from the
comfort of the Scheme language, with all the expressiveness of
Scheme and with the power of a real programming
language. If you want to be able to deal with mime files you
need mpack as well.
Here is an example of rules file.
All you need to do is to redirect your e-mail to spmr.
Something like this in your .forward file will do:
"| /path/to/spmr"
where spmr is the trampoline program.
Note that the trampoline program improves dramatically
performances on heavy e-mail traffic, avoiding to run multiple
SCSH instances concurrently, which has the potential risk of
clogging the system.
The spmr.image should be installed in the same
place as the trampoline.
-
Some functions to generate
business cards in postscript. This requires fps 1.0 and
a patch to correct a bug triggered by
my code. You can start from this example
to find out how to use the library.
-
An utility to help
keeping tidy your FreeBSD distfiles directory.
It removes (or shows) the outdated distribution files.
-
An utility to find
system installation problems, such as missing shared libraries
and stray cat pages (pun intended). It walks through
your search path, or a list of directories you supply. It's
useful if you sometimes removed packages without taking care
of broken dependencies. It has been written for FreeBSD but
its usefulness is not limited to that OS.
-
An utility to find broken
symbolic links. It checks, possibly recursively, a list of
files or your current directory for broken symbolic links.
-
Find duplicate files in a directory
tree. It reports files containing the same data but are
not the same inode. This is, a verbatim copy.
-
I keep the CVS live tree of the software I use the most, and
keep it up to date
with update-cvs.scm.
It fully exploits the available bandwidth by executing
parallel cvs commands up to *max-procs*.
See the .update-cvs file.
Hitting the INFO key (normally Ctrl-T, see stty)
you get a neat summary of what's going on.
-
Extract all the e-mail
addresses from files (HTML pages). Any unethical use of
this script, such as the building of spamming lists, will be
punished in the afterlife.
-
Convert to tar (but can be anything)
from any other inferior archive format. Aka, yet
another trivial example of Scsh use in everyday life.
-
Create an ISO-9660 image from
a list of directories. It asks interactively some details
guessing some defaults and proposes you to burn the image
right away. It needs cdrtools and mkisofs.
-
Some syntactic sugar for Scsh (or
Scheme48).
One of the features in the wish list of Arc that I found
cool was the square bracket sexp that expands to a single
argument lambda expression. So that one can do things like:
(map [/ _ 2] '(2 4 6 8 10))
(cond ((regexp-exec re str) => [match:substring _ 1]) ...)
instead of
(map (lambda (x) (/ x 2)) '(2 4 6 8 10))
(cond ((regexp-exec re str) => (lambda (m) (match:substring m 1))) ...)
Disclaimer: I am not advocating Perl-ish syntactic crypticism.
This has been written just as a funny exercise in Scsh
hacking.
Here is a less heretic approach for those using
Emacs:
(defun lisp-insert-lambda ()
"Insert lambda form at point asking for variables."
(interactive)
(insert "(lambda (" (read-string "Variables: ") ") ")
(save-excursion (insert ")")))
(add-hook 'scheme-mode-hook
'(lambda ()
(local-set-key "\C-cl" 'lisp-insert-lambda)))
FreeBSD
Patches to the FreeBSD
system. Some Scheme code for FreeBSD is available elsewhere on
this page.
Sawfish
The following code is made for the Sawfish Window manager.
-
A poor man's dock for WindowMaker dockable
applications.
-
Some simple input/output utilities.
-
A few functions to change the LCD
back light intensity of a Sony Vaio. Under FreeBSD you need to
install the sjog package, because this code
calls
setbrightness. I recommend to bind
increase-brightness to the
Super-Button4-Click event
and decrease-brightness to
the Super-Button5-Click event. Tested on a
PCG-XG9.
-
A Ctrl-Alt-Del mapping for Sawfish for
those of us stuck to the MS look'n'feel-sick.
Miscellanea
-
A tiny little patch
for ng_mangle
0.2, a netgraph based packet mangler
for FreeBSD. The original
0.2 version worked only on FreeBSD up to 5.2. The author,
Dominik Łupiński, discontinued the project and authorised me
to publish this patched
version.
-
A simple file concatenation utility
similar to cat(1) but suitable to incrementally copy
log files. It concatenates two or more files avoiding to
replicate footer and header of adjacent files. That
is, if a file ends with the same data at the beginning of the
next one, only one copy of this repeated data is guaranteed to
be present in the output.
Example: abcd + cdef = abcdef.
If the option -o is given, files are concatenated
after the end of the first (modifying it).
-
Software for the Thomson
(RCA outside Germany) Lyra MP3 player.
-
Modgetty, a modular getty with Tcl extensions.
This stuff is so old that I didn't bother to store it
anywhere, but there is still some trace around. Here is a
page:
www.linux-ag.de.
All the photographs on these pages are copyright Walter
C. Pelissero. All rights are reserved. No copy, manipulation or
transfer, beside for the sake of personal view of the page where
they appear on, is allowed. Also the direct linking of web pages to
the single photograph image is forbidden.
If you need to have them, much higher resolution hard copies are
available on request.
Copyright © Walter C. Pelissero, all rights reserved
Last modified: Thu Jun 19 18:30:48 CEST 2008