Fossil ISAPI

Check-in [89e4f22c5f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed some bugs. Cookies still buggy!
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:89e4f22c5f1b685dffbf7f8b2f911dbe2eed72ef
User & Date: K.Inanloo 2012-12-23 16:50:35
Context
2012-12-31
00:09
Fixed anything except cookie! Now all headers are sent correctly. Leaf check-in: 8559f2a709 user: Kamyar tags: trunk
2012-12-23
16:50
Fixed some bugs. Cookies still buggy! check-in: 89e4f22c5f user: K.Inanloo tags: trunk
10:31
Beta release. Still buggy! check-in: 8cd27df06e user: K.Inanloo tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to FossilIsapi/FossilIsapi.cpp.

1
2
3
4
5
6
7

8
9
10
11
12
13
14
..
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41











42
43
44
45
46



47
48
49
50
51
52
53
54
55
56
57
58
59


60


61
62
63
64
// FossilIsapi.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "FossilIsapi.h"
#include <iomanip>
#include <iostream>


BOOL WINAPI
	GetExtensionVersion( HSE_VERSION_INFO *pVer )
{
	/*  Set the extension version */
	pVer->dwExtensionVersion = HSE_VERSION;
	/*  Set a description string for the extension */
................................................................................


/*  This function is called when the extension is accessed */
DWORD WINAPI
	HttpExtensionProc( LPEXTENSION_CONTROL_BLOCK ecb )
{
	char *header   = new char[255];
	DWORD headerlen;
	DWORD msglen;

	/* Use a server support function to write out a header with our
	additional header information */


	std::string output;
	const int MAX_BUFFER = 255;
	char buffer[MAX_BUFFER];

	_putenv_s("PATH_INFO", ecb->lpszPathInfo);
	_putenv_s("QUERY_STRING", ecb->lpszQueryString);
	_putenv_s("REQUEST_METHOD", ecb->lpszMethod);	
	_putenv_s("REQUEST_URI", ecb->lpszPathTranslated);
	_putenv_s("GATEWAY_INTERFACE", "CGI/1.1");












	char* fossil = new char[255];
	sprintf_s(fossil, 255, "fossil %s", std::getenv("FOSSIL_CONFIG"));
	FILE *stream = _popen(fossil, "r");
	



	while(fscanf_s(stream, "%[^\n]", header, 255)) {
		headerlen  = strlen( header );
		ecb->ServerSupportFunction( ecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER, 0,
			&headerlen, (DWORD *)header );
	}
	
	while ( fgets(buffer, MAX_BUFFER, stream) != NULL )
		output.append(buffer);
	_pclose(stream);


	msglen = output.length();
	LPCSTR msg = output.c_str();


	ecb->WriteClient( ecb->ConnID,(LPVOID) msg, &msglen, 0 );



	/* Return, indicating success */
	return HSE_STATUS_SUCCESS;
}







>







 







|
<






|
|



|
<
|
>
>
>
>
>
>
>
>
>
>
>



|
|
>
>
>






<
<
<

<
<
<
>
>
|
>
>
|



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
..
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
35
36
37
38
39

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65



66



67
68
69
70
71
72
73
74
75
// FossilIsapi.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "FossilIsapi.h"
#include <iomanip>
#include <iostream>
#include <array>

BOOL WINAPI
	GetExtensionVersion( HSE_VERSION_INFO *pVer )
{
	/*  Set the extension version */
	pVer->dwExtensionVersion = HSE_VERSION;
	/*  Set a description string for the extension */
................................................................................


/*  This function is called when the extension is accessed */
DWORD WINAPI
	HttpExtensionProc( LPEXTENSION_CONTROL_BLOCK ecb )
{
	char *header   = new char[255];
	DWORD headerlen;	


	/* Use a server support function to write out a header with our
	additional header information */


	std::string output;
	const int MAX_BUFFER = 4096;
	char* buffer = (char*) malloc(MAX_BUFFER);

	_putenv_s("PATH_INFO", ecb->lpszPathInfo);
	_putenv_s("QUERY_STRING", ecb->lpszQueryString);
	_putenv_s("REQUEST_METHOD", ecb->lpszMethod);

	_putenv_s("GATEWAY_INTERFACE", "CGI/1.1");	
		

	DWORD size= 255;

	char* lpString[] = {"HTTP_HOST" , "HTTP_REFERER", "HTTP_COOKIE", "DOCUMENT_ROOT", "REQUEST_URI", "SERVER_NAME", "SERVER_PORT"};

	for(int i = 0; i < (sizeof(lpString)/sizeof(*lpString)); i++){
		char* value = new char[255];
		ecb->GetServerVariable(ecb->ConnID, lpString[i], value, &size);		
		_putenv_s(lpString[i], value);
	}

	char* fossil = new char[255];
	sprintf_s(fossil, 255, "fossil %s", std::getenv("FOSSIL_CONFIG"));
	FILE *stream = _popen(fossil, "r");	

	ecb->ServerSupportFunction( ecb->ConnID, HSE_REQ_SET_FLUSH_FLAG, (LPVOID) TRUE,
		NULL, NULL);

	while(fscanf_s(stream, "%[^\n]", header, 255)) {
		headerlen  = strlen( header );
		ecb->ServerSupportFunction( ecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER, 0,
			&headerlen, (DWORD *)header );
	}
	







	SIZE_T len;
	while ((len = fread(buffer, 1, MAX_BUFFER, stream)) != NULL )
		ecb->WriteClient( ecb->ConnID, buffer, &len, 0 );	
	free(buffer);
	_pclose(stream);	
	
	/* Return, indicating success */
	return HSE_STATUS_SUCCESS;
}

Changes to FossilIsapi/FossilIsapi.vcxproj.

110
111
112
113
114
115
116

117
118
119
120
121
122
123
      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FOSSILISAPI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>

    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PrecompiledHeader>Use</PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>







>







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FOSSILISAPI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <SubSystem>Windows</SubSystem>
      <GenerateDebugInformation>true</GenerateDebugInformation>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
      <ModuleDefinitionFile>fossilisapi.def</ModuleDefinitionFile>
    </Link>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <WarningLevel>Level3</WarningLevel>
      <PrecompiledHeader>Use</PrecompiledHeader>
      <Optimization>MaxSpeed</Optimization>