sr2ses (Sat Oct 25 2014 01:31:01)

This program uploads files into a Content Management System running on a
relational database.

This can be Generic or a Proprietary like Tera, Prestige, DewarView or Sypress
system running on MySql, Oracle, Sybase, SqlServer, Mimer or ODBC-accessed
database.

On startup, it gets its default parameter file : FORMAT or the parameter file
stated in the DF header field. The latter is usually WIRE for wire traffic,
VWIRE, ZWIRE, BOX for mailbox, FORM for data formats traffic etc..

The parameter files are in tables/db for generic and Tera and tables/ses for
the 3 Atex systems

This Program then scans its input directory and mangles the files. Header
fields are stuffed into the database. The actual data contents are left in a
Queue prescribed by the contents of the EQ header field.

The EQ field is normally added to the file at the ipwheel-tables/sys/USERS
stage. Sometimes funny chrs such as Space or Slash are required which will of
course give weirdo results to other programs downstream from ipwheel and
upstream from this one. So a dot, '.', is used as an escape chr. Dot is
followed by an UPPERCASE chr or a '@' then octal 040 is subtracted from it.
Hence :
.@ = SPC
.N or .. = .
.O = /
.J = " etc

If the queue name is NOT in the EQ field, it can be replaced with any other
using the 'outque' parameter. eg:
outque:TOP/SU/nextLevel/EQ
For a file with an SU of 'AP' and an EQ of 'BIZ' will be put in the queue :
/fip/spool/top/ap/nextlevel/biz
or with a -o /wires input switch (see below)
/wires/top/ap/nextlevel/biz
Note that the whole queuename is forced lowercase.

As the text has already been cleaned up by IPXCHG, this program can add Fixed
and header information at the top and bottom of the file using the 'before:'
and 'after' parameters.

Incoming files are checked for FIP header fields :
DF: Format table file default: FORMAT
DM: send a unix mail msg to these Unix logons default: none

Files of the same name in a different queue are normally NOT overwritten - the
filename is altered depending on the 'dup:' keyword.

If 'dup:inc' then the filename is incremented : if the name is 8 chrs long, the
last chr is incremented; if less than 8 chrs, an 'a' is suffixed to the name.
This is the default.

If 'dup:$' then the filename is changed to a CCM-like extention of $01 etc.

It uses environment variables :
FIP_SES_defEQ default queue default: junk
FIP_SES_defSN default filename default: new.000
FIP_SES_LINE default line length for $L def: 64

The Translation parameter file has the syntax :
note for most parameters - passwords, table and column names - case is
sometimes important so keep uppercase upper

dbhost:(name of server)
or dbname:(name of server)
dbname:MimDewar
dbdatabase:(name of database)
dbdatabase:GNW
Use this ONLY for Sybase or MsSQLSVR or MySql where we need to chg database
after logging on
dbuser: (User logon)
dbuser:DEWAR
dbpwd: (user password)
dbpwd:dribbleOG
dbchrset: (Chrset name - mysql only)
dbchrset:latin1

dbtbl: (table name)
dbtbl:EDMASTER
Normally only one table can be inserted from the contents of
one file. However for multiple inserts in Generic, each table
can be specified (up to dbtbl99; dbtbl is the same as dbtbl1) :
dbtbl:HEADER
dbtbl2:HEADER
dbtbl3:SUBCATEGORY
dbtbl4:TEXT

Either allow-update-fiphdr: (FipHdr)
Test this fipseq for 'update' or 'delete' and update or delete the entry
eg allow-update-fiphdr:JU
This turns 'insert' lines (see below) into updates (or delete)
There MUST be at least one column set to 'key:' and the data MUST contain a
non-blank value or you will get an error!

Or update: (full SQL string in FipSeq) (eoln)
eg. update:UPDATE EDMASTER set UNO = 'NU' WHERE AUTHOR = 'NA' and FILENAME =
'NX'
Note that AUTHOR and FILENAME are normally the key
Only one 'update' line per parameter file is allowed.
Any 'insert' lines are ignored.

Or a number of 'insert' lines - each to fill a single column of the table :
insert: (DataBase column/fieldname plus attributes to fill in ) (eoln)
Syntax :
insert:(name) type:(char|int|long|date|date+NUMBER|text)
size:(length to pad out to - for char only)
maxsize:(max length - for char only)
printable:
default:(defaultstring)
nulldefault:
data:(FipSeq string)
fiphdr:yes/no
case:(upper|lower)
split:(max length of field)
key:
cmd:
multiple-no:
id:feed or id:cat (Tera only)
update: (yes/no)

- Use double quotes to embed spaces and tabs if necessary
- There are several fields which MUST be filled in - those for the primary key
for example.

