if (error_code.ec_fields.Bytes_Available != ð)

{

printf("ATTEMPT TO ADD AN EXIT PROGRAM FAILED WITH EXCEPT￿ION:%.7s", error_code.ec_fields.Exception_Id);

exit(1);

}

 

 

 

 

 

 

 

 

 

 

} /\ end program \/

 

 

 

 

 

 

 

Defining Byte Alignment—Example

of

Correct

Coding

 

 

 

 

 

The following

example

program shows

a

CHAR(3) bytes reserved field b

to the structure to maintain 4-byte

alignment.16/ on(shownpage

at9-25). This

 

corresponds

.to14/ on page 9-23 in the

incorrect coding example. The 3

bytes

are

included in the length of the

replace .17/variableon -length

rec

page

9-26

shows

the

variable-length

record

is now 4-byte aligned

(re

16 is divisible by 4). This corresponds.15/ pageto 9-24 in the incorrect

cod

example.

 

 

 

 

 

 

 

 

 

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

 

 

/\

 

 

 

 

 

 

 

\/

 

 

/\Program Name: PGM2

 

 

 

 

 

\/

 

 

/\

 

 

 

 

 

 

 

\/

 

 

/\Program Language:

ILE C

 

 

 

\/

 

 

/\

 

 

 

 

 

 

 

\/

 

 

/\Description:

This program illustrates proper 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

 

 

\/

 

 

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

 

 

typedef struct {

 

 

 

/\ Error code

 

 

\/

 

 

Qus_EC_t ec_fields;

 

 

 

 

 

 

 

 

char

exception_data[1ðð];

 

 

 

 

 

 

} error_code_struct;

 

 

 

 

 

 

 

 

typedef struct {

 

 

 

/\ Exit program attribute keys\/

 

 

int

 

num_rec;

 

 

 

 

 

 

Qus_Vlen_Rec_4_t replace_rec;

 

 

 

 

 

 

char

 

replace;

 

 

 

 

 

 

char

 

Reserved[3];

.16/

 

 

 

 

 

 

 

 

 

 

Chapter

9.

Common API

Programming

Errors 9-25

 

Page 231
Image 231
IBM Version 4 manual Defining Byte Alignment-Example Correct, Ile C