On 2/18/2011 04:47, Tomas Hajny wrote:
On Fri, February 18, 2011 02:24, waldo kitty wrote:
I'm willing to have a look at your current version if you can upload it
somewhere. Synapse has probably not been ported to the OS/2 target and it
possibly uses various platform specific APIs but it should be possible to
port it with reasonable effort (especially stuff like processing MIME
messages should be fairly generic). First of all, you should check whether
the missing units are supposed to be platform independent or not. If not,
it is surely not just the matter of paths, etc. Also, if you mention
concrete error messages, people may be able to advise.

ok, as i wrote before, i would attempt to provide more information... here's what i'm getting with the attached source code when attempting to compile a GO32V2 (native) target on my win2k development box... this environment is from the DOS242FULL.ZIP archive with the same last synapse public release code as previously used in my i386-win32 console compilations... this is the same/only public release code available from the synapse site... i have NOT (yet) attempted to pull the SVN synapse code... yes, this synapse code appears to be "ancient" in that it is dated 2009 (IIRC!)...

Fatal: Can't find unit dynlibs used by synafpc

my sources, yet unmodified for more general processing, are attached... yes, it is "ugly" and i need to move at least one section to another procedure or two but here it is in all its ugliness ;)

i /THINK/ this is the same initial error i get when attempting to compile on OS/2 from the OS2242FULL.ZIP archive... on each, they are set up as a separate and distinct entity and the exact same synapse sources are copied to each distinct base installation's projects directory... the only thing i've done in each case is to add the synapse sources' directory to the unit and include files sections in the FPC IDE...

i hope this is clear and understandable... i will provide another post with the necessary information for the OS/2 native side if necessary... just let me know, eh? :P
{$MODE DELPHI}

Program ArnewsMimeExtractor;

uses
  mimepart,
  synachar,
  synautil,
  classes;

type
  Tc = class(TObject)
  public
    class procedure ph(const Sender: TMimePart);
  end;

class procedure Tc.ph(const Sender: TMimePart);
begin
//  Sender.Charset := 'ISO_8859_1';
//  Sender.DefaultCharset := 'ISO_8859_1';
//  Sender.TargetCharset := GetCPFromID('ISO_8859_1');
  Sender.ConvertCharset := FALSE;
  Sender.DecodePart;
  Sender.EncodePart;
end;

var
  LineList: tstringlist;
  MsgIn: tmimepart;
  PartCount: integer;
  MsgWork: tmimepart;
  MyPart: integer;
  MyPartCount: integer;
  i: integer;
  cpos: integer;
  llen: integer;
  ArrayCount: integer;
  FindChars: array of ansistring;
  ReplaceChars: array of ansistring;

begin
  // set up arrays for character string replacements
  ArrayCount := 14;
  setlength(FindChars,ArrayCount);
  setlength(ReplaceChars,ArrayCount);
  FindChars[0]    := '=20'; ReplaceChars[0]  := ' ';
  FindChars[1]    := '=3D'; ReplaceChars[1]  := '=';
  FindChars[2]    := '=85'; ReplaceChars[2]  := '...';
  FindChars[3]    := '=96'; ReplaceChars[3]  := '-';
  FindChars[4]    := '=99'; ReplaceChars[4]  := '(tm)';
  FindChars[5]    := '=A0'; ReplaceChars[5]  := ' ';
  FindChars[6]    := '=A7'; ReplaceChars[6]  := '§';
  FindChars[7]    := '=AD'; ReplaceChars[7]  := ' ';
  FindChars[8]    := '=AE'; ReplaceChars[8]  := '(r)';
  FindChars[9]    := '=B7'; ReplaceChars[9]  := '·';
  FindChars[10]   := '=D8'; ReplaceChars[10] := 'Ø';
  FindChars[11]   := '=E1'; ReplaceChars[11] := 'á';
  FindChars[12]   := '=F6'; ReplaceChars[12] := '”';
  FindChars[13]   := '  ';  ReplaceChars[13] := ' ';

  MsgIn := tmimepart.create;
  LineList := TStringList.create;
  writeln('Processing file ',paramstr(1),'...');
  try
    MsgIn.OnWalkPart:=tc.ph;
    MsgIn.Lines.LoadFromFile(paramstr(1));
    writeln('  Working with ',MsgIn.Lines.Count,' lines in message file...');
    MsgIn.Charset := 'ISO_8859_1';
    MsgIn.DefaultCharset := 'ISO_8859_1';
    MsgIn.TargetCharset := GetCPFromID('ISO_8859_1');
    MsgIn.ConvertCharset := FALSE;
    MsgIn.DecomposeParts;
    MsgIn.Charset := 'ISO_8859_1';
    MsgIn.DefaultCharset := 'ISO_8859_1';
    MsgIn.TargetCharset := GetCPFromID('ISO_8859_1');
    MsgIn.ConvertCharset := FALSE;
    MsgIn.WalkPart;
    PartCount := MsgIn.GetSubPartCount;
    MsgIn.Charset := 'ISO_8859_1';
    MsgIn.DefaultCharset := 'ISO_8859_1';
    MsgIn.TargetCharset := GetCPFromID('ISO_8859_1');
    MsgIn.ConvertCharset := FALSE;
