This program takes a output file from MediaPlanner and builds a Fip_SMGL file
suitable for IPSETTER to convert to PostScript and proof/print/send

The Magic number of each data file (the first 4 bytes) is checked. All
PostScript and PostScript with Binary Header files are left 'as is' and the
filename noted. All other types are compared against our table of images
defined with the 'image' parameter.

If the image is on that list and there is a conversion script to convert it to
EPS then that is run and the EPS file dropped into the 'raw file path' -
usually spool/epsf.

Any not in that list are stripped.

The program first goes and gets its parameter file :
or  tables/setup/MEDIAPLANNER.FIP for Windows 2K, Windows 7, Windows 8

If the -OWNER flag is on, the program looks for a parameter file
setup/MEDIAPLANNER-(OwnerCode). This ownercode is the XX-YYY from the
MediaPlanner file. There can be a default for each Publication called
MEDIAPLANNER-XX-DEF where XX is the forst part of the owner code and DEF starts

Note all field numbers are from 1 onwards.

The format of this file is :
Often changed parameters are :
    ; comment line
    datapath    Main data path for the High Res data files
            default is /home/ds/lithos/highres

    map-drive   Map a Windows drive letter to a Unix Path
            default for all is the 'data-path'
            map-drive:(drive letter) (spaces/tab) (UnixPath)
            map-drive:K /home/ds/bigdisk/low-availability

    or for sites which prefer to use UNC/hostname mappings like \\bigserver\
    map-system  Map a Windows systemname to a Unix Path
            default for all is the 'data-path'
            map-system:(hostname) (spaces/tab) (UnixPath)
            map-system:ntsys /home/ds/bigdisk/low-availability
            eg \\Editserv\mediaplanner\Graphics\20060208\FA\5\60455975
                map-system:editserv //n2wdevfip1/d$/fip

        ** NOTE - please use '/' not '\' and please do NOT add a trailing '/',

    or for sites which prefer to use UNC paths or hostname/SHARE mappings like
\\bigserver\myShare (or using Samba or NFSshare)
    map-share   Map a Windows host/share to a Unix Path
            default for all is the 'data-path'
            map-share:(hostname)/(share) (spaces/tab) (UnixPath)
            map-share://nfssys/SambaAds /home/ds/bigdisk/low-availability

        ** NOTE that UNC path is ALWAYS stripped off - so if the data REALLY is on
the host, you need to specify it !
            map-share://adsplanning/classified  //adsplanning/classified

        ** NOTE if there are several shares on a system AND you need to specifiy that
host WITHOUT a share as well, the map-system should be specified last ie
        map-share:Ads/mpGRAPH   /data1/adsdata/graphs
        map-share:Ads/mpTEXT    /data1/adsdata/text
        map-system:Ads      /data/adsdata

        ** NOTE that later model Windows (7, 2008 etc) have much stricter
authentication. If you are using UNC paths or data on a remote drive you will
ALWAYS need to start the Fip service (in Services) with a Domain logon which
has the right permissions to read the files off the remote system.

    map-untracked: Path for the High Res data files for any untracked ads
    map-dash-untracked: Path for the data files for any untracked ads that have a
dash or hyphen in the name.
    map-untracked-by-adtype: (Ad type letter)   (Path)
        use this for finding elements that are organised by ad type in different
folders :
        eg  map-untracked-by-adtype:F   /ad4pag/%furniture
            map-untracked-by-adtype:S   /ad4pag/%headers
        if there is no map-untracked-by-adtype for that particular adtype, then the
plain 'map-untracked' is used (if specified)
    check-all-untracked-maps: Use this to check in each map-untracked folder in
case the element has been misplaced.
        default: no - just check that one folder.
    map-missing: Alternate Path for the High Res data files for any missing ads
        default: none

    image:(name)    magic:(magic)   script:(script)
            See below for handling non-epsf images

    adlist-filename: Path and filename of a file containing a list of ads used
            eg  adlist-filename: /fip/spool/2syb/\SN.\$z
    adlist-fiphdr: (FipSeq)
            Add a FipHdr to the Adlist - and supplement it with this as extra
            eg  adlist-fiphdr:#XX:from \SP\n
    adlist-format:  Format in FipSeq of each line for each ad in the adlist file
eg adlist-format: ADORA|UPDATE_ADLIST|\$d-\$m-\$e\$y
            default is \$d-\$m-\$e\$y \$h:\$n:\$b \PP \PS \ZD-\ZM-\ZZ \PN \PF\n
            Please remember to ad a NL at the end of the line with \n
    adlist-banner: Format for some FipSmgl defining the job banner (used for
Proofing only)
    adlist-file-format: same as adlist-format:
    adlist-rule-format: Format for RULES in the adlist
    adlist-area-format: Format for PAGEAREAS in the adlist
    adlist-miss-format: Format for Missing files the adlist
    adlist-meta-format: Format for MetaData in the adlist
    adlist-job-format:  Format for Job in the adlist - gets called when a JOB line
    adlist-folio-format: Format for defining the FipSmgl Folio file (in
customer/folio) in the adlist
            default - all ignored
    adlist-insert-after-folio: (Same as insert-after-folio)     default - ignored
    missing-ad-filename: Path and filename of a file containing a list of ads not
            eg  missing-ad-filename:/fip/data/missings/\$e\$y\$i\$d.\PP.miss
                This will append to a file containing all the missing ads
            If you want individual file, it is usually a goo idea to add FipSeq like
\$z.\$v somewhere to make the name unique
            eg  missing-ad-filename:/fip/spool/getads/FTP.\PP.\SN.\$u.\$z.\$v.fip
    missing-ad-format: Format in FipSeq of each line for each ad in the missing-ad
