# @(#) pm-javar.rc -- Jari's global variable definitions
# @(#) $Id: pm-javar.rc,v 2.0 2001/07/27 22:45:51 jaalto Exp $
#
#   File id
#
#       .Copyright (C)   1997-2001 Jari Aalto
#       .$Created:       1997-12 $
#       .$Contactid:     jari.aalto@poboxes.com $
#       .$Keywords:      procmail, variable definitions $
#
#       This code is free software in terms of GNU Gen. pub. Lic. v2 or later
#	Refer to http://www.gnu.org/copyleft/gpl.html
#
#   Description
#
#	This file defines common variables that you can use in the recipe's
#	condition line. Procmail does not know about escape sequences like
#	\t or \n and it is therefore much more readable to use variables as
#	substitute for common regular expression atoms. Pay attention
#	that the line starts with "*$ ", where "$" expands the variables:
#
#           :0
#           *$ $s+something+$s+$d+$a+
#
#       The equivalent without variables (you don't see the tabs and spaces)
#
#	    :0
#	    #  Space + tab
#           * [ 	]something[	][0-9]+[a-z]+
#
#
#	In addition all system dependent variables are defined in this module.
#	For example if you have Gnu awk, it is strongly suggest that you set:
#
#	    AWK = "/path/to/gawk"
#
#	Also if your plain `perl' binary still runs the perl 4, then please set
#
#	    PERL = "path/to/perl5"
#
# 	You can define these variables before or after the module, just make
#	sure the binaries reflect your operating system's paths. In genral,
#	if you "port" your setup to several system, dont' include absolute
#	paths. In the other hand, if your setup is in the same place using
#	absolute paths speed up executions by a factor of 3 or more.
#	(depending on how long your PATH is)
#
#   Standard variables defined
#
#       See pm-tips.txt file for full explanation or look at the source code.
#
#           SPC WSPC NSPC SPCL       # Whitespace, NonWhitespace, W+linefeed
#           \s \d \D \w \W and \a \A # perl equivalents
#
#   Special variable from_daemon
#
#	In order to boost procmail and to save extra CPU cycles, this module
#       defines variable `from_daemon' that caches the information of
#       ^FROM_DAEMON.  You can refer to `from_daemon' as you would to
#       big brother FROM_DAEMON. This has the advantage that procmail
#       has already computed the result and the variable `from_daemon'
#       is used as a cache, thus avoiding repeated FROM_DAEMON regexp
#       tests, which are expensive.  Variable `from_daemon_match'
#       contains "" or the result of matched daemon text.
#
#           *$ $from_daemon
#
#       or the familiar
#
#           *$ ! $from_daemon
#
#       Instead of using the regexp parsing with
#
#           * ^FROM_DAEMON
#
#       and
#
#           * ! ^FROM_DAEMON
#
#   Special variable from_mailer
#
#       Works like `from_daemon' variable but in respect to FROM_MAILER.
#       The matches text is in `from_mailer_match'
#
#   Usage example
#
#       Put this as a first line in you includerc. It checks if WSPC
#       varaible does not include a space --> load the variable definitions.
#	If the variable is already defined, the file is not loaded.
#	This is something like #ifdef -- #endif in C/C++ language or
#	conditional "import" command in other languages.
#
#           :0
#           * ! WSPC ?? [ ]
#           {
#               INCLUDERC = $PMSRC/pm-javar.rc
#           }
#
#       For your .procmailrc, you can simply put this, because you
#	want to load the variables at startup
#
#           INCLUDERC = $PMSRC/pm-javar.rc
#
#   Defined modules
#
#	After this file loads, you can refer to any module with $RC_MODULE.
#	Eg. to call email spit module in your code you would use following.
#	See at the end of this file for all defined modulenames.
#
#	    INCLUDERC = $RC_EMAIL
#
#   Change Log (none)

id    = "pm-javar.rc"
dummy = "
========================================================================
$id: init:
"

# ....................................................... &space-tab ...

#   pure newline, you mainly use this for:
#   LOG = "    message $NL"

NL	= "
"
LF	= $NL			# synonym, linefeed


WSPC    = " 	"		# whitespace in procmail: space + tab

#   These are the variables that you're likely to use in
#   conditionb lines. Notice that there is Perl styles `s' variable
#   for shorter name for most used SPC.

SPC     = "[$WSPC]"		# Regexp space/tab
NSPC    = "[^$WSPC]"            # Negation, non-whitespace

#   Whitespace with linefeed
#   Note that in regexps, the craracter class is faster that OR.
#   Refer to O'Reilly book "Mastering Regular Expressions"
#
#	space + tab + dollar
#
#	( | |$)  is slower than ([ ]|$)

SPCL   = "($SPC|$)"		# space or tab or linefeed

# ..................................................... &perl-styled ...
# http://www.perl.com/   if you don't know what 'Perl' is

#   And some shorter variable names, mimic perl token names.

s	= "$SPC"		# Almost like perl	-- \s
d	= "[0-9]"		# digit			-- Perl \d
D	= "[^0-9]"		# Non-digit		-- Perl \D
w	= "[0-9a-z_A-Z]"	# word			-- Perl \w
W	= "[^0-9a-z_A-Z]"	# Non-word		-- Perl \W

