- Timestamp:
- May 22, 2016, 1:01:52 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Library/ACLUtility.pas
r309 r400 149 149 end; 150 150 151 {$ifdef os2} 152 function GetCrc32( pData: pointer; size: longint ): longword; 153 {$endif} 154 155 function Pascal_GetCrc32( pData: pointer; size: longint ): longword; 156 151 157 // Raise an exception if the given Code is <> 0 152 158 procedure CheckSystemError( Code: longword; … … 154 160 155 161 {$ifdef os2} 162 // get pointer to start, and length, of specified parameter 163 procedure GetCommandLineParameter( item: byte; 164 var pParam: pchar; 165 var ParamLength: longint ); 166 156 167 function GetUserProfileString( const AppName: string; 157 168 const KeyName: string; … … 514 525 {$endif} 515 526 527 const 528 Crc32Table: array[ 0..255 ] of longword = 529 ( 530 $00000000, $77073096, $EE0E612C, $990951BA, 531 $076DC419, $706AF48F, $E963A535, $9E6495A3, 532 $0EDB8832, $79DCB8A4, $E0D5E91E, $97D2D988, 533 $09B64C2B, $7EB17CBD, $E7B82D07, $90BF1D91, 534 $1DB71064, $6AB020F2, $F3B97148, $84BE41DE, 535 $1ADAD47D, $6DDDE4EB, $F4D4B551, $83D385C7, 536 $136C9856, $646BA8C0, $FD62F97A, $8A65C9EC, 537 $14015C4F, $63066CD9, $FA0F3D63, $8D080DF5, 538 $3B6E20C8, $4C69105E, $D56041E4, $A2677172, 539 $3C03E4D1, $4B04D447, $D20D85FD, $A50AB56B, 540 $35B5A8FA, $42B2986C, $DBBBC9D6, $ACBCF940, 541 $32D86CE3, $45DF5C75, $DCD60DCF, $ABD13D59, 542 $26D930AC, $51DE003A, $C8D75180, $BFD06116, 543 $21B4F4B5, $56B3C423, $CFBA9599, $B8BDA50F, 544 $2802B89E, $5F058808, $C60CD9B2, $B10BE924, 545 $2F6F7C87, $58684C11, $C1611DAB, $B6662D3D, 546 $76DC4190, $01DB7106, $98D220BC, $EFD5102A, 547 $71B18589, $06B6B51F, $9FBFE4A5, $E8B8D433, 548 $7807C9A2, $0F00F934, $9609A88E, $E10E9818, 549 $7F6A0DBB, $086D3D2D, $91646C97, $E6635C01, 550 $6B6B51F4, $1C6C6162, $856530D8, $F262004E, 551 $6C0695ED, $1B01A57B, $8208F4C1, $F50FC457, 552 $65B0D9C6, $12B7E950, $8BBEB8EA, $FCB9887C, 553 $62DD1DDF, $15DA2D49, $8CD37CF3, $FBD44C65, 554 $4DB26158, $3AB551CE, $A3BC0074, $D4BB30E2, 555 $4ADFA541, $3DD895D7, $A4D1C46D, $D3D6F4FB, 556 $4369E96A, $346ED9FC, $AD678846, $DA60B8D0, 557 $44042D73, $33031DE5, $AA0A4C5F, $DD0D7CC9, 558 $5005713C, $270241AA, $BE0B1010, $C90C2086, 559 $5768B525, $206F85B3, $B966D409, $CE61E49F, 560 $5EDEF90E, $29D9C998, $B0D09822, $C7D7A8B4, 561 $59B33D17, $2EB40D81, $B7BD5C3B, $C0BA6CAD, 562 $EDB88320, $9ABFB3B6, $03B6E20C, $74B1D29A, 563 $EAD54739, $9DD277AF, $04DB2615, $73DC1683, 564 $E3630B12, $94643B84, $0D6D6A3E, $7A6A5AA8, 565 $E40ECF0B, $9309FF9D, $0A00AE27, $7D079EB1, 566 $F00F9344, $8708A3D2, $1E01F268, $6906C2FE, 567 $F762575D, $806567CB, $196C3671, $6E6B06E7, 568 $FED41B76, $89D32BE0, $10DA7A5A, $67DD4ACC, 569 $F9B9DF6F, $8EBEEFF9, $17B7BE43, $60B08ED5, 570 $D6D6A3E8, $A1D1937E, $38D8C2C4, $4FDFF252, 571 $D1BB67F1, $A6BC5767, $3FB506DD, $48B2364B, 572 $D80D2BDA, $AF0A1B4C, $36034AF6, $41047A60, 573 $DF60EFC3, $A867DF55, $316E8EEF, $4669BE79, 574 $CB61B38C, $BC66831A, $256FD2A0, $5268E236, 575 $CC0C7795, $BB0B4703, $220216B9, $5505262F, 576 $C5BA3BBE, $B2BD0B28, $2BB45A92, $5CB36A04, 577 $C2D7FFA7, $B5D0CF31, $2CD99E8B, $5BDEAE1D, 578 $9B64C2B0, $EC63F226, $756AA39C, $026D930A, 579 $9C0906A9, $EB0E363F, $72076785, $05005713, 580 $95BF4A82, $E2B87A14, $7BB12BAE, $0CB61B38, 581 $92D28E9B, $E5D5BE0D, $7CDCEFB7, $0BDBDF21, 582 $86D3D2D4, $F1D4E242, $68DDB3F8, $1FDA836E, 583 $81BE16CD, $F6B9265B, $6FB077E1, $18B74777, 584 $88085AE6, $FF0F6A70, $66063BCA, $11010B5C, 585 $8F659EFF, $F862AE69, $616BFFD3, $166CCF45, 586 $A00AE278, $D70DD2EE, $4E048354, $3903B3C2, 587 $A7672661, $D06016F7, $4969474D, $3E6E77DB, 588 $AED16A4A, $D9D65ADC, $40DF0B66, $37D83BF0, 589 $A9BCAE53, $DEBB9EC5, $47B2CF7F, $30B5FFE9, 590 $BDBDF21C, $CABAC28A, $53B39330, $24B4A3A6, 591 $BAD03605, $CDD70693, $54DE5729, $23D967BF, 592 $B3667A2E, $C4614AB8, $5D681B02, $2A6F2B94, 593 $B40BBE37, $C30C8EA1, $5A05DF1B, $2D02EF8D 594 ); 595 596 function Pascal_GetCrc32( pData: pointer; size: longint ): longword; 597 var 598 i: longint; 599 p: pbyte; 600 begin 601 Result := $ffffffff; 602 p := pData; 603 for i := 0 to size - 1 do 604 begin 605 Result := ( Result shr 8 ) 606 xor Crc32Table[ ( Result xor p^ ) and $000000FF ]; 607 inc( p ); 608 end; 609 end; 610 611 {$ifdef os2} 612 function GetCrc32( pData: pointer; size: longint ): longword; 613 begin 614 asm 615 mov esi, pData {esi: Points to Buffer} 616 mov edx, $ffffffff {edx: Result} 617 mov ecx, Size 618 xor eax, eax {clear EAX: top bits must remain 0} 619 cld 620 621 @@Loop: 622 mov ebx, edx {Save Result in ebx} 623 shr edx, 8 624 lodsb {Load next Buffer entry} 625 xor ebx, eax 626 and ebx, $ff 627 628 // should be able to use 629 // xor edx, dword ptr [edi+4*ebx] 630 // Sibyl Assembler doesn't support it! 631 632 mov edi, ebx {Get lookup index} 633 shl edi, 2 {x4 to get address for longword} 634 xor edx, Crc32Table[edi] {lookup in table, XOR with edx} 635 636 dec ecx {Dec Count} 637 jnz @@Loop {if Count<>0 goto @@Loop} 638 639 mov Result, edx {Save Result} 640 end; 641 end; 642 {$endif} 643 516 644 // Raise an exception if the given Code is <> 0 517 645 procedure CheckSystemError( Code: longword; … … 527 655 528 656 {$ifdef os2} 657 procedure GetCommandLineParameter( item: byte; 658 var pParam: pchar; 659 var ParamLength: longint ); 660 661 Begin 662 ParamLength := 0; 663 ASM 664 MOV CL, item // Load item to CL 665 MOV AL, 2 666 MOV ESI, SYSTEM.ArgStart // Get start of parameters 667 CALLN32 SYSTEM.!ParaInfo // Get start of this parameter 668 669 LEA EDI, pParam // Address of pParam 670 MOV EDI, [EDI] // Address of what pParam references 671 MOV [EDI], ESI // store start of param 672 673 CMP ESI, 0 // Parameter invalid ? 674 JE gclp_End // leave if invalid 675 676 CLD 677 MOV ECX, 0 // Len is 0 678 MOV DL, 0 // we are not in quote state 679 680 gclp_Loop: 681 LODSB // load byte of parameter 682 683 CMP AL, '"' // Check for quote char 684 JNE gclp_NotQuote 685 NOT DL // toggle quote flag 686 687 gclp_NotQuote: 688 CMP AL, ' ' // check for space - end of parameter 689 JNE gclp_NotEnd 690 // parameter has ended, unless in quote 691 CMP DL, 0 // check quote flag 692 JE gclp_Done // if off, then we're finished 693 694 gclp_NotEnd: 695 CMP AL, 0 // check for zero terminator at end of last parameter 696 JE gclp_Done // if found, we're finished 697 698 INC ECX // OK we have one more byte 699 JMP gclp_Loop // next please 700 701 gclp_Done: 702 // now to remove quotes at start/end 703 CMP ECX, 0 704 JE gclp_NoQuotes // length is zero, can't be quotes 705 706 LEA EDI, pParam // Address of pParam 707 MOV EDI, [EDI] // Address of what pParam references 708 MOV ESI, [EDI] // get start of param 709 710 MOV AL, [ESI+ECX-1] // get last char 711 CMP AL, '"' // check if quote 712 JNE gclp_EndQuoteDone 713 DEC ECX // decrease length 714 CMP ECX, 0 715 JE gclp_StartQuoteDone // length is zero, can't be another quote 716 gclp_EndQuoteDone: 717 718 LODSB // load first byte, inc ESI 719 CMP AL, '"' // check if quote 720 JNE gclp_StartQuoteDone 721 DEC ECX // quote, so decrease length 722 MOV [EDI], ESI // store new start of param 723 gclp_StartQuoteDone: 724 725 gclp_NoQuotes: 726 LEA EDI,ParamLength // address of ParamLength 727 MOV EDI, [EDI] // dereference 728 MOV [EDI],ECX // store length 729 gclp_End: 730 END; 731 END; 732 529 733 function GetUserProfileString( const AppName: string; 530 734 const KeyName: string;
Note:
See TracChangeset
for help on using the changeset viewer.