home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume16 / ecu3 / part26 < prev    next >
Encoding:
Internet Message Format  |  1991-01-06  |  43.5 KB

  1. From: wht@n4hgf.uucp (Warren Tucker)
  2. Newsgroups: comp.sources.misc
  3. Subject: v16i050:  ECU async comm package rev 3.0, Part26/35
  4. Message-ID: <1991Jan6.052633.28654@sparky.IMD.Sterling.COM>
  5. Date: 6 Jan 91 05:26:33 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: cf38427c c202b56d 963eb372 0f7eb07f
  8.  
  9. Submitted-by: wht@n4hgf.uucp (Warren Tucker)
  10. Posting-number: Volume 16, Issue 50
  11. Archive-name: ecu3/part26
  12.  
  13. ---- Cut Here and feed the following to sh ----
  14. #!/bin/sh
  15. # This is part 26 of ecu3
  16. if touch 2>&1 | fgrep 'amc' > /dev/null
  17.  then TOUCH=touch
  18.  else TOUCH=true
  19. fi
  20. # ============= gendial/template.c ==============
  21. if test ! -d 'gendial'; then
  22.     echo 'x - creating directory gendial'
  23.     mkdir 'gendial'
  24. fi
  25. echo 'x - extracting gendial/template.c (Text)'
  26. sed 's/^X//' << 'SHAR_EOF' > 'gendial/template.c' &&
  27. X/*+-------------------------------------------------------------------------
  28. X    template.c - DCE-specific portion of generic SCO UUCP dialer
  29. X    wht@n4hgf.Mt-Park.GA.US
  30. X
  31. X Necessary DCE switch setting or other configuration:
  32. X   Switch foo off: enable onhook upon loss of DTR
  33. X--------------------------------------------------------------------------*/
  34. X/*+:EDITS:*/
  35. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  36. X
  37. X#include "dialer.h"
  38. X
  39. X/*
  40. X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
  41. X *                    sees the transition; this value may be changed
  42. X *                    as necessary before each call to ltoggleDTR(),
  43. X * but, generally, a constant value will do.
  44. X */
  45. Xlong DCE_DTR_low_msec = 500;
  46. X
  47. X/*
  48. X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
  49. X *                     DCE may be expected to be ready to be commanded
  50. X */
  51. Xlong DCE_DTR_high_msec = 500;
  52. X
  53. X/*
  54. X * DCE_write_pase_msec - milliseconds to pause between each character
  55. X *                       sent to the DCE (zero if streaming I/O is
  56. X *                       permitted); this value may be changed as
  57. X * necessary before each call to lwrite(), but, generally, a constant
  58. X * value will do.  Note that this value is used to feed a value to nap(),
  59. X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
  60. X * and .050 seconds on XENIX/86.
  61. X */
  62. Xlong DCE_write_pace_msec = 20;
  63. X
  64. X/*
  65. X * DCE_name     - short name for DCE
  66. X * DCE_revision - revision number for this module
  67. X */
  68. Xchar *DCE_name = "Frobozz 9600";
  69. Xchar *DCE_revision = "1.00";
  70. X
  71. X/*
  72. X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
  73. X *                    and readying it for dial in access
  74. X *                    (BXXX mask); use a value of zero if the speed
  75. X *                    specified by the invoker is to be used.
  76. X * This value is useful for DCEs such as the early Hayes 2400
  77. X * which are so unfortunately compatible with their 1200 predecessor
  78. X * that they refuse to answer at 2400 baud unless you last spoke to
  79. X * them at that rate. For such bad boys, use B2400 below.
  80. X */
  81. Xint DCE_hangup_CBAUD = 0;
  82. X/* int DCE_hangup_CBAUD = B2400; */
  83. X
  84. X/*
  85. X * DCE_results - a table of DCE response strings and a token
  86. X *               code for each; when you call lread() or lread_ignore(),
  87. X *               if the read routine detects one of the strings,
  88. X * the appropriate code is returned.  If no string matches, then
  89. X * lread()/lread_ignore examines the DCE result string for a
  90. X * numeric value; if one is found, the numeric value or'd with
  91. X * 0x4000 is returned (in this way, e.g., you can read "modem
  92. X * S registers."  If nothing agrees with this search, lread()
  93. X * will abort the program with RC|FAIL|RCE_TIMOUT, lread_ignore()
  94. X * will return -1.  You may use any value between 0 and 0x3FFFFFFF.
  95. X * This module is the only consumer  of the codes, although they
  96. X * are decoded by gendial.c's _lread()
  97. X */
  98. X#define rfConnect        0x00400000
  99. X
  100. X#define rOk                0
  101. X#define rNoCarrier        1
  102. X#define rError            2
  103. X#define rNoDialTone        3
  104. X#define rBusy            4
  105. X#define rNoAnswer        5
  106. X#define rRring            6
  107. X#define rConnect300        (7 | rfConnect)
  108. X#define rConnect1200    (8 | rfConnect)
  109. X#define rConnect2400    (9 | rfConnect)
  110. X
  111. XDCE_RESULT DCE_results[] =
  112. X{
  113. X    { "OK",                        rOk,            },
  114. X    { "NO CARRIER",                rNoCarrier,        },
  115. X    { "ERROR",                    rError            },
  116. X    { "NO DIALTONE",            rNoDialTone,    },
  117. X    { "BUSY",                    rBusy            },
  118. X    { "NO ANSWER",                rNoAnswer        },
  119. X    { (char *)0,                -1                }        /* end table */
  120. X};
  121. X
  122. X/*+-------------------------------------------------------------------------
  123. X    DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
  124. X
  125. X  DCE dependent function must validate baud rates supported by DCE
  126. X  returns baud rate in struct termio c_cflag fashion
  127. X  or terminates program with error
  128. X--------------------------------------------------------------------------*/
  129. Xint
  130. XDCE_baud_to_CBAUD(baud)
  131. Xunsigned int baud;
  132. X{
  133. X    switch(baud)
  134. X    {
  135. X        case 50:   return(B50);        /* delete the ones you dont handle */
  136. X        case 75:   return(B75);
  137. X        case 110:  return(B110);
  138. X        case 134:  return(B134);
  139. X        case 150:  return(B150);
  140. X        case 300:  return(B300);
  141. X        case 1200: return(B1200);
  142. X        case 2400: return(B2400);
  143. X        case 4800: return(B4800);
  144. X        case 9600: return(B9600);
  145. X
  146. X#if defined(B19200)
  147. X        case 19200: return(B19200);
  148. X#else
  149. X#ifdef EXTA
  150. X        case 19200: return(EXTA);
  151. X#endif
  152. X#endif
  153. X
  154. X#if defined(B38400)
  155. X        case 38400: return(B38400);
  156. X#else
  157. X#ifdef EXTB
  158. X        case 38400: return(EXTB);
  159. X#endif
  160. X#endif
  161. X
  162. X    }
  163. X    myexit(RC_FAIL | RCE_SPEED);
  164. X}    /* end of DCE_baud_to_CBAUD */
  165. X
  166. X/*+-------------------------------------------------------------------------
  167. X    DCE_hangup() - issue hangup command to DCE
  168. X
  169. XThis function should do whatever is necessary to ensure
  170. X1) any active connection is terminated
  171. X2) the DCE is ready to receive an incoming call if DTR is asserted
  172. X3) the DCE will not accept an incoming call if DTR is false
  173. X
  174. XThe function should return when done.
  175. X
  176. XAny necessary switch setting or other configuration necessary for this
  177. Xfunction to succeed should be documented at the top of the module.
  178. X--------------------------------------------------------------------------*/
  179. Xvoid
  180. XDCE_hangup()
  181. X{
  182. X    DEBUG(3,"RESETING %s\n",DCE_name);
  183. X
  184. X}    /* end of DCE_hangup */
  185. X
  186. X/*+-------------------------------------------------------------------------
  187. X    DCE_dial(telno) - dial a remote DCE
  188. X
  189. XThis function should connect to the remote DCE and use any success
  190. Xindication to modify the tty baud rate if necessary before returning.
  191. X
  192. XUpon successful connection, return 0.
  193. X
  194. XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
  195. XRCE_XXX value from dialer.h.
  196. X
  197. Xlwrite() is used to write to the DCE.
  198. X
  199. Xlread() and lread_ignore() are used to read from the DCE.  Read timeouts
  200. Xfrom calling lread() will result automatically in the proper error
  201. Xtermination of the program.  Read timeouts from calling lread_ignore()
  202. Xreturn -1; you handle the execption here.
  203. X
  204. XAny necessary coding of phone numbers, switch settings or other
  205. Xconfiguration necessary for this function to succeed should be
  206. Xdocumented at the top of the module.
  207. X--------------------------------------------------------------------------*/
  208. Xint
  209. XDCE_dial(telno)
  210. Xchar *telno;
  211. X{
  212. Xchar cmd[80];
  213. X
  214. X/* preliminary setup */
  215. X
  216. X/* if root, let him see number, otherwise just say "remote system" */
  217. X    DEBUG(1,"DIALING %s\n", (uid) ? "remote system" : telno);
  218. X
  219. X/* indicate non-root should not see DTE->DCE traffic */
  220. X    secure = 1;
  221. X
  222. X/* issue the actual dialing command */
  223. X
  224. X/* indicate non-root can see DTE->DCE traffic */
  225. X    secure = 0;
  226. X
  227. X    return(0);        /* succeeded */
  228. X
  229. X}    /* end of DCE_dial */
  230. X
  231. X/**********************************************************
  232. X*  You probably do not need to modify the code below here *
  233. X**********************************************************/
  234. X
  235. X/*+-------------------------------------------------------------------------
  236. X    DCE_abort(sig) - dial attempt aborted
  237. X
  238. X sig =  0 if non-signal abort (read timeout, most likely)
  239. X     != 0 if non-SIGALRM signal caught
  240. X
  241. X extern int dialing set  1 if dialing request was active,
  242. X                    else 0 if hangup request was active
  243. X
  244. XThis is a chance for the DCE-specific code to do anything it
  245. Xneeds to cl,ean up after a failure.  Note that if a dialing
  246. Xcall fails, it is the responsibility of the higher-level
  247. Xprogram calling the dialer to call it again with a hangup request, so
  248. Xthis function is usually a no-op.
  249. X--------------------------------------------------------------------------*/
  250. Xvoid
  251. XDCE_abort(sig)
  252. Xint sig;
  253. X{
  254. X    DEBUG(10,"DCE_abort(%d);\n",sig);
  255. X}    /* end of DCE_abort */
  256. X
  257. X/*+-------------------------------------------------------------------------
  258. X    DCE_exit(exitcode) - "last chance for gas" in this incarnation
  259. X
  260. XThe independent portion of the dialer program calls this routine in
  261. Xlieu of exit() in every case except one (see DCE_argv_hook() below).
  262. XNormally, this function just passes it's argument to exit(), but
  263. Xany necessary post-processing can be done.  The function must,
  264. Xhowever, eventually call exit(exitcode);
  265. X--------------------------------------------------------------------------*/
  266. Xvoid
  267. XDCE_exit(exitcode)
  268. Xint exitcode;
  269. X{
  270. X    DEBUG(10,"DCE_exit(%d);\n",exitcode);
  271. X    exit(exitcode);
  272. X}    /* end of DCE_exit */
  273. X
  274. X/*+-------------------------------------------------------------------------
  275. X    DCE_argv_hook(argc,argv,optind,unrecognized_switches)
  276. X
  277. XThis hook gives DCE-specific code a chance to look over the entire
  278. Xcommand line, such as for -z Telebit processing.
  279. X
  280. Xargc andf argv are the same values passed to main(),
  281. X
  282. Xoptind is the value of optind at the end of normal getopt processing.
  283. X
  284. Xunrecognized_switches is the count of switches not handled by main().
  285. XSpecifically, -h and -x are standard switches.
  286. X
  287. XNormally, this function should just return RC_FAIL|RCE_ARGS if there are
  288. Xany unrecognized switches, otherwise zero.  If you keep your nose clean
  289. Xthough, you can do anything you need to do here and exit the program.
  290. X
  291. XNote: only simple switches (with no argument) may be used with this
  292. Xfacility if the functrion is to return,' since main()'s getopt() will
  293. Xstop processing switches if it runs into an unrecognized switch with an
  294. Xargument.
  295. X
  296. XIf the function returns a non-zero value, then the value will be passed
  297. XDIRECTLY to exit() with no further ado.  Thus, a non-zero value must be
  298. Xof the format expected by dialer program callers, with RC_FAIL set as a
  299. Xminimum.
  300. X--------------------------------------------------------------------------*/
  301. Xint
  302. XDCE_argv_hook(argc,argv,optind,unrecognized_switches)
  303. Xint argc;
  304. Xchar **argv;
  305. Xint optind;
  306. Xint unrecognized_switches;
  307. X{
  308. X    if(unrecognized_switches)
  309. X        return(RC_FAIL | RCE_ARGS);
  310. X    return(0);
  311. X}    /* end of DCE_argv_hook */
  312. X
  313. X/* vi: set tabstop=4 shiftwidth=4: */
  314. SHAR_EOF
  315. $TOUCH -am 0814204290 'gendial/template.c' &&
  316. chmod 0644 gendial/template.c ||
  317. echo 'restore of gendial/template.c failed'
  318. Wc_c="`wc -c < 'gendial/template.c'`"
  319. test 9615 -eq "$Wc_c" ||
  320.     echo 'gendial/template.c: original size 9615, current size' "$Wc_c"
  321. # ============= gendial/dceMC9624.c ==============
  322. echo 'x - extracting gendial/dceMC9624.c (Text)'
  323. sed 's/^X//' << 'SHAR_EOF' > 'gendial/dceMC9624.c' &&
  324. X/* CHK=0xB3C9 */
  325. X#define WHT
  326. X/*+-------------------------------------------------------------------------
  327. X    dceMC9624.c - DCE-specific portion of generic SCO UUCP dialer
  328. X    Driver for Microcom AX/9624c (assuming DTMF dialing only)
  329. X    wht@n4hgf.Mt-Park.GA.US
  330. X--------------------------------------------------------------------------*/
  331. X/*+:EDITS:*/
  332. X/*:11-29-1990-18:31-r@n4hgf-revision/1st releasable */
  333. X/*:07-24-1990-15:36-wht@n4hgf-add speaker on/off */
  334. X/*:07-20-1990-00:10-wht@n4hgf-creation */
  335. X
  336. X#include "dialer.h"
  337. X
  338. X/*
  339. X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
  340. X *                    sees the transition; this value may be changed
  341. X *                    as necessary before each call to ltoggleDTR(),
  342. X * but, generally, a constant value will do.
  343. X */
  344. Xlong DCE_DTR_low_msec = 500;
  345. X
  346. X/*
  347. X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
  348. X *                     DCE may be expected to be ready to be commanded
  349. X */
  350. Xlong DCE_DTR_high_msec = 500;
  351. X
  352. X/*
  353. X * DCE_write_pase_msec - milliseconds to pause between each character
  354. X *                       sent to the DCE (zero if streaming I/O is
  355. X *                       permitted); this value may be changed as
  356. X * necessary before each call to lwrite(), but, generally, a constant
  357. X * value will do.  Note that this value is used to feed a value to nap(),
  358. X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
  359. X * and .050 seconds on XENIX/86.
  360. X */
  361. Xlong DCE_write_pace_msec = 0;
  362. X
  363. X/*
  364. X * DCE_name     - short name for DCE
  365. X * DCE_revision - revision number for this module
  366. X */
  367. Xchar *DCE_name = "Microcom AX/9624c";
  368. Xchar *DCE_revision = "1.00";
  369. X
  370. X/*
  371. X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
  372. X *                    and readying it for dial in access
  373. X *                    (BXXX mask); use a value of zero if the speed
  374. X *                    specified by the invoker is to be used.
  375. X * This value is useful for DCEs such as the early Hayes 2400
  376. X * which are so unfortunately compatible with their 1200 predecessor
  377. X * that they refuse to answer at 2400 baud unless you last spoke to
  378. X * them at that rate. For such bad boys, use B2400 below.
  379. X */
  380. Xint DCE_hangup_CBAUD = 0;
  381. X/* int DCE_hangup_CBAUD = B2400; */
  382. X
  383. X/*
  384. X * DCE_results - a table of DCE response strings and a token
  385. X *               code for each; when you call lread() or lread_ignore(),
  386. X *               if the read routine detects one of the strings,
  387. X * the appropriate code is returned.  If no string matches, then
  388. X * lread()/lread_ignore examines the DCE result string for a
  389. X * numeric value; if one is found, the numeric value or'd with
  390. X * 0x40000000 is returned (in this way, e.g., you can read "modem
  391. X * S registers").  If nothing agrees with this search, lread()
  392. X * will abort the program with RC|FAIL|RCE_TIMOUT, lread_ignore()
  393. X * will return -1.  You may use any value between 0 and 0x3FFFFFFF.
  394. X * This module is the only consumer  of the codes, although they
  395. X * are decoded by gendial.c's _lread()
  396. X */
  397. X
  398. X/* flag bits */
  399. X#define rfConnect        0x00800000
  400. X#define rfREL            0x00400000
  401. X#define rfMASK            0x0000FFFF    /* mask off rfBits */
  402. X
  403. X/* unique codes */
  404. X#define rOk                0
  405. X#define rNoCarrier        1
  406. X#define rError            2
  407. X#define rNoDialTone     3
  408. X#define rBusy            4
  409. X#define rNoAnswer        5
  410. X#define rConnect300        (  300  | rfConnect)
  411. X#define rConnect1200    ( 1200  | rfConnect)
  412. X#define rConnect2400    ( 1200  | rfConnect)
  413. X#define rConnect4800    ( 4800  | rfConnect)
  414. X#define rConnect9600    ( 9600  | rfConnect)
  415. X#define rConnect300R    (  300  | rfConnect | rfREL)
  416. X#define rConnect1200R    ( 1200  | rfConnect | rfREL)
  417. X#define rConnect2400R    ( 2400  | rfConnect | rfREL)
  418. X#define rConnect4800R    ( 4800  | rfConnect | rfREL)
  419. X#define rConnect9600R    ( 9600  | rfConnect | rfREL)
  420. X
  421. XDCE_RESULT DCE_results[] =
  422. X{
  423. X    { "OK",                        rOk,            },
  424. X    { "NO CARRIER",                rNoCarrier,        },
  425. X    { "ERROR",                    rError            },
  426. X    { "NO DIALTONE",            rNoDialTone,    },
  427. X    { "BUSY",                    rBusy            },
  428. X    { "NO ANSWER",                rNoAnswer        },
  429. X    { "CONNECT 300/REL",        rConnect300R    },
  430. X    { "CONNECT 1200/REL",        rConnect1200R    },
  431. X    { "CONNECT 2400/REL",        rConnect2400R    },
  432. X    { "CONNECT 4800/REL",        rConnect4800R    },
  433. X    { "CONNECT 9600/REL",        rConnect9600R    },
  434. X    { "CONNECT 300",            rConnect300        },
  435. X    { "CONNECT 1200",            rConnect1200    },
  436. X    { "CONNECT 2400",            rConnect2400    },
  437. X    { "CONNECT 4800",            rConnect4800     },
  438. X    { "CONNECT 9600",            rConnect9600    },
  439. X    { (char *)0,                -1                }        /* end table */
  440. X};
  441. X
  442. X/*+-------------------------------------------------------------------------
  443. X    DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
  444. X
  445. X  DCE dependent function must validate baud rates supported by DCE
  446. X  returns baud rate in struct termio c_cflag fashion
  447. X  or terminates program with error
  448. X--------------------------------------------------------------------------*/
  449. Xint
  450. XDCE_baud_to_CBAUD(baud)
  451. Xunsigned int baud;
  452. X{
  453. X    switch(baud)
  454. X    {
  455. X        case 110:  return(B110);
  456. X        case 300:  return(B300);
  457. X        case 1200: return(B1200);
  458. X        case 2400: return(B2400);
  459. X        case 4800: return(B4800);
  460. X        case 9600: return(B9600);
  461. X
  462. X#if defined(B19200)
  463. X        case 19200: return(B19200);
  464. X#else
  465. X#ifdef EXTA
  466. X        case 19200: return(EXTA);
  467. X#endif
  468. X#endif
  469. X
  470. X    }
  471. X    myexit(RC_FAIL | RCE_SPEED);
  472. X}    /* end of DCE_baud_to_CBAUD */
  473. X
  474. X/*+-------------------------------------------------------------------------
  475. X    sync_Microcom() - sync modem with our DTE speed
  476. X--------------------------------------------------------------------------*/
  477. Xvoid
  478. Xsync_Microcom()
  479. X{
  480. Xregister int maxretry = 4;
  481. Xregister int count;
  482. Xunsigned char rdchar;
  483. X
  484. X    while(maxretry--)
  485. X    {
  486. X        lflush();
  487. X        DCE_write_pace_msec = 20;
  488. X        lwrite("ATQ0E1V1\r");
  489. X        DCE_write_pace_msec = 0;
  490. X        if(lread_ignore(2) == rOk)
  491. X            return;
  492. X    }
  493. X
  494. X    DEBUG(1,"Microcom SYNC FAILED\n",0);
  495. X    myexit(RC_FAIL | RCE_TIMOUT);
  496. X
  497. X}    /* end of sync_Microcom */
  498. X
  499. X/*+-------------------------------------------------------------------------
  500. X    DCE_hangup() - issue hangup command to DCE
  501. X
  502. XThis function should do whatever is necessary to ensure
  503. X1) any active connection is terminated
  504. X2) the DCE is ready to receive an incoming call if DTR is asserted
  505. X3) the DCE will not accept an incoming call if DTR is false
  506. X
  507. XThe function should return when done.
  508. X
  509. XAny necessary switch setting or other configuration necessary for this
  510. Xfunction to succeed should be documented at the top of the module.
  511. X--------------------------------------------------------------------------*/
  512. Xvoid
  513. XDCE_hangup()
  514. X{
  515. Xchar *dialin = "ATS0=1Q1E0M0\\N3\\Q1\\G1%C1%P2\r";
  516. X
  517. X    DEBUG(7,"INITIALIZING %s\n",dce_name);
  518. X
  519. X    ltoggleDTR(2000L);
  520. X    sync_Microcom();
  521. X    lwrite(dialin);
  522. X    nap(500L);
  523. X
  524. X}    /* end of DCE_hangup */
  525. X
  526. X/*+-------------------------------------------------------------------------
  527. X    DCE_dial(telno) - dial a remote DCE
  528. X
  529. XThis function should connect to the remote DCE and use any success
  530. Xindication to modify the tty baud rate if necessary before returning.
  531. X
  532. XUpon successful connection, return 0.
  533. X
  534. XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
  535. XRCE_XXX value from dialer.h.
  536. X
  537. Xlwrite() is used to write to the DCE.
  538. X
  539. Xlread() and lread_ignore() are used to read from the DCE.  Read timeouts
  540. Xfrom calling lread() will result automatically in the proper error
  541. Xtermination of the program.  Read timeouts from calling lread_ignore()
  542. Xreturn -1; you handle the execption here.
  543. X
  544. XAny necessary coding of phone numbers, switch settings or other
  545. Xconfiguration necessary for this function to succeed should be
  546. Xdocumented at the top of the module.
  547. X
  548. XMicrocom Plus-specific comments:
  549. X--------------------------------------------------------------------------*/
  550. Xint
  551. XDCE_dial(telno)
  552. Xchar *telno;
  553. X{
  554. Xchar cmd[128];
  555. Xint s50_set = 0;
  556. Xint s111_set = 0;
  557. Xint timeout;
  558. Xint result;
  559. Xlong then;
  560. Xlong now;
  561. Xchar *cptr;
  562. Xchar phnum[42];
  563. X#define MDVALID "0123456789NnSs,*#()-"
  564. Xchar *setup      = "ATQ0E1V1X4S0=0&D2&C1%C1%P2";
  565. Xchar *setup_REL  = "\\N3\\Q1\\G1";
  566. Xchar *setup_NORM = "\\N0\\Q0\\G0";
  567. X
  568. X/* preliminary setup */
  569. X    translate("=,-,",telno);
  570. X    if(strspn(telno,MDVALID) != strlen(telno))
  571. X    {
  572. X        DEBUG(1,"phone number has invalid characters\n",0);
  573. X        return(RC_FAIL | RCE_PHNO);
  574. X    }
  575. X    if(decode_phone_number(telno,phnum,sizeof(phnum)))
  576. X    {
  577. X        DEBUG(1,"phone number too long\n",0);
  578. X        return(RC_FAIL | RCE_PHNO);
  579. X    }
  580. X
  581. X/*
  582. X * calculate a timeout for the connect
  583. X * allow a minimum of 40 seconds, if reliable, 50
  584. X * also if long distance (North American calculation here)
  585. X * make it 132
  586. X */
  587. X    timeout = 40;
  588. X    if(hiCBAUD > B2400)
  589. X        timeout = 50;
  590. X    if((phnum[0] == '1') && (phnum[0] != '0'))
  591. X        timeout = 132;
  592. X    for(cptr = phnum; cptr = strchr(cptr,','); cptr++)
  593. X        timeout += 2;    /* add extra time for pause characters */
  594. X    DEBUG(6,"timeout waiting for connect = %d seconds\n",timeout);
  595. X
  596. X/*
  597. X * build and issue the dialout setup command
  598. X * 9624's S7 timing is way off (S7 is calculated as timeout * .6)
  599. X */
  600. X    DEBUG(1,"--> issuing setup command\n",0);
  601. X    sprintf(cmd,"%s%sS7=%d\r",
  602. X        setup,
  603. X        (hiCBAUD > B2400) ? setup_REL : setup_NORM,
  604. X        (timeout * 6) / 10);
  605. X
  606. X    sync_Microcom();
  607. X    lwrite(cmd);
  608. X    if(lread(2) != rOk)
  609. X        return(RC_FAIL | RCE_NULL);
  610. X
  611. X/* indicate non-root should not see DTE->DCE traffic */
  612. X    secure = 1;
  613. X
  614. X/*
  615. X * build and issue the actual dialing command
  616. X * if root, let him see number, otherwise just say "remote system"
  617. X */
  618. X#ifdef WHT
  619. X    if(!strncmp(*gargv,"ECU",3))
  620. X        dialer_codes['S' - 'A'] = 1;
  621. X#endif
  622. X    DEBUG(1,"--> dialing %s\n", (uid) ? "remote system" : phnum);
  623. X    sprintf(cmd,"ATS2=1M%dDT%s\r",
  624. X        ((dialer_codes['S' - 'A']) && !(dialer_codes['N' - 'A'])) ? 1 : 0,
  625. X        phnum);
  626. X
  627. X    /* cmd string can only be 40 characters including "AT" */
  628. X    if(strlen(cmd) > 40)
  629. X    {
  630. X        DEBUG(1,"phone number string too long\n",0);
  631. X        cleanup(RC_FAIL | RCE_PHNO);
  632. X    }
  633. X
  634. X    lwrite(cmd);
  635. X
  636. X/* indicate non-root can see DTE->DCE traffic */
  637. X    secure = 0;
  638. X
  639. X/* wait for connect */
  640. XWAIT_FOR_CONNECT:
  641. X    time(&then);
  642. X    result = lread(timeout);
  643. X    if(!(result & rfConnect))
  644. X    {
  645. X        switch(result & rfMASK)
  646. X        {
  647. X        case rNoDialTone:
  648. X            return(RC_FAIL | RCE_NOTONE);
  649. X        case rBusy:
  650. X            return(RC_FAIL | RCE_BUSY);
  651. X        case rNoAnswer:
  652. X        case rNoCarrier:    /* with ATX4, NO CARRIER == NO ANSWER
  653. X                             * since BUSY and NO DIAL TONE are reported
  654. X                             */
  655. X            return(RC_FAIL | RCE_ANSWER);
  656. X        default:
  657. X            return(RC_FAIL | RCE_NULL);
  658. X        }
  659. X    }
  660. X
  661. X    return(0);        /* succeeded */
  662. X
  663. X}    /* end of DCE_dial */
  664. X
  665. X/**********************************************************
  666. X*  You probably do not need to modify the code below here *
  667. X**********************************************************/
  668. X
  669. X/*+-------------------------------------------------------------------------
  670. X    DCE_abort(sig) - dial attempt aborted
  671. X
  672. X sig =  0 if non-signal abort (read timeout, most likely)
  673. X     != 0 if non-SIGALRM signal caught
  674. X
  675. X extern int dialing set  1 if dialing request was active,
  676. X                    else 0 if hangup request was active
  677. X
  678. XThis is a chance for the DCE-specific code to do anything it
  679. Xneeds to cl,ean up after a failure.  Note that if a dialing
  680. Xcall fails, it is the responsibility of the higher-level
  681. Xprogram calling the dialer to call it again with a hangup request, so
  682. Xthis function is usually a no-op.
  683. X--------------------------------------------------------------------------*/
  684. Xvoid
  685. XDCE_abort(sig)
  686. Xint sig;
  687. X{
  688. X    DEBUG(10,"DCE_abort(%d);\n",sig);
  689. X}    /* end of DCE_abort */
  690. X
  691. X/*+-------------------------------------------------------------------------
  692. X    DCE_exit(exitcode) - "last chance for gas" in this incarnation
  693. X
  694. XThe independent portion of the dialer program calls this routine in
  695. Xlieu of exit() in every case except one (see DCE_argv_hook() below).
  696. XNormally, this function just passes it's argument to exit(), but
  697. Xany necessary post-processing can be done.  The function must,
  698. Xhowever, eventually call exit(exitcode);
  699. X--------------------------------------------------------------------------*/
  700. Xvoid
  701. XDCE_exit(exitcode)
  702. Xint exitcode;
  703. X{
  704. X    DEBUG(10,"DCE_exit(%d);\n",exitcode);
  705. X    exit(exitcode);
  706. X}    /* end of DCE_exit */
  707. X
  708. X/*+-------------------------------------------------------------------------
  709. X    DCE_argv_hook(argc,argv,optind,unrecognized_switches)
  710. X
  711. XThis hook gives DCE-specific code a chance to look over the entire
  712. Xcommand line, such as for -z processing.
  713. X
  714. Xargc andf argv are the same values passed to main(),
  715. X
  716. Xoptind is the value of optind at the end of normal getopt processing.
  717. X
  718. Xunrecognized_switches is the count of switches not handled by main().
  719. XSpecifically, -h and -x are standard switches.
  720. X
  721. XNormally, this function should just return RC_FAIL|RCE_ARGS if there are
  722. Xany unrecognized switches, otherwise zero.  If you keep your nose clean
  723. Xthough, you can do anything you need to do here and exit the program.
  724. X
  725. XNote: only simple switches (with no argument) may be used with this
  726. Xfacility if the functrion is to return,' since main()'s getopt() will
  727. Xstop processing switches if it runs into an unrecognized switch with an
  728. Xargument.
  729. X
  730. XIf the function returns a non-zero value, then the value will be passed
  731. XDIRECTLY to exit() with no further ado.  Thus, a non-zero value must be
  732. Xof the format expected by dialer program callers, with RC_FAIL set as a
  733. Xminimum.
  734. X--------------------------------------------------------------------------*/
  735. Xint
  736. XDCE_argv_hook(argc,argv,optind,unrecognized_switches)
  737. Xint argc;
  738. Xchar **argv;
  739. Xint optind;
  740. Xint unrecognized_switches;
  741. X{
  742. X    if(unrecognized_switches)
  743. X        return(RC_FAIL | RCE_ARGS);
  744. X    return(0);
  745. X}    /* end of DCE_argv_hook */
  746. X
  747. X/* vi: set tabstop=4 shiftwidth=4: */
  748. SHAR_EOF
  749. $TOUCH -am 1129183190 'gendial/dceMC9624.c' &&
  750. chmod 0644 gendial/dceMC9624.c ||
  751. echo 'restore of gendial/dceMC9624.c failed'
  752. Wc_c="`wc -c < 'gendial/dceMC9624.c'`"
  753. test 13186 -eq "$Wc_c" ||
  754.     echo 'gendial/dceMC9624.c: original size 13186, current size' "$Wc_c"
  755. # ============= gendial/dceTBPlus.c ==============
  756. echo 'x - extracting gendial/dceTBPlus.c (Text)'
  757. sed 's/^X//' << 'SHAR_EOF' > 'gendial/dceTBPlus.c' &&
  758. X/* CHK=0xFF53 */
  759. X/* #define TRUSTING        /* trust user has -z'd before use */
  760. X#define WHT
  761. X/*+-------------------------------------------------------------------------
  762. X    dceTBPlus.c - DCE-specific portion of generic SCO UUCP dialer
  763. X    Driver for Telebit Trailblazer Plus
  764. X    wht@n4hgf.Mt-Park.GA.US
  765. X--------------------------------------------------------------------------*/
  766. X/*+:EDITS:*/
  767. X/*:11-29-1990-18:31-r@n4hgf-revision/1st releasable */
  768. X/*:07-20-1990-00:10-wht@n4hgf-creation */
  769. X
  770. X#include "dialer.h"
  771. X
  772. X/*
  773. X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
  774. X *                    sees the transition; this value may be changed
  775. X *                    as necessary before each call to ltoggleDTR(),
  776. X * but, generally, a constant value will do.
  777. X */
  778. Xlong DCE_DTR_low_msec = 500;
  779. X
  780. X/*
  781. X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
  782. X *                     DCE may be expected to be ready to be commanded
  783. X */
  784. Xlong DCE_DTR_high_msec = 500;
  785. X
  786. X/*
  787. X * DCE_write_pase_msec - milliseconds to pause between each character
  788. X *                       sent to the DCE (zero if streaming I/O is
  789. X *                       permitted); this value may be changed as
  790. X * necessary before each call to lwrite(), but, generally, a constant
  791. X * value will do.  Note that this value is used to feed a value to nap(),
  792. X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
  793. X * and .050 seconds on XENIX/86.
  794. X */
  795. Xlong DCE_write_pace_msec = 0;
  796. X
  797. X/*
  798. X * DCE_name     - short name for DCE
  799. X * DCE_revision - revision number for this module
  800. X */
  801. Xchar *DCE_name = "Telebit Trailblazer Plus";
  802. Xchar *DCE_revision = "1.00";
  803. X
  804. X/*
  805. X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
  806. X *                    and readying it for dial in access
  807. X *                    (BXXX mask); use a value of zero if the speed
  808. X *                    specified by the invoker is to be used.
  809. X * This value is useful for DCEs such as the early Hayes 2400
  810. X * which are so unfortunately compatible with their 1200 predecessor
  811. X * that they refuse to answer at 2400 baud unless you last spoke to
  812. X * them at that rate. For such bad boys, use B2400 below.
  813. X */
  814. Xint DCE_hangup_CBAUD = 0;
  815. X/* int DCE_hangup_CBAUD = B2400; */
  816. X
  817. X/*
  818. X * DCE_results - a table of DCE response strings and a token
  819. X *               code for each; when you call lread() or lread_ignore(),
  820. X *               if the read routine detects one of the strings,
  821. X * the appropriate code is returned.  If no string matches, then
  822. X * lread()/lread_ignore examines the DCE result string for a
  823. X * numeric value; if one is found, the numeric value or'd with
  824. X * 0x40000000 is returned (in this way, e.g., you can read "modem
  825. X * S registers").  If nothing agrees with this search, lread()
  826. X * will abort the program with RC|FAIL|RCE_TIMOUT, lread_ignore()
  827. X * will return -1.  You may use any value between 0 and 0x3FFFFFFF.
  828. X * This module is the only consumer  of the codes, although they
  829. X * are decoded by gendial.c's _lread()
  830. X */
  831. X
  832. X/* flag bits */
  833. X#define rfConnect        0x00800000
  834. X#define rfREL            0x00400000
  835. X#define rfFAST            0x00200000
  836. X#define rfMASK            0x0000FFFF    /* mask off rfBits */
  837. X
  838. X/* unique codes */
  839. X#define rOk                0
  840. X#define rNoCarrier        1
  841. X#define rError            2
  842. X#define rNoDialTone     3
  843. X#define rBusy            4
  844. X#define rNoAnswer        5
  845. X#define rRring            6
  846. X#define rConnect300        (  300  | rfConnect)
  847. X#define rConnect1200    ( 1200  | rfConnect)
  848. X#define rConnect2400    ( 2400  | rfConnect)
  849. X#define rConnect300R    (  300  | rfConnect | rfREL)
  850. X#define rConnect1200R    ( 1200  | rfConnect | rfREL)
  851. X#define rConnect2400R    ( 2400  | rfConnect | rfREL)
  852. X#define rConnectFASTK    (19200  | rfConnect | rfFAST)
  853. X#define rConnectFASTX    (19200  | rfConnect | rfFAST)
  854. X#define rConnectFASTU    (19200  | rfConnect | rfFAST)
  855. X#define rConnectFAST    (19200  | rfConnect | rfFAST)
  856. X
  857. XDCE_RESULT DCE_results[] =
  858. X{
  859. X    { "OK",                        rOk,            },
  860. X    { "NO CARRIER",                rNoCarrier,        },
  861. X    { "ERROR",                    rError            },
  862. X    { "NO DIALTONE",            rNoDialTone,    },
  863. X    { "BUSY",                    rBusy            },
  864. X    { "NO ANSWER",                rNoAnswer        },
  865. X    { "RRING",                    rRring            },
  866. X    { "CONNECT 300/REL",        rConnect300R    },
  867. X    { "CONNECT 1200/REL",        rConnect1200R    },
  868. X    { "CONNECT 2400/REL",        rConnect2400R    },
  869. X    { "CONNECT 300",            rConnect300        },
  870. X    { "CONNECT 1200",            rConnect1200    },
  871. X    { "CONNECT 2400",            rConnect2400    },
  872. X    { "CONNECT FAST/KERM",        rConnectFASTK    },
  873. X    { "CONNECT FAST/XMDM",        rConnectFASTX    },
  874. X    { "CONNECT FAST/UUCP",        rConnectFASTU    },
  875. X    { "CONNECT FAST",            rConnectFAST    },
  876. X    { (char *)0,                -1                }        /* end table */
  877. X};
  878. X
  879. X/*+-------------------------------------------------------------------------
  880. X    DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
  881. X
  882. X  DCE dependent function must validate baud rates supported by DCE
  883. X  returns baud rate in struct termio c_cflag fashion
  884. X  or terminates program with error
  885. X--------------------------------------------------------------------------*/
  886. Xint
  887. XDCE_baud_to_CBAUD(baud)
  888. Xunsigned int baud;
  889. X{
  890. X    switch(baud)
  891. X    {
  892. X        case 110:  return(B110);
  893. X        case 300:  return(B300);
  894. X        case 1200: return(B1200);
  895. X        case 2400: return(B2400);
  896. X        case 9600: return(B9600);
  897. X
  898. X#if defined(B19200)
  899. X        case 19200: return(B19200);
  900. X#else
  901. X#ifdef EXTA
  902. X        case 19200: return(EXTA);
  903. X#endif
  904. X#endif
  905. X
  906. X#if defined(B38400)
  907. X        case 38400: return(B38400);
  908. X#else
  909. X#ifdef EXTB
  910. X        case 38400: return(EXTB);
  911. X#endif
  912. X#endif
  913. X
  914. X    }
  915. X    myexit(RC_FAIL | RCE_SPEED);
  916. X}    /* end of DCE_baud_to_CBAUD */
  917. X
  918. X/*+-------------------------------------------------------------------------
  919. X    sync_Telebit() - sync modem with our DTE speed
  920. X--------------------------------------------------------------------------*/
  921. Xvoid
  922. Xsync_Telebit()
  923. X{
  924. Xregister int maxretry = 8;
  925. Xregister int count;
  926. Xunsigned char rdchar;
  927. X
  928. X    while(maxretry--)
  929. X    {
  930. X        lflush();
  931. X        write(fddce,"a",1);
  932. X        count = 5;
  933. X        while(count)    /* wait 50-200 msec for character, depending on HZ */
  934. X        {
  935. X            if(rdchk(fddce))
  936. X                break;
  937. X            nap(50L);
  938. X            count--;
  939. X        }
  940. X        if(count && (read(fddce,&rdchar,1) == 1) && (rdchar == 'a'))
  941. X            return;
  942. X    }
  943. X
  944. X    DEBUG(1,"Telebit SYNC FAILED\n",0);
  945. X    myexit(RC_FAIL | RCE_TIMOUT);
  946. X
  947. X}    /* end of sync_Telebit */
  948. X
  949. X/*+-------------------------------------------------------------------------
  950. X    init_TBPlus() - init TBPlus from scratch, assuming nothing
  951. X
  952. X    reset to factory defaults, then set
  953. X    E0          no local echo in command mode
  954. X    F1          no local echo in data transfer mode
  955. X    M0          speaker off
  956. X    Q4          generate reult codes, but not RING
  957. X    V1          verbal result codes
  958. X    X3          extended result codes
  959. X    S0=1        answer on first ring
  960. X    S2=1        escape to "unusual" value
  961. X    S11=50      50 msec DTMF timing
  962. X    S45=1       enable remote access
  963. X    S48=1       all 8 bits are significant
  964. X    S50=0       use automatic connect speed determination
  965. X    S51=252     set serial port baud rate automatically (no typeahead)
  966. X    S52=2       go on hook when DTR drops and reset to NV-RAM
  967. X    S53=1       DCD signal follows remote carrier, DSR on when modem ready
  968. X    S54=3       pass BREAK signal to remote modem
  969. X    S55=0       respond to command escape sequence
  970. X    S58=2       DTE uses CTS/RTS flow control.
  971. X    S64=1       ignore characters sent by DTE while answering
  972. X    S66=0       don't lock interface speed, just go with the flow.
  973. X    S68=255     DCE uses whatever flow control DTE uses
  974. X    S92=1       PEP tones at the end of answer sequence
  975. X    S95=0       no MNP
  976. X    S110=255    use data compression when the remote modem requests it.
  977. X    S111=255    accept any protocol
  978. X--------------------------------------------------------------------------*/
  979. Xvoid
  980. Xinit_TBPlus()
  981. X{
  982. Xregister itmp;
  983. Xint maxretry = 4;
  984. Xchar *init0 = "AT&FE0F1M0Q4V1X3\r";
  985. Xchar *init1 = "ATS0=1S2=1S11=50S45=1S48=1S50=0S51=252S52=2S53=1S54=3\r";
  986. Xchar *init2 = "ATS55=0S58=2S64=1S66=0S68=255S92=1S95=0S110=255S111=255\r";
  987. X
  988. X    DEBUG(7,"INITIALIZING %s\n",dce_name);
  989. X    ltoggleDTR(0L);
  990. X    sync_Telebit();
  991. X
  992. X    /*
  993. X     * set to factory default (bless them for this command)
  994. X     * and a few initial beachhead values
  995. X     */
  996. X    for(itmp = 0; itmp < maxretry; itmp++)
  997. X    {
  998. X        lwrite("AT&FE0F1M0Q4V1X3\r");
  999. X        if(lread(2) == rOk)
  1000. X            break;
  1001. X    }
  1002. X    if(itmp == maxretry)
  1003. X    {
  1004. X        DEBUG(1,"INIT FAILED (init0)\n",0);
  1005. X        myexit(RC_FAIL | RCE_TIMOUT);
  1006. X    }
  1007. X
  1008. X    /*
  1009. X     * send initialization string 1
  1010. X     */
  1011. X    for(itmp = 0; itmp < maxretry; itmp++)
  1012. X    {
  1013. X        lwrite(init1);
  1014. X        if(lread(2) == rOk)
  1015. X            break;
  1016. X    }
  1017. X    if(itmp == maxretry)
  1018. X    {
  1019. X        DEBUG(1,"INIT FAILED (init1)\n",0);
  1020. X        myexit(RC_FAIL | RCE_TIMOUT);
  1021. X    }
  1022. X
  1023. X    /*
  1024. X     * send initialization string 2
  1025. X     */
  1026. X    for(itmp = 0; itmp < maxretry; itmp++)
  1027. X    {
  1028. X        lwrite(init2);
  1029. X        if(lread(2) == rOk)
  1030. X            break;
  1031. X    }
  1032. X    if(itmp == maxretry)
  1033. X    {
  1034. X        DEBUG(1,"INIT FAILED (init2)\n",0);
  1035. X        myexit(RC_FAIL | RCE_TIMOUT);
  1036. X    }
  1037. X
  1038. X}    /* end of init_TBPlus */
  1039. X
  1040. X/*+-------------------------------------------------------------------------
  1041. X    DCE_hangup() - issue hangup command to DCE
  1042. X
  1043. XThis function should do whatever is necessary to ensure
  1044. X1) any active connection is terminated
  1045. X2) the DCE is ready to receive an incoming call if DTR is asserted
  1046. X3) the DCE will not accept an incoming call if DTR is false
  1047. X
  1048. XThe function should return when done.
  1049. X
  1050. XAny necessary switch setting or other configuration necessary for this
  1051. Xfunction to succeed should be documented at the top of the module.
  1052. X--------------------------------------------------------------------------*/
  1053. Xvoid
  1054. XDCE_hangup()
  1055. X{
  1056. X#ifdef TRUSTING
  1057. X    DEBUG(7,"RESETING %s\n",dce_name);
  1058. X    ltoggle_DTR(0L);
  1059. X    lwrite("ATZ\r");
  1060. X    (void)lread_ignore(1);
  1061. X#else /* !TRUSTING */
  1062. X    init_TBPlus();
  1063. X#endif
  1064. X
  1065. X}    /* end of DCE_hangup */
  1066. X
  1067. X/*+-------------------------------------------------------------------------
  1068. X    DCE_dial(telno) - dial a remote DCE
  1069. X
  1070. XThis function should connect to the remote DCE and use any success
  1071. Xindication to modify the tty baud rate if necessary before returning.
  1072. X
  1073. XUpon successful connection, return 0.
  1074. X
  1075. XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
  1076. XRCE_XXX value from dialer.h.
  1077. X
  1078. Xlwrite() is used to write to the DCE.
  1079. X
  1080. Xlread() and lread_ignore() are used to read from the DCE.  Read timeouts
  1081. Xfrom calling lread() will result automatically in the proper error
  1082. Xtermination of the program.  Read timeouts from calling lread_ignore()
  1083. Xreturn -1; you handle the execption here.
  1084. X
  1085. XAny necessary coding of phone numbers, switch settings or other
  1086. Xconfiguration necessary for this function to succeed should be
  1087. Xdocumented at the top of the module.
  1088. X
  1089. XTelebit Plus-specific comments:
  1090. X S0=0        dont allow connect while dialing
  1091. X S54=3       pass BREAK signal to remote modem
  1092. X S64=0       abort dialing if characters sent by DTE
  1093. X S66=1       lock the interface speed
  1094. X S110=0      disable data compression unless requested otherwise
  1095. X--------------------------------------------------------------------------*/
  1096. Xint
  1097. XDCE_dial(telno)
  1098. Xchar *telno;
  1099. X{
  1100. Xchar cmd[128];
  1101. Xchar phone[50];
  1102. Xint s50_set = 0;
  1103. Xint s111_set = 0;
  1104. Xint timeout;
  1105. Xint result;
  1106. Xint rrings = 0;
  1107. Xlong then;
  1108. Xlong now;
  1109. Xchar *cptr;
  1110. Xchar *dialout_default = "ATS0=0S7=40S54=3S64=0S66=1S110=0\r";
  1111. X#define MDVALID     "0123456789CcEeFfKkMmNnPpRrSsUuWwXx*#,!/()-"
  1112. X
  1113. X/* preliminary setup */
  1114. X    translate("=,-,",telno);
  1115. X    if(strspn(telno,MDVALID) != strlen(telno))
  1116. X    {
  1117. X        DEBUG(1,"phone number has invalid characters\n",0);
  1118. X        return(RC_FAIL | RCE_PHNO);
  1119. X    }
  1120. X    if(decode_phone_number(telno,phone,sizeof(phone)))
  1121. X    {
  1122. X        DEBUG(1,"phone number too long\n",0);
  1123. X        return(RC_FAIL | RCE_PHNO);
  1124. X    }
  1125. X
  1126. X/* walk through dialer codes, doing custom setup */
  1127. X    strcpy(cmd,"AT");
  1128. X    cptr = cmd + strlen(cmd);
  1129. X    if(dialer_codes['C' - 'A'])
  1130. X    {
  1131. X        DEBUG(5,"COMPRESSION requested\n",0);
  1132. X        strcat(cmd,"S110=1");
  1133. X    }
  1134. X    if(dialer_codes['E' - 'A'])
  1135. X    {
  1136. X        DEBUG(5,"ECHO SUPPRESSION requested\n",0);
  1137. X        strcat(cmd,"S121=1");
  1138. X    }
  1139. X    if(dialer_codes['F' - 'A'])
  1140. X    {
  1141. X        DEBUG(5,"XON/XOFF FLOW CONTROL requested\n",0);
  1142. X        strcat(cmd,"S58=3");
  1143. X    }
  1144. X    if(dialer_codes['K' - 'A'])
  1145. X    {
  1146. X        DEBUG(5,"KERMIT requested\n",0);
  1147. X        strcat(cmd,"S111=10");
  1148. X        s111_set++;
  1149. X    }
  1150. X    if(dialer_codes['X' - 'A'])
  1151. X    {
  1152. X        DEBUG(5,"XMODEM requested\n",0);
  1153. X        strcat(cmd,"S111=20");
  1154. X        s111_set++;
  1155. X    }
  1156. X    if(dialer_codes['U' - 'A'])
  1157. X    {
  1158. X        DEBUG(5,"UUCP requested\n",0);
  1159. X        strcat(cmd,"S111=30");
  1160. X        s111_set++;
  1161. X    }
  1162. X    if(dialer_codes['M' - 'A'])
  1163. X    {
  1164. X        DEBUG(5,"MNP requested\n",0);
  1165. X        strcat(cmd,"S95=1");
  1166. X    }
  1167. X
  1168. X    if((dialer_codes['P' - 'A']) || s111_set || (hiCBAUD >= B9600))
  1169. X    {
  1170. X        if(hiCBAUD < B9600)
  1171. X        {
  1172. X            DEBUG(1,"baud rate not high enough for PEP\n",0);
  1173. X            return(RC_FAIL | RCE_SPEED);
  1174. X        }
  1175. X        if(dialer_codes['P' - 'A'])
  1176. X            DEBUG(5,"PEP requested\n",0);
  1177. X        else
  1178. X            DEBUG(5,"PEP inferred: speed >= 9600\n",0);
  1179. X
  1180. X        dialer_codes['P' - 'A'] = 1;
  1181. X        strcat(cmd,"S50=255");
  1182. X    }
  1183. X
  1184. X
  1185. X    DEBUG(6,"--> issuing default setup command\n",0);
  1186. X    sync_Telebit();
  1187. X    lwrite(dialout_default);
  1188. X    if(lread(2) != rOk)
  1189. X    {
  1190. X        DEBUG(1,"default dialout setup failed\n",0);
  1191. X        return(RC_FAIL | RCE_NULL);
  1192. X    }
  1193. X
  1194. X/* issue the custom setup command */
  1195. X    if(*cptr)
  1196. X    {
  1197. X        DEBUG(5,"--> issuing custom setup cmd\n",0);
  1198. X        strcat(cmd,"\r");
  1199. X        sync_Telebit();
  1200. X        lwrite(cmd);
  1201. X        if(lread(2) != rOk)
  1202. X        {
  1203. X            DEBUG(1,"custom modem setup failed\n",0);
  1204. X            return(RC_FAIL | RCE_NULL);
  1205. X        }
  1206. X    }
  1207. X
  1208. X/*
  1209. X * calculate a timeout for the connect
  1210. X * allow a minimum of 40 seconds, but if PEP, 90
  1211. X * also if long distance (North American calculation here)
  1212. X * make it 132 (S7 is calculated as timeout * .9)
  1213. X */
  1214. X    timeout = 40;
  1215. X    if((phone[0] == '1') && (phone[0] != '0'))
  1216. X        timeout = 132;
  1217. X    if((timeout < 90) && dialer_codes['P' - 'A'])
  1218. X        timeout = 90;
  1219. X    for(cptr = phone; cptr = strchr(cptr,','); cptr++)
  1220. X        timeout += 2;    /* add extra time for pause characters */
  1221. X    DEBUG(6,"timeout waiting for connect = %d seconds\n",timeout);
  1222. X
  1223. X/* indicate non-root should not see DTE->DCE traffic */
  1224. X    secure = 1;
  1225. X
  1226. X/*
  1227. X * build and issue the actual dialing command
  1228. X * if root, let him see number, otherwise just say "remote system"
  1229. X */
  1230. X    DEBUG(1,"--> dialing %s\n", (uid) ? "remote system" : telno);
  1231. X#ifdef WHT
  1232. X    if(!strncmp(*gargv,"ECU",3))
  1233. X        dialer_codes['S' - 'A'] = 1;
  1234. X#endif
  1235. X    sprintf(cmd,"ATM%dS7=%dDT%s\r",
  1236. X        ((dialer_codes['S' - 'A']) && !(dialer_codes['N' - 'A'])) ? 1 : 0,
  1237. X        (timeout * 9) / 10,telno);
  1238. X
  1239. X    /* cmd string can only be 80 characters including "AT" */
  1240. X    if(strlen(cmd) > 80)
  1241. X    {
  1242. X        DEBUG(1,"phone number string too long\n",0);
  1243. X        cleanup(RC_FAIL | RCE_PHNO);
  1244. X    }
  1245. X
  1246. X    sync_Telebit();
  1247. X    lwrite(cmd);
  1248. X
  1249. X/* indicate non-root can see DTE->DCE traffic */
  1250. X    secure = 0;
  1251. X
  1252. X/* wait for connect */
  1253. XWAIT_FOR_CONNECT:
  1254. X    time(&then);
  1255. X    result = lread(timeout);
  1256. X    if(!(result & rfConnect))
  1257. X    {
  1258. X        switch(result & rfMASK)
  1259. X        {
  1260. X        case rNoCarrier:
  1261. X            return(RC_FAIL | ((rrings > 2) ? RCE_ANSWER : RCE_NOTONE));
  1262. X        case rNoDialTone:
  1263. X            return(RC_FAIL | RCE_NOTONE);
  1264. X        case rBusy:
  1265. X            return(RC_FAIL | RCE_BUSY);
  1266. X        case rNoAnswer:
  1267. X            return(RC_FAIL | RCE_ANSWER);
  1268. X        case rRring:
  1269. X            if(rrings++ > 7)
  1270. X                return(RC_FAIL | RCE_ANSWER);
  1271. X            time(&now);
  1272. X            if((timeout -= ((int)(then - now))) > 0)
  1273. X                goto WAIT_FOR_CONNECT;
  1274. X        case rError:
  1275. X        default:
  1276. X            return(RC_FAIL | RCE_NULL);
  1277. X        }
  1278. X    }
  1279. X
  1280. X    return(0);        /* succeeded */
  1281. X
  1282. X}    /* end of DCE_dial */
  1283. X
  1284. X/**********************************************************
  1285. X*  You probably do not need to modify the code below here *
  1286. X**********************************************************/
  1287. X
  1288. X/*+-------------------------------------------------------------------------
  1289. X    DCE_abort(sig) - dial attempt aborted
  1290. X
  1291. X sig =  0 if non-signal abort (read timeout, most likely)
  1292. X     != 0 if non-SIGALRM signal caught
  1293. X
  1294. X extern int dialing set  1 if dialing request was active,
  1295. X                    else 0 if hangup request was active
  1296. X
  1297. XThis is a chance for the DCE-specific code to do anything it
  1298. Xneeds to cl,ean up after a failure.  Note that if a dialing
  1299. Xcall fails, it is the responsibility of the higher-level
  1300. Xprogram calling the dialer to call it again with a hangup request, so
  1301. Xthis function is usually a no-op.
  1302. X--------------------------------------------------------------------------*/
  1303. Xvoid
  1304. XDCE_abort(sig)
  1305. Xint sig;
  1306. X{
  1307. X    DEBUG(10,"DCE_abort(%d);\n",sig);
  1308. X}    /* end of DCE_abort */
  1309. X
  1310. X/*+-------------------------------------------------------------------------
  1311. X    DCE_exit(exitcode) - "last chance for gas" in this incarnation
  1312. X
  1313. XThe independent portion of the dialer program calls this routine in
  1314. Xlieu of exit() in every case except one (see DCE_argv_hook() below).
  1315. XNormally, this function just passes it's argument to exit(), but
  1316. Xany necessary post-processing can be done.  The function must,
  1317. Xhowever, eventually call exit(exitcode);
  1318. X--------------------------------------------------------------------------*/
  1319. Xvoid
  1320. XDCE_exit(exitcode)
  1321. Xint exitcode;
  1322. X{
  1323. X    DEBUG(10,"DCE_exit(%d);\n",exitcode);
  1324. X    exit(exitcode);
  1325. X}    /* end of DCE_exit */
  1326. X
  1327. X/*+-------------------------------------------------------------------------
  1328. X    DCE_argv_hook(argc,argv,optind,unrecognized_switches)
  1329. X
  1330. XThis hook gives DCE-specific code a chance to look over the entire
  1331. Xcommand line, such as for -z Telebit processing.
  1332. X
  1333. Xargc andf argv are the same values passed to main(),
  1334. X
  1335. Xoptind is the value of optind at the end of normal getopt processing.
  1336. X
  1337. Xunrecognized_switches is the count of switches not handled by main().
  1338. XSpecifically, -h and -x are standard switches.
  1339. X
  1340. XNormally, this function should just return RC_FAIL|RCE_ARGS if there are
  1341. Xany unrecognized switches, otherwise zero.  If you keep your nose clean
  1342. Xthough, you can do anything you need to do here and exit the program.
  1343. X
  1344. XNote: only simple switches (with no argument) may be used with this
  1345. Xfacility if the functrion is to return,' since main()'s getopt() will
  1346. Xstop processing switches if it runs into an unrecognized switch with an
  1347. Xargument.
  1348. X
  1349. XIf the function returns a non-zero value, then the value will be passed
  1350. XDIRECTLY to exit() with no further ado.  Thus, a non-zero value must be
  1351. Xof the format expected by dialer program callers, with RC_FAIL set as a
  1352. Xminimum.
  1353. X--------------------------------------------------------------------------*/
  1354. Xint
  1355. XDCE_argv_hook(argc,argv,optind,unrecognized_switches)
  1356. Xint argc;
  1357. Xchar **argv;
  1358. Xint optind;
  1359. Xint unrecognized_switches;
  1360. X{
  1361. X    if(unrecognized_switches)
  1362. X        return(RC_FAIL | RCE_ARGS);
  1363. X    return(0);
  1364. X}    /* end of DCE_argv_hook */
  1365. X
  1366. X/* vi: set tabstop=4 shiftwidth=4: */
  1367. SHAR_EOF
  1368. $TOUCH -am 1226045590 'gendial/dceTBPlus.c' &&
  1369. chmod 0644 gendial/dceTBPlus.c ||
  1370. echo 'restore of gendial/dceTBPlus.c failed'
  1371. Wc_c="`wc -c < 'gendial/dceTBPlus.c'`"
  1372. test 17853 -eq "$Wc_c" ||
  1373.     echo 'gendial/dceTBPlus.c: original size 17853, current size' "$Wc_c"
  1374. true || echo 'restore of gendial/dceT1000.c failed'
  1375. echo End of part 26, continue with part 27
  1376. exit 0
  1377. --------------------------------------------------------------------
  1378. Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  1379. Hacker Extraordinaire  d' async PADs,  pods,  proteins and protocols
  1380.  
  1381. exit 0 # Just in case...
  1382. -- 
  1383. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1384. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1385. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1386. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1387.