Definitions and Declarations

The OSDI module that contains user-modifiable code (DIPUNIX.C, DIPMSDOS.C and so on) must contain certain definitions and declarations. Usually these are provided for you in some form. There are circumstances in which you may need to modify them, so a certain understanding of their function is useful.

You will see the following declarations in the OSDI user module:

 #define NR_PDESCS 1
 
 struct PDESC pdesc[NR_PDESCS];
 int nr_pdescs = NR_PDESCS;

All output from an application to a POD is passed to an OSDI as text to be "printed". The OSDI holds the text in a buffer. Furthermore the OSDI provides facilities for asynchronous printing whereby multiple lines of text (and therefore multiple buffers) are maintained.

The structure PDESC (print descriptor) is defined for you in DIP.H. It forms the basis of output data buffering and contains three fields:

 struct PDESC
 {
    char *text;
    int busy;
    int next;
 } 

The OSDI will automatically store data output from the application at the address specified by text. The other two fields are discussed later in the section on asynchronous printing. The pdesc array is an array of these structures. This is how multiple lines of output text are buffered.

One of the actions your OSDI must take on Device Group initialisation is to set the text pointers to suitable addresses. To achieve this you should declare buffers appropriately and initialise the pdesc array to point at these buffers. Example code is provided, where buffers are declared as:

static char pdtext[NR_PDESCS][PRN_BUFSIZE];

The text field of each component of the pdtext array must be initialised to point to an array of characters large enough to contain the longest line which will be printed. This initialisation may be done in prg_start() . The value PRN_BUFSIZE defined in DIP.H is a safe size for the array of characters, but a smaller value may be acceptable if it is known that there is a smaller limit on the size of line which will be printed.

Whenever a line of text is passed to the OSDI program, it is automatically copied into the area pointed to by pdesc[i].text. The index value, i, will then be passed to the prn_print() function.

The mnemonics PRN_INIT, PRN_PRINTER and so on are defined for COD identifiers in DIP.H. They correspond to the CODs used by Itim Technology Solutions Chameleon.