⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 awfax.pas

📁 测试用例
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      {Send message terminator}
      caHDCLEnd(FP);
    end;
  end;

  procedure caPutTSIFrame(FP : PFaxRec);
    {-Transmit a TSI frame}
  var
    I : Word;
  begin
    with PC12FaxData(FP)^, fCData^, fPData^ do begin
      {Send HDLC address and control fields}
      caHDLCStart(FP, False);

      {Send fax control field, TSI format}
      aPort.PutChar(Char(TSIFrame or $01));

      {Send TSI data}
      for I := 19 downto Length(aStationID) do
        aPort.PutChar(' ');
      for I := Length(aStationID) downto 1 do
        aPort.PutChar(Char(aStationID[I]));

      {Send message terminator}
      caHDCLEnd(FP);
    end;
  end;

  procedure caPutDCSDISFrame(FP : PFaxRec; UseDIS : Boolean);
    {-Transmit a DCS or DIS frame}
  var
    B : Byte;
  begin
    with PC12FaxData(FP)^, fCData^, fPData^ do begin
      {Send HDLC address and control fields}
      caHDLCStart(FP, True);

      {Send fax control field, DCS format}
      if UseDIS then
        aPort.PutChar(Char(DISFrame))
      else
        aPort.PutChar(Char(DCSFrame or $01));

      {Send DCS/DIS data, first byte is static}
      aPort.PutChar(Char(DISGroup1));

      {Second byte contains resolution and BPS info}
      B := DISGroup3_1;

      {Can receive at high resolution, set when transmitting high res}
      if UseDIS or (cResC = '1') then
        B := B or DISHighResolution;

      if UseDIS then begin
        case cBPSIndex of
          6 :  B := B or DIS7200BPS or DIS14400BPS;
          5 :  B := B or DIS7200BPS or DIS12000BPS;                  
          3 :  B := B or DIS7200BPS;
          2 :  B := B or DIS4800BPS;
          1 :  B := B or DIS2400BPS;
          else B := B or DIS7200BPS
        end;
      end else begin
        case cBPSIndex of
          6 :  B := B or DIS14400BPS;
          5 :  B := B or DIS12000BPS;
          3 :  B := B or DIS7200BPS;
          2 :  B := B or DIS4800BPS;
          1 :  B := B or DIS2400BPS;
          else B := B or DIS9600BPS;
        end;
      end;
      aPort.PutChar(Char(B));

      {Note modulation code for training and message transmission}
      if not UseDIS then
        cModCode := ModArray[cBPSIndex];

      {Third byte}
      if UseDIS then
        B := DISGroup3_2 or ZeroScanTime
      else
        B := DISGroup3_2 or ScanTimeResponse[cSessionScan, cSessionRes];

      if UseDIS or ((cPageHeader.ImgFlags and ffHighWidth) <> 0) then
        B := B or DISWideWidth;

      aPort.PutChar(Char(B));

      {Last byte is static}
      aPort.PutChar(Char(DISGroup3_3));

      {Send message terminator}
      caHDCLEnd(FP);
    end;
  end;

  procedure caPutCSIFrame(FP : PFaxRec);
    {-Transmit a CSI frame}
  var
    I : Word;
  begin
    with PC12FaxData(FP)^, fCData^, fPData^ do begin
      {Send HDLC address and control fields}
      caHDLCStart(FP, False);

      {Send fax control field, CSI format}
      aPort.PutChar(Char(CSIFrame));

      {Send CSI data}
      for I := 19 downto Length(aStationID) do
        aPort.PutChar(' ');
      for I := Length(aStationID) downto 1 do
        aPort.PutChar(Char(aStationID[I]));

      {Send message terminator}
      caHDCLEnd(FP);
    end;
  end;

  procedure caPutTCFData(FP : PFaxRec);
    {-Put zeros for training data}
  var
    Required : Word;
  begin
    with PC12FaxData(FP)^, fCData^, fPData^ do begin
      {Assumes free space is available}

      Required := 18 * (cSessionBPS div 100);
      if Required > SizeOf(cBufferBlock) then
        {sanity check}
        Required := SizeOf(cBufferBlock);
      FillChar(cBufferBlock, Required, #0);
      aPort.PutBlock(cBufferBlock, Required);                      
      caHDCLEnd(FP);
    end;
  end;

  function caProcessFrame(FP : PFaxRec;
                         var Retrain, Last : Boolean) : Integer;
    {-Process the frame in Response}
  var
    I : Word;
  begin
    caProcessFrame := ecOK;

    with PC12FaxData(FP)^, fCData^, fPData^ do begin
      Retrain := False;

      {Discard till flag byte}
      while (cResponse[1] <> #255) and (Length(cResponse) > 1) do
        Delete(cResponse, 1, 1);

      {If last frame, return True}
      Last := Byte(cResponse[2]) and $10 = $10;
      cReceivedFrame := Ord(cResponse[3]);

      {Process frame}
      case (cReceivedFrame and $FE )of
        TSIFrame,
        CSIFrame :
          begin
            {Extract remote station ID}
            for I := 1 to 20 do
              aRemoteID[I] := cResponse[24-I];
            aRemoteID[0] := #20;
            aFaxProgress := fpGotRemoteID;
            cForceStatus := True;
          end;
        DISFrame :
          begin
            {Extract session parameters}
            caExtractClass1Params(FP, True,
                                  Ord(cResponse[5]), Ord(cResponse[6]));

            if (not cCanDoHighRes and
               ((cPageHeader.ImgFlags and ffHighRes  ) <> 0)) or
               (not cCanDoHighWid and
               ((cPageHeader.ImgFlags and ffHighWidth) <> 0)) then begin
              afReportError(FP, ecFaxBadMachine);
              Exit;
            end else begin
              aFaxProgress := fpSessionParams;
              cForceStatus := True;
            end;
          end;
        DCSFrame :
          begin
            {Extract session parameters}
            caExtractClass1Params(FP, False, Ord(cResponse[5]),
                                  Ord(cResponse[6]));

            {Set modulation code}
            cModCode := ModArray[cBPSIndex];

            aFaxProgress := fpSessionParams;
            cForceStatus := True;
          end;
        CFRFrame :
          cGotCFR := True;
        NSFFrame :
          {Nothing to do for NSF frames} ;
        RTNFrame,
        FTTFrame :
          Retrain := True;
        DCNFrame :
          {Unexpected disconnect request}
          caProcessFrame := ecCancelRequested;
      end;
      caPrepResponse(FP);
    end;
  end;

{C12SendFax}

  function fInitC12SendFax(var FP : PFaxRec; ID : Str20;
                           ComPort : TApdBaseDispatcher; Window : TApdHwnd) : Integer;
  begin
    FP := AllocMem(SizeOf(TC12SendFax));
    with PC12SendFax(FP)^ do begin

      fMaxRetries    := DefMaxRetries;
      fMaxSendCount  := DefMaxSendCnt;
      fBufferMinimum := DefBufferMin;
      fSafeMode      := True;
      fFastPage      := True;                                       

      cInitC12AbsData(fCData);
      if fCData = nil then begin
        fInitC12SendFax := ecOutOfMemory;
        fDoneC12SendFax(FP);
        Exit;
      end;

      afInitFaxData(fPData, ID, ComPort, Window);
      if fPData = nil then begin
        fInitC12SendFax := ecOutOfMemory;
        fDoneC12SendFax(FP);
        Exit;
      end;
    end;

    with PC12SendFax(FP)^, fCData^, fPData^ do begin

      aSending := True;
    end;
    fInitC12SendFax := ecOK;
  end;

  procedure fDoneC12SendFax(var FP : PFaxRec);
  {function fDoneC12SendFax(var FP : PFaxRec) : Integer;}
  begin
    if not Assigned(FP) then
      Exit;

    with PC12SendFax(FP)^ do begin
      if Assigned(fConverter) then
        if PTextFaxData(fConverter^.UserData)^.IsExtended then
          fcDoneTextExConverter(fConverter)
        else
          fcDoneTextConverter(fConverter);
      afDoneFaxData(fPData);
      cDoneC12AbsData(fCData);
      FreeMem(FP, SizeOf(TC12SendFax));
    end;
  end;

  procedure fSetHeaderText(FP : PFaxRec; S : ShortString);
    {-set HeaderLine to S}
  begin
    with PC12SendFax(FP)^ do
      fHeaderLine := S;
  end;

  procedure fSetEnhTextEnabled(FP : PFaxRec; Enabled : Boolean);
  begin
    PC12FaxData(FP)^.fcData^.cEnhTextEnabled := Enabled;
  end;

  procedure fSetEnhSmallFont(FP : PFaxRec; SmFont : TFont);
  begin
    with PC12FaxData(FP)^, fcData^ do begin
      if Assigned(cEnhSmallFont) then
        cEnhSmallFont.Assign(SmFont);
    end;
  end;

  procedure fSetEnhStandardFont(FP : PFaxRec; StFont : TFont);
  begin
    with PC12FaxData(FP)^, fcData^ do begin
      if Assigned(cEnhStandardFont) then
        cEnhStandardFont.Assign(StFont);
    end;
  end;

  procedure fSetBlindDial(FP : PFaxRec; Blind : Boolean);
  begin
    with PC12FaxData(FP)^, fCData^ do begin
      cBlindDial := Blind;
      if not cDetectBusy and cBlindDial then
        cForcedInit := DefX1Init
      else if not cDetectBusy then
        cForcedInit := DefNoDetectBusyInit
      else if cBlindDial then
        cForcedInit := DefBlindInit                                 
      else
        cForcedInit := DefNormalInit;
    end;
  end;

  procedure fSetDetectBusy(FP : PFaxRec; DetectBusySignal : Boolean);
  begin
    with PC12FaxData(FP)^, fCData^ do begin
      cDetectBusy := DetectBusySignal;
      if not cDetectBusy and cBlindDial then
        cForcedInit := DefX1Init
      else if not cDetectBusy then
        cForcedInit := DefNoDetectBusyInit
      else if cBlindDial then
        cForcedInit := DefBlindInit
      else
        cForcedInit := DefNormalInit;
    end;
  end;

  procedure fSetTapiDefInit(FP : PFaxRec);
  begin
    with PC12FaxData(FP)^, fCData^ do
      cForcedInit := DefTapiInit;
  end;

  procedure fSetToneDial(FP : PFaxRec; Tone : Boolean);
  begin
    with PC12FaxData(FP)^, fCData^ do begin
      cToneDial := Tone;
      { bail if we're using the TAPI dialing properties }
      if fPData^.aUsingTapi then                                         {!!.04}
        Exit;                                                            {!!.04}
      {if cDialTonePulse = ' ' then}                                     {!!.04}
        {Exit;}                                                          {!!.04}
      if Tone then
        cDialTonePulse := 'T'
      else
        cDialTonePulse := 'P';
    end;
  end;

  procedure fSetDialPrefix(FP : PFaxRec; P : ShortString);
  begin
    with PC12FaxData(FP)^, fCData^ do
      cDialPrefix := P;
  end;

  procedure fSetDialTime(FP : PFaxRec; DT : Integer);
  begin
    with PC12FaxData(FP)^, fCData^ do
      cDialWait := DT;
  end;

  procedure csSendWhiteRasterLines(FP : PFaxRec; Count : Word);
    {-Send white raster lines to create a physical top margin}
  const
    WhiteLine : array[1..6] of char = #$00#$80#$B2'Y'#$01#$00;
  var
    I, J : Word;
  begin
    with PC12SendFax(FP)^, fCData^, fPData^ do begin
      if cMinBytes > SizeOf(WhiteLine) then
        J := succ(cMinBytes - SizeOf(WhiteLine))
      else
        J := 0;
      FillChar(cBufferBlock, J, #0);
      for I := 1 to Count do begin
        aPort.PutBlock(WhiteLine, SizeOf(WhiteLine));
        if J > 0 then
          aPort.PutBlock(cBufferBlock, J);
      end;
    end;
  end;

  procedure fSetMaxRetries(FP : PFaxRec; MR : Integer);
    {-set MaxRetries to MR}
  begin
    with PC12SendFax(FP)^ do
      fMaxRetries := MR;
  end;

  procedure fSetYielding(FP : PFaxRec; MaxLines, FreeBuffer : Word);
    {-Set the max lines sent per call and the minimum free outbuffer space}
  begin
    with PC12SendFax(FP)^ do begin
      fMaxSendCount := MaxLines;
      fBufferMinimum := FreeBuffer;
    end;
  end;

  procedure fSetSafeMode(FP : PFaxRec; SafeMode : Boolean);
    {-Enable/disable safe mode}
  begin
    with PC12SendFax(FP)^ do
      fSafeMode := SafeMode;
  end;

  procedure csPutBuffer(FP : PFaxRec; var Buffer; Len : Word);
  type
    BA = array[1..$FFF0] of Char;
  var
    I, J : Word;

  begi

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -