10 #if defined( INC_ALL )
30 #ifdef USE_DATABASE_PLUGIN
67 connectInfo.name = bufPtr;
69 &connectInfo, dbmsInfo->errorMessage,
70 &dbmsInfo->errorCode );
73 netEncodeError( buffer, status );
79 status = swrite( &dbmsInfo->stream, buffer,
102 sNetDisconnect( &dbmsInfo->stream );
105 netEncodeError( buffer, status );
109 int initDispatchNet(
DBMS_INFO *dbmsInfo )
129 void odbcProcessCommand(
void *stateInfo,
BYTE *buffer );
130 #define initDispatchODBC( dbmsInfo ) \
131 ( dbmsInfo->dispatchFunction = odbcProcessCommand ) != NULL
133 #define initDispatchODBC( dbmsInfo ) CRYPT_ERROR
135 #if defined( USE_DATABASE )
136 void databaseProcessCommand(
void *stateInfo,
BYTE *buffer );
137 #define initDispatchDatabase( dbmsInfo ) \
138 ( dbmsInfo->dispatchFunction = databaseProcessCommand ) != NULL
140 #define initDispatchDatabase( dbmsInfo ) CRYPT_ERROR
142 #ifdef USE_DATABASE_PLUGIN
143 int initDispatchNet(
DBMS_INFO *dbmsInfo );
145 #define initDispatchNet( dbmsInfo ) CRYPT_ERROR
151 #if MAX_SQL_QUERY_SIZE + 256 >= DBX_IO_BUFSIZE
152 #error Database RPC buffer size is too small, increase DBX_IO_BUFSIZE and rebuild
157 static int dispatchCommand(
COMMAND_INFO *cmd,
void *stateInfo,
164 ( cmd->
noStrArgs * COMMAND_WORDSIZE ) + \
165 cmd->strArgLen[ 0 ] + cmd->
strArgLen[ 1 ] + \
171 assert( dispatchFunction != NULL );
181 for( i = 0; i < sentCmd.
noArgs; i++ )
188 const int argLength = sentCmd.
strArgLen[ i ];
192 memcpy( bufPtr + COMMAND_WORDSIZE, sentCmd.
strArg[ i ],
194 bufPtr += COMMAND_WORDSIZE + argLength;
199 dispatchFunction( stateInfo, buffer );
217 for( i = 0; i < cmd->
noArgs; i++ )
226 bufPtr += COMMAND_WORDSIZE + cmd->
strArgLen[ i ];
232 return( cmd->
arg[ 0 ] );
234 for( i = 1; i < cmd->
noArgs; i++ )
235 cmd->
arg[ i - 1 ] = cmd->
arg[ i ];
258 const char *command,
const void *boundData,
259 const int boundDataLength,
const time_t boundDate,
266 if( command != NULL )
268 cmd->
strArg[ 0 ] = (
void * ) command;
274 assert(
sizeof( time_t ) <= 4 );
278 memset( encodedDate, 0, 8 );
280 encodedDate[ 3 ] = (
BYTE )( ( boundDate >> 32 ) & 0xFF );
282 encodedDate[ 4 ] = (
BYTE )( ( boundDate >> 24 ) & 0xFF );
283 encodedDate[ 5 ] = (
BYTE )( ( boundDate >> 16 ) & 0xFF );
284 encodedDate[ 6 ] = (
BYTE )( ( boundDate >> 8 ) & 0xFF );
285 encodedDate[ 7 ] = (
BYTE )( ( boundDate ) & 0xFF );
287 cmd->
strArg[ argIndex ] = encodedDate;
290 if( boundData != NULL )
294 memcpy( dbmsInfo->
boundData, boundData, boundDataLength );
297 cmd->
strArgLen[ argIndex++ ] = boundDataLength;
305 static int openDatabase(
DBMS_INFO *dbmsInfo,
const char *
name,
306 const int nameLength,
const int options,
319 cmd.
strArg[ 0 ] = (
void * ) name;
323 ( cmd.
arg[ 0 ] & DBMS_HAS_BINARYBLOBS ) )
328 static void closeDatabase(
DBMS_INFO *dbmsInfo )
341 static void performErrorQuery(
DBMS_INFO *dbmsInfo )
352 dbmsInfo->errorCode = 0;
356 cmd.
strArg[ 0 ] = dbmsInfo->errorMessage;
361 dbmsInfo->errorCode = cmd.
arg[ 0 ];
362 dbmsInfo->errorMessage[ cmd.
strArgLen[ 0 ] ] =
'\0';
366 static int performUpdate(
DBMS_INFO *dbmsInfo,
const char *command,
367 const void *boundData,
const int boundDataLength,
368 const time_t boundDate,
374 BYTE encodedDate[ 8 + 8 ];
388 initQueryData( &cmd, &cmdTemplate, encodedDate, dbmsInfo, command,
389 boundData, boundDataLength, boundDate, updateType );
392 performErrorQuery( dbmsInfo );
405 static int performStaticUpdate(
DBMS_INFO *dbmsInfo,
const char *command )
407 return( performUpdate( dbmsInfo, command, NULL, 0, 0,
411 static int performQuery(
DBMS_INFO *dbmsInfo,
const char *command,
413 const int queryDataLength,
const time_t queryDate,
420 BYTE encodedDate[ 8 + 8 ];
424 assert( ( data == NULL && dataLength == NULL ) || \
426 assert( ( queryData == NULL && queryDataLength == 0 ) || \
427 ( queryDataLength > 0 && \
428 isReadPtr( queryData, queryDataLength ) ) );
449 memset( data, 0, 16 );
454 argIndex = initQueryData( &cmd, &cmdTemplate, encodedDate, dbmsInfo,
455 command, queryData, queryDataLength,
456 queryDate, queryType );
457 cmd.
arg[ 1 ] = queryEntry;
464 performErrorQuery( dbmsInfo );
474 if( dataLength != NULL )
479 assert( NOTREACHED );
480 memset( data, 0, 16 );
488 static int performStaticQuery(
DBMS_INFO *dbmsInfo,
const char *command,
492 return( performQuery( dbmsInfo, command, NULL, NULL, NULL, 0, 0,
493 queryEntry, queryType ) );