Common Lisp Package: COBSTOR

README:

FUNCTION

Public

CBL-CONNECT (NAME)

Connect to remote agent for file of type NAME.

CBL-ENSURE-CONNECTION (FILE-NAME)

Return a handle of a connection to a Cobol agent. If *KEEP-AGENT-CONNECTIONS* is true the handle may already exist in the cache, in this case no new connection is created.

CBL-FILE-METADATA (FILE-NAME)

Find a data file in *DATA-FILES-TABLE*.

CBL-MAP-FIELDS (PROC FIELDS &KEY LEAVES-ONLY-P NAMED-ONLY-P)

Apply PROC to FIELDS. If LEAVES-ONLY-P is true, don't apply PROC to fields that contain subfields.

CBL-OPEN (FILE &KEY (DIRECTION INPUT))

Open a remote cobol file of type NAME. The DIRECTION can be :INPUT, :OUTPUT or :INPUT-OUTPUT.

CBL-RECORD-FIELDS (RECORD)

Return the tree of fields of Cobol record RECORD, which is a symbol.

CBL-RELEASE-CONNECTION (FILE &KEY ABORT)

Dispose of a connection that is no longer necessary. If *KEEP-AGENT-CONNECTIONS* is true at least a connection to a each file is kept in cache so that the next time we require to access the same file, the burden of starting a new agent is avoided.

CBL-UNLOCK (FILE)

Unlock all records of FILE.

CLEAR-AGENTS-POOL (&OPTIONAL ABORT)

Severe all the existing connections to Cobol agents and remove the entries from the *agent-handles-by-name* and *agent-handles-by-port* hash tables.

NEXT-KEY (RECORD &OPTIONAL KEY)

Return the key of the record following RECORD in the file.

NEXT-RECORD (RECORD &OPTIONAL KEY)

Fetch the record that follows RECORD in the file.

PREVIOUS-KEY (RECORD &OPTIONAL KEY)

Return the key of the record preceding RECORD in the file.

PREVIOUS-RECORD (RECORD &OPTIONAL KEY)

Fetch the record that precedes RECORD in the file.

RECORD-KEY (RECORD &OPTIONAL KEY)

Return the value of the key of RECORD. KEY, if specified is a symbol. If KEY is not specified, return the default key.

STRING (X)

Coerces X into a string. If X is a string, X is returned. If X is a symbol, X's pname is returned. If X is a character then a one element string containing that character is returned. If X cannot be coerced into a string, an error occurs.

Undocumented

ALREADY-EXISTS-P (STATUS)

COPY-RECORD (RECORD)

EOF-P (STATUS)

FILE-ERROR-P (STATUS)

LOAD-ALL-PROXIES

LOAD-PROXY (NAME)

NOT-FOUND-P (STATUS)

Private

ADD-FIELD-SIZES (FIELDS)

Add the :SIZE property to FIELDS, which is a list of fields as expected by DEFINE-COBOL-RECORD. Return a modified list of fields.

AGENT-FILE-PATHNAME (NAME)

Return the absolute pathname of the Cobol agent source file named NAME.

BUFFER (N)

Make an (UNSIGNED-BYTE 8) vector of length N.

