Update of /cvsroot/firebird/vulcan/src/jrd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31050/src/jrd Modified Files: Engine8.cpp Engine8.h InfoGen.cpp JString.cpp MsgFile.cpp MsgFile.h Service.cpp Service.h StatusPrint.cpp Subsystem.cpp Subsystem.h Sync.cpp gds.cpp gds_proto.h ibase.h jrd.cpp jrd.vcproj jrd_proto.h sdl.cpp svc.cpp svc.h svc_proto.h thd.h Added Files: MsgFormat.cpp MsgFormat.h Log Message: Work in progress on Services provider --- MsgFormat.cpp ADDED --- --- MsgFormat.h ADDED --- Index: Engine8.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/Engine8.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -b -U3 -r1.3 -r1.4 --- Engine8.cpp 5 Aug 2005 16:09:37 -0000 1.3 +++ Engine8.cpp 2 Sep 2005 19:11:10 -0000 1.4 @@ -73,7 +73,7 @@ const TEXT* translatedName, DbHandle *dbHandle, int dpbLength, - UCHAR* dpb, + const UCHAR* dpb, ConfObject* databaseConfiguration, ConfObject* providerConfiguration) { @@ -163,7 +163,7 @@ const TEXT* translatedName, DbHandle *dbHandle, int dpbLength, - UCHAR* dpb, + const UCHAR* dpb, int databaseType, ConfObject* databaseConfiguration, ConfObject* providerConfiguration) @@ -186,8 +186,8 @@ return exitSystem (jrd8_database_info (statusVector, (Attachment**) dbHandle, - itemLength, (const UCHAR*) items, - bufferLength, (UCHAR*) buffer)); + itemLength, items, + bufferLength, buffer)); } ISC_STATUS Engine8::detachDatabase(ISC_STATUS *statusVector, DbHandle *dbHandle ) @@ -217,14 +217,14 @@ bpb)); } -ISC_STATUS Engine8::prepareTransaction(ISC_STATUS *statusVector, TraHandle *traHandle, int msgLength, UCHAR* msg) +ISC_STATUS Engine8::prepareTransaction(ISC_STATUS *statusVector, TraHandle *traHandle, int msgLength, const UCHAR* msg) { enterSystem(); return exitSystem (jrd8_prepare_transaction (statusVector, (Transaction**) traHandle, msgLength, msg)); } -ISC_STATUS Engine8::reconnectTransaction(ISC_STATUS *statusVector, DbHandle *dbHandle, TraHandle *traHandle, int, UCHAR *) +ISC_STATUS Engine8::reconnectTransaction(ISC_STATUS *statusVector, DbHandle *dbHandle, TraHandle *traHandle, int, const UCHAR *) { return entrypointUnavailable (statusVector); } @@ -241,8 +241,8 @@ { return exitSystem (jrd8_request_info (statusVector, (Request**) reqHandle, level, - itemsLength, (const UCHAR*) items, - bufferLength, (UCHAR*) buffer)); + itemsLength, items, + bufferLength, buffer)); } ISC_STATUS Engine8::rollbackTransaction(ISC_STATUS *statusVector, TraHandle *traHandle ) @@ -283,7 +283,7 @@ level)); } -ISC_STATUS Engine8::startMultiple(ISC_STATUS *statusVector, TraHandle *traHandle, int count, teb *tebs) +ISC_STATUS Engine8::startMultiple(ISC_STATUS *statusVector, TraHandle *traHandle, int count, const teb *tebs) { enterSystem(); @@ -317,7 +317,7 @@ return entrypointUnavailable (statusVector); } -ISC_STATUS Engine8::executeDDL(ISC_STATUS *statusVector, DbHandle *dbHandle, TraHandle *traHandle, int ddlLength, UCHAR *ddl) +ISC_STATUS Engine8::executeDDL(ISC_STATUS *statusVector, DbHandle *dbHandle, TraHandle *traHandle, int ddlLength, const UCHAR *ddl) { enterSystem(); @@ -370,9 +370,9 @@ } ISC_STATUS Engine8::dsqlExecute (ISC_STATUS* userStatus, TraHandle *traHandle, DsqlHandle *dsqlHandle, - int inBlrLength, UCHAR *inBlr, - int inMsgType, int inMsgLength, UCHAR *inMsg, - int outBlrLength, UCHAR *outBlr, + int inBlrLength, const UCHAR *inBlr, + int inMsgType, int inMsgLength, const UCHAR *inMsg, + int outBlrLength, const UCHAR *outBlr, int outMsgType, int outMsgLength, UCHAR *outMsg) { enterSystem(); @@ -393,7 +393,10 @@ } ISC_STATUS Engine8::dsqlExecuteImmediate(ISC_STATUS *statusVector, DbHandle *dbHandle, TraHandle *traHandle, - int sqlLength, const char* sql, int dialect, int blrLength, UCHAR *blr, + int sqlLength, + const char* sql, + int dialect, + int blrLength, const UCHAR *blr, int msgType, int msgLength, UCHAR* msg) { return entrypointUnavailable (statusVector); @@ -401,9 +404,9 @@ ISC_STATUS Engine8::dsqlExecuteImmediate2(ISC_STATUS *statusVector, DbHandle *dbHandle, TraHandle *traHandle, int sqlLength, const char* sql, int dialect, - int inBlrLength, UCHAR *inBlr, - int inMsgType, int inMsgLength, UCHAR *inMsg, - int outBlrLength, UCHAR *outBlr, + int inBlrLength, const UCHAR *inBlr, + int inMsgType, int inMsgLength, const UCHAR *inMsg, + int outBlrLength, const UCHAR *outBlr, int outMsgType, int outMsgLength, UCHAR *outMsg) { enterSystem(); @@ -443,7 +446,7 @@ return exitSystem (ret); } -ISC_STATUS Engine8::dsqlInsert(ISC_STATUS *statusVector, DsqlHandle *dsqlHandle, int blrLength, UCHAR* blr, int msgType, int msgLength, const UCHAR* msg) +ISC_STATUS Engine8::dsqlInsert(ISC_STATUS *statusVector, DsqlHandle *dsqlHandle, int blrLength, const UCHAR* blr, int msgType, int msgLength, const UCHAR* msg) { return entrypointUnavailable (statusVector); } @@ -482,7 +485,7 @@ return exitSystem (statement->getSqlInfo (statusVector, itemsLength, items, bufferLength, buffer)); } -ISC_STATUS Engine8::serviceAttach(ISC_STATUS *statusVector, const TEXT *, SvcHandle *dbHandle, int, UCHAR*, +ISC_STATUS Engine8::serviceAttach(ISC_STATUS *statusVector, const TEXT *, SvcHandle *dbHandle, int, const UCHAR*, ConfObject* servicesConfiguration, ConfObject* providerConfiguration) { @@ -494,7 +497,7 @@ return entrypointUnavailable (statusVector); } -ISC_STATUS Engine8::serviceQuery(ISC_STATUS *statusVector, SvcHandle *dbHandle, int, UCHAR *, int, UCHAR *, int, UCHAR *) +ISC_STATUS Engine8::serviceQuery(ISC_STATUS *statusVector, SvcHandle *dbHandle, int, const UCHAR *, int, const UCHAR *, int, UCHAR *) { return entrypointUnavailable (statusVector); } Index: Engine8.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/Engine8.h,v retrieving revision 1.2 retrieving revision 1.3 diff -b -U3 -r1.2 -r1.3 --- Engine8.h 5 Aug 2005 16:09:37 -0000 1.2 +++ Engine8.h 2 Sep 2005 19:11:10 -0000 1.3 @@ -46,7 +46,7 @@ const TEXT* translatedName, DbHandle *dbHandle, int dpb_length, - UCHAR* dpb, + const UCHAR* dpb, int databaseType, ConfObject* databaseConfiguration, ConfObject* providerConfiguration); @@ -55,18 +55,18 @@ const TEXT* translatedName, DbHandle *dbHandle, int dpb_length, - UCHAR* dpb, + const UCHAR* dpb, ConfObject* databaseConfiguration, ConfObject* providerConfiguration); virtual ISC_STATUS databaseInfo(ISC_STATUS*, DbHandle *dbHandle, int, const UCHAR*, int, UCHAR*); virtual ISC_STATUS detachDatabase(ISC_STATUS*, DbHandle *dbHandle); virtual ISC_STATUS dropDatabase (ISC_STATUS*, DbHandle *dbHandle); - virtual ISC_STATUS startMultiple(ISC_STATUS *, TraHandle *traHandle, int, teb *); - virtual ISC_STATUS reconnectTransaction(ISC_STATUS*, DbHandle *dbHandle, TraHandle *traHandle, int, UCHAR*); + virtual ISC_STATUS startMultiple(ISC_STATUS *, TraHandle *traHandle, int, const teb *); + virtual ISC_STATUS reconnectTransaction(ISC_STATUS*, DbHandle *dbHandle, TraHandle *traHandle, int, const UCHAR*); virtual ISC_STATUS transactionInfo(ISC_STATUS* userStatus, TraHandle *traHandle, int itemsLength, const UCHAR* items, int bufferLength, UCHAR* buffer); - virtual ISC_STATUS prepareTransaction(ISC_STATUS*, TraHandle *traHandle, int msgLength, UCHAR* msg); + virtual ISC_STATUS prepareTransaction(ISC_STATUS*, TraHandle *traHandle, int msgLength, const UCHAR* msg); virtual ISC_STATUS commitRetaining(ISC_STATUS *, TraHandle *traHandle); virtual ISC_STATUS commitTransaction(ISC_STATUS*, TraHandle *traHandle); virtual ISC_STATUS rollbackRetaining(ISC_STATUS *, TraHandle *traHandle); @@ -113,38 +113,38 @@ int bufferLength, UCHAR *buffer); //virtual ISC_STATUS dsqlInsert(ISC_STATUS* userStatus, DsqlHandle *dsqlHandle, int dialect, XSQLDA *sqlda); - virtual ISC_STATUS dsqlInsert(ISC_STATUS* userStatus, DsqlHandle *dsqlHandle, int blrLength, UCHAR* blr, int msgType, int msgLength, const UCHAR* msg); + virtual ISC_STATUS dsqlInsert(ISC_STATUS* userStatus, DsqlHandle *dsqlHandle, int blrLength, const UCHAR* blr, int msgType, int msgLength, const UCHAR* msg); virtual ISC_STATUS dsqlFetch(ISC_STATUS* userStatus, DsqlHandle *dsqlHandle, int blrLength, const UCHAR* blr, int msgType, int msgLength, UCHAR* msg); //virtual ISC_STATUS dsqlExecuteImmediate2(ISC_STATUS*, DbHandle *dbHandle, TraHandle *traHandle, int, UCHAR*, int, int, UCHAR *, int, int, UCHAR *, int, UCHAR*, int, int, UCHAR*); virtual ISC_STATUS dsqlExecuteImmediate2(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int sqlLength, const char* sql, int dialect, - int inBlrLength, UCHAR *inBlr, - int inMsgType, int inMsgLength, UCHAR *inMsg, - int outBlrLength, UCHAR *outBlr, + int inBlrLength, const UCHAR *inBlr, + int inMsgType, int inMsgLength, const UCHAR *inMsg, + int outBlrLength, const UCHAR *outBlr, int outMsgType, int outMsgLength, UCHAR *outMsg); //virtual ISC_STATUS dsqlExecuteImmediate(ISC_STATUS*, DbHandle *dbHandle, TraHandle *traHandle, int, UCHAR*,int, int, UCHAR *, int, int, UCHAR*); virtual ISC_STATUS dsqlExecuteImmediate (ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, - int sqlLength, const char* sql, int dialect, int blrLength, UCHAR *blr, + int sqlLength, const char* sql, int dialect, int blrLength, const UCHAR *blr, int msgType, int msgLength, UCHAR* msg); virtual ISC_STATUS dsqlExecute (ISC_STATUS* userStatus, TraHandle *traHandle, DsqlHandle *dsqlHandle, - int inBlrLength, UCHAR *inBlr, - int inMsgType, int inMsgLength, UCHAR *inMsg, - int outBlrLength, UCHAR *outBlr, + int inBlrLength, const UCHAR *inBlr, + int inMsgType, int inMsgLength, const UCHAR *inMsg, + int outBlrLength, const UCHAR *outBlr, int outMsgType, int outMsgLength, UCHAR *outMsg); virtual ISC_STATUS dsqlExecute2(ISC_STATUS*, TraHandle *traHandle, DsqlHandle *dsqlHandle, int, UCHAR*,int, int, UCHAR*, int, UCHAR*, int, int,UCHAR*); virtual ISC_STATUS dsqlFreeStatement(ISC_STATUS *, DsqlHandle *dsqlHandle, int); virtual ISC_STATUS cancelOperation(ISC_STATUS *, DbHandle *dbHandle, int); - virtual ISC_STATUS serviceQuery(ISC_STATUS *, SvcHandle *dbHandle, int, UCHAR *, int, UCHAR *, int, UCHAR *); + virtual ISC_STATUS serviceQuery(ISC_STATUS *, SvcHandle *dbHandle, int, const UCHAR *, int, const UCHAR *, int, UCHAR *); virtual ISC_STATUS serviceDetach(ISC_STATUS *, SvcHandle *dbHandle); - virtual ISC_STATUS serviceAttach(ISC_STATUS *, const TEXT *, SvcHandle *dbHandle, int, UCHAR*, + virtual ISC_STATUS serviceAttach(ISC_STATUS *, const TEXT *, SvcHandle *dbHandle, int, const UCHAR*, ConfObject* servicesConfiguration, ConfObject* providerConfiguration); virtual ISC_STATUS transactRequest(ISC_STATUS*, DbHandle *dbHandle, TraHandle *traHandle, int, UCHAR*,int, UCHAR*, int, UCHAR*); - virtual ISC_STATUS executeDDL(ISC_STATUS*, DbHandle *dbHandle, TraHandle *traHandle, int, UCHAR*); + virtual ISC_STATUS executeDDL(ISC_STATUS*, DbHandle *dbHandle, TraHandle *traHandle, int, const UCHAR*); virtual const TEXT* getDescription(); Index: InfoGen.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/InfoGen.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -b -U3 -r1.3 -r1.4 --- InfoGen.cpp 4 Aug 2005 19:00:31 -0000 1.3 +++ InfoGen.cpp 2 Sep 2005 19:11:10 -0000 1.4 @@ -7,7 +7,6 @@ #include "firebird.h" #include "InfoGen.h" #include "ibase.h" -#include ".\infogen.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction Index: JString.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/JString.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -b -U3 -r1.1.1.1 -r1.2 --- JString.cpp 20 Jan 2005 19:22:44 -0000 1.1.1.1 +++ JString.cpp 2 Sep 2005 19:11:10 -0000 1.2 @@ -184,7 +184,8 @@ va_start (args, stuff); char temp [1024]; - vsprintf (temp, stuff, args); + //vsprintf (temp, stuff, args); + int length = vsnprintf (temp, sizeof (temp) - 1, stuff, args); setString (temp); } Index: MsgFile.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/MsgFile.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -b -U3 -r1.2 -r1.3 --- MsgFile.cpp 18 Apr 2005 20:45:59 -0000 1.2 +++ MsgFile.cpp 2 Sep 2005 19:11:10 -0000 1.3 @@ -107,6 +107,7 @@ int MsgFile::openMsgFile(const char* filename) { + fileName = filename; msg_file = ::open(filename, O_RDONLY | O_BINARY, 0); if (msg_file < 0) Index: MsgFile.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/MsgFile.h,v retrieving revision 1.3 retrieving revision 1.4 diff -b -U3 -r1.3 -r1.4 --- MsgFile.h 18 Apr 2005 20:45:59 -0000 1.3 +++ MsgFile.h 2 Sep 2005 19:11:10 -0000 1.4 @@ -5,8 +5,10 @@ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 + #include "Sync.h" #include "SyncObject.h" +#include "JString.h" START_NAMESPACE @@ -25,6 +27,7 @@ USHORT msg_bucket_size; USHORT msg_levels; UCHAR *msg_bucket; + JString fileName; }; END_NAMESPACE Index: Service.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/Service.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -b -U3 -r1.5 -r1.6 --- Service.cpp 5 Aug 2005 16:09:37 -0000 1.5 +++ Service.cpp 2 Sep 2005 19:11:10 -0000 1.6 @@ -22,7 +22,7 @@ svc_stdout = NULL; svc_argv = NULL; svc_service = NULL; - svc_switches = NULL; + svc_argv_strings = NULL; svc_stdout_head = 0; svc_stdout_tail = 0; @@ -37,7 +37,9 @@ Service::~Service() { - + delete [] svc_stdout; + delete [] svc_argv; + delete [] svc_argv_strings; } void Service::setEncryptedPassword(const char* password) @@ -56,3 +58,25 @@ { return configuration->getValue("SecurityDatabase", "security.fdb"); } + +TEXT** Service::allocArgv(int count) +{ + delete svc_argv; + svc_argc = count; + svc_argv = new TEXT*[count + 1]; + + return svc_argv; +} + +TEXT* Service::setArgvStrings(const TEXT* string) +{ + delete [] svc_argv_strings; + svc_argv_strings = new char [strlen(string) + 1]; + strcpy (svc_argv_strings, string); + + return svc_argv_strings; +} + +void Service::svc_started(void) +{ +} Index: Service.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/Service.h,v retrieving revision 1.5 retrieving revision 1.6 diff -b -U3 -r1.5 -r1.6 --- Service.h 5 Aug 2005 16:09:37 -0000 1.5 +++ Service.h 2 Sep 2005 19:11:10 -0000 1.6 @@ -9,11 +9,12 @@ #pragma once #endif // _MSC_VER > 1000 -#include "../jrd/jrd_blks.h" -#include "../include/fb_blk.h" +//#include "../jrd/jrd_blks.h" +//#include "../include/fb_blk.h" #include "AsyncEvent.h" #include "JString.h" #include "TempSpace.h" +#include "thd.h" #ifndef MAX_PASSWORD_ENC_LENGTH #define MAX_PASSWORD_ENC_LENGTH 12 @@ -28,11 +29,12 @@ #define SVC_finished 16 #define SVC_thd_running 32 #define SVC_evnt_fired 64 +#define SVC_cmd_line 128 class Service; CLASS(ConfObject); -typedef int (*pfn_svc_main) (Service*); +//typedef int (*pfn_svc_main) (Service*); typedef int (*pfn_svc_output)(Service*, const UCHAR*); struct serv @@ -41,7 +43,8 @@ const TEXT* serv_name; const TEXT* serv_std_switches; const TEXT* serv_executable; - pfn_svc_main serv_thd; + //pfn_svc_main serv_thd; + ThreadEntryPoint* serv_thd; BOOLEAN* in_use; }; @@ -53,14 +56,15 @@ Service(ConfObject *configuration); virtual ~Service(); ISC_STATUS svc_status[ISC_STATUS_LENGTH]; - HANDLE svc_handle; /* "handle" of process/thread running service */ - HANDLE svc_input; /* input to service */ - HANDLE svc_output; /* output from service */ + SLONG svc_handle; /* "handle" of process/thread running service */ + void* svc_input; /* input to service */ + void* svc_output; /* output from service */ ULONG svc_stdout_head; ULONG svc_stdout_tail; UCHAR* svc_stdout; - TEXT** svc_argv; ULONG svc_argc; + TEXT** svc_argv; + TEXT* svc_argv_strings; AsyncEvent svc_start_event[1]; /* fired once service has started successfully */ const serv* svc_service; //UCHAR* svc_resp_buf; @@ -74,7 +78,7 @@ BOOLEAN svc_do_shutdown; //TEXT svc_enc_password[MAX_PASSWORD_ENC_LENGTH]; TEXT svc_reserved[1]; - TEXT* svc_switches; + JString svc_switches; JString encryptedPassword; JString userName; ConfObject *configuration; @@ -82,6 +86,9 @@ void setEncryptedPassword(const char* password); void setPassword(const char * password); const char* getSecurityDatabase(void); + TEXT** allocArgv(int count); + TEXT* setArgvStrings(const TEXT* string); + void svc_started(void); }; Index: StatusPrint.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/StatusPrint.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -b -U3 -r1.2 -r1.3 --- StatusPrint.cpp 18 Apr 2005 20:45:59 -0000 1.2 +++ StatusPrint.cpp 2 Sep 2005 19:11:10 -0000 1.3 @@ -56,7 +56,8 @@ { const ISC_STATUS *vector = *vectorPtr; - if (vector[0] == isc_arg_tkts_error) vector += 2; + if (vector[0] == isc_arg_tkts_error) + vector += 2; if (!*vector) return 0; @@ -98,8 +99,10 @@ int l = (int) *v++; const char *q = (const char*) *v++; *arg++ = p; + for (; p < endTemp && l > 0; --l) *p++ = *q++; + if (p < endTemp) *p++ = 0; } @@ -121,6 +124,7 @@ { USHORT fac = 0, class_ = 0; ISC_STATUS decoded = gds__decode(code, &fac, &class_); + if (gds__msg_format(0, fac, decoded, 128, buffer, args[0], args[1], args[2], args[3], args[4]) < 0) @@ -137,6 +141,7 @@ case isc_arg_interpreted: { p = buffer; + for (const char *q = (const char*) vector[1]; *p++ = *q++;) ; } Index: Subsystem.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/Subsystem.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -b -U3 -r1.2 -r1.3 --- Subsystem.cpp 5 Aug 2005 16:09:37 -0000 1.2 +++ Subsystem.cpp 2 Sep 2005 19:11:10 -0000 1.3 @@ -78,7 +78,7 @@ const TEXT* translatedName, DbHandle *dbHandle, int dpbLength, - UCHAR* dpb, + const UCHAR* dpb, int databaseType, ConfObject* databaseConfiguration, ConfObject* providerConfiguration) @@ -92,7 +92,7 @@ const TEXT* translatedName, DbHandle *dbHandle, int dpb_length, - UCHAR* dpb, + const UCHAR* dpb, ConfObject* databaseConfiguration, ConfObject* providerConfiguration) { @@ -119,13 +119,13 @@ -ISC_STATUS Subsystem::startMultiple(ISC_STATUS *userStatus, TraHandle *traHandle, int, teb *) +ISC_STATUS Subsystem::startMultiple(ISC_STATUS *userStatus, TraHandle *traHandle, int, const teb *) { return entrypointUnavailable (userStatus); } -ISC_STATUS Subsystem::reconnectTransaction(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int, UCHAR*) +ISC_STATUS Subsystem::reconnectTransaction(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int, const UCHAR*) { return entrypointUnavailable (userStatus); } @@ -137,7 +137,7 @@ } -ISC_STATUS Subsystem::prepareTransaction(ISC_STATUS* userStatus, TraHandle *traHandle, int, UCHAR*) +ISC_STATUS Subsystem::prepareTransaction(ISC_STATUS* userStatus, TraHandle *traHandle, int, const UCHAR*) { return entrypointUnavailable (userStatus); } @@ -367,9 +367,9 @@ ISC_STATUS Subsystem::dsqlExecute (ISC_STATUS* userStatus, TraHandle *traHandle, DsqlHandle *dsqlHandle, - int inBlrLength, UCHAR *inBlr, - int inMsgType, int inMsgLength, UCHAR *inMsg, - int outBlrLength, UCHAR *outBlr, + int inBlrLength, const UCHAR *inBlr, + int inMsgType, int inMsgLength, const UCHAR *inMsg, + int outBlrLength, const UCHAR *outBlr, int outMsgType, int outMsgLength, UCHAR *outMsg) { return entrypointUnavailable (userStatus); @@ -387,9 +387,9 @@ ISC_STATUS Subsystem::dsqlExecuteImmediate2(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int sqlLength, const char* sql, int dialect, - int inBlrLength, UCHAR *inBlr, - int inMsgType, int inMsgLength, UCHAR *inMsg, - int outBlrLength, UCHAR *outBlr, + int inBlrLength, const UCHAR *inBlr, + int inMsgType, int inMsgLength, const UCHAR *inMsg, + int outBlrLength, const UCHAR *outBlr, int outMsgType, int outMsgLength, UCHAR *outMsg) { return entrypointUnavailable (userStatus); @@ -426,9 +426,9 @@ ISC_STATUS Subsystem::serviceQuery(ISC_STATUS *userStatus, SvcHandle *dbHandle, int inItemLength, - UCHAR* inItem, + const UCHAR* inItem, int outItemLength, - UCHAR* outItem, + const UCHAR* outItem, int bufferLength, UCHAR *buffer) { @@ -446,7 +446,7 @@ const TEXT *service, SvcHandle *dbHandle, int spbLength, - UCHAR *spb, + const UCHAR *spb, ConfObject* servicesConfiguration, ConfObject* providerConfiguration) { @@ -457,7 +457,7 @@ ISC_STATUS Subsystem::serviceStart(ISC_STATUS* userStatus, SvcHandle *dbHandle, int spbLength, - UCHAR * spb) + const UCHAR * spb) { return entrypointUnavailable (userStatus); } @@ -467,9 +467,9 @@ DbHandle *dbHandle, TraHandle *traHandle, int blrLength, - UCHAR* blr, + const UCHAR* blr, int inMsgLength, - UCHAR* inMsg, + const UCHAR* inMsg, int outMsgLength, UCHAR* outMsg) { @@ -477,7 +477,7 @@ } -ISC_STATUS Subsystem::executeDDL(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int ddlLength, UCHAR* ddl) +ISC_STATUS Subsystem::executeDDL(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int ddlLength, const UCHAR* ddl) { return entrypointUnavailable (userStatus); } Index: Subsystem.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/Subsystem.h,v retrieving revision 1.2 retrieving revision 1.3 diff -b -U3 -r1.2 -r1.3 --- Subsystem.h 5 Aug 2005 16:09:37 -0000 1.2 +++ Subsystem.h 2 Sep 2005 19:11:10 -0000 1.3 @@ -70,7 +70,7 @@ const TEXT* translatedName, DbHandle *dbHandle, int dpb_length, - UCHAR* dpb, + const UCHAR* dpb, int databaseType, ConfObject* databaseConfiguration, ConfObject* providerConfiguration); @@ -79,17 +79,17 @@ const TEXT* translatedName, DbHandle *dbHandle, int dpb_length, - UCHAR* dpb, + const UCHAR* dpb, ConfObject* databaseConfiguration, ConfObject* providerConfiguration); virtual ISC_STATUS databaseInfo(ISC_STATUS* userStatus, DbHandle *dbHandle, int itemsLength, const UCHAR* items, int bufferLength, UCHAR* buffer); virtual ISC_STATUS detachDatabase(ISC_STATUS* userStatus, DbHandle *dbHandle); virtual ISC_STATUS dropDatabase (ISC_STATUS* userStatus, DbHandle *dbHandle); - virtual ISC_STATUS startMultiple(ISC_STATUS *, TraHandle *traHandle, int, teb *); - virtual ISC_STATUS reconnectTransaction(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int, UCHAR*); + virtual ISC_STATUS startMultiple(ISC_STATUS *, TraHandle *traHandle, int, const teb *); + virtual ISC_STATUS reconnectTransaction(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int, const UCHAR*); virtual ISC_STATUS transactionInfo(ISC_STATUS* userStatus, TraHandle *traHandle, int itemsLength, const UCHAR* items, int bufferLength, UCHAR* buffer); - virtual ISC_STATUS prepareTransaction(ISC_STATUS* userStatus, TraHandle *traHandle, int msgLength, UCHAR* msg); + virtual ISC_STATUS prepareTransaction(ISC_STATUS* userStatus, TraHandle *traHandle, int msgLength, const UCHAR* msg); virtual ISC_STATUS commitRetaining(ISC_STATUS *, TraHandle *traHandle); virtual ISC_STATUS commitTransaction(ISC_STATUS* userStatus, TraHandle *traHandle); virtual ISC_STATUS rollbackRetaining(ISC_STATUS *, TraHandle *traHandle); @@ -143,17 +143,17 @@ int sqlLength, const char *sql, int dialect, XSQLDA *inSqlda, XSQLDA *outSqlda); virtual ISC_STATUS dsqlExecute (ISC_STATUS* userStatus, TraHandle *traHandle, DsqlHandle *dsqlHandle, - int inBlrLength, UCHAR *inBlr, - int inMsgType, int inMsgLength, UCHAR *inMsg, - int outBlrLength, UCHAR *outBlr, + int inBlrLength, const UCHAR *inBlr, + int inMsgType, int inMsgLength, const UCHAR *inMsg, + int outBlrLength, const UCHAR *outBlr, int outMsgType, int outMsgLength, UCHAR *outMsg); virtual ISC_STATUS dsqlExecute (ISC_STATUS* userStatus, TraHandle *traHandle, DsqlHandle *dsqlHandle, int dialect, XSQLDA *inSqlda, XSQLDA *outSqlda); //virtual ISC_STATUS dsqlExecute2(ISC_STATUS* userStatus, TraHandle *traHandle, DsqlHandle *dsqlHandle, int, UCHAR*,int, int, UCHAR*, int, UCHAR*, int, int,UCHAR*); virtual ISC_STATUS dsqlExecuteImmediate2(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int sqlLength, const char* sql, int dialect, - int inBlrLength, UCHAR *inBlr, - int inMsgType, int inMsgLength, UCHAR *inMsg, - int outBlrLength, UCHAR *outBlr, + int inBlrLength, const UCHAR *inBlr, + int inMsgType, int inMsgLength, const UCHAR *inMsg, + int outBlrLength, const UCHAR *outBlr, int outMsgType, int outMsgLength, UCHAR *outMsg); virtual ISC_STATUS dsqlExecuteImmediate3(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int sqlLength, const char* sql, int dialect, @@ -170,9 +170,9 @@ virtual ISC_STATUS serviceQuery(ISC_STATUS *userStatus, SvcHandle *dbHandle, int inItemLength, - UCHAR* inItem, + const UCHAR* inItem, int outItemLength, - UCHAR* outItem, + const UCHAR* outItem, int bufferLength, UCHAR *buffer); virtual ISC_STATUS serviceDetach(ISC_STATUS *userStatus, SvcHandle *dbHandle); @@ -180,23 +180,23 @@ const TEXT *service, SvcHandle *dbHandle, int spbLength, - UCHAR *spb, + const UCHAR *spb, ConfObject* servicesConfiguration, ConfObject* providerConfiguration); virtual ISC_STATUS serviceStart(ISC_STATUS* userStatus, SvcHandle *dbHandle, int spbLength, - UCHAR * spb); + const UCHAR * spb); virtual ISC_STATUS transactRequest(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int blrLength, - UCHAR* blr, + const UCHAR* blr, int inMsgLength, - UCHAR* inMsg, + const UCHAR* inMsg, int outMsgLength, UCHAR* outMsg); - virtual ISC_STATUS executeDDL(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int ddlLength, UCHAR* ddl); + virtual ISC_STATUS executeDDL(ISC_STATUS* userStatus, DbHandle *dbHandle, TraHandle *traHandle, int ddlLength, const UCHAR* ddl); virtual int enableSubsystem (TEXT* subSystem); virtual int disableSubsystem (TEXT* subSystem); virtual ISC_STATUS databaseCleanup (ISC_STATUS* userStatus, Index: Sync.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/Sync.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -b -U3 -r1.1.1.1 -r1.2 --- Sync.cpp 20 Jan 2005 19:22:38 -0000 1.1.1.1 +++ Sync.cpp 2 Sep 2005 19:11:10 -0000 1.2 @@ -116,7 +116,7 @@ void Sync::print(const char *label) { - LOG_DEBUG ("%s %s state %d (%d) syncObject %x\n", + LOG_DEBUG ("%s %s state %d (%d) syncObject %lx\n", label, where, state, request, syncObject); } Index: gds.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/gds.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -b -U3 -r1.3 -r1.4 --- gds.cpp 18 Apr 2005 20:45:59 -0000 1.3 +++ gds.cpp 2 Sep 2005 19:11:10 -0000 1.4 @@ -673,6 +673,12 @@ return printer.interpretStatus (-1, s, (const ISC_STATUS**) vector); } +SLONG API_ROUTINE fb_interpret(char* s, int bufsize, const ISC_STATUS** vector) +{ + StatusPrint printer; + + return printer.interpretStatus (bufsize, s, (const ISC_STATUS**) vector); +} /* CVC: This special function for ADA has been restored to non-const vector, too, in case its usage was broken. */ @@ -1008,21 +1014,26 @@ } else { - sprintf(formatted, "can't format message %d:%d -- ", facility, - number); + sprintf(formatted, "can't format message %d:%d -- ", facility, number); TEXT* p; + if (n == -1) strcat(formatted, "message text not found"); - else if (n == -2) { + else if (n == -2) + { strcat(formatted, "message file "); + for (p = formatted; *p;) p++; + gds__prefix_msg(p, MSG_FILE); strcat(p, " not found"); } - else { + else + { for (p = formatted; *p;) p++; + sprintf(p, "message system code %d", n); } } @@ -1034,8 +1045,8 @@ *buffer++ = *p++; *buffer = 0; - gds__free((SLONG *) formatted); + return ((n > 0) ? l : -l); } Index: gds_proto.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/gds_proto.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -b -U3 -r1.1.1.1 -r1.2 --- gds_proto.h 20 Jan 2005 19:28:40 -0000 1.1.1.1 +++ gds_proto.h 2 Sep 2005 19:11:10 -0000 1.2 @@ -84,6 +84,7 @@ /* CVC: This non-const signature is needed for compatibility, see gds.cpp. */ SLONG API_ROUTINE gds__interprete(char*, ISC_STATUS**); void API_ROUTINE gds__interprete_a(SCHAR*, SSHORT*, ISC_STATUS*, SSHORT*); +SLONG API_ROUTINE fb_interpret(char*, int, const ISC_STATUS**); void API_ROUTINE gds__log(const TEXT*, ...); void API_ROUTINE gds__trace(const char*); Index: ibase.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/ibase.h,v retrieving revision 1.4 retrieving revision 1.5 diff -b -U3 -r1.4 -r1.5 --- ibase.h 3 Aug 2005 22:19:04 -0000 1.4 +++ ibase.h 2 Sep 2005 19:11:10 -0000 1.5 @@ -648,6 +648,10 @@ ISC_LONG ISC_EXPORT isc_interprete_cpp(char* const, const ISC_STATUS**); +SLONG ISC_EXPORT fb_interpret(char*, + int, + const ISC_STATUS**); + ISC_STATUS ISC_EXPORT isc_open_blob(ISC_STATUS*, isc_db_handle*, isc_tr_handle*, Index: jrd.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/jrd.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -b -U3 -r1.9 -r1.10 --- jrd.cpp 20 Jul 2005 22:43:49 -0000 1.9 +++ jrd.cpp 2 Sep 2005 19:11:10 -0000 1.10 @@ -577,7 +577,7 @@ const TEXT* translatedName, Attachment** handle, SSHORT dpb_length, - UCHAR* dpb, + const UCHAR* dpb, ConfObject* databaseConfiguration, ConfObject* providerConfiguration) { @@ -2469,7 +2469,7 @@ ISC_STATUS GDS_PREPARE(ISC_STATUS * user_status, Transaction** tra_handle, USHORT length, - UCHAR * msg) + const UCHAR * msg) { /************************************** * @@ -3440,7 +3440,7 @@ ISC_STATUS GDS_START_MULTIPLE(ISC_STATUS * user_status, Transaction** tra_handle, USHORT count, - TEB * vector) + const TEB * vector) { /************************************** * @@ -3452,7 +3452,6 @@ * Start a transaction. * **************************************/ - TEB* v; DBB dbb; api_entry_point_init(user_status); ThreadData threadData (user_status); @@ -3460,7 +3459,7 @@ NULL_CHECK(tra_handle, isc_bad_trans_handle); const TEB* const end = vector + count; - for (v = vector; v < end; v++) + for (const TEB *v = vector; v < end; v++) { if (check_database(threadData, *v->teb_database, user_status)) return user_status[1]; Index: jrd.vcproj =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/jrd.vcproj,v retrieving revision 1.13 retrieving revision 1.14 diff -b -U3 -r1.13 -r1.14 --- jrd.vcproj 1 Aug 2005 19:46:53 -0000 1.13 +++ jrd.vcproj 2 Sep 2005 19:11:10 -0000 1.14 @@ -757,6 +757,9 @@ </FileConfiguration> </File> <File + RelativePath=".\ExecutionPathInfoGen.cpp"> + </File> + <File RelativePath="ext.cpp"> <FileConfiguration Name="Debug|Win32"> @@ -1433,6 +1436,9 @@ RelativePath=".\MsgFile.cpp"> </File> <File + RelativePath=".\MsgFormat.cpp"> + </File> + <File RelativePath=".\Mutex.cpp"> </File> <File @@ -2595,6 +2601,9 @@ RelativePath="ExecuteStatement.h"> </File> <File + RelativePath=".\ExecutionPathInfoGen.h"> + </File> + <File RelativePath="ext.h"> </File> <File @@ -2988,6 +2997,9 @@ RelativePath=".\MsgFile.h"> </File> <File + RelativePath=".\MsgFormat.h"> + </File> + <File RelativePath="..\include\gen\msgs.h"> </File> <File @@ -3300,10 +3312,10 @@ RelativePath="..\include\gen\sql_code.h"> </File> <File - RelativePath="..\dsql\sqlda.h"> + RelativePath=".\Sqlda.h"> </File> <File - RelativePath=".\Sqlda.h"> + RelativePath="..\dsql\sqlda.h"> </File> <File RelativePath=".\SQLError.h"> Index: jrd_proto.h =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/jrd_proto.h,v retrieving revision 1.3 retrieving revision 1.4 diff -b -U3 -r1.3 -r1.4 --- jrd_proto.h 6 Mar 2005 23:12:05 -0000 1.3 +++ jrd_proto.h 2 Sep 2005 19:11:10 -0000 1.4 @@ -38,7 +38,7 @@ const TEXT* translatedName, Attachment** dbHandle, SSHORT dpb_length, - UCHAR* dpb, + const UCHAR* dpb, ConfObject* databaseConfiguration, ConfObject* providerConfiguration); ISC_STATUS jrd8_blob_info(ISC_STATUS*, blb**, SSHORT, @@ -84,7 +84,7 @@ Transaction**, blb**, struct bid*, USHORT, const UCHAR*); ISC_STATUS jrd8_prepare_transaction(ISC_STATUS *, Transaction **, - USHORT, UCHAR *); + USHORT, const UCHAR *); ISC_STATUS jrd8_put_segment(ISC_STATUS*, blb**, USHORT, const UCHAR*); ISC_STATUS jrd8_put_slice(ISC_STATUS*, Attachment**, @@ -123,7 +123,7 @@ ISC_STATUS jrd8_start_request(ISC_STATUS *, Request **, Transaction **, SSHORT); ISC_STATUS jrd8_start_multiple(ISC_STATUS *, Transaction **, USHORT, - struct teb *); + const struct teb *); ISC_STATUS jrd8_start_transaction(ISC_STATUS *, Transaction **, SSHORT, ...); ISC_STATUS jrd8_transaction_info(ISC_STATUS*, Transaction**, Index: sdl.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/sdl.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -b -U3 -r1.1.1.1 -r1.2 --- sdl.cpp 20 Jan 2005 19:22:00 -0000 1.1.1.1 +++ sdl.cpp 2 Sep 2005 19:11:10 -0000 1.2 @@ -693,21 +693,26 @@ case op_scalar: value = *next++; next++; /* Skip count, unsupported. */ - for (range = array_desc->ads_rpt, subscript = 0; - range < range_end; ++range) { + + for (range = array_desc->ads_rpt, subscript = 0; range < range_end; ++range) + { n = *stack_ptr++; - if (n < range->ads_lower || n > range->ads_upper) { + + if (n < range->ads_lower || n > range->ads_upper) + { error(arg->sdl_arg_status_vector, isc_out_of_bounds, 0); return FALSE; } subscript += (n - range->ads_lower) * range->ads_length; } + element_desc = array_desc->ads_rpt[value].ads_desc; element_desc.dsc_address = (BLOB_PTR *) arg->sdl_arg_array + - (long) element_desc.dsc_address + + (IPTR) element_desc.dsc_address + (array_desc->ads_element_length * subscript); /* Is this element within the array bounds? */ + fb_assert_continue((BLOB_PTR *) element_desc.dsc_address >= (BLOB_PTR *) arg->sdl_arg_array); fb_assert_continue((BLOB_PTR *) element_desc.dsc_address + Index: svc.cpp =================================================================== RCS file: /cvsroot/firebird/vulcan/src/jrd/svc.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -b -U3 -r1.7 -r1.8 --- svc.cpp 30 Aug 2005 08:53:11 -0000 1.7 +++ svc.cpp 2 Sep 2005 19:11:10 -0000 1.8 @@ -59,6 +59,7 @@ #include "Mutex.h" #include "OSRIException.h" #include "Sync.h" +#include "gdsassert.h" #ifdef SERVER_SHUTDOWN #include "../jrd/jrd_proto.h" @@ -197,7 +198,7 @@ USHORT spb_version; } SPB; -static void conv_switches(USHORT, USHORT, const UCHAR*, TEXT**); +static JString conv_switches(USHORT, USHORT, const UCHAR*); static const TEXT* find_switch(int, IN_SW_TAB); static USHORT process_switches(USHORT, const UCHAR*, TEXT*); static void get_options(const UCHAR*, USHORT, TEXT*, SPB*); @@ -258,16 +259,14 @@ /* Service Functions */ #ifdef SUPERSERVER -//int main_gbak(Service* service); #include "../burp/burp_proto.h" -//int main_gfix(Service* service); #include "../alice/alice_proto.h" -int main_wal_print(); -int main_lock_print(); -int main_gstat(Service* service); -//int main_gsec(Service* service); #include "../utilities/gsec/gsec_proto.h" +int main_lock_print(); +//int main_gstat(Service* service); +THREAD_ENTRY_DECLARE main_gstat(THREAD_ENTRY_PARAM arg); + #define MAIN_GBAK BURP_main #define MAIN_GFIX ALICE_main #define MAIN_WAL_PRINT main_wal_print @@ -286,22 +285,22 @@ void SVC_STATUS_ARG(ISC_STATUS*& status, USHORT type, const void* value) { if (value) - { switch (type) { case isc_arg_number: *status++ = type; *status++ = reinterpret_cast<ISC_STATUS>(value); break; + case isc_arg_string: *status++ = type; *status++ = (ISC_STATUS) static_cast<const char*>(value); break; + default: break; } - } } /* Entries which have a NULL serv_executable field will not fork @@ -594,16 +593,18 @@ if (serv->serv_std_switches) strcpy(switches, serv->serv_std_switches); - if (options.spb_command_line && serv->serv_std_switches) + if (options.spb_command_line) + { + if (serv->serv_std_switches) strcat(switches, " "); - if (options.spb_command_line) strcat(switches, options.spb_command_line); + } /* Services operate outside of the context of databases. Therefore we cannot use the JRD allocator. */ - Service *service = new Service(configuration); + service = new Service(configuration); //service = FB_NEW(*getDefaultMemoryPool()) Service; //memset((void *) service, 0, sizeof(struct Service)); //service->svc_status = new ISC_STATUS [ISC_STATUS_LENGTH]; @@ -613,8 +614,8 @@ //service->blk_pool_id = 0; //service->blk_length = 0; service->svc_service = serv; - service->svc_flags = - (serv->serv_executable ? SVC_forked : 0) | (switches ? SVC_cmd_line : 0); + //service->svc_flags = serv->serv_executable ? SVC_forked : 0; + service->svc_flags = (serv->serv_executable ? SVC_forked : 0) | (switches ? SVC_cmd_line : 0); service->svc_switches = switches; service->svc_handle = 0; service->svc_user_flag = user_flag; @@ -744,21 +745,23 @@ **************************************/ #ifdef SERVER_SHUTDOWN - if (service->svc_do_shutdown) { + if (service->svc_do_shutdown) + { #ifdef SUPERSERVER int flShutdownComplete = 0; - gds__thread_start(shutdown_thread, &flShutdownComplete, - THREAD_medium, 0, 0); + gds__thread_start(shutdown_thread, &flShutdownComplete, THREAD_medium, 0, 0); THREAD_EXIT; int timeout = 10; // seconds - while (timeout--) { + + while (timeout--) + { if (flShutdownComplete) break; THREAD_SLEEP(1 * 1000); } - if (!flShutdownComplete) { + if (!flShutdownComplete) gds__log("Forced server shutdown - not all databases closed"); - } + #else // SUPERSERVER if (fb_shutdown_connections (fb_shutdown_immediate, 500)) @@ -772,20 +775,22 @@ exit(0); /* The shutdown operation is complete, just wait to die */ - while (1); + while (1) + ; } #endif /* SERVER_SHUTDOWN */ #ifdef SUPERSERVER -/* Mark service as detached. */ -/* If service thread is finished, cleanup memory being used by service. */ + /* Mark service as detached. */ + /* If service thread is finished, cleanup memory being used by service. */ SVC_finish(service, SVC_detached); #else -/* Go ahead and cleanup memory being used by service */ + /* Go ahead and cleanup memory being used by service */ + SVC_cleanup(service); #endif @@ -884,7 +889,9 @@ * S V C _ p u t c * **************************************/ -/* Ensure that service is not detached. */ + + /* Ensure that service is not detached. */ + if (!(service->svc_flags & SVC_detached)) service_enqueue_byte(ch, service); } @@ -1136,20 +1143,22 @@ infoGen.putString(item, buffer); break; - #ifdef SUPERSERVER +#ifdef SUPERSERVER case isc_info_svc_dump_pool_info: { char fname[MAXPATHLEN]; - int length = isc_vax_integer(items, sizeof(USHORT)); + int length = isc_vax_integer((char*) items, sizeof(USHORT)); + if (length >= sizeof(fname)) length = sizeof(fname) - 1; // truncation + items += sizeof(USHORT); - strncpy(fname, items, length); + strncpy(fname, (const char*) items, length); fname[length] = 0; - JRD_print_all_counters(fname); + //JRD_print_all_counters(fname); // It's a no-op anyway (jas) break; } - #endif +#endif /* case isc_info_svc_get_config: // TODO: iterate through all integer-based config values @@ -1518,15 +1527,15 @@ case isc_info_svc_dump_pool_info: { char fname[MAXPATHLEN]; - int length = isc_vax_integer(items, sizeof(USHORT)); + int length = isc_vax_integer((const char*) items, sizeof(USHORT)); if (length >= sizeof(fname)) length = sizeof(fname) - 1; // truncation items += sizeof(USHORT); - strncpy(fname, items, length); + strncpy(fname, (const char*) items, length); fname[length] = 0; - JRD_print_all_counters(fname); + //JRD_print_all_counters(fname); break; } #endif @@ -1693,8 +1702,6 @@ * **************************************/ //thread_db *tdbb; - const struct serv *serv; - TEXT* tmp_ptr = NULL; USHORT opt_switch_len = 0; BOOLEAN flag_spb_options = FALSE; #ifndef SUPERSERVER @@ -1713,6 +1720,7 @@ /* The name of the service is the first element of the buffer */ const USHORT svc_id = *spb; + const struct serv *serv; for (serv = (struct serv*)services; serv->serv_action; serv++) if (serv->serv_action == svc_id) @@ -1741,23 +1749,19 @@ if (service->svc_flags & SVC_thd_running) SVC_post(isc_svc_in_use, isc_arg_string, serv->serv_name, 0); - else - { + /* Another service may have been started with this service block. If so, * we must reset the service flags. */ - if (service->svc_switches && !(service->svc_flags & SVC_cmd_line)) - { - gds__free(service->svc_switches); - service->svc_switches = NULL; - } + //if (service->svc_switches) + if (!service->svc_switches.IsEmpty() && !(service->svc_flags & SVC_cmd_line)) + service->svc_switches = ""; if (!(service->svc_flags & SVC_detached)) service->svc_flags = 0; service->svc_flags |= SVC_thd_running; - } sync.unlock(); //tdbb = GET_THREAD_DATA; @@ -1795,8 +1799,8 @@ /* If svc_switches is not used -- call a command-line parsing utility */ - if (!service->svc_switches) - conv_switches(spb_length, opt_switch_len, spb, &service->svc_switches); + if (service->svc_switches.IsEmpty()) + service->svc_switches = conv_switches(spb_length, opt_switch_len, spb); else { /* Command line options (isc_spb_options) is used. @@ -1804,62 +1808,74 @@ * is called with a "-server" switch. */ flag_spb_options = TRUE; - - tmp_ptr = (TEXT *) - gds__alloc((SLONG) (strlen(service->svc_switches) + +1 + opt_switch_len + 1)); - if (!tmp_ptr) /* NOMEM: */ - SVC_post(isc_virmemexh, 0); } /* add the username and password to the end of svc_switches if needed */ - if (service->svc_switches) + JString temp; + + if (!service->svc_switches.IsEmpty()) { if (flag_spb_options) - strcpy(tmp_ptr, service->svc_switches); + temp = service->svc_switches; + //strcpy(tmp_ptr, service->svc_switches); if (!service->userName.IsEmpty()) { if (!flag_spb_options) + service->svc_switches.Format("%s %s %s", + (const char*) service->svc_switches, USERNAME_SWITCH, + (const char*) service->userName); + /*** sprintf(service->svc_switches, "%s %s %s", - service->svc_switches, USERNAME_SWITCH, + (const char*) service->svc_switches, USERNAME_SWITCH, (const char*) service->userName); + ***/ else + temp.Format("%s %s %s", (const char*) temp, USERNAME_SWITCH, (const char*) service->userName); + /*** sprintf(tmp_ptr, "%s %s %s", tmp_ptr, USERNAME_SWITCH, (const char*) service->userName); + ***/ } if (!service->encryptedPassword.IsEmpty()) { if (!flag_spb_options) + service->svc_switches.Format("%s %s %s", + (const char*) service->svc_switches, PASSWORD_SWITCH, + (const char*) service->encryptedPassword); + /*** sprintf(service->svc_switches, "%s %s %s", service->svc_switches, PASSWORD_SWITCH, (const char*) service->encryptedPassword); + ***/ else + temp.Format("%s %s %s", (const char*) temp, PASSWORD_SWITCH, + (const char*) service->encryptedPassword); + /*** sprintf(tmp_ptr, "%s %s %s", tmp_ptr, PASSWORD_SWITCH, (const char*) service->encryptedPassword); + ***/ } if (flag_spb_options) - { - gds__free(service->svc_switches); - service->svc_switches = tmp_ptr; - } + service->svc_switches = temp; } } else { /* If svc_switches is not used -- call a command-line parsing utility */ - if (!service->svc_switches) - conv_switches(spb_length, opt_switch_len, spb, &service->svc_switches); + if (service->svc_switches.IsEmpty()) + service->svc_switches = conv_switches(spb_length, opt_switch_len, spb); else - fb_assert(service->svc_switches == NULL); + fb_assert(service->svc_switches.IsEmpty()); // this makes no sense to me -- jas } /* All services except for get_ib_log require switches */ - if (service->svc_switches == NULL && *spb != isc_action_svc_get_ib_log) + if (service->svc_switches.IsEmpty() && *spb != isc_action_svc_get_ib_log) SVC_post(isc_bad_spb_form, 0); #ifndef SUPERSERVER @@ -1876,10 +1892,10 @@ if (service->svc_switches) { - USHORT argc; - TEXT* p; + USHORT argc = 2; + TEXT* p = service->setArgvStrings(service->svc_switches); - for (argc = 2, p = service->svc_switches; *p;) + while (*p) { if (*p == ' ') { @@ -1902,27 +1918,9 @@ } } - service->svc_argc = argc; - - TEXT** arg = (TEXT **) gds__alloc((SLONG) ((argc + 1) * sizeof(TEXT *))); - - /* - * the service block can be reused hence free a memory from the - * previous usage if any. - */ - - if (service->svc_argv) - gds__free(service->svc_argv); - - service->svc_argv = arg; - - /* FREE: at SVC_detach() - Possible memory leak if SVC_post() occurs */ - - if (!arg) /* NOMEM: */ - SVC_post(isc_virmemexh, 0); - + TEXT** arg = service->allocArgv(argc); *arg++ = (TEXT *)(serv->serv_thd); - const TEXT* q = p = service->svc_switches; + TEXT* q = p = service->svc_argv_strings; while (*q == ' ') q++; @@ -1978,16 +1976,8 @@ */ memset((void *) service->svc_status, 0, ISC_STATUS_LENGTH * sizeof(ISC_STATUS)); - - if (service->svc_stdout) - gds__free(service->svc_stdout); - - service->svc_stdout = (UCHAR*)gds__alloc((SLONG) SVC_STDOUT_BUFFER_SIZE + 1); - - /* FREE: at SVC_detach() */ - - if (!service->svc_stdout) /* NOMEM: */ - SVC_post(isc_virmemexh, 0); + delete service->svc_stdout; + service->svc_stdout = new UCHAR[SVC_STDOUT_BUFFER_SIZE + 1]; if (serv->serv_thd) { @@ -2008,9 +1998,9 @@ ISC_event_init(evnt_ptr, 0, 0); count = ISC_event_clear(evnt_ptr); - gds__thread_start(reinterpret_cast < FPTR_INT_VOID_PTR > - (serv->serv_thd), service, THREAD_medium, 0, - (void *) &service->svc_handle); + gds__thread_start(reinterpret_cast<FPTR_INT_VOID_PTR>(serv->serv_thd), + service, THREAD_medium, 0, + ( void*) &service->svc_handle); /* check for the service being detached. This will prevent the thread * from waiting infinitely if the client goes away @@ -2031,10 +2021,6 @@ } // try catch (...) { - if (service->svc_switches) - gds__free((SLONG *) service->svc_switches); - - if (service) delete service; throw; @@ -2044,7 +2030,8 @@ } -int SVC_read_ib_log(Service* service) +//int SVC_read_ib_log(Service* service) +THREAD_ENTRY_DECLARE SVC_read_ib_log(THREAD_ENTRY_PARAM arg) { /************************************** * @@ -2057,6 +2044,8 @@ * log file into the service buffers. * **************************************/ + + Service *service = (Service*) arg; IB_FILE *file; TEXT name[MAXPATHLEN], buffer[100]; bool svc_started = false; @@ -2241,7 +2230,7 @@ * **************************************/ -#ifdef MULTI_THREAD +#ifdef MULTI_THREADxxx if (reenter_flag) THREAD_ENTER; #endif @@ -2285,7 +2274,7 @@ * Startup a service. * **************************************/ - TEXT *argv_data, argv_data_buf[512], *p, *q, *arg; + //TEXT *argv_data, argv_data_buf[512], *p, *q, *arg; USHORT quote_flag, user_quote; HANDLE my_output, pipe_input, pipe_output, pipe_error; SECURITY_ATTRIBUTES attr; @@ -2362,96 +2351,93 @@ and size of the command line arguments. Add some extra space for the pipe's file handles. */ - USHORT len = (USHORT) (strlen(service_path) + strlen(service->svc_switches) + 16); + USHORT len = (USHORT) (strlen(service_path) + service->svc_switches.length() + 16); + const TEXT *p; + TEXT *q; for (p = service->svc_switches; *p;) if (*p++ == ' ') len += 2; - if (len > sizeof(argv_data_buf)) - argv_data = (TEXT*) gds__alloc((SLONG) len); - else - argv_data = argv_data_buf; - - /* FREE: at procedure return */ - - if (!argv_data) /* NOMEM: */ - SVC_post(isc_virmemexh, 0); + TEXT argv_data_buf[512]; + TempSpace tempSpace(sizeof (argv_data_buf), argv_data_buf); + tempSpace.resize(len); + TEXT *argv_data = (TEXT*) tempSpace.space; /* Create a command line. */ svc_flag = FALSE; - for (p = argv_data, q = service_path; *p = *q++; p++) + for (q = argv_data, p = service_path; *q = *p++; q++) ; - q = service->svc_switches; + p = service->svc_switches; - if (*q) - *p++ = ' '; + if (*p) + *q++ = ' '; - while (*q == ' ') - q++; + while (*p == ' ') + p++; user_quote = FALSE; - while (*q) + while (*p) { - arg = p; - *p++ = '\"'; + TEXT *arg = q; + *q++ = '\"'; quote_flag = FALSE; - while (((*p = *q++) && *p != ' ') || user_quote) + while (((*q = *p++) && *q != ' ') || user_quote) { - if (*p == '\\' && *q == ' ' && !user_quote) + if (*q == '\\' && *p == ' ' && !user_quote) { - *p = ' '; - q++; + *q = ' '; + p++; quote_flag = TRUE; } - if (*p == '"') + if (*q == '"') { user_quote = !user_quote; - p++; + q++; continue; } - p++; + q++; } if (!quote_flag) { *arg = ' '; - if (!strncmp(arg, " -Service", p - arg)) + if (!strncmp(arg, " -Service", q - arg)) { if (windows_nt) - sprintf(p, "_re %lu %x %x", pipe_input, pipe_output, pipe_error); + sprintf(q, "_re %lu %x %x", pipe_input, pipe_output, pipe_error); else - sprintf(p, "_re %u %u %u", my_output, my_input, my_output); + sprintf(q, "_re %u %u %u", my_output, my_input, my_output); - p += strlen(p); - *p = q[-1]; + q += strlen(q); + *q = p[-1]; svc_flag = TRUE; } } else { - p[1] = p[0]; - *p++ = '\"'; + q[1] = q[0]; + *q++ = '\"'; } - if (!*p) + if (!*q) break; - *p++ = ' '; + *q++ = ' '; - while (*q == ' ') - q++; + while (*p == ' ') + p++; } - for (q = argv_data; *q; q++) + for (q = argv_data; *p; p++) if (*q == SVC_TRMNTR) *q = ' '; @@ -2485,9 +2471,6 @@ THREAD_ENTER; - if (argv_data != argv_data_buf) - gds__free((SLONG *) argv_data); - if (!ret) SVC_post(isc_sys_request, isc_arg_string, "CreateProcess", SYS_ERR, status, 0); @@ -2639,20 +2622,17 @@ is_service_running(service); - while (length) { - if (!WriteFile((HANDLE) service->svc_output, buffer, (SLONG) length, - (ULONG*) &n, NULL)) + while (length) { - io_error("WriteFile", GetLastError(), "service pipe", - isc_io_write_err, TRUE); - } + if (!WriteFile((HANDLE) service->svc_output, buffer, (SLONG) length, (ULONG*) &n, NULL)) + io_error("WriteFile", GetLastError(), "service pipe", isc_io_write_err, TRUE); + length -= (USHORT) n; buffer += n; } if (!FlushFileBuffers((HANDLE) service->svc_output)) - io_error("FlushFileBuffers", GetLastError(), "service pipe", - isc_io_write_err, TRUE); + io_error("FlushFileBuffers", GetLastError(), "service pipe", isc_io_write_err, TRUE); } @@ -2787,12 +2767,16 @@ * Functional description * **************************************/ -/* Wait for space in buffer while service is not detached. */ + + /* Wait for space in buffer while service is not detached. */ + while (service_full(service) && !(service->svc_flags & SVC_detached)) THREAD_SLEEP(1); -/* Ensure that service is not detached. */ - if (!(service->svc_flags & SVC_detached)) { + /* Ensure that service is not detached. */ + + if (!(service->svc_flags & SVC_detached)) + { service->svc_stdout_tail = service_add_one(service->svc_stdout_tail); service->svc_stdout[service->svc_stdout_tail] = ch; } @@ -2811,50 +2795,56 @@ * Startup a service. * **************************************/ - USHORT argc; - TEXT **arg, *p, *q; - for (argc = 2, p = service->svc_switches; *p;) - if (*p++ == ' ') - argc++; + // First, count the arguments - service->svc_argc = argc; + USHORT argc = 2; + TEXT *p = service->setArgvStrings(service->svc_switches); - arg = (TEXT **) gds__alloc((SLONG) ((argc + 1) * sizeof(TEXT *))); - service->svc_argv = arg; -/* FREE: at SVC_detach() - Possible memory leak if SVC_post() occurs */ - if (!arg) /* NOMEM: */ - SVC_post(isc_virmemexh, 0); + while (*p) + if (*p++ == ' ') + { + argc++; + while (*p == ' ') + ++p; + } + TEXT **arg = service->allocArgv(argc); *arg++ = (TEXT *)(service_executable); -/* Break up the command line into individual arguments. */ + /* Break up the command line into individual arguments. */ - p = q = service->svc_switches; + TEXT *q = p = service->svc_argv_strings; while (*q == ' ') q++; - while (*q) { + + while (*q) + { *arg++ = p; - while ((*p = *q++) && *p != ' ') { - if (*p == '\\' && *q == ' ') { + + while ((*p = *q++) && *p != ' ') + { + if (*p == '\\' && *q == ' ') + { *p = ' '; q++; } p++; } + if (!*p) break; + *p++ = 0; + while (*q == ' ') q++; } + *arg = NULL; - service->svc_stdout = (UCHAR*)gds__alloc((SLONG) SVC_STDOUT_BUFFER_SIZE + 1); -/* FREE: at SVC_detach() */ - if (!service->svc_stdout) /* NOMEM: */ - SVC_post(isc_virmemexh, 0); + service->svc_stdout = new UCHAR[SVC_STDOUT_BUFFER_SIZE + 1]; THREAD_EXIT; gds__thread_start(reinterpret_cast<FPTR_INT_VOID_PTR>(service_executable), @@ -2930,7 +2920,7 @@ } -static void service_put(Service* service, const SCHAR* buffer, USHORT length) +static void service_put(Service* service, const UCHAR* buffer, USHORT length) { /************************************** * @@ -2989,12 +2979,12 @@ if (pipe(pair1) < 0 || pipe(pair2) < 0) io_error("pipe", errno, "", isc_io_create_err, FALSE); -/* Probe service executable to see it if plausibly exists. */ + /* Probe service executable to see it if plausibly exists. */ if (statistics(service_path, &stat_buf) == -1) io_error("stat", errno, service_path, isc_io_access_err, FALSE); -/* Make sure we have buffers that are large enough to hold the number + /* Make sure we have buffers that are large enough to hold the number and size of the command line arguments. */ for (argc = 2, p = service->svc_switches; *p;) @@ -3009,7 +2999,8 @@ { if (*p == SVC_TRMNTR) { - while (*p++ && *p != SVC_TRMNTR); + while (*p++ && *p != SVC_TRMNTR) + ; fb_assert (*p == SVC_TRMNTR); } p++; @@ -3020,24 +3011,31 @@ argv = (TEXT **) gds__alloc((SLONG) (argc * sizeof(TEXT *))); else argv = argv_buf; -/* FREE: at procedure return */ + + /* FREE: at procedure return */ + if (!argv) /* NOMEM: */ SVC_post(isc_virmemexh, 0); + service->svc_argc = argc; len = strlen(service->svc_switches) + 1; + if (len > sizeof(argv_data_buf)) argv_data = (TEXT *) gds__alloc((SLONG) len); else argv_data = argv_data_buf; -/* FREE: at procedure return */ - if (!argv_data) { /* NOMEM: */ + + /* FREE: at procedure return */ + + if (!argv_data) + { /* NOMEM: */ if (argv != argv_buf) gds__free(argv); SVC_post(isc_virmemexh, 0); } -/* Break up the command line into individual arguments. */ + /* Break up the command line into individual arguments. */ arg = argv; *arg++ = service_path; @@ -3047,12 +3045,14 @@ while (*q == ' ') q++; + while (*q) { *arg = p; while (*p = *q++) { - if (*p == ' ') break; + if (*p == ' ') + break; if (*p == SVC_TRMNTR) { @@ -3073,23 +3073,30 @@ *p = ' '; q++; } + p++; } + arg++; + if (!*p) break; + *p++ = '\0'; + while (*q == ' ') q++; } + *arg = NULL; -/* At last we can fork the sub-process. If the fork succeeds, repeat + /* At last we can fork the sub-process. If the fork succeeds, repeat it so that we don't have defunct processes hanging around. */ THREAD_EXIT; - switch (pid = vfork()) { + switch (pid = vfork()) + { case -1: THREAD_ENTER; if (argv != argv_buf) @@ -3105,18 +3112,23 @@ close(pair1[0]); close(pair2[1]); - if (pair2[0] != 0) { + + if (pair2[0] != 0) + { close(0); dup(pair2[0]); close(pair2[0]); } - if (pair1[1] != 1) { + + if (pair1[1] != 1) ... [truncated message content] |