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 \brief
\95\
\8e¦
\83\81\83b
\83Z
\81[
\83W
\82Ì
\90®
\8c`
50 \param msg
\95\
\8e¦
\82·
\82é
\83\81\83b
\83Z
\81[
\83W
51 \param elements
\92u
\8a·
\92P
\8cê
53 msg
\82Ì
\92\86\82Ì
\92u
\8a·
\82³
\82ê
\82é
\92P
\8cê
\82Í '^
\94Ô
\8d\86'
\82Å
\95\
\82³
\82ê
\81A
54 elements
\82Í
\89ü
\8ds
\82É
\82æ
\82Á
\82Ä
\92P
\8cê
\95ª
\82¯
\82³
\82ê
\82Ü
\82·
\81B<br>
57 elements := IntToStr( 10 ) + #10 + 'hoge';
59 '^0
\8cÂ
\82Ì
\81g^1
\81h
\82ð
\92u
\8a·
\82µ
\82Ü
\82µ
\82½
\81B',
63 \82Å
\8fo
\97Í
\82³
\82ê
\82é m
\82Í
\81u10
\8cÂ
\82Ì
\81ghoge
\81h
\82ð
\92u
\8a·
\82µ
\82Ü
\82µ
\82½
\81B
\81v
\82Æ
\82È
\82è
\82Ü
\82·
\81B
65 function MessageStyle(
67 const elements : string
70 function MessageStyle(
72 const elements : TStringList
76 /// Mode
\92l
\82ª
\82¨
\82©
\82µ
\82¢
77 EMappedFileModeError = class( Exception );
78 ///
\83}
\83b
\83s
\83\93\83O
\82É
\8e¸
\94s
79 EMappedFileMappingError = class( Exception );
81 ///
\83\81\83\82\83\8a\83}
\83b
\83v
\83h
\81E
\83t
\83@
\83C
\83\8b \83N
\83\89\83X
82 TMappedFile = class( TObject )
84 FFileHandle : THandle;
85 FMappingHandle : THandle;
87 FViewAddress : Pointer;
89 constructor Create( const filePath : string; mode : Longword = fmOpenRead );
90 destructor Destroy; override;
92 ///
\83T
\83C
\83Y
\82Ì
\8eæ
\93¾
93 property Size : Longword read FSize;
94 ///
\83A
\83h
\83\8c\83X
\82Ì
\8eæ
\93¾
95 property Memory : Pointer read FViewAddress;
98 //==================================================
100 //==================================================
101 kYofKanji : TSysCharSet = [#$80..#$A0, #$E0..#$ff];
103 //==================================================
105 //==================================================
109 //
\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
110 procedure ExtractHttpFields(
111 const chrSep : TSysCharSet;
112 const chrWhite : TSysCharSet;
113 const strValue : string;
114 var strResult : TStringList;
115 unknownFlag : boolean = false
118 last, p, strLen : Integer;
121 strLen := Length( strValue );
128 if strValue[ p ] in chrSep then
130 strResult.Add( Copy( strValue, last, p - last ) );
139 strResult.Add( Copy( strValue, last, strLen - last + 1 ) );
144 const strValue : string
152 strLen := Length( strValue );
158 case strValue[ i ] of
161 strResult := strResult + '&';
165 strResult := strResult + '<';
169 strResult := strResult + '>';
173 strResult := strResult + '"';
177 if strValue[ i ] in kYofKanji then
179 strResult := strResult + strValue[ i ];
182 strResult := strResult + strValue[ i ];
195 const strValue : string
201 strResult := StringReplace( strValue, '<', '<', [rfReplaceAll] );
202 strResult := StringReplace( strResult, '>', '>', [rfReplaceAll] );
203 strResult := StringReplace( strResult, '"', '"', [rfReplaceAll] );
204 strResult := StringReplace( strResult, '&', '&', [rfReplaceAll] );
211 const strValue : string
219 kHexCode : array [0..15] of char = (
220 '0', '1', '2', '3', '4', '5', '6', '7',
221 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' );
224 strLen := Length( strValue );
230 case strValue[ i ] of
231 '0' .. '9', 'a' .. 'z', 'A' .. 'Z', '*', '-', '.', '@', '_':
233 strResult := strResult + strValue[ i ];
237 b := Integer( strValue[ i ] );
238 strResult := strResult + '%'
239 + kHexCode[ b div $10 ]
240 + kHexCode[ b mod $10 ];
256 mov ecx, eax // ecx = (ch - 'a')
258 cmp ecx, 26 // edx = ecx < 26 (
\8f¬
\95¶
\8e\9a\82È
\82ç
\83t
\83\8b\83r
\83b
\83g)
260 and edx, $20 // edx &= 0x20 (
\8f¬
\95¶
\8e\9a\82È
\82ç 0x20)
261 xor eax, edx // eax ^= edx
265 const strValue : string
274 strLen := Length( strValue );
280 if '%' = strValue[ i ] then begin
282 if strValue[ i ] in ['a' .. 'z', 'A' .. 'Z'] then
283 b := (toupper( Longword( strValue[ i ] ) ) - 55) shl 4
285 b := (Byte( strValue[ i ] ) - Byte( '0' )) shl 4;
287 if strValue[ i ] in ['a' .. 'z', 'A' .. 'Z'] then
288 b := b or (toupper( Longword( strValue[ i ] ) ) - 55)
290 b := b or (Byte( strValue[ i ] ) - Byte( '0' ));
292 strResult := strResult + Char( Byte( b ) );
294 strResult := strResult + strValue[ i ];
305 //
\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
306 function MatchesMask(
307 const filename, mask : string
310 pName, pMask : Integer;
311 ptrName, ptrMask : PChar;
312 nameLen, maskLen : Integer;
314 delimiterPos : Integer;
317 nameLen := Length( filename );
318 maskLen := Length( mask );
319 ptrName := PChar( filename );
320 ptrMask := PChar( mask );
323 delimiterPos := Pos( '\', string( ptrName + pName ) );
324 while delimiterPos > 0 do
326 pName := pName + delimiterPos;
327 delimiterPos := Pos( '\', string( ptrName + pName ) );
330 while (pMask < maskLen) and (pName < nameLen) do
333 case ptrMask[ pMask ] of
336 //
\82±
\82Ì 1
\8e\9a\82Í
\89½
\82à
\82µ
\82È
\82¢
341 // mask
\82ð
\91\96\8d¸
\82µ
\90Ø
\82Á
\82½
\82ç
\8fI
\97¹
342 if pMask >= maskLen then
348 // *
\82Ì
\8e\9f\82Ì
\95¶
\8e\9a\82ª
\97\88\82é
\82Ü
\82Å
\94ò
\82Î
\82·
349 chrUpMask := upcase( ptrMask[ pMask ] );
350 while chrUpMask <> UpCase( ptrName[ pName ] ) do
353 if pName >= nameLen then
360 // *
\82Ì
\8e\9f\82Ì
\95¶
\8e\9a\82ª
\8c©
\82Â
\82©
\82ç
\82È
\82©
\82Á
\82½
\82ç
\8fI
\97¹
361 if chrUpMask <> UpCase( ptrName[ pName ] ) then
372 //
\82±
\82Ì 1
\95¶
\8e\9a\82ª
\88á
\82Á
\82½
\82ç
\8fI
\97¹
373 if UpCase( ptrMask[ pMask ] ) <> UpCase( ptrName[ pName ] ) then
382 //
\8e\9f\82Ì
\95¶
\8e\9a\82Ö
388 if (pMask >= maskLen) and (pName >= nameLen) then
396 //
\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·
397 function RegExpEncode(
404 strResult := StringReplace( text, '\', '\\', [rfReplaceAll] );
405 strResult := StringReplace( strResult, '[', '\[', [rfReplaceAll] );
406 strResult := StringReplace( strResult, ']', '\]', [rfReplaceAll] );
407 strResult := StringReplace( strResult, '(', '\(', [rfReplaceAll] );
408 strResult := StringReplace( strResult, ')', '\)', [rfReplaceAll] );
409 strResult := StringReplace( strResult, '[', '\[', [rfReplaceAll] );
410 strResult := StringReplace( strResult, ']', '\]', [rfReplaceAll] );
411 strResult := StringReplace( strResult, '*', '\*', [rfReplaceAll] );
412 strResult := StringReplace( strResult, '?', '\?', [rfReplaceAll] );
413 strResult := StringReplace( strResult, '.', '\.', [rfReplaceAll] );
414 strResult := StringReplace( strResult, '+', '\+', [rfReplaceAll] );
415 strResult := StringReplace( strResult, '|', '\|', [rfReplaceAll] );
416 strResult := StringReplace( strResult, '^', '\^', [rfReplaceAll] );
417 strResult := StringReplace( strResult, '$', '\$', [rfReplaceAll] );
423 function MessageStyle(
425 const elements : string
431 list := TStringList.Create;
433 list.Text := elements;
434 Result := MessageStyle( msg, list );
441 function MessageStyle(
443 const elements : TStringList
450 for i := elements.Count - 1 downto 0 do
451 Result := CustomStringReplace( Result, '^' + IntToStr( i ), elements[ i ], false );
458 \brief
\83\81\83\82\83\8a\83}
\83b
\83v
\83h
\83t
\83@
\83C
\83\8b\82Ì
\8dì
\90¬
459 \param filePath
\8aJ
\82
\83t
\83@
\83C
\83\8b\82Ì
\83p
\83X
460 \param mode fmOpenRead (
\83f
\83t
\83H
\83\8b\83g)
\82Ü
\82½
\82Í fmOpenReadWrite
462 constructor TMappedFile.Create( const filePath : string; mode : Longword = fmOpenRead );
464 dwFileDesiredAccess : DWORD;
466 dwViewDesiredAccess : DWORD;
472 dwFileDesiredAccess := GENERIC_READ;
473 flProtect := PAGE_READONLY;
474 dwViewDesiredAccess := FILE_MAP_READ;
479 dwFileDesiredAccess := GENERIC_READ or GENERIC_WRITE;
480 flProtect := PAGE_READWRITE;
481 dwViewDesiredAccess := FILE_MAP_WRITE;
485 raise EMappedFileModeError.Create( '
\83t
\83@
\83C
\83\8b\83I
\81[
\83v
\83\93\82Ì
\83\82\81[
\83h
\82ª
\95s
\90³
\82Å
\82·
\81B' );
488 FFileHandle := CreateFile(
489 PChar( filePath ), dwFileDesiredAccess, 0, nil, OPEN_EXISTING,
490 FILE_ATTRIBUTE_NORMAL, 0 );
491 if FFileHandle = INVALID_HANDLE_VALUE then
492 raise EFOpenError.Create( '
\83t
\83@
\83C
\83\8b\82Ì
\83I
\81[
\83v
\83\93\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\81B' );
494 FSize := GetFileSize( FFileHandle, nil );
496 FMappingHandle := CreateFileMapping(
497 FFileHandle, nil, flProtect, 0, 0, nil );
498 if FFileHandle = INVALID_HANDLE_VALUE then
499 raise EMappedFileMappingError.Create( '
\83t
\83@
\83C
\83\8b\82Ì
\83}
\83b
\83s
\83\93\83O
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\81B' );
501 FViewAddress := MapViewOfFile( FMappingHandle, dwViewDesiredAccess, 0, 0, 0 );
502 if FViewAddress = nil then
503 raise EMappedFileMappingError.Create( '
\83t
\83@
\83C
\83\8b\82Ì
\83}
\83b
\83s
\83\93\83O
\82É
\8e¸
\94s
\82µ
\82Ü
\82µ
\82½
\81B' );
507 destructor TMappedFile.Destroy;
510 UnmapViewOfFile( FViewAddress );
511 CloseHandle( FMappingHandle );
512 CloseHandle( FFileHandle );