gtpc2mg8C/C++ Language Support User's Guide

TO2_atTPFsystemKey-Retrieve the Element Using the Specified Key

This function locates the entry represented by the specified key and returns its contents to the requester. If the key length is less than 64 bytes, the first entry with a key that matches the passed key string is returned.

Format

#include <c$to2.h>
TO2_BUF_PTR  TO2_atTPFsystemKey (      TO2_ENV_PTR  env_ptr,
                                 const void        *key,
                                 const long        *keyLength);

env_ptr
The pointer to the environment as returned by the TO2_createEnv function.

key
The pointer to the EBCDIC key to use to locate the dictionary entry.

keyLength
The pointer to a field containing the length of the key string.

Normal Return

The normal return is a pointer (TO2_BUF_PTR) to a structure (buffer) of type TO2_BUF_HDR (see Type Definitions).

Error Return

An error return is indicated by a zero. When zero is returned, use the TO2_getErrorCode function to determine the specific error code. For more information, see Error Handling.

The following error codes are common for this function:

TO2_ERROR_ENV

TO2_ERROR_LOCATOR_LGH

TO2_ERROR_LOCATOR_NOT_FOUND

Programming Considerations

Examples

The following example reads an element from the TPF system dictionary.

#include <c$to2.h>                /* Needed for TO2 API Functions     */
#include <stdio.h>                /* APIs for standard I/O functions  */
 
TO2_ENV_PTR    env_ptr;           /* Pointer to TO2 Environment       */
 
TO2_ERR_CODE     err_code;        /* TO2 error code value             */
TO2_ERR_TEXT_PTR err_text_ptr;    /* TO2 error code text pointer      */
 
TO2_BUF_PTR buffer;               /* TO2 buffer pointer returned      */
 
u_char key[64]
= "TPF.Key.is.64.characters.long                                   ";
 
long keyLength = sizeof(key);

  ·
  ·
  ·
if ((buffer = TO2_atTPFsystemKey(env_ptr, key, &keyLength)) == TO2_ERROR) { printf("atTPFsystemKey failed!\n"); err_code = TO2_getErrorCode(env_ptr); err_text_ptr = TO2_getErrorText(env_ptr, err_code); printf("err_text_ptr is %s\n", err_text_ptr); } else printf("atTPFsystemKey is successful!\n");
  ·
  ·
  ·
free(buffer); /* Release buffer when finished */

Related Information