A
download bsend.cpp
Language: C++
Copyright: Copyright 1987-96, Bit Bucket Software Co.
LOC: 138
Project Info
BinkleyTerm XE(btxe)
Server: SourceForge
Type: cvs
...e\b\btxe\btxe\btnt\sources\
   Addr.cpp
   Addr.h
   aglcrc.cpp
   aglcrc.h
   asyn_lnx.cpp
   asyn_os2.cpp
   asyn_w32.cpp
   async.h
   asyos2v1.h
   b_banner.cpp
   b_bbs.cpp
   b_faxrcv.cpp
   b_flofil.cpp
   b_frproc.cpp
   b_help.cpp
   b_initva.cpp
   b_logs.cpp
   b_passwo.cpp
   b_proto.cpp
   b_rspfil.cpp
   b_sbinit.cpp
   b_script.cpp
   b_search.cpp
   b_sessio.cpp
   b_spawn.cpp
   b_term.cpp
   b_termov.cpp
   b_today.cpp
   b_wazoo.cpp
   b_whack.cpp
   b_wzsend.cpp
   banner.cpp
   banner.h
   BasicString.h
   bbs_ctra.cpp
   bbs_data.cpp
   bbs_incl.h
   bbs_io.cpp
   bink.h
   bink_asm.cpp
   binkdlg.cpp
   binkpipe.h
   box.h
   brec.cpp
   bsend.cpp
   bt.cpp
   btconfig.cpp
   btutil.cpp
   buffer.h
   cache.cpp
   cache.h
   callback.cpp
   callerid.cpp
   callwin.cpp
   callwin.h
   capi.cpp
   cfosline.cpp
   chat.cpp
   com.h
   com_dos.h
   com_lnx.h
   com_os2.h
   com_w32.h
   common.cpp
   cpuload.cpp
   css.cpp
   css.h
   data.cpp
   debug.cpp
   debug.h
   defines.h
   dosfuncs.cpp
   emsi.cpp
   emxmxcom.cpp
   evtparse.cpp
   evtsetup.cpp
   exceptio.cpp
   exceptio.h
   Exceptions.cpp
   Exceptions.h
   externs.h
   faxproto.h
   fcfgread.cpp
   fidomail.h
   file_all.cpp
   file_dos.cpp
   file_io.h
   file_lnx.cpp
   file_os2.cpp
   file_w32.cpp
   foffsets.h
   fossil.cpp
   freepoll.cpp
   ftsc.cpp
   gethcomm.h
   heap.cpp
   history.cpp
   history.h
   hydra.cpp
   hydra.h
   includes.cpp
   includes.h
   janus.cpp
   janus.h
   keybd.h
   keyfncs.h
   keymap.cpp
   langload.cpp
   language.h
   lngmagic.h
   m7rec.cpp
   m7send.cpp
   mailer.cpp
   mailovly.cpp
   mailroot.cpp
   maxcomm.h
   maxmcp.cpp
   maxmcp.h
   maxprm.cpp
   mdm_proc.cpp
   misc.cpp
   msgs.h
   Node.cpp
   Node.h
   NodeList.cpp
   NodeList.h
   nodeproc.cpp
   os2_pm.cpp
   outbound.cpp
   pipe.cpp
   pktmsgs.cpp
   pktmsgs.h
   protcomm.cpp
   prototyp.h
   recvbark.cpp
   recvsync.cpp
   sbuf.cpp
   sbuf.h
   sched.cpp
   sched.h
   script2.cpp
   SelfTest.cpp
   SelfTest.h
   sendbark.cpp
   sendsync.cpp
   squish.cpp
   squish.h
   srif.cpp
   statetbl.cpp
   stats.cpp
   stdafx.cpp
   stdafx.h
   timer.cpp
   timer.h
   times.cpp
   types.h
   v7debug.cpp
   version.cpp
   version7.cpp
   version7.h
   vfos_dos.cpp
   vfos_lnx.cpp
   vfos_os2.cpp
   vfos_qnx.cpp
   vfos_w32.cpp
   vfossil.h
   video.h
   vt100.cpp
   vt100.h
   xfer.h
   xmrec.cpp
   xmsend.cpp
   xstring.h
   yoohoo.cpp
   zmodem.cpp
   zmodem.h

/*---------------------------------------------------------------------------*
 *
 *                               BinkleyTerm
 *
 *              (C) Copyright 1987-96, Bit Bucket Software Co.
 *     For license and contact information see /doc/orig_260/license.260.
 *
 *           This version was modified by the BinkleyTerm XE Team.
 *        For contact information see /doc/team.lst and /doc/join.us.
 *  For a complete list of changes see /doc/xe_user.doc and /doc/xe_hist.doc.
 *
 * Filename    : $Source: /cvsroot/btxe/btnt/sources/bsend.cpp,v $
 * Revision    : $Revision: 1.1 $
 * Tagname     : $Name:  $
 * Last updated: $Date: 2005/01/01 15:18:11 $
 * State       : $State: Exp $
 * Orig. Author: Bob Hartman
 *
 * Description : BinkleyTerm Batch Sender State Machine
 *
 *---------------------------------------------------------------------------*/

/* Include this file before any other includes or defines! */

#include "includes.h"

#define NO_SEALINK_IS_TELINK 1

static long batch_no_sealink;

