home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume42 / ecu / part27 < prev    next >
Encoding:
Internet Message Format  |  1994-05-24  |  64.5 KB

  1. From: wht@n4hgf.atl.ga.us (Warren Tucker)
  2. Newsgroups: comp.sources.misc
  3. Subject: v42i125:  ecu - ECU Asynchronous Communications v3.30, Part27/37
  4. Date: 24 May 1994 09:07:51 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2rt1nn$d5r@sparky.sterling.com>
  9. X-Md4-Signature: db720bf5d44a3f93ac1d98193e18e0fc
  10.  
  11. Submitted-by: wht@n4hgf.atl.ga.us (Warren Tucker)
  12. Posting-number: Volume 42, Issue 125
  13. Archive-name: ecu/part27
  14. Environment: SCO,SCOXENIX,MOTOROLA,HP-UX,LINUX,NetBSD,SUNOS,SYSVR4,SOLARIS2
  15. Supersedes: ecu: Volume 32, Issue 36-75
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  ecu330/ecuchdir.c ecu330/ecuwinutil.c ecu330/fasi/Space.c
  22. #   ecu330/gendial/dceUSR24v.c ecu330/regexp.c
  23. # Wrapped by kent@sparky on Mon May 23 13:41:01 1994
  24. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  25. echo If this archive is complete, you will see the following message:
  26. echo '          "shar: End of archive 27 (of 37)."'
  27. if test -f 'ecu330/ecuchdir.c' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'ecu330/ecuchdir.c'\"
  29. else
  30.   echo shar: Extracting \"'ecu330/ecuchdir.c'\" \(13231 characters\)
  31.   sed "s/^X//" >'ecu330/ecuchdir.c' <<'END_OF_FILE'
  32. X/*+-------------------------------------------------------------------------
  33. X    ecuchdir.c - ECU change directory command/history
  34. X    wht@n4hgf.atl.ga.us
  35. X
  36. X  Defined functions:
  37. X    cd_array_delete(arg,narg)
  38. X    cd_array_delete_usage()
  39. X    cd_array_init()
  40. X    cd_array_read()
  41. X    cd_array_save()
  42. X    change_directory(dirname,arg_present_flag)
  43. X    expand_dirname(dirname,maxlen)
  44. X    pop_directory(arg,arg_present,pcmd)
  45. X    push_directory(dirname,arg_present,pcmd)
  46. X
  47. X  Paraphrase: "It just goes to show you: no matter where you find
  48. X  yourself -- there you are!" -- Pogo
  49. X
  50. X--------------------------------------------------------------------------*/
  51. X/*+:EDITS:*/
  52. X/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
  53. X/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
  54. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  55. X/*:09-25-1991-18:24-wht@n4hgf2-fix seg viol in popd w/o argument on Sun */
  56. X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
  57. X/*:07-14-1991-18:18-wht@n4hgf-new ttygets functions */
  58. X/*:05-21-1991-18:53-wht@n4hgf-add push_directory and pop_directory */
  59. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  60. X
  61. X#include "ecu.h"
  62. X#include "ecukey.h"
  63. X#include "ecutty.h"
  64. X#include "termecu.h"
  65. X
  66. Xint push_directory();
  67. X
  68. X#define CD_PATHLEN    256
  69. X
  70. X#define CD_QUAN        44
  71. Xchar *cd_array[CD_QUAN];
  72. Xuint cd_in_use = 0;
  73. X
  74. X#define DIR_PUSH_MAX    10
  75. Xchar *dir_push_stack[DIR_PUSH_MAX];
  76. Xuint dir_push_level = 0;
  77. X
  78. Xextern char curr_dir[CURR_DIRSIZ];    /* current working directory */
  79. Xextern int proc_trace;
  80. Xextern char errmsg[];
  81. Xextern int errno;
  82. X
  83. X/*+-------------------------------------------------------------------------
  84. X    cd_array_read() - read ~/.ecu/dir
  85. X--------------------------------------------------------------------------*/
  86. Xvoid
  87. Xcd_array_read()
  88. X{
  89. X    char dirpath[CD_PATHLEN];
  90. X    FILE *fpcd;
  91. X    FILE *fopen();
  92. X    register char *cptr;
  93. X    char *skip_ld_break();
  94. X
  95. X    get_home_dir(dirpath);
  96. X    strcat(dirpath, "/.ecu/dir");
  97. X    if ((fpcd = fopen(dirpath, "r")) == (FILE *) 0)
  98. X        return;                 /* none found */
  99. X
  100. X    for (cd_in_use = 0; cd_in_use < CD_QUAN; cd_in_use++)
  101. X    {
  102. X        if (fgets(dirpath, sizeof(dirpath), fpcd) == (char *)0)
  103. X            break;
  104. X        dirpath[strlen(dirpath) - 1] = 0;
  105. X        cptr = skip_ld_break(dirpath);
  106. X        if (strlen(cptr) == 0)
  107. X        {
  108. X            --cd_in_use;
  109. X            continue;
  110. X        }
  111. X        strcpy(cd_array[cd_in_use], cptr);
  112. X    }
  113. X    fclose(fpcd);
  114. X}                             /* end of cd_array_read */
  115. X
  116. X/*+-------------------------------------------------------------------------
  117. X    cd_array_save() - save ~/.ecu/dir
  118. X--------------------------------------------------------------------------*/
  119. Xvoid
  120. Xcd_array_save()
  121. X{
  122. X    register icd;
  123. X    char savepath[256];
  124. X    FILE *fpcd;
  125. X    FILE *fopen();
  126. X
  127. X    get_home_dir(savepath);
  128. X    strcat(savepath, "/.ecu/dir");
  129. X
  130. X    if (cd_in_use == 0)
  131. X    {
  132. X        ff(se, "No directory list to save in %s\r\n", savepath);
  133. X        return;
  134. X    }
  135. X    if ((fpcd = fopen(savepath, "w")) == (FILE *) 0)
  136. X    {
  137. X        ff(se, "%s could not be opened\r\n", savepath);
  138. X        return;
  139. X    }
  140. X
  141. X    for (icd = 0; icd < cd_in_use; icd++)
  142. X        fprintf(fpcd, "%s\n", cd_array[icd]);
  143. X    fclose(fpcd);
  144. X    ff(se, "%d entries saved in %s\r\n", cd_in_use, savepath);
  145. X
  146. X}                             /* end of cd_array_save */
  147. X
  148. X/*+-------------------------------------------------------------------------
  149. X    cd_array_delete_usage()
  150. X--------------------------------------------------------------------------*/
  151. Xvoid
  152. Xcd_array_delete_usage()
  153. X{
  154. X    ff(se, "usage: d[elete] <1st> [<last>]\r\n");
  155. X}                             /* end of cd_array_delete_usage */
  156. X
  157. X/*+-------------------------------------------------------------------------
  158. X    cd_array_delete(arg,narg)
  159. X--------------------------------------------------------------------------*/
  160. Xcd_array_delete(arg, narg)
  161. Xchar **arg;
  162. Xint narg;
  163. X{
  164. X    uint first;                 /* 1st to delete */
  165. X    uint last;                 /* last to delete */
  166. X
  167. X    if ((narg < 2) || (narg > 3))
  168. X    {
  169. X        cd_array_delete_usage();
  170. X        return (-1);
  171. X    }
  172. X
  173. X    first = atoi(arg[1]) - 1;
  174. X    if (narg == 2)
  175. X        last = first;
  176. X    else
  177. X        last = atoi(arg[2]) - 1;
  178. X
  179. X    if ((first > (cd_in_use - 1)) || (last > (cd_in_use - 1)) || (last < first))
  180. X    {
  181. X        cd_array_delete_usage();
  182. X        return (-1);
  183. X    }
  184. X
  185. X    if (last == (cd_in_use - 1))
  186. X    {
  187. X        cd_in_use = first;
  188. X    }
  189. X    else
  190. X    {
  191. X        int count_less = last - first + 1;
  192. X
  193. X        last++;
  194. X        while (last != cd_in_use)
  195. X            strcpy(cd_array[first++], cd_array[last++]);
  196. X        cd_in_use -= count_less;
  197. X    }
  198. X    return (0);
  199. X}                             /* end of cd_array_delete */
  200. X
  201. X/*+-------------------------------------------------------------------------
  202. X    cd_array_init()
  203. X--------------------------------------------------------------------------*/
  204. Xvoid
  205. Xcd_array_init()
  206. X{
  207. X    register itmp;
  208. X
  209. X/*allocate change_directory stack */
  210. X    for (itmp = 0; itmp < CD_QUAN; itmp++)
  211. X    {
  212. X        if (!(cd_array[itmp] = malloc(CD_PATHLEN + 1)))
  213. X        {
  214. X            ff(se, "Not enough memory for cd stack\r\n");
  215. X            termecu(TERMECU_MALLOC);
  216. X        }
  217. X        *cd_array[itmp] = 0;
  218. X    }
  219. X    (void)cd_array_read();
  220. X}                             /* end of cd_array_init */
  221. X
  222. X/*+-------------------------------------------------------------------------
  223. X    expand_dirname(dirname,maxlen) - convert dirname with shell chars
  224. X--------------------------------------------------------------------------*/
  225. Xexpand_dirname(dirname, maxlen)
  226. Xchar *dirname;
  227. Xint maxlen;
  228. X{
  229. X    char s256[256];
  230. X    char *expcmd;
  231. X
  232. X    if (!find_shell_chars(dirname))
  233. X        return (0);
  234. X
  235. X    sprintf(s256, "`ls -d %s`", dirname);
  236. X    if (expand_wildcard_list(s256, &expcmd))
  237. X    {
  238. X        strcpy(errmsg, "No such directory");
  239. X        return (-1);
  240. X    }
  241. X    strncpy(dirname, expcmd, maxlen);
  242. X    dirname[maxlen - 1] = 0;
  243. X    free(expcmd);
  244. X    if (strchr(dirname, ' '))
  245. X    {
  246. X        strcpy(errmsg, "Too many files");
  247. X        return (-1);
  248. X    }
  249. X    return (0);
  250. X
  251. X}                             /* end of expand_dirname */
  252. X
  253. X/*+-------------------------------------------------------------------------
  254. X    change_directory(dirname,arg_present_flag) - 'cd' interactive cmd hdlr
  255. X
  256. X  Change directory to 'dirname' if arg_present_flag is true,
  257. X  else if flag 0, ask for new directory name and change to it
  258. X  This procedure maintains the global variable 'curr_dir' that
  259. X  reflects the ecu transmitter process current working directory.
  260. X--------------------------------------------------------------------------*/
  261. Xint
  262. Xchange_directory(dirname, arg_present_flag)
  263. Xchar *dirname;
  264. Xint arg_present_flag;
  265. X{
  266. X    register icd;
  267. X    register itmp;
  268. X    char s256[256];
  269. X    uchar delim;
  270. X
  271. X#define BLD_ARG_MAX    5
  272. X    char *arg[BLD_ARG_MAX];
  273. X    int narg;
  274. X    int longest;
  275. X    int pushing = 0;
  276. X
  277. X    if (cd_in_use == 0)
  278. X        cd_array_read();
  279. X
  280. X    fputs("  ", se);
  281. X
  282. X    if (arg_present_flag)     /* if there is an argument ... */
  283. X    {
  284. X        if (isdigit(*dirname))    /* ... and first char is digit */
  285. X        {
  286. X            icd = atoi(dirname) - 1;
  287. X            if ((icd < 0) || (icd >= cd_in_use))
  288. X                goto DISPLAY_CD_ARRAY;
  289. X            strncpy(s256, cd_array[icd], sizeof(s256) - 1);
  290. X        }
  291. X        else
  292. X            strncpy(s256, dirname, sizeof(s256) - 1);    /* literal dir spec */
  293. X
  294. X        s256[sizeof(s256) - 1] = 0;
  295. X    }
  296. X    else
  297. X        /* no arg to cd command */
  298. X    {
  299. X      DISPLAY_CD_ARRAY:
  300. X        fputs("\r\n", se);
  301. X        longest = 0;
  302. X        for (icd = 0; icd < CD_QUAN / 2; icd++)
  303. X        {
  304. X            if (icd >= cd_in_use)
  305. X                break;
  306. X            if (longest < (itmp = strlen(cd_array[icd])))
  307. X                longest = itmp;
  308. X        }
  309. X        longest += 4;
  310. X        if (longest < 36)
  311. X            longest += 4;
  312. X        for (icd = 0; icd < CD_QUAN / 2; icd++)
  313. X        {
  314. X            if (icd >= cd_in_use)
  315. X                break;
  316. X            sprintf(s256, "%2d %s ", icd + 1, cd_array[icd]);
  317. X            fputs(s256, se);
  318. X            if (icd + CD_QUAN / 2 >= cd_in_use)
  319. X                fputs("\r\n", se);
  320. X            else
  321. X            {
  322. X                itmp = longest - strlen(s256);
  323. X                while (itmp-- > 0)
  324. X                    fputc(' ', se);
  325. X                sprintf(s256, "%2d %s\r\n",
  326. X                    icd + 1 + CD_QUAN / 2, cd_array[icd + CD_QUAN / 2]);
  327. X                fputs(s256, se);
  328. X
  329. X            }
  330. X        }
  331. X        fputs("current dir: ", se);
  332. X        tcap_stand_out();
  333. X        ff(se, " %s ", curr_dir);
  334. X        tcap_stand_end();
  335. X        tcap_eeol();
  336. X        fputs("\r\n", se);
  337. X
  338. X      GET_NEW_DIR:
  339. X        fputs(
  340. X            "New dir, <#>, %save, %read, %del, %xmitcd, %pushd, <enter>:  ", se);
  341. X        ttygets(s256, sizeof(s256), TG_CRLF, &delim, (int *)0);
  342. X
  343. X      TRY_AGAIN:
  344. X        if ((delim == ESC) || !strlen(s256))
  345. X        {
  346. X            ff(se, "no directory change\r\n");
  347. X            return (0);
  348. X        }
  349. X        else if (s256[0] == '%')
  350. X        {
  351. X            if (pushing)
  352. X            {
  353. X                ff(se, "syntax error\r\n");
  354. X                return (-1);
  355. X            }
  356. X            build_str_array(s256, arg, BLD_ARG_MAX, &narg);
  357. X
  358. X            if (minunique("save", &s256[1], 1))
  359. X            {
  360. X                cd_array_save();
  361. X                goto GET_NEW_DIR;
  362. X            }
  363. X            else if (minunique("read", &s256[1], 1))
  364. X            {
  365. X                cd_array_read();
  366. X                goto DISPLAY_CD_ARRAY;
  367. X            }
  368. X            else if (minunique("delete", &s256[1], 1))
  369. X            {
  370. X                if (cd_array_delete(arg, narg))
  371. X                    goto GET_NEW_DIR;
  372. X                else
  373. X                    goto DISPLAY_CD_ARRAY;
  374. X            }
  375. X            else if (minunique("xmitcd", &s256[1], 1))
  376. X            {
  377. X                lputs("cd ");
  378. X                lputs(curr_dir);
  379. X                lputc('\r');
  380. X                return (0);
  381. X            }
  382. X            else if (minunique("pushd", &s256[1], 1))
  383. X            {
  384. X                strcpy(s256, arg[1]);
  385. X                pushing = 1;
  386. X                goto TRY_AGAIN;
  387. X            }
  388. X            else
  389. X            {
  390. X                ff(se, "Invalid cd subcommand\r\n");
  391. X                goto GET_NEW_DIR;
  392. X            }
  393. X        }
  394. X        else if (icd = atoi(s256))
  395. X        {
  396. X            icd--;
  397. X            if (icd >= cd_in_use)
  398. X                goto GET_NEW_DIR;
  399. X            strncpy(s256, cd_array[icd], sizeof(s256) - 1);
  400. X            s256[sizeof(s256) - 1] = 0;
  401. X        }
  402. X    }
  403. X    if (pushing)
  404. X    {
  405. X        if (push_directory(s256, 1, 1))
  406. X            return (-1);
  407. X    }
  408. X    else
  409. X    {
  410. X        if (expand_dirname(s256, sizeof(s256)))
  411. X        {
  412. X            ff(se, "%s\r\n", errmsg);
  413. X            return (-1);
  414. X        }
  415. X        if (chdir(s256) < 0) /* now change to the new directory */
  416. X        {
  417. X            perror(s256);     /* print error if we get one */
  418. X            ff(se, "\r\n");
  419. X            return (-1);
  420. X        }
  421. X        get_curr_dir(curr_dir, sizeof(curr_dir));
  422. X        fputs("confirmed: ", se);
  423. X        tcap_stand_out();
  424. X        ff(se, " %s ", curr_dir);
  425. X        tcap_stand_end();
  426. X        fputs("\r\n", se);
  427. X    }
  428. X
  429. X    for (icd = 0; icd < cd_in_use; icd++)
  430. X    {
  431. X        if (strcmp(curr_dir, cd_array[icd]) == 0)
  432. X            return (0);
  433. X    }
  434. X    if (cd_in_use == CD_QUAN)
  435. X    {
  436. X        for (icd = 1; icd < CD_QUAN; icd++)
  437. X        {
  438. X            strcpy(cd_array[icd - 1], cd_array[icd]);
  439. X        }
  440. X        strcpy(cd_array[CD_QUAN - 1], curr_dir);
  441. X    }
  442. X    else
  443. X        strcpy(cd_array[cd_in_use++], curr_dir);
  444. X
  445. X    return (0);
  446. X
  447. X}                             /* end of change_directory */
  448. X
  449. X/*+-------------------------------------------------------------------------
  450. X    push_directory(dirname,arg_present,pcmd) - 'pushd' function
  451. X
  452. XThis function performs 'pushd' actions for both the interactive
  453. Xand procedure 'pushd' commands
  454. X
  455. Xdirname is new directory name if arg_present true
  456. Xpcmd true if procedure command or cd %p interactive, else interactive command
  457. X
  458. Xreturns -1 if error, else 0
  459. X--------------------------------------------------------------------------*/
  460. Xint
  461. Xpush_directory(dirname, arg_present, pcmd)
  462. Xchar *dirname;
  463. Xint arg_present;
  464. Xint pcmd;
  465. X{
  466. X    register itmp;
  467. X    char s256[256];
  468. X
  469. X    if (!pcmd)
  470. X        ff(se, "\r\n");
  471. X
  472. X    if (!arg_present)
  473. X    {
  474. X        if (!dir_push_level)
  475. X        {
  476. X            if (!pcmd || proc_trace)
  477. X                pprintf("---: no directories pushed\n");
  478. X        }
  479. X        else
  480. X        {
  481. X            for (itmp = 0; itmp < dir_push_level; itmp++)
  482. X                pprintf("%3d: %s\n", itmp, dir_push_stack[itmp]);
  483. X        }
  484. X        pprintf("cwd: %s\n", curr_dir);
  485. X        return (0);
  486. X    }
  487. X
  488. X    if (dir_push_level == DIR_PUSH_MAX)
  489. X    {
  490. X        pputs("too many pushds\n");
  491. X        return (-1);
  492. X    }
  493. X
  494. X    if (!dir_push_stack[dir_push_level])
  495. X    {
  496. X        if (!(dir_push_stack[dir_push_level] = malloc(CD_PATHLEN)))
  497. X        {
  498. X            pputs("no memory for pushd\n");
  499. X            return (-1);
  500. X        }
  501. X    }
  502. X
  503. X    get_curr_dir(dir_push_stack[dir_push_level], CD_PATHLEN);
  504. X
  505. X    strncpy(s256, dirname, sizeof(s256) - 1);
  506. X    s256[sizeof(s256) - 1] = 0;
  507. X    if (expand_dirname(s256, sizeof(s256)))
  508. X    {
  509. X        pprintf("'%s': %s\n", s256, errmsg);
  510. X        return (-1);
  511. X    }
  512. X    if (chdir(s256) < 0)     /* now change to the new directory */
  513. X    {
  514. X        pperror(s256);         /* print error if we get one */
  515. X        return (-1);
  516. X    }
  517. X    get_curr_dir(curr_dir, sizeof(curr_dir));
  518. X
  519. X    if (pcmd && proc_trace)
  520. X        pprintf("pushed to directory %s\n", curr_dir);
  521. X    else
  522. X    {
  523. X        fputs("confirmed: ", se);
  524. X        tcap_stand_out();
  525. X        ff(se, " %s ", curr_dir);
  526. X        tcap_stand_end();
  527. X        ff(se, " (level %d)\r\n", dir_push_level);
  528. X    }
  529. X
  530. X    dir_push_level++;
  531. X    return (0);
  532. X
  533. X}                             /* end of push_directory */
  534. X
  535. X/*+-------------------------------------------------------------------------
  536. X    pop_directory(arg,arg_present,pcmd) - 'popd' function
  537. X
  538. XThis function performs 'popd' actions for both the interactive
  539. Xand procedure 'popd' commands
  540. X
  541. Xarg is empty if arg_present false
  542. Xif not empty, it is == 'all' or a numeric level to pop to
  543. Xpcmd true if procedure command, else interactive command
  544. X
  545. Xreturns -1 if error, else 0
  546. X--------------------------------------------------------------------------*/
  547. Xint
  548. Xpop_directory(arg, arg_present, pcmd)
  549. Xchar *arg;
  550. Xint arg_present;
  551. Xint pcmd;
  552. X{
  553. X    int new_level = -1;
  554. X
  555. X    if (!pcmd)
  556. X        pputs("\n");
  557. X
  558. X    if (!dir_push_level)
  559. X    {
  560. X        if (!pcmd || proc_trace)
  561. X        {
  562. X            pprintf("---: no directories pushed\n");
  563. X            pprintf("cwd: %s\n", curr_dir);
  564. X        }
  565. X        return (-1);
  566. X    }
  567. X
  568. X    if (!arg_present)
  569. X        new_level = dir_push_level - 1;
  570. X    else if (minunique("all", arg, 1))
  571. X        new_level = 0;
  572. X    else if (isdigit(*arg))
  573. X        new_level = atoi(arg);
  574. X    else
  575. X    {
  576. X        pprintf("argument error: '%s'\n", arg);
  577. X        return (-1);
  578. X    }
  579. X
  580. X    if ((new_level < 0) || (new_level > (dir_push_level - 1)))
  581. X    {
  582. X        pprintf("invalid popd argument (or not pushed to level): '%s'\n", arg);
  583. X        return (-1);
  584. X    }
  585. X
  586. X    dir_push_level = new_level;
  587. X    if (chdir(dir_push_stack[dir_push_level]) < 0)
  588. X    {
  589. X        pperror(dir_push_stack[dir_push_level]);
  590. X        return (-1);
  591. X    }
  592. X    get_curr_dir(curr_dir, sizeof(curr_dir));
  593. X
  594. X    if (pcmd && proc_trace)
  595. X        pprintf("popped to directory %s (level %d)\n", curr_dir, dir_push_level);
  596. X    else
  597. X    {
  598. X        fputs("confirmed: ", se);
  599. X        tcap_stand_out();
  600. X        ff(se, " %s ", curr_dir);
  601. X        tcap_stand_end();
  602. X        ff(se, " (level %d)\r\n", dir_push_level);
  603. X    }
  604. X
  605. X    return (0);
  606. X
  607. X}                             /* end of pop_directory */
  608. X
  609. X/* end of ecuchdir.c */
  610. X/* vi: set tabstop=4 shiftwidth=4: */
  611. END_OF_FILE
  612.   if test 13231 -ne `wc -c <'ecu330/ecuchdir.c'`; then
  613.     echo shar: \"'ecu330/ecuchdir.c'\" unpacked with wrong size!
  614.   fi
  615.   # end of 'ecu330/ecuchdir.c'
  616. fi
  617. if test -f 'ecu330/ecuwinutil.c' -a "${1}" != "-c" ; then 
  618.   echo shar: Will not clobber existing file \"'ecu330/ecuwinutil.c'\"
  619. else
  620.   echo shar: Extracting \"'ecu330/ecuwinutil.c'\" \(12629 characters\)
  621.   sed "s/^X//" >'ecu330/ecuwinutil.c' <<'END_OF_FILE'
  622. X/*+-------------------------------------------------------------------------
  623. X    ecuwinutil.c - curses window utilities
  624. X    wht@n4hgf.atl.ga.us
  625. X
  626. X  Defined functions:
  627. X    clear_area(win,y,x,len)
  628. X    clear_area_char(win,y,x,len,fillchar)
  629. X    winbox(win)
  630. X    window_create(title,title_x,tly,tlx,lines,cols)
  631. X    window_setup(win,title,title_x)
  632. X    windows_end(botleft_flag)
  633. X    windows_end_signal()
  634. X    windows_start()
  635. X    winget_single(win,nondelim_list,delim_list)
  636. X    wingets(win,y,x,buf,bufsize,delim,edit,pwgpos)
  637. X
  638. X  It's hard to get ivory in Africa, but in Alabama the
  639. X  Tuscaloosa.  -- Groucho
  640. X
  641. X--------------------------------------------------------------------------*/
  642. X/*+:EDITS:*/
  643. X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  644. X/*:11-12-1993-11:00-wht@n4hgf-Linux changes by bob@vancouver.zadall.com */
  645. X/*:09-15-1993-11:31-wht@n4hgf-endwin on non-SCO per bob@vancouver.zadall.com */
  646. X/*:08-17-1993-14:04-wht@n4hgf-add OLD_WINGETS for compatibility */
  647. X/*:08-13-1993-04:04-wht@n4hgf-add highlight_delete function to wingets */
  648. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  649. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  650. X/*:02-09-1992-16:08-root@n4hgf-ruling characters only on  SCO (tcap curses) */
  651. X/*:08-25-1991-14:39-wht@n4hgf-SVR4 port thanks to aega84!lh */
  652. X/*:08-01-1991-03:52-wht@n4hgf-when editing string, set cursor to end */
  653. X/*:07-25-1991-12:57-wht@n4hgf-ECU release 3.10 */
  654. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  655. X
  656. X#include "ecucurses.h"
  657. X#include <errno.h>
  658. X#include <ctype.h>
  659. X#include "ecukey.h"
  660. X#include "ecuxkey.h"
  661. X#include "termecu.h"
  662. X#include "pc_scr.h"
  663. X
  664. X#if !defined(ushort)
  665. X#define ushort unsigned short
  666. X#endif
  667. X#if !defined(uchar)
  668. X#define uchar unsigned char
  669. X#endif
  670. X#if !defined(uint)
  671. X#define uint unsigned int
  672. X#endif
  673. X#if !defined(ulong)
  674. X#define ulong unsigned long
  675. X#endif
  676. X
  677. Xextern int tty_is_multiscreen;
  678. X
  679. X#ifdef M_SYSV
  680. Xunsigned char sTL = at_TL;
  681. Xunsigned char sTR = at_TR;
  682. Xunsigned char sBL = at_BL;
  683. Xunsigned char sBR = at_BR;
  684. Xunsigned char sLT = at_LT;
  685. Xunsigned char sRT = at_RT;
  686. Xunsigned char sVR = at_VR;
  687. Xunsigned char sHR = at_HR;
  688. X
  689. X#else
  690. X#ifdef LINUX
  691. Xchtype sTL = vanilla_TL;
  692. Xchtype sTR = vanilla_TR;
  693. Xchtype sBL = vanilla_BL;
  694. Xchtype sBR = vanilla_BR;
  695. Xchtype sLT = vanilla_LT;
  696. Xchtype sRT = vanilla_RT;
  697. Xchtype sVR = vanilla_VR;
  698. Xchtype sHR = vanilla_HR;
  699. X
  700. X#else
  701. Xunsigned char sTL = vanilla_TL;
  702. Xunsigned char sTR = vanilla_TR;
  703. Xunsigned char sBL = vanilla_BL;
  704. Xunsigned char sBR = vanilla_BR;
  705. Xunsigned char sLT = vanilla_LT;
  706. Xunsigned char sRT = vanilla_RT;
  707. Xunsigned char sVR = vanilla_VR;
  708. Xunsigned char sHR = vanilla_HR;
  709. X
  710. X#endif
  711. X#endif
  712. X
  713. Xint windows_active = 0;
  714. X
  715. Xint ttymode_before_window_start;
  716. X
  717. X/*+-------------------------------------------------------------------------
  718. X    clear_area_char(win,y,x,len,fillchar)
  719. X--------------------------------------------------------------------------*/
  720. Xvoid
  721. Xclear_area_char(win, y, x, len, fillchar)
  722. XWINDOW *win;
  723. Xint y;
  724. Xint x;
  725. Xint len;
  726. Xchar fillchar;
  727. X{
  728. X    wmove(win, y, x);
  729. X    while (len-- > 0)
  730. X        waddch(win, fillchar & 0xFF);
  731. X    wmove(win, y, x);
  732. X
  733. X}                             /* end of clear_area_char */
  734. X
  735. X/*+-------------------------------------------------------------------------
  736. X    clear_area(win,y,x,len)
  737. X--------------------------------------------------------------------------*/
  738. Xvoid
  739. Xclear_area(win, y, x, len)
  740. XWINDOW *win;
  741. Xint y;
  742. Xint x;
  743. Xint len;
  744. X{
  745. X    clear_area_char(win, y, x, len, ' ');
  746. X}                             /* end of clear_area_char */
  747. X
  748. X/*+-------------------------------------------------------------------------
  749. X    windows_start()
  750. X--------------------------------------------------------------------------*/
  751. Xvoid
  752. Xwindows_start()
  753. X{
  754. X    extern int tty_not_char_special;
  755. X    static int initscr_already_performed = 0;
  756. X
  757. X    if (tty_not_char_special)
  758. X    {
  759. X        errno = ENOTTY;
  760. X        fprintf(stderr, "curses features unavailable when stdin not tty\r\n");
  761. X        termecu(TERMECU_CURSES_ERROR);
  762. X    }
  763. X
  764. X    ttymode_before_window_start = get_ttymode();
  765. X    ttymode(0);
  766. X    if (!initscr_already_performed && !initscr())
  767. X    {
  768. X        fprintf(stderr, "curses init failure ... check terminal type\r\n");
  769. X        termecu(TERMECU_CURSES_ERROR);
  770. X    }
  771. X    initscr_already_performed = 1;
  772. X    scrollok(stdscr, 0);
  773. X    savetty();
  774. X    raw();
  775. X    noecho();
  776. X    nonl();
  777. X    clear();
  778. X#if defined(M_TERMINFO) && !defined(LINUX) && !defined(BSD)
  779. X    typeahead(-1);
  780. X#endif
  781. X    windows_active = 1;
  782. X
  783. X#if defined(M_SYSV)
  784. X    if (!tty_is_multiscreen)
  785. X    {
  786. X        sTL = vanilla_TL;
  787. X        sTR = vanilla_TR;
  788. X        sBL = vanilla_BL;
  789. X        sBR = vanilla_BR;
  790. X        sLT = vanilla_LT;
  791. X        sRT = vanilla_RT;
  792. X        sVR = vanilla_VR;
  793. X        sHR = vanilla_HR;
  794. X    }
  795. X#endif
  796. X
  797. X#if defined(LINUX)
  798. X    sTL = ACS_ULCORNER;
  799. X    sTR = ACS_URCORNER;
  800. X    sBL = ACS_LLCORNER;
  801. X    sBR = ACS_LRCORNER;
  802. X    sLT = ACS_LTEE;
  803. X    sRT = ACS_RTEE;
  804. X    sVR = ACS_VLINE;
  805. X    sHR = ACS_HLINE;
  806. X#endif
  807. X
  808. X    wclear(stdscr);
  809. X    touchwin(stdscr);
  810. X    wrefresh(stdscr);
  811. X
  812. X}                             /* end of windows_start */
  813. X
  814. X/*+-------------------------------------------------------------------------
  815. X    windows_end(botleft_flag)
  816. X--------------------------------------------------------------------------*/
  817. Xvoid
  818. Xwindows_end(botleft_flag)
  819. Xint botleft_flag;
  820. X{
  821. X    if (!windows_active)
  822. X        return;
  823. X#if !defined(M_UNIX) && !defined(M_XENIX)
  824. X    endwin();
  825. X#else
  826. X    refresh();
  827. X#endif
  828. X    if (botleft_flag)
  829. X        tcap_cursor(LINES - 1, 0);
  830. X    ttymode(ttymode_before_window_start);
  831. X    windows_active = 0;
  832. X}                             /* end of windows_end */
  833. X
  834. X/*+-------------------------------------------------------------------------
  835. X    windows_end_signal() -- called by termecu()
  836. X--------------------------------------------------------------------------*/
  837. Xvoid
  838. Xwindows_end_signal()
  839. X{
  840. X    windows_end(0);
  841. X}                             /* end of windows_end_signal */
  842. X
  843. X/*+-------------------------------------------------------------------------
  844. X    winbox(win)
  845. X--------------------------------------------------------------------------*/
  846. Xvoid
  847. Xwinbox(win)
  848. XWINDOW *win;
  849. X{
  850. X
  851. X#if defined(SVR4)
  852. X    box(win, (unsigned long)sVR, (unsigned long)sHR);
  853. X#else
  854. X    box(win, sVR, sHR);
  855. X#if !defined(LINUX)
  856. X    wmove(win, 0, 0);
  857. X    waddch(win, (unsigned)sTL);
  858. X    wmove(win, win->_maxy - 1, 0);
  859. X    waddch(win, (unsigned)sBL);
  860. X    wmove(win, win->_maxy - 1, win->_maxx - 1);
  861. X    waddch(win, (unsigned)sBR);
  862. X    wmove(win, 0, win->_maxx - 1);
  863. X    waddch(win, (unsigned)sTR);
  864. X#endif
  865. X#endif
  866. X
  867. X}                             /* end of winbox */
  868. X
  869. X/*+-------------------------------------------------------------------------
  870. X    window_setup(win,title,title_x)
  871. X--------------------------------------------------------------------------*/
  872. Xvoid
  873. Xwindow_setup(win, title, title_x)
  874. XWINDOW *win;
  875. Xchar *title;
  876. Xint title_x;
  877. X{
  878. X    register stand = (title_x < 0);
  879. X
  880. X    if (stand)
  881. X        title_x = -title_x;
  882. X
  883. X    touchwin(win);
  884. X    scrollok(win, 0);         /* do not scroll */
  885. X    winbox(win);
  886. X    wmove(win, 0, title_x);
  887. X    if (stand)
  888. X        wstandout(win);
  889. X    waddch(win, '[');
  890. X    wprintw(win, " %s ", title);
  891. X    waddch(win, ']');
  892. X    if (stand)
  893. X        wstandend(win);
  894. X}                             /* end of window_setup */
  895. X
  896. X/*+-------------------------------------------------------------------------
  897. X    window_create(title,title_x,tly,tlx,lines,cols)
  898. Xif title_x negative, make title "stand" out
  899. X--------------------------------------------------------------------------*/
  900. XWINDOW *
  901. Xwindow_create(title, title_x, tly, tlx, lines, cols)
  902. Xchar *title;
  903. Xint title_x;
  904. Xint tly;
  905. Xint tlx;
  906. Xint lines;
  907. Xint cols;
  908. X{
  909. X    register WINDOW *nwin = newwin(lines, cols, tly, tlx);
  910. X
  911. X    if (nwin)
  912. X        window_setup(nwin, title, title_x);
  913. X    else
  914. X    {
  915. X        fprintf(stderr, "\r\ncurses error: cannot create new window\r\n");
  916. X        termecu(TERMECU_CURSES_ERROR);
  917. X    }
  918. X    return (nwin);
  919. X}                             /* end of window_create */
  920. X
  921. X/*+-------------------------------------------------------------------------
  922. X    wingets(win,y,x,buf,bufsize,delim,edit,pwgpos)
  923. X
  924. XThis procedure reads a string from win and returns the number
  925. Xof characters read.
  926. X
  927. XIf edit is non-zero and pwgpos is not null, the inital string
  928. Xposition is set by dereferencing the pointer.
  929. X
  930. XThe terminating delim is returned in 'delim'.
  931. X
  932. XIf pwgpos is not null, the ending string position is returned in
  933. Xthe integer pointed to.
  934. X
  935. X-1 is returned if an ESCape is typed by the keyboard user,
  936. Xotherwise the count of characters in the string.
  937. X
  938. XThe entire line must be contained on one line (no line wrap supported).
  939. X--------------------------------------------------------------------------*/
  940. Xint
  941. Xwingets(win, y, x, buf, bufsize, delim, edit, pwgpos)
  942. XWINDOW *win;
  943. Xint y;
  944. Xregister x;
  945. Xregister char *buf;
  946. Xint bufsize;                 /* includes room for null..field is 1 less */
  947. Xregister uchar *delim;
  948. Xint edit;
  949. Xint *pwgpos;
  950. X{
  951. X    register count = 0;
  952. X    register pos = 0;
  953. X    int insert_mode = 0;
  954. X
  955. X#ifndef OLD_WINGETS
  956. X    int highlight_delete = 0;
  957. X
  958. X#endif
  959. X    int rtn_val = 0;
  960. X
  961. X    bufsize--;
  962. X    if (edit && strlen(buf))
  963. X    {
  964. X#ifndef OLD_WINGETS
  965. X        highlight_delete = 1;
  966. X#endif
  967. X        clear_area_char(win, y, x, bufsize, ' ');
  968. X        wstandout(win);
  969. X        waddstr(win, buf);
  970. X        wstandend(win);
  971. X        count = pos = strlen(buf);
  972. X        if (pwgpos)
  973. X        {
  974. X            pos = *pwgpos;
  975. X            if ((pos < 0) || (pos > count))
  976. X                pos = count;
  977. X        }
  978. X    }
  979. X    else
  980. X    {
  981. X        clear_area_char(win, y, x, bufsize, '_');
  982. X        *buf = 0;
  983. X    }
  984. X
  985. X    wmove(win, y, x + pos);
  986. X
  987. X    while (1)
  988. X    {
  989. X        wrefresh(win);
  990. X        *delim = ttygetc(1);
  991. X        if ((*delim < 0x20) || (*delim >= 0x7F))
  992. X        {
  993. X#ifndef OLD_WINGETS
  994. X            if (highlight_delete)
  995. X            {
  996. X                clear_area_char(win, y, x, bufsize, '_');
  997. X                waddstr(win, buf);
  998. X                wmove(win, y, x + pos);
  999. X                highlight_delete = 0;
  1000. X            }
  1001. X#endif
  1002. X            switch (*delim)
  1003. X            {
  1004. X                case CRET:
  1005. X                    *delim = NL;
  1006. X                case NL:
  1007. X                    wrefresh(win);
  1008. X                    rtn_val = count;
  1009. X                    goto FUNC_RETURN;
  1010. X
  1011. X                case BS:
  1012. X                case DEL:
  1013. X                    if (count)
  1014. X                    {
  1015. X                        if (count == pos)
  1016. X                        {
  1017. X                            *(buf + --count) = 0;
  1018. X                            wmove(win, y, x + count);
  1019. X                            waddch(win, '_');
  1020. X                            wmove(win, y, x + count);
  1021. X                            pos--;
  1022. X                        }
  1023. X                        else
  1024. X                        {
  1025. X                            if (!pos)
  1026. X                                continue;
  1027. X                            mem_cpy(buf + pos - 1, buf + pos, count - pos);
  1028. X                            *(buf + --count) = 0;
  1029. X                            wmove(win, y, x + --pos);
  1030. X                            waddstr(win, buf + pos);
  1031. X                            waddch(win, '_');
  1032. X                            wmove(win, y, x + pos);
  1033. X                        }
  1034. X                    }
  1035. X                    continue;
  1036. X
  1037. X                case XFcurlf:
  1038. X                    if (pos)
  1039. X                        wmove(win, y, x + --pos);
  1040. X                    continue;
  1041. X
  1042. X                case XFcurrt:
  1043. X                    if (pos < count)
  1044. X                        wmove(win, y, x + ++pos);
  1045. X                    continue;
  1046. X
  1047. X                case XFins:
  1048. X                    insert_mode = !insert_mode;
  1049. X                    continue;
  1050. X
  1051. X                case ESC:
  1052. X                    rtn_val = -1;
  1053. X                    goto FUNC_RETURN;
  1054. X
  1055. X                case CTL_U:
  1056. X                    clear_area_char(win, y, x, bufsize, '_');
  1057. X                    count = 0;
  1058. X                    pos = 0;
  1059. X                    *buf = 0;
  1060. X                    continue;
  1061. X
  1062. X                default:
  1063. X                    *(buf + count) = 0;
  1064. X                    rtn_val = count;
  1065. X                    goto FUNC_RETURN;
  1066. X
  1067. X            }                 /* end of switch(*delim) */
  1068. X            /* NOTREACHED */
  1069. X        }                     /* end of if read delimiter */
  1070. X
  1071. X#ifndef OLD_WINGETS
  1072. X        if (highlight_delete)
  1073. X        {
  1074. X            clear_area_char(win, y, x, bufsize, '_');
  1075. X            count = 0;
  1076. X            pos = 0;
  1077. X            highlight_delete = 0;
  1078. X        }
  1079. X#endif
  1080. X
  1081. X        if (count == bufsize)
  1082. X        {
  1083. X            ring_bell();
  1084. X            continue;
  1085. X        }
  1086. X
  1087. X        if (insert_mode && (pos != count))
  1088. X        {
  1089. X            waddch(win, *delim);
  1090. X            waddstr(win, buf + pos);
  1091. X            mem_cpy(buf + pos + 1, buf + pos, count - pos);
  1092. X            *(buf + pos++) = *delim;
  1093. X            *(buf + ++count) = 0;
  1094. X            wmove(win, y, x + pos);
  1095. X        }
  1096. X        else
  1097. X        {
  1098. X            waddch(win, *delim);
  1099. X            *(buf + pos) = *delim;
  1100. X            if (pos == count)
  1101. X                *(buf + ++count) = 0;
  1102. X            pos++;
  1103. X        }
  1104. X    }                         /* end of while can get character */
  1105. X
  1106. X  FUNC_RETURN:
  1107. X    if (pwgpos)
  1108. X        *pwgpos = pos;
  1109. X    return (rtn_val);
  1110. X
  1111. X}                             /* end of wingets */
  1112. X
  1113. X/*+-------------------------------------------------------------------------
  1114. X    winget_single(win,nondelim_list,delim_list)
  1115. X
  1116. XThis procedure assumes cursor is positioned, repeats reading a non-echoing
  1117. Xcharacter from the keyboard until it matches a character in nondelim_list
  1118. Xor delim_list.  delim_list is expected to contain printable characters
  1119. Xand no upper-case characters.
  1120. X
  1121. XIf no match occurs, the bell is rung and the keyboard is read again.
  1122. X
  1123. XIf the input character matches a character in delim_list, the index (0-n)
  1124. Xof the character in delim_list is returned.  If a match occurs, an
  1125. Xupper-case version of the matching character is placed in the window.
  1126. X
  1127. XIf the input character matches a character in nondelim_list, the character
  1128. Xis returned or'ed with 0x1000
  1129. X
  1130. X--------------------------------------------------------------------------*/
  1131. Xint
  1132. Xwinget_single(win, nondelim_list, delim_list)
  1133. XWINDOW *win;
  1134. Xregister uchar *nondelim_list;
  1135. Xregister uchar *delim_list;
  1136. X{
  1137. X    register itmp;
  1138. X    register nlen = strlen(nondelim_list);
  1139. X    register dlen = strlen(delim_list);
  1140. X    register unsigned int ichar;
  1141. X
  1142. X    wrefresh(win);
  1143. X
  1144. X    while (1)
  1145. X    {
  1146. X        ichar = to_lower(ttygetc(1));
  1147. X        for (itmp = 0; itmp < nlen; itmp++)
  1148. X        {
  1149. X            if (ichar == nondelim_list[itmp])
  1150. X            {
  1151. X                if (isprint(ichar))
  1152. X                    waddch(win, to_upper(ichar));
  1153. X                wrefresh(win);
  1154. X                return (itmp);
  1155. X            }
  1156. X        }
  1157. X        for (itmp = 0; itmp < dlen; itmp++)
  1158. X        {
  1159. X            if (ichar == delim_list[itmp])
  1160. X                return (ichar | 0x1000);
  1161. X        }
  1162. X        ring_bell();
  1163. X    }
  1164. X
  1165. X}                             /* end of winget_single */
  1166. X
  1167. X/* end of ecuwinutil.c */
  1168. X/* vi: set tabstop=4 shiftwidth=4: */
  1169. END_OF_FILE
  1170.   if test 12629 -ne `wc -c <'ecu330/ecuwinutil.c'`; then
  1171.     echo shar: \"'ecu330/ecuwinutil.c'\" unpacked with wrong size!
  1172.   fi
  1173.   # end of 'ecu330/ecuwinutil.c'
  1174. fi
  1175. if test -f 'ecu330/fasi/Space.c' -a "${1}" != "-c" ; then 
  1176.   echo shar: Will not clobber existing file \"'ecu330/fasi/Space.c'\"
  1177. else
  1178.   echo shar: Extracting \"'ecu330/fasi/Space.c'\" \(8855 characters\)
  1179.   sed "s/^X//" >'ecu330/fasi/Space.c' <<'END_OF_FILE'
  1180. X/* Async device configuration file for the FAS async driver. */
  1181. X
  1182. X/*
  1183. X * COM1(STD) + COM2(DIGIBOARD PC-8)
  1184. X */
  1185. X/*+:EDITS:*/
  1186. X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  1187. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1188. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1189. X/*:07-25-1991-12:57-wht@n4hgf-ECU release 3.10 */
  1190. X/*:01-20-1991-16:17-wht@n4hgf-add fas_names */
  1191. X/*:01-20-1991-05:01-wht@n4hgf-changed buffer sizes */
  1192. X/*:01-16-1991-22:13-wht@n4hgf-creation */
  1193. X
  1194. X/* FAS was developed by ( ==> BUT DO NOT CONTACT HIM ABOUT THIS HACK )
  1195. XUwe Doering             INET : gemini@geminix.in-berlin.de
  1196. XBillstedter Pfad 17 b   UUCP : ...!unido!fub!geminix.in-berlin.de!gemini
  1197. X1000 Berlin 20
  1198. XGermany
  1199. X*/
  1200. X
  1201. X/* Alas, SCO idinstall has no -z (Define) option like ISC does */
  1202. X#if !defined(FASI)
  1203. X#define FASI
  1204. X#endif
  1205. X#if !defined(SCO)
  1206. X#define SCO
  1207. X#endif
  1208. X
  1209. X#if defined(FASI)
  1210. X/* {quan,irq,addr1-addr2,type} */
  1211. Xchar *fasi_space_ident =
  1212. X"FAS/i 2.08:{1,4,03f8-03ff,COM1},{8,3,0210-024f,DIGI-PC8}";
  1213. X
  1214. X#endif /* FASI */
  1215. X
  1216. X#if !defined (M_I286) && !defined(__STDC__) && !defined(__GNUC__)
  1217. X#ident    "@(#)space.c    2.08.0 COM1(STD) + COM2(DIGIBOARD PC-8)";
  1218. X#endif
  1219. X
  1220. X#include <sys/param.h>
  1221. X#include <sys/types.h>
  1222. X#include <sys/signal.h>
  1223. X#include <sys/buf.h>
  1224. X#include <sys/dir.h>
  1225. X#if defined (XENIX)
  1226. X#include <sys/page.h>
  1227. X#include <sys/seg.h>
  1228. X#endif
  1229. X#include <sys/user.h>
  1230. X#include <sys/errno.h>
  1231. X#include <sys/tty.h>
  1232. X#include <sys/conf.h>
  1233. X#include <sys/sysinfo.h>
  1234. X#include <sys/file.h>
  1235. X#if !defined (XENIX) && !defined(CBAUD)
  1236. X#include <sys/termio.h>
  1237. X#endif
  1238. X#include <sys/ioctl.h>
  1239. X#if !defined(FASI)
  1240. X#include <macros.h>
  1241. X#endif
  1242. X#if defined (HAVE_VPIX)
  1243. X#if !defined (XENIX)
  1244. X#include <sys/tss.h>
  1245. X#include <sys/immu.h>
  1246. X#include <sys/region.h>
  1247. X#endif
  1248. X#include <sys/proc.h>
  1249. X#include <sys/v86.h>
  1250. X#endif
  1251. X
  1252. X#if defined (XENIX)
  1253. X#include "fas.h"
  1254. X#include "digi-pc8.h"
  1255. X#else
  1256. X#include <local/fas.h>
  1257. X#include <local/digi-pc8.h>
  1258. X#endif
  1259. X
  1260. X/* This is the number of devices to be handled by this driver.
  1261. X   You may define up to 16 devices.  If this number is changed
  1262. X   the arrays below must be filled in accordingly.
  1263. X*/
  1264. X#define NUM_PHYSICAL_UNITS    9
  1265. X
  1266. X#if NUM_PHYSICAL_UNITS > MAX_UNITS
  1267. X#undef NUM_PHYSICAL_UNITS
  1268. X#define NUM_PHYSICAL_UNITS    MAX_UNITS
  1269. X#endif
  1270. X
  1271. X/* let the driver know the number of devices */
  1272. Xuint fas_physical_units = NUM_PHYSICAL_UNITS;
  1273. X
  1274. X/* array of base port addresses
  1275. X   If you deliberately want to force off the FIFOs of a UART you have
  1276. X   to "or" the NO_FIFO macro to its base port address. This is useful
  1277. X   for mouse devices where you need immediate response to the mouse
  1278. X   movement.
  1279. X*/
  1280. Xulong fas_port[NUM_PHYSICAL_UNITS] =
  1281. X{
  1282. X    0x3f8,
  1283. X    COM21, COM22, COM23, COM24, COM25, COM26, COM27, COM28
  1284. X};
  1285. X
  1286. X/*
  1287. X * array of port names
  1288. X * Note this is a kludge to enable kmem seeking programs to
  1289. X * determine which tty is associated with which tty struct
  1290. X * and is <yetch> duplication of information appearing in
  1291. X * the Node (/etc/node.d/fas) file
  1292. X */
  1293. X#if defined(FASI)
  1294. Xstruct fas_name fas_names[NUM_PHYSICAL_UNITS * 2] =
  1295. X{
  1296. X    {"1a"},
  1297. X    {"2a"},
  1298. X    {"2b"},
  1299. X    {"2c"},
  1300. X    {"2d"},
  1301. X    {"2e"},
  1302. X    {"2f"},
  1303. X    {"2g"},
  1304. X    {"2h"},
  1305. X    {"1A"},
  1306. X    {"2A"},
  1307. X    {"2B"},
  1308. X    {"2C"},
  1309. X    {"2D"},
  1310. X    {"2E"},
  1311. X    {"2F"},
  1312. X    {"2G"},
  1313. X    {"2H"}
  1314. X};
  1315. X
  1316. X#endif
  1317. X
  1318. X/* array of interrupt vectors */
  1319. Xuint fas_vec[NUM_PHYSICAL_UNITS] =
  1320. X{
  1321. X    4,
  1322. X    3, 3, 3, 3, 3, 3, 3, 3
  1323. X};
  1324. X
  1325. X/* initialization sequence for serial card
  1326. X   This array contains pairs of values of the form:
  1327. X
  1328. X        portaddress, value,
  1329. X              :
  1330. X              :
  1331. X        portaddress, value,
  1332. X        0
  1333. X
  1334. X   For every line `value' will be written to `portaddress'. If
  1335. X   `value' is replaced with the macro `READ_PORT' then a value
  1336. X   is read from `portaddress' instead. The value itself will be
  1337. X   discarded. Therefor this makes only sense if the read access
  1338. X   to the port has a side effect like setting or resetting
  1339. X   certain flags.
  1340. X
  1341. X   NOTE: This array *must* be terminated with a value of 0
  1342. X         in the portaddress column!
  1343. X*/
  1344. Xuint fas_init_seq[] =
  1345. X{
  1346. X    0
  1347. X};
  1348. X
  1349. X/* initial modem control port info
  1350. X   This value is ored into the modem control value for each UART. This is
  1351. X   normaly used to force out2 which is used to enable the interrupts of
  1352. X   the standard com1 and com2 ports. Several brands of cards have modes
  1353. X   that allow them to work in compatible mode like com1 and com2 or as a
  1354. X   shared interrupts card. One of these cards is the AST 4-port card. When
  1355. X   this card is used in shared interrupts mode out2 must _not_ be set.
  1356. X
  1357. X   Note: This is one of the major trouble-spots with shared interrupts
  1358. X   cards. Check your manual.
  1359. X*/
  1360. Xuint fas_mcb[NUM_PHYSICAL_UNITS] =
  1361. X{
  1362. X    MC_SET_OUT2,
  1363. X    MC_SET_OUT2, MC_SET_OUT2, MC_SET_OUT2, MC_SET_OUT2,
  1364. X    MC_SET_OUT2, MC_SET_OUT2, MC_SET_OUT2, MC_SET_OUT2
  1365. X};
  1366. X
  1367. X/* array of modem control flags
  1368. X   You can choose which signals to use for modem control. See fas.h
  1369. X   for possible names and values. Whether or not modem control is
  1370. X   used is determined by the minor device number at open time.
  1371. X*/
  1372. Xulong fas_modem[NUM_PHYSICAL_UNITS] =
  1373. X{
  1374. X    EO_DTR | EI_DTR | CA_DCD,
  1375. X    EO_DTR | EI_DTR | CA_DCD, EO_DTR | EI_DTR | CA_DCD,
  1376. X    EO_DTR | EI_DTR | CA_DCD, EO_DTR | EI_DTR | CA_DCD,
  1377. X    EO_DTR | EI_DTR | CA_DCD, EO_DTR | EI_DTR | CA_DCD,
  1378. X    EO_DTR | EI_DTR | CA_DCD, EO_DTR | EI_DTR | CA_DCD
  1379. X};
  1380. X
  1381. X/* array of hardware flow control flags
  1382. X   You can choose which signals to use for hardware handshake. See fas.h
  1383. X   for possible names and values. Whether or not hardware handshake is
  1384. X   used is determined by the minor device number at open time and by the
  1385. X   RTSFLOW/CTSFLOW termio(7) flags.
  1386. X*/
  1387. Xulong fas_flow[NUM_PHYSICAL_UNITS] =
  1388. X{
  1389. X    HI_RTS | HO_CTS_ON_DSR | HX_RTS,
  1390. X    HI_RTS | HO_CTS_ON_DSR | HX_RTS,
  1391. X    HI_RTS | HO_CTS_ON_DSR | HX_RTS,
  1392. X    HI_RTS | HO_CTS_ON_DSR | HX_RTS,
  1393. X    HI_RTS | HO_CTS_ON_DSR | HX_RTS,
  1394. X    HI_RTS | HO_CTS_ON_DSR | HX_RTS,
  1395. X    HI_RTS | HO_CTS_ON_DSR | HX_RTS,
  1396. X    HI_RTS | HO_CTS_ON_DSR | HX_RTS,
  1397. X    HI_RTS | HO_CTS_ON_DSR | HX_RTS
  1398. X};
  1399. X
  1400. X/* array of control register addresses
  1401. X   There are serial boards available that have all serial ports
  1402. X   multiplexed to one address location in order to save I/O address
  1403. X   space (Bell Tech HUB-6 card etc.). This multiplexing is controlled
  1404. X   by a special register that needs to be written to before the actual
  1405. X   port registers can be accessed. This array contains the addresses
  1406. X   of these special registers.
  1407. X   Enter the addresses on a per unit base. An address of zero
  1408. X   disables this feature.
  1409. X*/
  1410. Xuint fas_ctl_port[NUM_PHYSICAL_UNITS] =
  1411. X{
  1412. X    0,
  1413. X    0, 0, 0, 0, 0, 0, 0, 0
  1414. X};
  1415. X
  1416. X/* array of control register values
  1417. X   These values are written to the corresponding control register
  1418. X   before the first access to the actual port registers. If not only
  1419. X   entire UART chips (blocks of 8 contiguous addresses) but even the
  1420. X   single registers of the UART chips need to be multiplexed to one
  1421. X   address you have to "or" a bit mask (shifted 8 times to the left)
  1422. X   to the control register value. This mask determines at which bit
  1423. X   locations the UART chip register number is "xored" into the control
  1424. X   register value at runtime. This implies that you can also use
  1425. X   negative logic by setting the bits in the control register value
  1426. X   to 1 at the locations corresponding to the bit mask.
  1427. X*/
  1428. Xuint fas_ctl_val[NUM_PHYSICAL_UNITS] =
  1429. X{
  1430. X    0,
  1431. X    0, 0, 0, 0, 0, 0, 0, 0
  1432. X};
  1433. X
  1434. X/* additional configurations for shared interrupts boards
  1435. X   If you have a shared interrupts board, you may have to acknowledge
  1436. X   interrupts by writing to a special register. The following arrays
  1437. X   contain the special register addresses and the corresponding values
  1438. X   that are written to them in response to an interrupt.
  1439. X*/
  1440. X
  1441. X/* array of int ack register addresses
  1442. X   These registers are written to every time after all interrupt
  1443. X   sources in all of the UARTs that are tied to the corresponding
  1444. X   interrupt vector have been cleared.
  1445. X   Enter the addresses on a per vector base. An address of zero
  1446. X   disables this feature.
  1447. X*/
  1448. Xuint fas_int_ack_port[NUM_INT_VECTORS] =
  1449. X{
  1450. X    0, 0, 0, 0,
  1451. X    0, 0, 0, 0,
  1452. X    0, 0, 0, 0,
  1453. X    0, 0, 0, 0,
  1454. X    0, 0, 0, 0,
  1455. X    0, 0, 0, 0,
  1456. X    0, 0, 0, 0,
  1457. X    0, 0, 0, 0
  1458. X};
  1459. X
  1460. X/* array of int ack values
  1461. X   These values are written to the corresponding int ack register
  1462. X   in response to an interrupt.
  1463. X*/
  1464. Xuint fas_int_ack[NUM_INT_VECTORS] =
  1465. X{
  1466. X    0, 0, 0, 0,
  1467. X    0, 0, 0, 0,
  1468. X    0, 0, 0, 0,
  1469. X    0, 0, 0, 0,
  1470. X    0, 0, 0, 0,
  1471. X    0, 0, 0, 0,
  1472. X    0, 0, 0, 0,
  1473. X    0, 0, 0, 0
  1474. X};
  1475. X
  1476. X/* NOTHING NEEDS TO BE CHANGED BELOW THIS LINE.
  1477. X   ============================================
  1478. X*/
  1479. X
  1480. X/* array of structures to hold all info for a physical minor device */
  1481. Xstruct fas_info fas_info[NUM_PHYSICAL_UNITS];
  1482. X
  1483. X/* array of ttys for logical minor devices */
  1484. Xstruct tty fas_tty[NUM_PHYSICAL_UNITS * 2];
  1485. X
  1486. X/* array of pointers to fas_info structures
  1487. X   this prevents time consuming multiplications for index calculation
  1488. X*/
  1489. Xstruct fas_info *fas_info_ptr[NUM_PHYSICAL_UNITS];
  1490. X
  1491. X/* array of pointers to fas_tty structures
  1492. X   this prevents time consuming multiplications for index calculation
  1493. X*/
  1494. Xstruct tty *fas_tty_ptr[NUM_PHYSICAL_UNITS * 2];
  1495. END_OF_FILE
  1496.   if test 8855 -ne `wc -c <'ecu330/fasi/Space.c'`; then
  1497.     echo shar: \"'ecu330/fasi/Space.c'\" unpacked with wrong size!
  1498.   fi
  1499.   # end of 'ecu330/fasi/Space.c'
  1500. fi
  1501. if test -f 'ecu330/gendial/dceUSR24v.c' -a "${1}" != "-c" ; then 
  1502.   echo shar: Will not clobber existing file \"'ecu330/gendial/dceUSR24v.c'\"
  1503. else
  1504.   echo shar: Extracting \"'ecu330/gendial/dceUSR24v.c'\" \(12151 characters\)
  1505.   sed "s/^X//" >'ecu330/gendial/dceUSR24v.c' <<'END_OF_FILE'
  1506. X/*+-------------------------------------------------------------------------
  1507. X  dceUSR24v.c - DCE-specific portion of generic SCO UUCP dialer
  1508. X    Driver for USR Courier 2400 - optimized for rapid use as voice dialer
  1509. X    wht@n4hgf.atl.ga.us
  1510. X
  1511. X This is for attended voice applications where speed of operation is
  1512. X more important than superb reliability.  The modem I had in mind
  1513. X here is an old (simple and reliable) USR 2400 I had lying around
  1514. X doing nothing.  Now it is a voice line dialer.  Autoanswer is always
  1515. X turned off whenever we can do it.  No one goes after the modem
  1516. X anywhere near once per minute.  We can dispense with delays and
  1517. X brick outhouse initialization.
  1518. X
  1519. X Necessary DCE switch setting or other configuration:
  1520. X   enable onhook upon loss of DTR
  1521. X
  1522. XThis dialer does not use the X6 quick dial feature, nor voice detection.
  1523. XQuick dial tone recognition often fqails due to the telco granting
  1524. Xdial tone ahead of the actual time it is ready to accept dialing.
  1525. XVoice recognition fails when dialing 0+ with a credit card, as in "Thank
  1526. Xyou for using ATT" - CLICK - "VOICE".
  1527. X
  1528. X--------------------------------------------------------------------------*/
  1529. X/*+:EDITS:*/
  1530. X/*:05-04-1994-04:39-wht@n4hgf-ECU release 3.30 */
  1531. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1532. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1533. X/*:02-02-1992-18:01-root@n4hgf-proper ordering of DCE_result entries */
  1534. X/*:01-26-1992-15:30-wht@n4hgf-gendial 1.2 for ecu 3.20- better hangup */
  1535. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  1536. X/*:07-25-1991-04:34-wht@n4hgf-add naps around writes */
  1537. X/*:04-16-1991-18:18-wht@n4hgf-creation from template */
  1538. X
  1539. X#include "dialer.h"
  1540. X
  1541. X/*
  1542. X * DCE_DTR_low_msec - milliseconds to hold DTR low to ensure DCE
  1543. X *                    sees the transition; this value may be changed
  1544. X *                    as necessary before each call to lflash_DTR(),
  1545. X * but, generally, a constant value will do.
  1546. X */
  1547. Xlong DCE_DTR_low_msec = 100L;
  1548. X
  1549. X/*
  1550. X * DCE_DTR_high_msec - milliseconds DTR must remain high before the
  1551. X *                     DCE may be expected to be ready to be commanded
  1552. X */
  1553. Xlong DCE_DTR_high_msec = 50L;
  1554. X
  1555. X/*
  1556. X * DCE_write_pace_msec - milliseconds to pause between each character
  1557. X *                       sent to the DCE (zero if streaming I/O is
  1558. X *                       permitted); this value may be changed as
  1559. X * necessary before each call to lwrite(), but, generally, a constant
  1560. X * value will do.  Note that this value is used to feed a value to Nap(),
  1561. X * which has a granularity of .010 seconds on UNIX/386, .020 on XENIX/286
  1562. X * and .050 seconds on XENIX/86.
  1563. X */
  1564. Xlong DCE_write_pace_msec = 0;
  1565. X
  1566. X/*
  1567. X * DCE_name     - short name for DCE
  1568. X * DCE_revision - revision number for this module
  1569. X */
  1570. Xchar *DCE_name = "USR Courier 2400 quick voice";
  1571. Xchar *DCE_revision = "1.00";
  1572. X
  1573. X/*
  1574. X * DCE_hangup_CBAUD - baud rate to use for hanging up DCE
  1575. X *                    and readying it for dial in access
  1576. X *                    (BXXX mask); use a value of zero if the speed
  1577. X *                    specified by the invoker is to be used.
  1578. X * This value is useful for DCEs such as the early Hayes 2400
  1579. X * which are so unfortunately compatible with their 1200 predecessor
  1580. X * that they refuse to answer at 2400 baud unless you last spoke to
  1581. X * them at that rate. For such bad boys, use B2400 below.
  1582. X */
  1583. Xint DCE_hangup_CBAUD = B2400;
  1584. X
  1585. X/*
  1586. X * DCE_results - a table of DCE response strings and a token
  1587. X *               code for each; when you call lread() or lread_ignore(),
  1588. X *               if the read routine detects one of the strings,
  1589. X * the appropriate code is returned.  If no string matches, then
  1590. X * lread()/lread_ignore examines the DCE result string for a
  1591. X * numeric value; if one is found, the numeric value or'd with
  1592. X * 0x4000 is returned (in this way, e.g., you can read "modem
  1593. X * S registers."  If nothing agrees with this search, lread()
  1594. X * will abort the program with RC|FAIL|RCE_TIMOUT, lread_ignore()
  1595. X * will return -1.  You may use any value between 0 and 0x3FFFFFFF.
  1596. X * This module is the only consumer  of the codes, although they
  1597. X * are decoded by gendial.c's _lread()
  1598. X *
  1599. X * If one possible result is an "early substring" of another, like
  1600. X * "CONNECT" is of "CONNECT 1200", then put such results later in the
  1601. X * table than the larger result.
  1602. X *
  1603. X */
  1604. X#define rfConnect        0x00400000
  1605. X#define rfMASK            0x000000FF
  1606. X
  1607. X#define rOk                0
  1608. X#define rNoCarrier        1
  1609. X#define rError            2
  1610. X#define rNoDialTone        3
  1611. X#define rBusy            4
  1612. X#define rNoAnswer        5
  1613. X#define rVoice            6
  1614. X#define rConnect300        (7 | rfConnect)
  1615. X#define rConnect1200    (8 | rfConnect)
  1616. X#define rConnect2400    (9 | rfConnect)
  1617. X
  1618. XDCE_RESULT DCE_results[] =
  1619. X{
  1620. X    {"OK", rOk,},
  1621. X    {"NO CARRIER", rNoCarrier,},
  1622. X    {"ERROR", rError},
  1623. X    {"NO DIALTONE", rNoDialTone,},
  1624. X    {"BUSY", rBusy},
  1625. X    {"NO ANSWER", rNoAnswer},
  1626. X    {"VOICE", rVoice},
  1627. X    {"CONNECT 1200", rConnect1200},
  1628. X    {"CONNECT 2400", rConnect2400},
  1629. X    {"CONNECT", rConnect300},
  1630. X    {(char *)0, -1}             /* end table */
  1631. X};
  1632. X
  1633. X/*+-------------------------------------------------------------------------
  1634. X    DCE_baud_to_CBAUD(baud) - check for valid baud rates supported by DCE
  1635. X
  1636. X  DCE dependent function must validate baud rates supported by DCE
  1637. X  returns baud rate in struct termio c_cflag fashion
  1638. X  or terminates program with error
  1639. X--------------------------------------------------------------------------*/
  1640. Xint
  1641. XDCE_baud_to_CBAUD(baud)
  1642. Xunsigned int baud;
  1643. X{
  1644. X    switch (baud)
  1645. X    {
  1646. X        case 50:
  1647. X            return (B50);     /* delete the ones you dont handle */
  1648. X        case 75:
  1649. X            return (B75);
  1650. X        case 110:
  1651. X            return (B110);
  1652. X        case 134:
  1653. X            return (B134);
  1654. X        case 150:
  1655. X            return (B150);
  1656. X        case 300:
  1657. X            return (B300);
  1658. X        case 1200:
  1659. X            return (B1200);
  1660. X        case 2400:
  1661. X            return (B2400);
  1662. X        case 4800:
  1663. X            return (B4800);
  1664. X        case 9600:
  1665. X            return (B9600);
  1666. X
  1667. X#if defined(B19200)
  1668. X        case 19200:
  1669. X            return (B19200);
  1670. X#else
  1671. X#ifdef EXTA
  1672. X        case 19200:
  1673. X            return (EXTA);
  1674. X#endif
  1675. X#endif
  1676. X
  1677. X#if defined(B38400)
  1678. X        case 38400:
  1679. X            return (B38400);
  1680. X#else
  1681. X#ifdef EXTB
  1682. X        case 38400:
  1683. X            return (EXTB);
  1684. X#endif
  1685. X#endif
  1686. X
  1687. X    }
  1688. X    myexit(RC_FAIL | RCE_SPEED);
  1689. X#if defined(OPTIMIZE) || defined(__OPTIMIZE__)
  1690. X    return (0);                 /* I wish this wasn't necessary to avoid
  1691. X                              * warnings */
  1692. X#endif
  1693. X}                             /* end of DCE_baud_to_CBAUD */
  1694. X
  1695. X/*+-------------------------------------------------------------------------
  1696. X    DCE_hangup() - issue hangup command to DCE
  1697. X
  1698. XThis function should do whatever is necessary to ensure
  1699. X1) any active connection is terminated
  1700. X2) the DCE is ready to receive an incoming call if DTR is asserted
  1701. X3) the DCE will not accept an incoming call if DTR is false
  1702. X
  1703. XThe function should return when done.
  1704. X
  1705. XYou must set any switches necessary to make modem hang up on loss of DTR
  1706. X--------------------------------------------------------------------------*/
  1707. Xvoid
  1708. XDCE_hangup()
  1709. X{
  1710. X
  1711. X    DEBUG(1, "--> hanging up %s\n", dce_name);
  1712. X    lflash_DTR();
  1713. X
  1714. X    lwrite("ATQ0S0=0\r");
  1715. X    Nap(20L);
  1716. X
  1717. X}                             /* end of DCE_hangup */
  1718. X
  1719. X/*+-------------------------------------------------------------------------
  1720. X    DCE_dial(telno_str) - dial a remote DCE
  1721. X
  1722. XThis function should connect to the remote DCE and use any success
  1723. Xindication to modify the tty baud rate if necessary before returning.
  1724. X
  1725. XUpon successful connection, return 0.
  1726. X
  1727. XUpon unsuccessful connection, return RC_FAIL or'd with an appropriate
  1728. XRCE_XXX value from dialer.h.
  1729. X
  1730. Xlwrite() is used to write to the DCE.
  1731. X
  1732. Xlread() and lread_ignore() are used to read from the DCE.  Read timeouts
  1733. Xfrom calling lread() will result automatically in the proper error
  1734. Xtermination of the program.  Read timeouts from calling lread_ignore()
  1735. Xreturn -1; you handle the execption here.
  1736. X
  1737. XAny necessary coding of phone numbers, switch settings or other
  1738. Xconfiguration necessary for this function to succeed should be
  1739. Xdocumented at the top of the module.
  1740. X--------------------------------------------------------------------------*/
  1741. Xint
  1742. XDCE_dial(telno_str)
  1743. Xchar *telno_str;
  1744. X{
  1745. X    char cmd[128];
  1746. X    char phone[50];
  1747. X    int timeout;
  1748. X    int result;
  1749. X    char *sptr;
  1750. X    char *dptr;
  1751. X    char ch;
  1752. X    int len;
  1753. X
  1754. X    sptr = telno_str;
  1755. X    dptr = phone + 1;
  1756. X    *dptr = 0;
  1757. X    while (ch = *sptr++)
  1758. X    {
  1759. X        if (isdigit(ch) || (ch == ','))
  1760. X        {
  1761. X            *dptr++ = ch;
  1762. X            *dptr = 0;
  1763. X        }
  1764. X    }
  1765. X
  1766. X    telno_str = phone + 1;
  1767. X    if (((len = strlen(phone + 1)) == 10) &&
  1768. X        ((phone[1 + 1] == '0') || (phone[1 + 1] == '1')))
  1769. X    {
  1770. X        phone[0] = '1';
  1771. X        telno_str = phone;
  1772. X    }
  1773. X
  1774. X/*
  1775. X * build and issue the actual dialing command
  1776. X */
  1777. X    DEBUG(1, "--> dialing %s\n", telno_str);
  1778. X    sprintf(cmd, "ATe1Q0V1S0=0S7=120X3DT%s\r", telno_str);
  1779. X    DCE_write_pace_msec = 20;
  1780. X    lwrite("AA");
  1781. X    DCE_write_pace_msec = 0;
  1782. X    lwrite(cmd);
  1783. X
  1784. X/* wait for connect */
  1785. X    result = lread(timeout);
  1786. X    if (!(result & rfConnect))
  1787. X    {
  1788. X        switch (result & rfMASK)
  1789. X        {
  1790. X            case rNoCarrier:
  1791. X                return (RC_FAIL | RCE_NOCARR);
  1792. X            case rVoice:     /* if you get voice, certainly wrong number */
  1793. X            case rNoDialTone:
  1794. X                return (RC_FAIL | RCE_NOTONE);
  1795. X            case rBusy:
  1796. X                return (RC_FAIL | RCE_BUSY);
  1797. X            case rNoAnswer:
  1798. X                return (RC_FAIL | RCE_ANSWER);
  1799. X            case rError:
  1800. X            default:
  1801. X                return (RC_FAIL | RCE_NULL);
  1802. X        }
  1803. X    }
  1804. X
  1805. X/* indicate non-root can see DTE->DCE traffic */
  1806. X    secure = 0;
  1807. X    return (0);                 /* succeeded */
  1808. X
  1809. X}                             /* end of DCE_dial */
  1810. X
  1811. X/**********************************************************
  1812. X*  You probably do not need to modify the code below here *
  1813. X**********************************************************/
  1814. X
  1815. X/*+-------------------------------------------------------------------------
  1816. X    DCE_abort(sig) - dial attempt aborted
  1817. X
  1818. X sig =  0 if non-signal abort (read timeout, most likely)
  1819. X     != 0 if non-SIGALRM signal caught
  1820. X
  1821. X extern int dialing set  1 if dialing request was active,
  1822. X                    else 0 if hangup request was active
  1823. X
  1824. XThis is a chance for the DCE-specific code to do anything it
  1825. Xneeds to cl,ean up after a failure.  Note that if a dialing
  1826. Xcall fails, it is the responsibility of the higher-level
  1827. Xprogram calling the dialer to call it again with a hangup request, so
  1828. Xthis function is usually a no-op.
  1829. X--------------------------------------------------------------------------*/
  1830. Xvoid
  1831. XDCE_abort(sig)
  1832. Xint sig;
  1833. X{
  1834. X    DEBUG(10, "DCE_abort(%d);\n", sig);
  1835. X}                             /* end of DCE_abort */
  1836. X
  1837. X/*+-------------------------------------------------------------------------
  1838. X    DCE_exit(exitcode) - "last chance for gas" in this incarnation
  1839. X
  1840. XThe independent portion of the dialer program calls this routine in
  1841. Xlieu of exit() in every case except one (see DCE_argv_hook() below).
  1842. XNormally, this function just passes it's argument to exit(), but
  1843. Xany necessary post-processing can be done.  The function must,
  1844. Xhowever, eventually call exit(exitcode);
  1845. X--------------------------------------------------------------------------*/
  1846. Xvoid
  1847. XDCE_exit(exitcode)
  1848. Xint exitcode;
  1849. X{
  1850. X    DEBUG(10, "DCE_exit(%d);\n", exitcode);
  1851. X    exit(exitcode);
  1852. X}                             /* end of DCE_exit */
  1853. X
  1854. X/*+-------------------------------------------------------------------------
  1855. X    DCE_argv_hook(argc,argv,optind,unrecognized_switches)
  1856. X
  1857. XThis hook gives DCE-specific code a chance to look over the entire
  1858. Xcommand line, such as for -z Telebit processing.
  1859. X
  1860. Xargc andf argv are the same values passed to main(),
  1861. X
  1862. Xoptind is the value of optind at the end of normal getopt processing.
  1863. X
  1864. Xunrecognized_switches is the count of switches not handled by main().
  1865. XSpecifically, -h and -x are standard switches.
  1866. X
  1867. XNormally, this function should just return RC_FAIL|RCE_ARGS if there are
  1868. Xany unrecognized switches, otherwise zero.  If you keep your nose clean
  1869. Xthough, you can do anything you need to do here and exit the program.
  1870. X
  1871. XNote: only simple switches (with no argument) may be used with this
  1872. Xfacility if the functrion is to return,' since main()'s getopt() will
  1873. Xstop processing switches if it runs into an unrecognized switch with an
  1874. Xargument.
  1875. X
  1876. XIf the function returns a non-zero value, then the value will be passed
  1877. XDIRECTLY to exit() with no further ado.  Thus, a non-zero value must be
  1878. Xof the format expected by dialer program callers, with RC_FAIL set as a
  1879. Xminimum.
  1880. X--------------------------------------------------------------------------*/
  1881. Xint
  1882. XDCE_argv_hook(argc, argv, optind, unrecognized_switches)
  1883. Xint argc;
  1884. Xchar **argv;
  1885. Xint optind;
  1886. Xint unrecognized_switches;
  1887. X{
  1888. X    if (unrecognized_switches)
  1889. X        return (RC_FAIL | RCE_ARGS);
  1890. X    return (0);
  1891. X}                             /* end of DCE_argv_hook */
  1892. X
  1893. X/* vi: set tabstop=4 shiftwidth=4: */
  1894. END_OF_FILE
  1895.   if test 12151 -ne `wc -c <'ecu330/gendial/dceUSR24v.c'`; then
  1896.     echo shar: \"'ecu330/gendial/dceUSR24v.c'\" unpacked with wrong size!
  1897.   fi
  1898.   # end of 'ecu330/gendial/dceUSR24v.c'
  1899. fi
  1900. if test -f 'ecu330/regexp.c' -a "${1}" != "-c" ; then 
  1901.   echo shar: Will not clobber existing file \"'ecu330/regexp.c'\"
  1902. else
  1903.   echo shar: Extracting \"'ecu330/regexp.c'\" \(12818 characters\)
  1904.   sed "s/^X//" >'ecu330/regexp.c' <<'END_OF_FILE'
  1905. X/*+-------------------------------------------------------------------------
  1906. X    regexp.c -- regular expression functions made sane
  1907. X    wht@n4hgf.atl.ga.us
  1908. X
  1909. X  Defined functions:
  1910. X    advance(lp,ep)
  1911. X    compile(pattern,ep,endbuf,seof)
  1912. X    ecmp(a,b,count)
  1913. X    getrnge(regexp)
  1914. X    regexp_compile(regexp,cmpbuf,cmpbuf_size,emsg)
  1915. X    regexp_operation(match_str,regexp_str,rtn_value)
  1916. X    regexp_scan(cmpbuf,str_to_search,match,matchlen)
  1917. X    step(p1,p2)
  1918. X
  1919. X--------------------------------------------------------------------------*/
  1920. X/*+:EDITS:*/
  1921. X/*:05-04-1994-04:40-wht@n4hgf-ECU release 3.30 */
  1922. X/*:09-10-1992-14:00-wht@n4hgf-ECU release 3.20 */
  1923. X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
  1924. X/*:08-28-1991-14:07-wht@n4hgf2-SVR4 cleanup by aega84!lh */
  1925. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  1926. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1927. X
  1928. X#include <stdio.h>
  1929. X#include "ecuerror.h"
  1930. X#include "esd.h"
  1931. X#include "var.h"
  1932. X#include <setjmp.h>
  1933. X
  1934. X#define    CBRA    2
  1935. X#define    CCHR    4
  1936. X#define    CDOT    8
  1937. X#define    CCL        12
  1938. X#define    CDOL    20
  1939. X#define    CCEOF    22
  1940. X#define    CKET    24
  1941. X#define    CBACK    36
  1942. X
  1943. X#define    STAR    01
  1944. X#define    RNGE    03
  1945. X
  1946. X#define    NBRA    9
  1947. X
  1948. X#define    PLACE(c)    ep[c >> 3] |= bittab[c & 07]
  1949. X#define    ISTHERE(c)    (ep[c >> 3] & bittab[c & 07])
  1950. X
  1951. Xvoid getrnge();
  1952. Xint advance();
  1953. Xint ecmp();
  1954. X
  1955. Xextern int proc_level;
  1956. Xextern int proc_trace;
  1957. X
  1958. Xchar *braslist[NBRA];
  1959. Xchar *braelist[NBRA];
  1960. Xint nbra;
  1961. Xint ebra;
  1962. Xchar *match_start;
  1963. Xchar *match_end;
  1964. Xchar *locs;
  1965. Xint sed;
  1966. Xint nodelim;
  1967. Xint circf;
  1968. Xint low;
  1969. Xint size;
  1970. Xunsigned char bittab[] =
  1971. X{1, 2, 4, 8, 16, 32, 64, 128};
  1972. Xjmp_buf compile_error_jmpbuf;
  1973. X
  1974. X/*+-------------------------------------------------------------------------
  1975. X    compile(pattern,ep,endbuf,seof)
  1976. X--------------------------------------------------------------------------*/
  1977. Xvoid
  1978. Xcompile(pattern, ep, endbuf, seof)
  1979. Xchar *pattern;
  1980. Xregister char *ep;
  1981. Xchar *endbuf;
  1982. Xint seof;
  1983. X{
  1984. X    register char *sp = pattern;
  1985. X    register c;
  1986. X    register eof = seof;
  1987. X    char *lastep = pattern;
  1988. X    int cclcnt;
  1989. X    char bracket[NBRA], *bracketp;
  1990. X    int closed;
  1991. X    char neg;
  1992. X    int lc;
  1993. X    int i, cflg;
  1994. X
  1995. X    lastep = 0;
  1996. X    if ((c = *sp++) == eof || c == '\n')
  1997. X    {
  1998. X        if (c == '\n')
  1999. X        {
  2000. X            --sp;
  2001. X            nodelim = 1;
  2002. X        }
  2003. X        if (*ep == 0 && !sed)
  2004. X            longjmp(compile_error_jmpbuf, 41);
  2005. X        return;
  2006. X    }
  2007. X    bracketp = bracket;
  2008. X    circf = closed = nbra = ebra = 0;
  2009. X    if (c == '^')
  2010. X        circf++;
  2011. X    else
  2012. X        --sp;
  2013. X    while (1)
  2014. X    {
  2015. X        if (ep >= endbuf)
  2016. X            longjmp(compile_error_jmpbuf, 50);
  2017. X        c = *sp++;
  2018. X        if (c != '*' && ((c != '\\') || (*sp != 0x7B)))
  2019. X            lastep = ep;
  2020. X        if (c == eof)
  2021. X        {
  2022. X            *ep++ = CCEOF;
  2023. X            return;
  2024. X        }
  2025. X        switch (c)
  2026. X        {
  2027. X
  2028. X            case '.':
  2029. X                *ep++ = CDOT;
  2030. X                continue;
  2031. X
  2032. X            case '\n':
  2033. X                if (!sed)
  2034. X                {
  2035. X                    --sp;
  2036. X                    *ep++ = CCEOF;
  2037. X                    nodelim = 1;
  2038. X                    return;
  2039. X                }
  2040. X                else
  2041. X                    longjmp(compile_error_jmpbuf, 36);
  2042. X            case '*':
  2043. X                if (lastep == 0 || *lastep == CBRA || *lastep == CKET)
  2044. X                    goto defchar;
  2045. X                *lastep |= STAR;
  2046. X                continue;
  2047. X
  2048. X            case '$':
  2049. X                if (*sp != eof && *sp != '\n')
  2050. X                    goto defchar;
  2051. X                *ep++ = CDOL;
  2052. X                continue;
  2053. X
  2054. X            case '[':
  2055. X                if (&ep[17] >= endbuf)
  2056. X                    longjmp(compile_error_jmpbuf, 50);
  2057. X
  2058. X                *ep++ = CCL;
  2059. X                lc = 0;
  2060. X                for (i = 0; i < 16; i++)
  2061. X                    ep[i] = 0;
  2062. X
  2063. X                neg = 0;
  2064. X                if ((c = *sp++) == '^')
  2065. X                {
  2066. X                    neg = 1;
  2067. X                    c = *sp++;
  2068. X                }
  2069. X
  2070. X                do
  2071. X                {
  2072. X                    if (c == '\0' || c == '\n')
  2073. X                        longjmp(compile_error_jmpbuf, 49);
  2074. X                    if (c == '-' && lc != 0)
  2075. X                    {
  2076. X                        if ((c = *sp++) == ']')
  2077. X                        {
  2078. X                            PLACE('-');
  2079. X                            break;
  2080. X                        }
  2081. X                        while (lc < c)
  2082. X                        {
  2083. X                            PLACE(lc);
  2084. X                            lc++;
  2085. X                        }
  2086. X                    }
  2087. X                    if (c == '\\')
  2088. X                    {
  2089. X                        switch (c = *sp++)
  2090. X                        {
  2091. X                            case 'n':
  2092. X                                c = '\n';
  2093. X                                break;
  2094. X                        }
  2095. X                    }
  2096. X                    lc = c;
  2097. X                    PLACE(c);
  2098. X                }
  2099. X                while ((c = *sp++) != ']');
  2100. X                if (neg)
  2101. X                {
  2102. X                    for (cclcnt = 0; cclcnt < 16; cclcnt++)
  2103. X                        ep[cclcnt] ^= -1;
  2104. X                    ep[0] &= 0376;
  2105. X                }
  2106. X
  2107. X                ep += 16;
  2108. X
  2109. X                continue;
  2110. X
  2111. X            case '\\':
  2112. X                switch (c = *sp++)
  2113. X                {
  2114. X
  2115. X                    case 0x28:    /* open paren */
  2116. X                        if (nbra >= NBRA)
  2117. X                            longjmp(compile_error_jmpbuf, 43);
  2118. X                        *bracketp++ = nbra;
  2119. X                        *ep++ = CBRA;
  2120. X                        *ep++ = nbra++;
  2121. X                        continue;
  2122. X
  2123. X                    case 0x29:    /* close paren */
  2124. X                        if (bracketp <= bracket || ++ebra != nbra)
  2125. X                            longjmp(compile_error_jmpbuf, 42);
  2126. X                        *ep++ = CKET;
  2127. X                        *ep++ = *--bracketp;
  2128. X                        closed++;
  2129. X                        continue;
  2130. X
  2131. X                    case 0x7B:    /* open brace */
  2132. X                        if (lastep == (char *)(0))
  2133. X                            goto defchar;
  2134. X                        *lastep |= RNGE;
  2135. X                        cflg = 0;
  2136. X                      nlim:
  2137. X                        c = *sp++;
  2138. X                        i = 0;
  2139. X                        do
  2140. X                        {
  2141. X                            if ('0' <= c && c <= '9')
  2142. X                                i = 10 * i + c - '0';
  2143. X                            else
  2144. X                                longjmp(compile_error_jmpbuf, 16);
  2145. X                        }
  2146. X                        while (((c = *sp++) != '\\') && (c != ','));
  2147. X                        if (i >= 255)
  2148. X                            longjmp(compile_error_jmpbuf, 11);
  2149. X                        *ep++ = i;
  2150. X                        if (c == ',')
  2151. X                        {
  2152. X                            if (cflg++)
  2153. X                                longjmp(compile_error_jmpbuf, 44);
  2154. X                            if ((c = *sp++) == '\\')
  2155. X                                *ep++ = 255;
  2156. X                            else
  2157. X                            {
  2158. X                                --sp;
  2159. X                                goto nlim;
  2160. X                                /* get 2'nd number */
  2161. X                            }
  2162. X                        }
  2163. X                        if (*sp++ != 0x7D)    /* close brace */
  2164. X                            longjmp(compile_error_jmpbuf, 45);
  2165. X                        if (!cflg)    /* one number */
  2166. X                            *ep++ = i;
  2167. X                        else if ((ep[-1] & 0377) < (ep[-2] & 0377))
  2168. X                            longjmp(compile_error_jmpbuf, 46);
  2169. X                        continue;
  2170. X
  2171. X                    case '\n':
  2172. X                        longjmp(compile_error_jmpbuf, 36);
  2173. X
  2174. X                    case 'n':
  2175. X                        c = '\n';
  2176. X                        goto defchar;
  2177. X
  2178. X                    default:
  2179. X                        if (c >= '1' && c <= '9')
  2180. X                        {
  2181. X                            if ((c -= '1') >= closed)
  2182. X                                longjmp(compile_error_jmpbuf, 25);
  2183. X                            *ep++ = CBACK;
  2184. X                            *ep++ = c;
  2185. X                            continue;
  2186. X                        }
  2187. X                }
  2188. X
  2189. X                /*
  2190. X                 * Drop through to default to use \ to turn off special
  2191. X                 * chars
  2192. X                 */
  2193. X
  2194. X              defchar:
  2195. X            default:
  2196. X                lastep = ep;
  2197. X                *ep++ = CCHR;
  2198. X                *ep++ = c;
  2199. X        }
  2200. X    }
  2201. X}                             /* end of compile */
  2202. X
  2203. X/*+-------------------------------------------------------------------------
  2204. X    step(p1,p2)
  2205. X--------------------------------------------------------------------------*/
  2206. Xint
  2207. Xstep(p1, p2)
  2208. Xregister char *p1, *p2;
  2209. X{
  2210. X    register c;
  2211. X
  2212. X    if (circf)
  2213. X    {
  2214. X        match_start = p1;
  2215. X        return (advance(p1, p2));
  2216. X    }
  2217. X    /* fast check for first character */
  2218. X    if (*p2 == CCHR)
  2219. X    {
  2220. X        c = p2[1];
  2221. X        do
  2222. X        {
  2223. X            if (*p1 != c)
  2224. X                continue;
  2225. X            if (advance(p1, p2))
  2226. X            {
  2227. X                match_start = p1;
  2228. X                return (1);
  2229. X            }
  2230. X        }
  2231. X        while (*p1++);
  2232. X        return (0);
  2233. X    }
  2234. X    /* regular algorithm */
  2235. X    do
  2236. X    {
  2237. X        if (advance(p1, p2))
  2238. X        {
  2239. X            match_start = p1;
  2240. X            return (1);
  2241. X        }
  2242. X    }
  2243. X    while (*p1++);
  2244. X    return (0);
  2245. X}                             /* end of step */
  2246. X
  2247. X/*+-------------------------------------------------------------------------
  2248. X    advance(lp,ep)
  2249. X--------------------------------------------------------------------------*/
  2250. Xint
  2251. Xadvance(lp, ep)
  2252. Xregister char *lp, *ep;
  2253. X{
  2254. X    register char *curlp;
  2255. X    char c;
  2256. X    char *bbeg;
  2257. X    int ct;
  2258. X
  2259. X    while (1)
  2260. X        switch (*ep++)
  2261. X        {
  2262. X
  2263. X            case CCHR:
  2264. X                if (*ep++ == *lp++)
  2265. X                    continue;
  2266. X                return (0);
  2267. X
  2268. X            case CDOT:
  2269. X                if (*lp++)
  2270. X                    continue;
  2271. X                return (0);
  2272. X
  2273. X            case CDOL:
  2274. X                if (*lp == 0)
  2275. X                    continue;
  2276. X                return (0);
  2277. X
  2278. X            case CCEOF:
  2279. X                match_end = lp;
  2280. X                return (1);
  2281. X
  2282. X            case CCL:
  2283. X                c = *lp++ & 0177;
  2284. X                if (ISTHERE(c))
  2285. X                {
  2286. X                    ep += 16;
  2287. X                    continue;
  2288. X                }
  2289. X                return (0);
  2290. X            case CBRA:
  2291. X                braslist[*ep++] = lp;
  2292. X                continue;
  2293. X
  2294. X            case CKET:
  2295. X                braelist[*ep++] = lp;
  2296. X                continue;
  2297. X
  2298. X            case CCHR | RNGE:
  2299. X                c = *ep++;
  2300. X                getrnge(ep);
  2301. X                while (low--)
  2302. X                    if (*lp++ != c)
  2303. X                        return (0);
  2304. X                curlp = lp;
  2305. X                while (size--)
  2306. X                    if (*lp++ != c)
  2307. X                        break;
  2308. X                if (size < 0)
  2309. X                    lp++;
  2310. X                ep += 2;
  2311. X                goto star;
  2312. X
  2313. X            case CDOT | RNGE:
  2314. X                getrnge(ep);
  2315. X                while (low--)
  2316. X                    if (*lp++ == '\0')
  2317. X                        return (0);
  2318. X                curlp = lp;
  2319. X                while (size--)
  2320. X                    if (*lp++ == '\0')
  2321. X                        break;
  2322. X                if (size < 0)
  2323. X                    lp++;
  2324. X                ep += 2;
  2325. X                goto star;
  2326. X
  2327. X            case CCL | RNGE:
  2328. X                getrnge(ep + 16);
  2329. X                while (low--)
  2330. X                {
  2331. X                    c = *lp++ & 0177;
  2332. X                    if (!ISTHERE(c))
  2333. X                        return (0);
  2334. X                }
  2335. X                curlp = lp;
  2336. X                while (size--)
  2337. X                {
  2338. X                    c = *lp++ & 0177;
  2339. X                    if (!ISTHERE(c))
  2340. X                        break;
  2341. X                }
  2342. X                if (size < 0)
  2343. X                    lp++;
  2344. X                ep += 18;     /* 16 + 2 */
  2345. X                goto star;
  2346. X
  2347. X            case CBACK:
  2348. X                bbeg = braslist[*ep];
  2349. X                ct = braelist[*ep++] - bbeg;
  2350. X
  2351. X                if (ecmp(bbeg, lp, ct))
  2352. X                {
  2353. X                    lp += ct;
  2354. X                    continue;
  2355. X                }
  2356. X                return (0);
  2357. X
  2358. X            case CBACK | STAR:
  2359. X                bbeg = braslist[*ep];
  2360. X                ct = braelist[*ep++] - bbeg;
  2361. X                curlp = lp;
  2362. X                while (ecmp(bbeg, lp, ct))
  2363. X                    lp += ct;
  2364. X
  2365. X                while (lp >= curlp)
  2366. X                {
  2367. X                    if (advance(lp, ep))
  2368. X                        return (1);
  2369. X                    lp -= ct;
  2370. X                }
  2371. X                return (0);
  2372. X
  2373. X            case CDOT | STAR:
  2374. X                curlp = lp;
  2375. X                while (*lp++) ;
  2376. X                goto star;
  2377. X
  2378. X            case CCHR | STAR:
  2379. X                curlp = lp;
  2380. X                while (*lp++ == *ep) ;
  2381. X                ep++;
  2382. X                goto star;
  2383. X
  2384. X            case CCL | STAR:
  2385. X                curlp = lp;
  2386. X                do
  2387. X                {
  2388. X                    c = *lp++ & 0177;
  2389. X                }
  2390. X                while (ISTHERE(c));
  2391. X                ep += 16;
  2392. X                goto star;
  2393. X
  2394. X              star:
  2395. X                do
  2396. X                {
  2397. X                    if (--lp == locs)
  2398. X                        break;
  2399. X                    if (advance(lp, ep))
  2400. X                        return (1);
  2401. X                }
  2402. X                while (lp > curlp);
  2403. X                return (0);
  2404. X
  2405. X        }
  2406. X}                             /* end of advance */
  2407. X
  2408. X/*+-------------------------------------------------------------------------
  2409. X    getrnge(regexp)
  2410. X--------------------------------------------------------------------------*/
  2411. Xvoid
  2412. Xgetrnge(regexp)
  2413. Xregister char *regexp;
  2414. X{
  2415. X    low = *regexp++ & 0377;
  2416. X    size = ((*regexp & 0377) == 255) ? 20000 : (*regexp & 0377) - low;
  2417. X}                             /* end of getrnge */
  2418. X
  2419. X/*+-------------------------------------------------------------------------
  2420. X    ecmp(a,b,count)
  2421. X--------------------------------------------------------------------------*/
  2422. Xint
  2423. Xecmp(a, b, count)
  2424. Xregister char *a, *b;
  2425. Xregister count;
  2426. X{
  2427. X    while (count--)
  2428. X        if (*a++ != *b++)
  2429. X            return (0);
  2430. X    return (1);
  2431. X}                             /* end of ecmp */
  2432. X
  2433. X/*+-------------------------------------------------------------------------
  2434. X    itmp = regexp_compile(regexp,cmpbuf,cmpbuf_size,emsg)
  2435. X
  2436. Xreturns 0 if no compile error,
  2437. Xelse error occurred (*emsg points to error message text)
  2438. X--------------------------------------------------------------------------*/
  2439. Xint
  2440. Xregexp_compile(regexp, cmpbuf, cmpbuf_size, emsg)
  2441. Xchar *regexp;
  2442. Xchar *cmpbuf;
  2443. Xint cmpbuf_size;
  2444. Xchar **emsg;
  2445. X{
  2446. X    register int itmp;
  2447. X    static char errm[40];
  2448. X
  2449. X    if (itmp = setjmp(compile_error_jmpbuf))
  2450. X    {
  2451. X        switch (itmp)
  2452. X        {
  2453. X            case 11:
  2454. X                *emsg = "Range endpoint too large";
  2455. X                break;
  2456. X            case 16:
  2457. X                *emsg = "Bad number";
  2458. X                break;
  2459. X            case 25:
  2460. X                *emsg = "\"\\digit\" out of range";
  2461. X                break;
  2462. X            case 36:
  2463. X                *emsg = "Illegal or missing delimiter";
  2464. X                break;
  2465. X            case 41:
  2466. X                *emsg = "No previous regular expression";
  2467. X                break;
  2468. X            case 42:
  2469. X                *emsg = "More \\)'s than \\('s in regular expression";
  2470. X                break;
  2471. X            case 43:
  2472. X                *emsg = "More \\('s than \\)'s in regular expression";
  2473. X                break;
  2474. X            case 44:
  2475. X                *emsg = "More than 2 numbers in \\{ \\}";
  2476. X                break;
  2477. X            case 45:
  2478. X                *emsg = "} expected after \\";
  2479. X                break;
  2480. X            case 46:
  2481. X                *emsg = "First number exceeds second in \\{ \\}";
  2482. X                break;
  2483. X            case 49:
  2484. X                *emsg = "[] imbalance";
  2485. X                break;
  2486. X            case 50:
  2487. X                *emsg = "Regular expression too complex";
  2488. X                break;
  2489. X            default:
  2490. X                sprintf(errm, "Unknown regexp compile error %d", itmp);
  2491. X                *emsg = errm;
  2492. X                break;
  2493. X        }
  2494. X        return (itmp);
  2495. X    }
  2496. X
  2497. X    compile(regexp, cmpbuf, cmpbuf + cmpbuf_size, 0);
  2498. X    return (0);
  2499. X}                             /* end of regexp_compile */
  2500. X
  2501. X/*+-------------------------------------------------------------------------
  2502. X    regexp_scan(cmpbuf,str_to_search,&match,&matchlen)
  2503. Xreturn 1 if string match found, else 0
  2504. Xif string matches, match receives pointer to first byte, matchlen = length
  2505. Xof matching string
  2506. X--------------------------------------------------------------------------*/
  2507. Xregexp_scan(cmpbuf, str_to_search, match, matchlen)
  2508. Xchar *cmpbuf;
  2509. Xchar *str_to_search;
  2510. Xchar **match;
  2511. Xint *matchlen;
  2512. X{
  2513. X    register int itmp = step(str_to_search, cmpbuf);
  2514. X
  2515. X    if (itmp)
  2516. X    {
  2517. X        *match = match_start;
  2518. X        *matchlen = (int)(match_end - match_start);
  2519. X    }
  2520. X    return (itmp);
  2521. X}                             /* end of regexp_scan */
  2522. X
  2523. X/*+-------------------------------------------------------------------------
  2524. X    regexp_operation(match_str,regexp_str,rtn_value)
  2525. X
  2526. Xone stop operation used by procedure language:
  2527. Xdetermine if 'match_str' matches 'regexp_str', returning the index of
  2528. Xthe match in *rtn_value and setting #I0 to the length of the match
  2529. X
  2530. Xreturns 0 if no error, else eFATAL_ALREADY after printing the error message
  2531. X--------------------------------------------------------------------------*/
  2532. Xint
  2533. Xregexp_operation(match_str, regexp_str, rtn_value)
  2534. Xchar *match_str;
  2535. Xchar *regexp_str;
  2536. Xlong *rtn_value;
  2537. X{
  2538. X#define CMPBUF_SIZE    512
  2539. X    char cmpbuf[CMPBUF_SIZE];
  2540. X    char *emsg;
  2541. X    char *match;
  2542. X    int matchlen;
  2543. X
  2544. X    if (regexp_compile(regexp_str, cmpbuf, sizeof(cmpbuf), &emsg))
  2545. X    {
  2546. X        pprintf("regexp compile error: %s\n", emsg);
  2547. X        return (eFATAL_ALREADY);
  2548. X    }
  2549. X
  2550. X    if (regexp_scan(cmpbuf, match_str, &match, &matchlen))
  2551. X    {
  2552. X        *rtn_value = (long)(match - match_str);
  2553. X        iv[0] = (long)matchlen;
  2554. X        if (proc_level && proc_trace)
  2555. X            pprintf("%match set $i00 = %ld\n", iv[0]);
  2556. X    }
  2557. X    else
  2558. X        *rtn_value = -1L;
  2559. X
  2560. X    return (0);
  2561. X}                             /* end of regexp_operation */
  2562. X
  2563. X/* vi: set tabstop=4 shiftwidth=4: */
  2564. X/* end of regexp.c */
  2565. END_OF_FILE
  2566.   if test 12818 -ne `wc -c <'ecu330/regexp.c'`; then
  2567.     echo shar: \"'ecu330/regexp.c'\" unpacked with wrong size!
  2568.   fi
  2569.   # end of 'ecu330/regexp.c'
  2570. fi
  2571. echo shar: End of archive 27 \(of 37\).
  2572. cp /dev/null ark27isdone
  2573. MISSING=""
  2574. for I in 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 ; do
  2575.     if test ! -f ark${I}isdone ; then
  2576.     MISSING="${MISSING} ${I}"
  2577.     fi
  2578. done
  2579. if test "${MISSING}" = "" ; then
  2580.     echo You have unpacked all 37 archives.
  2581.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2582. else
  2583.     echo You still must unpack the following archives:
  2584.     echo "        " ${MISSING}
  2585. fi
  2586. exit 0
  2587. exit 0 # Just in case...
  2588.