YBOS Bank Functions (ybk_xxx)
[The ybos.h & ybos.c]


Functions

void ybk_init (DWORD *plrl)
void ybk_create (DWORD *plrl, char *bkname, DWORD bktype, void *pbkdat)
INT ybk_close (DWORD *plrl, void *pbkdat)
INT ybk_size (DWORD *plrl)
INT ybk_list (DWORD *plrl, char *bklist)
INT ybk_find (DWORD *plrl, char *bkname, DWORD *bklen, DWORD *bktype, void **pbk)
INT ybk_locate (DWORD *plrl, char *bkname, void *pdata)
INT ybk_iterate (DWORD *plrl, YBOS_BANK_HEADER **pybkh, void **pdata)


Function Documentation

INT ybk_close ( DWORD plrl,
void *  pbkdat 
)

Close the YBOS bank previously created by ybk_create().

The data pointer pdata must be obtained by ybk_create() and used as an address to fill a bank. It is incremented with every value written to the bank and finally points to a location just after the last byte of the bank. It is then passed to ybk_close() to finish the bank creation. YBOS is a 4 bytes bank aligned structure. Padding is performed at the closing of the bank with values of 0x0f or/and 0x0ffb. See YBOS bank examples.

Parameters:
plrl pointer to current composed event.
pbkdat pointer to the current data.
Returns:
number number of bytes contained in bank.

Definition at line 386 of file ybos.c.

00387 {
00388    DWORD tdlen;
00389    /* align pbkdat to I*4 */
00390    if (((POINTER_T) pbkdat & 0x1) != 0) {
00391       *((BYTE *) pbkdat) = 0x0f;
00392       pbkdat = (void *) (((BYTE *) pbkdat) + 1);
00393    }
00394    if (((POINTER_T) pbkdat & 0x2) != 0) {
00395       *((WORD *) pbkdat) = 0x0ffb;
00396       pbkdat = (void *) (((WORD *) pbkdat) + 1);
00397    }
00398 
00399    /* length in byte */
00400    tdlen = (DWORD) ((char *) pbkdat - (char *) __pbkh - sizeof(YBOS_BANK_HEADER));
00401 
00402    /* YBOS bank length in I4 */
00403    __pbkh->length = (tdlen + 4) / 4;    /* (+Bank Type &@#$!) YBOS bank length */
00404 
00405    /* adjust Logical Record Length (entry point from the system) */
00406    *plrl += __pbkh->length + (sizeof(YBOS_BANK_HEADER) / 4) - 1;
00407    return __pbkh->length;
00408 }

void ybk_create ( DWORD plrl,
char *  bkname,
DWORD  bktype,
void *  pbkdat 
)

Define the following memory area to be a YBOS bank with the given attribute. See YBOS bank examples.

Before banks can be created in an event, ybk_init(). has to be called first. YBOS does not support mixed bank type. i.e: all the data are expected to be of the same type. YBOS is a 4 bytes bank aligned structure. Padding is performed at the closing of the bank (see ybk_close) with values of 0x0f or/and 0x0ffb. See YBOS bank examples.

Parameters:
plrl pointer to the first DWORD of the event area.
bkname name to be assigned to the breated bank (max 4 char)
bktype YBOS Bank Types of the values for the entire created bank.
pbkdat return pointer to the first empty data location.
Returns:
void

Definition at line 273 of file ybos.c.

00274 {
00275    DWORD dname = 0;
00276    __pbkh = (YBOS_BANK_HEADER *) (((DWORD *) (plrl + 1)) + (*(DWORD *) plrl));
00277    strncpy((char *) &dname, bkname, 4);
00278    __pbkh->name = *((DWORD *) bkname);
00279    __pbkh->number = 1;
00280    __pbkh->index = 0;
00281    __pbkh->length = 0;
00282    __pbkh->type = bktype;
00283    *((DWORD **) pbkdat) = (DWORD *) (__pbkh + 1);
00284    return;
00285 }

INT ybk_find ( DWORD plrl,
char *  bkname,
DWORD bklen,
DWORD bktype,
void **  pbk 
)

Find the requested bank and return the infirmation if the bank as well as the pointer to the top of the data section.

