/* Copyright © Oracle Corporation 1995. All Rights Reserved. */ /*++ * FACILITY: * RDML -- Relational Data Manipulation Language Preprocessors * * ABSTRACT: * Include file for VAX C modules preprocessed by RDML * * VERSION: * RDML V1.3 *-- */ #ifndef EOF #include #endif /* * It is my belief that the following piece of code can go away * because the converter this file supports operates only on VMS. * * * #ifndef vax11c * #ifndef globalref * #define globalref extern * #define globaldef * #endif * #endif */ /********************************/ /* BOOLEAN Constants */ /********************************/ /* * The converter produces the following #define names * for the boolean values TRUE and FALSE. */ #ifndef TRUE #define TRUE (1==1) #define FALSE (1==0) #endif /********************************/ /* SQL Error Codes */ /********************************/ /* * The converter produces the following #define names * for SQL error codes. These may be moved to a standard * SQL include file */ #define SQL$_SUCCESS 0 #define SQL$_EOF 100 /* * It is my belief that the following piece of code can go away * because the converter does not produce these constants. * * * #define CHR(p) (char) p * * #define RDB$EOF CHR(1) * #define RDB$NOTEOF CHR(0) * #define RDB$TRUE CHR(1) */ /* Type Definitions Usable in the host program */ #define RDB$MSG_VECTOR_SIZE 20 typedef unsigned long RDB$MSG_VECTOR_TYPE[RDB$MSG_VECTOR_SIZE]; typedef unsigned long SQL$HANDLE_TYPE; typedef SQL$HANDLE_TYPE RDML$HANDLE_TYPE; typedef SQL$HANDLE_TYPE DDTM$HANDLE_TYPE; /* * Should the following be removed from this support package? (Is * the converter "part of the next release of RDML"?) * * The undocumented macros used to declare varying string datatypes * are no longer used by RDML. To continue to use them place a * #define USE_OLD_RDML_MACROS in your source code before the * database statements in your modules. These definitions will be * removed from the next release of RDML. */ #ifdef USE_OLD_RDML_MACROS /* Define macro for declaring a Varying string datatype */ #define VARYING_STRING(maxsize)\ struct {\ unsigned short size; /* string size*/\ char string[(maxsize)]; /* string bytes */\ } #define VARYING_STRING_CONSTANT(name,str)\ VARYING_STRING(sizeof(str)-1) name = {sizeof(str)-1,str } #endif /************************/ /* TEXT Data Type */ /************************/ /* * Define macro to copy text */ #define SQL$COPY_TEXT(dst, src)\ {\ char *pdst = (char *)(dst),\ *psrc = (char *)(src),\ *pcur, *pend;\ pcur = pdst;\ if (sizeof(dst) > sizeof(src)) /* determine a safe end point */\ pend = pdst + sizeof(src);\ else\ pend = pdst + sizeof(dst);\ while (pcur < pend) /* copy characters */\ *pcur++ = *psrc++;\ pend = pdst + sizeof(dst);\ while (pcur < pend) /* blank fill to right, if necessary */\ *pcur++ = ' ';\ } /* * ...and one to compare two strings */ #define SQL$COMPARE_TEXT(str1, str2) strcmp(str1, str2) /*********************************/ /* VARYING STRINGS Data Type */ /*********************************/ /* * Each varying string type is defined locally within each module, * because every different object may have its own size. * * Define macro to convert C string (ASCIZ) to varying string. * Note that this macro will also copy the trailing '\0', so * the string portion of the resultant varying string is still * ASCIZ. * * This function corresponds to RDB$CSTRING_TO_VARYING. The * order of operands have been reversed to make it correspond */ #define SQL$COPY_VARSTRING(cv,azptr)\ {\ int cntr = 0, limit = sizeof((cv).string);\ char *src, *start,\ *dst = &(cv).string;\ for(src = start = (azptr);\ (++cntr <= limit) && (*dst++ = *src++);)\ ;\ (cv).size = cntr-1;\ } /* * Define macro to convert VARYING_STRING string back to C * string (ASCIZ). (cv and azptr are both assumed to be pointers) * Corresponds to RDB$VARYING_TO_CSTRING. */ #define RDB$VARYING_TO_CSTRING(cv,azptr)\ {\ char *src = &(cv).string,\ *dst = (azptr);\ unsigned int size;\ for (size = (cv).size ; size ; --size)\ *dst++ = *src++;\ *dst = '\0';\ } /* * Inverse of RDB$VARYING_TO_CSTRING, this macro takes a strng * into a varying. Corresponds to RDB$CSTRING_TO_VARYING. */ #define RDB$CSTRING_TO_VARYING(azptr,cv)\ {\ char *src, *start,\ *dst = &(cv).string;\ for(src = start = (azptr); *dst++ = *src++;)\ ;\ (cv).size = --src - start;\ } /* * Because two objects of varying string types can have different * sizes and thus not be assignment compatible, an assignment * function is provided for varying strings. */ #define SQL$COPY_VARYING(target,source)\ {\ const int limit1 = sizeof((target).string);\ const int limit2 = (source).size;\ char *dst = (target).string;\ char *src = (source).string;\ int cntr;\ \ for(cntr = 1;\ (cntr <= limit1) && (cntr <= limit2);\ cntr++) {\ (*dst++ = *src++);\ }\ (target).size = cntr - 1;\ } #define SQL$COMPARE_VARYING(str1, str2) strcmp(str1.string, str2.string) /********************************/ /* DATE Data Type */ /********************************/ /* * The type SQL$DATE_TYPE represents the quadword type the way * RDML has implemented it. */ typedef unsigned char SQL$DATE_TYPE[8]; /* * Define a "zero" constant for this type. There is an extra null * character at the end of the quoted string. */ static const SQL$DATE_TYPE SQL$DATE_ZERO = "\0\0\0\0\0\0\0"; /* * Because the type is implemented as an array, functions which * perform assignment and comparison also must be provided. */ #define SQL$COPY_DATE(dst, src) memcpy(dst, src, 8) #define SQL$COMPARE_DATE(s1, s2) memcmp(s1, s2, 8) /********************************/ /* QUADWORD Data Type */ /********************************/ /* * The type SQL$QUADWORD_TYPE represents the quadword type the way * RDML has implemented it. */ typedef unsigned char SQL$QUADWORD_TYPE[8]; /* * Define a "zero" constant for this type. There is an extra null * character at the end of the string. */ static const SQL$QUADWORD_TYPE SQL$QUAD_ZERO = "\0\0\0\0\0\0\0"; /* * Because the type is implemented as an array, functions which perform * assignment and comparison also must be provided. */ #define SQL$COPY_QUADWORD(dst, src) memcpy(dst, src, 8) #define SQL$COMPARE_QUADWORD(s1, s2) (memcmp(s1, s2, 8) == 0) /********************************/ /* SEGMENTED STRING Data Type */ /********************************/ /* * The segmented string data type seems to be a string of 8 characters. */ typedef unsigned char SQL$SEGSTR_ID_TYPE[8]; /* * All that is required here at this time is a null Seg String value. */ #define SQL$NULL_SEGSTR "\0\0\0\0\0\0\0" /********************************/ /* Other RDML Objects */ /********************************/ /* * Old and new names for message vector and default transaction * handle (To allow RDML modules to coexist with RDBPRE and SQLPRE * modules) */ /* NOTE: This variable called RDB$TRANSACTION_HANDLE is not the same * thing as the "real" RDB$TRANSACTION_HANDLE. This one must always * have a value zero since it is used to communicate with SQL and * DDTM. Modules linked with SQL do not have access to the * RDB$TRANSACTION_HANDLE associated with databases. This variable * is only named RDB$TRANSACTION_HANDLE so that it will be * compatible with programs that might explicitly specify this * name. */ globalref RDB$MSG_VECTOR_TYPE RDB$MSG_VECTOR; /* old name */ globalref RDML$HANDLE_TYPE RDB$LU_TRHANDLE; /* old name */ extern RDB$MSG_VECTOR_TYPE RDB$MESSAGE_VECTOR; /* new name */ static RDML$HANDLE_TYPE RDB$TRANSACTION_HANDLE = 0; /* new name */ /* * Procedures which are shared across modules and are provided by * the converter's run-time support library * * The SQL versions are for use when /NOCONTEXT is specified. * The _DEF versions are for use when /CONTEXT is specified but no handle. * The _TH versions are for use when /CONTEXT is specified with a handle. */ extern void SQL$COMMIT (int *SQLCODE); extern void SQL$ROLLBACK(int *SQLCODE); extern void SQL$COMMIT_DEF (int *SQLCODE, DDTM$HANDLE_TYPE *handle); extern void SQL$ROLLBACK_DEF(int *SQLCODE, DDTM$HANDLE_TYPE *handle); extern void SQL$COMMIT_TH (int *SQLCODE, DDTM$HANDLE_TYPE *handle); extern void SQL$ROLLBACK_TH (int *SQLCODE, DDTM$HANDLE_TYPE *handle); /* * DDTM support routines */ extern void SQL$CHECK_TH(int *SQLCODE, DDTM$HANDLE_TYPE *handle); extern void SQL$START_TH(int *SQLCODE, DDTM$HANDLE_TYPE *handle); extern void SQL$START_DEF_TID (int *SQLCODE, DDTM$HANDLE_TYPE *handle, void *distributed_trans_id); extern void SQL$START_TH_TID (int *SQLCODE, DDTM$HANDLE_TYPE *handle, void *distributed_trans_id); /* These routines check a transaction handle to insure that it is valid and that a transaction has been started. If no transaction has been started, RE_START_TH will start a transaction. RE_CHECK_TH_ERR will not start a transaction but set an error code instead. */ extern void SQL$CHECK_TH_ERR (int *SQLCODE, DDTM$HANDLE_TYPE *handle); extern void SQL$RE_START_TH (int *SQLCODE, DDTM$HANDLE_TYPE *handle); /********************************/ /* SQL$ERROR_ABORT */ /********************************/ /* Called when an SQL-ML procedure returns an abnormal status code and no ON ERROR block exists to handle the error. */ extern void SQL$ERROR_ABORT(void);