#   No perl equivalents for these, but handy anyway.

a       = "[a-zA-Z]"            # word, only alphabets
A       = "[^a-zA-Z]"           # Non alphabet
h       = "[0-9a-fA-F]"         # Hex values
H       = "[^0-9a-fA-F]"        # Non-Hex values

# ............................................................ &misc ...

SUPREME = 9876543210            # The highest score value. See pm-tips.txt

#   Getting month or month-number matches. See pm-jadate*rc modules
#   for examples.

mm2nbr	 = "Jan01Feb02Mar03Apr04May05Jun06Jul07Aug08Sep09Oct10Nov11Dec12"
nbr2mm	 = "01Jan02Feb03Mar04Apr05May06Jun07Jul08Aug09Sep10Oct11Nov12Dec"
weekdays = "(Sun|Mon|Tue|Wed|Thu|Fri|Sat)"

TMPDIR      = ${TMPDIR:-"/tmp"}

# ........................................................ &programs ...
#   Substitute these with absolute path names and binaries will run faster

FORMAIL     = ${FORMAIL:-"formail"}
PROCMAIL    = ${PROCMAIL:-"procmail"}

#	Don't ever leave out flags -oi and -t

SENDMAIL_FLAGS	= "-oi -t"
SENDMAIL	= ${SENDMAIL:-"sendmail $SENDMAIL_FLAGS"}

LS	    = ${LS:-"ls"}
LS_BY_DATE  = ${LS:-"ls -t"}
TR          = ${TR:-"tr"}
RM          = ${RM:-"rm"}
MV          = ${RM:-"mv"}
CP	    = ${CP:-"cp"}
CAT         = ${CAT:-"cat"}
SED         = ${SED:-"sed"}
AWK         = ${AWK:-"awk"}

RMDIR	    = ${RMDIR-"rmdir"}
MKDIR	    = ${MKDIR-"mkdir"}

TOUCH       = ${TOUCH:-"touch"}
CHMOD       = ${CHMOD:-"chmod"}
DATE	    = ${DATE:- "date"}	    # must accept POSIX % escapes as date(1)

EGREP       = ${EGREP:-"egrep"}
GREP        = ${EGREP:-"egrep"}
NSLOOKUP    = ${NSLOOKUP:-"nslookup"}
GZIP	    = ${GZIP:-"gzip"}

#	This _must_ be Perl 5.x version. Old version 4.0 is way too old
#	and obsolete for statements like BEGIN{}

PERL        = ${PERL:-"perl"}


# ............................................................ &test ...
#   The `test' command is not identical in every system, so they
#   must be put behnd variables. Eg. On Irix the -e
#   option is not recognized so IS_EXIST must be changed to -r

IS_READABLE   = ${IS_READABLE:-"test -r"}
IS_EXIST      = ${IS_READABLE:-"test -e"}
IS_EXECUTABLE = ${IS_READABLE:-"test -x"}
IS_FILE       = ${IS_READABLE:-"test -f"}
IS_DIR        = ${IS_READABLE:-"test -d"}
IS_NOT_EMPTY  = ${IS_READABLE:-"test -s"}    # exist and not empty

# ............................................................ &mime ...
# Mime decode commands

MIME_BIN        = ${MIME_BIN:-"mimencode"}
MIME_BIN_QP     = ${MIME_BIN_QP:-"$MIME_BIN -u -q"}
MIME_BIN_64     = ${MIME_BIN_64:-"$MIME_BIN -u -b"}

#  encode commands with "E" at  the end

MIME_BIN_QP_E   = ${MIME_BIN_QPE:-"$MIME_BIN -q"}
MIME_BIN_64_E   = ${MIME_BIN_64E:-"$MIME_BIN -b"}

# ...................................................... &exit-codes ...
# These should be pretty standard. See /usr/include/sysexits.h

EX_OK          = 0        # successful termination
EX__BASE       = 64       # base value for error messages
                          #
EX_USAGE       = 64       # command line usage error
EX_DATAERR     = 65       # data format error
EX_NOINPUT     = 66       # cannot open input
EX_NOUSER      = 67       # addressee unknown
EX_NOHOST      = 68       # host name unknown
EX_UNAVAILABLE = 69       # service unavailable
EX_SOFTWARE    = 70       # internal software error
EX_OSERR       = 71       # system error (e.g., can't fork)
EX_OSFILE      = 72       # critical OS file missing
EX_CANTCREAT   = 73       # can't create (user) output file
EX_IOERR       = 74       # input/output error
EX_TEMPFAIL    = 75       # temp failure; user is invited to retry
EX_PROTOCOL    = 76       # remote error in protocol
EX_NOPERM      = 77       # permission denied

# ........................................................ &messages ...
# Reserver string variables

JA_MSG_ERROR	   = "ERROR: *** "	 # Message follows after this
JA_MSG_ERROR_FATAL = "ERROR: FATAL: *** " # Message follows after this

# ..................................................... &from-daemon ...

from_daemon = "!"