The 'insert' subkeywords in more detail :
-- TYPE This can be CHAR, INT, FILENAME, TEXT, DATE or DATE+(number)
Normally these will all be CHAR except the dates and a single FILENAME
FILENAME is used to describe the filename to be left on disk.
DATE+(number) can be used for the PURGEDATE :
insert:PURGEDATE type:date+10
will create a Date that is 10 days in front of the current System Date
TEXT is used only for generic traffic and is the data of the file and is only
available for those databases which allow BLOB or TEXT data.
-- SIZE Fixed Length of the field - if longer, trim; if shorter, pad with
spaces.
-- MAXSIZE Maximum length of the field - if longer, trim; if shorter, leave as
is.
-- PRINTABLE Chrs must only be normal printable ascii : space, 0-9, A-Z, a-z
and normal punctuation
-- DEFAULT If there is no data for this field, use this default strng (in
FipSeq)
-- NULLDEFAULT not used in this version
-- DATA FipSeq string to insert (restricted to 99 chrs long)
-- CASE Force the contents upper or lower case
-- SPLIT If a field has a size of over 254 - LEAD is a good example - it is
normally split across LEAD, LEAD1, LEAD2 etc. Use 'split:254' to specify the
size of each (sub)record.
-- KEY One field should be flagged with an extra field 'key:'. When a record
is to be inserted but it has a duplicate key, this field is incremented. This
field is normally also flagged type:FILENAME.
** NOTE that for Duplicate Keys to be correctly handled, the (one) field you
want to be modified MUST be labelled 'key:'
-- ID For Tera only. id:cat or id:feed are valid
-- UPDATE (yes/no) Allow updates to this field ?
This is ONLY used if 'allow-updates-fiphdr' is non blank. It defaults to YES
-- FIPHDR (yes/no) For TEXT fields, add the fiphdr or not - default:no
-- CMD The string in the 'data:' subkeyword is actual an SQL command NOT pure
data.
eg : insert:EDNO cmd: data:"(Select MAX (EDNO) + 1 from STORIES)
or for Oracle dates using 'to_date'
insert:DATETIME cmd: data:"to_date (47HDHMHYHHHNHB47,
47DDMMYYYYHH24MISS47)"
-- MULTIPLE-NO: Where you want to insert multiple rows from a single file, with
different data for each row. you can
This is ONLY available for type Generic.
eg:
; these have no 'multiple-no' so are present for all inserts
insert:XTYPE type:char data:wire.SU
insert:XNAME type:char data:SN
insert:XDATE type:char data:"HD-HM-HY HH:HN:HB"
; first record is Priority - only output row is XP has data
test-for-multiple:1 XP
insert:SUBTYPE type:char data:Priority multiple-no:1
insert:XVALUE type:char data:XP multiple-no:1
; second record is Headline/Keyword
test-for-multiple:2 XK
insert:SUBTYPE type:char data:Headline multiple-no:2
insert:XVALUE type:char data:XK multiple-no:2
; data is signified as type:multidata
; third record is Headline/Keyword
; text type is the actual data
insert:SUBTYPE type:char data:Text multiple-no:3
insert:XVALUE type:text multiple-no:3

Other keywords are :
; comment
name: (fipseq for filename) (end of line)
format: (pc, mac, unix, raw) (eoln)
ext: (extention to the filename) (eoln)
number: (dec, oct or hex) (eoln)
before: (fipseq) (eoln)
after: (fipseq) (eoln)
filebefore: (filename) (eoln)
fileafter: (filename) (eoln)
dup: ($ or inc) (eoln)
supercede: (eoln)
takes: (Field Name:NewName) (eoln)
size: (size of filename) (eoln)
forcesize: (force the size of filename) (eoln)
abstract: (size of abstract) (eoln)
outque: (Fip Sequence to replace EQ) (eoln)
newEN: (New Hdr field to replace EN) (eoln)
newEP: (New Hdr field to replace EP) (eoln)
newES: For Tera id:Feed, the ES field if NOT FipHdr ES
newEC: For Tera id:Cat, the EC field if NOT FipHdr EC
newEI: (New Hdr field to replace EI) (eoln)
newEH: (New Hdr field to replace EH - Prestige only - subfolder) (eoln)
newEF: (New Hdr field to replace EF) (eoln)
newER: (New Hdr field to replace ER - pkg Raw filename) (eoln)
replace-hash: Chr to replace the hash in the ER field default is octal 201
owner: (new owner/logon for these files) (eoln)
script: (name of script plus any optional fipseq) (eoln)
respath:(path for resource fork) (eoln)
restype:(type of resource fork) (eoln)
resorig:(original template res fork) (eoln)
resfile: (type of file) (eoln)
archive: (name of archive in log/data) (eoln)
forcename: (upper/lower/nochg) (eoln)
forceque: (upper/lower/nochg) (eoln)
log: (log message) (eoln)
hdrchgchr: Exchange this chr from all Fip Hdr fields BEFORE
including the header field in Data to be inserted into Database fields.
Syntax:
hdrchgchr: (original chr) (replaced chr)
Note there are no spaces/tabs between the two chrs.
If no replacement is specified, a Space is used.
hdrchgchr:14047
hdrchgchr:Aa
All 256 chrs can be stripped.
hdrzap: zap all chrs between FROM to TO in the Data to be inserted into
Database fields
hdrzap:<:> Delete all <P>, <HTML> etc
Only one dirzap may be specified.
zap-fiphdr-field: (one or more comma-separated FipHdr fields)
Zap these FipHdr fields before processing
zap-fiphdr-field:JI,JW
Use this where you may be using FipHdr fields in Options etc
and want to make doubly sure there are no existing fields.
chkexists: (Full Path/file or queuename) (eoln)
chktimeout: (timeout in seconds) (eoln)
uno-select:
sypress-select: SQL string for the Sypress Sequence Number change
uno-update:
sypress-update: SQL string for the Sypress Sequence Number change
uno-ignore:
sypress-ignore: number which is used as a return code from uno-update which
means no further action is required - default is -999
prestige-default-queue: Default queue for Prestige - normally