Release 14
git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@31 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
parent
e9e1d8f75a
commit
318575bb8e
116
asn1util.pas
116
asn1util.pas
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Delphree - Synapse | 001.002.000 |
|
| Project : Delphree - Synapse | 001.003.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: support for ASN.1 coding and decoding |
|
| Content: support for ASN.1 coding and decoding |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -30,7 +30,7 @@ unit ASN1Util;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils, SynaUtil;
|
SysUtils;
|
||||||
|
|
||||||
const
|
const
|
||||||
ASN1_INT = $02;
|
ASN1_INT = $02;
|
||||||
@ -52,9 +52,15 @@ function ASNEncInt(Value: integer): string;
|
|||||||
function ASNEncUInt(Value: integer): string;
|
function ASNEncUInt(Value: integer): string;
|
||||||
function ASNObject(Data: string; ASNType: integer): string;
|
function ASNObject(Data: string; ASNType: integer): string;
|
||||||
function ASNItem(var Start: integer; Buffer: string; var ValueType:integer): string;
|
function ASNItem(var Start: integer; Buffer: string; var ValueType:integer): string;
|
||||||
|
Function MibToId(mib:string):string;
|
||||||
|
Function IdToMib(id:string):string;
|
||||||
|
Function IntMibToStr(int:string):string;
|
||||||
|
function IPToID(Host: string): string;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{ASNEncOIDitem}
|
||||||
function ASNEncOIDitem(Value: integer): string;
|
function ASNEncOIDitem(Value: integer): string;
|
||||||
var
|
var
|
||||||
x,xm:integer;
|
x,xm:integer;
|
||||||
@ -74,6 +80,8 @@ begin
|
|||||||
until x=0;
|
until x=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{ASNDecOIDitem}
|
||||||
function ASNDecOIDitem(var Start: integer; Buffer: string): integer;
|
function ASNDecOIDitem(var Start: integer; Buffer: string): integer;
|
||||||
var
|
var
|
||||||
x:integer;
|
x:integer;
|
||||||
@ -92,6 +100,8 @@ begin
|
|||||||
until false
|
until false
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{ASNEncLen}
|
||||||
function ASNEncLen(Len: integer): string;
|
function ASNEncLen(Len: integer): string;
|
||||||
var
|
var
|
||||||
x, y: integer;
|
x, y: integer;
|
||||||
@ -113,6 +123,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{ASNDecLen}
|
||||||
function ASNDecLen(var Start: integer; Buffer: string): integer;
|
function ASNDecLen(var Start: integer; Buffer: string): integer;
|
||||||
var
|
var
|
||||||
x,n: integer;
|
x,n: integer;
|
||||||
@ -135,6 +147,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{ASNEncInt}
|
||||||
function ASNEncInt(Value: integer): string;
|
function ASNEncInt(Value: integer): string;
|
||||||
var
|
var
|
||||||
x,y:cardinal;
|
x,y:cardinal;
|
||||||
@ -154,6 +168,8 @@ begin
|
|||||||
then result:=#0+result;
|
then result:=#0+result;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{ASNEncUInt}
|
||||||
function ASNEncUInt(Value: integer): string;
|
function ASNEncUInt(Value: integer): string;
|
||||||
var
|
var
|
||||||
x,y:integer;
|
x,y:integer;
|
||||||
@ -173,11 +189,15 @@ begin
|
|||||||
then result[1]:=char(ord(result[1]) or $80);
|
then result[1]:=char(ord(result[1]) or $80);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{ASNObject}
|
||||||
function ASNObject(Data: string; ASNType: integer): string;
|
function ASNObject(Data: string; ASNType: integer): string;
|
||||||
begin
|
begin
|
||||||
Result := Char(ASNType) + ASNEncLen(Length(Data)) + Data;
|
Result := Char(ASNType) + ASNEncLen(Length(Data)) + Data;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{ASNItem}
|
||||||
function ASNItem(var Start: integer; Buffer: string; var ValueType:integer): string;
|
function ASNItem(var Start: integer; Buffer: string; var ValueType:integer): string;
|
||||||
var
|
var
|
||||||
ASNType: integer;
|
ASNType: integer;
|
||||||
@ -269,6 +289,98 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{MibToId}
|
||||||
|
function MibToId(mib:string):string;
|
||||||
|
var
|
||||||
|
x:integer;
|
||||||
|
|
||||||
|
Function walkInt(var s:string):integer;
|
||||||
|
var
|
||||||
|
x:integer;
|
||||||
|
t:string;
|
||||||
|
begin
|
||||||
|
x:=pos('.',s);
|
||||||
|
if x<1 then
|
||||||
|
begin
|
||||||
|
t:=s;
|
||||||
|
s:='';
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
t:=copy(s,1,x-1);
|
||||||
|
s:=copy(s,x+1,length(s)-x);
|
||||||
|
end;
|
||||||
|
result:=StrToIntDef(t,0);
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
result:='';
|
||||||
|
x:=walkint(mib);
|
||||||
|
x:=x*40+walkint(mib);
|
||||||
|
result:=ASNEncOIDItem(x);
|
||||||
|
while mib<>'' do
|
||||||
|
begin
|
||||||
|
x:=walkint(mib);
|
||||||
|
result:=result+ASNEncOIDItem(x);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{IdToMib}
|
||||||
|
Function IdToMib(id:string):string;
|
||||||
|
var
|
||||||
|
x,y,n:integer;
|
||||||
|
begin
|
||||||
|
result:='';
|
||||||
|
n:=1;
|
||||||
|
while length(id)+1>n do
|
||||||
|
begin
|
||||||
|
x:=ASNDecOIDItem(n,id);
|
||||||
|
if (n-1)=1 then
|
||||||
|
begin
|
||||||
|
y:=x div 40;
|
||||||
|
x:=x mod 40;
|
||||||
|
result:=IntTostr(y);
|
||||||
|
end;
|
||||||
|
result:=result+'.'+IntToStr(x);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{IntMibToStr}
|
||||||
|
Function IntMibToStr(int:string):string;
|
||||||
|
Var
|
||||||
|
n,y:integer;
|
||||||
|
begin
|
||||||
|
y:=0;
|
||||||
|
for n:=1 to length(int)-1 do
|
||||||
|
y:=y*256+ord(int[n]);
|
||||||
|
result:=IntToStr(y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{IPToID} //Hernan Sanchez
|
||||||
|
function IPToID(Host: string): string;
|
||||||
|
var
|
||||||
|
s, t: string;
|
||||||
|
i, x: integer;
|
||||||
|
begin
|
||||||
|
Result := '';
|
||||||
|
for x:= 1 to 3 do
|
||||||
|
begin
|
||||||
|
t := '';
|
||||||
|
s := StrScan(PChar(Host), '.');
|
||||||
|
t := Copy(Host, 1, (Length(Host) - Length(s)));
|
||||||
|
Delete(Host, 1, (Length(Host) - Length(s) + 1));
|
||||||
|
i := StrTointDef(t, 0);
|
||||||
|
Result := Result + Chr(i);
|
||||||
|
end;
|
||||||
|
i := StrTointDef(Host, 0);
|
||||||
|
Result := Result + Chr(i);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
exit;
|
exit;
|
||||||
asm
|
asm
|
||||||
|
173
mimeinln.pas
Normal file
173
mimeinln.pas
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
{==============================================================================|
|
||||||
|
| Project : Delphree - Synapse | 001.000.000 |
|
||||||
|
|==============================================================================|
|
||||||
|
| Content: Inline MIME support procedures and functions |
|
||||||
|
|==============================================================================|
|
||||||
|
| The contents of this file are subject to the Mozilla Public License Ver. 1.0 |
|
||||||
|
| (the "License"); you may not use this file except in compliance with the |
|
||||||
|
| License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ |
|
||||||
|
| |
|
||||||
|
| Software distributed under the License is distributed on an "AS IS" basis, |
|
||||||
|
| WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for |
|
||||||
|
| the specific language governing rights and limitations under the License. |
|
||||||
|
|==============================================================================|
|
||||||
|
| The Original Code is Synapse Delphi Library. |
|
||||||
|
|==============================================================================|
|
||||||
|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
|
||||||
|
| Portions created by Lukas Gebauer are Copyright (c)2000. |
|
||||||
|
| All Rights Reserved. |
|
||||||
|
|==============================================================================|
|
||||||
|
| Contributor(s): |
|
||||||
|
|==============================================================================|
|
||||||
|
| History: see HISTORY.HTM from distribution package |
|
||||||
|
| (Found at URL: http://www.ararat.cz/synapse/) |
|
||||||
|
|==============================================================================}
|
||||||
|
|
||||||
|
unit MIMEinLN;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
sysutils, classes, windows, MIMEchar, SynaCode, SynaUtil;
|
||||||
|
|
||||||
|
function InlineDecode(value:string;CP:TMimeChar):string;
|
||||||
|
function InlineEncode(value:string;CP,MimeP:TMimeChar):string;
|
||||||
|
Function NeedInline(value:string):boolean;
|
||||||
|
function InlineCode(value:string):string;
|
||||||
|
function InlineEmail(value:string):string;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{InlineDecode}
|
||||||
|
function InlineDecode(value:string;CP:TMimeChar):string;
|
||||||
|
var
|
||||||
|
s,su:string;
|
||||||
|
x,y,z,n:integer;
|
||||||
|
ichar:TMimeChar;
|
||||||
|
c:char;
|
||||||
|
|
||||||
|
function SearchEndInline(value:string;be:integer):integer;
|
||||||
|
var
|
||||||
|
n,q:integer;
|
||||||
|
begin
|
||||||
|
q:=0;
|
||||||
|
result:=0;
|
||||||
|
for n:=be+2 to length(value)-1 do
|
||||||
|
if value[n]='?' then
|
||||||
|
begin
|
||||||
|
inc(q);
|
||||||
|
if (q>2) and (value[n+1]='=') then
|
||||||
|
begin
|
||||||
|
result:=n;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
result:=value;
|
||||||
|
x:=pos('=?',result);
|
||||||
|
y:=SearchEndInline(result,x);
|
||||||
|
while y>x do
|
||||||
|
begin
|
||||||
|
s:=copy(result,x,y-x+2);
|
||||||
|
su:=copy(s,3,length(s)-4);
|
||||||
|
ichar:=GetCPfromID(su);
|
||||||
|
z:=pos('?',su);
|
||||||
|
if (length(su)>=(z+2)) and (su[z+2]='?') then
|
||||||
|
begin
|
||||||
|
c:=uppercase(su)[z+1];
|
||||||
|
su:=copy(su,z+3,length(su)-z-2);
|
||||||
|
if c='B' then
|
||||||
|
begin
|
||||||
|
s:=DecodeBase64(su);
|
||||||
|
s:=DecodeChar(s,ichar,CP);
|
||||||
|
end;
|
||||||
|
if c='Q' then
|
||||||
|
begin
|
||||||
|
s:='';
|
||||||
|
for n:=1 to length(su) do
|
||||||
|
if su[n]='_'
|
||||||
|
then s:=s+' '
|
||||||
|
else s:=s+su[n];
|
||||||
|
s:=DecodeQuotedprintable(s);
|
||||||
|
s:=DecodeChar(s,ichar,CP);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
result:=copy(result,1,x-1)+s+copy(result,y+2,length(result)-y-1);
|
||||||
|
x:=pos('=?',result);
|
||||||
|
y:=SearchEndInline(result,x);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{InlineEncode}
|
||||||
|
function InlineEncode(value:string;CP,MimeP:TMimeChar):string;
|
||||||
|
var
|
||||||
|
s,s1:string;
|
||||||
|
n:integer;
|
||||||
|
begin
|
||||||
|
s:=DecodeChar(value,CP,MimeP);
|
||||||
|
s:=EncodeQuotedPrintable(s);
|
||||||
|
s1:='';
|
||||||
|
for n:=1 to length(s) do
|
||||||
|
if s[n]=' '
|
||||||
|
then s1:=s1+'=20'
|
||||||
|
else s1:=s1+s[n];
|
||||||
|
result:='=?'+GetIdFromCP(MimeP)+'?Q?'+s1+'?=';
|
||||||
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{NeedInline}
|
||||||
|
Function NeedInline(value:string):boolean;
|
||||||
|
var
|
||||||
|
n:integer;
|
||||||
|
begin
|
||||||
|
result:=false;
|
||||||
|
for n:=1 to length(value) do
|
||||||
|
if value[n] in (SpecialChar+[char(1)..char(31),char(128)..char(255)]) then
|
||||||
|
begin
|
||||||
|
result:=true;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{InlineCode}
|
||||||
|
function InlineCode(value:string):string;
|
||||||
|
var
|
||||||
|
c:TMimeChar;
|
||||||
|
begin
|
||||||
|
if NeedInline(value)
|
||||||
|
then
|
||||||
|
begin
|
||||||
|
c:=IdealCoding(value,GetCurCP,
|
||||||
|
[ISO_8859_1, ISO_8859_2, ISO_8859_3, ISO_8859_4, ISO_8859_5,
|
||||||
|
ISO_8859_6, ISO_8859_7, ISO_8859_8, ISO_8859_9, ISO_8859_10]);
|
||||||
|
result:=InlineEncode(value,GetCurCP,c);
|
||||||
|
end
|
||||||
|
else result:=value;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
{InlineEmail}
|
||||||
|
function InlineEmail(value:string):string;
|
||||||
|
var
|
||||||
|
sd,se:string;
|
||||||
|
begin
|
||||||
|
sd:=getEmaildesc(value);
|
||||||
|
se:=getEmailAddr(value);
|
||||||
|
if sd=''
|
||||||
|
then result:=se
|
||||||
|
else result:='"'+InlineCode(sd)+'"<'+se+'>';
|
||||||
|
end;
|
||||||
|
|
||||||
|
{==============================================================================}
|
||||||
|
|
||||||
|
begin
|
||||||
|
exit;
|
||||||
|
asm
|
||||||
|
db 'Synapse Inline MIME encoding and decoding library by Lukas Gebauer',0
|
||||||
|
end;
|
||||||
|
end.
|
13
mimemess.pas
13
mimemess.pas
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Delphree - Synapse | 001.000.000 |
|
| Project : Delphree - Synapse | 001.000.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: MIME message object |
|
| Content: MIME message object |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -29,7 +29,7 @@ unit MIMEmess;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
classes, Sysutils, MimePart, MimeChar, SynaUtil;
|
classes, Sysutils, MimePart, MimeChar, SynaUtil, MIMEInLn;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -103,7 +103,6 @@ end;
|
|||||||
function TMimeMess.AddPart:integer;
|
function TMimeMess.AddPart:integer;
|
||||||
var
|
var
|
||||||
mp:TMimePart;
|
mp:TMimePart;
|
||||||
n:integer;
|
|
||||||
begin
|
begin
|
||||||
mp:=TMimePart.create;
|
mp:=TMimePart.create;
|
||||||
result:=PartList.Add(mp);
|
result:=PartList.Add(mp);
|
||||||
@ -134,8 +133,7 @@ end;
|
|||||||
{TMimeMess.AddPartBinary}
|
{TMimeMess.AddPartBinary}
|
||||||
procedure TMimeMess.AddPartBinary(value:string);
|
procedure TMimeMess.AddPartBinary(value:string);
|
||||||
var
|
var
|
||||||
n,x:integer;
|
x:integer;
|
||||||
s:string;
|
|
||||||
begin
|
begin
|
||||||
x:=Addpart;
|
x:=Addpart;
|
||||||
with TMimePart(PartList[x]) do
|
with TMimePart(PartList[x]) do
|
||||||
@ -189,7 +187,6 @@ end;
|
|||||||
{TMimeMess.FinalizeHeaders}
|
{TMimeMess.FinalizeHeaders}
|
||||||
procedure TMimeMess.FinalizeHeaders;
|
procedure TMimeMess.FinalizeHeaders;
|
||||||
var
|
var
|
||||||
s:string;
|
|
||||||
n:integer;
|
n:integer;
|
||||||
begin
|
begin
|
||||||
Lines.Insert(0,'x-mailer: Synapse - Delphi TCP/IP library by Lukas Gebauer');
|
Lines.Insert(0,'x-mailer: Synapse - Delphi TCP/IP library by Lukas Gebauer');
|
||||||
@ -236,8 +233,8 @@ procedure TMimeMess.DecodeMessage;
|
|||||||
var
|
var
|
||||||
l:tstringlist;
|
l:tstringlist;
|
||||||
m:tmimepart;
|
m:tmimepart;
|
||||||
x,i,n:integer;
|
x,i:integer;
|
||||||
bound,s:string;
|
bound:string;
|
||||||
begin
|
begin
|
||||||
l:=tstringlist.create;
|
l:=tstringlist.create;
|
||||||
m:=tmimepart.create;
|
m:=tmimepart.create;
|
||||||
|
140
mimepart.pas
140
mimepart.pas
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Delphree - Synapse | 001.000.001 |
|
| Project : Delphree - Synapse | 001.001.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: MIME support procedures and functions |
|
| Content: MIME support procedures and functions |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -78,33 +78,38 @@ TMimePart=class
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
MaxMimeType=15;
|
MaxMimeType=25;
|
||||||
MimeType:array [0..MaxMimeType,0..2] of string=
|
MimeType:array [0..MaxMimeType,0..2] of string=
|
||||||
(
|
(
|
||||||
|
('AU','audio','basic'),
|
||||||
|
('AVI','video','x-msvideo'),
|
||||||
|
('BMP','image','BMP'),
|
||||||
('DOC','application','MSWord'),
|
('DOC','application','MSWord'),
|
||||||
|
('EPS','application','Postscript'),
|
||||||
('GIF','image','GIF'),
|
('GIF','image','GIF'),
|
||||||
('JPEG','image','JPEG'),
|
('JPEG','image','JPEG'),
|
||||||
('JPG','image','JPEG'),
|
('JPG','image','JPEG'),
|
||||||
|
('MID','audio','midi'),
|
||||||
|
('MOV','video','quicktime'),
|
||||||
('MPEG','video','MPEG'),
|
('MPEG','video','MPEG'),
|
||||||
('MPG','video','MPEG'),
|
('MPG','video','MPEG'),
|
||||||
|
('MP2','audio','mpeg'),
|
||||||
|
('MP3','audio','mpeg'),
|
||||||
('PDF','application','PDF'),
|
('PDF','application','PDF'),
|
||||||
('PNG','image','PNG'),
|
('PNG','image','PNG'),
|
||||||
('PS','application','Postscript'),
|
('PS','application','Postscript'),
|
||||||
('MOV','video','quicktime'),
|
('QT','video','quicktime'),
|
||||||
|
('RA','audio','x-realaudio'),
|
||||||
('RTF','application','RTF'),
|
('RTF','application','RTF'),
|
||||||
|
('SND','audio','basic'),
|
||||||
('TIF','image','TIFF'),
|
('TIF','image','TIFF'),
|
||||||
('TIFF','image','TIFF'),
|
('TIFF','image','TIFF'),
|
||||||
('WAV','audio','basic'),
|
('WAV','audio','x-wav'),
|
||||||
('WPD','application','Wordperfect5.1'),
|
('WPD','application','Wordperfect5.1'),
|
||||||
('ZIP','application','ZIP')
|
('ZIP','application','ZIP')
|
||||||
);
|
);
|
||||||
|
|
||||||
procedure NormalizePart(value:Tstringlist);
|
procedure NormalizePart(value:Tstringlist);
|
||||||
function InlineDecode(value:string;CP:TMimeChar):string;
|
|
||||||
function InlineEncode(value:string;CP,MimeP:TMimeChar):string;
|
|
||||||
Function NeedInline(value:string):boolean;
|
|
||||||
function InlineCode(value:string):string;
|
|
||||||
function InlineEmail(value:string):string;
|
|
||||||
function GenerateBoundary:string;
|
function GenerateBoundary:string;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -112,12 +117,10 @@ implementation
|
|||||||
procedure NormalizePart(value:Tstringlist);
|
procedure NormalizePart(value:Tstringlist);
|
||||||
var
|
var
|
||||||
t:tstringlist;
|
t:tstringlist;
|
||||||
x:integer;
|
|
||||||
s:string;
|
s:string;
|
||||||
begin
|
begin
|
||||||
t:=tstringlist.create;
|
t:=tstringlist.create;
|
||||||
try
|
try
|
||||||
x:=0;
|
|
||||||
while (value.Count-1) > 0 do
|
while (value.Count-1) > 0 do
|
||||||
begin
|
begin
|
||||||
s:=value[0];
|
s:=value[0];
|
||||||
@ -183,7 +186,7 @@ end;
|
|||||||
{TMIMEPart.ExtractPart}
|
{TMIMEPart.ExtractPart}
|
||||||
function TMIMEPart.ExtractPart(value:TStringList; BeginLine:integer):integer;
|
function TMIMEPart.ExtractPart(value:TStringList; BeginLine:integer):integer;
|
||||||
var
|
var
|
||||||
n,x,y,x1,x2:integer;
|
n,x,x1,x2:integer;
|
||||||
t:tstringlist;
|
t:tstringlist;
|
||||||
s,su,b:string;
|
s,su,b:string;
|
||||||
st,st2:string;
|
st,st2:string;
|
||||||
@ -512,128 +515,15 @@ end;
|
|||||||
|
|
||||||
{TMIMEPart.SetCharset}
|
{TMIMEPart.SetCharset}
|
||||||
procedure TMIMEPart.SetCharset(Value:string);
|
procedure TMIMEPart.SetCharset(Value:string);
|
||||||
var
|
|
||||||
s:string;
|
|
||||||
begin
|
begin
|
||||||
FCharset:=Value;
|
FCharset:=Value;
|
||||||
CharsetCode:=GetCPfromID(value);
|
CharsetCode:=GetCPfromID(value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{==============================================================================}
|
|
||||||
{InlineDecode}
|
|
||||||
function InlineDecode(value:string;CP:TMimeChar):string;
|
|
||||||
var
|
|
||||||
s,su:string;
|
|
||||||
x,y,z,n:integer;
|
|
||||||
ichar:TMimeChar;
|
|
||||||
c:char;
|
|
||||||
begin
|
|
||||||
result:=value;
|
|
||||||
x:=pos('=?',uppercase(value));
|
|
||||||
y:=pos('?=',value);
|
|
||||||
if y>x then
|
|
||||||
begin
|
|
||||||
s:=copy(value,x,y-x+2);
|
|
||||||
su:=copy(s,3,length(s)-4);
|
|
||||||
ichar:=GetCPfromID(su);
|
|
||||||
z:=pos('?',su);
|
|
||||||
if (length(su)>=(z+2)) and (su[z+2]='?') then
|
|
||||||
begin
|
|
||||||
c:=uppercase(su)[z+1];
|
|
||||||
su:=copy(su,z+3,length(su)-z-2);
|
|
||||||
if c='B' then
|
|
||||||
begin
|
|
||||||
s:=DecodeBase64(su);
|
|
||||||
s:=DecodeChar(s,ichar,CP);
|
|
||||||
end;
|
|
||||||
if c='Q' then
|
|
||||||
begin
|
|
||||||
s:='';
|
|
||||||
for n:=1 to length(su) do
|
|
||||||
if su[n]='_'
|
|
||||||
then s:=s+' '
|
|
||||||
else s:=s+su[n];
|
|
||||||
s:=DecodeQuotedprintable(s);
|
|
||||||
s:=DecodeChar(s,ichar,CP);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
result:=copy(value,1,x-1)+s+copy(value,y+2,length(value)-y-1);
|
|
||||||
repeat
|
|
||||||
s:=InlineDecode(result,CP);
|
|
||||||
if s=result
|
|
||||||
then break;
|
|
||||||
result:=s;
|
|
||||||
until false;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{==============================================================================}
|
|
||||||
{InlineEncode}
|
|
||||||
function InlineEncode(value:string;CP,MimeP:TMimeChar):string;
|
|
||||||
var
|
|
||||||
s,s1:string;
|
|
||||||
n:integer;
|
|
||||||
begin
|
|
||||||
s:=DecodeChar(value,CP,MimeP);
|
|
||||||
s:=EncodeQuotedPrintable(s);
|
|
||||||
s1:='';
|
|
||||||
for n:=1 to length(s) do
|
|
||||||
if s[n]=' '
|
|
||||||
then s1:=s1+'=20'
|
|
||||||
else s1:=s1+s[n];
|
|
||||||
result:='=?'+GetIdFromCP(MimeP)+'?Q?'+s1+'?=';
|
|
||||||
end;
|
|
||||||
|
|
||||||
{==============================================================================}
|
|
||||||
{NeedInline}
|
|
||||||
Function NeedInline(value:string):boolean;
|
|
||||||
var
|
|
||||||
n:integer;
|
|
||||||
begin
|
|
||||||
result:=false;
|
|
||||||
for n:=1 to length(value) do
|
|
||||||
if value[n] in (SpecialChar+[char(1)..char(31),char(128)..char(255)]) then
|
|
||||||
begin
|
|
||||||
result:=true;
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{==============================================================================}
|
|
||||||
{InlineCode}
|
|
||||||
function InlineCode(value:string):string;
|
|
||||||
var
|
|
||||||
c:TMimeChar;
|
|
||||||
begin
|
|
||||||
if NeedInline(value)
|
|
||||||
then
|
|
||||||
begin
|
|
||||||
c:=IdealCoding(value,GetCurCP,
|
|
||||||
[ISO_8859_1, ISO_8859_2, ISO_8859_3, ISO_8859_4, ISO_8859_5,
|
|
||||||
ISO_8859_6, ISO_8859_7, ISO_8859_8, ISO_8859_9, ISO_8859_10]);
|
|
||||||
result:=InlineEncode(value,GetCurCP,c);
|
|
||||||
end
|
|
||||||
else result:=value;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{==============================================================================}
|
|
||||||
{InlineEmail}
|
|
||||||
function InlineEmail(value:string):string;
|
|
||||||
var
|
|
||||||
sd,se:string;
|
|
||||||
begin
|
|
||||||
sd:=getEmaildesc(value);
|
|
||||||
se:=getEmailAddr(value);
|
|
||||||
if sd=''
|
|
||||||
then result:=se
|
|
||||||
else result:='"'+InlineCode(sd)+'"<'+se+'>';
|
|
||||||
end;
|
|
||||||
|
|
||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
{GenerateBoundary}
|
{GenerateBoundary}
|
||||||
function GenerateBoundary:string;
|
function GenerateBoundary:string;
|
||||||
var
|
var
|
||||||
s:string;
|
|
||||||
x:integer;
|
x:integer;
|
||||||
begin
|
begin
|
||||||
randomize;
|
randomize;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Delphree - Synapse | 001.001.000 |
|
| Project : Delphree - Synapse | 001.001.001 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: Coding and decoding support |
|
| Content: Coding and decoding support |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -151,7 +151,7 @@ begin
|
|||||||
if c<>'='
|
if c<>'='
|
||||||
then result:=result+c
|
then result:=result+c
|
||||||
else
|
else
|
||||||
if (x+1)<length(value)
|
if x<length(value)
|
||||||
then
|
then
|
||||||
begin
|
begin
|
||||||
s:=copy(value,x,2);
|
s:=copy(value,x,2);
|
||||||
|
105
synautil.pas
105
synautil.pas
@ -1,5 +1,5 @@
|
|||||||
{==============================================================================|
|
{==============================================================================|
|
||||||
| Project : Delphree - Synapse | 001.004.000 |
|
| Project : Delphree - Synapse | 001.005.000 |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
| Content: support procedures and functions |
|
| Content: support procedures and functions |
|
||||||
|==============================================================================|
|
|==============================================================================|
|
||||||
@ -30,7 +30,7 @@ unit SynaUtil;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Blcksock, sysutils, classes, windows;
|
sysutils, classes, windows;
|
||||||
|
|
||||||
function timezone:string;
|
function timezone:string;
|
||||||
function Rfc822DateTime(t:TDateTime):String;
|
function Rfc822DateTime(t:TDateTime):String;
|
||||||
@ -39,10 +39,6 @@ function DeCodeInt(Value:string;Index:integer):word;
|
|||||||
function IsIP(Value:string):Boolean;
|
function IsIP(Value:string):Boolean;
|
||||||
function ReverseIP(Value:string):string;
|
function ReverseIP(Value:string):string;
|
||||||
procedure Dump (Buffer:string;DumpFile:string);
|
procedure Dump (Buffer:string;DumpFile:string);
|
||||||
Function MibToId(mib:string):string;
|
|
||||||
Function IdToMib(id:string):string;
|
|
||||||
Function IntMibToStr(int:string):string;
|
|
||||||
function IPToID(Host: string): string;
|
|
||||||
function SeparateLeft(value,delimiter:string):string;
|
function SeparateLeft(value,delimiter:string):string;
|
||||||
function SeparateRight(value,delimiter:string):string;
|
function SeparateRight(value,delimiter:string):string;
|
||||||
function getparameter(value,parameter:string):string;
|
function getparameter(value,parameter:string):string;
|
||||||
@ -52,9 +48,6 @@ function StrToHex(value:string):string;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
|
||||||
ASN1util;
|
|
||||||
|
|
||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
{timezone}
|
{timezone}
|
||||||
function timezone:string;
|
function timezone:string;
|
||||||
@ -199,98 +192,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{==============================================================================}
|
|
||||||
|
|
||||||
{MibToId}
|
|
||||||
function MibToId(mib:string):string;
|
|
||||||
var
|
|
||||||
x:integer;
|
|
||||||
|
|
||||||
Function walkInt(var s:string):integer;
|
|
||||||
var
|
|
||||||
x:integer;
|
|
||||||
t:string;
|
|
||||||
begin
|
|
||||||
x:=pos('.',s);
|
|
||||||
if x<1 then
|
|
||||||
begin
|
|
||||||
t:=s;
|
|
||||||
s:='';
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
t:=copy(s,1,x-1);
|
|
||||||
s:=copy(s,x+1,length(s)-x);
|
|
||||||
end;
|
|
||||||
result:=StrToIntDef(t,0);
|
|
||||||
end;
|
|
||||||
begin
|
|
||||||
result:='';
|
|
||||||
x:=walkint(mib);
|
|
||||||
x:=x*40+walkint(mib);
|
|
||||||
result:=ASNEncOIDItem(x);
|
|
||||||
while mib<>'' do
|
|
||||||
begin
|
|
||||||
x:=walkint(mib);
|
|
||||||
result:=result+ASNEncOIDItem(x);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{==============================================================================}
|
|
||||||
|
|
||||||
{IdToMib}
|
|
||||||
Function IdToMib(id:string):string;
|
|
||||||
var
|
|
||||||
x,y,n:integer;
|
|
||||||
begin
|
|
||||||
result:='';
|
|
||||||
n:=1;
|
|
||||||
while length(id)+1>n do
|
|
||||||
begin
|
|
||||||
x:=ASNDecOIDItem(n,id);
|
|
||||||
if (n-1)=1 then
|
|
||||||
begin
|
|
||||||
y:=x div 40;
|
|
||||||
x:=x mod 40;
|
|
||||||
result:=IntTostr(y);
|
|
||||||
end;
|
|
||||||
result:=result+'.'+IntToStr(x);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{==============================================================================}
|
|
||||||
{IntMibToStr}
|
|
||||||
Function IntMibToStr(int:string):string;
|
|
||||||
Var
|
|
||||||
n,y:integer;
|
|
||||||
begin
|
|
||||||
y:=0;
|
|
||||||
for n:=1 to length(int)-1 do
|
|
||||||
y:=y*256+ord(int[n]);
|
|
||||||
result:=IntToStr(y);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{==============================================================================}
|
|
||||||
{IPToID} //Hernan Sanchez
|
|
||||||
function IPToID(Host: string): string;
|
|
||||||
var
|
|
||||||
s, t: string;
|
|
||||||
i, x: integer;
|
|
||||||
begin
|
|
||||||
Result := '';
|
|
||||||
for x:= 1 to 3 do
|
|
||||||
begin
|
|
||||||
t := '';
|
|
||||||
s := StrScan(PChar(Host), '.');
|
|
||||||
t := Copy(Host, 1, (Length(Host) - Length(s)));
|
|
||||||
Delete(Host, 1, (Length(Host) - Length(s) + 1));
|
|
||||||
i := StrTointDef(t, 0);
|
|
||||||
Result := Result + Chr(i);
|
|
||||||
end;
|
|
||||||
i := StrTointDef(Host, 0);
|
|
||||||
Result := Result + Chr(i);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{==============================================================================}
|
{==============================================================================}
|
||||||
{SeparateLeft}
|
{SeparateLeft}
|
||||||
function SeparateLeft(value,delimiter:string):string;
|
function SeparateLeft(value,delimiter:string):string;
|
||||||
@ -310,6 +211,8 @@ var
|
|||||||
x:integer;
|
x:integer;
|
||||||
begin
|
begin
|
||||||
x:=pos(delimiter,value);
|
x:=pos(delimiter,value);
|
||||||
|
if x>0
|
||||||
|
then x:=x+length(delimiter)-1;
|
||||||
result:=trim(copy(value,x+1,length(value)-x));
|
result:=trim(copy(value,x+1,length(value)-x));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user