download b_bbs.cpp
Language: C++
Copyright: Copyright 1987-96, Bit Bucket Software Co.
LOC: 227
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/*---------------------------------------------------------------------------*
 *
 *                               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/b_bbs.cpp,v $
 * Revision    : $Revision: 1.1 $
 * Tagname     : $Name:  $
 * Last updated: $Date: 2005/01/01 15:18:11 $
 * State       : $State: Exp $
 * Orig. Author: Vince Perriello
 *
 * Description : BinkleyTerm BBS / UUCP Session Initiator
 *
 *---------------------------------------------------------------------------*/

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

#include "includes.h"

#ifdef NEED_OS2COMMS
#define  hcModem hfComHandle
#endif

void LOCALFUNC                  /* CEH 990107 */
createcmndstring (char *command, char *name, unsigned long baudrate,
                  int el, int cid)
{
    char temp[33];

    /* MR 961122 added addBINKpath */
    sprintf (command, "%s%s %lu %lu ", addBINKpath, name,
             baudrate, cur_baud.rate_value);

#ifndef __unix__
    strcat (command, ultoa ((unsigned long) hfComHandle, temp, 10));
#else
strcat (command, port_device);
#endif

    strcat (command, " ");
    strcat (command, itoa (time_to_next (1), temp, 10));

    if (el != -1)
    {
        strcat (command, " ");
        strcat (command, itoa (el, temp, 10));
    }

    strcat (command, " ");
    strcat (command, mdm_reliable);

    /* SMS 980916 added CurrentCID */
    if (cid && CurrentCID)
    {
        strcat (command, " ");
        strcat (command, CurrentCID);
    }
}


void
BBSexit ()
{
    long retval;
    int xit = 0;
    unsigned long baudrate;
    char command[PATHLEN];
    FILE *bbsbatch = NULL;
    long t1, t2;

    if (BBSnote != NULL)
    {
        SendBanner ((char far *) "\r\n", 1);  /* Start with newline   */
        SendBanner ((char far *) BBSnote, 1);  /* Tell user we're going */
        SendBanner ((char far *) "\r\n", 1);  /* End it with a newline */
    }

    t1 = timerset (100);
    t2 = timerset (400);

    /* Wait for output complete, 4 seconds, or carrier loss */
    while (!OUT_EMPTY () && !timeup (t2) && ComIsOnline(hcModem))
        time_release ();

    /* Make sure we waited at least 1 second */
    while (ComIsOnline(hcModem) && !timeup (t1))
        time_release ();

    /* Now if there is no carrier bag it */
    if (!ComIsOnline(hcModem))
    {
        status_line (MSG_TXT (M_NO_CARRIER));
        return;
    }

    ++hist.bbs_calls;

    // MR 970502 do not update because css is already shown!
    // do_today(0);       /* TJW 960903 update / don't show bmf counters */

    if ((lock_baud && (pbtypes[baud].rate_value >= lock_baud))
            || (ARQ_lock != 0))
        baudrate = max_baud.rate_value;
    else
        baudrate = cur_baud.rate_value;

    if (BBSopt == OPT_BATCH)      /* if BBS flag is batch *//* MR 961122 */
    {
        /* TJW 960722 BBSBATCH -> BBSBAT## */
        /* MR 961122 added addBINKpath */

        sprintf (command, "%s%sbbsbat%02x%s",
                 addBINKpath, COMFILE_PREFIX, TaskNumber, COMFILE_SUFFIX);

        unlink (command);           /* Delete old copies        */

        /* Try to open the file */
        bbsbatch = fopen (command, write_ascii);
        if (bbsbatch == NULL)
        {
            got_error (MSG_TXT (M_OPEN_MSG), command);
            return;
        }

        errno = 0;
        createcmndstring (command, "spawnbbs", baudrate, -1, 0);
        fprintf (bbsbatch, "%s\n", command);
        fclose (bbsbatch);
        xit = 1;
    }

#ifdef BINKLEY_SOUNDS
    Make_Sound (fnBBSSound);
#endif

    if ((BBSopt == OPT_EXIT) || xit)  /* exit or batch? *//* MR 961122 */
    {
        /* MR 961123 use const errorlvl with BBS Batch to make the batch easier */
        if (xit)
            retval = 101;
        else
            retval = baudrate / 100L;

        status_line (MSG_TXT (M_BBS_EXIT), (int) retval);

        if (vfossil_installed)
            vfossil_close ();

        if (!share)                 /* Turn off FOSSIL,         */
            MDM_DISABLE ();           /* if need be               */

        write_sched ();
        no_longer_alive ();         /* MR 961123                */
        exit ((int) retval);        /* and exit with error      */
    }
    else if (BBSopt == OPT_SPAWN) /* if BBS flag is spawn *//* MR 961122 */
    {
        status_line (MSG_TXT (M_BBS_SPAWN));
        gotoxy (0, SB_ROWS - 1);    /* TJW 960517 */
        cputs ("\n");               /* TJW 960517 */
        close_up (share);
        createcmndstring (command, "spawnbbs", baudrate, -1, 1);
        b_spawn (command);          /* Run the BBS */
        come_back ();
        status_line (MSG_TXT (M_BBS_RETURN));
    }
#ifdef BBS_INTERNAL             /* EH */
    else if (BBSopt == OPT_INTERNAL)  /* if BBS flag is internal */
    {
        css_done ();
        status_line (":Calling internal BBS");
        bbsinternal (0);
        status_line (MSG_TXT (M_BBS_RETURN));
        css_init ();
    }
#endif
}