eg  missing-ad-format: \$d-\$m-\$e\$y \$h:\$n:\$b|\PP|\PS|\ZD-\ZM-\ZZ|\PN|\PF\n
            default is
                pub|section|pubdate|pageno|input path/filename|missing Ad
path/filename|reason|comment|unixtime|datetime NL
            Please remember to ad a NL at the end of the line with \n
    missing-ad-header: Format in FipSeq of a header line before any ads in the
missing-ad file
            default is \PP|\PS|\ZZ\ZM\ZG|\PN|!!ZAP!!|\\$u\n
    missing-ad-trailer: Format in FipSeq of a trailer line after all ads in the
missing-ad file
            This is ONLY output if there have been any missing ads
            default is none
    list-scale-errors: Each wrongly scaled ad to be logged in the missing-ad file
with PU contain "Scale Error"

    left-folio-x:   x posn of 0,0 point of Left folio
    left-folio-y:   y posn of 0,0 point of Left folio
    right-folio-x:  x posn of 0,0 point of Right folio
    right-folio-y:  y posn of 0,0 point of Right folio
    fudge-folio-y:  y posn of 0,0 point of both folios - fudged a bit more !
    roman-numerals: Upper|lower case        default is UPPER
    force-roman-numerals: yes/no
        Normally Roman numerals are created by MP and are flagged by the ROMAN key in
the FOLIO line and the 2 page numbers (orig in FipHdr PV and the alt in PQ)
        Use 'force-roman-numerals:yes' to replace anything from MediaPlanner and use
the Fip routines to grenerate new PV and PQ from whatever the Folio Page Number

    output-single-pages: Output each page as a separate file rather than one file
for all pages.

    ignore-ad-types: List of single letter ad-types that should be totally ignored
        Normal MediaPlanner ad types are :
            D - Display
            L - Lineage
            S - Section Header
            H - Header
            F - Filler
            P - AdSite
            X - eXtras such as WaterMarks
        So use with care ! Usually AdSites are NOT required - but are also rarely
    replace-colour-ads: Stub file to replace a Colour Ad
        This file name will be force uppercase and reside in tables/form/postscript
    opi-ad-types: List of single letter ad-types that will need to be OPIed rather
than the whole EPS included by 'ipsetter'.
        Normal MediaPlanner ad types are :
            D - Display
            L - Lineage
            S - Section Header
            H - Header
            F - Filler
            P - AdSite
            X - eXtras such as WaterMarks
        or  * - all types
        These force 'ipsetter' to call a stub file for the OPI in form/postscript
called 'MP-OPI-STUB-?' where ? is the (uppercase) ad type.
    resolve-opi-script: (script with parameters in FipSeq)
        Run this script for all OPI types (as flagged with the opi-ad-type)
        and include any hires in the output file and do NOT use the OPI
        call (nor use the MP-OPI-STUB file as described above)

    default-route:  name of default route   ie FipHdr field PR
    default-pubcode: ie FipHdr field PP
    default-section: ie FipHdr field PS
        Folio or furniture is ON or OFF unless overwritten by
        NOTE - These defaultS MUST be defined at the top of the parameter file if
