You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by pr...@apache.org on 2006/03/21 17:48:48 UTC
svn commit: r387579 - in /webservices/axis/trunk/c/src/configuration:
AxisConfiguration.cpp AxisConfiguration.hpp AxisConfigurationLibraries.cpp
AxisConfigurationLibraries.hpp FileFunctions.cpp FileFunctions.hpp
ListMethods.cpp
Author: prestonf
Date: Tue Mar 21 08:48:46 2006
New Revision: 387579
URL: http://svn.apache.org/viewcvs?rev=387579&view=rev
Log:
General clean up of code and reworking of some function to work on Linux.
Modified:
webservices/axis/trunk/c/src/configuration/AxisConfiguration.cpp
webservices/axis/trunk/c/src/configuration/AxisConfiguration.hpp
webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.cpp
webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.hpp
webservices/axis/trunk/c/src/configuration/FileFunctions.cpp
webservices/axis/trunk/c/src/configuration/FileFunctions.hpp
webservices/axis/trunk/c/src/configuration/ListMethods.cpp
Modified: webservices/axis/trunk/c/src/configuration/AxisConfiguration.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/configuration/AxisConfiguration.cpp?rev=387579&r1=387578&r2=387579&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/configuration/AxisConfiguration.cpp (original)
+++ webservices/axis/trunk/c/src/configuration/AxisConfiguration.cpp Tue Mar 21 08:48:46 2006
@@ -3,7 +3,7 @@
#include "MissingCFunctions.hpp"
#include "AxisConfigurationLibraries.hpp"
-// Client -a c:\wscc -o obj\bin -th transport.dll -c channel.dll -cs sslChannel.dll -x xerces.dll -cl client.log
+// Client -a c:\wscc -o obj\bin -m on -th transport.dll -c channel.dll -cs sslChannel.dll -x xerces.dll -cl client.log
int main( int argc, char * argv[])
{
@@ -30,10 +30,19 @@
bool bSuccess = false;
LIST sFileNameList;
char * psDefaultParamList[eConfigMax];
+#if WIN32
+ char cSlash = '\\';
+ char * pszPackageName = "axis-c-1.6-Win32-bin\\bin";
+#else
+ char cSlash = '/';
+ char * pszPackageName = "axis-c-1.6-Linux-bin/bin";
+#endif
+ char szAxisCpp_Deploy[256];
+
Initialise( &sDLLNames, iConfigInfoArray, &sFileNameList, (char **) psDefaultParamList);
- switch( ReadConfigOptions( argc, argv, (char **) psDefaultParamList))
+ switch( ReadConfigOptions( argc, argv, (char **) psDefaultParamList, cSlash))
{
case eEmpty:
{
@@ -43,30 +52,145 @@
cout << "AxisConfiguration Both [params3]\tConfigure the client and server side." << endl << endl;
cout << "The param list is as follows:-" << endl;
cout << "-a root directory of Axis download (AXISCPP_HOME)" << endl;
- cout << "-o offset from AXISCPP_HOME to object files" << endl;
+#if WIN32
+ cout << " example: -a c:\\Axis" << endl;
+#else
+ cout << " example: -a /home/userid/Axis" << endl;
+#endif
+ cout << "-o directory offset from AXISCPP_HOME to object files" << endl;
+#if WIN32
+ cout << " example: -o " << pszPackageName << endl;
+#else
+ cout << " example: -o " << pszPackageName << endl;
+#endif
cout << "-th transport library name" << endl;
+ cout << " if -a and -o have both already been defined, then only the" << endl;
+ cout << " filename is required. Otherwise the fully qualified path will" << endl;
+ cout << " be required (NB: You can still override the -a and -o definitions" << endl;
+ cout << " by using a fully qulified path)." << endl;
+ cout << " example (with -a and -o defined): " << endl;
+#if WIN32
+ cout << " -th HTTPTransport.dll" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+ cout << " -th c:\\Axis\\" << pszPackageName << "\\HTTPTransport.dll" << endl;
+#else
+ cout << " -th libhttp_transport.so" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+ cout << " -th /home/userid/Axis/" << pszPackageName << "/libhttp_transport.so" << endl;
+#endif
cout << "-c channel library name" << endl;
+ cout << " if -a and -o have both already been defined, then only the" << endl;
+ cout << " filename is required. Otherwise the fully qualified path will" << endl;
+ cout << " be required (NB: You can still override the -a and -o definitions" << endl;
+ cout << " by using a fully qulified path)." << endl;
+ cout << " example (with -a and -o defined): " << endl;
+#if WIN32
+ cout << " -c HTTPChannel.dll" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+ cout << " -c c:\\Axis\\" << pszPackageName << "\\HTTPChannel.dll" << endl;
+#else
+ cout << " -c libhttp_channel.so" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+ cout << " -c /home/userid/Axis/" << pszPackageName << "/libhttp_channel.so" << endl;
+#endif
cout << "-cs ssl channel library name" << endl;
+ cout << " if -a and -o have both already been defined, then only the" << endl;
+ cout << " filename is required. Otherwise the fully qualified path will" << endl;
+ cout << " be required (NB: You can still override the -a and -o definitions" << endl;
+ cout << " by using a fully qulified path)." << endl;
+ cout << " example (with -a and -o defined): " << endl;
+#if WIN32
+ cout << " -cs HTTPSSLChannel.dll" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+ cout << " -cs c:\\Axis\\" << pszPackageName << "\\HTTPSSLChannel.dll" << endl;
+#else
+ cout << " -cs libhttp_channelssl.so" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+ cout << " -cs /home/userid/Axis/" << pszPackageName << "/libhttp_channelssl.so" << endl;
+#endif
cout << "-x xerces library name" << endl;
+ cout << " if -a and -o have both already been defined, then only the" << endl;
+ cout << " filename is required. Otherwise the fully qualified path will" << endl;
+ cout << " be required (NB: You can still override the -a and -o definitions" << endl;
+ cout << " by using a fully qulified path)." << endl;
+ cout << " example (with -a and -o defined): " << endl;
+#if WIN32
+ cout << " -x AxisXMLParserXerces.dll" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+ cout << " -x c:\\Axis\\" << pszPackageName << "\\AxisXMLParserXerces.dll" << endl;
+#else
+ cout << " -x libaxis_xerces.so" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+ cout << " -x /home/userid/Axis/" << pszPackageName << "/libaxis_xerces.so" << endl;
+#endif
+ cout << "-m merge with existing configuration file" << endl;
+ cout << " example: -m on|off (the default is 'off' meaning 'overwrite')" << endl;
cout << "Client Specific" << endl;
cout << "-cl client log filename" << endl;
+ cout << " if -a has been defined, then only the filename is required." << endl;
+ cout << " Otherwise the fully qualified path will be required." << endl;
+ cout << " (NB: You can still override the -a and -o definitions by using" << endl;
+ cout << " a fully qulified path)." << endl;
+ cout << " example (with -a defined): " << endl;
+ cout << " -cl client.log" << endl;
+ cout << " example (without -a defined): " << endl;
+#if WIN32
+ cout << " -cl c:\\Axis\\client.log" << endl;
+#else
+ cout << " -cl /home/userid/Axis/client.log" << endl;
+#endif
cout << "-cw client WSDD filename" << endl;
+ cout << " if -a and -o have both already been defined, then only the" << endl;
+ cout << " filename is required. Otherwise the fully qualified path will" << endl;
+ cout << " be required (NB: You can still override the -a and -o definitions" << endl;
+ cout << " by using a fully qulified path)." << endl;
+ cout << " example (with -a and -o defined): " << endl;
+ cout << " -cw client.wsdd" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+#if WIN32
+ cout << " -cw c:\\Axis\\WSDD\\client.wsdd" << endl;
+#else
+ cout << " -cw /home/userid/Axis/WSDD/client.wsdd" << endl;
+#endif
cout << "Server Specific" << endl;
cout << "-sl server log filename" << endl;
+ cout << " if -a has been defined, then only the filename is required." << endl;
+ cout << " Otherwise the fully qualified path will be required." << endl;
+ cout << " (NB: You can still override the -a and -o definitions by using" << endl;
+ cout << " a fully qulified path)." << endl;
+ cout << " example (with -a defined): " << endl;
+ cout << " -sl server.log" << endl;
+ cout << " example (without -a defined): " << endl;
+#if WIN32
+ cout << " -sl c:\\Axis\\server.log" << endl;
+#else
+ cout << " -sl /home/userid/Axis/server.log" << endl;
+#endif
cout << "-sw server WSDD filename" << endl;
+ cout << " if -a and -o have both already been defined, then only the" << endl;
+ cout << " filename is required. Otherwise the fully qualified path will" << endl;
+ cout << " be required (NB: You can still override the -a and -o definitions" << endl;
+ cout << " by using a fully qulified path)." << endl;
+ cout << " example (with -a and -o defined): " << endl;
+ cout << " -sw server.wsdd" << endl;
+ cout << " example (without -a and -o defined): " << endl;
+#if WIN32
+ cout << " -sw c:\\Axis\\WSDD\\server.wsdd" << endl;
+#else
+ cout << " -sw /home/userid/Axis/WSDD/server.wsdd" << endl;
+#endif
break;
}
case eClient:
{
- char szAxisCpp_Deploy[256];
char szAxis_Bin[256];
char szAxis_Bin_Default[256];
cout << "Axis Client Configuration" << endl;
cout << "=========================" << endl;
- GetHomeAndLibrary( &sDLLNames, szAxisCpp_Deploy, szAxis_Bin, szAxis_Bin_Default, &sFileNameList, (char **) psDefaultParamList);
+ GetHomeAndLibrary( &sDLLNames, szAxisCpp_Deploy, szAxis_Bin, szAxis_Bin_Default, &sFileNameList, (char **) psDefaultParamList, pszPackageName);
int iChoiceCount = 0;
@@ -104,7 +228,7 @@
}
}
- char szFilename[512];
+ char szFilename[512];
if( szLog[0] == '\0')
{
@@ -135,14 +259,13 @@
case eServer:
{
- char szAxisCpp_Deploy[256];
char szAxis_Bin[256];
char szAxis_Bin_Default[256];
cout << "Axis Server Configuration" << endl;
cout << "=========================" << endl;
- GetHomeAndLibrary( &sDLLNames, szAxisCpp_Deploy, szAxis_Bin, szAxis_Bin_Default, &sFileNameList, (char **) psDefaultParamList);
+ GetHomeAndLibrary( &sDLLNames, szAxisCpp_Deploy, szAxis_Bin, szAxis_Bin_Default, &sFileNameList, (char **) psDefaultParamList, pszPackageName);
bSuccess = true;
@@ -160,7 +283,7 @@
if( bSuccess)
{
- WriteAxisConfigFile( &sDLLNames, iConfigInfoArray, sChoiceList);
+ WriteAxisConfigFile( &sDLLNames, iConfigInfoArray, sChoiceList, StringCompare( psDefaultParamList[eMerge], "on"), szAxisCpp_Deploy, cSlash);
}
Destroy( &sDLLNames, &sFileNameList, (char **) psDefaultParamList);
@@ -168,7 +291,7 @@
return (int) bSuccess;
}
-ECONFIG ReadConfigOptions( int iParamCount, char * pParamArray[], char ** ppsDefaultParamList)
+ECONFIG ReadConfigOptions( int iParamCount, char * pParamArray[], char ** ppsDefaultParamList, char cSlash)
{
ECONFIG eConfig = eEmpty;
OPTIONLIST sOptions[] = {{eHTTPTransport, "TH"},
@@ -181,7 +304,12 @@
{eServerLog, "SL"},
{eRootDirectory, "A"},
{eOffsetToLibs, "O"},
- {eServerWSDD, "SW"}};
+ {eServerWSDD, "SW"},
+ {eMerge, "M"}};
+
+ ppsDefaultParamList[eMerge] = (char *) malloc( strlen( "off "));
+
+ strcpy( ppsDefaultParamList[eMerge], "off");
for( int iCount = 0; iCount < iParamCount; iCount++)
{
@@ -223,14 +351,13 @@
if( iCount < iParamCount)
{
if( ppsDefaultParamList[eOffsetToLibs] != NULL &&
- ppsDefaultParamList[eRootDirectory] != NULL)
+ ppsDefaultParamList[eRootDirectory] != NULL &&
+ !(sOptions[iIndex].eConfType == eClientLog ||
+ sOptions[iIndex].eConfType == eServerLog) &&
+ strchr( pParamArray[iCount], cSlash) == NULL)
{
char szLocation[512];
- char cSlash = '/';
-#if WIN32
- cSlash = '\\';
-#endif
sprintf( szLocation, "%s%c%s%c%s", ppsDefaultParamList[eRootDirectory], cSlash, ppsDefaultParamList[eOffsetToLibs], cSlash, pParamArray[iCount]);
ppsDefaultParamList[sOptions[iIndex].eConfType] = (char *) malloc( strlen( szLocation) + 1);
@@ -256,21 +383,34 @@
}
-void GetHomeAndLibrary( LIST * psDLLNames, char * pszAxisCpp_Deploy, char * pszAxis_Bin, char * pszAxis_Bin_Default, LIST * psFileNameList, char ** ppsDefaultParamList)
+void GetHomeAndLibrary( LIST * psDLLNames, char * pszAxisCpp_Deploy, char * pszAxis_Bin, char * pszAxis_Bin_Default, LIST * psFileNameList, char ** ppsDefaultParamList, char * pszPackageName)
{
+ char * pszCurrentAxisCppDeployEnv = getenv( "AXISCPP_DEPLOY");
+
if( ppsDefaultParamList[eRootDirectory] == NULL)
{
#if WIN32
cout << "Type in the Axis fully qualified directory path (e.g. C:\\Axis)" << endl
<< "used when Axis was unzipped (NB: this directory must also contain the" << endl
- << "axiscpp.conf file)." << endl;
+ << "axiscpp.conf file).";
#else
cout << "Type in the Axis fully qualified directory path (e.g. /home/Axis)" << endl
<< "used when Axis was unzipped (NB: this directory must also contain the" << endl
- << "etc/axiscpp.conf file)." << endl;
+ << "etc/axiscpp.conf file).";
#endif
- cout << "AXISCPP_DEPLOY = ";
+ if( pszCurrentAxisCppDeployEnv != NULL)
+ {
+ cout << " Type '*' to used the existing value of the environment" << endl;
+ cout << "variable (i.e. '" << pszCurrentAxisCppDeployEnv << "').";
+ }
+
+ cout << endl << "AXISCPP_DEPLOY = ";
cin >> pszAxisCpp_Deploy;
+
+ if( *pszAxisCpp_Deploy == '*' && pszCurrentAxisCppDeployEnv != NULL)
+ {
+ strcpy( pszAxisCpp_Deploy, pszCurrentAxisCppDeployEnv);
+ }
}
else
{
@@ -291,25 +431,32 @@
}
}
- strcpy( pszAxis_Bin_Default, pszAxisCpp_Deploy);
-
-#if WIN32
- strcat( pszAxis_Bin_Default, "\\axis-c-1.6-Win32-trace-bin\\bin");
-#else
- strcat( pszAxis_Bin_Default, "/axis-c-1.6-Linux-trace-bin/bin");
-#endif
+// strcpy( pszAxis_Bin_Default, pszAxisCpp_Deploy);
+//
+//#if WIN32
+// strcat( pszAxis_Bin_Default, "\\");
+//#else
+// strcat( pszAxis_Bin_Default, "/");
+//#endif
+//
+ strcpy( pszAxis_Bin_Default, pszPackageName);
if( ppsDefaultParamList[eOffsetToLibs] == NULL)
{
- cout << endl << "Instruction:" << endl
- << "You will need to create an environment variable called " << endl
- << "\"AXISCPP_DEPLOY\" and set it to " << pszAxisCpp_Deploy << "." << endl
- << "On the command line this would be:-" << endl
+ if( pszCurrentAxisCppDeployEnv == NULL)
+ {
+ cout << endl << "Instruction:" << endl
+ << "You will need to create an environment variable called " << endl
+ << "\"AXISCPP_DEPLOY\" and set it to " << pszAxisCpp_Deploy << "." << endl
+ << "On the command line this would be:-" << endl
#if WIN32
- << "SET AXISCPP_DEPLOY=" << pszAxisCpp_Deploy << endl << endl;
+ << "SET AXISCPP_DEPLOY=" << pszAxisCpp_Deploy << endl;
#else
- << "EXPORT AXISCPP_DEPLOY=" << pszAxisCpp_Deploy << endl << endl;
+ << "EXPORT AXISCPP_DEPLOY=" << pszAxisCpp_Deploy << endl;
#endif
+ }
+
+ cout << endl;
do
{
@@ -352,16 +499,25 @@
StringToUpper( pszUpper);
+ char * pszExtn = strchr( pszUpper, '.');
+
+ if( pszExtn != NULL)
+ {
+ *pszExtn = '\0';
+ }
+
while( iDLLCount < psDLLNames->iCount)
{
+ DLLNAMEINFO * pszDLLNameInfo = ((DLLNAMEINFO *) psDLLNames->ppArray[iDLLCount]);
- if( ((DLLNAMEINFO *) psDLLNames->ppArray[iDLLCount])->pszDLLName != NULL && strstr( ((DLLNAMEINFO *) psDLLNames->ppArray[iDLLCount])->pszDLLName, pszUpper) != NULL)
+ if( pszDLLNameInfo->pszDLLName != NULL &&
+ strstr( pszDLLNameInfo->pszDLLName, pszUpper) != NULL)
{
int * piDLLOffset = (int *) GetNextListElement( &sDLLOffsetList, sizeof( int));
*piDLLOffset = iDLLCount;
- cout << sDLLOffsetList.iCount << ".\t" << ((DLLNAMEINFO *) psDLLNames->ppArray[iDLLCount])->pszDLLFilename << endl;
+ cout << sDLLOffsetList.iCount << ".\t" << pszDLLNameInfo->pszDLLFilename << endl;
}
iDLLCount++;
@@ -412,7 +568,7 @@
}
else
{
- cout << "There are no recognised file names for the type of DLL." << endl << "You will have to modify the configuration file namually." << endl << endl;
+ cout << "There are no recognised file names for the type of file/library." << endl << "You will have to modify the configuration file namually." << endl << endl;
bHTTPTransportFound = true;
}
@@ -445,4 +601,4 @@
}
return bSuccess;
-}
\ No newline at end of file
+}
Modified: webservices/axis/trunk/c/src/configuration/AxisConfiguration.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/configuration/AxisConfiguration.hpp?rev=387579&r1=387578&r2=387579&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/configuration/AxisConfiguration.hpp (original)
+++ webservices/axis/trunk/c/src/configuration/AxisConfiguration.hpp Tue Mar 21 08:48:46 2006
@@ -2,13 +2,13 @@
#define __AXIS_CONFIG__
+#undef _DEBUG
+
#include <iostream>
#include "platforms/PlatformAutoSense.hpp"
#include "common/AxisConfig.h"
#include "ListMethods.hpp"
-#undef _DEBUG
-
using namespace std;
typedef enum
@@ -33,6 +33,7 @@
eServerWSDD,
eRootDirectory,
eOffsetToLibs,
+ eMerge,
eConfigMax
} ECONFIGTYPE;
@@ -58,11 +59,11 @@
char * pszOption;
} OPTIONLIST;
-ECONFIG ReadConfigOptions( int iParamCount, char * pszParamArray[], char ** ppsDefaultParamList);
+ECONFIG ReadConfigOptions( int iParamCount, char * pszParamArray[], char ** ppsDefaultParamList, char cSlash);
bool CheckAxisBinDirectoryExists( char * pszAxisCpp_Deploy, char * pszAxis_Bin, char * pszAxis_Bin_Default, LIST * psLIST, LIST * psFileNameList);
-void GetHomeAndLibrary( LIST * psLIST, char * pszAxisCpp_Deploy, char * pszAxis_Bin, char * pszAxis_Bin_Default, LIST * psFileNameList, char ** ppsDefaultParamList);
+void GetHomeAndLibrary( LIST * psLIST, char * pszAxisCpp_Deploy, char * pszAxis_Bin, char * pszAxis_Bin_Default, LIST * psFileNameList, char ** ppsDefaultParamList, char * pszPackageName);
void SelectFileFromList( CHOICELIST * psChoiceList, int iChoiceCount, LIST * psLIST, int * piConfigInfoArray, char ** ppsDefaultParamList, LIST * psFileNameList, char * pszAxisCpp_Deploy);
void AddFilenameToList( LIST * psFileNameList, char * pszFilename);
bool FileExists( char * pszFilename);
-#endif
\ No newline at end of file
+#endif
Modified: webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.cpp?rev=387579&r1=387578&r2=387579&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.cpp (original)
+++ webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.cpp Tue Mar 21 08:48:46 2006
@@ -1,6 +1,6 @@
#include "AxisConfigurationLibraries.hpp"
-const char * CreateConfigElement( LIST * psDLLNames, int * piConfigInfoArray, CHOICELIST * psChoiceList, ECONFIGTYPE eConfigType)
+char * CreateConfigElement( LIST * psDLLNames, int * piConfigInfoArray, CHOICELIST * psChoiceList, ECONFIGTYPE eConfigType)
{
int iIndex = 0;
bool bFound = false;
@@ -36,16 +36,28 @@
if( piConfigInfoArray[eConfigType] != -1)
{
- sprintf( szReturn, "%s:%s\n", pszConfigName, ((DLLNAMEINFO *)(psDLLNames->ppArray[piConfigInfoArray[eConfigType]]))->pszDLLFilename);
+ sprintf( szReturn, "%s:%s\n\n", pszConfigName, ((DLLNAMEINFO *)(psDLLNames->ppArray[piConfigInfoArray[eConfigType]]))->pszDLLFilename);
}
else
{
- sprintf( szReturn, "#%s:<not set>\n", pszConfigName);
+ sprintf( szReturn, "#%s:<not set>\n\n", pszConfigName);
}
sReturn += szReturn;
- return sReturn.c_str();
+ return (char *) sReturn.c_str();
+}
+
+char * GetTagValue( LIST * psDLLNames, int * piConfigInfoArray, ECONFIGTYPE eConfigType)
+{
+ char * pszTagValue = NULL;
+
+ if( piConfigInfoArray[eConfigType] != -1)
+ {
+ pszTagValue = ((DLLNAMEINFO *)(psDLLNames->ppArray[piConfigInfoArray[eConfigType]]))->pszDLLFilename;
+ }
+
+ return pszTagValue;
}
void Initialise( LIST * psDLLNames, int * piConfigInfoArray, LIST * psFileNameList, char ** ppsDefaultParamList)
@@ -109,4 +121,29 @@
psDLLNameInfo->bAddToClientConfig = bAddToClientConfig;
return psDLLNames->iCount - 1;
-}
\ No newline at end of file
+}
+
+int GetChoiceIndexForConfigType( CHOICELIST * psChoiceList, ECONFIGTYPE eConfigType)
+{
+ int iIndex = 0;
+ bool bFound = false;
+
+ while( iIndex < eConfigMax && !bFound)
+ {
+ if( psChoiceList[iIndex].eConfigType == eConfigType)
+ {
+ bFound = true;
+ }
+ else
+ {
+ iIndex++;
+ }
+ }
+
+ if( !bFound)
+ {
+ iIndex = -1;
+ }
+
+ return iIndex;
+}
Modified: webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.hpp?rev=387579&r1=387578&r2=387579&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.hpp (original)
+++ webservices/axis/trunk/c/src/configuration/AxisConfigurationLibraries.hpp Tue Mar 21 08:48:46 2006
@@ -1,6 +1,8 @@
#include "AxisConfiguration.hpp"
-const char * CreateConfigElement( LIST * psDLLNames, int * piConfigInfoArray, CHOICELIST * psChoiceList, ECONFIGTYPE eConfigType);
+char * CreateConfigElement( LIST * psDLLNames, int * piConfigInfoArray, CHOICELIST * psChoiceList, ECONFIGTYPE eConfigType);
void Initialise( LIST * psDLLNames, int * piConfigInfoArray, LIST * psFileNameList, char ** ppsDefaultParamList);
void Destroy( LIST * psDLLNames, LIST * psFileNameList, char ** psDefaultParamList);
int PopulateNewDLLNameInfo( LIST * psDLLNames, char * pszName, char * pszFilename, bool bAddToClientConfig);
+char * GetTagValue( LIST * psDLLNames, int * piConfigInfoArray, ECONFIGTYPE eConfigType);
+int GetChoiceIndexForConfigType( CHOICELIST * psChoiceList, ECONFIGTYPE eConfigType);
Modified: webservices/axis/trunk/c/src/configuration/FileFunctions.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/configuration/FileFunctions.cpp?rev=387579&r1=387578&r2=387579&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/configuration/FileFunctions.cpp (original)
+++ webservices/axis/trunk/c/src/configuration/FileFunctions.cpp Tue Mar 21 08:48:46 2006
@@ -35,7 +35,6 @@
#else // Else !(WINDOWS code)
DIR * psDIR;
struct dirent* pDirEnt;
- int iFilenameCount = 0;
if( (psDIR = opendir( pszDirName)) == NULL)
{
@@ -132,28 +131,283 @@
return bFound;
}
-void WriteAxisConfigFile( LIST * psDLLNames, int * piConfigInfoArray, CHOICELIST * psChoiceList)
+void WriteAxisConfigFile( LIST * psDLLNames, int * piConfigInfoArray, CHOICELIST * psChoiceList, bool bMerge, char * pszAxisCpp_Deploy, char cSlash)
{
- cout << "DLL selection complete" << endl << endl;
+ char szFilename[256];
- cout << "AxisCPP.conf file now has the following information:-" << endl;
+ sprintf( szFilename, "%s%caxiscpp.conf", pszAxisCpp_Deploy, cSlash);
- cout << "# The comment character is '#'" << endl;
- cout << "#Available directives are as follows" << endl;
- cout << "#(Some of these directives may not be implemented yet)" << endl;
- cout << "#" << endl;
- cout << CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eServerLog) << endl;
- cout << CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eServerWSDD) << endl;
- cout << CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eClientLog) << endl;
- cout << CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eClientWSDD) << endl;
- cout << "#Node name." << endl;
- cout << "#NodeName: <not set>" << endl << endl;
- cout << "#Listening port." << endl;
- cout << "#ListenPort: <not set>" << endl << endl;
- cout << CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eHTTPTransport) << endl;
- cout << CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eSMTPTransport) << endl;
- cout << CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eXMLParser) << endl;
- cout << CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eHTTPChannel) << endl;
- cout << CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eHTTPSSLChannel) << endl;
- cout << endl;
+ cout << endl << "Configuration complete." << endl << endl;
+
+ BackUpExistingConfigFile( pszAxisCpp_Deploy, szFilename, cSlash);
+
+ if( bMerge)
+ {
+ char * pszData = NULL;
+ long lFileLength = 0;
+
+ if( (lFileLength = ReadFileContents( szFilename, &pszData)) > -1)
+ {
+ FILE * pFile = fopen( szFilename, "w");
+
+ if( lFileLength < 5)
+ {
+ char szConfigData[512];
+#if WIN32
+ __time64_t ltime;
+
+ _time64( <ime);
+
+ sprintf( szConfigData, "# This header file was created by AxisConfiguration on %s", _ctime64( <ime));
+#else
+ time_t sTimeNow;
+
+ sTimeNow = time( NULL);
+
+ sprintf( szConfigData, "# This header file was created by AxisConfiguration on %s", asctime( localtime( &sTimeNow)));
+#endif
+ WriteLineToFile( pFile, szConfigData);
+
+ WriteLineToFile( pFile, "# The comment character is '#'\n");
+ WriteLineToFile( pFile, "# Available directives are as follows\n");
+ WriteLineToFile( pFile, "#(Some of these directives may not be implemented yet)\n");
+ WriteLineToFile( pFile, "#\n");
+ }
+
+ for( int ieConfigType = eHTTPTransport; ieConfigType < eConfigMax; ieConfigType++)
+ {
+ int iChoiceIndex = GetChoiceIndexForConfigType( psChoiceList, (ECONFIGTYPE) ieConfigType);
+
+ if( iChoiceIndex != -1)
+ {
+ char * psTag = strstr( pszData, psChoiceList[iChoiceIndex].pszConfigName);
+
+ if( psTag)
+ {
+ char * psTagLineStart = strchr( psTag, ':');
+ char * psTagLineEnd = psTag;
+
+ if( psTagLineStart != NULL)
+ {
+ psTagLineStart++;
+
+ while( *psTagLineEnd != '\n' &&
+ *psTagLineEnd != '\r' &&
+ *psTagLineEnd != '\0' &&
+ psTagLineEnd - pszData < lFileLength)
+ {
+ psTagLineEnd++;
+ }
+
+ int iTagValueLength = (int) (psTagLineEnd - psTagLineStart);
+ char * pszTagValue = GetTagValue( psDLLNames, piConfigInfoArray, (ECONFIGTYPE) ieConfigType);
+
+ if( pszTagValue != NULL)
+ {
+ if( (int) strlen( pszTagValue) == iTagValueLength)
+ {
+ if( StringCompare( psTagLineStart, pszTagValue))
+ {
+ // No change
+ }
+ else
+ {
+ memcpy( psTagLineStart, pszTagValue, iTagValueLength);
+ }
+ }
+ else if( (int) strlen( pszTagValue) > iTagValueLength)
+ {
+ // New tag value is longer than current tag.
+ int iTagValueLengthDiff = (int) strlen( pszTagValue) - iTagValueLength;
+ int iTagValueOffset = (int) (psTagLineStart - pszData);
+
+ pszData = (char *) realloc( pszData, strlen( pszData) + iTagValueLengthDiff + 1);
+
+ memmove( pszData + iTagValueOffset + iTagValueLength + iTagValueLengthDiff,
+ pszData + iTagValueOffset + iTagValueLength,
+ strlen( pszData + iTagValueOffset + iTagValueLength) + 1);
+ memcpy( pszData + iTagValueOffset,
+ pszTagValue,
+ strlen( pszTagValue));
+ }
+ else
+ {
+ // New tag value is shorter than current tag.
+ int iTagValueLengthDiff = iTagValueLength - (int) strlen( pszTagValue);
+ int iTagValueOffset = (int) (psTagLineStart - pszData);
+
+ memmove( pszData + iTagValueOffset + iTagValueLength - iTagValueLengthDiff,
+ pszData + iTagValueOffset + iTagValueLength,
+ strlen( pszData + iTagValueOffset + iTagValueLength) + 1);
+ memcpy( pszData + iTagValueOffset,
+ pszTagValue,
+ strlen( pszTagValue));
+ }
+ }
+ }
+ }
+ else
+ {
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, (ECONFIGTYPE) ieConfigType));
+ }
+ }
+ else
+ {
+ // No choice information
+ }
+ }
+
+ WriteLineToFile( pFile, pszData);
+
+ free( pszData);
+
+ fclose( pFile);
+ }
+ else
+ {
+ cout << "Error - The existing configuration file (" << szFilename << ")" << endl
+ << " could not be read/found. The new configuration data has" << endl
+ << " not been written." << endl;
+ }
+ }
+ else
+ {
+ FILE * pFile = fopen( szFilename, "w");
+ char szConfigData[512];
+
+#if WIN32
+ __time64_t ltime;
+
+ _time64( <ime);
+
+ sprintf( szConfigData, "# This header file was created by AxisConfiguration on %s", _ctime64( <ime));
+#else
+ time_t sTimeNow;
+
+ sTimeNow = time( NULL);
+
+ sprintf( szConfigData, "# This header file was created by AxisConfiguration on %s", asctime( localtime( &sTimeNow)));
+#endif
+
+ WriteLineToFile( pFile, szConfigData);
+
+ WriteLineToFile( pFile, "# The comment character is '#'\n");
+ WriteLineToFile( pFile, "# Available directives are as follows\n");
+ WriteLineToFile( pFile, "#(Some of these directives may not be implemented yet)\n");
+ WriteLineToFile( pFile, "#\n");
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eServerLog));
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eServerWSDD));
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eClientLog));
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eClientWSDD));
+ WriteLineToFile( pFile, "#Node name.\n");
+ WriteLineToFile( pFile, "#NodeName: <not set>\n\n");
+ WriteLineToFile( pFile, "#Listening port.\n");
+ WriteLineToFile( pFile, "#ListenPort: <not set>\n\n");
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eHTTPTransport));
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eSMTPTransport));
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eXMLParser));
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eHTTPChannel));
+ WriteLineToFile( pFile, CreateConfigElement( psDLLNames, piConfigInfoArray, psChoiceList, eHTTPSSLChannel));
+
+ fclose( pFile);
+ }
+}
+bool BackUpExistingConfigFile( char * pszAxisCpp_Deploy, char * pszFilename, char cSlash)
+{
+ bool bSuccess = false;
+
+ if( FileExists( pszFilename))
+ {
+ int iBackCount = -1;
+ char szBackFilename[256];
+
+ do
+ {
+ iBackCount++;
+
+ sprintf( szBackFilename, "%s%caxiscpp.conf.backup_%04d", pszAxisCpp_Deploy, cSlash, iBackCount);
+
+ } while( FileExists( szBackFilename));
+
+ FILE * pFileFrom = fopen( pszFilename, "r");
+ FILE * pFileTo = fopen( szBackFilename, "w");
+
+ if( pFileFrom != NULL && pFileTo != NULL)
+ {
+ long lFileLength = GetFileLength( pFileFrom);
+ char szBackupHeader[256];
+#if WIN32
+ __time64_t ltime;
+
+ _time64( <ime);
+
+ sprintf( szBackupHeader, "# This header file was automatically backed up by AxisConfiguration on %s", _ctime64( <ime));
+#else
+ time_t sTimeNow;
+
+ sTimeNow = time( NULL);
+
+ sprintf( szBackupHeader, "# This header file was automatically backed up by AxisConfiguration on %s", asctime( localtime( &sTimeNow)));
+#endif
+
+ char * pFileContent = (char *) malloc( lFileLength + strlen( szBackupHeader) + 2);
+
+ pFileContent[lFileLength + strlen( szBackupHeader) + 1] = '\0';
+
+ strcpy( pFileContent, szBackupHeader);
+
+ fread( pFileContent + strlen( szBackupHeader), sizeof( char), lFileLength, pFileFrom);
+ fwrite( pFileContent, sizeof( char), lFileLength + strlen(szBackupHeader) + 1, pFileTo);
+
+ fclose( pFileFrom);
+ fclose( pFileTo);
+
+ free( pFileContent);
+
+ bSuccess = true;
+ }
+ }
+
+ return bSuccess;
+}
+
+void WriteLineToFile( FILE * pFile, char * pszData)
+{
+ fwrite( pszData, sizeof( char), strlen( pszData), pFile);
+}
+
+long GetFileLength( FILE * pFile)
+{
+ fseek( pFile, 0, SEEK_END);
+
+ long lFileLength = ftell( pFile);
+
+ rewind( pFile);
+
+ return lFileLength;
+}
+
+long ReadFileContents( char * pszFilename, char ** ppszData)
+{
+ long lFileLength = -1;
+
+ if( FileExists( pszFilename))
+ {
+ FILE * pFile = fopen( pszFilename, "r");
+
+ if( pFile != NULL)
+ {
+ lFileLength = GetFileLength( pFile);
+
+ *ppszData = (char *) malloc( lFileLength + 1);
+
+ memset( *ppszData, 0, lFileLength + 1);
+
+ fread( *ppszData, sizeof( char), lFileLength, pFile);
+
+ fclose( pFile);
+ }
+ }
+
+ return lFileLength;
}
Modified: webservices/axis/trunk/c/src/configuration/FileFunctions.hpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/configuration/FileFunctions.hpp?rev=387579&r1=387578&r2=387579&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/configuration/FileFunctions.hpp (original)
+++ webservices/axis/trunk/c/src/configuration/FileFunctions.hpp Tue Mar 21 08:48:46 2006
@@ -7,6 +7,12 @@
#endif
#include "AxisConfiguration.hpp"
+#include <time.h>
bool ReadFilenamesInaDirectory( char * pszDirName, LIST * psFileNameList);
-void WriteAxisConfigFile( LIST * psDLLNames, int * piConfigInfoArray, CHOICELIST * psChoiceList);
+void WriteAxisConfigFile( LIST * psDLLNames, int * piConfigInfoArray, CHOICELIST * psChoiceList, bool bMerge, char * pszAxisCpp_Deploy, char cSlash);
+bool BackUpExistingConfigFile( char * pszAxisCpp_Deploy, char * pszFilename, char cSlash);
+void WriteLineToFile( FILE * pFile, char * pszData);
+long GetFileLength( FILE * pFile);
+long ReadFileContents( char * pszFilename, char ** ppszData);
+
Modified: webservices/axis/trunk/c/src/configuration/ListMethods.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/configuration/ListMethods.cpp?rev=387579&r1=387578&r2=387579&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/configuration/ListMethods.cpp (original)
+++ webservices/axis/trunk/c/src/configuration/ListMethods.cpp Tue Mar 21 08:48:46 2006
@@ -29,4 +29,4 @@
psList->iCount++;
return psList->ppArray[psList->iCount - 1];
-}
\ No newline at end of file
+}