void
close_up (int share_com)
{
    // HJK 98/06/13 - Problems should be fixed by new NTCOMM.DLL version
    // and shareport can now be used in Windows
    // #ifdef _WIN32               /* AS, 970623, ugly hack, but necessary to fix a BIG memory leak (probably caused by cominit/deinit code in NTCOMM) */
    //        COMPAUSE (hcModem);
    // #else
    if (!share_com)
        MDM_DISABLE ();
#if defined(OS_2) | defined(_WIN32)
    else
        ComPause (hcModem);         /* AG 990124 standard function case */
#endif
    // #endif

    vfossil_close ();

#ifdef SET_CONMODE
    setmode (fileno (stdin), O_TEXT);
    setmode (fileno (stdout), O_TEXT);
#endif
}

void
come_back ()
{
    /* Re-enable ourselves */
    if (Cominit (port_ptr, buftmo) != 0x1954)
    {
        printf ("\n%s\n", MSG_TXT (M_FOSSIL_GONE));
        exit (1);
    }

#if defined(OS_2) | defined(_WIN32)
    ComResume (hcModem);          /* AG 990124 standard function case */
#endif

    program_baud ();
    vfossil_init ();

#ifdef SET_CONMODE
    setmode (fileno (stdin), O_BINARY);
    setmode (fileno (stdout), O_BINARY);
#endif

    if (un_attended)
    {
        vfossil_cursor (0);
        screen_clear ();
        sb_dirty ();
        // opening_banner ();  /* MR 970803 removed, because clears screen in terminal mode */
        // mailer_banner ();   /* MR 970803 removed, because sets (wrong) baud rate
        sb_show ();
    }
}

void
UUCPexit (int errlevel, int fCheckCarrier)
{
    unsigned long baudrate;
    char command[PATHLEN];
    FILE *mailbatch;
    long t1, t2;

    /* We check carrier for all applications where we would want to send
       MAILnote. Good thing. SendBanner is highly sensitive to carrier. */

    if (MAILnote != NULL && fCheckCarrier)
    {
        SendBanner ((char far *) "\r\n", 1);  /* Start with newline   */
        SendBanner ((char far *) MAILnote, 1);  /* Say it's mail time */
        SendBanner ((char far *) "\r\n", 1);  /* End with a newline   */
    }

    t1 = timerset (PER_SECOND);
    t2 = timerset (4 * PER_SECOND);

    /* Wait for output complete, 4 seconds, or carrier loss */
    while (!OUT_EMPTY () && !timeup (t2) && (!fCheckCarrier || ComIsOnline(hcModem)))
        time_release ();

    /* Make sure we waited at least 1 second */
    while ((!fCheckCarrier || ComIsOnline(hcModem)) && !timeup (t1))
        time_release ();

    /* Now if there is no carrier bag it */
    if (fCheckCarrier && !ComIsOnline(hcModem))
    {
        status_line (MSG_TXT (M_NO_CARRIER));
        return;
    }

    if ((lock_baud && (pbtypes[baud].rate_value >= lock_baud))
            || (ARQ_lock != 0))
        baudrate = max_baud.rate_value;
    else
        baudrate = cur_baud.rate_value;

#ifdef BINKLEY_SOUNDS
    Make_Sound (fnEXTSound);
#endif

    if (EXTopt == OPT_SPAWN)      /* opt=spawn *//* MR 961122 */
    {
        status_line (MSG_TXT (M_EXT_SPAWN));
        gotoxy (0, SB_ROWS - 1);    /* TJW 960517 */
        cputs ("\n");               /* TJW 960517 */
        close_up (share);
        createcmndstring (command, "extmail", baudrate, errlevel, 0);
        b_spawn (command);          /* Run the External Program */
        come_back ();
        status_line (MSG_TXT (M_EXT_RETURN));
        return;
    }

    strcpy (command, addBINKpath);  /* MR 961122 added addBINKpath */
    strcat (command, COMFILE_PREFIX);  /* Start of batch filename  */
    strcat (command, "mailbat");  /* Meat of Batch filename   */
    strcat (command, COMFILE_SUFFIX);  /* End of batch filename    */
    unlink (command);             /* Delete old copies    */

    /* Try to open the file */
    mailbatch = fopen (command, append_ascii);
    if (mailbatch == NULL)
    {
        got_error (MSG_TXT (M_OPEN_MSG), command);
        return;
    }

    createcmndstring (command, "extmail", baudrate, errlevel, 1);
    fprintf (mailbatch, "%s\n", command);
    fclose (mailbatch);
    status_line (MSG_TXT (M_EXT_MAIL), errlevel);

    if (vfossil_installed)
        vfossil_close ();

    if (!share)                   /* Turn off FOSSIL,         */
        MDM_DISABLE ();             /* if need be               */

    write_sched ();               /* Save scheduler info      */
    no_longer_alive ();           /* MR 961123                */
    exit (errlevel);              /* and exit with UUCP error */
}

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

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