gtpc2miaC/C++ Language Support User's Guide

TO2_convertBinPIDtoEBCDIC-Make a PID Printable

This function converts a binary persistent identifier (PID) to an EBCDIC string.

Format

#include <c$to2.h>
long TO2_convertBinPIDtoEBCDIC (const TO2_PID_PTR  binary_pid_ptr,
                                      TO2_ENV_PTR  env_ptr,
                                      char         EBCDIC_pid_output[64]
                                      long        *pid_output_length);

binary_pid_ptr
The pointer to a field that is 32 characters long and contains the binary PID that will be formatted.

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

EBCDIC_pid_output
The pointer to a field that is 64 characters long in which the converted EBCDIC PID will be stored.

pid_output_length
The pointer to where the length of the converted PID will be stored on return. This length includes trailing zeros in the PID.

Normal Return

The normal return is a positive value.

Error Return

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

The following error code is common for this function:

TO2_ERROR_ENV

Programming Considerations

This function does not use TPF transaction services on behalf of the caller.

Examples

The following example converts a PID to an EBCDIC string.

#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 the TO2 environment  */
TO2_PID        collect;
char           pid_buffer[64];
long           pid_length;

  ·
  ·
  ·
/**********************************************************************/ /* Make sure that the collection PID is assigned before arriving here.*/ /**********************************************************************/ pid_length = sizeof(pid_buffer); if (TO2_convertBinPIDtoEBCDIC(&collect, env_ptr, pid_buffer, &pid_length) == TO2_ERROR) { printf("TO2_convertBinPIDtoEBCDIC failed!\n"); process_error(env_ptr); } else { printf("TO2_convertBinPIDtoEBCDIC successful!\n"); printf("The PID may now be displayed as %s",pid_buffer); }

Related Information

TO2_convertEBCDICtoBinPID-Convert EBCDIC String to PID.