CBL-FILE-STATUS-EXTENDED (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CBL-FILE-STATUS-MAJOR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CBL-FILE-STATUS-MINOR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

CBL-RECORD-FIELD-NAMES (RECORD)

Return the list of field names of Cobol record RECORD, which is a symbol. Return a list of symbols.

COMPILED-AGENT-FILE-PATHNAME (NAME)

Return the absolute pathname of the compiled Cobol agent program named NAME.

DATA-FILE-PATHNAME (NAME)

Return the absolute pathname of the Cobol data file named NAME.

DECODE-FILE-STATUS (STATUS)

Read the file status from STREAM and return a CBL-FILE-STATUS object.

FREE-PORT-P (PORT)

Check whether port is currently free to be used by a local server.

GET-RUNNING-AGENT (NAME)

If it exists, return a running agent for NAME file. In doing so, remove it from the names hash table so the subsequent calls to this function won't find the same agent.

INITIAL-HANDSHAKE (HANDLE)

Do some sanity checks on the cbl-file HANDLE, just in case the agent doesn't correspond to the proxy stub.

OPEN-PIPE (FMT &REST ARGS)

Return a process object from which the command output/input will be read/written.

RECEIVE-MESSAGE (FILE)

Receive a message from agent. Anything coming from the agent is preceded by a two bytes length of the following byte sequence.

RELEASE-RUNNING-AGENT (FILE)

Opposite of GET-RUNNING-AGENT. Return FILE to the names hash table so that FIND-RUNNING-AGENT will find it.

RUN-ASYNC-PROGRAM (FMT &REST ARGS)

Run a shell program asynchronously (in background).

SEND-MESSAGE (FILE SEQUENCE)

Send a message to agent.

SIZE-OF-COMP4/5 (DIGITS SIGNED)

Return the size of the storage accupied by COMP-4 Cobol field with DIGITS and SIGN. This is according to the AcuCobol documentation that considers at most 31 digits.

WRSEQ (SEQ STREAM)

Like write-sequence but considers the element type of the stream.

Undocumented

ADD-RUNNING-AGENT (FILE)

BYTE-VECTOR->INTEGER (SEQUENCE)

SETFCBL-FILE-STATUS-EXTENDED (NEW-VALUE INSTANCE)

SETFCBL-FILE-STATUS-MAJOR (NEW-VALUE INSTANCE)

SETFCBL-FILE-STATUS-MINOR (NEW-VALUE INSTANCE)

CBL-FILE-STATUS-P (OBJECT)

COLLECT-NAMES (FIELDS)

COPY-CBL-FILE-STATUS (INSTANCE)

DELETE-RUNNING-AGENT (FILE)

ENSURE-TERM-ENVVAR

FIELD-TYPE->ACCESSOR-MAKER (TYPE)

FIELD-TYPE->SIZER (TYPE)

FIND-RUNNING-AGENT (NAME)

FIND-RUNNING-AGENT-BY-PORT (PORT-NUMBER)

GET-AREA-FIELD-VALUE (STORAGE OFFSET LENGTH)

GET-COMP1-FIELD-VALUE (STORAGE OFFSET)

GET-COMP2-FIELD-VALUE (STORAGE OFFSET SIZE SIGNED DECIMALS)

GET-COMP3-FIELD-VALUE (STORAGE OFFSET SIZE SIGNED DECIMALS)

GET-COMP6-FIELD-VALUE (STORAGE OFFSET SIZE DECIMALS)

GET-FIELD-VALUE-COMP4/5-BE (STORAGE OFFSET SIZE DECIMALS)

GET-FIELD-VALUE-COMP4/5-LE (STORAGE OFFSET SIZE DECIMALS)

GET-NUMERIC-FIELD-VALUE (STORAGE OFFSET SIZE SIGNED SIGN-SEPARATED-P SIGN-POSITION DECIMALS)

GET-STRING-FIELD-VALUE (STORAGE OFFSET LENGTH)

INTEGER->BYTE-VECTOR (INTEGER LENGTH)

MAKE-CBL-BINARY-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &REST ARGS)

MAKE-CBL-BINARY-AREA-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &KEY LENGTH)

MAKE-CBL-COMP-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &REST ARGS)

MAKE-CBL-COMP1-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES)

MAKE-CBL-COMP2-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &KEY LENGTH SIGNED (DECIMALS 0))

MAKE-CBL-COMP3-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &KEY LENGTH SIGNED (DECIMALS 0))

MAKE-CBL-COMP4-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &KEY LENGTH SIGNED (DECIMALS 0))

MAKE-CBL-COMP5-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &KEY LENGTH SIGNED (DECIMALS 0) (ENDIANNESS *DEFAULT-ENDIANNESS*))

MAKE-CBL-COMP6-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &KEY LENGTH (DECIMALS 0))

MAKE-CBL-FILE-STATUS (&KEY ((MAJOR DUM51) NIL) ((MINOR DUM52) NIL) ((EXTENDED DUM53) NIL))

MAKE-CBL-NUMERIC-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &KEY LENGTH SIGNED (DECIMALS 0) SIGN-SEPARATED (SIGN-POSITION *DEFAULT-SIGN-POSITION*))