Parameters:
plrl pointer to the area of event.
bkname name of the bank to be located.
bklen returned length in 4bytes unit of the bank.
bktype returned bank type.
pbk pointer to the first data of the found bank.
Returns:
YB_SUCCESS, YB_BANK_NOT_FOUND, YB_WRONG_BANK_TYPE

Definition at line 480 of file ybos.c.

00481 {
00482    YBOS_BANK_HEADER *pevt;
00483    DWORD *pendevt;
00484 
00485    pevt = (YBOS_BANK_HEADER *) (plrl + 1);
00486 
00487    /* end of event pointer skip LRL, point to YBOS_BANK_HEADER */
00488    pendevt = (DWORD *) pevt + *plrl;
00489 
00490    /* check if bank_type in range */
00491    if (pevt->type >= MAX_BKTYPE)
00492       return (YB_WRONG_BANK_TYPE);
00493 
00494    /* init returned variables */
00495    *bklen = 0;
00496    *bktype = 0;
00497 
00498    /* scan event */
00499    while ((DWORD *) pevt < pendevt) {
00500       /* check bank name */
00501       if (strncmp((char *) &(pevt->name), bkname, 4) == 0) {    /* bank name match */
00502          /* extract bank length */
00503          *bklen = pevt->length - 1;     /* exclude bank type */
00504 
00505          /* extract bank type */
00506          *bktype = pevt->type;
00507 
00508          /* return point to bank name */
00509          *pbk = &pevt->name;
00510          return (YB_SUCCESS);
00511       } else {
00512          /* skip to next bank */
00513          pevt = (YBOS_BANK_HEADER *) (((DWORD *) pevt) + pevt->length + 4);
00514       }
00515    }
00516    return (YB_BANK_NOT_FOUND);
00517 }

void ybk_init ( DWORD plrl  ) 

Initializes an event for YBOS banks structure.

Before banks can be created in an event, ybk_init() has to be called first. See YBOS bank examples.

Parameters:
plrl pointer to the first DWORD of the event area of event
Returns:
void

Definition at line 243 of file ybos.c.

00244 {
00245    *plrl = 0;
00246    return;
00247 }

INT ybk_iterate ( DWORD plrl,
YBOS_BANK_HEADER **  pybkh,
void **  pdata 
)

Returns the bank header pointer and data pointer of the given bank name.

Parameters:
plrl pointer to the area of event.
pybkh pointer to the YBOS bank header.
pdata pointer to the first data of the current bank.
Returns:
data length in 4 bytes unit. return -1 if no more bank found.

Definition at line 566 of file ybos.c.

00567 {
00568    static int len;
00569    static DWORD *pendevt;
00570    static DWORD *pybk;
00571    /*PAA char bname[5]; */
00572 
00573    /* the event may have several bank
00574       check if we have been already in here */
00575    if (*pybkh == NULL) {
00576       /* first time in (skip lrl) */
00577       *pybkh = (YBOS_BANK_HEADER *) (plrl + 1);
00578 
00579       if ((*pybkh)->type > I1_BKTYPE) {
00580          *pdata = NULL;
00581          *pybkh = (YBOS_BANK_HEADER *) * pdata;
00582          return (YB_WRONG_BANK_TYPE);
00583       }
00584 
00585       /* end of event pointer (+ lrl) */
00586       pendevt = plrl + *plrl;
00587 
00588       /* skip the EVID bank if present */
00589     /*-PAA- keep it in for a little while Dec 17/98
00590     *((DWORD *)bname) = (*pybkh)->name;
00591     if (strncmp (bname,"EVID",4) == 0)
00592     {
00593     len = (*pybkh)->length;
00594     (YBOS_BANK_HEADER *)(*pybkh)++;
00595     pybk = (DWORD *) *pybkh;
00596     pybk += len - 1;
00597     *pybkh = (YBOS_BANK_HEADER *) pybk;
00598     }
00599     */
00600    } else {
00601       /* already been in iterate */
00602       /* skip current pointed bank ( + bank_length + header) */
00603       len = (*pybkh)->length;
00604       (YBOS_BANK_HEADER *) (*pybkh)++;
00605       pybk = (DWORD *) * pybkh;
00606       pybk += len - 1;
00607       *pybkh = (YBOS_BANK_HEADER *) pybk;
00608    }
00609 
00610    /* check for end of event */
00611    if ((DWORD *) (*pybkh) < pendevt) {
00612       /* points to the data section */
00613       *pdata = (void *) (*pybkh + 1);
00614 
00615       /* length always in I*4 due to YBOS -1 because type included in length !@# */
00616       return ((*pybkh)->length - 1);
00617    } else {
00618       /* no more bank in this event */
00619       *pdata = NULL;
00620       *pybkh = (YBOS_BANK_HEADER *) * pdata;
00621       return (-1);
00622    }
00623 }

