gtpc2mga | C/C++ Language Support User's Guide |
This function creates the entry represented by the specified key and stores the passed data values as its contents. The passed key is assumed to be 64 bytes in length.
Format
#include <c$to2.h> long TO2_atTPFsystemNewKeyPut ( TO2_ENV_PTR env_ptr, const void *key, const long *dataLength, const void *data);
Normal Return
The normal return is a positive value. A new entry is added to the dictionary represented by the specified key.
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_NOT_UNIQUE
Programming Considerations
A commit scope will be created for the TO2_atTPFsystemNewKeyPut request. If the request is successful, the scope will be committed. If an error occurs while processing the TO2_atTPFsystemNewKeyPut request, the scope will be rolled back.
Examples
The following example adds a new element to 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 */ char key[64] = "TPF.Key.is.64.characters.long "; u_char data[] = "This.is.some.data.for.the.TPF.Dictionary"; long dataLength = sizeof(data);
·
·
·
if (TO2_atTPFsystemNewKeyPut(env_ptr, key, &dataLength, data) == TO2_ERROR) { printf("atTPFsystemNewKeyPut 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("atTPFsystemNewKeyPut is successful!\n");
·
·
·
Related Information