4 HttpApp
\82Ì
\83N
\83\8d\81[
\83\93\82â
\82»
\82Ì
\91¼
\8eG
\97p
\8aÖ
\90\94
8 //==================================================
10 //==================================================
15 procedure ExtractHttpFields(
16 const chrSep : TSysCharSet;
17 const chrWhite : TSysCharSet;
18 const strValue : string;
19 var strResult : TStringList;
20 unknownFlag : boolean = false
24 const strValue : string
28 const strValue : string
32 const strValue : string
36 const strValue : string
40 const filename, mask : string
43 //
\83\81\83^
\83L
\83\83\83\89\83N
\83^
\82ð
\90³
\8bK
\95\
\8c»
\88µ
\82¢
\82É
\82È
\82ç
\82È
\82¢
\82æ
\82¤
\82É
\92u
\8a·
44 function RegExpEncode(
49 /// Mode
\92l
\82ª
\82¨
\82©
\82µ
\82¢
50 EMappedFileModeError = class( Exception );
51 ///
\83}
\83b
\83s
\83\93\83O
\82É
\8e¸
\94s
52 EMappedFileMappingError = class( Exception );
54 ///
\83\81\83\82\83\8a\83}
\83b
\83v
\83h
\81E
\83t
\83@
\83C
\83\8b \83N
\83\89\83X
55 TMappedFile = class( TObject )
57 FFileHandle : THandle;
58 FMappingHandle : THandle;
60 FViewAddress : Pointer;
62 constructor Create( const filePath : string; mode : Longword = fmOpenRead );
63 destructor Destroy; override;
65 ///
\83T
\83C
\83Y
\82Ì
\8eæ
\93¾
66 property Size : Longword read FSize;
67 ///
\83A
\83h
\83\8c\83X
\82Ì
\8eæ
\93¾
68 property Memory : Pointer read FViewAddress;
71 //==================================================
73 //==================================================
74 kYofKanji : TSysCharSet = [#$80..#$A0, #$E0..#$ff];
76 //==================================================
78 //==================================================
80 //
\82Æ
\82è
\82 \82¦
\82¸
\82Ì
\91ã
\97p
\95i
\82È
\82Ì
\82Å chrWhite
\82ð
\8dl
\97¶
\82µ
\82Ä
\82¢
\82È
\82¢
\82±
\82Æ
\82É
\92\8d\88Ó
\81I
\81I
\81I
81 procedure ExtractHttpFields(
82 const chrSep : TSysCharSet;
83 const chrWhite : TSysCharSet;
84 const strValue : string;
85 var strResult : TStringList;
86 unknownFlag : boolean = false
89 last, p, strLen : Integer;
92 strLen := Length( strValue );
99 if strValue[ p ] in chrSep then
101 strResult.Add( Copy( strValue, last, p - last ) );
110 strResult.Add( Copy( strValue, last, strLen - last + 1 ) );
115 const strValue : string
123 strLen := Length( strValue );
129 case strValue[ i ] of
132 strResult := strResult + '&';
136 strResult := strResult + '<';
140 strResult := strResult + '>';
144 strResult := strResult + '"';
148 if strValue[ i ] in kYofKanji then
150 strResult := strResult + strValue[ i ];
153 strResult := strResult + strValue[ i ];
166 const strValue : string
172 strResult := StringReplace( strValue, '<', '<', [rfReplaceAll] );
173 strResult := StringReplace( strResult, '>', '>', [rfReplaceAll] );
174 strResult := StringReplace( strResult, '"', '"', [rfReplaceAll] );
175 strResult := StringReplace( strResult, '&', '&', [rfReplaceAll] );
182 const strValue : string
190 kHexCode : array [0..15] of char = (
191 '0', '1', '2', '3', '4', '5', '6', '7',
192 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' );
195 strLen := Length( strValue );
201 case strValue[ i ] of
202 '0' .. '9', 'a' .. 'z', 'A' .. 'Z', '*', '-', '.', '@', '_':
204 strResult := strResult + strValue[ i ];
208 b := Integer( strValue[ i ] );
209 strResult := strResult + '%'
210 + kHexCode[ b div $10 ]
211 + kHexCode[ b mod $10 ];
227 mov ecx, eax // ecx = (ch - 'a')
229 cmp ecx, 26 // edx = ecx < 26 (
\8f¬
\95¶
\8e\9a\82È
\82ç
\83t
\83\8b\83r
\83b
\83g)
231 and edx, $20 // edx &= 0x20 (
\8f¬
\95¶
\8e\9a\82È
\82ç 0x20)
232 xor eax, edx // eax ^= edx
236 const strValue : string
245 strLen := Length( strValue );
251 if '%' = strValue[ i ] then begin
253 if strValue[ i ] in ['a' .. 'z', 'A' .. 'Z'] then
254 b := (toupper( Longword( strValue[ i ] ) ) - 55) shl 4
256 b := (Byte( strValue[ i ] ) - Byte( '0' )) shl 4;
258 if strValue[ i ] in ['a' .. 'z', 'A' .. 'Z'] then
259 b := b or (toupper( Longword( strValue[ i ] ) ) - 55)
261 b := b or (Byte( strValue[ i ] ) - Byte( '0' ));
263 strResult := strResult + Char( Byte( b ) );
265 strResult := strResult + strValue[ i ];
276 //
\82Æ
\82è
\82 \82¦
\82¸
\82Ì
\91ã
\97p
\95i
\82È
\82Ì
\82Å []
\82ð
\8eg
\82Á
\82½
\90³
\8bK
\95\
\8c»
\82ð
\8dl
\97¶
\82µ
\82Ä
\82¢
\82È
\82¢
\82±
\82Æ
\82É
\92\8d\88Ó
\81I
\81I
\81I
277 function MatchesMask(
278 const filename, mask : string
281 pName, pMask : Integer;
282 ptrName, ptrMask : PChar;
283 nameLen, maskLen : Integer;
285 delimiterPos : Integer;
288 nameLen := Length( filename );
289 maskLen := Length( mask );
290 ptrName := PChar( filename );
291 ptrMask := PChar( mask );
294 delimiterPos := Pos( '\', string( ptrName + pName ) );
295 while delimiterPos > 0 do
297 pName := pName + delimiterPos;
298 delimiterPos := Pos( '\', string( ptrName + pName ) );
301 while (pMask < maskLen) and (pName < nameLen) do
304 case ptrMask[ pMask ] of
307 //
\82±
\82Ì 1
\8e\9a\82Í
\89½
\82à
\82µ
\82È
\82¢
312 // mask
\82ð
\91\96\8d¸
\82µ
\90Ø
\82Á
\82½
\82ç
\8fI
\97¹
313 if pMask >= maskLen then
319 // *
\82Ì
\8e\9f\82Ì
\95¶
\8e\9a\82ª
\97\88\82é
\82Ü
\82Å
\94ò
\82Î
\82·
320 chrUpMask := upcase( ptrMask[ pMask ] );
321 while chrUpMask <> UpCase( ptrName[ pName ] ) do
324 if pName >= nameLen then
331 // *
\82Ì
\8e\9f\82Ì
\95¶
\8e\9a\82ª
\8c©
\82Â
\82©
\82ç
\82È
\82©
\82Á
\82½
\82ç
\8fI
\97¹
332 if chrUpMask <> UpCase( ptrName[ pName ] ) then
343 //
\82±
\82Ì 1
\95¶
\8e\9a\82ª
\88á
\82Á
\82½
\82ç
\8fI
\97¹
344 if UpCase( ptrMask[ pMask ] ) <> UpCase( ptrName[ pName ] ) then
353 //
\8e\9f\82Ì
\95¶
\8e\9a\82Ö
359 if (pMask >= maskLen) and (pName >= nameLen) then
367 //
\83\81\83^
\83L
\83\83\83\89\83N
\83^
\82ð
\90³
\8bK
\95\
\8c»
\88µ
\82¢
\82É
\82È
\82ç
\82È
\82¢
\82æ
\82¤
\82É
\92u
\8a·
368 function RegExpEncode(
375 strResult := StringReplace( text, '\', '\\', [rfReplaceAll] );
376 strResult := StringReplace( strResult, '[', '\[', [rfReplaceAll] );
377 strResult := StringReplace( strResult, ']', '\]', [rfReplaceAll] );
378 strResult := StringReplace( strResult, '(', '\(', [rfReplaceAll] );
379 strResult := StringReplace( strResult, ')', '\)', [rfReplaceAll] );
380 strResult := StringReplace( strResult, '[', '\[', [rfReplaceAll] );
381 strResult := StringReplace( strResult, ']', '\]', [rfReplaceAll] );
382 strResult := StringReplace( strResult, '*', '\*', [rfReplaceAll] );
383 strResult := StringReplace( strResult, '?', '\?', [rfReplaceAll] );
384 strResult := StringReplace( strResult, '.', '\.', [rfReplaceAll] );
385 strResult := StringReplace( strResult, '+', '\+', [rfReplaceAll] );
386 strResult := StringReplace( strResult, '|', '\|', [rfReplaceAll] );
387 strResult := StringReplace( strResult, '^', '\^', [rfReplaceAll] );
388 strResult := StringReplace( strResult, '$', '\$', [rfReplaceAll] );
397 \brief
\83\81\83\82\83\8a\83}
\83b
\83v
\83h
\83t
\83@
\83C
\83\8b\82Ì
\8dì
\90¬
398 \param filePath
\8aJ
\82
\83t
\83@
\83C
\83\8b\82Ì
\83p
\83X
399 \param mode fmOpenRead (
\83f
\83t
\83H
\83\8b\83g)
\82Ü
\82½
\82Í fmOpenReadWrite
401 constructor TMappedFile.Create( const filePath : string; mode : Longword = fmOpenRead );
403 dwFileDesiredAccess : DWORD;
405 dwViewDesiredAccess : DWORD;
411 dwFileDesiredAccess := GENERIC_READ;
412 flProtect := PAGE_READONLY;
413 dwViewDesiredAccess := FILE_MAP_READ;
418 dwFileDesiredAccess := GENERIC_READ or GENERIC_WRITE;
419 flProtect := PAGE_READWRITE;
420 dwViewDesiredAccess := FILE_MAP_WRITE;
424 raise EMappedFileModeError.Create( '
\83t
\83@
\83C
\83\8b\83I
\81[
\83v
\83\93\82Ì
\83\82\81[
\83h
\82ª
\95s
\90³
\82Å
\82·
\81B' );
427 FFileHandle := CreateFile(
428 PChar( filePath ), dwFileDesiredAccess, 0, nil, OPEN_EXISTING,
429 FILE_ATTRIBUTE_NORMAL, 0 );
430 if FFileHandle = INVALID_HANDLE_VALUE then
431 raise EFOpenError.Create( '
\83t
\83@
\83C
\83\8b\82Ì
\83I
\81[
\83v
\83\93\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\81B' );
433 FSize := GetFileSize( FFileHandle, nil );
435 FMappingHandle := CreateFileMapping(
436 FFileHandle, nil, flProtect, 0, 0, nil );
437 if FFileHandle = INVALID_HANDLE_VALUE then
438 raise EMappedFileMappingError.Create( '
\83t
\83@
\83C
\83\8b\82Ì
\83}
\83b
\83s
\83\93\83O
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\81B' );
440 FViewAddress := MapViewOfFile( FMappingHandle, dwViewDesiredAccess, 0, 0, 0 );
441 if FViewAddress = nil then
442 raise EMappedFileMappingError.Create( '
\83t
\83@
\83C
\83\8b\82Ì
\83}
\83b
\83s
\83\93\83O
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\81B' );
446 destructor TMappedFile.Destroy;
449 UnmapViewOfFile( FViewAddress );
450 CloseHandle( FMappingHandle );
451 CloseHandle( FFileHandle );