home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume32 / ecu / part16 < prev    next >
Text File  |  1992-09-14  |  58KB  |  2,565 lines

  1. Newsgroups: comp.sources.misc
  2. From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  3. Subject:  v32i051:  ecu - ECU Asynchronous Communications v3.20, Part16/40
  4. Message-ID: <1992Sep13.153623.5576@sparky.imd.sterling.com>
  5. X-Md4-Signature: 771020a5e60609547dc6deacc2689351
  6. Date: Sun, 13 Sep 1992 15:36:23 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
  10. Posting-number: Volume 32, Issue 51
  11. Archive-name: ecu/part16
  12. Environment: SCO,XENIX,ISC,SUNOS,SYSVR4,HDB,Curses
  13. Supersedes: ecu: Volume 21, Issue 53-89
  14.  
  15. ---- Cut Here and feed the following to sh ----
  16. #!/bin/sh
  17. # this is ecu320.16 (part 16 of ecu320)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file fasiintf.c continued
  20. #
  21. if test ! -r _shar_seq_.tmp; then
  22.     echo 'Please unpack part 1 first!'
  23.     exit 1
  24. fi
  25. (read Scheck
  26.  if test "$Scheck" != 16; then
  27.     echo Please unpack part "$Scheck" next!
  28.     exit 1
  29.  else
  30.     exit 0
  31.  fi
  32. ) < _shar_seq_.tmp || exit 1
  33. if test ! -f _shar_wnt_.tmp; then
  34.     echo 'x - still skipping fasiintf.c'
  35. else
  36. echo 'x - continuing file fasiintf.c'
  37. sed 's/^X//' << 'SHAR_EOF' >> 'fasiintf.c' &&
  38. X    return(txt);
  39. X
  40. X}    /* end of msr_text */
  41. X
  42. X/*+-------------------------------------------------------------------------
  43. X    mcr_text(mcr)
  44. X--------------------------------------------------------------------------*/
  45. Xchar *
  46. Xmcr_text(mcr)
  47. Xuchar mcr;
  48. X{
  49. X    static char txt[32];
  50. X
  51. X    txt[0] = '*';
  52. X    txt[1] = 0;
  53. X    if(!mcr)
  54. X    {
  55. X        strcat(txt,"NULL*");
  56. X        return(txt);
  57. X    }
  58. X    if(mcr & MC_SET_DTR) strcat(txt,"DTR*");
  59. X    if(mcr & MC_SET_RTS) strcat(txt,"RTS*");
  60. X    if(mcr & MC_SET_OUT1) strcat(txt,"OUT1*");
  61. X    if(mcr & MC_SET_OUT2) strcat(txt,"OUT2*");
  62. X    if(mcr & MC_SET_LOOPBACK) strcat(txt,"LOOPBACK*");
  63. X    return(txt);
  64. X
  65. X}    /* end of mcr_text */
  66. X
  67. X/*+-------------------------------------------------------------------------
  68. X    lcr_text(lcr)
  69. X--------------------------------------------------------------------------*/
  70. Xchar *
  71. Xlcr_text(lcr)
  72. Xuchar lcr;
  73. X{
  74. X    static char txt[64];
  75. X
  76. X    sprintf(txt,"*%ddb*",(lcr & LC_WORDLEN_MASK) + 5);
  77. X    strcat(txt,(lcr & LC_STOPBITS_LONG) ? "2" : "1");
  78. X    strcat(txt,"sb*");
  79. X    if(lcr & LC_ENABLE_PARITY)
  80. X    {
  81. X        strcat(txt,"PARITY*");
  82. X        if(lcr & LC_STICK_PARITY)
  83. X            strcat(txt,(lcr & LC_EVEN_PARITY) ? "MARK*" : "SPACE*");
  84. X        else
  85. X            strcat(txt,(lcr & LC_EVEN_PARITY) ? "EVEN*" : "ODD*" );
  86. X    }
  87. X    else
  88. X        strcat(txt,"NOPAR*");
  89. X    if(lcr & LC_SET_BREAK_LEVEL)
  90. X        strcat(txt,"SETBREAK*");
  91. X    if(lcr & LC_ENABLE_DIVISOR)
  92. X        strcat(txt,"ENABDIV*");
  93. X    return(txt);
  94. X
  95. X}    /* end of lcr_text */
  96. X
  97. X/*+-------------------------------------------------------------------------
  98. X    ier_text(ier)
  99. X--------------------------------------------------------------------------*/
  100. Xchar *
  101. Xier_text(ier)
  102. Xuchar ier;
  103. X{
  104. X    static char txt[32];
  105. X
  106. X    txt[0] = '*';
  107. X    txt[1] = 0;
  108. X    if(!ier)
  109. X    {
  110. X        strcat(txt,"NULL*");
  111. X        return(txt);
  112. X    }
  113. X    if(ier & IE_RECV_DATA_AVAILABLE) strcat(txt,"RDAV*");
  114. X    if(ier & IE_XMIT_HOLDING_BUFFER_EMPTY) strcat(txt,"TBMT*");
  115. X    if(ier & IE_LINE_STATUS) strcat(txt,"LS*");
  116. X    if(ier & IE_MODEM_STATUS) strcat(txt,"MS*");
  117. X    return(txt);
  118. X
  119. X}    /* end of ier_text */
  120. X
  121. X/*+-------------------------------------------------------------------------
  122. X    display_fasi(fip)
  123. X--------------------------------------------------------------------------*/
  124. Xvoid
  125. Xdisplay_fasi(fip)
  126. Xstruct fas_info *fip;
  127. X{
  128. X
  129. X    pprintf("base address: %04x irq=%u ",fip->port_0.addr,fip->vec);
  130. X    pputs("device is ");
  131. X    if(fip->device_flags.s & DF_DEVICE_IS_NS16550A)
  132. X        pputs("16550\n");
  133. X    else if(fip->device_flags.s & DF_DEVICE_IS_I82510)
  134. X        pputs("82510\n");
  135. X    else
  136. X        pputs("16450\n");
  137. X    pprintf("MSR=%s   ",msr_text(fip->msr));
  138. X    pprintf("MCR=%s\n",mcr_text(fip->mcr));
  139. X    pprintf("LCR=%s   ",lcr_text(fip->lcr));
  140. X    pprintf("IER=%s\n",ier_text(fip->ier));
  141. X    pprintf("recv ring cnt=%u  ",fip->recv_ring_cnt);
  142. X    pprintf("xmit ring cnt=%u  ",fip->xmit_ring_cnt);
  143. X    pprintf("xmit fifo size=%u\n",fip->xmit_fifo_size);
  144. X    pprintf("characters received    =%12lu\n",fip->characters_received);
  145. X    pprintf("characters transmitted =%12lu\n",fip->characters_transmitted);
  146. X    pprintf("modem status events    =%12lu\n",fip->modem_status_events);
  147. X    pprintf("overrun errors=%lu  ",fip->overrun_errors);
  148. X    pprintf("framing errors=%lu  ",fip->framing_errors);
  149. X    pprintf("parity errors=%lu\n",fip->parity_errors);
  150. X    pprintf("rings detected=%lu  ",fip->rings_detected);
  151. X    pprintf("breaks detected=%lu\n",fip->breaks_detected);
  152. X    pprintf("xmtr flow off XON/XOFF=%lu  RTS/CTS=%lu\n",
  153. X        fip->xmtr_sw_flow_count,fip->xmtr_hw_flow_count);
  154. X    pprintf("rcvr flow off XON/XOFF=%lu  RTS/CTS=%lu\n",
  155. X        fip->rcvr_sw_flow_count,fip->rcvr_hw_flow_count);
  156. X
  157. X}    /* end of display_fasi */
  158. X
  159. X/*+-------------------------------------------------------------------------
  160. X    fasi_msr() - return modem status register contents
  161. X--------------------------------------------------------------------------*/
  162. Xuchar
  163. Xfasi_msr()
  164. X{
  165. X    ulong ltmp = 0;
  166. X
  167. X    return((uchar)ioctl(shm->Liofd,FASIC_MCR,(char *)<mp));
  168. X    return(ltmp);
  169. X}    /* end of fasi_msr */
  170. X
  171. X/*+-------------------------------------------------------------------------
  172. X    fasi_line_errors() - return UART error count
  173. X--------------------------------------------------------------------------*/
  174. Xulong
  175. Xfasi_line_errors()
  176. X{
  177. X    struct fas_info finfo,*fip = &finfo;
  178. X
  179. X    memset((char *)fip,0,sizeof(*fip));
  180. X
  181. X    if((ioctl(shm->Liofd,FASIC_SIP,(char *)fip)) < 0)
  182. X        return(0);
  183. X    return(fip->parity_errors + fip->framing_errors + fip->overrun_errors);
  184. X
  185. X}    /* end of fasi_line_errors */
  186. X
  187. X/*+-------------------------------------------------------------------------
  188. X    fasi_rings_detected() - return number of RI trailing edges
  189. X--------------------------------------------------------------------------*/
  190. Xulong
  191. Xfasi_rings_detected()
  192. X{
  193. X    struct fas_info finfo,*fip = &finfo;
  194. X
  195. X    memset((char *)fip,0,sizeof(*fip));
  196. X
  197. X    if((ioctl(shm->Liofd,FASIC_SIP,(char *)fip)) < 0)
  198. X        return(0);
  199. X    return(fip->rings_detected);
  200. X
  201. X}    /* end of fasi_rings_detected */
  202. X
  203. X/*+-------------------------------------------------------------------------
  204. X    fasi_breaks_detected() - return number of BREAKs detected
  205. X--------------------------------------------------------------------------*/
  206. Xulong
  207. Xfasi_breaks_detected()
  208. X{
  209. X    struct fas_info finfo,*fip = &finfo;
  210. X
  211. X    memset((char *)fip,0,sizeof(*fip));
  212. X
  213. X    if((ioctl(shm->Liofd,FASIC_SIP,(char *)fip)) < 0)
  214. X        return(0);
  215. X    return(fip->breaks_detected);
  216. X
  217. X}    /* end of fasi_breaks_detected */
  218. X
  219. X/*+-------------------------------------------------------------------------
  220. X    pcmd_fasi(param)
  221. Xfasi [-switches] <str-cmd>>
  222. X
  223. Xwhere <str-cmd> is 'd[isplay]'
  224. X                or 'r[eset]'
  225. X
  226. Xfasi 'd'
  227. Xfasi 'r'
  228. X--------------------------------------------------------------------------*/
  229. Xint
  230. Xpcmd_fasi(param)
  231. XESD *param;
  232. X{
  233. X    int erc;
  234. X    char switches[8];
  235. X    ESD *tesd = (ESD *)0;
  236. X    struct fas_info finfo,*fip = &finfo;
  237. X    char ident_str[128];
  238. X
  239. X    memset((char *)fip,0,sizeof(*fip));
  240. X
  241. X    get_switches(param,switches,sizeof(switches));
  242. X    if(!(tesd = esdalloc(64)))
  243. X        return(eNoMemory);
  244. X    if(!(erc = gstr(param,tesd,1)))
  245. X    {
  246. X        skip_cmd_break(tesd);
  247. X        switch(to_lower(*(tesd->pb + tesd->index)))
  248. X        {
  249. X            case 'd':    /* display */
  250. X                if((ioctl(shm->Liofd,FASIC_SIP,(char *)fip)) < 0)
  251. X                {
  252. X                    pperror("ioctl FASIC_SIP");
  253. X                    erc = eFATAL_ALREADY;
  254. X                }
  255. X                else
  256. X                    display_fasi(fip);
  257. X                if((ioctl(shm->Liofd,FASIC_DVR_IDENT,ident_str)) < 0)
  258. X                {
  259. X                    pperror("ioctl FASIC_DVR_IDENT");
  260. X                    erc = eFATAL_ALREADY;
  261. X                }
  262. X                else
  263. X                    pprintf("driver:  '%s'\n",ident_str);
  264. X                if((ioctl(shm->Liofd,FASIC_SPACE_IDENT,ident_str)) < 0)
  265. X                {
  266. X                    pperror("ioctl FASIC_SPACE_IDENT");
  267. X                    erc = eFATAL_ALREADY;
  268. X                }
  269. X                else
  270. X                    pprintf("space.c: '%s'\n",ident_str);
  271. X                break;
  272. X
  273. X            case 'r':    /* reset */
  274. X                if((ioctl(shm->Liofd,FASIC_RESET_STAT,(char *)0)) < 0)
  275. X                {
  276. X                    pperror("ioctl FASIC_RESET_STAT");
  277. X                    erc = eFATAL_ALREADY;
  278. X                }
  279. X                else if(proctrace)
  280. X                    pputs("statistics reset\n");
  281. X                break;
  282. X
  283. X            default:
  284. X                pputs("invalid subcommand '");
  285. X                pputs(tesd->pb);
  286. X                pputs("'\n");
  287. X                erc = eFATAL_ALREADY;
  288. X                break;
  289. X        }
  290. X    }
  291. X
  292. X    if(tesd)
  293. X        esdfree(tesd);
  294. X    return(erc);
  295. X
  296. X}    /* end of pcmd_fasi */
  297. X
  298. X/*+-------------------------------------------------------------------------
  299. X    icmd_fasi(narg,arg)
  300. X--------------------------------------------------------------------------*/
  301. Xvoid
  302. Xicmd_fasi(narg,arg)
  303. Xint narg;
  304. Xchar **arg;
  305. X{
  306. X    struct fas_info finfo,*fip = &finfo;
  307. X    char ident_str[128];
  308. X
  309. X    memset((char *)fip,0,sizeof(*fip));
  310. X
  311. X    if((narg > 1) && (to_lower(*arg[1]) == 'r'))
  312. X    {
  313. X        if((ioctl(shm->Liofd,FASIC_RESET_STAT,(char *)0)) < 0)
  314. X        {
  315. X            pperror("   ioctl FASIC_RESET_STAT");
  316. X            return;
  317. X        }
  318. X        ff(se,"  fasi statistics reset\r\n");
  319. X    }
  320. X    else
  321. X    {
  322. X        if((ioctl(shm->Liofd,FASIC_SIP,(char *)fip)) < 0)
  323. X        {
  324. X            pperror("   ioctl FASIC_SIP");
  325. X            return;
  326. X        }
  327. X        ff(se,"\r\n");
  328. X        display_fasi(fip);
  329. X        if((ioctl(shm->Liofd,FASIC_DVR_IDENT,ident_str)) < 0)
  330. X            pperror("ioctl FASIC_DVR_IDENT");
  331. X        else
  332. X            pprintf("driver:  '%s'\n",ident_str);
  333. X        if((ioctl(shm->Liofd,FASIC_SPACE_IDENT,ident_str)) < 0)
  334. X            pperror("ioctl FASIC_SPACE_IDENT");
  335. X        else
  336. X            pprintf("space.c: '%s'\n",ident_str);
  337. X    }
  338. X
  339. X}    /* end of icmd_fasi */
  340. X
  341. X#endif /* FASI */
  342. X
  343. X/* vi: set tabstop=4 shiftwidth=4: */
  344. X/* end of fasiintf.c */
  345. SHAR_EOF
  346. echo 'File fasiintf.c is complete' &&
  347. chmod 0644 fasiintf.c ||
  348. echo 'restore of fasiintf.c failed'
  349. Wc_c="`wc -c < 'fasiintf.c'`"
  350. test 9450 -eq "$Wc_c" ||
  351.     echo 'fasiintf.c: original size 9450, current size' "$Wc_c"
  352. rm -f _shar_wnt_.tmp
  353. fi
  354. # ============= feval.c ==============
  355. if test -f 'feval.c' -a X"$1" != X"-c"; then
  356.     echo 'x - skipping feval.c (File already exists)'
  357.     rm -f _shar_wnt_.tmp
  358. else
  359. > _shar_wnt_.tmp
  360. echo 'x - extracting feval.c (Text)'
  361. sed 's/^X//' << 'SHAR_EOF' > 'feval.c' &&
  362. X/*+-------------------------------------------------------------------------
  363. X    feval.c - integer and string function evaluation
  364. X    wht@n4hgf.Mt-Park.GA.US
  365. X
  366. X    feval_int(param,&int_returned) where 'int' here means long ECU $i int
  367. X    feval_str(param,&esd_to_be_plugged)
  368. X
  369. X  These routines are called with param.index as follows:
  370. X
  371. X         !nnnnn       nnn is name of function
  372. X          ^
  373. X          |
  374. X
  375. X  Defined functions:
  376. X    feval_int(param,value)
  377. X    feval_str(param,result_esd)
  378. X    strfunc_left(param,scratch_esd,result_esd)
  379. X    strfunc_right(param,scratch_esd,result_esd)
  380. X
  381. X--------------------------------------------------------------------------*/
  382. X/*+:EDITS:*/
  383. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  384. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  385. X/*:05-07-1992-15:04-wht@n4hgf-bug in FIconn code */
  386. X/*:04-25-1992-14:28-wht@n4hgf-%conn returns -1 if no line open */
  387. X/*:04-25-1992-13:19-wht@n4hgf-%line succeeds even if line not open */
  388. X/*:03-01-1992-13:28-wht@n4hgf-come up to modern times ... enum for FI/FS  */
  389. X/*:02-14-1992-16:37-wht@n4hgf-add uname */
  390. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  391. X/*:07-14-1991-18:18-wht@n4hgf-new ttygets functions */
  392. X/*:06-29-1991-16:33-wht@n4hgf-use cuserid() instead of getlogin() */
  393. X/*:03-16-1991-15:23-wht@n4hgf-add %nice */
  394. X/*:01-31-1991-16:10-wht@n4hgf-was freeing tesd1 twice in feval_str */
  395. X/*:12-24-1990-04:31-wht@n4hgf-experimental fasi driver functions */
  396. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  397. X
  398. X#include "ecu.h"
  399. X#include "ecuerror.h"
  400. X#include "esd.h"
  401. X#include "proc.h"
  402. X#include "var.h"
  403. X#include "ecutty.h"
  404. X#include <sys/utsname.h>
  405. X
  406. X#if defined(FASI)
  407. Xchar *msr_text();
  408. X#endif
  409. X
  410. Xenum FI_codes
  411. X{
  412. X    FIZERO,
  413. X    FIargc,
  414. X    FIbaud,
  415. X    FIbrdet,
  416. X    FIcolors,
  417. X    FIcols,
  418. X    FIconn,
  419. X    FIcsec,
  420. X    FIctoi,
  421. X    FIcurx,
  422. X    FIcury,
  423. X    FIesecs,
  424. X    FIfasi,
  425. X    FIfatime,
  426. X    FIfmode,
  427. X    FIfmtime,
  428. X    FIfsize,
  429. X    FIftell,
  430. X    FIgid,
  431. X    FIinstr,
  432. X    FIisalnum,
  433. X    FIisalpha,
  434. X    FIisascii,
  435. X    FIischr,
  436. X    FIiscntrl,
  437. X    FIisdigit,
  438. X    FIisdir,
  439. X    FIisgraph,
  440. X    FIislower,
  441. X    FIisprint,
  442. X    FIispunct,
  443. X    FIisreg,
  444. X    FIisspace,
  445. X    FIisupper,
  446. X    FIisxdigit,
  447. X    FIlen,
  448. X    FIlgetc,
  449. X    FIlines,
  450. X    FIlnerr,
  451. X    FImatch,
  452. X    FImhack,
  453. X    FImsr,
  454. X    FInice,
  455. X    FIpid,
  456. X    FIrchr,
  457. X    FIrchrc,
  458. X    FIridet,
  459. X    FIrinstr,
  460. X    FIshmid,
  461. X    FIstoi,
  462. X    FIuid,
  463. X    FIxchr,
  464. X    FIxchrc,
  465. X    FI____end
  466. X};
  467. X
  468. XKEYTAB feval_int_tbl[] =
  469. X{
  470. X    {"argc",FIargc},
  471. X    {"baud",FIbaud},
  472. X#if defined(FASI)
  473. X    {"brdet",FIbrdet},
  474. X#endif
  475. X    {"colors",FIcolors},
  476. X    {"cols",FIcols},
  477. X    {"conn",FIconn},
  478. X    {"csec",FIcsec},
  479. X    {"ctoi",FIctoi},
  480. X    {"curx",FIcurx},
  481. X    {"cury",FIcury},
  482. X    {"esecs",FIesecs},
  483. X    {"fasi",FIfasi},
  484. X    {"fatime",FIfatime},
  485. X    {"fmode",FIfmode},
  486. X    {"fmtime",FIfmtime},
  487. X    {"fsize",FIfsize},
  488. X    {"ftell",FIftell},
  489. X    {"gid",FIgid},
  490. X    {"instr",FIinstr},
  491. X    {"isalnum",FIisalnum},
  492. X    {"isalpha",FIisalpha},
  493. X    {"isalpha",FIisalpha},
  494. X    {"isascii",FIisascii},
  495. X    {"ischr",FIischr},
  496. X    {"iscntrl",FIiscntrl},
  497. X    {"isdigit",FIisdigit},
  498. X    {"isdir",FIisdir},
  499. X    {"isgraph",FIisgraph},
  500. X    {"islower",FIislower},
  501. X    {"isprint",FIisprint},
  502. X    {"ispunct",FIispunct},
  503. X    {"isreg",FIisreg},
  504. X    {"isspace",FIisspace},
  505. X    {"isupper",FIisupper},
  506. X    {"isxdigit",FIisxdigit},
  507. X    {"len",FIlen},
  508. X#if defined(FASI)
  509. X    {"lnerr",FIlnerr},
  510. X#endif
  511. X    {"lgetc",FIlgetc},
  512. X    {"lines",FIlines},
  513. X    {"match",FImatch},
  514. X    {"mhack",FImhack},
  515. X#if defined(FASI)
  516. X    {"msr",FImsr},
  517. X#endif
  518. X    {"nice",FInice},
  519. X    {"pid",FIpid},
  520. X    {"rchr",FIrchr},
  521. X    {"rchrc",FIrchrc},
  522. X#if defined(FASI)
  523. X    {"ridet",FIridet},
  524. X#endif
  525. X    {"rinstr",FIrinstr},
  526. X    {"shmid",FIshmid},
  527. X    {"stoi",FIstoi},
  528. X    {"uid",FIuid},
  529. X    {"xchr",FIxchr},
  530. X    {"xchrc",FIxchrc},
  531. X    {(char *)0,0}
  532. X};
  533. X
  534. Xenum FS_codes
  535. X{
  536. X    FSZERO,
  537. X    FSargv,
  538. X    FSbasename,
  539. X    FScgetc,
  540. X    FScgets,
  541. X    FSchr,
  542. X    FSdate,
  543. X    FSdatez,
  544. X    FSday,
  545. X    FSdayz,
  546. X    FSdir,
  547. X    FSdirpart,
  548. X    FSedate,
  549. X    FSenvvar,
  550. X    FSerrstr,
  551. X    FSetime,
  552. X    FSfilepart,
  553. X    FSfmodestr,
  554. X    FSitos,
  555. X    FSleft,
  556. X    FSline,
  557. X    FSlogname,
  558. X    FSmid,
  559. X    FSmonth,
  560. X    FSmonthz,
  561. X    FSmsrtext,
  562. X    FSrdesc,
  563. X    FSright,
  564. X    FSrname,
  565. X    FSrtel,
  566. X    FSscreen,
  567. X    FStime,
  568. X    FStimes,
  569. X    FStimez,
  570. X    FStimezs,
  571. X    FStty,
  572. X    FSuname,
  573. X    FS____end
  574. X};
  575. X
  576. XKEYTAB feval_str_tbl[] =
  577. X{
  578. X    {"argv",FSargv},
  579. X    {"basename",FSbasename},
  580. X    {"cgetc",FScgetc},
  581. X    {"cgets",FScgets},
  582. X    {"chr",FSchr},
  583. X    {"date",FSdate},
  584. X    {"datez",FSdatez},
  585. X    {"day",FSday},
  586. X    {"dir",FSdir},
  587. X    {"dirpart",FSdirpart},
  588. X    {"edate",FSedate},
  589. X    {"envvar",FSenvvar},
  590. X    {"errstr",FSerrstr},
  591. X    {"etime",FSetime},
  592. X    {"filepart",FSfilepart},
  593. X    {"fmodestr",FSfmodestr},
  594. X    {"getenv",FSenvvar},
  595. X    {"itos",FSitos},
  596. X    {"left",FSleft},
  597. X    {"line",FSline},
  598. X    {"logname",FSlogname},
  599. X    {"mid",FSmid},
  600. X    {"month",FSmonth},
  601. X#if defined(FASI)
  602. X    {"msrtext",FSmsrtext},
  603. X#endif
  604. X    {"rdesc",FSrdesc},
  605. X    {"right",FSright},
  606. X    {"rname",FSrname},
  607. X    {"rtelno",FSrtel},
  608. X    {"screen",FSscreen},
  609. X    {"time",FStime},
  610. X    {"times",FStimes},
  611. X    {"timez",FStimez},
  612. X    {"timezs",FStimezs},
  613. X    {"tty",FStty},
  614. X    {"uname",FSuname},
  615. X    {(char *)0,0}
  616. X};
  617. X
  618. Xextern char curr_dir[];
  619. Xextern int proctrace;
  620. Xextern PCB *pcb_stack[];
  621. Xextern struct timeb starting_timeb;
  622. Xextern uint tcap_LINES;
  623. Xextern uint tcap_COLS;
  624. X
  625. Xextern int shm_shmid;
  626. X
  627. Xchar *day_of_week_list = "SunMonTueWedThuFriSat";
  628. Xchar *month_name_list = "JanFebMarAprMayJunJulAugSepOctNovDec";
  629. X
  630. X/*+-------------------------------------------------------------------------
  631. X    erc = feval_int(param,&int_returned);
  632. XFunctions (parameter types are expressed by the usage of variables)
  633. X--------------------------------------------------------------------------*/
  634. Xfeval_int(param,value)
  635. XESD *param;
  636. Xlong *value;
  637. X{
  638. Xregister erc;
  639. Xregister keyword_token;
  640. XESD *tesd1 = (ESD *)0;
  641. XESD *tesd2 = (ESD *)0;
  642. Xulong int1;
  643. Xchar s32[32];
  644. Xstruct timeb now_timeb;
  645. Xint nice();
  646. X
  647. X    if(erc = get_alphanum_zstr(param,s32,sizeof(s32)))
  648. X    {
  649. X        erc = eInvalidFunction;
  650. X        goto RETURN;
  651. X    }
  652. X
  653. X    keyword_token = keyword_lookup(feval_int_tbl,s32);
  654. X    switch(keyword_token)
  655. X    {
  656. X/* LEN($S0)         length of $S0 */
  657. X    case FIlen:
  658. X        if(!(tesd1 = esdalloc(256)))
  659. X        {
  660. X            erc = eNoMemory;
  661. X            goto RETURN;
  662. X        }
  663. X        if(erc = skip_paren(param,1))
  664. X            goto RETURN;
  665. X        if(erc = gstr(param,tesd1,1))
  666. X            goto RETURN;
  667. X        if(erc = skip_paren(param,0))
  668. X            goto RETURN;
  669. X        *value = (long)tesd1->cb;
  670. X        break;
  671. X
  672. X/* INSTR($S0,$S1)   index of first occurrence of $S1 in $S0, -1 if none */
  673. X    case FIinstr:
  674. X        if(!(tesd1 = esdalloc(256)))
  675. X        {
  676. X            erc = eNoMemory;
  677. X            goto RETURN;
  678. X        }
  679. X        if(!(tesd2 = esdalloc(256)))
  680. X        {
  681. X            erc = eNoMemory;
  682. X            goto RETURN;
  683. X        }
  684. X        if(erc = skip_paren(param,1))
  685. X            goto RETURN;
  686. X        if(erc = gstr(param,tesd1,1))
  687. X            goto RETURN;
  688. X        if(erc = skip_comma(param))
  689. X            goto RETURN;
  690. X        if(erc = gstr(param,tesd2,1))
  691. X            goto RETURN;
  692. X        if(erc = skip_paren(param,0))
  693. X            goto RETURN;
  694. X
  695. X        *value = (long)ulindex(tesd1->pb,tesd2->pb);
  696. X        break;
  697. X
  698. X/* RINSTR($S0,$S1)   index of last occurrence of $S1 in $S0, -1 if none */
  699. X    case FIrinstr:
  700. X        if(!(tesd1 = esdalloc(256)))
  701. X        {
  702. X            erc = eNoMemory;
  703. X            goto RETURN;
  704. X        }
  705. X        if(!(tesd2 = esdalloc(256)))
  706. X        {
  707. X            erc = eNoMemory;
  708. X            goto RETURN;
  709. X        }
  710. X        if(erc = skip_paren(param,1))
  711. X            goto RETURN;
  712. X        if(erc = gstr(param,tesd1,1))
  713. X            goto RETURN;
  714. X        if(erc = skip_comma(param))
  715. X            goto RETURN;
  716. X        if(erc = gstr(param,tesd2,1))
  717. X            goto RETURN;
  718. X        if(erc = skip_paren(param,0))
  719. X            goto RETURN;
  720. X
  721. X        *value = (long)ulrindex(tesd1->pb,tesd2->pb);
  722. X        break;
  723. X
  724. X    case FImatch:
  725. X        if(!(tesd1 = esdalloc(256)))
  726. X        {
  727. X            erc = eNoMemory;
  728. X            goto RETURN;
  729. X        }
  730. X        if(!(tesd2 = esdalloc(256)))
  731. X        {
  732. X            erc = eNoMemory;
  733. X            goto RETURN;
  734. X        }
  735. X        if(erc = skip_paren(param,1))
  736. X            goto RETURN;
  737. X        if(erc = gstr(param,tesd1,1))
  738. X            goto RETURN;
  739. X        if(erc = skip_comma(param))
  740. X            goto RETURN;
  741. X        if(erc = gstr(param,tesd2,1))
  742. X            goto RETURN;
  743. X        if(erc = skip_paren(param,0))
  744. X            goto RETURN;
  745. X
  746. X        erc = regexp_operation(tesd1->pb,tesd2->pb,value);
  747. X        break;
  748. X
  749. X    case FImhack:
  750. X        ftime(&now_timeb);
  751. X        *value = ((now_timeb.time - starting_timeb.time) * 1000) +
  752. X                (now_timeb.millitm - starting_timeb.millitm);
  753. X        erc = 0;
  754. X        break;
  755. X
  756. X    case FIesecs:
  757. X        ftime(&now_timeb);
  758. X        *value = now_timeb.time;
  759. X        erc = 0;
  760. X        break;
  761. X
  762. X    case FIargc:
  763. X        if(!proc_level)
  764. X        {
  765. X            pputs("not executing procedure\n");
  766. X            erc = eFATAL_ALREADY;
  767. X            break;
  768. X        }
  769. X        *value = (long)pcb_stack[proc_level - 1]->argc;
  770. X        break;
  771. X
  772. X    case FIcolors:
  773. X        if(erc = ifunc_colors(value))
  774. X            goto RETURN;
  775. X        break;
  776. X
  777. X    case FIftell:
  778. X        if(erc = ifunc_ftell(param,value))
  779. X            goto RETURN;
  780. X        break;
  781. X
  782. X    case FIfmode:
  783. X        if(erc = ifunc_fmode(param,value))
  784. X            goto RETURN;
  785. X        break;
  786. X
  787. X    case FIfsize:
  788. X        if(erc = ifunc_fsize(param,value))
  789. X            goto RETURN;
  790. X        break;
  791. X
  792. X    case FIfmtime:
  793. X        if(erc = ifunc_fmtime(param,value))
  794. X            goto RETURN;
  795. X        break;
  796. X
  797. X    case FIfatime:
  798. X        if(erc = ifunc_fatime(param,value))
  799. X            goto RETURN;
  800. X        break;
  801. X
  802. X    case FIischr:
  803. X        if(erc = ifunc_ischr(param,value))
  804. X            goto RETURN;
  805. X        break;
  806. X
  807. X    case FIisdir:
  808. X        if(erc = ifunc_isdir(param,value))
  809. X            goto RETURN;
  810. X        break;
  811. X
  812. X    case FIisreg:
  813. X        if(erc = ifunc_isreg(param,value))
  814. X            goto RETURN;
  815. X        break;
  816. X
  817. X    case FIbaud:
  818. X        *value = (long)shm->Lbaud;
  819. X        erc = 0;
  820. X        break;
  821. X
  822. X    case FIpid:
  823. X        *value = (long)getpid();
  824. X        erc = 0;
  825. X        break;
  826. X
  827. X    case FIcsec:
  828. X        *value = (shm->Lconnected) ? shm->Loff_hook_time : -1;
  829. X        erc = 0;
  830. X        break;
  831. X
  832. X    case FIconn:
  833. X        if(shm->Liofd < 0)
  834. X            *value = -1;
  835. X        else
  836. X            *value = (long)(shm->Lconnected) ? (long)shm->Liofd : 0;
  837. X        erc = 0;
  838. X        break;
  839. X
  840. X    case FIxchr:
  841. X        *value = shm->xmit_chars;
  842. X        erc = 0;
  843. X        break;
  844. X
  845. X    case FIxchrc:
  846. X        *value = shm->xmit_chars_this_connect;
  847. X        erc = 0;
  848. X        break;
  849. X
  850. X    case FIrchr:
  851. X        *value = shm->rcvd_chars;
  852. X        erc = 0;
  853. X        break;
  854. X
  855. X    case FIrchrc:
  856. X        *value = shm->rcvd_chars_this_connect;
  857. X        erc = 0;
  858. X        break;
  859. X
  860. X/* LGETC($I0) get char from line, waiting for $I0 msec
  861. Xreturns  character read or -1 if none read in time */
  862. X    case FIlgetc:
  863. X        if(erc = skip_paren(param,1))
  864. X            goto RETURN;
  865. X        if(erc = gint(param,&int1))
  866. X            goto RETURN;
  867. X        if(erc = skip_paren(param,0))
  868. X            goto RETURN;
  869. X        *value = (long)lgetc_timeout(int1);
  870. X        if(zero_length_read_detected)
  871. X        {
  872. X            zero_length_read_detected = 0;
  873. X            erc = eProcAttn_DCDloss;
  874. X        }
  875. X        break;
  876. X
  877. X    case FIctoi:
  878. X        if(!(tesd1 = esdalloc(256)))
  879. X        {
  880. X            erc = eNoMemory;
  881. X            goto RETURN;
  882. X        }
  883. X        if(erc = skip_paren(param,1))
  884. X            goto RETURN;
  885. X        if(erc = gstr(param,tesd1,1))
  886. X            goto RETURN;
  887. X        if(erc = skip_paren(param,0))
  888. X            goto RETURN;
  889. X        if(tesd1->cb == 0)
  890. X            *value = -1;
  891. X        else
  892. X            *value = (long)((unsigned)0xFF & (unsigned)tesd1->pb[0]);
  893. X        break;
  894. X
  895. X    case FIstoi:
  896. X        if(!(tesd1 = esdalloc(256)))
  897. X        {
  898. X            erc = eNoMemory;
  899. X            goto RETURN;
  900. X        }
  901. X        if(erc = skip_paren(param,1))
  902. X            goto RETURN;
  903. X        if(erc = gstr(param,tesd1,1))
  904. X            goto RETURN;
  905. X        if(erc = skip_paren(param,0))
  906. X            goto RETURN;
  907. X
  908. X        tesd1->index = 0;
  909. X        skip_cmd_break(tesd1);
  910. X        *value = 0;
  911. X        gint_constant(tesd1,value);
  912. X        break;
  913. X
  914. X    case FIcurx:
  915. X        *value = (long)shm->cursor_x;
  916. X        break;
  917. X
  918. X    case FIcury:
  919. X        *value = (long)shm->cursor_y;
  920. X        break;
  921. X
  922. X    case FIshmid:
  923. X        *value = (long)shm_shmid;
  924. X        break;
  925. X
  926. X    case FIisalpha:
  927. X    case FIisupper:
  928. X    case FIislower:
  929. X    case FIisdigit:
  930. X    case FIisxdigit:
  931. X    case FIisspace:
  932. X    case FIispunct:
  933. X    case FIisalnum:
  934. X    case FIisprint:
  935. X    case FIisgraph:
  936. X    case FIiscntrl:
  937. X    case FIisascii:
  938. X        if(!(tesd1 = esdalloc(256)))
  939. X        {
  940. X            erc = eNoMemory;
  941. X            goto RETURN;
  942. X        }
  943. X        if(erc = skip_paren(param,1))
  944. X            goto RETURN;
  945. X        if(erc = gstr(param,tesd1,1))
  946. X            goto RETURN;
  947. X        if(erc = skip_paren(param,0))
  948. X            goto RETURN;
  949. X        if(!tesd1->cb)
  950. X        {
  951. X            *value = 0;
  952. X            goto RETURN;
  953. X        }
  954. X        switch(keyword_token)
  955. X        {
  956. X            case FIisalpha:
  957. X                *value = !!isalpha(*tesd1->pb);
  958. X                break;
  959. X            case FIisupper:
  960. X                *value = !!isupper(*tesd1->pb);
  961. X                break;
  962. X            case FIislower:
  963. X                *value = !!islower(*tesd1->pb);
  964. X                break;
  965. X            case FIisdigit:
  966. X                *value = !!isdigit(*tesd1->pb);
  967. X                break;
  968. X            case FIisxdigit:
  969. X                *value = !!isxdigit(*tesd1->pb);
  970. X                break;
  971. X            case FIisspace:
  972. X                *value = !!isspace(*tesd1->pb);
  973. X                break;
  974. X            case FIispunct:
  975. X                *value = !!ispunct(*tesd1->pb);
  976. X                break;
  977. X            case FIisalnum:
  978. X                *value = !!isalnum(*tesd1->pb);
  979. X                break;
  980. X            case FIisprint:
  981. X                *value = !!isprint(*tesd1->pb);
  982. X                break;
  983. X            case FIisgraph:
  984. X                *value = !!isgraph(*tesd1->pb);
  985. X                break;
  986. X            case FIiscntrl:
  987. X                *value = !!iscntrl(*tesd1->pb);
  988. X                break;
  989. X            case FIisascii:
  990. X                *value = !!isascii(*tesd1->pb);
  991. X                break;
  992. X        }
  993. X        break;
  994. X
  995. X    case FIlines:
  996. X        *value = (long)tcap_LINES;
  997. X        break;
  998. X
  999. X    case FIcols:
  1000. X        *value = (long)tcap_COLS;
  1001. X        break;
  1002. X
  1003. X#if defined(FASI)
  1004. X    case FIfasi:
  1005. X        *value = 1;
  1006. X        break;
  1007. X    case FImsr:
  1008. X        *value = (long)fasi_msr();
  1009. X        break;
  1010. X    case FIlnerr:
  1011. X        *value = (long)fasi_line_errors();
  1012. X        break;
  1013. X    case FIridet:
  1014. X        *value = (long)fasi_rings_detected();
  1015. X        break;
  1016. X    case FIbrdet:
  1017. X        *value = (long)fasi_breaks_detected();
  1018. X        break;
  1019. X#else
  1020. X    case FIfasi:
  1021. X        *value = 0;
  1022. X        break;
  1023. X#endif
  1024. X
  1025. X    case FInice:
  1026. X        *value = (long)nice(0) + 20;
  1027. X        erc = 0;
  1028. X        break;
  1029. X
  1030. X    case FIuid:
  1031. X        *value = (long)getuid();
  1032. X        erc = 0;
  1033. X        break;
  1034. X
  1035. X    case FIgid:
  1036. X        *value = (long)getgid();
  1037. X        erc = 0;
  1038. X        break;
  1039. X
  1040. X    default:
  1041. X        erc = eInvalidFunction;
  1042. X    }   /* end of keyword lookup erc switch statement */
  1043. X
  1044. XRETURN:
  1045. X    if(tesd1)
  1046. X        esdfree(tesd1);
  1047. X    if(tesd2)
  1048. X        esdfree(tesd2);
  1049. X    return(erc);
  1050. X
  1051. X}   /* end of feval_int() */
  1052. X
  1053. X/*+------------------------------------------------------------------
  1054. X    strfunc_left(param,&scratch_esd,&result_esd)
  1055. X-------------------------------------------------------------------*/
  1056. Xint
  1057. Xstrfunc_left(param,scratch_esd,result_esd)
  1058. XESD *param;
  1059. XESD *scratch_esd;
  1060. XESD *result_esd;
  1061. X{
  1062. Xregister erc;
  1063. Xint itmp;
  1064. Xlong ltmp;
  1065. X
  1066. X    if(erc = skip_paren(param,1))
  1067. X        return(erc);
  1068. X    if(erc = gstr(param,scratch_esd,1))
  1069. X        return(erc);
  1070. X    if(erc = skip_comma(param))
  1071. X        return(erc);
  1072. X    if(erc = gint(param,<mp))
  1073. X        return(erc);
  1074. X    itmp = (int)ltmp;
  1075. X    if(itmp < 0)
  1076. X        return(eBadParameter);
  1077. X    if(erc = skip_paren(param,0))
  1078. X        return(erc);
  1079. X    /* take min of param and .cb */
  1080. X    itmp = (itmp < scratch_esd->cb) ? itmp : scratch_esd->cb;
  1081. X    if(itmp > (result_esd->maxcb - result_esd->cb) )
  1082. X        return(eBufferTooSmall);
  1083. X    memcpy(&result_esd->pb[result_esd->cb],
  1084. X        scratch_esd->pb,itmp);
  1085. X    result_esd->cb += itmp;
  1086. X    return(erc);
  1087. X}   /* end of strfunc_left() */
  1088. X
  1089. X/*+-------------------------------------------------------------------------
  1090. X    erc = strfunc_right(param,&scratch_esd,&result_esd)
  1091. X--------------------------------------------------------------------------*/
  1092. Xint
  1093. Xstrfunc_right(param,scratch_esd,result_esd)
  1094. XESD *param;
  1095. XESD *scratch_esd;
  1096. XESD *result_esd;
  1097. X{
  1098. Xregister erc;
  1099. Xint itmp;
  1100. Xlong ltmp;
  1101. X
  1102. X    if(erc = skip_paren(param,1))
  1103. X        return(erc);
  1104. X    if(erc = gstr(param,scratch_esd,1))
  1105. X        return(erc);
  1106. X    if(erc = skip_comma(param))
  1107. X        return(erc);
  1108. X    if(erc = gint(param,<mp))
  1109. X        return(erc);
  1110. X    itmp = (int)ltmp;
  1111. X    if(itmp < 0)
  1112. X        return(eBadParameter);
  1113. X    if(erc = skip_paren(param,0))
  1114. X        return(erc);
  1115. X
  1116. X/* take min of param and .cb */
  1117. X    itmp = (itmp < scratch_esd->cb) ? itmp : scratch_esd->cb;
  1118. X    if(itmp > (result_esd->maxcb - result_esd->cb) )
  1119. X        return(eBufferTooSmall);
  1120. X    memcpy(&result_esd->pb[result_esd->cb],
  1121. X        &scratch_esd->pb[scratch_esd->cb - itmp],itmp);
  1122. X    result_esd->cb += itmp;
  1123. X    return(0);
  1124. X
  1125. X}   /* end of strfunc_right() */
  1126. X
  1127. X/*+-------------------------------------------------------------------------
  1128. X    erc = feval_str(param,&esd_to_be_plugged);
  1129. X    results are APPENDED to 'result_esd'
  1130. X--------------------------------------------------------------------------*/
  1131. Xfeval_str(param,result_esd)
  1132. XESD *param;
  1133. XESD *result_esd;
  1134. X{
  1135. Xregister erc;
  1136. Xregister itmp;
  1137. Xint int1,int2;
  1138. Xchar s64[64];
  1139. Xchar *cptr;
  1140. Xlong ltmp;
  1141. Xlong ltmp2;
  1142. Xlong ltmp3;
  1143. XESD *tesd1;
  1144. XESD *tesd2 = (ESD *)0;
  1145. Xchar *get_ttyname();
  1146. Xchar *getenv();
  1147. Xchar *cuserid();
  1148. Xchar *get_elapsed_time();
  1149. Xchar *mode_map();
  1150. X
  1151. X    if(!(tesd1 = esdalloc(128)))
  1152. X        return(eNoMemory);
  1153. X
  1154. X    if(erc = get_alphanum_zstr(param,s64,sizeof(s64)-1))
  1155. X    {
  1156. X        esdfree(tesd1);
  1157. X        return(eInvalidFunction);
  1158. X    }
  1159. X
  1160. X    erc = 0;
  1161. X    itmp=keyword_lookup(feval_str_tbl,s64);
  1162. X    switch(itmp)
  1163. X    {
  1164. X/* LEFT($S0,$I0)   return leftmost $I0 characters of $S0 */
  1165. X    case FSleft:
  1166. X        erc = strfunc_left(param,tesd1,result_esd);
  1167. X        break;
  1168. X
  1169. X/* RIGHT($S0,$I0)   return rightmost $I0 characters of $S0 */
  1170. X    case FSright:
  1171. X        erc = strfunc_right(param,tesd1,result_esd);
  1172. X        break;
  1173. X
  1174. X/* MID($S0,$I0,$I1)   return middle $I1 chars of $S0 starting at $I0 */
  1175. X    case FSmid:
  1176. X        if(erc = skip_paren(param,1))
  1177. X            break;
  1178. X        if(erc = gstr(param,tesd1,1))
  1179. X            break;
  1180. X        if(erc = skip_comma(param))
  1181. X            break;
  1182. X        if(erc = gint(param,<mp))
  1183. X            break;
  1184. X        int1 = (int)ltmp;
  1185. X        if(int1 < 0)
  1186. X        {
  1187. X            erc = eBadParameter;
  1188. X            break;
  1189. X        }
  1190. X        if(erc = skip_cmd_break(param))
  1191. X            break;
  1192. X        if(param->pb[param->index] == ')') /* if we find a ')' instead of ... */
  1193. X        {                                  /* 2nd int param, default to max */
  1194. X            ++param->index;
  1195. X            int2 = 256;
  1196. X        }
  1197. X        else
  1198. X        {
  1199. X            if(erc = skip_comma(param))
  1200. X                break;
  1201. X            if(erc = gint(param,<mp))
  1202. X                break;
  1203. X            int2 = (int)ltmp;
  1204. X            if(int2 < 0)
  1205. X            {
  1206. X                erc = eBadParameter;
  1207. X                break;
  1208. X            }
  1209. X            if(erc = skip_paren(param,0))
  1210. X                break;
  1211. X        }
  1212. X
  1213. X        if(int1 >= tesd1->cb) /* if initial index past end of string */
  1214. X            break;
  1215. X        itmp = tesd1->cb - int1;
  1216. X        itmp = (int2 < itmp) ? int2 : itmp;
  1217. X        cptr = tesd1->pb + int1;
  1218. X        goto CPTR_ITMP_COMMON;
  1219. X
  1220. X/* ARGV($I0) */
  1221. X    case FSargv:
  1222. X        if(!proc_level)
  1223. X        {
  1224. X            pputs("not executing procedure\n");
  1225. X            erc = eFATAL_ALREADY;
  1226. X            break;
  1227. X        }
  1228. X        if(erc = skip_paren(param,1))
  1229. X            break;
  1230. X        if(erc = gint(param,<mp))
  1231. X            break;
  1232. X        if(erc = skip_paren(param,0))
  1233. X            break;
  1234. X        itmp = (long)pcb_stack[proc_level - 1]->argc; /* arg count */
  1235. X        if((int)ltmp > itmp - 1)
  1236. X        {
  1237. X            if(proctrace)
  1238. X            {
  1239. X                pprintf("WARNING: %%argc=%d, %%argv(%ld) null\n",
  1240. X                    itmp,ltmp);
  1241. X            }
  1242. X            break;
  1243. X        }
  1244. X        cptr = (pcb_stack[proc_level - 1])->argv[(int)ltmp];
  1245. X        itmp = strlen(cptr);
  1246. X        goto CPTR_ITMP_COMMON;
  1247. X
  1248. X    case FSdir:
  1249. X        cptr = curr_dir;
  1250. X        itmp = strlen(curr_dir);
  1251. X        goto CPTR_ITMP_COMMON;
  1252. X
  1253. X    case FSetime:
  1254. X        if(erc = skip_paren(param,1))
  1255. X            break;
  1256. X        if(erc = gint(param,<mp))
  1257. X            break;
  1258. X        if(erc = skip_paren(param,0))
  1259. X            break;
  1260. X        cptr = get_elapsed_time(ltmp);
  1261. X        itmp = strlen(cptr);
  1262. X        goto CPTR_ITMP_COMMON;
  1263. X
  1264. X    case FSerrstr:
  1265. X        if(erc = skip_paren(param,1))
  1266. X            break;
  1267. X        if(erc = gint(param,<mp))
  1268. X            break;
  1269. X        if(erc = skip_paren(param,0))
  1270. X            break;
  1271. X        cptr = errno_text((int)ltmp);
  1272. X        itmp = strlen(cptr);
  1273. X        goto CPTR_ITMP_COMMON;
  1274. X
  1275. X    case FSenvvar:
  1276. X        if(erc = skip_paren(param,1))
  1277. X            break;
  1278. X        if(erc = gstr(param,tesd1,1))
  1279. X            break;
  1280. X        if(erc = skip_paren(param,0))
  1281. X            break;
  1282. X        if(!(cptr = getenv(tesd1->pb)))
  1283. X            break;
  1284. X        itmp = strlen(cptr);
  1285. X        goto CPTR_ITMP_COMMON;
  1286. X
  1287. X    case FSlogname:
  1288. X        if(!(cptr = cuserid((char *)0)))
  1289. X            break;
  1290. X        itmp = strlen(cptr);
  1291. X        goto CPTR_ITMP_COMMON;
  1292. X
  1293. X    case FSfmodestr:
  1294. X        if(erc = skip_paren(param,1))
  1295. X            break;
  1296. X        if(erc = gint(param,<mp))
  1297. X            break;
  1298. X        if(erc = skip_paren(param,0))
  1299. X            break;
  1300. X        cptr = mode_map((ushort)ltmp,(char *)0);
  1301. X        itmp = strlen(cptr);
  1302. X        goto CPTR_ITMP_COMMON;
  1303. X
  1304. X    case FStty:
  1305. X        cptr = get_ttyname();
  1306. X        itmp = strlen(cptr);
  1307. X        goto CPTR_ITMP_COMMON;
  1308. X
  1309. X    case FSuname:
  1310. X    {
  1311. X        struct utsname utsn;
  1312. X#ifdef M_SYSV /* SCO */
  1313. X        FILE *fp = fopen("/etc/systemid","r");
  1314. X        if(fp)
  1315. X        {
  1316. X            s64[0] = 0;
  1317. X            fgets(s64,sizeof(s64),fp);
  1318. X            fclose(fp);
  1319. X            if(itmp = strlen(s64))
  1320. X            {
  1321. X                if(*(cptr = s64 + itmp - 1) == '\n')
  1322. X                    *cptr = 0,itmp--;
  1323. X                strip_trail_break(s64);
  1324. X                cptr = s64;
  1325. X                itmp = strlen(cptr);
  1326. X                goto CPTR_ITMP_COMMON;
  1327. X            }
  1328. X        }
  1329. X#endif
  1330. X        if(uname(&utsn) == -1)
  1331. X        {
  1332. X            pperror("uname");
  1333. X            erc = eFATAL_ALREADY;
  1334. X            break;
  1335. X        }
  1336. X        cptr = utsn.sysname;
  1337. X        itmp = strlen(cptr);
  1338. X        goto CPTR_ITMP_COMMON;
  1339. X    } /* end of case FSuname */
  1340. X
  1341. X    case FSrname:
  1342. X        if(!shm->Lconnected)
  1343. X            break;
  1344. X        cptr = shm->Lrname;
  1345. X        itmp = strlen(shm->Lrname);
  1346. X        goto CPTR_ITMP_COMMON;
  1347. X
  1348. X    case FSrdesc:
  1349. X        if(!shm->Lconnected)
  1350. X            break;
  1351. X        cptr = shm->Ldescr;
  1352. X        itmp = strlen(shm->Ldescr);
  1353. X        goto CPTR_ITMP_COMMON;
  1354. X
  1355. X    case FSrtel:
  1356. X        if(!shm->Lconnected)
  1357. X            break;
  1358. X        cptr = shm->Ltelno;
  1359. X        itmp = strlen(shm->Ltelno);
  1360. X        goto CPTR_ITMP_COMMON;
  1361. X
  1362. X    case FSline:
  1363. X        cptr = shm->Lline;
  1364. X        itmp = strlen(shm->Lline);
  1365. X        goto CPTR_ITMP_COMMON;
  1366. X
  1367. X    case FSmonth:
  1368. X    case FSmonthz:
  1369. X        cptr = &month_name_list[(get_month(itmp == FSmonthz) - 1) * 3];
  1370. X        itmp = 3;
  1371. X        goto CPTR_ITMP_COMMON;
  1372. X
  1373. X    case FSday:
  1374. X    case FSdayz:
  1375. X        cptr = &day_of_week_list[get_day(itmp == FSdayz) * 3];
  1376. X        itmp = 3;
  1377. X        goto CPTR_ITMP_COMMON;
  1378. X
  1379. X    case FSscreen:
  1380. X        if(erc = skip_paren(param,1))
  1381. X            break;
  1382. X        if(erc = gint(param,<mp))        /* y */
  1383. X            break;
  1384. X        if(ltmp > 42)
  1385. X        {
  1386. X            erc = eBadParameter;
  1387. X            break;
  1388. X        }
  1389. X        if(erc = skip_comma(param))
  1390. X            break;
  1391. X        if(erc = gint(param,<mp2))    /* x */
  1392. X            break;
  1393. X        if(ltmp2 > 79)
  1394. X        {
  1395. X            erc = eBadParameter;
  1396. X            break;
  1397. X        }
  1398. X        if(erc = skip_comma(param))
  1399. X            break;
  1400. X        if(erc = gint(param,<mp3))    /* len */
  1401. X            break;
  1402. X        if(erc = skip_paren(param,0))
  1403. X            break;
  1404. X
  1405. X        int1 = ((int)ltmp * 80) + (int)ltmp2;    /* screen position */
  1406. X        itmp = (int)ltmp3;                        /* length */
  1407. X        int2 = sizeof(shm->screen) - int1;        /* size from y,x to end */
  1408. X        if(itmp > int2)
  1409. X            itmp = int2;
  1410. X        cptr = ((char *)shm->screen) + int1;
  1411. X        goto CPTR_ITMP_COMMON;
  1412. X
  1413. X    case FSbasename:
  1414. X        if(!(tesd2 = esdalloc(32)))
  1415. X            return(eNoMemory);
  1416. X        if(erc = skip_paren(param,1))
  1417. X            break;
  1418. X        if(erc = gstr(param,tesd1,1))
  1419. X            break;
  1420. X        if(erc = skip_comma(param))
  1421. X            break;
  1422. X        if(erc = gstr(param,tesd2,1))
  1423. X            break;
  1424. X        if(erc = skip_paren(param,0))
  1425. X            break;
  1426. X        cptr = tesd1->pb;
  1427. X        itmp = tesd1->cb;
  1428. X        if((tesd1->cb >= tesd2->cb) &&
  1429. X            !strcmp(cptr + tesd1->cb - tesd2->cb,tesd2->pb))
  1430. X        {
  1431. X            itmp -= tesd2->cb;
  1432. X        }
  1433. X        goto CPTR_ITMP_COMMON;
  1434. X
  1435. X    case FSdirpart:
  1436. X        if(erc = skip_paren(param,1))
  1437. X            break;
  1438. X        if(erc = gstr(param,tesd1,1))
  1439. X            break;
  1440. X        if(erc = skip_paren(param,0))
  1441. X            break;
  1442. X        if(cptr = strrchr(tesd1->pb,'/'))
  1443. X            itmp = cptr - tesd1->pb;
  1444. X        else
  1445. X            itmp = tesd1->cb;
  1446. X        cptr = tesd1->pb;
  1447. X        goto CPTR_ITMP_COMMON;
  1448. X
  1449. X    case FSfilepart:
  1450. X        if(erc = skip_paren(param,1))
  1451. X            break;
  1452. X        if(erc = gstr(param,tesd1,1))
  1453. X            break;
  1454. X        if(erc = skip_paren(param,0))
  1455. X            break;
  1456. X        if(cptr = strrchr(tesd1->pb,'/'))
  1457. X            itmp = strlen(++cptr);
  1458. X        else
  1459. X        {
  1460. X            cptr = tesd1->pb;
  1461. X            itmp = tesd1->cb;
  1462. X        }
  1463. X        goto CPTR_ITMP_COMMON;
  1464. X
  1465. X#if defined(FASI)
  1466. X    case FSmsrtext:
  1467. X        cptr = msr_text(fasi_msr());
  1468. X        itmp = strlen(cptr);
  1469. X        goto CPTR_ITMP_COMMON;
  1470. X#endif
  1471. X
  1472. XCPTR_ITMP_COMMON:
  1473. X        if( itmp > (result_esd->maxcb - result_esd->cb))
  1474. X        {
  1475. X            erc = eBufferTooSmall;
  1476. X            break;
  1477. X        }
  1478. X        memcpy(&result_esd->pb[result_esd->cb],cptr,itmp);
  1479. X        result_esd->cb += itmp;
  1480. X        break;
  1481. X
  1482. X    case FSedate:
  1483. X        if(erc = skip_paren(param,1))
  1484. X            break;
  1485. X        if(erc = gint(param,<mp))
  1486. X            break;
  1487. X        if(erc = skip_paren(param,0))
  1488. X            break;
  1489. X        if(19 > (result_esd->maxcb - result_esd->cb))
  1490. X        {
  1491. X            erc = eBufferTooSmall;
  1492. X            break;
  1493. X        }
  1494. X        epoch_secs_to_str(ltmp,3,&result_esd->pb[result_esd->cb]);
  1495. X        result_esd->cb += 19;
  1496. X        break;
  1497. X
  1498. X    case FStime:
  1499. X        if(5 > (result_esd->maxcb - result_esd->cb))
  1500. X        {
  1501. X            erc = eBufferTooSmall;
  1502. X            break;
  1503. X        }
  1504. X        get_tod(0,&result_esd->pb[result_esd->cb]);
  1505. X        result_esd->cb += 5;
  1506. X        break;
  1507. X
  1508. X    case FStimes:
  1509. X        if(8 > (result_esd->maxcb - result_esd->cb))
  1510. X        {
  1511. X            erc = eBufferTooSmall;
  1512. X            break;
  1513. X        }
  1514. X        get_tod(1,&result_esd->pb[result_esd->cb]);
  1515. X        result_esd->cb += 8;
  1516. X        break;
  1517. X
  1518. X    case FStimez:
  1519. X        if(5 > (result_esd->maxcb - result_esd->cb))
  1520. X        {
  1521. X            erc = eBufferTooSmall;
  1522. X            break;
  1523. X        }
  1524. X        get_tod(6,&result_esd->pb[result_esd->cb]);
  1525. X        result_esd->cb += 5;
  1526. X        break;
  1527. X
  1528. X    case FStimezs:
  1529. X        if(8 > (result_esd->maxcb - result_esd->cb))
  1530. X        {
  1531. X            erc = eBufferTooSmall;
  1532. X            break;
  1533. X        }
  1534. X        get_tod(7,&result_esd->pb[result_esd->cb]);
  1535. X        result_esd->cb += 8;
  1536. X        break;
  1537. X
  1538. X    case FSdate:
  1539. X        if(10 > (result_esd->maxcb - result_esd->cb))
  1540. X        {
  1541. X            erc = eBufferTooSmall;
  1542. X            break;
  1543. X        }
  1544. X        get_tod(5,&result_esd->pb[result_esd->cb]);
  1545. X        result_esd->cb += 10;
  1546. X        break;
  1547. X
  1548. X    case FSdatez:
  1549. X        if(10 > (result_esd->maxcb - result_esd->cb))
  1550. X        {
  1551. X            erc = eBufferTooSmall;
  1552. X            break;
  1553. X        }
  1554. X        get_tod(8,&result_esd->pb[result_esd->cb]);
  1555. X        result_esd->cb += 10;
  1556. X        break;
  1557. X
  1558. X    case FScgets:
  1559. X        erc = ttygets_esd(result_esd,TG_CRLF,1);
  1560. X        break;
  1561. X
  1562. X    case FScgetc:
  1563. X        if(result_esd->cb == result_esd->maxcb)
  1564. X        {
  1565. X            erc = eBufferTooSmall;
  1566. X            break;
  1567. X        }
  1568. X        result_esd->pb[result_esd->cb] = ttygetc(0);
  1569. X        result_esd->cb++;
  1570. X        break;
  1571. X
  1572. X    case FSchr:
  1573. X        if(erc = skip_paren(param,1))
  1574. X            break;
  1575. X        if(erc = gint(param,<mp))
  1576. X            break;
  1577. X        if(!ltmp)
  1578. X        {
  1579. X            pputs("cannot use %chr(0)\n");
  1580. X            return(eFATAL_ALREADY);
  1581. X        }
  1582. X        if(erc = skip_paren(param,0))
  1583. X            break;
  1584. X        if(result_esd->cb == result_esd->maxcb )
  1585. X        {
  1586. X            erc = eBufferTooSmall;
  1587. X            break;
  1588. X        }
  1589. X        result_esd->pb[result_esd->cb] = (char)ltmp;
  1590. X        result_esd->cb++;
  1591. X        break;
  1592. X
  1593. X    case FSitos:
  1594. X        if(erc = skip_paren(param,1))
  1595. X            break;
  1596. X        if(erc = gint(param,<mp))
  1597. X            break;
  1598. X        s64[0] = 0;
  1599. X        if(!skip_comma(param))
  1600. X        {
  1601. X            if(erc = get_numeric_zstr(param,s64 + 1,sizeof(s64) - 4))
  1602. X                strcpy(s64 + 1,"1");
  1603. X            if(((itmp = atoi(s64 + 1)) < 0) ||
  1604. X                (itmp > (result_esd->maxcb - result_esd->cb)))
  1605. X            {
  1606. X                erc = eBufferTooSmall;
  1607. X                break;
  1608. X            }
  1609. X            s64[0] = '%';
  1610. X            if(ulindex(param->pb + param->index,"x") == 0)
  1611. X            {
  1612. X                param->index++;
  1613. X                strcat(s64,"lx");
  1614. X            }
  1615. X            else if(ulindex(param->pb + param->index,"o") == 0)
  1616. X            {
  1617. X                param->index++;
  1618. X                strcat(s64,"lo");
  1619. X            }
  1620. X            else if(ulindex(param->pb + param->index,"d") == 0)
  1621. X            {
  1622. X                param->index++;
  1623. X                strcat(s64,"ld");
  1624. X            }
  1625. X            else if(erc)
  1626. X                break;
  1627. X            else
  1628. X                strcat(s64,"ld");
  1629. X        }
  1630. X        if(erc = skip_paren(param,0))
  1631. X            break;
  1632. X        sprintf(tesd1->pb,s64[0] ? s64 : "%ld",ltmp);
  1633. X        tesd1->cb = strlen(tesd1->pb);
  1634. X        if(result_esd->maxcb - result_esd->cb < tesd1->cb)
  1635. X        {
  1636. X            erc = eBufferTooSmall;
  1637. X            break;
  1638. X        }
  1639. X        strcpy(&result_esd->pb[result_esd->cb],tesd1->pb);
  1640. X        result_esd->cb += tesd1->cb;
  1641. X        break;
  1642. X
  1643. X
  1644. X    default:
  1645. X        erc = eInvalidFunction;
  1646. X        break;
  1647. X    }   /* end of keyword lookup erc switch statement */
  1648. X
  1649. X    esd_null_terminate(result_esd);
  1650. X    esdfree(tesd1);
  1651. X    if(tesd2)
  1652. X        esdfree(tesd2);
  1653. X    return(erc);
  1654. X
  1655. X}   /* end of feval_str() */
  1656. X
  1657. X/* vi: set tabstop=4 shiftwidth=4: */
  1658. X/* end of feval.c */
  1659. SHAR_EOF
  1660. chmod 0644 feval.c ||
  1661. echo 'restore of feval.c failed'
  1662. Wc_c="`wc -c < 'feval.c'`"
  1663. test 25046 -eq "$Wc_c" ||
  1664.     echo 'feval.c: original size 25046, current size' "$Wc_c"
  1665. rm -f _shar_wnt_.tmp
  1666. fi
  1667. # ============= feval.h ==============
  1668. if test -f 'feval.h' -a X"$1" != X"-c"; then
  1669.     echo 'x - skipping feval.h (File already exists)'
  1670.     rm -f _shar_wnt_.tmp
  1671. else
  1672. > _shar_wnt_.tmp
  1673. echo 'x - extracting feval.h (Text)'
  1674. sed 's/^X//' << 'SHAR_EOF' > 'feval.h' &&
  1675. X/*+-------------------------------------------------------------------------
  1676. X    feval.h
  1677. X    wht@n4hgf.Mt-Park.GA.US
  1678. X--------------------------------------------------------------------------*/
  1679. X/*+:EDITS:*/
  1680. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1681. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1682. X/*:03-27-1992-16:21-wht@n4hgf-re-include protection for all .h files */
  1683. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  1684. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1685. X
  1686. X#ifndef _feval_h
  1687. X#define _feval_h
  1688. X
  1689. X#define FIinstr        1
  1690. X#define FIlen        2
  1691. X#define FIstoi        3
  1692. X#define FIctoi        4
  1693. X#define FIbaud        5
  1694. X#define FIconn        6
  1695. X#define FIcsec        7
  1696. X#define FIpid        8
  1697. X#define FIrchr        9
  1698. X#define FIrchrc        10
  1699. X#define FIxchr        11
  1700. X#define FIxchrc        12
  1701. X#define FIlgetc        13
  1702. X#define FIargc        14
  1703. X#define FIftell        15
  1704. X#define FIfmode        16
  1705. X#define FIisdir        17
  1706. X#define FIisreg        18
  1707. X#define FIischr        19
  1708. X#define FIfatime    20
  1709. X#define FIfmtime    21
  1710. X#define FIfsize        22
  1711. X#define FIcolors    23
  1712. X
  1713. X
  1714. XKEYTAB feval_int_tbl[] =
  1715. X{
  1716. X    {"argc",FIargc},
  1717. X    {"baud",FIbaud},
  1718. X    {"colors",FIcolors},
  1719. X    {"conn",FIconn},
  1720. X    {"csec",FIcsec},
  1721. X    {"ctoi",FIctoi},
  1722. X    {"fatime",FIfatime},
  1723. X    {"fmode",FIfmode},
  1724. X    {"fmtime",FIfmtime},
  1725. X    {"fsize",FIfsize},
  1726. X    {"ftell",FIftell},
  1727. X    {"instr",FIinstr},
  1728. X    {"ischr",FIischr},
  1729. X    {"isdir",FIisdir},
  1730. X    {"isreg",FIisreg},
  1731. X    {"len",FIlen},
  1732. X    {"lgetc",FIlgetc},
  1733. X    {"pid",FIpid},
  1734. X    {"rchr",FIrchr},
  1735. X    {"rchrc",FIrchrc},
  1736. X    {"stoi",FIstoi},
  1737. X    {"xchr",FIxchr},
  1738. X    {"xchrc",FIxchrc},
  1739. X    {(char *)0,0}
  1740. X};
  1741. X
  1742. X#define FSleft        2
  1743. X#define FSright        3
  1744. X#define FSmid        4
  1745. X#define FSdate        5
  1746. X#define FSmonth        6
  1747. X#define FSday        7
  1748. X#define FScgets        9
  1749. X#define FScgetc        10
  1750. X#define FSitos        11
  1751. X#define FSchr        12
  1752. X#define FSdir        13
  1753. X#define FStty        14
  1754. X#define FSrdesc        15
  1755. X#define FSrname        16
  1756. X#define FSline        17
  1757. X#define FSrtel        18
  1758. X#define FSargv        19
  1759. X#define FStime        20
  1760. X#define FStimes        21
  1761. X#define FSedate        22
  1762. X#define FSetime        23
  1763. X#define FSgetenv    24
  1764. X#define FSgetlogin    25
  1765. X
  1766. X
  1767. XKEYTAB feval_str_tbl[] =
  1768. X{
  1769. X    {"argv",FSargv},
  1770. X    {"cgetc",FScgetc},
  1771. X    {"cgets",FScgets},
  1772. X    {"chr",FSchr},
  1773. X    {"date",FSdate},
  1774. X    {"day",FSday},
  1775. X    {"dir",FSdir},
  1776. X    {"edate",FSedate},
  1777. X    {"etime",FSetime},
  1778. X    {"getenv",FSgetenv},
  1779. X    {"getlogin",FSgetlogin},
  1780. X    {"itos",FSitos},
  1781. X    {"left",FSleft},
  1782. X    {"line",FSline},
  1783. X    {"mid",FSmid},
  1784. X    {"month",FSmonth},
  1785. X    {"rdesc",FSrdesc},
  1786. X    {"right",FSright},
  1787. X    {"rname",FSrname},
  1788. X    {"rtelno",FSrtel},
  1789. X    {"time",FStime},
  1790. X    {"times",FStimes},
  1791. X    {"tty",FStty},
  1792. X    {(char *)0,0}
  1793. X};
  1794. X
  1795. X#endif /* _feval_h */
  1796. X
  1797. X/* vi: set tabstop=4 shiftwidth=4: */
  1798. X/* end of feval.h */
  1799. SHAR_EOF
  1800. chmod 0644 feval.h ||
  1801. echo 'restore of feval.h failed'
  1802. Wc_c="`wc -c < 'feval.h'`"
  1803. test 2461 -eq "$Wc_c" ||
  1804.     echo 'feval.h: original size 2461, current size' "$Wc_c"
  1805. rm -f _shar_wnt_.tmp
  1806. fi
  1807. # ============= funckeymap.c ==============
  1808. if test -f 'funckeymap.c' -a X"$1" != X"-c"; then
  1809.     echo 'x - skipping funckeymap.c (File already exists)'
  1810.     rm -f _shar_wnt_.tmp
  1811. else
  1812. > _shar_wnt_.tmp
  1813. echo 'x - extracting funckeymap.c (Text)'
  1814. sed 's/^X//' << 'SHAR_EOF' > 'funckeymap.c' &&
  1815. X/* #define NONANSI_DEBUG */
  1816. X/*+-----------------------------------------------------------------
  1817. X    funckeymap.c - keyboard function key -> ECU internal
  1818. X    wht@n4hgf.Mt-Park.GA.US
  1819. X
  1820. X  Defined functions:
  1821. X    fkmap_command(argc,argv)
  1822. X    funckeymap(buf,buflen)
  1823. X    funckeymap_define(bufptr)
  1824. X    funckeymap_display(fp)
  1825. X    funckeymap_display_single(tkde,fp)
  1826. X    funckeymap_init()
  1827. X    funckeymap_read(name)
  1828. X
  1829. X------------------------------------------------------------------*/
  1830. X/*+:EDITS:*/
  1831. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  1832. X/*:08-30-1992-23:06-wht@n4hgf-add fkmap_command */
  1833. X/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
  1834. X/*:08-28-1991-14:51-wht@n4hgf2-look correctly for funckeymap in ECULIBDIR */
  1835. X/*:08-26-1991-05:45-wht@n4hgf2-# got included in key def */
  1836. X/*:08-06-1991-13:19-wht@n4hgf-allow any code as first in key sequence */
  1837. X/*:08-03-1991-14:44-wht@n4hgf-look for funckeymap in ECULIBDIR too */
  1838. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  1839. X/*:03-20-1991-03:06-root@n4hgf-no Metro Link problems here */
  1840. X/*:03-20-1991-01:04-root@n4hgf-diagnose Metro Link xterm differences */
  1841. X/*:01-10-1991-23:15-wht@n4hgf-string overflow rptd by spooley@compulink.co.uk */
  1842. X/*:12-01-1990-12:51-wht@n4hgf-creation, borrowing from and using ecufkey.c */
  1843. X
  1844. X#include "ecu.h"
  1845. X#include "ecuerror.h"
  1846. X#include "ecukey.h"
  1847. X#include "ecufkey.h"
  1848. X#include "ecuxkey.h"
  1849. X#include "ecufork.h"
  1850. X
  1851. Xextern int tty_not_char_special;
  1852. Xextern char *dash_f_funckeytype;
  1853. X
  1854. XKDE funckeymap_table[KDE_COUNT];
  1855. Xchar funckeymap_name[32] = "";
  1856. X#if defined(NONANSI_DEBUG)
  1857. Xstatic FILE *nadbg = (FILE *)0;
  1858. X#endif
  1859. X
  1860. X/*+-------------------------------------------------------------------------
  1861. X    funckeymap_init() - initialize function key mapping (recognition)
  1862. X--------------------------------------------------------------------------*/
  1863. Xvoid
  1864. Xfunckeymap_init()
  1865. X{
  1866. X    register itmp;
  1867. X    register KDE *tkde;
  1868. X    char *make_char_graphic();
  1869. X
  1870. X    for(itmp = 0; itmp < KDE_COUNT; itmp++)
  1871. X    {
  1872. X        tkde = &funckeymap_table[itmp];
  1873. X        tkde->logical[0] = 0;
  1874. X        tkde->count = 0;
  1875. X        tkde->ikde = 0;
  1876. X    }
  1877. X
  1878. X    funckeymap_name[0] = 0;
  1879. X
  1880. X}    /* end of funckeymap_init */
  1881. X
  1882. X/*+-------------------------------------------------------------------------
  1883. X    funckeymap_define(bufptr) - use funckeymap line to define a mapping
  1884. X
  1885. X  returns 0 good keydef
  1886. X         -1 if syntax error
  1887. X--------------------------------------------------------------------------*/
  1888. Xint
  1889. Xfunckeymap_define(bufptr)
  1890. Xregister char *bufptr;
  1891. X{
  1892. X    register itmp;
  1893. X    register token_number = 0;
  1894. X    KDE *tkde = (KDE *)0;
  1895. X    int ikde = 0;
  1896. X    int octothorpe = 0;
  1897. X    char *token;
  1898. X    char *arg_token();
  1899. X    char *str_token();
  1900. X    char *skip_ld_break();
  1901. X
  1902. X    while(!octothorpe &&
  1903. X       (token = (token_number < 2) ? str_token(bufptr,":")
  1904. X                                   : arg_token(bufptr," \t")))
  1905. X    {
  1906. X        bufptr = (char *)0;    /* further calls to arg_token need NULL */
  1907. X        token = skip_ld_break(token);
  1908. X        strip_trail_break(token);
  1909. X
  1910. X        switch(token_number)
  1911. X        {
  1912. X            case 0:        /* first field is key identifier */
  1913. X                if((ikde = kde_name_to_ikde(token)) < 0)
  1914. X                {
  1915. X                    pprintf("  %s is not a legal key identifier\r\n",token);
  1916. X                    return(-1);
  1917. X                }
  1918. X                tkde = &funckeymap_table[ikde];
  1919. X                tkde->logical[0] = 0;
  1920. X                tkde->count = 0;
  1921. X                tkde->ikde = ikde;
  1922. X                break;
  1923. X
  1924. X            case 1:        /* second field is logical key name */
  1925. X                if(*token == '#')
  1926. X                    goto MISSING_LABEL;
  1927. X                strncpy(tkde->logical,token,sizeof(tkde->logical));
  1928. X                tkde->logical[sizeof(tkde->logical) - 1] = 0;
  1929. X                break;
  1930. X
  1931. X            case 2:        /* third field is first token of sequence */
  1932. X                if(*token == '#')
  1933. X                    goto MISSING_SEQUENCE;
  1934. X
  1935. X            default:    /* third and subsequent to define key */
  1936. X                if(*token == '#')
  1937. X                {
  1938. X                    octothorpe = 1;
  1939. X                    break;
  1940. X                }
  1941. X                if(tkde->count == sizeof(tkde->str))
  1942. X                {
  1943. X                    pprintf("  %s: output count too long",
  1944. X                        keyset_idstr(ikde));
  1945. X                    return(-1);
  1946. X                }
  1947. X                if((itmp = ascii_to_hex(token)) < 0)
  1948. X                {
  1949. X                    pprintf("  %s: '%s' invalid\r\n",
  1950. X                        keyset_idstr(ikde),token);
  1951. X                    return(-1);
  1952. X                }
  1953. X                tkde->str[tkde->count] = itmp;
  1954. X                tkde->count++;
  1955. X                break;
  1956. X        }    /* end of switch(token_number) */
  1957. X
  1958. X        if(octothorpe)
  1959. X            break;
  1960. X
  1961. X        token_number++;
  1962. X
  1963. X    }        /* end while not end of record */
  1964. X
  1965. X    switch(token_number)
  1966. X    {
  1967. X        case 0:
  1968. X            pprintf("funckeymap_define logic error\n");
  1969. X            termecu(TERMECU_LOGIC_ERROR);
  1970. X            break;
  1971. X
  1972. X        case 1:
  1973. XMISSING_LABEL:
  1974. X            pprintf("%s: missing key label\r\n",keyset_idstr(ikde));
  1975. X            break;
  1976. X
  1977. X        case 2:
  1978. XMISSING_SEQUENCE:
  1979. X            pprintf("%s: missing char sequence\r\n",keyset_idstr(ikde));
  1980. X            break;
  1981. X        default:
  1982. X            /* special init string entry */
  1983. X            if(ikde == IKDE_InitStr)
  1984. X                fwrite(tkde->str,1,tkde->count,stderr);
  1985. X            else if(tkde->count)
  1986. X            {
  1987. X                uchar ch = tkde->str[0];
  1988. X                extern uchar kbdeof;        /* current input EOF */
  1989. X                extern uchar kbdeol2;        /* current secondary input EOL */
  1990. X                extern uchar kbdeol;        /* current input EOL */
  1991. X                extern uchar kbderase;        /* current input ERASE */
  1992. X                extern uchar kbdintr;        /* current input INTR */
  1993. X                extern uchar kbdkill;        /* current input KILL */
  1994. X                extern uchar kbdquit;        /* current input QUIT */
  1995. X
  1996. X                if(    (ch == kbdeof) || (ch == kbdeol2) ||
  1997. X                    (ch == kbdeol) || (ch == kbderase) ||
  1998. X                    (ch == kbdintr) || (ch == kbdkill) ||
  1999. X                    (ch == kbdquit) )
  2000. X                {
  2001. X                    pprintf(
  2002. X                        "%s: 1st char cannot be input control character\r\n",
  2003. X                        keyset_idstr(ikde));
  2004. X                    break;
  2005. X                }
  2006. X            }
  2007. X            return(0);
  2008. X    }
  2009. X
  2010. X    return(-1);        /* error */
  2011. X
  2012. X}    /* end of funckeymap_define */
  2013. X
  2014. X/*+-------------------------------------------------------------------------
  2015. X    funckeymap_read(name) - read key-sequence-to-fkey map from funckeymap
  2016. X--------------------------------------------------------------------------*/
  2017. Xvoid
  2018. Xfunckeymap_read(name)
  2019. Xchar *name;
  2020. X{
  2021. X    register itmp;
  2022. X    char buf[128];
  2023. X    FILE *fp_keys;
  2024. X    int errstat = 0;
  2025. X    static char ecukeys_name[128];
  2026. X
  2027. X#if defined(NONANSI_DEBUG)
  2028. X    if(!nadbg)
  2029. X    {
  2030. X        nadbg = fopen("/tmp/nadbg.log","w");
  2031. X        setbuf(nadbg,NULL);
  2032. X    }
  2033. X#endif
  2034. X
  2035. X    funckeymap_init();    /* clear any previous key defns */
  2036. X
  2037. X    if(!ecukeys_name[0])
  2038. X    {
  2039. X        get_home_dir(ecukeys_name);
  2040. X        strcat(ecukeys_name,"/.ecu/funckeymap");
  2041. X    }
  2042. X
  2043. X    if(!(fp_keys = fopen(ecukeys_name,"r")))
  2044. X    {
  2045. X        strcpy(ecukeys_name,eculibdir);
  2046. X        strcat(ecukeys_name,"/funckeymap");
  2047. X        if(!(fp_keys = fopen(ecukeys_name,"r")))
  2048. X        {
  2049. X            ff(stderr,"'funckeymap' not in ~/.ecu or %s; unable to proceed\r\n",
  2050. X                eculibdir);
  2051. X            termecu(TERMECU_CONFIG_ERROR);
  2052. X        }
  2053. X    }
  2054. X
  2055. X/* find funckeymap name */
  2056. X    errstat = 1;
  2057. X    while((itmp = kde_fgets(buf,sizeof(buf),fp_keys)) != KDETYPE_EOF)
  2058. X    {
  2059. X        if((itmp == KDETYPE_COMMENT) || (itmp == KDETYPE_ENTRY))
  2060. X            continue;
  2061. X        if(!strcmp(buf,name))
  2062. X        {
  2063. X            errstat = 0;        /* indicate success */
  2064. X            break;
  2065. X        }
  2066. X    }
  2067. X    if(errstat)
  2068. X    {
  2069. X        ff(stderr,"terminal type '%s'\r\n",name);
  2070. X        ff(stderr,"not found in %s; unable to proceed\r\n",ecukeys_name);
  2071. X        termecu(TERMECU_CONFIG_ERROR);
  2072. X    }
  2073. X
  2074. X/* read past any other funckeymap names matching this set */
  2075. X    errstat = 1;
  2076. X    while((itmp = kde_fgets(buf,sizeof(buf),fp_keys)) != KDETYPE_EOF)
  2077. X    {
  2078. X        if(itmp == KDETYPE_ENTRY)
  2079. X        {
  2080. X            errstat = 0;        /* indicate success */
  2081. X            break;
  2082. X        }
  2083. X    }
  2084. X    if(errstat)
  2085. X    {
  2086. X        ff(stderr,
  2087. X            "terminal type '%s' has null entry in %s; unable to proceed\r\n",
  2088. X            name,ecukeys_name);
  2089. X        termecu(TERMECU_CONFIG_ERROR);
  2090. X    }
  2091. X
  2092. X/* we found the definition ... process it */
  2093. X    errstat = 0;
  2094. X    itmp = KDETYPE_ENTRY;
  2095. X    do {
  2096. X        if(itmp == KDETYPE_NAME)
  2097. X            break;
  2098. X        else if(itmp == KDETYPE_ENTRY)
  2099. X        {
  2100. X            if(funckeymap_define(buf))
  2101. X                errstat = 1;
  2102. X        }
  2103. X    } while((itmp = kde_fgets(buf,sizeof(buf),fp_keys)) != KDETYPE_EOF);
  2104. X
  2105. X/* finish up */
  2106. X    strncpy(funckeymap_name,name,sizeof(funckeymap_name));
  2107. X    funckeymap_name[sizeof(funckeymap_name) - 1] = 0;
  2108. X    fclose(fp_keys);
  2109. X
  2110. X    if(!funckeymap_table[IKDE_HOME].count)
  2111. X    {
  2112. X        ff(stderr,"You MUST have a 'Home' key defined\r\n");
  2113. X        errstat = 2;
  2114. X    }
  2115. X    if(!funckeymap_table[IKDE_END].count)
  2116. X    {
  2117. X        ff(stderr,"You MUST have a 'End' key defined\r\n");
  2118. X        errstat = 2;
  2119. X    }
  2120. X    if((errstat == 2) || (errstat && tty_not_char_special))
  2121. X        termecu(TERMECU_CONFIG_ERROR);
  2122. X
  2123. X    if(errstat)
  2124. X    {
  2125. X        ff(stderr,
  2126. X            "WARNING: key mapping syntax errors\r\nContinue anyway (y,[n])? ");
  2127. X        if((itmp = ttygetc(0)) == 'Y' || (itmp == 'y'))
  2128. X        {
  2129. X            ff(stderr,"YES\r\n");
  2130. X            return;
  2131. X        }
  2132. X        ff(stderr,"NO\r\n");
  2133. X        termecu(TERMECU_CONFIG_ERROR);
  2134. X        /*NOTREACHED*/
  2135. X    }
  2136. X
  2137. X}    /* end of funckeymap_read */
  2138. X
  2139. X/*+-------------------------------------------------------------------------
  2140. X    funckeymap(buf,buflen) - map char sequence to ikde code
  2141. X
  2142. Xreturn XF_ code or XF_not_yet if no match yet, XF_no_way if no match possible
  2143. X--------------------------------------------------------------------------*/
  2144. Xuchar
  2145. Xfunckeymap(buf,buflen)
  2146. Xuchar *buf;
  2147. Xint buflen;
  2148. X{
  2149. X    register ikde;
  2150. X    register KDE *tkde;
  2151. X    int err_rtn = XF_no_way;
  2152. X
  2153. X    if(!buflen)
  2154. X        return(XF_not_yet);
  2155. X
  2156. X#if defined(NONANSI_DEBUG)
  2157. X    if(nadbg)
  2158. X        hex_dump_fp(nadbg,buf,-buflen,"mapna",1);
  2159. X#endif
  2160. X
  2161. X    for(ikde = 0,tkde = funckeymap_table; ikde <= IKDE_lastKey;
  2162. X        ikde++,tkde++)
  2163. X    {
  2164. X#if defined(NONANSI_DEBUG)
  2165. X            if(nadbg)
  2166. X                fprintf(nadbg,"--> %s ",tkde->logical);
  2167. X#endif
  2168. X        if((tkde->count == buflen) && !memcmp(tkde->str,buf,buflen))
  2169. X        {
  2170. X#if defined(NONANSI_DEBUG)
  2171. X            if(nadbg)
  2172. X                fprintf(nadbg,"yes\n");
  2173. X#endif
  2174. X            return(tkde->ikde);
  2175. X        }
  2176. X#if defined(NONANSI_DEBUG)
  2177. X        if(nadbg)
  2178. X            fprintf(nadbg,"no\n");
  2179. X#endif
  2180. X        if((tkde->count > buflen) &&
  2181. X            ((uchar)*(tkde->str + buflen) == *(buf + buflen)))
  2182. X        {
  2183. X            err_rtn = XF_not_yet;
  2184. X        }
  2185. X    }
  2186. X    return(err_rtn);
  2187. X}    /* end of funckeymap */
  2188. X
  2189. X/*+-------------------------------------------------------------------------
  2190. X    funckeymap_display_single(tkde,fp) - display single mapping on FILE fp
  2191. X--------------------------------------------------------------------------*/
  2192. Xvoid
  2193. Xfunckeymap_display_single(ikde,fp)
  2194. Xint ikde;
  2195. XFILE *fp;
  2196. X{
  2197. X    int keys_left;
  2198. X    char *keys;
  2199. X    char s64[64];
  2200. X    KDE *tkde;
  2201. X
  2202. X    if((unsigned)ikde > IKDE_lastKey)
  2203. X        return;
  2204. X
  2205. X    tkde = &funckeymap_table[ikde];
  2206. X    sprintf(s64," %s:%s:                   ",
  2207. X        keyset_idstr(ikde),tkde->logical);
  2208. X    s64[16] = 0;
  2209. X    if(fp == stderr)
  2210. X        pputs(s64);
  2211. X    else
  2212. X        fputs(s64,fp);
  2213. X    keys_left = tkde->count;
  2214. X    keys = tkde->str;
  2215. X    while(keys_left--)
  2216. X    {
  2217. X        if(fp == stderr)
  2218. X        {
  2219. X            pprintf("%s%s",
  2220. X                make_char_graphic(*keys++,0),
  2221. X                (keys_left) ? " " : "");
  2222. X        }
  2223. X        else
  2224. X        {
  2225. X            fprintf(fp,"%s%s",
  2226. X                make_char_graphic(*keys++,0),
  2227. X                (keys_left) ? " " : "");
  2228. X        }
  2229. X    }
  2230. X    if(fp == stderr)
  2231. X        pputs("\n");
  2232. X    else
  2233. X        fputs("\n",fp);
  2234. X
  2235. X}    /* end of funckeymap_display_single */
  2236. X
  2237. X/*+-------------------------------------------------------------------------
  2238. X    funckeymap_display(fp) - display function key table of FILE fp
  2239. X--------------------------------------------------------------------------*/
  2240. Xvoid
  2241. Xfunckeymap_display(fp)
  2242. XFILE *fp;
  2243. X{
  2244. X    int ikde;
  2245. X    char *ftype = 0;
  2246. X
  2247. X    if(dash_f_funckeytype)
  2248. X        ftype =    dash_f_funckeytype;
  2249. X    else
  2250. X        ftype = getenv("ECUFUNCKEY");
  2251. X
  2252. X    if(ttype && ftype)
  2253. X    {
  2254. X        fprintf(fp,"#$TERM=%s -F/$ECUFUNCKEY=%s",ftype,ttype);
  2255. X        if(fp == stderr)
  2256. X            fputs("\r\n",fp);
  2257. X        else
  2258. X            fputs("\n",fp);
  2259. X    }
  2260. X
  2261. X    if(ttype || ftype)
  2262. X    {
  2263. X        fputs((ftype) ? ftype : ttype,fp);
  2264. X        if(fp == stderr)
  2265. X            fputs("\r\n",fp);
  2266. X        else
  2267. X            fputs("\n",fp);
  2268. X    }
  2269. X
  2270. X    for(ikde = 0; ikde <= IKDE_lastKey; ikde++)
  2271. X        funckeymap_display_single(ikde,fp);
  2272. X
  2273. X}    /* end of funckeymap_display */
  2274. X
  2275. X/*+-------------------------------------------------------------------------
  2276. X    fkmap_command(argc,argv) - common interactive and procedure 'fkmap' cmd
  2277. X
  2278. Xreturn procedure error codes
  2279. X--------------------------------------------------------------------------*/
  2280. Xint
  2281. Xfkmap_command(argc,argv)
  2282. Xint argc;
  2283. Xchar **argv;
  2284. X{
  2285. X    register itmp;
  2286. X    int err = 0;
  2287. X    char *ftype = 0;
  2288. X    int iargv = 1;
  2289. X    char *arg;
  2290. X    char fkcmd[512 + 1];
  2291. X    char *fkcptr = fkcmd;
  2292. X    int fkclen = 0;
  2293. X    int ikde;
  2294. X    KDE save;
  2295. X    FILE *fp;
  2296. X    
  2297. X    while((iargv < argc) && (*(arg = argv[iargv]) == '-'))
  2298. X    {
  2299. X        switch(*++arg)
  2300. X        {
  2301. X            case 'r': /* reset */
  2302. X                if(err)
  2303. X                    break;
  2304. X                if(dash_f_funckeytype)
  2305. X                    ftype =    dash_f_funckeytype;
  2306. X                else
  2307. X                    ftype = getenv("ECUFUNCKEY");
  2308. X                if(ttype || ftype)
  2309. X                    funckeymap_read((ftype) ? ftype : ttype);
  2310. X                if(!proc_level || proctrace)
  2311. X                    pputs("funckeymap reset to startup configuration\n");
  2312. X                if(iargv != (argc - 1))
  2313. X                    pputs("extra arguments ignored\n");
  2314. X                return(0);
  2315. X
  2316. X            case 's': /* save in file */
  2317. X                if(err)
  2318. X                    break;
  2319. X                if(iargv != (argc - 2))
  2320. X                {
  2321. X                    pputs("exactly one argument required for -s\n");
  2322. X                    return(eFATAL_ALREADY);
  2323. X                }
  2324. X                iargv++;
  2325. X                if(!(fp = fopen(argv[iargv],"a")))
  2326. X                {
  2327. X                    pperror(argv[iargv]);
  2328. X                    return(eFATAL_ALREADY);
  2329. X                }
  2330. X                funckeymap_display(fp);
  2331. X                fclose(fp);
  2332. X                if(!proc_level || proctrace)
  2333. X                    pprintf("current mapping saved in %s\n",argv[iargv]);
  2334. X                return(0);
  2335. X
  2336. X            default:
  2337. X                pprintf("unknown switch -%c\n",*arg);
  2338. X                err = 1;
  2339. X        }
  2340. X        iargv++;
  2341. X    }
  2342. X
  2343. X    if(err)
  2344. X        return(eFATAL_ALREADY);
  2345. X
  2346. X    if(iargv == argc)
  2347. X    {
  2348. X        funckeymap_display(stderr);
  2349. X        return(0);
  2350. X    }
  2351. X
  2352. X    arg = argv[iargv++];
  2353. X    if((ikde = kde_name_to_ikde(arg)) < 0)
  2354. X    {
  2355. X        pprintf("key name '%s' not recognized\n",arg);
  2356. X        return(eFATAL_ALREADY);
  2357. X    }
  2358. X    sprintf(fkcptr," %s:%s: ",keyset_idstr(ikde),keyset_idstr(ikde));
  2359. X    fkcptr += (itmp = strlen(fkcptr));
  2360. X    fkclen += itmp;
  2361. X
  2362. X    if(iargv == argc)
  2363. X    {
  2364. X        funckeymap_display_single(&funckeymap_table[ikde],stderr);
  2365. X        return(0);
  2366. X    }
  2367. X
  2368. X    while(iargv < argc)
  2369. X    {
  2370. X        arg = argv[iargv++];
  2371. X        itmp = strlen(arg);
  2372. X        if((fkclen + itmp + 2) > sizeof(fkcmd))
  2373. X        {
  2374. X            pprintf("fkmap command may be no longer than %d characters\n",
  2375. X                sizeof(fkcmd) - 1);
  2376. X            return(eFATAL_ALREADY);
  2377. X        }
  2378. X        strcpy(fkcptr,arg);
  2379. X        fkcptr += itmp;
  2380. X        fkclen += itmp;
  2381. X        if(iargv != argc)
  2382. X        {
  2383. X            *fkcptr++ = ' ';
  2384. X            *fkcptr = 0;
  2385. X            fkclen++;
  2386. X        }
  2387. X    }
  2388. X
  2389. X    save = funckeymap_table[ikde];
  2390. X    if(err = funckeymap_define(fkcmd))
  2391. X        funckeymap_table[ikde] = save;
  2392. X
  2393. X    if(!err && (!proc_level || proctrace))
  2394. X        funckeymap_display_single(ikde,stderr);
  2395. X
  2396. X    return((err) ? eFATAL_ALREADY : 0);
  2397. X
  2398. X}    /* end of fkmap_command */
  2399. X
  2400. X/* end of funckeymap.c */
  2401. X/* vi: set tabstop=4 shiftwidth=4: */
  2402. SHAR_EOF
  2403. chmod 0644 funckeymap.c ||
  2404. echo 'restore of funckeymap.c failed'
  2405. Wc_c="`wc -c < 'funckeymap.c'`"
  2406. test 13650 -eq "$Wc_c" ||
  2407.     echo 'funckeymap.c: original size 13650, current size' "$Wc_c"
  2408. rm -f _shar_wnt_.tmp
  2409. fi
  2410. # ============= gint.c ==============
  2411. if test -f 'gint.c' -a X"$1" != X"-c"; then
  2412.     echo 'x - skipping gint.c (File already exists)'
  2413.     rm -f _shar_wnt_.tmp
  2414. else
  2415. > _shar_wnt_.tmp
  2416. echo 'x - extracting gint.c (Text)'
  2417. sed 's/^X//' << 'SHAR_EOF' > 'gint.c' &&
  2418. X/*+-------------------------------------------------------------------------
  2419. X    gint.c - ecu get integer parameter functions
  2420. X    wht@n4hgf.Mt-Park.GA.US
  2421. X
  2422. X  Defined functions:
  2423. X    gcol_range(param,col1,col2)
  2424. X    gint(param,int_returned)
  2425. X    gint_base(param,value)
  2426. X    gint_constant(param,value)
  2427. X    gintop(param,intop)
  2428. X
  2429. X--------------------------------------------------------------------------*/
  2430. X/*+:EDITS:*/
  2431. X/*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 */
  2432. X/*:08-22-1992-15:39-wht@n4hgf-ECU release 3.20 BETA */
  2433. X/*:07-25-1991-12:58-wht@n4hgf-ECU release 3.10 */
  2434. X/*:01-31-1991-16:50-wht@n4hgf-reinstate octal with 0o prefix */
  2435. X/*:01-09-1991-22:31-wht@n4hgf-ISC port */
  2436. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  2437. X
  2438. X#include "ecu.h"
  2439. X#include "ecuerror.h"
  2440. X#include "esd.h"
  2441. X#include "var.h"
  2442. X
  2443. X#define OP_ADD      1
  2444. X#define OP_SUB      2
  2445. X#define OP_MUL      3
  2446. X#define OP_DIV      4
  2447. X#define OP_XOR      5
  2448. X#define OP_MOD      6
  2449. X#define OP_OR       7
  2450. X#define OP_AND      8
  2451. X
  2452. X#define BASE_DEC    1
  2453. X#define BASE_OCT    2
  2454. X#define BASE_HEX      3
  2455. X
  2456. X
  2457. X/*+-------------------------------------------------------------------------
  2458. X    gint_constant(param,int_returned) - evaluate integer constant
  2459. X--------------------------------------------------------------------------*/
  2460. Xint
  2461. Xgint_constant(param,value)
  2462. XESD *param;
  2463. Xlong *value;
  2464. X{
  2465. Xregister itmp;
  2466. Xint base = BASE_DEC;
  2467. Xint erc;
  2468. Xlong new_value;
  2469. X
  2470. X    if(erc = skip_cmd_break(param))
  2471. X        return(erc);
  2472. X    esd_null_terminate(param);
  2473. X
  2474. X/* get integer from string */
  2475. X    if((!strncmp(param->pb + param->index,"0x",2)) ||
  2476. X        (!strncmp(param->pb + param->index,"0X",2)))
  2477. X    {
  2478. X        base = BASE_HEX;
  2479. X        param->index += 2;
  2480. X    }
  2481. X    else if((!strncmp(param->pb + param->index,"0o",2)) ||
  2482. X        (!strncmp(param->pb + param->index,"0O",2)))
  2483. X    {
  2484. X        base = BASE_OCT;
  2485. X        param->index += 2;
  2486. X    }
  2487. X
  2488. X    param->old_index = param->index;
  2489. X    switch(base)
  2490. X    {
  2491. X        case BASE_HEX:
  2492. X            sscanf(param->pb + param->index,"%lx",&new_value);
  2493. X            itmp = param->index + strspn(param->pb + param->index,
  2494. X                "0123456789ABCDEFabcdef");
  2495. X            erc = eInvalidHexNumber;
  2496. X            break;
  2497. X        case BASE_DEC:
  2498. X            sscanf(param->pb + param->index,"%ld",&new_value);
  2499. X            itmp = param->index + strspn(param->pb + param->index,"0123456789");
  2500. X            erc = eInvalidDecNumber;
  2501. X            break;
  2502. X        case BASE_OCT:
  2503. X            sscanf(param->pb + param->index,"%lo",&new_value);
  2504. X            itmp = param->index + strspn(param->pb + param->index,"01234567");
  2505. X            erc = eInvalidOctNumber;
  2506. X            break;
  2507. X        default:
  2508. X            return(eInternalLogicError);
  2509. X    }
  2510. X
  2511. X    param->index = itmp;
  2512. X    if(isalnum(*(param->pb + itmp)))
  2513. X        param->old_index = itmp;
  2514. X
  2515. X    if(param->old_index != param->index)
  2516. X    {
  2517. X        *value = new_value;
  2518. X        return(0);
  2519. X    }
  2520. X    return(erc);
  2521. X
  2522. X}   /* end of gint_constant */
  2523. X
  2524. X/*+-------------------------------------------------------------------------
  2525. X    gint_base(param,value) - evaluate integer constant, variable or function
  2526. X--------------------------------------------------------------------------*/
  2527. Xint
  2528. Xgint_base(param,value)
  2529. XESD *param;
  2530. Xlong *value;
  2531. X{
  2532. Xregister erc;
  2533. Xlong *varptr;
  2534. X
  2535. X    if(erc = skip_cmd_break(param))
  2536. X        return(erc);
  2537. X
  2538. X    switch(param->pb[param->index])        /* look at first character */
  2539. X    {
  2540. X        case '$':        /* '$i...' variable reference? */
  2541. X            if(param->index >= param->cb-2)
  2542. X                return(eSyntaxError);
  2543. X            param->old_index = ++param->index;
  2544. X            if(to_lower(param->pb[param->index++]) != 'i')
  2545. X                return(eIllegalVarType);
  2546. X            if(erc = get_ivptr(param,&varptr,0))
  2547. X                return(erc);
  2548. X            *value = *varptr;    
  2549. X            return(0);
  2550. X
  2551. X        case '%':        /* '%...' function reference? */
  2552. X            param->index++;
  2553. X            if(erc = feval_int(param,value))
  2554. X                return(erc);
  2555. X            return(0);
  2556. SHAR_EOF
  2557. true || echo 'restore of gint.c failed'
  2558. fi
  2559. echo 'End of ecu320 part 16'
  2560. echo 'File gint.c is continued in part 17'
  2561. echo 17 > _shar_seq_.tmp
  2562. exit 0
  2563.  
  2564. exit 0 # Just in case...
  2565.