MAKE-CBL-PACKED-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &REST ARGS)

MAKE-CBL-STRING-ACCESSOR (SLOT-NAME CLASS OFFSET SIZE CARDINALITIES &KEY LENGTH)

NEXT-AGENT-PORT (&OPTIONAL (BASE *AGENT-BASE-PORT*))

NO-CURRENT-RECORD-P (STATUS)

QUERY-RECORD-LENGTH (FILE)

RDSEQ (SEQ STREAM)

RECEIVE-ANSWER (FILE &OPTIONAL RECORD)

RECEIVE-NAME (HANDLE)

RECEIVE-OK (FILE &OPTIONAL RECORD)

RECEIVE-SEQUENCE (STREAM LENGTH)

RECEIVE-STRING-MESSAGE (FILE)

SEND-COMMAND (FILE COMMAND &OPTIONAL RECORD KEY)

SET-AREA-FIELD-VALUE (VALUE STORAGE OFFSET LENGTH)

SET-COMP1-FIELD-VALUE (VALUE STORAGE OFFSET)

SET-COMP2-FIELD-VALUE (VALUE STORAGE OFFSET SIZE SIGNED DECIMALS)

SET-COMP3-FIELD-VALUE (VALUE STORAGE OFFSET SIZE SIGNED DECIMALS)

SET-COMP6-FIELD-VALUE (VALUE STORAGE OFFSET SIZE DECIMALS)

SET-FIELD-VALUE-COMP4/5-BE (VALUE STORAGE OFFSET SIZE DECIMALS)

SET-FIELD-VALUE-COMP4/5-LE (VALUE STORAGE OFFSET SIZE DECIMALS)

SET-NUMERIC-FIELD-VALUE (VALUE STORAGE OFFSET SIZE SIGNED SIGN-SEPARATED-P SIGN-POSITION DECIMALS)

SET-STRING-FIELD-VALUE (VALUE STORAGE OFFSET LENGTH)

SIGNED-NEGATIVE-DIGIT-CODING-TABLE

SIGNED-POSITIVE-DIGIT-CODING-TABLE

SIMPLE-COMMAND (FILE COMMAND)

SIZE-OF-CBL-BINARY (&REST ARGS)

SIZE-OF-CBL-BINARY-AREA (&KEY LENGTH)

SIZE-OF-CBL-COMP (&REST ARGS)

SIZE-OF-CBL-COMP1

SIZE-OF-CBL-COMP2 (&KEY LENGTH SIGNED DECIMALS)

SIZE-OF-CBL-COMP3 (&KEY LENGTH SIGNED DECIMALS)

SIZE-OF-CBL-COMP4 (&KEY LENGTH SIGNED DECIMALS)

SIZE-OF-CBL-COMP5 (&KEY LENGTH SIGNED DECIMALS ENDIANNESS)

SIZE-OF-CBL-COMP6 (&KEY LENGTH DECIMALS)

SIZE-OF-CBL-NUMERIC (&KEY LENGTH SIGNED DECIMALS SIGN-SEPARATED SIGN-POSITION)

SIZE-OF-CBL-PACKED (&REST ARGS)

SIZE-OF-CBL-STRING (&KEY LENGTH)

TRY-CONNECT-TO-AGENT (PORT)

UNSIGNED-DIGIT-CODING-TABLE

MACRO

Public

DECLARE-COBOL-DATA-FILE (NAME RECORD KEYS)

Add a data file to the *AGENT-TABLE*.

LOOP-CBL-FILE-QUERY ((FILE RECORD STARTS &KEY COMPARE-OP KEY MULTI-RECORD PATHNAME FIELDS) &BODY BODY)

Execute BODY within a start and next loop on FILE. Overwrite RECORD at each iteration with the next record in FILE. COMPARE-OP and KEY are the same as for CBL-START. STARTS is a list where each element is a two elements list: the first is the RECORD accessor for a key field and the second is its start value. If MULTI-RECORD is true allocate a new record at each iteration. If RECORD is within parenthesis, don't allocate a new record and use one in the lexical context. If FIELDS is not null bind local macrolets to access RECORD's fields. If FIELDS is a list bind only those listed.