:0
* ^FROM_DAEMON
{
    from_daemon_match   = $MATCH
    from_daemon         = "!!"  # double !! means "OK"

    #  2000-01-08  This has been copied from procmail log file
    #  because we can't get the match otherwise.
    #  Procmail version: v3.11pre4 1995/10/29
    #
    #  The following recipe is dummy: It solely sets MATCH to show
    #  what procmail thinks triggered FROM_DAEMON

#    :0
#    * ()\/^(Precedence:.*(junk|bulk|list)|To: Multiple recipients of |(((Resent-)?(From|Sender)|X-Envelope-From):|>?From )([^>]*[^(.%@a-z0-9])?(Post(ma?(st(e?r)?|n)|office)|(send)?Mail(er)?|daemon|mmdf|n?uucp|LIST(SERV|proc)|NETSERV|owner|r(e(quest|sponse)|oot)|b(ounce|bs\.smtp)|echo|mirror|s(erv(ices?|er)|mtp)|A(dmin(istrator)?|MMGR|utoanswer))(([^).!:a-z0-9][-_a-z0-9]*)?[%@>	 ][^<)]*(\(.*\).*)?)?$([^>]|$)))
#    { }

}

# ..................................................... &from_mailer ...

from_mailer = "!"

:0
* ^FROM_MAILER
{
    from_mailer_match   = $MATCH
    from_mailer         = "!!"  # double !! means "OK"

}

# .................................................. &define-modules ...

:0
* PMSRC ?? [a-z]
{

    RC_ADDR	    = $PMSRC/pm-jaaddr.rc
    RC_BUP	    = $PMSRC/pm-jabup.rc
    RC_COOKIE	    = $PMSRC/pm-jacookie.rc
    RC_COOKIE1	    = $PMSRC/pm-jacookie1.rc
    RC_CRON	    = $PMSRC/pm-jacron.rc
    RC_DAEMON	    = $PMSRC/pm-jadaemon.rc
    RC_DATE	    = $PMSRC/pm-jadate.rc
    RC_DATE1	    = $PMSRC/pm-jadate1.rc
    RC_DATE2	    = $PMSRC/pm-jadate2.rc
    RC_DATE3	    = $PMSRC/pm-jadate3.rc
    RC_DATE4	    = $PMSRC/pm-jadate4.rc
    RC_DATE5	    = $PMSRC/pm-jadate5.rc
    RC_DUP	    = $PMSRC/pm-jadup.rc
    RC_EMPTY	    = $PMSRC/pm-jaempty.rc
    RC_FROM	    = $PMSRC/pm-jafrom.rc
    RC_FWD	    = $PMSRC/pm-jafwd.rc
    RC_LIST	    = $PMSRC/pm-jalist.rc

    RC_MIME_DECODE  = $PMSRC/pm-jamime-decode.rc
    RC_MIME_KILL    = $PMSRC/pm-jamime-kill.rc
    RC_MIME_SAVE    = $PMSRC/pm-jamime-save.rc
    RC_MIME	    = "$PMSRC/pm-jamime.rc"

    RC_NETMIND	    = $PMSRC/pm-janetmind.rc
    RC_NSLOOKUP	    = $PMSRC/pm-janslookup.rc
    RC_ORIG	    = $PMSRC/pm-jaorig.rc
    RC_PING	    = $PMSRC/pm-japing.rc
    RC_POP3	    = $PMSRC/pm-japop3.rc
    RC_RANDF	    = $PMSRC/pm-jarandf.rc
    RC_SRV_CHECK    = $PMSRC/pm-jasrv-check.rc
    RC_SRV_DAEMON   = $PMSRC/pm-jasrv-daemon.rc
    RC_SRV_ERR	    = $PMSRC/pm-jasrv-err.rc
    RC_SRV_FROM	    = $PMSRC/pm-jasrv-from.rc
    RC_SRV_MSG	    = $PMSRC/pm-jasrv-msg.rc
    RC_SRV_MULTI    = $PMSRC/pm-jasrv-multi.rc
    RC_SRV_REQ	    = $PMSRC/pm-jasrv-req.rc
    RC_SRV_SEND	    = $PMSRC/pm-jasrv-send.rc
    RC_SRV	    = $PMSRC/pm-jasrv.rc
    RC_STORE	    = $PMSRC/pm-jastore.rc
    RC_SUBJECT	    = $PMSRC/pm-jasubject.rc
    RC_TIME	    = $PMSRC/pm-jatime.rc
    RC_UBE	    = $PMSRC/pm-jaube.rc
    RC_UBE1	    = $PMSRC/pm-jaube1.rc
    RC_VAC	    = $PMSRC/pm-javac.rc
    RC_VAR	    = $PMSRC/pm-javar.rc

}

:0 E
{
    LINEBUF = 1024	# So that line is not truncated.
    dummy   = "
****************************************************"*********************
        $id: PANIC: you do not have set the PMSRC variable to point
        to procmail recipe code directory. E.g $HOME/procmail/lib
****************************************************"*********************
"
}

dummy = "$id: end: variables defined."

# End of file pm-javar.rc