used (or they will override any prestated parameters)

    dcs-plates: DCS Colour plates in order of output
        dcs-plates: Black%My_Green
        Use the '%' as a separator for the different Plate names.
        This will override the 'eps-comments..' parameters.
        NOTE - Black, if specified, should be the FIRST plate.
        Just to confuse, 'ipsetter' will output the plates in REVERSE
        order so that the first plate, which should be Black, will be
        the LAST plate output. This is so that any subsequent process
        can wait for the Black plate before processing.
    default-dcs-plate: Black
        If there is no colour(s) in the Ps Header of the ad, use this colour
        default is Black
        If present, this option forces a check of the PostScript
        Header of each file to check how many and which DCS plates
        are valid.  For 'ipsetter', the PostScript routine
        'wantDCSplate' must exist in the PSHDR or USER for this to work.
    fpo-plates: Colour Plates to check for in FPO order
        fpo-plates: Cyan%Magenta%Yellow%Black
        Use the '%' as a separator for the different Plate names.
        so colorFlag 1 is Cyan etc
        'check-dcs-plates' also needs to be specified.

    eps-comments-4colour: name of file in tables/form/postscript for
        adding to as comments in the PostScript header to denote a
        4 colour page. (As denoted by MP's 'COLOURPAGE 4' tag)
    eps-comments-spot: name of file in tables/form/postscript for
        adding to as comments in the PostScript header to denote a
        spot colour page. (As denoted by MP's 'COLOURPAGE 1' tag)
    eps-comments-backing: name of file in tables/form/postscript for
        adding to as comments in the PostScript header to denote a
        a pair of backing pages. (As denoted by MP's 'BACKING' tag)
    eps-comments-black: name of file in tables/form/postscript for
        adding to as comments in the PostScript header to denote a
        mono page. (As denoted by MP's 'COLOURPAGE 1' tag or no tag at all)

    extra-setpage: Extra information for the SETPAGE file   default:none
        Usually this is some FipSeq stuff (watch out - it is in FipSeq):
        extra-setpage:combie:QX DI|XK|AB,default\nfixed:BC \\$d.\\$m\n

        This option will enable/disable the feature if a page with a
        double-truck ad is followed immediately by the next subsequent
        page, they are paired automatically.  default: no
    double-truck-scaling: (same parameters as for force-scaling)
    dps-scaling: (same parameters as for force-scaling)
        Scale a double page spread (dps) or wrap - default: same as for all other ads
        this set the default - but normally it will be in the data (if not forced)
    allow-partial-pages: yes/no
        default is no
    route-partial-pages: (name of route)
        Only allow partial pages for this route
        Use the PostScript variable FIPmpcol for movement. If used,
        the variable MUST be defined in the PSHDR. FIPmpcol is finer
        than FIPcol as it also includes the x and y of the folio.
        default: no
    editorial-folder:(Path in FipSeq)
        Path to an editorial shape with predefined file name (see MP itself)
        Check for editorial on this page. Needs'editorial-folder' too. default is no
    editorial-scaling: (same parameters as for force-scaling)
        Scale editorial element- default: No scaling
    editorial-offset-y: X/Y offsets for Editorial pages to position correctly
compared to the AdArea
        Use this when the Editorial pages have a trim/bleed
        It is the offset from the bottom left hand corner of the editorial template
to the 0,0 of the Ad/text area

        Normally Folios are output if selected in the MediaPlanner output drop down.
        Use this to specify the name of a SHAPE on the page
        If the shape exists, a Folio is output and the NO/FOLIO line ignored.
        The ALT version will pull in a customer/folio of
        rather than the normal
        The name of the shape must NOT be one of our keywords - FOLIO, NOFOLIO,
        If using shapes to determine whether to add a folio (or an alt folio), use
these parameters to move full page elements where there is NO folio.

    route:(MP string)   (Output folder for 'ipsetter' to leave EPS file)
        Map a ROUTE from Mediaplanner to an actual folder. This tells
        'ipsetter' where to leave its output file
            route:rip3  /fip/spool/2rip3
            route:default   /ppdata/poll
        (note versions of ipsetter before 41f assumed the folder
        was under /fip/spool/)
    route-top:(MPstring)    (Text/FipSeq/Fip markup to add at the top of
                the data part of the file)
        route-top:rip3      <z: 100000 -100000 translate>\n
    route-fiphdr:(MPstring) (extra FipHdr fields to add to the file)
eg route-fiphdr:xrx_dc340 RR:<z :\376\376/PageSize [842 1191] \377\377
        Do/Do NOT stuff a folio on for this route.
        default: if a default folio has been specified, folio please.
    route-add-furniture: (MProute)
    route-no-furniture: (MProute)
        Do/Do NOT stuff any page furniture on for this route.
        default: if page furniture has been specified, draw it please.
    route-show-missing-ads: (MProute)
        For this route, show missing ads by a box and the Ad number.
    route-blank-ads: (MProute)
        For this route, white out the ad shape before printing.
        This layers the ad on top of the furniture rather than using
        the transparent feature which is default to level 2 rips.
    route-always-pair: (MProute)
        For this route, always pair and output doubles.
        The default is to do whatever the 'PAGEPAIR' check box was.
    route-never-pair: (MProute)
        For this route, ignore all pairings and output single pages.
        The default is to do whatever the 'PAGEPAIR' check box was.
    route-ignore-dcs: (MProute)
        If DCS is the default color method, ignore it for this path
        and, if colour, output composite.
        If there is a Template PostScript file in tables/form/postscript
        called (in uppercase) (Routename)_NO_DCS, it is included
        eg :    route-ignore-dcs:composite_typhoon
        will pull in a file called 'COMPOSITE_TYPHOON_NO_DCS'
    route-filename: (MProute) (output filename in FipSeq)
        Normally the filename of the output will be the same as the
        input plus a 4 digit pagenumber extension. This allows
        a different filename to be applied to a route.
        Note this goes into the 'setpage' file for ipsetter to
        interpret so you can use 'extra-setpage' to manipulate
        FipHdr fields if necessary.
        eg  route-filename:pdf  P\FN-\$d\$h.pdf
    route-round-robin-max:  (MProute)   (number)
        A FipHdr field, PH, is filled with a sequencial number from
        (normally) 1 to 2. This can be used with 'route-fiphdr' to
        round-robin. Use this to change the max to another number.

    route-left-page-offset-x:  (MProute) (x offset in points of whole page)
    route-left-page-offset-y:  (MProute) (y offset in points of whole page)
    route-right-page-offset-x: (MProute) (x offset in points of whole page)
    route-right-page-offset-y: (MProute) (y offset in points of whole page)
        For single pages, (ie NOT paired) move the whole page these offsets depending
        on whether the folio number means it is a right or left hand page.
            default is 0 for no offset for all of these.
        eg :    route-left-page-offset-x:pdf    -5
            route-right-page-offset-x:pdf   5.2
    There is also case where a single page can be offset differently.
    The syntax for this is :
        route-special-left-page-offset-x: (MProute) (PageNo),(offset)
        (plus similar lines for 'right' and 'y')
        eg  route-special-right-page-offset-x:pdf   24,-30
            route-special-right-page-offset-y:pdf   24,10
        Please remember to specify both X and Y as the default is, again, 0.
    route-extra-fiphdr-file: Name of a file containing extra FipHdrs for including
with each file thru.
            default: none
        eg:  route-extra-fiphdr-file:proofer
        which could contain lines like :
        Allow routes to be route:plate1 plate2 etc
        Specify as route:plate*

Folio files can be setup for :
    - all publications and all sections
    - any variation of Owner Code, Pub Code and Section - any one of which can be
left as 'DEF' to flag default.
    - L for Left and R for Right (or from version 04r, PAGE1)
    - .eps files for standing items and .fip files containing FipMarkup for
These files are held in /fip/customer/folios.
The order of looking is (assuming a Left hand page) :
    1. OO-PPP-SSS-L.fip
    2. OO-PPP-XXX-L.fip
    3. OO-PPP-DEF-L.fip
    4. OO-DEF-SSS-L.fip
    5. OO-DEF-XXX-L.fip
    6. OO-DEF-DEF-L.fip
    7. DEF-DEF-L.fip

if the PAGE1 flag is on, L can be the string PAGE1.
Or if ALT - alternative shapes is on, the syntax is

Or - you can use your own naming convention with the 'folio-name:' keyword
    gives just (SECTION)-(L/R).fip

For Page Pairing, each publication should have a relevant parameter file
containing the following options which refer only to that pub.
If the two pages are for different sections, only the left-hand page is
    pp-furniture-4col: Optional EPS file(s) containing crop/register marks,
            colour bars etc. This is layed down BEFORE any other
            items.  The full pathname should be specified. There is
            no default. If the 4col or spot variants are not
            specified, the main is used.
            These files are in /tables/form/postscript
    pp-page-y-high: Offset in points for top left position of the lefthand
            page where the left page is a HIGHER folio number than
            the right.
    pp-page-y-low:  Offset in points for top left position of the lefthand
            page where the left page is a LOWER folio number than
            the right.
    pp-gutter:  Gutter width in points      default: 100.0 pts
    pp-max-creep:   Maximum creep to add to gutter  default: 0 pts
            IPXMP will calculate the fraction of this number as a
            ratio of the two folio numbers (taking into account
            pp-max-book-size) where Page 1 (or start of book) will
            have the maximum added and two folios with consequetive
            numbers will have zero added.
    pp-max-book-size: Where publications are output in 16/32/64 page
            sections or books and this affects the creep, this
            defines the number of pages in such a book.
            default is the sum of the two folios minus 1.
    guard-pubcode:  PubCode and Routing for Printer guards
        syntax  guard-pubcode:(pub or ownercode)    (optional route)
        The maximum edition size is 1000 pages
        There can be up to 40 pubcode and pubcode/routes for guards.
    guard-file: Path and name for the file containing all the guards
        The syntax for the file is :
            ; comment lines start with ANY no-alpha chr
                ------ all leading spaces are ignored
            (PUBCODE-SIZE) (spc) (left-page-no) (spc) (right--no)
        or  (OWNER-PUBCODE-SIZE) (spc) (left-no) (spc) (right-no)
        Where SIZE is the EditionSize or IssueSize or a '*' meaning any EditionSize
        Either left or right-page-no may be zero to signify a guard page
        The maximum file size for the guard-file is 64k.
        eg  ---- extracted 12 Aug 2002
            HL-HL-40    18  23
            HL-HL-40    22  19
            HL-HL-40    20  0
            HL-HL-40    0   21
Parameters (PDF) for ippdfglue - using mechanicals for W* lookups

; Bleed area
combie:T3   W6|WX|WC
combie:T4   W7|WY|WD
; Page Area = Ad Area plus Folio
combie:T7   WX|WC
combie:T8   WY|WD

; PDF using adlist
; with care - this adds to the whole file - which might be several pages

; diff elements

; sort out the areas

; Use meta to start the PAGE and add FipHdr at top

; Folio file in customer/folios plus ExtraFipHdr stuff - plus some more FIPHDR

Seldom changed parameters are :
    first-x     field number of the x-coordinate
            default is 6
            eg  first-x:5
    first-y     field number of the y-coordinate
            default is 5
    second-x    field number of the x-coordinate
            default is 8
    second-y    field number of the y-coordinate
            default is 7
    type        Field number of the type or -1 if none!
            default is -1 for none
    path        Field number of the full path and filename.
            default is 1
    page-no     Field number of the page number
            default is 2
    page-depth  Field number of the page depth
            used only for the bounding box of the whole document
            default is 3
    page-width  Field number of the page width
            used only for the bounding box of the whole document
            default is 4
    ad-type     Field number for the ad type
            default is 9
    ad-colour   Field number for the no of colours for this ad
            default is 10
    adora-name  Field number for the material-id name from Adora
            default is 11
    comment-fld Field number for the Comments for missing-ads
            default is 12
    scaling     Field number for Scaling
            default is 13
    double-truck    Field number for Double Truck
            default is 14
    irregular-shapes Field number for Irregular Shapes (not used)
            default is 15
    field-sep   Field Separator
            default is a tab
    extra-fiphdr    Extra FipHdr information as a FipSeq String
            This is processed at the start of the Page - so NO information from the page
is available
            default: none
    extra-fiphdr-after  Extra FipHdr information as a FipSeq String
            This is processed just before a FOLIO - so ALL pub, routing info is
            default: none
    extra-fiphdr-file: Name of a file containing extra FipHdrs for including with
each file thru.
            This is processed at the start of the Page - so no information from the page
is available
            default: none
        eg:  extra-fiphdr-file:/fip/customer/supplements/NAME-OF-SUPPLEMENT
        which could contain lines like :
    inline-extra-fiphdr Extra FipHdr information inserted as inline markup for
ipsetter to use (43z8+)
            This is processed just before a FOLIO - so ALL pub, routing info is
            default: none

    output-name Rename output file in FipSeq
            Normally the output filename (FipHdr SN) is the
            same as the input file.
            eg  output-name:20.\SN
        Normally the folio is ignored for page one
        If a Page 1 folio is required for a single PageDefn/Section,
        add 'allow-page-one-folio:check' to the parameter file
        and create a folio file in /fip/customer/folios called
        where PUBCODE and SECTION are as for all the other folios.
        Comma or space separated list of up to 30 page numbers which need no folios.
        Use negetive numbers to specify pages from the BACK of the book.
        where -1 is the back page, -2 the inside back etc. This only
        works where there is an ISSUESIZE (ie a late version of MP).
        Default is page 1 only unless 'allow-page-one-folio'

        eg  ; for an issuesize of 32, folios would NOT appear on 1,2,3,31,32
    strip-folios-on-bleed-ads: (yes/no)
        If specified, pages with the FIRST Ad being a bleed upwards will strip the
        default add the folio on all pages required.
    bleed-pass-thru: FipMarkup to flag pages where the folio has been stripped
        eg  bleed-pass-thru:<z: noteBleed>
        default: none

        Any Spot colour, regardless of what is specified, will be put on the Spot
        default - no

    missing-ad-comment: Replacement text/FipSeq for when the ad is missing
        default is just the name:   missing-ad-comment:\PA
        To use the comment field    missing-ad-comment:\PA - \PY

    default-page-width: in points - needed for the Folio.

    force-bbox-y: force the bounding box to be these values
    force-bbox-pair-x: ditto for a pair - force the bounding box to be these
    ignore-bbox-y: ignore the bounding box calculations and let 'ipsetter'
            calculate them

    always-pair:    Always attempt to Pair pages - use this with printer's guards
    ignore-backing: Always Ignore backing pages option if selected
    ignore-pairing: Always ignore page pairing option if selected

        If the queue/folder name of the data file includes this string
        then the Bounding Box of the EPSF is checked and, if different
        to the dimension given by MediaPlanner, the Y movement is
        compensated for.    default - ignore
        eg compensate-bb-path:Edit
            will check the Bounding Box for all files with 'Edit'
            in their path somewhere (but NOT in the filename)

        Script to run after the folio which creates a tmp file (Held in FipHdr \QX)
        containing more Fip Markup to include for a folio or page.
        EG it could be a script calling variable data from a database for that pub.
            post-folio-script:/fip/bin/ipadorachk -V 3 -H -h 'PC:\PC#PN:\PN' -O \QX
        In this example, adorachk is called with the ClassFolio (PC) and PageNumber
        Script to run after each page - possibly for tracking purposes
        Script to run after each file - possibly for tracking purposes
        force the scaling of each ad to fill the space alloted
        default: ignore -  to used the MediaPlanner flag for each ad.
    minimum-scale: (percentage between 0 and 100)
        do NOT scale if the difference is less than this percentage
        (this only takes effect if the scaling option is set of course)
        default is 0% for no checking
    maximum-scale: (percentage between 0 and 100)
        scale ONLY if the difference is less than this percentage
        (this only takes effect if the scaling option is set of course)
        default is 0% for no checking
    scale-error-folder: Any file with an which is outside either the min or max
scale can be placed here rather than sent.
        An output file with scale errors is NOT sent if input switch -x (do NOT
output if there are missing ads) or -X is set.

    zap-index:yes Zap the ClassNumber from SECTIONAME and CLASSFOLIO
        default - no
    reset-color: FipSeq string to add before Page, Furniture and Folio
    reset-colour: FipSeq string to add before Page, Furniture and Folio
        reset-colour:\n<z: FipColorReset>\n
        there is no default
    check-composite-colour: (no/yes)
        This ignores the COLOURPAGE setting from MediaPlanner (set when a certain
plan is chosen) and works out whether the page is colour or mono from the
BOOKING (ie does NOT drip down each file checking what it really is).
        default is NO
        See also the -4 input switch which sets the default to YES

    use-alt-dates:  use FipHdr T* rather than Z* for dates
    insert-after-folio:FipSeq string to add after the Folio and before ads
        insert-after-folio:\n<z: .75 .75 scale>\n
        there is no default
    insert-after-page:FipSeq string to add after ALL ads and Folio for each page
        insert-after-page:\n<z: FipCropMarks>\n
        there is no default
    insert-after-all:FipSeq string to add after ALL ads and Folio for each
incoming file
        insert-after-all:\n<z: FipCropMarks>\n
        there is no default

        Add the Spread type (ODD or EVEN) as a PostScript variable. This adds either
        /FIP-X-SpreadTypeE where { pop (MEDI) FIP-X-SpreadTypeE copy pop }if
    or  /FIP-X-SpreadTypeO where { pop (MEDI) FIP-X-SpreadTypeO copy pop }if

    include-pubcode-file: 2nd parameter file which include ANY of the above
        parameters which are specific to that owner-pubcode.
        (except 'include-pubcode-file' of course!)
        This enables a single main parameter file for all pubcodes
        and a couple of include files where there are alterations/additions.
        Note the Owner-PubCode is AUTOMATICALLY added to the filename
            so :    'include-pubcode-file:data-range'
            and an Owner-Pubcode of ES-ES
        looks for a file called 'DATE-RANGE-ES-ES'
            (or 'DATE-RANGE-ES-ES.fip' for Win2K)
        There can be 2 include files. If the Owner code version is not found, then a
default with NO owner code can be used.

    log-line: Custom Message line for logging (in FipSeq)
        default is ": \PR : \PP \PS \PN \ZG-\ZT-\ZZ"
        for Route Pub Section PageNo PubDate

    default-font:(name of a font in the tables/form/SETTER file)
        default is 'times'

    folio-name:(FipSeq of name of folio to use))
        the '-L.fip' or -R.fip is suffixed automatically
        default is folio-name:\PP-\PS
            to give (PUB)-(SECTION)-(L/R).fip
        eq folio-name:\PS
            gives just (SECTION)-(L/R).fip

    new-folio:(FipSeq for a field containing the Folio number to use)
        default is \FP

    furniture-scaling: (same parameters as for force-scaling)
        Scale EPS furniture elements - default: No scaling
    furniture-offset-y: X/Y offsets for EPS furniture to position correctly
compared to the AdArea
        Use this when the Furniture pages have a trim/bleed .
        It is the offset from the bottom left hand corner of the editorial template
to the 0,0 of the Ad/text area

    shrink-ad: (yes/no/horiz/vert)

    replace-ad:(Name of Shape)  (replacement markup)
        If a shape has a name that starts with this string, then replace the shape
with the replacement markup - see program doc for 'ipsetter' forthe markup.
        The name of the snape is put into FipHdr PA if it needs to be used.
        replace-ad:continued    <f=DINBOLD><p:20>\PA
        If the shape is called "Continued on Page 33", then this text is put in the
ad hole in 20pt DIN-Bold
        If there is a space in the (name), pls enclose the whole in double quotes
            replace-ad:"Continued on" ....markup.....

    fiphdr-colour-bckg: (2 letter FipHdr field)
    fiphdr-colour-text:: (2 letter FipHdr field)
        Add two Fiphdr fields which will hold the colour settings for Page-Background
or Folio-Text
        There is no default FipHdr fields assigned
        If they are specified, then the 'bckg' defaults to white and 'text' to black.

FipHdr fields created are:
    PP  Pubcode
    PB  Pubcode for single pages but for DPS, this is (PubCode)_DPS
    PS  Section.
    PE  Name of Section (optional) (versions 03t onwards)
    PR  Routing code from MediaPlanner (optional)
    FQ  Folder for routing from the routing match table.
    PN  PageNumber (may be offset)
    FP  PageNumber (same as PN)
    PV  PageNumber or Roman Numeral Page Number if flagged.
    PO  PageNumber - original, on the MP plan, no offsets
    PQ  PageNumber - alternative or section number (defaults to the same as PV)
    PW  L or R for Left or Right page
    PC  Class Folio name
    PJ  Jobname (from 006y onwards)
    PF  FullPathName of the Ad (used for Adlist or MissingAd files only)
    PA  Name of the Ad generally used in the missing Ad comment
    PL  FullPathName of the Original Ad (same as PF except when the ad has been
converted using 'image')
    PY  Ad comment for Missing Ads
    PK  Type of entry for adlist    FILE, RULE, ADAREA, IMAGEAREA (inc Folio)
    PU  Reason for line in Missing Ads file - missing ad, scaling error
    PT  Type of the Ad
    PX  No Of Colours specified for the page - 1,2,3 or 4
    PZ  No of Copies required (default 1)
    PH  RoundRobin Number - a sequence number from 1 to (max)
        where max defaults to 2 (see route-round-robin-max above)
    PG  PART or FULL for Partial Page (or Normal, Full Page)
    PD  Pair flag
        PD:single   Page is single
        PD:pairprinters Page is a Printer Pair
        PD:pairbacking  Page is a Backing Pair
        PD:pairdbltruck Page is a DoubleTrucked Pair
        The same string is also added as a comment as the last line
        of the data eg.  <n: FipPageType-pairbacking>
    PI  ODD or EVEN or BOTH (for pairs)

    SX  Original input file name (ie name only not folder).
    QI  input folder
    QO  output folder
    QX  temporary FipHdr to hold the Tmp file name for post-folio-script:

    PM  No of ads missing (available at the end of page or file only)
    P1,P2,P3,P4 X,Y of bottom left, width and depth of ad
    P5,P6   Width and Depth of the (Mediaplanner) Ad Area (these two are changeable
with fiphdr-mp-xy:)
    P7  Scaling flag    - blank for none, H-horizontal only, V-vertical only, B-both
    Z*  all the date fields for the PUBDATE.
        (These can be T* if you set parameter 'use-alt-dates:')
            ZD  - 1 or 2 digit day of month
            ZG  - 2 digit day of month (with leading zero)
            ZM  - 2 digit month
            ZY  - 2 digit Year  92
            ZZ  - 4 digit Year  1992
            ZW  - Day of week as in Monday, Tuesday etc
            ZS  - 3 chr Day of week as in Mon, Tue etc
            ZN  - Month as in January, February
            ZT  - 3 chr Month as in Jan, Feb, Mar etc
            ZJ  - Julian day of year
            ZH  - Hour 00-23
            ZI  - Hour 00-12
            ZF  - Minute 00-59
            ZE  - Second 00-59
            ZX  - 8 digit time since 1-Jan-1970 in Seconds
            ZU  - 1st, 2nd, 3rd, 24th for the day of the month
            ZA,ZB,ZK - The three different week-of-year numbers (ZA is 0-53 starting
Sunday, ZB is 0-53 starting Monday, ZK is ISO8601 1-53 where the first week has
4 or more days starting Monday!)
            ZC  - Dow
            ZP  - AM/PM
        Note that actual Day and Month names depend on your LOCALE

 Note that ONLY PP - owner/pub code - is usable when the parameter file is read
in. So any conditional FipSeq can only be on PP.
 eg to force the BoundingBox Y to be different (1060 pts v 1117 pts as default)
for these two publications :

; V0,1 QY for force-bboxy - different y size, 1117 except 2HE and 2HB which
should be 57 less
; F1-F4 for Folios offsets
option:V0   PP,,,,NL-2HB
option:V1   PP,,,,NL-2HE
fixed:V2    \V01060\$o\V11060\$o
combie:QY   V2,1117

EPSF variables

FIPmpX and FIPmpY are stuffed at the top of the data part and contain the
MediaPlanner Page width and depth in decipoints.
eg  <z: /FIPmpX 5939 def /FIPmpY 7937 def >

From version 04w, PostScript variables used are :
For each included file :
    FipBB1 - FipBB4 Bounding Box
    FipCC1 - FipCC4 Crop Box as defined by MediaPlanner
    FipCropX Y  Crop width and depth
    FipMPscaleX Y   Scale values
    FIPmpType   'L' or 'R' for page type
    FIPmpFolioX Y   Folio offset (in decipoints)
    FIPmpPageX Y    Page offset (from offset-page-x or route-left-page-offset-x) (in
    FIPmpX Y    MP page width and depth (in decipoints)

Converting NON-eps files to PostScript
The syntax of the 'image' keyword is
    image: (name)   magic:(1st 4 chrs of file)  script: (script to run to convert)

- Use double quotes to keep the spaces
- The script MUST generate a file in spool/epsf with the same filename as the
input with an Extra extension of '.eps'.

examples of using Image Alchemy to convert TIFF files :
image:tiffII    magic:"II*\000" script:"/usr/forum/bin/alchemy \QN \QN.eps -Q -o
-e --."
image:tiffMM    magic:"MM\000*" script:"/usr/forum/bin/alchemy \QN \QN.eps -Q -o
-e --."
image:pdf   magic:%PDF  script:"/usr/local/bin/pdf2ps \QN \QN.eps"

- Note that even more FipHdr fields are available ONLY for the script :
    QN - Full Path and Filename of the input file to be converted
    QR - Path or queue for converted files and files to convert
        which defaults to /fip/spool/epsf
    SN - name of the input file to the program !
    QI - name of the input  queue

Other Notes
Although the default measurements are in points, millimetres were introduced in
version 03a. All postional parameters in the MEDIAPLANNER file can be defained
as millimetres by using 'm' or 'mm' after the amount:
    eg  pp-gutter: 84.33mm
        pp-max-creep: 9mm

From version 01j, the default is force 'ipsetter' to put a FipHdr on its output
file. Use
route-fiphdr:(route)    #FQ:/ppdata/poll#FnoFIPHDR:
to force setter to leave its file in a folder with NO FipHdr - for Distiller
for example.

-------- Example of a MP-OPI-STUB-? file -------
 This is a template with FipSeq for the FipVariables for size and position. The
file is in fip/tables/postscript and the '?' is the ad type. (see the doc for
ipsetter for the actual FipHdr fields)

%%BeginObject: FipOpi \$V
%ALDImageFileName: /\FJ
%ALDImageCropRect: \F1 \F2 \F3 \F4
%ALDImagePosition: \F5 \F6 \F5 \F8 \F7 \F8 \F7 \F6
%%BeginObject: image \$V
\F5 \F6 \F5 \F8 \F7 \F8 \F7 \F6 ALDImagePosition
(\FJ) \F5 \F6 ALDImageFileName

Input parameters are (all optional) :
    -1 : path/filename for a single shot and stop   default: spooled
        The input file is NOT deleted in this case
    -4 : always check the booking for colours   default: no
        see check-composite-colour: above
    -a : single done file           default: increment filename
        and move all existing to a date key
    -C : do NOT check for the ID on the first line  default: do
        The first line should be 'ID (tab) FingerPost'
    -d : done queue for incoming        default: none
    -D : disable/ignore any DCS processing  default: use DCS if specified
        This overrules the parameters
    -E : extension for parameter file   defalt: none
        This ONLY applies to -OWNER
        It is forced uppercase.
        eg -E .canon and Owner of XE_NOW -> file is MEDIAPLANNER-XE-NOW.CANON
    -f : force name of EPSF file LOWERcase  default: leave as is
    -F : force name of EPSF file UPPERcase  default: leave as is
    -g : default route for PartPages    default: none
        This can be overridden by the route-part-pages parameter
    -h : Hires path     default:/home/ds/lithos/highres
    -i : input queue to scan        default: /home/ds/interfaces/mdp2pag
    -l : do NOT log incoming files      default: log
    -M : use the FIPmpcol postscript routine to force Folio positioning. def: no
    -o : output path to leave       default: spool/2set
    -OWNER : look first for a parameter file
        MEDIAPLANNER-(OWNER-PUBCODE)    default: use def param file
    -p : single done file           default: increment filename
        and delete older versions
    -PS or -PDF force copy flow to PS or PDF    default: PS
    -Q : do NOT error if the OWNER parameter file is missing. default: error
         In either case, the default parameter file is used in its place
    -r : raw file path          default: spool/epsf
    -S : disable/ignore any SplitPlates default: split
        This is normally used for MS PhotoAds in DCS
    -T : name of the folder in /fip/customer holding
        the folios          default: folios
    -V : drive letter (WINNT only) if not startup drive
    -w : file wait interval         default: 5 secs
    -x : do NOT output if there are missing ads     default: normal output
    -X : do NOT output anything - just check and log    default: normal output
    -Y : quiet mode - do NOT report in the Fip Log ALL,
        if any ad is missing.       default: do
    -z : name of parameter file     default: MEDIAPLANNER
    -Z : name of the folder in /fip/tables holding
        the parameter files     default: setup
    -v : print version no and exit

Version Control
;7c45   ;a-b 4sep07 added fiphdr-mp-xy
    ;c1-3 10jan08 added folio-name:(FipSeq) ;1 mods to replicate missing 7d ;2
allow MS-DEF as Ownercode
    ;c4 19jan10 P5/P6 now hold width and depth in written FipHdr (ie not just for
each AD)
    ;c5-8 10mar10 added output-single-pages
        ;7-14 adlist bugette fix and always produce adlist even if no ads and added
adlistFH and -PDF/-PS
        ;15-16 22aug11 added fiphdr-colour-bckg and fiphdr-colour-text ;16 6sep11
added P7 as Scale
        ;17-20 22mar12 added JOB-folder name and block no PLUS 2nd foldername
        ;21 26sep12 bug with DPS scaling - disney wark ;22 added log of adlist name
        ;24-25 14jan13 do not zap fiphdr until after extraFH has been generated and
added route--folio:never and always
        ;26 18feb13 added adlist-banner
        ;27 19jul13 redid include-file to be processed immediately rather than after
the main file has been read
        ;28-30 25jul13 added adlist-insert-after-folio/page/all and
extra-fiphdr-after plus missingFont for missing-ad-box
        ;31-34 21aug13 added ignore-ad-types ; 32 auto add .jpg and .pdf if -PDF ;34
chasing bugette in replace
        ;35-36 27mar14 added inline-extra-fiphdr and force-roman-numerals:yes
        ;37-39 11apr14 allow map-share to nothing (ie just strip the UNC hostname and
        ;40-44 outputSingle bugette and fudge for dratted vc2005 datebug ;42-44 DPS
PDF adlist - do not output 2nd page + PB:
        ;45 11aug16 woops bug with PART pages-FH:PSHDR.. gets clobbered (plus cleanup
for _64)
;006z5  14dec05 shrink_ad added
    ;b-d 25apr06 added check-for-folio-shape and check-for-alt-folio-shape
        and no-folio-shape-x/y
    ;e-h 11may06 added replace-ad for continuedon/from
    ;i-k 25jun06 added allow-route-wilds:Z7 and made PartPages higher priority to
        ** chg for PartPages : must have 'allow-part-pages' or 'route-part-pages'
    ;l-n 12jul06 added missing-ad-trailer and if no PubDate, use the Folio date
    ;o 24aug06 allow converted files to be scaled too
    ;p-r 13nov06 resolve page offsets at run time not param file read and allow
DPS for check-colour
    ;s 03jan07 added ZK for the ISO Week-of-year (not for WINNT!)
    ;t-x 20jan07 added bleed-pass-thru ;u for short conversion ;x for default-font
    ;y-z5 28apr07 JOB and alternate page numbers (z2 - move route-fiphdr to
output-page as we need PP/PS)
        - z5 for reset missings total on FILE end not PAGE end
;005z   09mar04 added insert-after-all
    ;a-d 18mar05 added FIPmpPageX/Y as PSC variables
    ;e-g 19apr05 added missing-ad-filename and m-a-format and -x -X and -1
    ;h-j 23apr05 added log-line and all variables now FipSeq and bleed bug
    ;k-l 29apr05 added Editorial/Noeditorial and end-of-file
    ;m-o 16may05 small mod for nfs and 'replace=colour-ads' and P1-P4 for
    ;p-q 02jun05 added minimum-scale, plan PN and alpha PN to folios and DPS
record type.
    ;r 14jun05 added maximum-scale and scale-error-folder
    ;s 20jun05 added dps-scaling:no/yes - todo DPS is PLANno NOT FolioNo (which
could be offset)
    ;t 05jul05 added map-untracked-by-adtype
    ;u 08jul05 added scale-error-format for logging scale errors
    ;v-w5 10jul05 added map-dash-untracked etc
    ;x-y 02nov05 added PW for L or R (left or right) and check-composite-colour
    ;z 10dec05 added furniture-offset-x/y furniture-scaling
;004z   23jan03 added zap-index:
    ;b 07feb03 added fpo-plates and reset-colour
    ;c 10feb03 woops - remember a default - black for example
    ;d 20feb03 zap rest of fiphdr on new folio/nofolio
    ;e-f 15apr03 have include files for each PUB - include-pubcode-file
    ;g 11jun03 allow no splitplates if composite
    ;h 11aug03 added PI for ODD or EVEN or BOTH
    ;i 18aug03 added insert-after-folio: and force-scaling:
    ;j 11nov03 added datadrv for Windows
    ;k-p 02dec03 added eps-comments-black
    ;q 16jun04 Allow %%CMYKCustomColors: (C0M1000Y1000K0) for colour
    ;r 28jul04 added PAGE1 folio for allow-page-one-folio:
    ;s 17nov04 added -Z setup queue and -T folios
        and incoming file with FipHdr
    ;t 08dec04 added -D and -P to disable DCS and Splits
    ;u 15dec04 added -M - showMPcol
    ;v-w 22dec04 added -h hiresque and FipBB
    ;y 22feb05 made all pp-* FipSeq for The Guardian (esp pp-gutter)
    ;z 28feb05 added strip-folios-on-bleed-ads:yes/no
;003zi  14jun01 added route-round-robin-max
    ;a 27jun01 finally allowed 'mm' as paras - STARTED
    ;b/c 12jul01 pages-with-no-folios can be neg for end-of-book
    ;d 07aug01 added Inches too
    ;e 20aug01 bugette in guards.. and fixed no-folios
    ;f 16jan02 added NOFOLIO plus redid offsets plus FOLIO in guards
    ;g 05apr02 added offsets for spec-left and spec-right
    ;h/i 10apr02 added maxColourPage fudge
    ;j 10jul02 added map-system and map-share
    ;k 23jul02 added -Q quiet if Owner Parameter file missing
    ;l 03oct02 added map-untracked
    ;m/n/o 07oct02 added Scaling of ads and PartPages
    ;p/r/s 28oct02 added Splitting of DCS ads with %%FipSplitPlates
            - scaling was the wrong way around
    ;t/u 04nov02 added NameOFSection as extra FipHdr PE
    ;v 19nov02 added /FIPmpcol {} def, /FipMPfoliosX,Y and
    ;w/x 20nov02 BUG - max pages upped from 100 to 2000 pages.
    ;y 27nov02 added show-mpcol and allow-dbl-trucks
    Note that the line  "/FIPmpcol {} def" must be added to the PSHDR file
    ;z/zi 13dec02 added PD for single/pair type - in the FILENAME

(copyright) 2017 and previous years FingerPost Ltd.