cvs: php4 /ext/isxfunc .cvsignore CREDITS ixsfunc.cpp ixsfunc.dsp ixsfunc.h setup.c setup.h
| From: | Frank M. Kromann | Date: | Mon, 17 Dec 2001 23:59:16 +0000 |
| Subject: | cvs: php4 /ext/isxfunc .cvsignore CREDITS ixsfunc.cpp ixsfunc.dsp ixsfunc.h setup.c setup.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-8704@lists.php.net to get a copy of this message | ||
fmk Mon Dec 17 18:59:16 2001 EDT
Added files:
/php4/ext/isxfunc .cvsignore CREDITS ixsfunc.cpp ixsfunc.dsp
ixsfunc.h setup.c setup.h
Log:
Adding new extension used to query Microsift Index Server.
Only available on WIn32
Index: php4/ext/isxfunc/.cvsignore +++ php4/ext/isxfunc/.cvsignore *.plg *.opt *.ncb IXSfunc_Release IXSfunc_Debug Index: php4/ext/isxfunc/ixsfunc.cpp +++ php4/ext/isxfunc/ixsfunc.cpp /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <frank@kromann.info> | +----------------------------------------------------------------------+ */ /* $Id: ixsfunc.cpp,v 1.1 2001/12/17 23:59:16 fmk Exp $ */ /* * Microsoft Index Server administration functions * Uses Registry, because COM administration is not supported on NT */ #define UNICODE #define INITGUID #include <afx.h> #include <stdio.h> #define _ATL_DLL_IMPL #include <ks.h> #include <atlbase.h> // ATL support #include "ixsfunc.h" CString CATALOGS_KEY = "SYSTEM\\CurrentControlSet\\Control\\ContentIndex\\Catalogs"; extern "C" IXSFUNC_API long CatalogExists(char *strCatalogName) { int rc; CRegKey *catalogs = new CRegKey(); CString strCatalogKey = CATALOGS_KEY + "\\" + strCatalogName + "\\Scopes"; rc = catalogs->Open(HKEY_LOCAL_MACHINE, strCatalogKey, MAXIMUM_ALLOWED); if (rc == ERROR_SUCCESS) { catalogs->Close(); rc = 0; } return rc; } extern "C" IXSFUNC_API long CreateCatalog(char *strCatalogName, char *strLocation) { int rc; CRegKey *catalog = new CRegKey(); CRegKey *scopes = new CRegKey(); CString strCatalogKey = CATALOGS_KEY + "\\" + strCatalogName; CString strLocationPath = strLocation; rc = catalog->Create(HKEY_LOCAL_MACHINE, strCatalogKey); if (rc == ERROR_SUCCESS) { catalog->SetValue(strLocationPath, _T("Location")); catalog->SetValue(1, _T("FilterFilesWithUnknownExtensions")); catalog->SetValue((DWORD)0, _T("GenerateCharacterization")); catalog->SetValue((DWORD)0, _T("IsIndexingW3Svc")); catalog->SetValue((DWORD)0, _T("IsIndexingNNTPSvc")); catalog->SetValue((DWORD)0, _T("IsIndexingIMAPSvc")); rc = scopes->Create(catalog->m_hKey, _T("Scopes")); if (rc == ERROR_SUCCESS) scopes->Close(); catalog->Close(); } return rc; } extern "C" IXSFUNC_API long CreateScope(char *strCatalogName, char *strPath, char *strConnectAs) { int rc; CRegKey *scopes = new CRegKey(); CString strScopesKey = CATALOGS_KEY + "\\" + strCatalogName + "\\Scopes"; CString strScope = strPath; CString strScopeSettings = ","; strScopeSettings = strScopeSettings + strConnectAs + ",5"; // Settings format is "<unc alias>,<connect as>,<option>" // where <option> is 3 for virtual webdir, 4 to exclude dir and 5 to include dir rc = scopes->Open(HKEY_LOCAL_MACHINE, strScopesKey); if (rc != ERROR_SUCCESS) return rc; rc = scopes->SetValue(strScopeSettings, strScope); scopes->Close(); return rc; } extern "C" IXSFUNC_API long RemoveScope(char *strCatalogName, char *strPath) { int rc; CRegKey *scopes = new CRegKey(); CString strScopesKey = CATALOGS_KEY + "\\" + strCatalogName + "\\Scopes"; CString strScope = strPath; rc = scopes->Open(HKEY_LOCAL_MACHINE, strScopesKey); if (rc != ERROR_SUCCESS) return rc; rc = scopes->DeleteValue(strScope); scopes->Close(); return rc; } CIisfunc::CIisfunc() { return; } Index: php4/ext/isxfunc/ixsfunc.dsp +++ php4/ext/isxfunc/ixsfunc.dsp # Microsoft Developer Studio Project File - Name="ixsfunc" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=ixsfunc - Win32 Release_TS !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "ixsfunc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "ixsfunc.mak" CFG="ixsfunc - Win32 Release_TS" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "ixsfunc - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "ixsfunc - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "ixsfunc - Win32 Release_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "IXSfunc_Release" # PROP Intermediate_Dir "IXSfunc_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IXSFUNC_EXPORTS" /Yu"stdafx.h" /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IXSFUNC_EXPORTS" /D "COMPILE_DL_IXSFUNC" /D ZEND_DEBUG=0 /D ZTS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /FD /c # SUBTRACT CPP /YX /Yc /Yu # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_ixsfunc.dll" /libpath:"p:\php4\Release_TS" !ELSEIF "$(CFG)" == "ixsfunc - Win32 Debug_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "IXSfunc_Debug" # PROP Intermediate_Dir "IXSfunc_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IXSFUNC_EXPORTS" /Yu"stdafx.h" /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IXSFUNC_EXPORTS" /D "COMPILE_DL_IXSFUNC" /D ZEND_DEBUG=1 /D ZTS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_ixsfunc.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" !ENDIF # Begin Target # Name "ixsfunc - Win32 Release_TS" # Name "ixsfunc - Win32 Debug_TS" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\ixsfunc.cpp # End Source File # Begin Source File SOURCE=.\setup.c !IF "$(CFG)" == "ixsfunc - Win32 Release_TS" # SUBTRACT CPP /YX /Yc /Yu !ELSEIF "$(CFG)" == "ixsfunc - Win32 Debug_TS" !ENDIF # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\ixsfunc.h # End Source File # Begin Source File SOURCE=.\setup.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project Index: php4/ext/isxfunc/ixsfunc.h +++ php4/ext/isxfunc/ixsfunc.h /* $Id: ixsfunc.h,v 1.1 2001/12/17 23:59:16 fmk Exp $ */ #ifdef __cplusplus extern "C" { #endif #ifdef IXSFUNC_EXPORTS #define IXSFUNC_API __declspec(dllexport) #else #define IXSFUNC_API __declspec(dllimport) #endif class IXSFUNC_API CIisfunc { public: CIisfunc(void); }; // extern "C" IXSFUNC_API long CatalogExists(char *strCatalogName); #ifdef __cplusplus } #endif Index: php4/ext/isxfunc/setup.c +++ php4/ext/isxfunc/setup.c /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <frank@kromann.info> | +----------------------------------------------------------------------+ */ /* $Id: setup.c,v 1.1 2001/12/17 23:59:16 fmk Exp $ */ /* * Microsoft Index Server administration functions * Uses Registry, because COM administration is not supported on NT */ #include "setup.h" #include <winbase.h> long CatalogExists(char *strCatalogName); long CreateCatalog(char *strCatalogName, char *strLocation); long CreateScope(char *strCatalogName, char *strPath, char *strConnectAs); long RemoveScope(char *strCatalogName, char *strPath); function_entry ixsfunc_functions[] = { PHP_FE(ixscatalogexists, NULL) PHP_FE(ixscreatecatalog, NULL) PHP_FE(ixscreatescope, NULL) PHP_FE(ixsremovescope, NULL) {NULL, NULL, NULL} }; void module_info(void) { php_printf("Swwwing IXS Function API<br>© 2001 Swwwing A/S"); } zend_module_entry ixsfunc_module_entry = { STANDARD_MODULE_HEADER, "IXS_API", ixsfunc_functions, PHP_MINIT(ixsfunc), PHP_MSHUTDOWN(ixsfunc), PHP_RINIT(ixsfunc), PHP_RSHUTDOWN(ixsfunc), PHP_MINFO(ixsfunc), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES }; #if COMPILE_DL_IXSFUNC ZEND_GET_MODULE(ixsfunc) #endif // Initialize user profile with default values PHP_MINIT_FUNCTION(ixsfunc) { return SUCCESS; } PHP_MSHUTDOWN_FUNCTION(ixsfunc) { return SUCCESS; } PHP_RINIT_FUNCTION(ixsfunc) { return SUCCESS; } PHP_RSHUTDOWN_FUNCTION(ixsfunc) { return SUCCESS; } PHP_MINFO_FUNCTION(ixsfunc) { } // Create a PHP3 warning from a Windows system message void Message2Warning(long messageId) { LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, messageId, 0, (LPTSTR) &lpMsgBuf, 0, NULL); php_error(E_WARNING, lpMsgBuf); LocalFree(lpMsgBuf); } /******************************************************************* Function: bool ixsCatalogExists($strCatalogName) Group: IXS Description: Checks registry for catalog key matching given name. Returns true if catalog exists, otherwise false. Parameters: strCatalogName Name of catalog to check for See also: *******************************************************************/ PHP_FUNCTION(ixscatalogexists) { zval **strCatalogName; int argc, rc; // Get and check parameters argc = ZEND_NUM_ARGS(); if (argc != 1 || zend_get_parameters_ex(argc, &strCatalogName) == FAILURE) WRONG_PARAM_COUNT; convert_to_string_ex(strCatalogName); rc = CatalogExists(Z_STRVAL_PP(strCatalogName)); if (rc == ERROR_SUCCESS) RETURN_TRUE else if (rc == ERROR_FILE_NOT_FOUND) RETURN_FALSE else { Message2Warning(rc); RETURN_FALSE; } } /******************************************************************* Function: long ixsCreateCatalog($strCatalogName, $strPath) Group: IXS Description: Creates a new catalog in the given location. Returns true on success, otherwise false and a warning. NOTE: Caller must create a Catalog.wci folder in the given path and restart the index server. Parameters: strCatalogName Name of catalog strPath Location for the index server catalog See also: *******************************************************************/ PHP_FUNCTION(ixscreatecatalog) { zval **strCatalogName, **strPath; int argc, rc; // Get and check parameters argc = ZEND_NUM_ARGS(); if (argc != 2 || zend_get_parameters_ex(argc, &strCatalogName, &strPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_string_ex(strCatalogName); convert_to_string_ex(strPath); rc = CreateCatalog(Z_STRVAL_PP(strCatalogName), Z_STRVAL_PP(strPath)); if (rc == ERROR_SUCCESS) RETURN_TRUE else { Message2Warning(rc); RETURN_FALSE; } } /******************************************************************* Function: long ixsCreateScope($strCatalogName, $strPath [, $strConnectAs]) Group: IXS Description: Creates a new scope/directory in given catalog, if it does no already exist Returns true on success, otherwise false and a warning. Parameters: strCatalogName Name of catalog strPath Scope strConnectAs Optional login for remote machine (default "") See also: *******************************************************************/ PHP_FUNCTION(ixscreatescope) { zval **vCatalogName, **vPath, **vConnectAs; int argc, rc; char *strConnectAs; // Get and check parameters argc = ZEND_NUM_ARGS(); if (argc < 2 || argc > 3 || zend_get_parameters_ex(argc, &vCatalogName, &vPath, &vConnectAs) == FAILURE) WRONG_PARAM_COUNT; convert_to_string_ex(vCatalogName); convert_to_string_ex(vPath); if (argc > 2) { convert_to_string_ex(vConnectAs); strConnectAs = Z_STRVAL_PP(vConnectAs); } else strConnectAs = ""; rc = CreateScope(Z_STRVAL_PP(vCatalogName), Z_STRVAL_PP(vPath), strConnectAs); if (rc == ERROR_SUCCESS) RETURN_TRUE else { Message2Warning(rc); RETURN_FALSE; } RETVAL_LONG(rc); } /******************************************************************* Function: long ixsRemoveScope($strCatalogName, $strPath) Group: IXS Description: Removes scope/directory from given catalog if it exists Returns true on success, otherwise false. If the operation fails for some other reason than that the scope does not exist, a warning is created. Parameters: strCatalogName Name of catalog strPath Scope See also: *******************************************************************/ PHP_FUNCTION(ixsremovescope) { zval **strCatalogName, **strPath; int argc, rc; // Get and check parameters argc = ZEND_NUM_ARGS(); if (argc != 2 || zend_get_parameters_ex(argc, &strCatalogName, &strPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_string_ex(strCatalogName); convert_to_string_ex(strPath); rc = RemoveScope(Z_STRVAL_PP(strCatalogName), Z_STRVAL_PP(strPath)); if (rc == ERROR_SUCCESS) RETURN_TRUE else if (rc == ERROR_FILE_NOT_FOUND) RETURN_FALSE else { Message2Warning(rc); RETURN_FALSE; } } Index: php4/ext/isxfunc/setup.h +++ php4/ext/isxfunc/setup.h /* $Id: setup.h,v 1.1 2001/12/17 23:59:16 fmk Exp $ */ #ifndef _ixs_setup_h #define _ixs_setup_h #include <php.h> #ifdef ZTS #include "TSRM.h" #endif extern zend_module_entry ixsfunc_module_entry; #define ixsfunc_module_ptr &ixsfunc_module_entry // Init function PHP_MINIT_FUNCTION(ixsfunc); PHP_MSHUTDOWN_FUNCTION(ixsfunc); PHP_RINIT_FUNCTION(ixsfunc); PHP_RSHUTDOWN_FUNCTION(ixsfunc); PHP_MINFO_FUNCTION(ixsfunc); PHP_FUNCTION(ixscatalogexists); PHP_FUNCTION(ixscreatecatalog); PHP_FUNCTION(ixscreatescope); PHP_FUNCTION(ixsremovescope); #ifdef ZTS # define IXSFUNC_G(v) TSRMG(ixsfunc_globals_id, zend_ixsfunc_globals *, v) #else # define IXSFUNC_G(v) (ixsfunc_globals.v) #endif #endif
Index: php4/ext/isxfunc/.cvsignore +++ php4/ext/isxfunc/.cvsignore *.plg *.opt *.ncb IXSfunc_Release IXSfunc_Debug Index: php4/ext/isxfunc/ixsfunc.cpp +++ php4/ext/isxfunc/ixsfunc.cpp /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <frank@kromann.info> | +----------------------------------------------------------------------+ */ /* $Id: ixsfunc.cpp,v 1.1 2001/12/17 23:59:16 fmk Exp $ */ /* * Microsoft Index Server administration functions * Uses Registry, because COM administration is not supported on NT */ #define UNICODE #define INITGUID #include <afx.h> #include <stdio.h> #define _ATL_DLL_IMPL #include <ks.h> #include <atlbase.h> // ATL support #include "ixsfunc.h" CString CATALOGS_KEY = "SYSTEM\\CurrentControlSet\\Control\\ContentIndex\\Catalogs"; extern "C" IXSFUNC_API long CatalogExists(char *strCatalogName) { int rc; CRegKey *catalogs = new CRegKey(); CString strCatalogKey = CATALOGS_KEY + "\\" + strCatalogName + "\\Scopes"; rc = catalogs->Open(HKEY_LOCAL_MACHINE, strCatalogKey, MAXIMUM_ALLOWED); if (rc == ERROR_SUCCESS) { catalogs->Close(); rc = 0; } return rc; } extern "C" IXSFUNC_API long CreateCatalog(char *strCatalogName, char *strLocation) { int rc; CRegKey *catalog = new CRegKey(); CRegKey *scopes = new CRegKey(); CString strCatalogKey = CATALOGS_KEY + "\\" + strCatalogName; CString strLocationPath = strLocation; rc = catalog->Create(HKEY_LOCAL_MACHINE, strCatalogKey); if (rc == ERROR_SUCCESS) { catalog->SetValue(strLocationPath, _T("Location")); catalog->SetValue(1, _T("FilterFilesWithUnknownExtensions")); catalog->SetValue((DWORD)0, _T("GenerateCharacterization")); catalog->SetValue((DWORD)0, _T("IsIndexingW3Svc")); catalog->SetValue((DWORD)0, _T("IsIndexingNNTPSvc")); catalog->SetValue((DWORD)0, _T("IsIndexingIMAPSvc")); rc = scopes->Create(catalog->m_hKey, _T("Scopes")); if (rc == ERROR_SUCCESS) scopes->Close(); catalog->Close(); } return rc; } extern "C" IXSFUNC_API long CreateScope(char *strCatalogName, char *strPath, char *strConnectAs) { int rc; CRegKey *scopes = new CRegKey(); CString strScopesKey = CATALOGS_KEY + "\\" + strCatalogName + "\\Scopes"; CString strScope = strPath; CString strScopeSettings = ","; strScopeSettings = strScopeSettings + strConnectAs + ",5"; // Settings format is "<unc alias>,<connect as>,<option>" // where <option> is 3 for virtual webdir, 4 to exclude dir and 5 to include dir rc = scopes->Open(HKEY_LOCAL_MACHINE, strScopesKey); if (rc != ERROR_SUCCESS) return rc; rc = scopes->SetValue(strScopeSettings, strScope); scopes->Close(); return rc; } extern "C" IXSFUNC_API long RemoveScope(char *strCatalogName, char *strPath) { int rc; CRegKey *scopes = new CRegKey(); CString strScopesKey = CATALOGS_KEY + "\\" + strCatalogName + "\\Scopes"; CString strScope = strPath; rc = scopes->Open(HKEY_LOCAL_MACHINE, strScopesKey); if (rc != ERROR_SUCCESS) return rc; rc = scopes->DeleteValue(strScope); scopes->Close(); return rc; } CIisfunc::CIisfunc() { return; } Index: php4/ext/isxfunc/ixsfunc.dsp +++ php4/ext/isxfunc/ixsfunc.dsp # Microsoft Developer Studio Project File - Name="ixsfunc" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=ixsfunc - Win32 Release_TS !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "ixsfunc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "ixsfunc.mak" CFG="ixsfunc - Win32 Release_TS" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "ixsfunc - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "ixsfunc - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "ixsfunc - Win32 Release_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "IXSfunc_Release" # PROP Intermediate_Dir "IXSfunc_Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IXSFUNC_EXPORTS" /Yu"stdafx.h" /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IXSFUNC_EXPORTS" /D "COMPILE_DL_IXSFUNC" /D ZEND_DEBUG=0 /D ZTS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /FD /c # SUBTRACT CPP /YX /Yc /Yu # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 php4ts.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_ixsfunc.dll" /libpath:"p:\php4\Release_TS" !ELSEIF "$(CFG)" == "ixsfunc - Win32 Debug_TS" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "IXSfunc_Debug" # PROP Intermediate_Dir "IXSfunc_Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IXSFUNC_EXPORTS" /Yu"stdafx.h" /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IXSFUNC_EXPORTS" /D "COMPILE_DL_IXSFUNC" /D ZEND_DEBUG=1 /D ZTS=1 /D ZEND_WIN32=1 /D PHP_WIN32=1 /FD /GZ /c # SUBTRACT CPP /YX /Yc /Yu # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 php4ts_debug.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_ixsfunc.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" !ENDIF # Begin Target # Name "ixsfunc - Win32 Release_TS" # Name "ixsfunc - Win32 Debug_TS" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\ixsfunc.cpp # End Source File # Begin Source File SOURCE=.\setup.c !IF "$(CFG)" == "ixsfunc - Win32 Release_TS" # SUBTRACT CPP /YX /Yc /Yu !ELSEIF "$(CFG)" == "ixsfunc - Win32 Debug_TS" !ENDIF # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\ixsfunc.h # End Source File # Begin Source File SOURCE=.\setup.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project Index: php4/ext/isxfunc/ixsfunc.h +++ php4/ext/isxfunc/ixsfunc.h /* $Id: ixsfunc.h,v 1.1 2001/12/17 23:59:16 fmk Exp $ */ #ifdef __cplusplus extern "C" { #endif #ifdef IXSFUNC_EXPORTS #define IXSFUNC_API __declspec(dllexport) #else #define IXSFUNC_API __declspec(dllimport) #endif class IXSFUNC_API CIisfunc { public: CIisfunc(void); }; // extern "C" IXSFUNC_API long CatalogExists(char *strCatalogName); #ifdef __cplusplus } #endif Index: php4/ext/isxfunc/setup.c +++ php4/ext/isxfunc/setup.c /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Frank M. Kromann <frank@kromann.info> | +----------------------------------------------------------------------+ */ /* $Id: setup.c,v 1.1 2001/12/17 23:59:16 fmk Exp $ */ /* * Microsoft Index Server administration functions * Uses Registry, because COM administration is not supported on NT */ #include "setup.h" #include <winbase.h> long CatalogExists(char *strCatalogName); long CreateCatalog(char *strCatalogName, char *strLocation); long CreateScope(char *strCatalogName, char *strPath, char *strConnectAs); long RemoveScope(char *strCatalogName, char *strPath); function_entry ixsfunc_functions[] = { PHP_FE(ixscatalogexists, NULL) PHP_FE(ixscreatecatalog, NULL) PHP_FE(ixscreatescope, NULL) PHP_FE(ixsremovescope, NULL) {NULL, NULL, NULL} }; void module_info(void) { php_printf("Swwwing IXS Function API<br>© 2001 Swwwing A/S"); } zend_module_entry ixsfunc_module_entry = { STANDARD_MODULE_HEADER, "IXS_API", ixsfunc_functions, PHP_MINIT(ixsfunc), PHP_MSHUTDOWN(ixsfunc), PHP_RINIT(ixsfunc), PHP_RSHUTDOWN(ixsfunc), PHP_MINFO(ixsfunc), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES }; #if COMPILE_DL_IXSFUNC ZEND_GET_MODULE(ixsfunc) #endif // Initialize user profile with default values PHP_MINIT_FUNCTION(ixsfunc) { return SUCCESS; } PHP_MSHUTDOWN_FUNCTION(ixsfunc) { return SUCCESS; } PHP_RINIT_FUNCTION(ixsfunc) { return SUCCESS; } PHP_RSHUTDOWN_FUNCTION(ixsfunc) { return SUCCESS; } PHP_MINFO_FUNCTION(ixsfunc) { } // Create a PHP3 warning from a Windows system message void Message2Warning(long messageId) { LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, messageId, 0, (LPTSTR) &lpMsgBuf, 0, NULL); php_error(E_WARNING, lpMsgBuf); LocalFree(lpMsgBuf); } /******************************************************************* Function: bool ixsCatalogExists($strCatalogName) Group: IXS Description: Checks registry for catalog key matching given name. Returns true if catalog exists, otherwise false. Parameters: strCatalogName Name of catalog to check for See also: *******************************************************************/ PHP_FUNCTION(ixscatalogexists) { zval **strCatalogName; int argc, rc; // Get and check parameters argc = ZEND_NUM_ARGS(); if (argc != 1 || zend_get_parameters_ex(argc, &strCatalogName) == FAILURE) WRONG_PARAM_COUNT; convert_to_string_ex(strCatalogName); rc = CatalogExists(Z_STRVAL_PP(strCatalogName)); if (rc == ERROR_SUCCESS) RETURN_TRUE else if (rc == ERROR_FILE_NOT_FOUND) RETURN_FALSE else { Message2Warning(rc); RETURN_FALSE; } } /******************************************************************* Function: long ixsCreateCatalog($strCatalogName, $strPath) Group: IXS Description: Creates a new catalog in the given location. Returns true on success, otherwise false and a warning. NOTE: Caller must create a Catalog.wci folder in the given path and restart the index server. Parameters: strCatalogName Name of catalog strPath Location for the index server catalog See also: *******************************************************************/ PHP_FUNCTION(ixscreatecatalog) { zval **strCatalogName, **strPath; int argc, rc; // Get and check parameters argc = ZEND_NUM_ARGS(); if (argc != 2 || zend_get_parameters_ex(argc, &strCatalogName, &strPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_string_ex(strCatalogName); convert_to_string_ex(strPath); rc = CreateCatalog(Z_STRVAL_PP(strCatalogName), Z_STRVAL_PP(strPath)); if (rc == ERROR_SUCCESS) RETURN_TRUE else { Message2Warning(rc); RETURN_FALSE; } } /******************************************************************* Function: long ixsCreateScope($strCatalogName, $strPath [, $strConnectAs]) Group: IXS Description: Creates a new scope/directory in given catalog, if it does no already exist Returns true on success, otherwise false and a warning. Parameters: strCatalogName Name of catalog strPath Scope strConnectAs Optional login for remote machine (default "") See also: *******************************************************************/ PHP_FUNCTION(ixscreatescope) { zval **vCatalogName, **vPath, **vConnectAs; int argc, rc; char *strConnectAs; // Get and check parameters argc = ZEND_NUM_ARGS(); if (argc < 2 || argc > 3 || zend_get_parameters_ex(argc, &vCatalogName, &vPath, &vConnectAs) == FAILURE) WRONG_PARAM_COUNT; convert_to_string_ex(vCatalogName); convert_to_string_ex(vPath); if (argc > 2) { convert_to_string_ex(vConnectAs); strConnectAs = Z_STRVAL_PP(vConnectAs); } else strConnectAs = ""; rc = CreateScope(Z_STRVAL_PP(vCatalogName), Z_STRVAL_PP(vPath), strConnectAs); if (rc == ERROR_SUCCESS) RETURN_TRUE else { Message2Warning(rc); RETURN_FALSE; } RETVAL_LONG(rc); } /******************************************************************* Function: long ixsRemoveScope($strCatalogName, $strPath) Group: IXS Description: Removes scope/directory from given catalog if it exists Returns true on success, otherwise false. If the operation fails for some other reason than that the scope does not exist, a warning is created. Parameters: strCatalogName Name of catalog strPath Scope See also: *******************************************************************/ PHP_FUNCTION(ixsremovescope) { zval **strCatalogName, **strPath; int argc, rc; // Get and check parameters argc = ZEND_NUM_ARGS(); if (argc != 2 || zend_get_parameters_ex(argc, &strCatalogName, &strPath) == FAILURE) WRONG_PARAM_COUNT; convert_to_string_ex(strCatalogName); convert_to_string_ex(strPath); rc = RemoveScope(Z_STRVAL_PP(strCatalogName), Z_STRVAL_PP(strPath)); if (rc == ERROR_SUCCESS) RETURN_TRUE else if (rc == ERROR_FILE_NOT_FOUND) RETURN_FALSE else { Message2Warning(rc); RETURN_FALSE; } } Index: php4/ext/isxfunc/setup.h +++ php4/ext/isxfunc/setup.h /* $Id: setup.h,v 1.1 2001/12/17 23:59:16 fmk Exp $ */ #ifndef _ixs_setup_h #define _ixs_setup_h #include <php.h> #ifdef ZTS #include "TSRM.h" #endif extern zend_module_entry ixsfunc_module_entry; #define ixsfunc_module_ptr &ixsfunc_module_entry // Init function PHP_MINIT_FUNCTION(ixsfunc); PHP_MSHUTDOWN_FUNCTION(ixsfunc); PHP_RINIT_FUNCTION(ixsfunc); PHP_RSHUTDOWN_FUNCTION(ixsfunc); PHP_MINFO_FUNCTION(ixsfunc); PHP_FUNCTION(ixscatalogexists); PHP_FUNCTION(ixscreatecatalog); PHP_FUNCTION(ixscreatescope); PHP_FUNCTION(ixsremovescope); #ifdef ZTS # define IXSFUNC_G(v) TSRMG(ixsfunc_globals_id, zend_ixsfunc_globals *, v) #else # define IXSFUNC_G(v) (ixsfunc_globals.v) #endif #endif