[Prev] [Contents] [Next]

Information about the example programs

The API documentation and concepts document includes example programs for all APIs. The following header file is used for all the examples. It should be named check.h (member CHECK in file H in a library in the library list).

In most cases error checking is contained in the examples that causes the program to exit() if any failure is detected. In some cases, error checking is left out of the examples for brevity. In general, the error checking provided should not be considered robust enough for all applications. All return codes from any system functions should be validated and appropriate action should be taken when failures occur.

The examples are provided "as-is" for demonstration and education purposes only. They do not necessarily provide or implement an appropriate level of robustness to be used for production code and should not be used directly for that purpose.

To create the examples, make sure the member CHECK is created in a file H in your library list. Use CRTCMOD on the member name that you download the source code to, then use CRTPGM to link the module into a program object. Alternately, you can use CRTBNDC to compile and link the program in one step.

Be sure to see "Writing and compiling threaded programs" on page 18 and "Running threaded programs" on page 19 for more information about compiling and running the example programs.

File Check.h used by API example programs

This example header file must be in the library list when you compile the example programs.

#ifndef _CHECK_H
#define _CHECK_H
/* headers used by a majority of the example program */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>

/* Simple function to check the return code and exit the program
   if the function call failed
   */
static void checkResults(char *string, int rc) {
  if (rc) {
    printf("Error on : %s, rc=%d",
           string, rc);
    exit(EXIT_FAILURE);
  }
  return;
}

#endif



[Prev] [Contents] [Next]
Copyright © 1998, IBM Corporation. All rights reserved.
Comments? Contact
rchthrds@us.ibm.com