IBM Version 4 manual Correct Byte Alignment ensures that data used With an

Models: Version 4

1 505
Download 505 pages 30.92 Kb
Page 228
Image 228

Defining Byte Alignment

 

 

 

 

 

 

Correct

byte

alignment ensures that data used

with an

API

is

correct.

ment is

also essential when APIs are used to

retrieve

and then print

data. When byte alignment is off, it causes

the API

to

read

the da

other

than at

the beginning of a record.

 

 

 

 

Defining

Byte

Alignment—Example

of

Incorrect

Coding

 

 

 

 

 

 

 

 

 

 

 

 

 

This

 

program

illustrates

byte

alignment

while

defining

a

structure. This

i

 

 

.14/ on page 9-23. Four-byte alignment is required when using this

progra

 

 

Variable-length records must begin on a 4-byte boundary.14/, . theAs shown

at

 

 

 

variable-length

record

 

CCSID_rec

is

not

beginning

on a

4-byte

boundary.

 

 

the

 

API

accesses

the

CCSID_rec record, 4-byte alignment is

forced

by

 

 

first 3 bytes of the CCSID_rec

between

the

replace

field

and

the

 

 

CCSID_rec record.15/. on

page

9-24

shows that the variable-length

record

 

 

not 4-byte aligned

(the value

is

13,

which is

not

divisible

by

4). T

 

 

is

shown

.at17/

on page 9-26.

 

 

 

 

 

 

 

 

 

 

 

 

 

Note:

Not

all

APIs require a 4-byte boundary. ILE APIs, such as

 

 

 

 

 

 

QusAddExitProgram,

do.

 

 

 

 

 

 

 

 

 

 

 

 

 

/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\Program Name: PGM1

 

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\Program Language: ILE C

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\Description:

 

This program illustrates improper byte

 

\/

 

 

 

 

 

 

/\

 

 

 

 

alignment when using variable length

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

records.

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\Header Files Included:

<stdio.h>

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

<signal.h>

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

<string.h>

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

<stdlib.h>

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

<qusrgfa1.h>

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

<qusec.h>

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

<qliept.h>

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\

APIs Used:

 

QusAddExitProgram

 

- Add an exit program

\/

 

 

 

 

 

 

/\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/

 

 

 

 

 

 

/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/

 

 

 

 

 

 

/\

 

 

 

 

 

Includes

 

 

 

 

 

 

\/

 

 

 

 

 

 

/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/

 

 

 

 

 

 

#include <stdio.h>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#include <signal.h>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#include <string.h>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#include <stdlib.h>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#include <qusrgfa1.h>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#include <qusec.h>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#include <qliept.h>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/

 

 

 

 

 

 

/\

 

 

 

 

 

Structures

 

 

 

 

 

 

\/

 

 

 

 

9-22

System API

Programming

V4R1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Page 228
Image 228
IBM Version 4 manual Correct Byte Alignment ensures that data used With an