WITH-RECORD (RECORD CLASS &BODY FORMS)

Locally create macrolets to access all RECORD's fields. RECORD is assumed to be of type CLASS.

WITH-RECORD-ACCESSORS (ACCESSORS RECORD &BODY FORMS)

Execute FORMS while locally creating macrolets to access RECORD's ACCESSORS.

WITH-RECORDS (RECORDS &BODY FORMS)

Locally create macrolets to access all fields in RECORDS. RECORDS is an alist of variable names and record classes. Each variable is assumed to be of the respective type and macrolet accessors are generated. See also WITH-RECORD-ACCESSORS.

Undocumented

DEFINE-COBOL-RECORD ((NAME &KEY ALTERNATES DOCUMENTATION) &REST DECLARATIONS)

WITH-CBL-FILE ((HANDLE FILE &KEY PATHNAME (DIRECTION INPUT)) &BODY BODY)

Private

Undocumented

DEFACCMKR (TYPE ARGS &BODY FORMS)

DEFSIZER (TYPE ARGS &BODY FORMS)

WITH-INDEXES ((OFFSET CARDINALITIES) &BODY FORMS)

GENERIC-FUNCTION

Public

WRITE-RECORD (RECORD STREAM)

Write the storage of RECORD to STREAM.

Undocumented

CBL-CLOSE (FILE)

CBL-DELETE (FILE RECORD &KEY INEXISTENT-ERRORP (INEXISTENT-ERRORP T) INEXISTENT-VALUE)

CBL-DELETE-FILE (FILE)

CBL-DISCONNECT (FILE &KEY ABORT)

CBL-ERROR-STATUS (CONDITION)

CBL-EXIT (FILE)

CBL-NEXT (FILE &OPTIONAL RECORD)

CBL-PREVIOUS (FILE &OPTIONAL RECORD)

CBL-READ (FILE RECORD &KEY KEY NOT-FOUND-ERRORP NOT-FOUND-VALUE)

CBL-RECORD-FILE (RECORD)

CBL-REWRITE (FILE RECORD &KEY IF-NOT-FOUND (IF-NOT-FOUND ERROR))

CBL-START (FILE RECORD &KEY COMPARE-OP KEY (COMPARE-OP NOT-LESS) NOT-FOUND-ERRORP)

CBL-WRITE (FILE RECORD &KEY IF-EXISTS (IF-EXISTS ERROR))

Private

Undocumented

CBL-FILE-INPUT (FILE)

CBL-FILE-OUTPUT (FILE)

CBL-SET-PATHNAME (FILE PATHNAME)

SLOT-ACCESSOR

Public

RECORD-SIZE (OBJECT)

Return the size of RECORD, which is a string.

Undocumented

RECORD-STORAGE (OBJECT)

Private

CBL-FILE-KEYS (OBJECT)

List of file keys this file supports.

CBL-FILE-NAME (OBJECT)

Name of the file and the Cobol agent.

CBL-FILE-PORT (OBJECT)

The port number this Cobol agent answers connections.

CBL-FILE-RECORD-TYPE (OBJECT)

The class of this file's records.

CBL-FILE-SOCKET (OBJECT)

The socket connected to the Cobol agent.

VARIABLE

Public

*AGENT-BASE-PORT*

Portnumber at which the Cobol agent serves connections.

*AGENTS-LIBRARY-NAME*

Pathname of the Cobol library containing all the agents. If NIL cobstor will run the single agents using the COMPILED-AGENT-FILE-PATHNAME function.

*BINARY-FIELD-CLASS*

Class to use to represent binary fields. The Cobol manual says: By default, a BINARY data item is identical to a COMP-4 data item. The compile-time option "-D5" treats BINARY data items as COMP-5 items instead.

*BINARY-FIELD-SIZE-CONVENTION*

The storage convention for binary fields. Normally this is :ACU but it can also be :ACU1, :ACU-TIGHT or :MF.

*COBOL-FILES*

List of files declared with DECLARE-COBOL-DATA-FILE.