/* .-----+----------+-------------------------+-------------------------+-----.
 * |State| State    | Predicate(s)            | Action(s)               | Next|
 * |  #  | Name     |                         |                         | St  |
 * +-----+----------+-+-----------------------+-------------------------+-----+
 * | BS0 | MoreFiles|1| more files to send    |                         | BS1 |
 * |     |          +-+-----------------------+-------------------------+-----+
 * |     |          |2| no more files to send |                         | BS4 |
 * +-----+----------+-+-----------------------+-------------------------+-----+
 * | BS1 | WaitType |1| rec NAK               | (MODEM7 FName send MS0) | BS2 |
 * |     |    (*1)  +-+-----------------------+-------------------------+-----+
 * |     |          |2| rec 'C'               | (SEAlink send file XS0) | BS3 |
 * |     |          +-+-----------------------+-------------------------+-----+
 * |     |          |3| rec other char        | eat character           | BS1 |
 * |     |          +-+-----------------------+-------------------------+-----+
 * |     |          |4| > 20 sec in BS1       | report name send bad    | exit|
 * +-----+----------+-+-----------------------+-------------------------+-----+
 * | BS2 | CheckFNm |1| MODEM7 Filename ok    | (TeLink send file XS0T) | BS3 |
 * |     |    (*2)  +-+-----------------------+-------------------------+-----+
 * |     |          |2| MODEM7 Filename bad   | report name send bad    | exit|
 * +-----+----------+-+-----------------------+-------------------------+-----+
 * | BS3 | CheckFile|1| File send ok          |                         | BS0 |
 * |     |          +-+-----------------------+-------------------------+-----+
 * |     |          |2| File send bad         | report file send bad    | exit|
 * +-----+----------+-+-----------------------+-------------------------+-----+
 * | BS4 | EndSend  |1| rec NAK or 'C'        | send EOT, report send ok| exit|
 * |     |    (*3)  +-+-----------------------+-------------------------+-----+
 * |     |          |2| 10 secs no NAK or 'C' | send EOT, report no NAK | exit|
 * `-----+----------+-+-----------------------+-------------------------+-----'
 *
 * BSx renamed to BSNDx, they are already defined for something else in Linux
 * CEH; 19981106 */

int BSInit (XMARGSP);
int BSEnd (XMARGSP);
int BSMoreFiles (XMARGSP);
int BSWaitType (XMARGSP);
int BSCheckFNm (XMARGSP);
int BSCheckFile (XMARGSP);
int BSEndSend (XMARGSP);

typedef struct
{
    char *state_name;
    int (*state_func) (XMARGSP);
}
BSTATES, *BSTATEP;

BSTATES Batch_Sender[] =
    {
        {"BSInit", BSInit},
        {"BSEnd", BSEnd},
        {"BSND0", BSMoreFiles},
        {"BSND1", BSWaitType},
        {"BSND2", BSCheckFNm},
        {"BSND3", BSCheckFile},
        {"BSND4", BSEndSend},
    };

int
BSInit (XMARGSP args)
{
    args->result = (int) args->control;
    batch_no_sealink = QueryNodeFlag (no_sealink, NOSEA, &remote_addr);
    XON_DISABLE ();
    return ((int) args->control);
}

int
BSEnd (XMARGSP args)
{
    args->result = (int) args->control;
    return ((int) args->control);
}

int
BSMoreFiles (XMARGSP args)
{
    if (args->filename != NULL)
        return (BSND1);
    else                          /* BS0.2 */
        return (BSND4);
}

int
BSWaitType (XMARGSP args)
{
    long BS1Timer;
    int in_char;

    BS1Timer = timerset (20 * PER_SECOND);
    while (!timeup (BS1Timer))
    {
        if ((in_char = PEEKBYTE ()) >= 0)
        {
            switch (in_char)
            {
            case NAK:                /* State BS1.1 */
                args->result = Modem7_Send_File (args->filename);
                return (BSND2);

            case WANTCRC:            /* State BS1.2 */
                if (!batch_no_sealink)
                {
                    args->result = Internal_SEAlink_Send_File (args->filename, NULL);
                    return (BSND3);
                }
#ifdef NO_SEALINK_IS_TELINK
                else
                {
                    args->result = Internal_Telink_Send_File (args->filename, NULL);
                    return (BSND3);
                }
#endif
                /* Fallthrough if we aren't doing SEAlink */

            default:                 /* State BS1.3 */
                TIMED_READ (0);
                time_release ();
            }
        }
        else
        {
            if (!ComIsOnline(hcModem))
                return (CARRIER_ERR);
            else
                time_release ();
        }
    }

    return (TIME_ERR);            /* State BS1.4 */
}

int
BSCheckFNm (XMARGSP args)
{
    if (args->result == SUCCESS)  /* State BS2.1 */
    {
        args->result = Internal_Telink_Send_File (args->filename, NULL);
        return (BSND3);
    }
    else                          /* State BS2.2 */
        return (FNAME_ERR);
}

int
BSCheckFile (XMARGSP args)
{
    return (args->result);
}

int
BSEndSend (XMARGSP args)
{
    long BS4Timer;

    BS4Timer = timerset (10 * PER_SECOND);
    while (!timeup (BS4Timer))
    {
        switch (TIMED_READ (1))
        {
        case NAK:
        case WANTCRC:
            goto Done;
        }
    }

Done:
    /* State BS4.2 */
    SENDBYTE (EOT);
    args->result = SUCCESS;
    return (SUCCESS);
}

int
Batch_Send (char *filename)
{
    XMARGS batch;
    int res;

    batch.result = 0;
    batch.filename = filename;
    res = state_machine ((STATEP) Batch_Sender, &batch, 2);
    status_line (">Batch_Send(%s) returns %d",
                 filename == NULL ? "(null)" : filename, res);
    return (res == SUCCESS ? FILE_SENT_OK : CANNOT_SEND);
}

/* $Id: bsend.cpp,v 1.1 2005/01/01 15:18:11 vildanov Exp $ */

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us