home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 January
/
Chip_1997-01_cd.bin
/
ms95
/
disk21
/
dir01
/
f010910.re_
/
f010910.re
Wrap
Text File
|
1996-04-02
|
25KB
|
755 lines
/*----------------------------------------------------------------------+
| |
| Copyright (c) 1985-93; Bentley Systems, Inc., All rights reserved. |
| |
| "MicroStation", "MDL", and "MicroCSL" are trademarks of Bentley |
| Systems, Inc. |
| |
| Limited permission is hereby granted to reproduce and modify this |
| copyrighted material provided that the resulting code is used only |
| in conjunction with Bentley Systems products under the terms of the |
| license agreement provided therein, and that this notice is retained |
| in its entirety in any such reproduction or modification. |
| |
+----------------------------------------------------------------------*/
/*----------------------------------------------------------------------+
| |
| database.h -- database definitions |
| |
| $Workfile: database.h $
| $Revision: 6.6 $
| $Date: 02 Nov 1995 01:14:44 $
| |
+----------------------------------------------------------------------*/
#ifndef __databaseH__
#define __databaseH__
#ifndef __msdefsH__
#include "msdefs.h"
#endif
#ifndef __dbdefsH__
#include "dbdefs.h"
#endif
/*----------------------------------------------------------------------+
| |
| Defines |
| |
+----------------------------------------------------------------------*/
#define DB_PACKET_SIZE 2048 /* the packet size for the DB IPC */
#define DB_MORE_PACKETS 1
#define DB_LAST_PACKET 2
#define DB_DATABASE_NAME_SIZE 64 /* size of a database name */
#define DB_TABLE_NAME_SIZE MAX_TABLE_LENGTH
/* size of a database table name */
#define DB_COLUMN_NAME_SIZE MAX_COLUMN_LENGTH
/* size of a database column name */
#define DB_FORM_EXT 10
#define VAR_STRING 0
#define VAR_NAME_STRING 1
#define CHARACTER_DATA 0 /* DEFAULT, return data in character form */
#define RAW_DATA 1 /* do not coerce to character, return raw data */
#define MAX_OPEN_CURSORS 10
#define MAX_ERROR_LENGTH 512 /* max length for error return strings */
#define SQL_LOOKUP -100 /* SQL error; look in errorInformation */
#define MAX_ENV_VAR_LENGTH 512 /* max length for value in an EnvVarRequest */
#define DB_COPY_TABLE_LENGTH 2048 /* length of the sql statement in a copy table */
#define DB_MAX_TYPE_LENGTH 128 /* max size for sql stmt in extract stmt type */
/* To insure that space is not always dynamically allocated (calloc) buffers in */
/* the IPC and SQL modules are allocated of the stack with the size below */
#define DB_DEFAULT_BUFFER_SIZE 2048
/* if default was not enough and total additional space is not known, the below */
/* amount of additonal space will be realloced */
#define DB_BUFFER_REALLOC_SIZE 2048
/* sql buffer realloc size, only for the dynamic sql buffer reallocation */
#define DB_SQLBUF_REALLOC_SIZE 256
/*----------------------------------------------------------------------+
| |
| Miscellaneous |
| |
+----------------------------------------------------------------------*/
/* database server types */
#define XBASE_SERVER 1
#define ORACLE_SERVER 2
#define ORACLE_STD_SERVER ORACLE_SERVER
#define ORACLE_DOS_SERVER 3
#define ORACLE_WIN_SERVER 4
#define INFORMIX_SERVER 5
#define RIS_SERVER 6
#define ODBC_SERVER 7
#define WINCON_SERVER ORACLE_WIN_SERVER
#define UNKNOWN_SERVER 8
/* ODBC database type defines */
#define ODBC_UNKNOWN 1
#define ODBC_FLATFILE 2
#define ODBC_ORACLE 3
#define ODBC_INFORMIX 4
#define ODBC_ACCESS 5
#define ODBC_SQLSERVER 6
#define ODBC_SYBASE 7
/* flat file database definitions */
#define ODBC_BF_DBASE (0x00000001 << 0)
#define ODBC_BF_BTRIEVE (0x00000001 << 1)
#define ODBC_BF_PARADOX (0x00000001 << 2)
#define ODBC_BF_EXCEL (0x00000001 << 3)
#define ODBC_BF_TEXT (0x00000001 << 4)
/* return values for preprocess step */
#define NOT_HANDLED 1
#define NOT_ORACLE_MSDOS (!(serverType == ORACLE_DOS_SERVER))
#define ORACLE_DOS (serverType == ORACLE_DOS_SERVER)
#define DB_USES_WINCON (serverType == WINCON_SERVER)
typedef struct allocdstmt
{
char *stmt;
int stmtLength;
int callocdLength;
char buffer[DB_DEFAULT_BUFFER_SIZE];
} AllocdStmt;
/*----------------------------------------------------------------------+
| |
| External server debug defines |
| |
+----------------------------------------------------------------------*/
#define DEBUG_ON (0x0001 << 0)
#define EXT_DEBUG_ON (0x0001 << 1)
#define IPC_DEBUG_ON (0x0001 << 2)
/*----------------------------------------------------------------------+
| |
| IPC service requests. |
| |
+----------------------------------------------------------------------*/
#define IPC_RegisterHandler 1
/*----------------------------------------------------------------------+
| |
| Message fields. |
| |
+----------------------------------------------------------------------*/
#define DBFORM_DAS 1
#define DBFORM_EDITAE 2
#define DBFORM_REVIEW 3
#define DBFORM_FORMCMD 4
/*----------------------------------------------------------------------+
| |
| Message fields. |
| |
+----------------------------------------------------------------------*/
#define FIELD_Status 1
#define FIELD_Error 2
#define FIELD_Message 3
#define FIELD_DebugWindow 4
/*----------------------------------------------------------------------+
| |
| SQL statement types. |
| |
+----------------------------------------------------------------------*/
#define DB_MALFORMED_STMT 1
#define DB_UNKNOWN_STMT 2
#define DB_SELECT_STMT 3
#define DB_UPDATE_STMT 4
#define DB_CONNECT_STMT 5
#define DB_DISCONNECT_STMT 6
#define DB_SQLFORMS_STMT 7
#define DB_RELOAD_STMT 8
#define DB_INSERT_STMT 9
#define DB_COMMIT_STMT 10
#define DB_ROLLBACK_STMT 11
#define DB_HANDLES_STMT 12
#define DB_DELETE_STMT 13
/*----------------------------------------------------------------------+
| |
| Cursor IDs |
| |
+----------------------------------------------------------------------*/
#define DB_CURSOR_ID_0 0
#define DB_CURSOR_ID_1 1
#define DB_CURSOR_ID_2 2
#define DB_CURSOR_ID_3 3
#define DB_CURSOR_ID_4 4
#define DB_CURSOR_ID_5 5
#define DB_CURSOR_ID_6 6
#define DB_CURSOR_ID_7 7
#define DB_CURSOR_ID_8 8
#define DB_CURSOR_ID_9 9
#define DB_DESRIBE_SQLDA 10 /* the sqlda used in a describe */
/*----------------------------------------------------------------------+
| |
| Message types. |
| |
+----------------------------------------------------------------------*/
#define MTYPE_ServiceRequest 1
#define MTYPE_ServiceRequestMore 2 /* one of many service requests */
#define MTYPE_ServiceRequestLast 3 /* last service request */
#define MTYPE_ServiceAcknowledge 4
#define MTYPE_ServiceAcknowledgeMore 5 /* one of many service acks with data */
#define MTYPE_ServiceAcknowledgeLast 6 /* last service ack with data */
#define MTYPE_ServiceAcknowledgeNoData 7 /* a service ack without data */
#define MTYPE_CallBackRequest 8
#define MTYPE_CallBackAcknowledge 9
/*----------------------------------------------------------------------+
| |
| Database service requests. |
| |
+----------------------------------------------------------------------*/
#define DS_DatabaseProfile 1
#define DS_OpenDatabase 2
#define DS_CloseDatabase 3
#define DS_Terminate 4
#define DS_DescribeDatabase 5
#define DS_DescribeTable 6
#define DS_DescribeColumn 7
#define DS_CommitTransaction 8
#define DS_RollbackTransaction 9
#define DS_ProcessStatement 10
#define DS_OpenCursor 11
#define DS_FetchRow 12
#define DS_CloseCursor 13
#define DS_ProcessForm 14
#define DS_GetErrorInformation 15
#define DS_AdditionalRequest 16
#define DS_DebugMode 17
#define DS_CopyTable 18
#define DS_LockTable 19
#define DS_SetAE 20 /* server to loader only */
#define DS_CreateDABuffer 21 /* Note: NEW Msg, not in Betas */
#define DS_SetMsforms 22 /* server to loader only */
/*----------------------------------------------------------------------+
| |
| CallBack requests. |
| |
+----------------------------------------------------------------------*/
#define CALLBACK_DebugMessage 1
#define CALLBACK_EnvVarRequest 2
#define CALLBACK_GetXbaseName 3
#define CALLBACK_SendPID 4
#define CALLBACK_MSWindowPriority 5
#define CALLBACK_FindDBFile 6
/*----------------------------------------------------------------------+
| |
| Additional request (AR) defines. Used with DS_AdditionalRequest. |
| |
+----------------------------------------------------------------------*/
#define AR_MaxMSLink 1
#define AR_CopyRowToAE 2
#define AR_CopyRowToReport 3
#define AR_SimpleSelect 4
#define AR_OpenCursorXbase 5
#define AR_FetchRowXbase 6
#define AR_CloseCursorXbase 7
/*----------------------------------------------------------------------+
| |
| Additional request (AR) structure typedefs. |
| |
+----------------------------------------------------------------------*/
typedef struct maxmslink
{
long requestType; /* The AR request type */
ULong maxMSLink; /* the max mslink in the table */
char tableName[DB_TABLE_NAME_SIZE]; /* table name to get max mslink from */
} MaxMSLink;
/* for Xbase performance improvements */
typedef struct copyrowtoaerequest
{
long requestType;
ULong *mslinkP;
char *whereValue;
char *whereFieldName;
char *sourceTableName;
char *destTableName;
char *query;
boolean zeroMslink;
} CopyRowToAERequest;
/* for Xbase performance improvements */
typedef struct copyrowtoreportrequest
{
long requestType;
long mslink;
char *sourceTableName;
char *destTableName;
} CopyRowToReportRequest;
/* for Xbase performance improvements */
typedef struct simpleselectar
{
long requestType;
long resultSize;
long numValues;
boolean breakResult;
char ***brokenResult;
char *result;
MS_sqlda *sqlda;
char *stmt;
boolean isMalloced;
} SimpleSelectAR;
/* for Xbase performance improvements */
typedef struct opencursorxbasear
{
long requestType;
char *stmt;
boolean getColInfo;
boolean isMalloced;
} OpenCursorXbaseAR;
/* for Xbase performance improvements */
typedef struct fetchrowxbasear
{
long requestType;
MS_sqlda *sqldaP;
} FetchRowXbaseAR;
/* for Xbase performance improvements */
typedef struct closecursorxbasear
{
long requestType;
} CloseCursorXbaseAR;
/*----------------------------------------------------------------------+
| |
| IPC typedefs. |
| |
+----------------------------------------------------------------------*/
typedef struct databaseservicehandler
{
char taskID[64]; /* name of task */
void *mdlFileDescr; /* mdl application handing requests */
ULong functionOffset; /* entry point in this application */
} DatabaseServiceHandler;
typedef struct ipcservice
{
ULong type; /* type of request */
DatabaseServiceHandler handler; /* service handler */
} IPCService;
typedef struct servicename
{
char *name; /* name of database service */
ULong type; /* service code */
} ServiceName;
/*----------------------------------------------------------------------+
| |
| Service name table. |
| |
+----------------------------------------------------------------------*/
#if defined (GLOBAL_DEFINITIONS)
ServiceName serviceNameTable[]=
{
{"DS_DatabaseProfile", DS_DatabaseProfile},
{"DS_OpenDatabase", DS_OpenDatabase},
{"DS_CloseDatabase", DS_CloseDatabase},
{"DS_Terminate", DS_Terminate},
{"DS_DescribeDatabase", DS_DescribeDatabase},
{"DS_DescribeTable", DS_DescribeTable},
{"DS_DescribeColumn", DS_DescribeColumn},
{"DS_CommitTransaction", DS_CommitTransaction},
{"DS_RollbackTransaction", DS_RollbackTransaction},
{"DS_ProcessStatement", DS_ProcessStatement},
{"DS_OpenCursor", DS_OpenCursor},
{"DS_FetchRow", DS_FetchRow},
{"DS_CloseCursor", DS_CloseCursor},
{"DS_ProcessForm", DS_ProcessForm},
{"DS_GetErrorInformation", DS_GetErrorInformation},
{"DS_AdditionalRequest", DS_AdditionalRequest},
{"DS_DebugMode", DS_DebugMode},
{"DS_CopyTable", DS_CopyTable},
{"DS_LockTable", DS_LockTable},
{"DS_SetAE", DS_SetAE},
{"DS_CreateDABuffer", DS_CreateDABuffer},
{"DS_SetMsforms", DS_SetMsforms}
};
#endif
/*----------------------------------------------------------------------+
| |
| Service requests. |
| |
+----------------------------------------------------------------------*/
typedef struct brandprofile
{
char brandName[32]; /* name of brand (Oracle, dBASE, ...) */
char serverName[32]; /* name of the database server executable */
char version[32]; /* version of database */
long odbcDBType; /* ODBC underlying database type */
} BrandProfile;
typedef struct accessprofile
{
long hostnameRequired; /* host name required for login */
long usernameRequired; /* user name required for login */
long passwordRequired; /* password required for login */
long optionString; /* option string supported */
} AccessProfile;
typedef struct datatype
{
long supported; /* data type supported */
char name[32]; /* vendor name */
} DataType;
typedef struct datatypeprofile
{
DataType charType; /* CHAR (n); fixed length */
DataType varcharType; /* VARCHAR (n); variable length */
DataType floatType; /* REAL; single precision*/
DataType doubleType; /* DOUBLE; double precision */
DataType intType; /* INTEGER; 32 bit integer */
DataType shortType; /* SMALLINT; 16 bit integer */
DataType numericType; /* NUMERIC (p, s); fixed point */
DataType decimalType; /* DECIMAL (p, s); fixed point */
DataType dateType; /* DATE */
DataType timeType; /* TIME */
DataType datetimeType; /* DATETIME; absolute (date + time) */
DataType intervalType; /* INTERVAL; delta (date + time) */
DataType rawType; /* RAW (n); binary data; */
DataType booleanType; /* BOOLEAN; logical */
DataType nationalType; /* NCHAR; national character string */
DataType rowid; /* ROWID; pseudo column primary key */
} DataTypeProfile;
typedef struct functionprofile
{
long max; /* min () function supported */
long min; /* max () function supported */
long count; /* count () function supported */
long sum; /* sum () function supported */
long avg; /* avg () function supported */
} FunctionProfile;
typedef struct transactionprofile
{
long supported; /* transactions supported */
} TransactionProfile;
typedef struct formsprofile
{
long supported; /* screen forms supported */
long fileOutput; /* can generate text file output */
char fileExt[DB_FORM_EXT]; /* file extension for forms, .frm .fmt */
} FormsProfile;
typedef struct graphicsprofile
{
UShort primarySignature; /* priamry user data signature */
UShort secondarySignature; /* secondary user data signature */
long saveAccessString; /* saved in design file */
long applicationLevel; /* level for access string */
} GraphicsProfile;
typedef struct sqlprofile
{
long ANSICompatible;
} SQLProfile;
typedef struct databaseprofile
{
BrandProfile brand; /* brand of RDBMS */
AccessProfile accessProfile; /* access method */
DataTypeProfile types; /* supported data types */
SQLProfile sql; /* SQL support and extensions */
FunctionProfile functions; /* aggregate function support */
TransactionProfile transactions; /* transaction support */
FormsProfile forms; /* screen forms support */
GraphicsProfile graphics; /* design file parameters */
} DatabaseProfile;
typedef struct opendatabase
{
char text[512]; /* the text of the open request */
} OpenDatabase;
typedef struct describedatabase
{
long descriptionLength;
char *description;
} DescribeDatabase;
typedef struct describetable
{
long descriptionLength;
char *description;
char tableName[DB_TABLE_NAME_SIZE];
} DescribeTable;
typedef struct describecolumn
{
char tableName[DB_TABLE_NAME_SIZE];
ColumnDescr columnDescr;
} DescribeColumn;
typedef struct processstatement
{
long statementLength;
char *statement;
} ProcessStatement;
typedef struct opencursor
{
long descriptionLength;
char *description;
long cursorID;
} OpenCursor;
typedef struct fetchrow
{
long rowLength; /* <= length of data */
char *row; /* <= the row that was fetched */
long cursorID; /* => the ID of the cursor to fetch from */
short returnDataType; /* => type of data to return, char or raw */
} FetchRow;
typedef struct closecursor
{
long cursorID; /* => the ID of the cursor to close */
} CloseCursor;
typedef struct processform
{
char arguments[256];
char formName[256];
char tableName[64];
char dosWindow[8];
long textMode;
long noStdOut;
} ProcessForm;
typedef struct errorinformation
{
long code; /* <=> SQL error code */
char message[MAX_ERROR_LENGTH]; /* <= text of error message */
} ErrorInformation;
typedef struct additionalrequest
{
long requestLength; /* <=> Length of text */
char *request; /* <=> The text of developer supplied request */
} AdditionalRequest;
typedef struct debugmode
{
long mode; /* => The new debug mode */
} DebugMode;
typedef struct copytable
{
char fromTableName[DB_TABLE_NAME_SIZE]; /* The table name to copy from */
char toTableName[DB_TABLE_NAME_SIZE]; /* The table name to copy to */
} CopyTable;
typedef struct locktable
{
char tableName[DB_TABLE_NAME_SIZE]; /* The table name to lock */
} LockTable;
/* The following request is only used for communication between
server.ma and dbload.ma - it never reachs the external server
*/
typedef struct setae
{
char aeTableName[DB_TABLE_NAME_SIZE];
} SetAE;
/* The following request is new for the Version 5 release of the toolkit
(3/94). It was not present in the Beta versions of the toolkit.
Database developers must handle this message if the server needs to work
with Displayable Attributes in Forms mode
*/
typedef struct createdabuffer
{
long numLines; /* <= # lines to read from frm file */
char dasFormFile[MAXFILELENGTH]; /* => the form name */
/* <= the qualified path name to */
/* the DAS form output file */
} CreateDABuffer;
/* The following request is only used for communication between
server.ma and dbload.ma - it never reachs the external server
*/
typedef struct setmsforms
{
char msformsTableName[DB_TABLE_NAME_SIZE];
} SetMsforms;
/*----------------------------------------------------------------------+
| |
| Service message. |
| |
+----------------------------------------------------------------------*/
typedef struct serviceheader
{
long status; /* <= return status */
ULong type; /* => type of request */
ULong length; /* <=> length of message */
long isCallocd; /* <= whether memory in structure was calloc'd */
long callocdLength; /* <= if isCallocd, this is the new size */
long databaseID; /* => id of target database (FUTURE EXPANSION) */
} ServiceHeader;
typedef struct databaseservice
{
ServiceHeader header; /* <=> message header */
union
{
DatabaseProfile databaseProfile;
OpenDatabase openDatabase;
DescribeDatabase describeDatabase;
DescribeTable describeTable;
DescribeColumn describeColumn;
ProcessStatement processStatement;
OpenCursor openCursor;
FetchRow fetchRow;
CloseCursor closeCursor;
ProcessForm processForm;
ErrorInformation errorInformation;
AdditionalRequest additionalRequest;
DebugMode debugMode;
CopyTable copyTable;
LockTable lockTable;
SetAE setAE;
CreateDABuffer createDABuffer;
SetMsforms setMsforms;
} u;
} DatabaseService;
typedef struct requestwithptr
{
ServiceHeader header;
long length;
char *data;
long cursorID;
} RequestWithPtr;
typedef struct bufferwithoutptr
{
long bufferLength;
ServiceHeader header;
long length;
char data[1];
} BufferWithoutPtr;
typedef struct bufferwithcursorid
{
long bufferLength;
ServiceHeader header;
long length;
long cursorID;
char data[1];
} BufferWithCursorID;
typedef struct bufferwithlength
{
long bufferLength;
char data[1];
} BufferWithLength;
/*----------------------------------------------------------------------+
| |
| CallBack requests. |
| |
+----------------------------------------------------------------------*/
typedef struct statusmessage
{
long field; /* <= field for message output */
char string[512]; /* <= user message */
} StatusMessage;
typedef struct envvarrequest
{
char variable[64]; /* <= environment variable */
char value[MAX_ENV_VAR_LENGTH]; /* => value of environment variable */
} EnvVarRequest;
typedef struct xbasenamerequest
{
char name[MAXFILELENGTH]; /* <=> databaseName */
} XbaseNameRequest;
typedef struct externalpid
{
ProcessID pid; /* <= process ID of external Server */
} ExternalPID;
typedef struct mswindowpriority
{
boolean activePriority; /* <= MS window priority High T/F */
} MSWindowPriority;
typedef struct finddbfile
{
char fileName[MAXFILELENGTH]; /* <= file to find */
/* => path to file */
char fileExt[10]; /* => file Extension */
} FindDBFile;
/*----------------------------------------------------------------------+
| |
| CallBack message. |
| |
+----------------------------------------------------------------------*/
typedef struct callbackheader
{
long status; /* <=> return status */
ULong type; /* <=> type of request */
ULong length; /* <=> length of message */
} CallBackHeader;
typedef struct servercallback
{
CallBackHeader header; /* <=> message header */
union
{
StatusMessage message; /* <=> */
EnvVarRequest envVarRequest; /* <=> */
XbaseNameRequest xbaseNameRequest; /* <=> */
ExternalPID externalPID; /* <= no ack */
MSWindowPriority msWindowPriority; /* <=> */
FindDBFile findDBFile; /* <=> */
} u;
} ServerCallBack;
/*----------------------------------------------------------------------+
| |
| Descriptor message (mdl -> Server) |
| |
+----------------------------------------------------------------------*/
typedef struct
{
short columns;
short rows;
short items;
} ServerDescrMessageHdr;
typedef struct
{
ServerDescrMessageHdr hdr;
char data[1];
} ServerDescriptorMessage;
#endif