INT ybk_list ( DWORD plrl,
char *  bklist 
)

Returns the size in bytes of the event composed of YBOS bank(s).

The bk_list() has to be a predefined string of max size of YB_STRING_BANKLIST_MAX.

Parameters:
plrl pointer to the area of event
bklist Filled character string of the YBOS bank names found in the event.
Returns:
number of banks found in this event.

Definition at line 431 of file ybos.c.

00432 {
00433 
00434    YBOS_BANK_HEADER *pbk;
00435    DWORD *pendevt, nbk;
00436 
00437    pbk = (YBOS_BANK_HEADER *) (plrl + 1);
00438 
00439    /* end of event pointer skip LRL, point to YBOS_BANK_HEADER */
00440    pendevt = (DWORD *) pbk + *plrl;
00441 
00442    /* check if bank_type in range */
00443    if (pbk->type >= MAX_BKTYPE)
00444       return (YB_WRONG_BANK_TYPE);
00445 
00446    /*init bank counter and returned string */
00447    nbk = 0;
00448    bklist[0] = 0;
00449 
00450    /* scan event */
00451    while ((DWORD *) pbk < pendevt) {
00452       /* update the number of bank counter */
00453       nbk++;
00454 
00455       if (nbk > YB_BANKLIST_MAX) {
00456          cm_msg(MINFO, "ybk_list", "over %i banks -> truncated", YB_BANKLIST_MAX);
00457          return (nbk);
00458       }
00459 
00460       /* append ybos bank name to list */
00461       strncat(bklist, (char *) &(pbk->name), 4);
00462 
00463       /* skip to next bank */
00464       pbk = (YBOS_BANK_HEADER *) (((DWORD *) pbk) + pbk->length + 4);
00465    }
00466    return (nbk);
00467 }

INT ybk_locate ( DWORD plrl,
char *  bkname,
void *  pdata 
)

Locate the requested bank and return the pointer to the top of the data section.

Parameters:
plrl pointer to the area of event
bkname name of the bank to be located.
pdata pointer to the first data of the located bank.
Returns:
Number of DWORD in bank or YB_BANK_NOT_FOUND, YB_WRONG_BANK_TYPE (<0)

Definition at line 527 of file ybos.c.

00528 {
00529    YBOS_BANK_HEADER *pybk;
00530    DWORD *pendevt;
00531 
00532    pybk = (YBOS_BANK_HEADER *) (plrl + 1);
00533 
00534    /* end of event pointer skip LRL, point to YBOS_BANK_HEADER */
00535    pendevt = (DWORD *) pybk + *plrl;
00536 
00537    /* check if bank_type in range */
00538    if (pybk->type >= MAX_BKTYPE)
00539       return (YB_WRONG_BANK_TYPE);
00540 
00541    /* scan event */
00542    while ((DWORD *) pybk < pendevt) {
00543       /* check bank name */
00544       if (strncmp((char *) &(pybk->name), bkname, 4) == 0) {    /* bank name match */
00545          /* extract bank length */
00546 
00547          /* return pointer to data section */
00548          *((void **) pdata) = pybk + 1;
00549          return (pybk->length - 1);
00550       } else {
00551          /* skip to next bank */
00552          pybk = (YBOS_BANK_HEADER *) (((DWORD *) pybk) + pybk->length + 4);
00553       }
00554    }
00555    return (YB_BANK_NOT_FOUND);
00556 }

INT ybk_size ( DWORD plrl  ) 

Returns the size in bytes of the event composed of YBOS bank(s).

Parameters:
plrl pointer to the area of event
Returns:
number of bytes contained in data area of the event

Definition at line 416 of file ybos.c.

00417 {
00418    return (*((DWORD *) plrl) * 4 + 4);
00419 }


Midas DOC Version 3.0.0 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk