IBM Version 4 Universal Remote User Manual


 
if (error_code.ec_fields.Bytes_Available != )
{
printf("ATTEMPT TO ADD AN EXIT PROGRAM FAILED WITH EXCEPTION:%.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 being added
to the structure to maintain 4-byte alignment (shown at 16 on page 9-25). This
corresponds to 14 on page 9-23 in the incorrect coding example. The 3 reserved
bytes are included in the length of the replace variable-length record. 17 on
page 9-26 shows the variable-length record is now 4-byte aligned (record length of
16 is divisible by 4). This corresponds to 15 on page 9-24 in the incorrect coding
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