打印本文 打印本文 关闭窗口 关闭窗口
TCP/IP(九)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1874  更新时间:2009/4/23 18:43:57  文章录入:mintao  责任编辑:mintao
end;
  end;
(*@\\\0000000B12*)
var
  i,j: integer;
  s,field,data: string;
  attach: t_attachment;
begin
  boundary:='''''''';
  RemoveAllAttachments;
(*@///   parse header lines and search for mime boundary *)
i:=0;
while (i<mail.count-1) and (mail.strings[i]<>'''''''') do begin
  strip_header(mail.strings[i],field,data);
(*@///   if field=''''content-type'''' then *)
if field=''''content-type'''' then begin
  s:=copy(data,pos(''''boundary'''',data),length(data));
  s:=copy(s,pos(''''"'''',s)+1,length(s));
  boundary:=copy(s,1,pos(''''"'''',s)-1);
  end;
(*@\\\0000000201*)
  inc(i);
  end;
(*@\\\0000000401*)
  attach:=t_attachment.create;
  while true do begin
    inc(i);    (* ignore the empty line *)
    if i>=mail.count-1 then BREAK;
    while (i<mail.count-1) and (mail.strings[i]<>''''--''''+boundary) and
        (mail.strings[i]<>''''--''''+boundary+''''--'''') do begin
      attach.text.add(mail.strings[i]);
      inc(i);
      end;
    case attach.encoding of
(*@///       ec_base64: *)
ec_base64: begin
  attach.data:=decode_base64(attach.text);
  attach.text:=NIL;
  end;
(*@\\\0000000301*)
(*@///       ec_quotedprintable: *)
ec_quotedprintable: begin
  for j:=0 to attach.text.count-1 do
    attach.text.strings[j]:=seven2eight_quoteprint(attach.text.strings[j]);
  end;
(*@\\\0000000301*)
      ec_none:             ;
      end;
    if mail.strings[i]=''''--''''+boundary+''''--'''' then  BREAK;  (* end of mime *)
    if i>=mail.count-1 then BREAK;
    if (attach.text.count>0) or (attach.data.size>0) then
      f_attachment.add(attach);
    attach:=t_attachment.create;
    inc(i);  (* ignore the empty line *)
    if i>=mail.count-1 then BREAK;
(*@///     parse mime block header *)
while (i<mail.count-1) and (mail.strings[i]<>'''''''') do begin
  if s[1]<>'''' '''' then
    strip_header(mail.strings[i],field,data)
  else
    data:=data+s;
  if false then
  else if field=''''content-type'''' then  attach.kind:=data
  else if field=''''content-disposition'''' then  attach.disposition:=data
(*@///   else if field=''''content-transfer-encoding'''' then begin *)
else if field=''''content-transfer-encoding'''' then begin
  data:=lowercase(data);
  if false then
  else if data=''''base64'''' then
    attach.encoding:=ec_base64
  else if data=''''quoted-printable'''' then
    attach.encoding:=ec_quotedprintable
  else
    attach.encoding:=ec_none;
  end;
(*@\\\0000000716*)
  inc(i);
  end;
(*@\\\0000000901*)
    end;
  f_attachment.add(attach);
  end;
(*@\\\0000001B33*)
(*@/// function t_mime.GetAttachment(index: integer):t_attachment; *)
function t_mime.GetAttachment(index: integer):t_attachment;
begin
  if index>f_attachment.count-1 then
    result:=NIL
  else
    result:=t_attachment(f_attachment[index]);
  end;
(*@\\\0000000306*)
(*@\\\0000000501*)

(*@/// procedure Register; *)
procedure Register;
begin
  RegisterComponents(''''TCP/IP'''', [t_finger]);
  RegisterComponents(''''TCP/IP'''', [t_fingerD]);
  RegisterComponents(''''TCP/IP'''', [t_http]);
  RegisterComponents(''''TCP/IP'''', [t_ftp]);
  RegisterComponents(''''TCP/IP'''', [t_lpr]);
  RegisterComponents(''''TCP/IP'''', [t_smtp]);
  RegisterComponents(''''TCP/IP'''', [t_mail]);
  RegisterComponents(''''TCP/IP'''', [t_nntp]);
  RegisterComponents(''''TCP/IP'''', [t_news]);
  RegisterComponents(''''TCP/IP'''', [t_time]);
  RegisterComponents(''''TCP/IP'''', [t_rexec]);
  RegisterComponents(''''TCP/IP'''', [t_rsh]);
  RegisterComponents(''''TCP/IP'''', [t_pop3]);
  RegisterComponents(''''TCP/IP'''', [t_mime]);
  end;
(*@\\\*)
(*@\\\0000003114*)
(*@/// initialization *)
begin
  lpr_count:=0;
  end.
(*@\\\*)
(*@\\\0001000011*)

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口