*COMP-FIELD-CLASS*

Class to use to represent comp fields. The Cobol manual says: In VAX/COBOL compatibility mode, a COMP data item is the same as COMP-4 and is treated as binary data. In RM/COBOL compatibility lmode, COMP is the same as COMP-2. You can use compile-time options to change the default behavior.

*DEFAULT-ENDIANNESS*

What kind of CPU should be emulated when handling fields which depend on the endianness of the architecture. Allowed values are :BIG-ENDIAN (like Motorola CPUs) and :LITTLE-ENDIAN (like Intel CPUs).

*DEFAULT-SIGN-POSITION*

Position of a separate sign in numeric fields if not explicitly specified. It can be :LEADING or :TRAILING.

*FIELD-ACCESSORS*

Type of accessor that is created for record fields. It can be either :METHOD, to create CLOS methods, or :FUNCTION, to create normal Lisp functions. If you don't expect name clashes :FUNCTION is the best choice, as it avoids the CLOS overhead.

*KEEP-AGENT-CONNECTIONS*

If true agent connections are not severed upon exit of WITH-CBL-FILE.

*NUMERIC-FIELD-SIGN-CONVENTION*

Notation used by numerical fields in presence of a sign. This can be :ACU :MF :VAX :IBM :NCR.

*PACKED-DECIMAL-FIELD-CLASS*

Class to use to represent packed decimal fields. The Cobol manual says: Data items described as PACKED-DECIMAL are identical to COMP-3. You can cause unsigned PACKED-DECIMAL to be treated as COMP-6 by using a compile-time option.

*RUNCBL-PATHNAME*

Pathname to the runcbl executable (or wrapper). Although a relative pathname would be resolved by the Unix shell search path, it's a bad idea to rely on that.

*SETTER-PREFIX*

Prefix to be prepended to function names of field setters. This should be a symbol, possibly ending in hyphen.

*TREAT-BLANK-AS-ZERO*

If true blanks in numeric fields with storage type `display' are treated as zeros.

Private

*AGENT-COMPILED-TYPE*

Pathname type of the compiled files of the Cobol agent.

*AGENT-HANDLES-BY-NAME*

The active connections to Cobol agents keyed by name.

*AGENT-HANDLES-BY-PORT*

The active connections to Cobol agents keyed by socket port.

*AGENT-SOURCE-TYPE*

Pathname type of the source files of the Cobol agent.

*BINARY-ALIAS*

Class to use to represent binary fields. The Cobol manual says: By default, a BINARY data item is identical to a COMP-4 data item. The compile-time option "-D5" treats BINARY data items as COMP-5 items instead.

*COMP-ALIAS*

Class to use to represent comp fields. The Cobol manual says: In VAX/COBOL compatibility mode, a COMP data item is the same as COMP-4 and is treated as binary data. In RM/COBOL compatibility lmode, COMP is the same as COMP-2. You can use compile-time options to change the default behavior.

*DEBUG*

If set to T, this library will produce more output.

*DEFAULT-TERM*

Default value for TERM envvar in case it's not set already. This is required by runcbl which requires it despite the -b (batch) flag.

*PACKED-DECIMAL-ALIAS*

Class to use to represent packed decimal fields. The Cobol manual says: Data items described as PACKED-DECIMAL are identical to COMP-3. You can cause unsigned PACKED-DECIMAL to be treated as COMP-6 by using a compile-time option.

CLASS

Public

CBL-RECORD

Base class for cobol records. Subclasses must specify an initform for the SIZE slot so that the default INITIALIZE-INSTANCE method will instantiate the storage automatically.

Undocumented

CBL-FILE

CBL-FILE-STATUS

STRING (X)

CONDITION

Public

CBL-FILE-CONDITION

Base abstract class for all the conditions related to the use of a CBL-FILE.

Undocumented

CBL-FILE-ERROR

CBL-PROTOCOL-ERROR

Private

CBL-CONDITION

Base abstract class for all the conditions of the cobstor package.

Undocumented

CBL-FILE-COBOL-ERROR

CONSTANT

Private

+WHITESPACE-BYTES+

List of whitespace characters as unsigned bytes.