//    writeln('MsgIn.GetSubPartCount    : ',PartCount);
//    writeln('MsgIn.Primary            : ',MsgIn.Primary);
//    writeln('MsgIn.Encoding           : ',MsgIn.Encoding);
//    writeln('MsgIn.Charset            : ',MsgIn.Charset);
//    writeln('MsgIn.DefaultCharset     : ',MsgIn.DefaultCharset);
//    writeln('MsgIn.PrimaryCode        : ',MsgIn.PrimaryCode);
//    writeln('MsgIn.EncodingCode       : ',MsgIn.EncodingCode);
//    writeln('MsgIn.CharsetCode        : ',MsgIn.CharsetCode);
//    writeln('MsgIn.TargetCharset      : ',MsgIn.TargetCharset);
//    writeln('MsgIn.ConvertCharset     : ',MsgIn.ConvertCharset);
//    writeln('MsgIn.ForcedHTMLConvert  : ',MsgIn.ForcedHTMLConvert);
//    writeln('MsgIn.Secondary          : ',MsgIn.Secondary);
//    writeln('MsgIn.Description        : ',MsgIn.Description);
//    writeln('MsgIn.Disposition        : ',MsgIn.Disposition);
//    writeln('MsgIn.ContentID          : ',MsgIn.ContentID);
//    writeln('MsgIn.Boundary           : ',MsgIn.Boundary);
//    writeln('MsgIn.FileName           : ',MsgIn.FileName);
//    writeln('MsgIn.SubLevel           : ',MsgIn.SubLevel);
//    writeln('MsgIn.MaxSubLevel        : ',MsgIn.MaxSubLevel);
//    writeln('MsgIn.AttachInside       : ',MsgIn.AttachInside);
//    writeln('MsgIn.MaxLineLength      : ',MsgIn.MaxLineLength);
//    writeln;


    if MsgIn.Primary = 'MULTIPART' then
      begin
//        writeln('  entering ProcessParts with ',PartCount,' parts...');
        for MyPart := 0 to PartCount - 1 do
          begin
//            if MyPart > 0 then
//              writeln;
//            writeln('    pulling part ',MyPart,' into MsgWork');
            MsgWork:= MsgIn.GetSubPart(MyPart);
            MsgWork.Charset := 'ISO_8859_1';
            MsgWork.DefaultCharset := 'ISO_8859_1';
            MsgWork.TargetCharset := GetCPFromID('ISO_8859_1');
            MsgWork.ConvertCharset := FALSE;
            if ((MsgWork.Primary = 'TEXT') and (MsgWork.Secondary = 'PLAIN')) 
then
              begin
//                writeln('    We have a TEXT/PLAIN section. Copying to 
LineList...');
                LineList.Assign(MsgWork.PartBody);
              end
            else
              begin
//                writeln('    ** This part is not TEXT/PLAIN... SKIPPING... ');
              end;
          end;
//        writeln('  vacating ProcessParts...');
      end
    else
      begin
        if ((MsgIn.Primary = 'TEXT') and (MsgIn.Secondary = 'PLAIN')) then
          begin
//            writeln('    We have a TEXT/PLAIN message. Copying to 
LineList...');
            LineList.Assign(MsgIn.PartBody);
          end
        else
          begin
//            writeln('    ** This message is not TEXT/PLAIN... SKIPPING... ');
          end;
      end;

//    writeln;

    writeln('  Pulled ',LineList.Count,' lines to work with...');
    MyPartCount := 0;
    for MyPart := 0 to LineList.Count - 1 do
      begin
        // Replace mime characters with ascii equivelents
        // ie: =99 is (tm)
        for i := 0 to ArrayCount - 1 do
          begin
            cpos := pos(FindChars[i],LineList.Strings[MyPart]);
            if cpos > 0 then
              LineList.Strings[MyPart] := 
ReplaceString(LineList.Strings[MyPart],FindChars[i],ReplaceChars[i]);
          end;
        // remove trailing mime wrap indicator = from lines
        llen := Length(LineList.Strings[MyPart]);
        if ((llen > 0) and (LineList.Strings[MyPart][llen] = '=')) then
          LineList.Strings[MyPart] := copy(LineList.Strings[MyPart],1,llen-1);
        // remove leading and trailing spaces
        LineList.Strings[MyPart] := TrimSP(LineList.Strings[MyPart]);
        if LineList.Strings[MyPart] = '------------------------------------' 
then
          MyPartCount := MyPart;
//        writeln(LineList[MyPart]);
      end;

      if MyPartCount > 0 then
        for MyPart := MyPartCount to LineList.Count - 1 do
          // trim garbage and excess lines
          LineList.Strings[MyPart] := '';
      StringsTrim(LineList);


      // add boilerplate and signoff
      LineList.Append('');
      LineList.Append('');
      LineList.Append('***');
      LineList.Append('');
      LineList.Append('As a Service to the HAM Radio Community and Ham 
Operators all around the');
      LineList.Append('world, this Amateur Radio Newline<tm> message has been 
gated from the internet');
      LineList.Append('and posted to you by Waldo''s Place USA, 1:3634/12. We 
hope you enjoyed it!');
//      LineList.Append('enjoyed it!');
      LineList.Append('');
      LineList.Append('Please address all comments and questions to the 
ARNewsletter editor as');
      LineList.Append('described in this posting. If you have any specific 
questions concerning');
      LineList.Append('the actual posting of this message service, you may 
address them to');
      LineList.Append('hamfdn -at- wpusa.dynip.com.');
      LineList.Append('');
      LineList.Append('Thank you and good day!');
      LineList.Append('');
      LineList.Append('-73-');
      LineList.Append('');

//    writeln('  fire LineList.Lines.SaveToFile...');
    LineList.SaveToFile(paramstr(1) + '.txt');
//    writeln('  return from LineList.Lines.SaveTofile...');

  finally
//    writeln;
//    writeln('finally');
//    write('  free MsgIn... ');
    MsgIn.free;
//    writeln('done!');
//    write('  free LineList... ');
    LineList.free;
//    writeln('done!');
  end;
  writeln('Process complete. Terminating...');
end.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to