gtpc2m1bC/C++ Language Support User's Guide

csonc-Convert System Ordinal Number

This function converts a database ordinal number (a file address reference format (FARF) format address) to a 7-byte file address in the MMCCHHR format. The name MMCCHHR displays how the address is constructed:

MM
A halfword symbolic module number used to identify the physical device

CC
A halfword cylinder address

HH
A halfword head address

R
A 1-byte record number.

The 5-byte CCHHR is the same as the record ID recorded in the count area on file.

Validity checking is done by this function on a FARF file address for the following:

Format

#include  <tpfio.h>
unsigned int csonc(enum t_lvl level, MCHR_STRUCT_PTR file_addr);
 

or

#include  <tpfio.h>
unsigned int csonc(TPF_FA8 *fa8, MCHR_STRUCT_PTR file_addr);
 

level
One of 16 possible values representing a valid entry control block (ECB) data level from the enumeration type t_lvl, expressed as Dx, where x represents the hexadecimal number of the level (0-F). This indicates which ECB file address reference word (FARW) should be initialized with the program's file address and record ID. The specified FARW must contain a FARF address.

fa8
A pointer to an 8-byte file address.

file_addr
The 2-byte module (MM), cylinder (CC), and head (HH) numbers, and also the 1-byte record number (R) are returned to the file address.

Normal Return

A nonzero value.

Error Return

An integer value of zero.

Programming Considerations

Examples

In the following example, FACS is called to calculate a FARF address and convert it to a MMCCHHR address.

#include <tpfeq.h>
#include <tpfio.h>
 
#pragma linkage(FACS,TPF,N)
extern void FACS(struct TPF_regs *);

·
·
·
MCHR_STRUCT mchr; struct TPF_regs regs; /* call FACS to calculate FARF address */ regs.r0 = 0; regs.r6 = (long int)"#RECTYPE"; regs.r7 = (long int)&ecbptr()->ce1fa0; FACS(&regs); if (regs.r0 == 0) { /* FACS error */ } else { /* call csonc to convert FARW to MMCCHHR */ if (csonc(D0, &mchr)) { /* success */ } else { /* failure */ } }

In the following example, tpf_fac8c is called to calculate a FARF address and convert it to a MMCCHHR address.

#include <tpfeq.h>
#include <tpfio.h>

·
·
·
MCHR_STRUCT mchr; TPF_FA8 fileAddr; TPF_FAC8 parms; /* call tpf_fac8c to calculate FARF address */ memcpy(parms.ifacrec, "#RECTYPE", 8); parms.ifacord=0; parms.ifactyp=IFAC8FCS; tpf_fac8c(&parms); if (parms.ifacret != TPF_FAC8_NRM) { /* FACE/FACS error */ } else { fileAddr=parms.ifacadr; /* call csonc to convert address to MMCCHHR */ if (csonc(&fileAddr, &mchr)) { /* success */ } else { /* failure */ } }

Related Information

None.