(please also refer to MOS documentation at

This program sits on the normal MOS inbound port (the Hi Port) - port 10541 -
and pretends to be a fully functional MOS server/deamon.
    - MOS Lower Port (10540) - Media Object Metadata
    - MOS Upper Port (10541) - Running Order

(Note the defaults :
    - 10541 is the port the MOS will accept connections from the NCS.
    - 10540 is the port the NCS will accept connections from MOS devices.

It allows ALL mos traffic for a server to be sucked in and treated like an
incoming data stream like a wire service.

Normally 'ipmos' will sit on the output folder of 'moswire' and rip apart the
data - splitting into runningOrders, stories etc

If you need outgoings, use 'ipbdcast' or 'ipprint' and point it at the NCS
(newsroom computer server) on port 10540 (or 10541)

-- Terminology
Media Object Server (MOS) communications protocol is used to pass data between
Newsroom Computer Systems (NCS) and Media Object Servers (MOS) such as Video
Servers, Audio Servers, Still Stores, and Character Generators.

The parameter file has the following options :
    ; comment
    default-mos-id: id of this receiver         default: same as the -n
        this is only used if there is NO mosID tag in the incoming data
    output-folder: (folder name)    (no number is the same as 1)
    output-folder1: (folder name)
    output-folder9: (folder name)
        if the folder does NOT start with a '/', it is assumed to be
        Note these override the default and '-o' input switch..
    heartbeat-folder: (folder name)             default: put in same folder
        add a different folder for heartbeats and ignore all the copies
    log-heartbeats: (yes/no)
        do/do NOT log heartbeats in the Fip Log     default: do NOT
        normally only timeouts are reported
    mos-ack-template: name of the ACK template in tables wire if NOT (SU).ACK
    mos-heartbeat-template: name of the HBT template in tables wire if NOT
    heartbeat-timeout: (seconds)                default: 85 secs
        send heartbeat token if no traffic within this period
    max-timeout: (seconds) (seconds)            default: 90 secs
        cut the connection if no traffic within this period
    default-encoding: utf8/ucs2 or utf16            default: match incoming
        use this where moswire initiates the connection
    hash-in-fiphdr: (FipSeq chr)            default:\035
        A hash/pound (#) in a FipHdr field is mapped to this chr
        Normally hashes are end-of-field in a FipHdr. So it needs to be mapped to
something else and we changed it here on outbound.
    extra-fiphdr: (FipSeq strings of FipHdr into to add)

    mos-environment: (2 letter FipHdr)
        This is the FipHdr field which holds the environment eg enps_live or
        If the -E input switch is on, then whatever is in that will overwrite any
metadata in the file with the same FH.
        It is used to separate the different feeds from different environments
(mainly in ipmos)

        Send a single Mos request on connection (default is nothing)
        The value is the ext of a parameter file in tables/wire/MOSWIRE.(value)

Notes ----
1. Currently, moswire handles these MOS Profiles/actions :
ALL Profile 0 – Basic Communications
    heartbeat reqMachInfo listMachInfo
ALL Profile 1 – Basic Object Based Workflow
    mosAck mosObj mosReqObj mosReqAll mosListAll
ALL Profile 2 – Basic Running Order/Content List Workflow
    “roConstruction” family of messages
    roAck roCreate roReplace roDelete roReq roList roMetadataReplace roDelete
roElementStat roElementAction roReadyToAir
    Included only for backwards compatibility: (<roElementAction> replaces these)
    roStoryAppend roStoryInsert roStoryReplace roStoryMove roStoryMoveMultiple
roStorySwap roStoryDelete roItemInsert roItemReplace roItemMoveMultiple
    plus roStat roItemStat
NONE    Profile 3 – Advanced Object Based Workflow
    mosObjCreate mosItemReplace
    mosReqObjList family of messages
        mosReqSearchableSchema mosListSearchableSchema mosReqObjList mosObjList
PARTIAL Profile 4 – Advanced RO/Content List Workflow
    but not roReqAll roListAll
NONE    Profile 5 – Item Control
    roItemCue roCtrl
ALL Profile 6 – MOS Redirection
NONE    Profile 7 – MOS RO/Content List Modification

2. MOS level 6 - Fully Qualified MOS ID

Profile 6 does not include any additional MOS messages. However, it does
require that all MOS device compatible with Profile 6 use a specific naming
convention for <mosID>’s and <ncsID>’s of this form:
    Where <location> and <enterprise> are optional.
This is called a “Fully Qualified MOS ID”.
For example, these are valid Fully Qualified MOS ID’s:

FipHdr fields filled in (if there is data) :
    S0 mosID
    S1 ncsID
    S2 mosAction
    S3 roID
    S4 roSlug
    SK roChannel
    S5 sender IPaddress
    S6 local IPaddress
    S7 StartTime
    S8 Kwmos
    S9 storyID

    SB Approved (ess bee)
    SG storySlug
    SM messageID
    SO roEdStart    (2p was ENPSItemType) (ess oh)
    S$ roEdDur  (2q)
    SS DocStatus    (ess ess) version 2f+
    SW Actual or ReadTime

    W0 roStatus - temporary, not saved
    W1 (extra message for Ack), not saved
For acks, heartbeats, there is also
    WX the mosID of this Client


Input Parameters : -----
Mandatory :
    -n : Name of the Parameter file in tables/wire      default: MOSWIRE
        Note there must also be a MOSWIRE.HEARTBEAT and a MOSWIRE.ACK templates for
heartbeat and ack
Optional :
    -A : name of the archive file if not the -n name field  default: 'name'
    -C : always close the underlying socket         default: no
    -d : done folder                    default: none
        This holds a copy of all incoming data files from every source
        The structure is
            (done folder) / (date)_(logon) eg 20110921_fip / (filename as written to the
output folder)
        It can be purged with an entry in maintenance (zapfiplog)
        eg if '-d raw.moswire' and we want the last 30 days data
            /fip/bin/ipdelque -q/fip/spool/raw.moswire -i1 -a30
    -E : maximum number of threads              default: 1
        up to a max of 200 (not Win2k)
        Note this is also a hardware limit in that small systems may not be able to
run more than 50 or so
    -f : Extra FIP header information           default: none
        For fixed header info in FIP. eg -f #QA:AA#QB:BASIC
        As this flag is normally the last specified, its contents
        can be used to overwrite any unique fields such as DU, DP,
        SN etc.
    -I : id of this instance                default: ignored
        Where there are several copies of 'moswire' running (more relevant for Win2k)
    -j : balance queue for balancing doneque items    default: 2balance
    -J : balance group for balancing doneque items    default: -none- no balancing
        This group MUST be in sys/BALANCE
    -l : no logging at all                  default: file
    -L : log all connections and files          default: no
    -o : Output folder in /fip/spool            default: spool/xmos
        Note this will be overridden if there are any 'output-folderX:' parameters in
the parameter file.
    -O : Name of output format (DF field)           default: MOSWIRE
    -r : the name of a DIFFERENT routing table to 'name'
        (SR field : used by iproute)            default: name
    -s : hostname/internet address to select        default: systemname on boot
        for servers with more than one card/address
        To specify ALL ipaddresses on this box : '-s +'
    -S : send request at start - same as sent-at-start parameter    default: none
    -w : max timeout with no data               default: 60 secs
        ie between packets. Set to ZERO to disable or 10 (or more) secs
    -u : logon for files created if NOT that
        which was used to start 'moswire'       default: same
    -Z : do NOT archive any incoming files          default: archive
    -z : name of the parameter file in tables/wire      default: same as -n
    -v : Print the version number and exit

Version Control
;2a-q   22dec16 cleanup ;c added ORIGpgid ;d S9 -> HDRBUF ;e 12jul17 added
        ;fg SS:DocStatus added
        ;hi 3jan20 added SPIDER and send-at-start ;jk added default-encoding
        ;lm buffers->2*STD for incoming meta S0+
        ;nop 20mar21 UCS2 emoijes and dump-data and -D ;q roEdDur
;01a-z  12sep14 cleanup ;h 5jan16 added hash ;i added SB, SO, SW ;j
max-timeout->90 ;k bugette in do_widget ;l-q bugs
    ;r added balance-queue/group ;s FIP_DispSockError added ;t different
ENVironments for testing/QA etc
    ;u-y extra-fiphdr and heartbeat-folder and max-timeout added
    ;z 21nov16 added SG for storySlug too
;00q    23may00 original version

(copyright) 2024 and previous years FingerPost Ltd.