home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / veos-2.0 / part02 < prev    next >
Encoding:
Text File  |  1993-04-25  |  92.8 KB  |  3,394 lines

  1. Newsgroups: comp.sources.unix
  2. From: voodoo@hitl.washington.edu (Geoffery Coco)
  3. Subject: v26i185: veos-2.0 - The Virtual Environment Operating Shell, V2.0, Part02/16
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: voodoo@hitl.washington.edu (Geoffery Coco)
  8. Posting-Number: Volume 26, Issue 185
  9. Archive-Name: veos-2.0/part02
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 2 (of 16)."
  18. # Contents:  kernel_private/src/fern/fern.lsp
  19. #   kernel_private/src/fern/local.lsp
  20. #   kernel_private/src/include/xv_native.h
  21. #   src/kernel_current/fern/fern.lsp src/kernel_current/fern/local.lsp
  22. #   src/kernel_current/include/xv_native.h src/xlisp/xcore/c/xldbug.c
  23. #   src/xlisp/xcore/c/xlglob.c src/xlisp/xcore/c/xlio.c
  24. #   src/xlisp/xcore/c/xljump.c src/xlisp/xcore/c/xlpp.c
  25. #   src/xlisp/xcore/c/xlsubr.c src/xlisp/xcore/c/xlsym.c
  26. #   src/xlisp/xcore/c/xlsys.c src/xlisp/xcore/c/xmain.c
  27. #   src/xlisp/xmodules.h
  28. # Wrapped by vixie@efficacy.home.vix.com on Sun Apr 25 23:10:32 1993
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'kernel_private/src/fern/fern.lsp' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'kernel_private/src/fern/fern.lsp'\"
  32. else
  33. echo shar: Extracting \"'kernel_private/src/fern/fern.lsp'\" \(5017 characters\)
  34. sed "s/^X//" >'kernel_private/src/fern/fern.lsp' <<'END_OF_FILE'
  35. X;;-----------------------------------------------------------
  36. X;; file: fern.lsp
  37. X;;
  38. X;; FERN is the Fractal Entity Relativity Node.
  39. X;; This file is the controller of the FERN compenents
  40. X;;
  41. X;; creation: February 28, 1992
  42. X;;
  43. X;; by Geoffrey P. Coco at the HITLab, Seattle
  44. X;;-----------------------------------------------------------
  45. X
  46. X;;-----------------------------------------------------------
  47. X;; Copyright (C) 1992  Geoffrey P. Coco,
  48. X;; Human Interface Technology Lab, Seattle
  49. X;;-----------------------------------------------------------
  50. X
  51. X
  52. X;;-----------------------------------------------------------
  53. X;;             Fern System
  54. X;;-----------------------------------------------------------
  55. X#|
  56. X
  57. XFern is a distributed world information management system.
  58. XFern provides the transparent underpinnings for distributed
  59. Xworld data maintenance.
  60. X
  61. XFern maintains a "perc" (e.g. perception) partition in an
  62. Xentity's grouplespace (see below).  Fern transparently
  63. Xupdates the "perc" partition of an entity's local
  64. Xgrouplespace to contain all world data relevant to the
  65. Xentity.
  66. X
  67. X("perc"
  68. X
  69. X    (;ext
  70. X  
  71. X        (;sps (;ent))
  72. X   
  73. X        (;sibs (;ent (;ob (;attr))))
  74. X
  75. X        (;fltrs)
  76. X    )
  77. X    (;bndry
  78. X
  79. X        (;vrt (;ob (;attr)))
  80. X   
  81. X        (;phys (;ob (;attr)))
  82. X    )
  83. X    (;int
  84. X
  85. X        (;subs (;ent (;ob (;attr))))
  86. X
  87. X    (;fltrs (;ent))
  88. X
  89. X        (;locl (;ob (;attr)))
  90. X    )
  91. X)
  92. X
  93. XThe "perc" partition is accessable through fe- functions.
  94. XUse fe- functions by composing the partition names you want
  95. Xto access.  For example, if you want to change an attribute
  96. Xin the virtual boundary, use (fe-put.bndry.vrt.ob.attr)
  97. X
  98. X|#
  99. X;;-----------------------------------------------------------
  100. X
  101. X
  102. X
  103. X;;-----------------------------------------------------------
  104. X;;             Fern Initialization
  105. X;;-----------------------------------------------------------
  106. X
  107. X
  108. X(defun fern-init ()
  109. X  (progn
  110. X
  111. X    ;;;
  112. X    ;;; init the VEOS kernel
  113. X    ;;; watch out for previous initialization
  114. X    ;;;
  115. X
  116. X    (let (zoot)
  117. X      (cond ((setq zoot (vinit))
  118. X         (setq self zoot))))
  119. X
  120. X    ;;;
  121. X    ;;; other initial accounting
  122. X    ;;;
  123. X
  124. X    (setq fern-debug t)
  125. X
  126. X
  127. X    ;;;
  128. X    ;;; initialize Fern System C module
  129. X    ;;;
  130. X
  131. X    (fbase-init)
  132. X
  133. X
  134. X    ;;;
  135. X    ;;; load and initialize Fern System lisp modules
  136. X    ;;;
  137. X
  138. X    (load "fgod")
  139. X    (fgod-init)
  140. X
  141. X    (load "fe")
  142. X    (fe-init)
  143. X
  144. X    (load "fx")
  145. X    (fx-init)
  146. X
  147. X    (load "fcon")
  148. X    (fcon-init)
  149. X
  150. X    (load "fph")
  151. X    (fph-init)
  152. X
  153. X
  154. X    ;;;
  155. X    ;;; print fern header
  156. X    ;;;
  157. X
  158. X    (fern-credits)
  159. X    t))
  160. X
  161. X;;-----------------------------------------------------------
  162. X
  163. X
  164. X
  165. X;;-----------------------------------------------------------
  166. X;;              Utilities
  167. X;;-----------------------------------------------------------
  168. X
  169. X
  170. X;;-----------------------------------------------------------
  171. X
  172. X(defun dump ()
  173. X  (pprint (vcopy '(> @@))))
  174. X
  175. X(defun empty ()
  176. X  (pprint (vget '(> @@))))
  177. X
  178. X(defmacro pp (expr) (pprint (eval expr)))
  179. X
  180. X;;-----------------------------------------------------------
  181. X
  182. X(defun uid2str (uid)
  183. X  (sprintf (aref uid 0) " " (aref uid 1)))
  184. X
  185. X(defun str2uid (str)
  186. X  (let ((lst (sscanf str)))
  187. X    (vector (car lst) (cadr lst))))
  188. X
  189. X;;-----------------------------------------------------------
  190. X
  191. X(defun vect2list (vect)
  192. X  (do ((ret NIL)
  193. X       (index (1- (length vect))))
  194. X
  195. X      ((eq index -1)
  196. X       ret)
  197. X
  198. X      (setq ret (cons (aref vect index) ret))
  199. X      (setq index (1- index))
  200. X      ))
  201. X
  202. X;;-----------------------------------------------------------
  203. X
  204. X(defun list2vect (lst)
  205. X  (do* ((len (length lst))
  206. X    (ret (make-array len))
  207. X    (index 0))
  208. X
  209. X       ((eq index len)
  210. X    ret)
  211. X
  212. X       (setf (aref ret index) (car lst))
  213. X       (setq index (1+ index))
  214. X       (setq lst (cdr lst))
  215. X       ))
  216. X
  217. X;;-----------------------------------------------------------
  218. X
  219. X;; a partition looks like ("name" (everything))
  220. X(defun put-gspace-partition (new-part)
  221. X  (cond 
  222. X   ;; assume partition is already there
  223. X   ((vput new-part `(> (,(car new-part) @@) **)))
  224. X
  225. X   ;; partition wasn't there, insert new
  226. X   ((vput new-part '(^ @@)))))
  227. X
  228. X;; part name is a string
  229. X(defun copy-gspace-partition (part-name)
  230. X  (car (vcopy `(> (,part-name @@) **))))
  231. X
  232. X;; part name is a string
  233. X(defun get-gspace-partition (part-name)
  234. X  (car (vget `(> (,part-name @@) **))))
  235. X
  236. X;;-----------------------------------------------------------
  237. X
  238. X(defun do-procs (pro-list)
  239. X  (dolist (proc pro-list)
  240. X      (eval (cadr proc))))
  241. X
  242. X;;-----------------------------------------------------------
  243. X
  244. X
  245. X
  246. X
  247. X;;-----------------------------------------------------------
  248. X;;         Main Fern Private Functions
  249. X;;-----------------------------------------------------------
  250. X
  251. X
  252. X;;-----------------------------------------------------------
  253. X(defun fern-credits ()
  254. X  (printf "
  255. X
  256. X
  257. X         ``````````````````````````
  258. X           The Fern System v1.0b1
  259. X                        by Geoff Coco
  260. X          Copyright (C) 1992, HITL
  261. X
  262. X         ''''''''''''''''''''''''''
  263. X"))
  264. X
  265. X;;-----------------------------------------------------------
  266. X
  267. X
  268. X
  269. X
  270. X
  271. X;;-----------------------------------------------------------
  272. X;;            Invoke Initialization
  273. X;;-----------------------------------------------------------
  274. X
  275. X(fern-init)
  276. X
  277. X
  278. X
  279. X
  280. X
  281. END_OF_FILE
  282. if test 5017 -ne `wc -c <'kernel_private/src/fern/fern.lsp'`; then
  283.     echo shar: \"'kernel_private/src/fern/fern.lsp'\" unpacked with wrong size!
  284. fi
  285. # end of 'kernel_private/src/fern/fern.lsp'
  286. fi
  287. if test -f 'kernel_private/src/fern/local.lsp' -a "${1}" != "-c" ; then 
  288.   echo shar: Will not clobber existing file \"'kernel_private/src/fern/local.lsp'\"
  289. else
  290. echo shar: Extracting \"'kernel_private/src/fern/local.lsp'\" \(5513 characters\)
  291. sed "s/^X//" >'kernel_private/src/fern/local.lsp' <<'END_OF_FILE'
  292. X;
  293. X; local.lsp
  294. X;
  295. X; Copyright (C) 1992  Washington Technology Center
  296. X;
  297. X; by Andrew MacDonald at the HITLab
  298. X;
  299. X; object caching in the local workspace
  300. X;
  301. X; this is based on fe_bnd.lsp and fe_int.lsp, and manipulates objects
  302. X; in perc.int.locl 
  303. X;
  304. X; functions are of the form fe-(put|get|copy).int.locl.(accessors),
  305. X; with macros of the form lo-(put|get|copy).(accessors) defined
  306. X; for each function
  307. X;
  308. X;;-----------------------------------------------------------
  309. X;; file: fe.lsp
  310. X;; by Geoffrey P. Coco at the HITLab, Seattle
  311. X;;-----------------------------------------------------------
  312. X
  313. X;;-----------------------------------------------------------
  314. X;; Copyright (C) 1992  Human Interface Technology Lab, Seattle
  315. X;;-----------------------------------------------------------
  316. X
  317. X
  318. X;;===========================================================
  319. X;;               Local Objects
  320. X;;===========================================================
  321. X
  322. X(defun fe-jam.int.locl.ob (ob)
  323. X  (vput ob
  324. X    '(("perc"
  325. X       @2
  326. X       ((^ @@) @2)) **)))
  327. X  
  328. X;;-----------------------------------------------------------
  329. X
  330. X;; objects are (ob-name (attr-list))
  331. X(defun fe-put.int.locl.ob (ob)
  332. X  (cond
  333. X
  334. X   ;; assume object is already there
  335. X   ((car (vput ob `(("perc"
  336. X             @2
  337. X             ((> (,(car ob) @) **) @2)) **))))
  338. X
  339. X   ;; object wasn't there, insert new one
  340. X   ((fe-jam.int.locl.ob ob))
  341. X   ))
  342. X
  343. X;;-----------------------------------------------------------
  344. X
  345. X;; pass object name
  346. X(defun fe-copy.int.locl.ob (ob-name)
  347. X  (car (vcopy `(("perc"
  348. X         @2
  349. X         ((> (,ob-name @) **) @2)) **))))
  350. X
  351. X;;-----------------------------------------------------------
  352. X
  353. X;; pass object name, returns entire object
  354. X(defun fe-get.int.locl.ob (ob-name)
  355. X  (car (vget `(("perc"
  356. X        @2
  357. X        ((> (,ob-name @) **) @2)) **))))
  358. X
  359. X;;-----------------------------------------------------------
  360. X
  361. X
  362. X
  363. X;;===========================================================
  364. X;;          Local Object - Complex
  365. X;;===========================================================
  366. X
  367. X(defun fe-copy.int.locl.ob.names ()
  368. X  (vcopy `(("perc"
  369. X        @2
  370. X        (((> @ @) **) @2)) **)
  371. X     :freq "all"))
  372. X
  373. X;;-----------------------------------------------------------
  374. X
  375. X
  376. X
  377. X
  378. X;;===========================================================
  379. X;;          Local Object Attributes
  380. X;;===========================================================
  381. X
  382. X(defun fe-jam.int.locl.ob.attr (ob-name attr)
  383. X  (cond
  384. X   ;; assume object exists, add new attr
  385. X   ((vput attr `(("perc"
  386. X          @2
  387. X          (((,ob-name (^ @@)) **) @2)) **)))
  388. X
  389. X   ;; object didn't exist, add new object with new attr.
  390. X   ((fe-jam.int.locl.ob `(,ob-name (,attr))))
  391. X   ))
  392. X
  393. X;;-----------------------------------------------------------
  394. X
  395. X(defun fe-put.int.locl.ob.attr (ob-name attr)
  396. X  (cond
  397. X
  398. X   ;; assume the object and attr exist, swap in new attr
  399. X   ((car (vput attr `(("perc"
  400. X               @2
  401. X               (((,ob-name (> (,(car attr) @) **)) **) @2)) **))))
  402. X    
  403. X   ;; attr didn't exist, add new attr
  404. X   ((fe-jam.int.locl.ob.attr ob-name attr))
  405. X   ))
  406. X
  407. X;;-----------------------------------------------------------
  408. X
  409. X(defun fe-get.int.locl.ob.attr (ob-name attr-name)
  410. X  (car (vget `(("perc"
  411. X        @2
  412. X        (((,ob-name (> (,attr-name @) **)) **) @2)) **))))
  413. X
  414. X;;-----------------------------------------------------------
  415. X
  416. X;; returns attr struct
  417. X(defun fe-copy.int.locl.ob.attr (ob-name attr-name)
  418. X  (car (vcopy `(("perc"
  419. X         @2
  420. X         (((,ob-name (> (,attr-name @) **)) **) @2)) **))))
  421. X  
  422. X;;-----------------------------------------------------------
  423. X
  424. X
  425. X
  426. X;;===========================================================
  427. X;;         Local Object Attributes - Complex
  428. X;;===========================================================
  429. X
  430. X;; returns list of boundary attribute names
  431. X(defun fe-copy.int.locl.ob.attr.names (ob-name)
  432. X  (vcopy `(("perc"
  433. X        @2
  434. X        (((,ob-name ((> @ @) **)) **) @2)) **)
  435. X     :freq "all"))
  436. X
  437. X;;-----------------------------------------------------------
  438. X
  439. X;; returns attr val
  440. X(defun fe-copy.int.locl.ob.attr.val (ob-name attr-name)
  441. X  (car (vcopy `(("perc"
  442. X         @2
  443. X         (((,ob-name ((,attr-name > @) **)) **) @2)) **))))
  444. X  
  445. X;;===========================================================
  446. X;;         Show Local Object Space
  447. X;;===========================================================
  448. X
  449. X(defun lo-dump ()
  450. X  (pprint (fe-copy.int.locl)))
  451. X
  452. X(defun lo-empty ()
  453. X  (pprint (fe-get.int.locl)))
  454. X
  455. X;;===========================================================
  456. X;;         Macro Shortcuts
  457. X;;===========================================================
  458. X
  459. X(defmacro lo-jam-ob (ob)
  460. X  `(fe-jam.int.locl.ob ,ob))
  461. X
  462. X(defmacro lo-put-ob (ob)
  463. X  `(fe-put.int.locl.ob ,ob))
  464. X
  465. X(defmacro lo-copy-ob (ob-name)
  466. X  `(fe-copy.int.locl.ob ,ob-name))
  467. X
  468. X(defmacro lo-get-ob (ob-name)
  469. X  `(fe-get.int.locl.ob ,ob-name))
  470. X
  471. X;----------------------------------------------------------------
  472. X
  473. X(defmacro lo-copy-ob-names ()
  474. X  '(fe-copy.int.locl.ob.names))
  475. X
  476. X;----------------------------------------------------------------
  477. X
  478. X(defmacro lo-jab-attr (ob-name attr)
  479. X  `(fe-jam.int.locl.ob.attr ,ob-name ,attr))
  480. X
  481. X(defmacro lo-put-attr (ob-name attr)
  482. X  `(fe-put.int.locl.ob.attr ,ob-name ,attr))
  483. X
  484. X;----------------------------------------------------------------
  485. X
  486. X(defmacro lo-get-attr (ob-name attr-name)
  487. X  `(fe-get.int.locl.ob.attr ,ob-name ,attr-name))
  488. X
  489. X;----------------------------------------------------------------
  490. X
  491. X(defmacro lo-copy-attr (ob-name attr-name)
  492. X  `(fe-copy.int.locl.ob.attr ,ob-name ,attr-name))
  493. X
  494. X(defmacro lo-copy-attr-names (ob-name)
  495. X  `(fe-copy.int.locl.ob.attr.names ,ob-name))
  496. X
  497. X(defmacro lo-copy-attr-val (ob-name attr-name)
  498. X  `(fe-copy.int.locl.ob.attr.val ,ob-name ,attr-name))
  499. X
  500. END_OF_FILE
  501. if test 5513 -ne `wc -c <'kernel_private/src/fern/local.lsp'`; then
  502.     echo shar: \"'kernel_private/src/fern/local.lsp'\" unpacked with wrong size!
  503. fi
  504. # end of 'kernel_private/src/fern/local.lsp'
  505. fi
  506. if test -f 'kernel_private/src/include/xv_native.h' -a "${1}" != "-c" ; then 
  507.   echo shar: Will not clobber existing file \"'kernel_private/src/include/xv_native.h'\"
  508. else
  509. echo shar: Extracting \"'kernel_private/src/include/xv_native.h'\" \(3846 characters\)
  510. sed "s/^X//" >'kernel_private/src/include/xv_native.h' <<'END_OF_FILE'
  511. X/****************************************************************************************
  512. X *                                            *
  513. X * file: xv_native.h                                    *
  514. X *                                            *
  515. X * the xlisp include file for integration with VEOS native prims.            *
  516. X *                                            *
  517. X * creation: December, 1991                                *
  518. X *                                            *
  519. X *                                            *
  520. X * by Geoffrey P. Coco at the HITLab, Seattle.                          *
  521. X *                                            *
  522. X ****************************************************************************************/
  523. X
  524. X/****************************************************************************************
  525. X * Copyright (C) 1992  Geoffrey P. Coco, Human Interface Technology Lab, Seattle    *
  526. X ****************************************************************************************/
  527. X
  528. X
  529. X#ifdef DEFINE_NATIVE_GLOBS
  530. X#define NEXTERN
  531. X#else
  532. X#define NEXTERN extern
  533. X#endif
  534. X
  535. X/****************************************************************************************/
  536. X
  537. X
  538. X/****************************************************************************************/
  539. X
  540. Xtypedef struct {
  541. X
  542. X    TPGrouple        pSrcGr;        /* the actual src data */
  543. X    TPGrouple        pPatGr;        /* how to match */
  544. X    int            iDestroyFlag;    /* copy, remove, gimme, replace */
  545. X    int            iFreqFlag;    /* once or all occasions */
  546. X
  547. X    LVAL        pXReplaceElt;    /* possible replacement data */
  548. X    TPTimeStamp        pStampTime;    /* optional time to stamp new data */
  549. X    TPTimeStamp        pTestTime;    /* optional time to compare with matched data */
  550. X    LVAL        pXResult;    /* result data to pass back */
  551. X
  552. X    } TXMandRRec,
  553. X      *TPXMandRRec,
  554. X      **THXMandRRec;
  555. X
  556. X
  557. Xtypedef struct {
  558. X    boolean    bOrdered;
  559. X    boolean    bExpContent;
  560. X    boolean    bExpOrder;
  561. X    boolean    bMarkedWithin;
  562. X    boolean    bTouchedWithin;
  563. X
  564. X    boolean    bMarkNextElt;
  565. X    boolean    bTouchNextElt;
  566. X    boolean    bMustEnd;
  567. X    boolean    bGetAnother;
  568. X
  569. X    } TPatStatRec,
  570. X      *TPPatStatRec,
  571. X      **THPatStatRec;
  572. X
  573. X/****************************************************************************************/
  574. X
  575. X#define NATIVE_BADTYPE        -10
  576. X#define NATIVE_NOKERNEL        -11
  577. X#define NATIVE_BADFREQ        -12
  578. X#define NATIVE_2KERNELS        -13
  579. X#define NATIVE_BADVTYPE        -14
  580. X#define NATIVE_THISWHAT        -15
  581. X#define NATIVE_TOOMANYMARKS    -16
  582. X#define NATIVE_CANTMIX        -17
  583. X#define NATIVE_NOREPLACEMARK    -18
  584. X#define NATIVE_NOFETCHMARK    -19
  585. X#define NATIVE_NOVOID        -20
  586. X#define NATIVE_BADPATSYMBOL    -21
  587. X#define NATIVE_CRAZYWILD    -22
  588. X#define NATIVE_MATCHFAIL    -23
  589. X#define NATIVE_NODATA        -24
  590. X#define NATIVE_EMPTYELT        -25
  591. X#define NATIVE_STARMORE        -26
  592. X#define NATIVE_NOTEND        -27
  593. X#define NATIVE_BADVOID        -28
  594. X#define NATIVE_NOSTARN        -29
  595. X#define NATIVE_BADXTYPE        -30
  596. X#define NATIVE_NOHOST        -31
  597. X#define NATIVE_NOTOUCH        -32
  598. X#define NATIVE_MODVOID        -33
  599. X
  600. X#define NATIVE_SYMBOL        10
  601. X#define NATIVE_STALE        -40
  602. X
  603. X/****************************************************************************************/
  604. X
  605. Xextern LVAL     xsendmsg0();
  606. Xextern LVAL    s_unbound;
  607. Xextern LVAL    true;
  608. Xextern LVAL     xlfatal();
  609. Xextern LVAL    s_stderr;
  610. X
  611. X/****************************************************************************************/
  612. X
  613. XNEXTERN LVAL        s_InSpace, k_TestTime, k_Freq;
  614. XNEXTERN LVAL           *hMsgList;
  615. XNEXTERN TXMandRRec    native_getPB, native_copyPB, native_putPB;
  616. X
  617. X/****************************************************************************************/
  618. X
  619. X#define NATIVE_INSPACE hMsgList
  620. X
  621. X#define NATIVE_TIME_ARG(pTime, tTest) \
  622. X{ \
  623. X    LVAL        pXTime; \
  624. X    TTimeStamp        tRead; \
  625. X\
  626. X    if (xlgetkeyarg(k_TestTime, &pXTime) && !null(pXTime)) { \
  627. X    XELT2TIME(pXTime, tTest); \
  628. X    pTime = &tTest; \
  629. X\
  630. X    GET_TIME(tRead); \
  631. X    TIME2XELT(tRead, pXTime); \
  632. X    } \
  633. X    else \
  634. X    pTime = nil; \
  635. X    }
  636. X
  637. X
  638. X#define NATIVE_FREQ_ARG(iFlag) \
  639. X{ \
  640. X    LVAL    pXFreq; \
  641. X\
  642. X    if (xlgetkeyarg(k_Freq, &pXFreq) && \
  643. X    (strcmp((char *)getstring(pXFreq), "all") == 0)) \
  644. X    iFlag = NANCY_MatchMany; \
  645. X    else \
  646. X    iFlag = NANCY_MatchOne; \
  647. X    }
  648. X
  649. X/****************************************************************************************/
  650. X
  651. X
  652. END_OF_FILE
  653. if test 3846 -ne `wc -c <'kernel_private/src/include/xv_native.h'`; then
  654.     echo shar: \"'kernel_private/src/include/xv_native.h'\" unpacked with wrong size!
  655. fi
  656. # end of 'kernel_private/src/include/xv_native.h'
  657. fi
  658. if test -f 'src/kernel_current/fern/fern.lsp' -a "${1}" != "-c" ; then 
  659.   echo shar: Will not clobber existing file \"'src/kernel_current/fern/fern.lsp'\"
  660. else
  661. echo shar: Extracting \"'src/kernel_current/fern/fern.lsp'\" \(5017 characters\)
  662. sed "s/^X//" >'src/kernel_current/fern/fern.lsp' <<'END_OF_FILE'
  663. X;;-----------------------------------------------------------
  664. X;; file: fern.lsp
  665. X;;
  666. X;; FERN is the Fractal Entity Relativity Node.
  667. X;; This file is the controller of the FERN compenents
  668. X;;
  669. X;; creation: February 28, 1992
  670. X;;
  671. X;; by Geoffrey P. Coco at the HITLab, Seattle
  672. X;;-----------------------------------------------------------
  673. X
  674. X;;-----------------------------------------------------------
  675. X;; Copyright (C) 1992  Geoffrey P. Coco,
  676. X;; Human Interface Technology Lab, Seattle
  677. X;;-----------------------------------------------------------
  678. X
  679. X
  680. X;;-----------------------------------------------------------
  681. X;;             Fern System
  682. X;;-----------------------------------------------------------
  683. X#|
  684. X
  685. XFern is a distributed world information management system.
  686. XFern provides the transparent underpinnings for distributed
  687. Xworld data maintenance.
  688. X
  689. XFern maintains a "perc" (e.g. perception) partition in an
  690. Xentity's grouplespace (see below).  Fern transparently
  691. Xupdates the "perc" partition of an entity's local
  692. Xgrouplespace to contain all world data relevant to the
  693. Xentity.
  694. X
  695. X("perc"
  696. X
  697. X    (;ext
  698. X  
  699. X        (;sps (;ent))
  700. X   
  701. X        (;sibs (;ent (;ob (;attr))))
  702. X
  703. X        (;fltrs)
  704. X    )
  705. X    (;bndry
  706. X
  707. X        (;vrt (;ob (;attr)))
  708. X   
  709. X        (;phys (;ob (;attr)))
  710. X    )
  711. X    (;int
  712. X
  713. X        (;subs (;ent (;ob (;attr))))
  714. X
  715. X    (;fltrs (;ent))
  716. X
  717. X        (;locl (;ob (;attr)))
  718. X    )
  719. X)
  720. X
  721. XThe "perc" partition is accessable through fe- functions.
  722. XUse fe- functions by composing the partition names you want
  723. Xto access.  For example, if you want to change an attribute
  724. Xin the virtual boundary, use (fe-put.bndry.vrt.ob.attr)
  725. X
  726. X|#
  727. X;;-----------------------------------------------------------
  728. X
  729. X
  730. X
  731. X;;-----------------------------------------------------------
  732. X;;             Fern Initialization
  733. X;;-----------------------------------------------------------
  734. X
  735. X
  736. X(defun fern-init ()
  737. X  (progn
  738. X
  739. X    ;;;
  740. X    ;;; init the VEOS kernel
  741. X    ;;; watch out for previous initialization
  742. X    ;;;
  743. X
  744. X    (let (zoot)
  745. X      (cond ((setq zoot (vinit))
  746. X         (setq self zoot))))
  747. X
  748. X    ;;;
  749. X    ;;; other initial accounting
  750. X    ;;;
  751. X
  752. X    (setq fern-debug t)
  753. X
  754. X
  755. X    ;;;
  756. X    ;;; initialize Fern System C module
  757. X    ;;;
  758. X
  759. X    (fbase-init)
  760. X
  761. X
  762. X    ;;;
  763. X    ;;; load and initialize Fern System lisp modules
  764. X    ;;;
  765. X
  766. X    (load "fgod")
  767. X    (fgod-init)
  768. X
  769. X    (load "fe")
  770. X    (fe-init)
  771. X
  772. X    (load "fx")
  773. X    (fx-init)
  774. X
  775. X    (load "fcon")
  776. X    (fcon-init)
  777. X
  778. X    (load "fph")
  779. X    (fph-init)
  780. X
  781. X
  782. X    ;;;
  783. X    ;;; print fern header
  784. X    ;;;
  785. X
  786. X    (fern-credits)
  787. X    t))
  788. X
  789. X;;-----------------------------------------------------------
  790. X
  791. X
  792. X
  793. X;;-----------------------------------------------------------
  794. X;;              Utilities
  795. X;;-----------------------------------------------------------
  796. X
  797. X
  798. X;;-----------------------------------------------------------
  799. X
  800. X(defun dump ()
  801. X  (pprint (vcopy '(> @@))))
  802. X
  803. X(defun empty ()
  804. X  (pprint (vget '(> @@))))
  805. X
  806. X(defmacro pp (expr) (pprint (eval expr)))
  807. X
  808. X;;-----------------------------------------------------------
  809. X
  810. X(defun uid2str (uid)
  811. X  (sprintf (aref uid 0) " " (aref uid 1)))
  812. X
  813. X(defun str2uid (str)
  814. X  (let ((lst (sscanf str)))
  815. X    (vector (car lst) (cadr lst))))
  816. X
  817. X;;-----------------------------------------------------------
  818. X
  819. X(defun vect2list (vect)
  820. X  (do ((ret NIL)
  821. X       (index (1- (length vect))))
  822. X
  823. X      ((eq index -1)
  824. X       ret)
  825. X
  826. X      (setq ret (cons (aref vect index) ret))
  827. X      (setq index (1- index))
  828. X      ))
  829. X
  830. X;;-----------------------------------------------------------
  831. X
  832. X(defun list2vect (lst)
  833. X  (do* ((len (length lst))
  834. X    (ret (make-array len))
  835. X    (index 0))
  836. X
  837. X       ((eq index len)
  838. X    ret)
  839. X
  840. X       (setf (aref ret index) (car lst))
  841. X       (setq index (1+ index))
  842. X       (setq lst (cdr lst))
  843. X       ))
  844. X
  845. X;;-----------------------------------------------------------
  846. X
  847. X;; a partition looks like ("name" (everything))
  848. X(defun put-gspace-partition (new-part)
  849. X  (cond 
  850. X   ;; assume partition is already there
  851. X   ((vput new-part `(> (,(car new-part) @@) **)))
  852. X
  853. X   ;; partition wasn't there, insert new
  854. X   ((vput new-part '(^ @@)))))
  855. X
  856. X;; part name is a string
  857. X(defun copy-gspace-partition (part-name)
  858. X  (car (vcopy `(> (,part-name @@) **))))
  859. X
  860. X;; part name is a string
  861. X(defun get-gspace-partition (part-name)
  862. X  (car (vget `(> (,part-name @@) **))))
  863. X
  864. X;;-----------------------------------------------------------
  865. X
  866. X(defun do-procs (pro-list)
  867. X  (dolist (proc pro-list)
  868. X      (eval (cadr proc))))
  869. X
  870. X;;-----------------------------------------------------------
  871. X
  872. X
  873. X
  874. X
  875. X;;-----------------------------------------------------------
  876. X;;         Main Fern Private Functions
  877. X;;-----------------------------------------------------------
  878. X
  879. X
  880. X;;-----------------------------------------------------------
  881. X(defun fern-credits ()
  882. X  (printf "
  883. X
  884. X
  885. X         ``````````````````````````
  886. X           The Fern System v1.0b1
  887. X                        by Geoff Coco
  888. X          Copyright (C) 1992, HITL
  889. X
  890. X         ''''''''''''''''''''''''''
  891. X"))
  892. X
  893. X;;-----------------------------------------------------------
  894. X
  895. X
  896. X
  897. X
  898. X
  899. X;;-----------------------------------------------------------
  900. X;;            Invoke Initialization
  901. X;;-----------------------------------------------------------
  902. X
  903. X(fern-init)
  904. X
  905. X
  906. X
  907. X
  908. X
  909. END_OF_FILE
  910. if test 5017 -ne `wc -c <'src/kernel_current/fern/fern.lsp'`; then
  911.     echo shar: \"'src/kernel_current/fern/fern.lsp'\" unpacked with wrong size!
  912. fi
  913. # end of 'src/kernel_current/fern/fern.lsp'
  914. fi
  915. if test -f 'src/kernel_current/fern/local.lsp' -a "${1}" != "-c" ; then 
  916.   echo shar: Will not clobber existing file \"'src/kernel_current/fern/local.lsp'\"
  917. else
  918. echo shar: Extracting \"'src/kernel_current/fern/local.lsp'\" \(5513 characters\)
  919. sed "s/^X//" >'src/kernel_current/fern/local.lsp' <<'END_OF_FILE'
  920. X;
  921. X; local.lsp
  922. X;
  923. X; Copyright (C) 1992  Washington Technology Center
  924. X;
  925. X; by Andrew MacDonald at the HITLab
  926. X;
  927. X; object caching in the local workspace
  928. X;
  929. X; this is based on fe_bnd.lsp and fe_int.lsp, and manipulates objects
  930. X; in perc.int.locl 
  931. X;
  932. X; functions are of the form fe-(put|get|copy).int.locl.(accessors),
  933. X; with macros of the form lo-(put|get|copy).(accessors) defined
  934. X; for each function
  935. X;
  936. X;;-----------------------------------------------------------
  937. X;; file: fe.lsp
  938. X;; by Geoffrey P. Coco at the HITLab, Seattle
  939. X;;-----------------------------------------------------------
  940. X
  941. X;;-----------------------------------------------------------
  942. X;; Copyright (C) 1992  Human Interface Technology Lab, Seattle
  943. X;;-----------------------------------------------------------
  944. X
  945. X
  946. X;;===========================================================
  947. X;;               Local Objects
  948. X;;===========================================================
  949. X
  950. X(defun fe-jam.int.locl.ob (ob)
  951. X  (vput ob
  952. X    '(("perc"
  953. X       @2
  954. X       ((^ @@) @2)) **)))
  955. X  
  956. X;;-----------------------------------------------------------
  957. X
  958. X;; objects are (ob-name (attr-list))
  959. X(defun fe-put.int.locl.ob (ob)
  960. X  (cond
  961. X
  962. X   ;; assume object is already there
  963. X   ((car (vput ob `(("perc"
  964. X             @2
  965. X             ((> (,(car ob) @) **) @2)) **))))
  966. X
  967. X   ;; object wasn't there, insert new one
  968. X   ((fe-jam.int.locl.ob ob))
  969. X   ))
  970. X
  971. X;;-----------------------------------------------------------
  972. X
  973. X;; pass object name
  974. X(defun fe-copy.int.locl.ob (ob-name)
  975. X  (car (vcopy `(("perc"
  976. X         @2
  977. X         ((> (,ob-name @) **) @2)) **))))
  978. X
  979. X;;-----------------------------------------------------------
  980. X
  981. X;; pass object name, returns entire object
  982. X(defun fe-get.int.locl.ob (ob-name)
  983. X  (car (vget `(("perc"
  984. X        @2
  985. X        ((> (,ob-name @) **) @2)) **))))
  986. X
  987. X;;-----------------------------------------------------------
  988. X
  989. X
  990. X
  991. X;;===========================================================
  992. X;;          Local Object - Complex
  993. X;;===========================================================
  994. X
  995. X(defun fe-copy.int.locl.ob.names ()
  996. X  (vcopy `(("perc"
  997. X        @2
  998. X        (((> @ @) **) @2)) **)
  999. X     :freq "all"))
  1000. X
  1001. X;;-----------------------------------------------------------
  1002. X
  1003. X
  1004. X
  1005. X
  1006. X;;===========================================================
  1007. X;;          Local Object Attributes
  1008. X;;===========================================================
  1009. X
  1010. X(defun fe-jam.int.locl.ob.attr (ob-name attr)
  1011. X  (cond
  1012. X   ;; assume object exists, add new attr
  1013. X   ((vput attr `(("perc"
  1014. X          @2
  1015. X          (((,ob-name (^ @@)) **) @2)) **)))
  1016. X
  1017. X   ;; object didn't exist, add new object with new attr.
  1018. X   ((fe-jam.int.locl.ob `(,ob-name (,attr))))
  1019. X   ))
  1020. X
  1021. X;;-----------------------------------------------------------
  1022. X
  1023. X(defun fe-put.int.locl.ob.attr (ob-name attr)
  1024. X  (cond
  1025. X
  1026. X   ;; assume the object and attr exist, swap in new attr
  1027. X   ((car (vput attr `(("perc"
  1028. X               @2
  1029. X               (((,ob-name (> (,(car attr) @) **)) **) @2)) **))))
  1030. X    
  1031. X   ;; attr didn't exist, add new attr
  1032. X   ((fe-jam.int.locl.ob.attr ob-name attr))
  1033. X   ))
  1034. X
  1035. X;;-----------------------------------------------------------
  1036. X
  1037. X(defun fe-get.int.locl.ob.attr (ob-name attr-name)
  1038. X  (car (vget `(("perc"
  1039. X        @2
  1040. X        (((,ob-name (> (,attr-name @) **)) **) @2)) **))))
  1041. X
  1042. X;;-----------------------------------------------------------
  1043. X
  1044. X;; returns attr struct
  1045. X(defun fe-copy.int.locl.ob.attr (ob-name attr-name)
  1046. X  (car (vcopy `(("perc"
  1047. X         @2
  1048. X         (((,ob-name (> (,attr-name @) **)) **) @2)) **))))
  1049. X  
  1050. X;;-----------------------------------------------------------
  1051. X
  1052. X
  1053. X
  1054. X;;===========================================================
  1055. X;;         Local Object Attributes - Complex
  1056. X;;===========================================================
  1057. X
  1058. X;; returns list of boundary attribute names
  1059. X(defun fe-copy.int.locl.ob.attr.names (ob-name)
  1060. X  (vcopy `(("perc"
  1061. X        @2
  1062. X        (((,ob-name ((> @ @) **)) **) @2)) **)
  1063. X     :freq "all"))
  1064. X
  1065. X;;-----------------------------------------------------------
  1066. X
  1067. X;; returns attr val
  1068. X(defun fe-copy.int.locl.ob.attr.val (ob-name attr-name)
  1069. X  (car (vcopy `(("perc"
  1070. X         @2
  1071. X         (((,ob-name ((,attr-name > @) **)) **) @2)) **))))
  1072. X  
  1073. X;;===========================================================
  1074. X;;         Show Local Object Space
  1075. X;;===========================================================
  1076. X
  1077. X(defun lo-dump ()
  1078. X  (pprint (fe-copy.int.locl)))
  1079. X
  1080. X(defun lo-empty ()
  1081. X  (pprint (fe-get.int.locl)))
  1082. X
  1083. X;;===========================================================
  1084. X;;         Macro Shortcuts
  1085. X;;===========================================================
  1086. X
  1087. X(defmacro lo-jam-ob (ob)
  1088. X  `(fe-jam.int.locl.ob ,ob))
  1089. X
  1090. X(defmacro lo-put-ob (ob)
  1091. X  `(fe-put.int.locl.ob ,ob))
  1092. X
  1093. X(defmacro lo-copy-ob (ob-name)
  1094. X  `(fe-copy.int.locl.ob ,ob-name))
  1095. X
  1096. X(defmacro lo-get-ob (ob-name)
  1097. X  `(fe-get.int.locl.ob ,ob-name))
  1098. X
  1099. X;----------------------------------------------------------------
  1100. X
  1101. X(defmacro lo-copy-ob-names ()
  1102. X  '(fe-copy.int.locl.ob.names))
  1103. X
  1104. X;----------------------------------------------------------------
  1105. X
  1106. X(defmacro lo-jab-attr (ob-name attr)
  1107. X  `(fe-jam.int.locl.ob.attr ,ob-name ,attr))
  1108. X
  1109. X(defmacro lo-put-attr (ob-name attr)
  1110. X  `(fe-put.int.locl.ob.attr ,ob-name ,attr))
  1111. X
  1112. X;----------------------------------------------------------------
  1113. X
  1114. X(defmacro lo-get-attr (ob-name attr-name)
  1115. X  `(fe-get.int.locl.ob.attr ,ob-name ,attr-name))
  1116. X
  1117. X;----------------------------------------------------------------
  1118. X
  1119. X(defmacro lo-copy-attr (ob-name attr-name)
  1120. X  `(fe-copy.int.locl.ob.attr ,ob-name ,attr-name))
  1121. X
  1122. X(defmacro lo-copy-attr-names (ob-name)
  1123. X  `(fe-copy.int.locl.ob.attr.names ,ob-name))
  1124. X
  1125. X(defmacro lo-copy-attr-val (ob-name attr-name)
  1126. X  `(fe-copy.int.locl.ob.attr.val ,ob-name ,attr-name))
  1127. X
  1128. END_OF_FILE
  1129. if test 5513 -ne `wc -c <'src/kernel_current/fern/local.lsp'`; then
  1130.     echo shar: \"'src/kernel_current/fern/local.lsp'\" unpacked with wrong size!
  1131. fi
  1132. # end of 'src/kernel_current/fern/local.lsp'
  1133. fi
  1134. if test -f 'src/kernel_current/include/xv_native.h' -a "${1}" != "-c" ; then 
  1135.   echo shar: Will not clobber existing file \"'src/kernel_current/include/xv_native.h'\"
  1136. else
  1137. echo shar: Extracting \"'src/kernel_current/include/xv_native.h'\" \(3846 characters\)
  1138. sed "s/^X//" >'src/kernel_current/include/xv_native.h' <<'END_OF_FILE'
  1139. X/****************************************************************************************
  1140. X *                                            *
  1141. X * file: xv_native.h                                    *
  1142. X *                                            *
  1143. X * the xlisp include file for integration with VEOS native prims.            *
  1144. X *                                            *
  1145. X * creation: December, 1991                                *
  1146. X *                                            *
  1147. X *                                            *
  1148. X * by Geoffrey P. Coco at the HITLab, Seattle.                          *
  1149. X *                                            *
  1150. X ****************************************************************************************/
  1151. X
  1152. X/****************************************************************************************
  1153. X * Copyright (C) 1992  Geoffrey P. Coco, Human Interface Technology Lab, Seattle    *
  1154. X ****************************************************************************************/
  1155. X
  1156. X
  1157. X#ifdef DEFINE_NATIVE_GLOBS
  1158. X#define NEXTERN
  1159. X#else
  1160. X#define NEXTERN extern
  1161. X#endif
  1162. X
  1163. X/****************************************************************************************/
  1164. X
  1165. X
  1166. X/****************************************************************************************/
  1167. X
  1168. Xtypedef struct {
  1169. X
  1170. X    TPGrouple        pSrcGr;        /* the actual src data */
  1171. X    TPGrouple        pPatGr;        /* how to match */
  1172. X    int            iDestroyFlag;    /* copy, remove, gimme, replace */
  1173. X    int            iFreqFlag;    /* once or all occasions */
  1174. X
  1175. X    LVAL        pXReplaceElt;    /* possible replacement data */
  1176. X    TPTimeStamp        pStampTime;    /* optional time to stamp new data */
  1177. X    TPTimeStamp        pTestTime;    /* optional time to compare with matched data */
  1178. X    LVAL        pXResult;    /* result data to pass back */
  1179. X
  1180. X    } TXMandRRec,
  1181. X      *TPXMandRRec,
  1182. X      **THXMandRRec;
  1183. X
  1184. X
  1185. Xtypedef struct {
  1186. X    boolean    bOrdered;
  1187. X    boolean    bExpContent;
  1188. X    boolean    bExpOrder;
  1189. X    boolean    bMarkedWithin;
  1190. X    boolean    bTouchedWithin;
  1191. X
  1192. X    boolean    bMarkNextElt;
  1193. X    boolean    bTouchNextElt;
  1194. X    boolean    bMustEnd;
  1195. X    boolean    bGetAnother;
  1196. X
  1197. X    } TPatStatRec,
  1198. X      *TPPatStatRec,
  1199. X      **THPatStatRec;
  1200. X
  1201. X/****************************************************************************************/
  1202. X
  1203. X#define NATIVE_BADTYPE        -10
  1204. X#define NATIVE_NOKERNEL        -11
  1205. X#define NATIVE_BADFREQ        -12
  1206. X#define NATIVE_2KERNELS        -13
  1207. X#define NATIVE_BADVTYPE        -14
  1208. X#define NATIVE_THISWHAT        -15
  1209. X#define NATIVE_TOOMANYMARKS    -16
  1210. X#define NATIVE_CANTMIX        -17
  1211. X#define NATIVE_NOREPLACEMARK    -18
  1212. X#define NATIVE_NOFETCHMARK    -19
  1213. X#define NATIVE_NOVOID        -20
  1214. X#define NATIVE_BADPATSYMBOL    -21
  1215. X#define NATIVE_CRAZYWILD    -22
  1216. X#define NATIVE_MATCHFAIL    -23
  1217. X#define NATIVE_NODATA        -24
  1218. X#define NATIVE_EMPTYELT        -25
  1219. X#define NATIVE_STARMORE        -26
  1220. X#define NATIVE_NOTEND        -27
  1221. X#define NATIVE_BADVOID        -28
  1222. X#define NATIVE_NOSTARN        -29
  1223. X#define NATIVE_BADXTYPE        -30
  1224. X#define NATIVE_NOHOST        -31
  1225. X#define NATIVE_NOTOUCH        -32
  1226. X#define NATIVE_MODVOID        -33
  1227. X
  1228. X#define NATIVE_SYMBOL        10
  1229. X#define NATIVE_STALE        -40
  1230. X
  1231. X/****************************************************************************************/
  1232. X
  1233. Xextern LVAL     xsendmsg0();
  1234. Xextern LVAL    s_unbound;
  1235. Xextern LVAL    true;
  1236. Xextern LVAL     xlfatal();
  1237. Xextern LVAL    s_stderr;
  1238. X
  1239. X/****************************************************************************************/
  1240. X
  1241. XNEXTERN LVAL        s_InSpace, k_TestTime, k_Freq;
  1242. XNEXTERN LVAL           *hMsgList;
  1243. XNEXTERN TXMandRRec    native_getPB, native_copyPB, native_putPB;
  1244. X
  1245. X/****************************************************************************************/
  1246. X
  1247. X#define NATIVE_INSPACE hMsgList
  1248. X
  1249. X#define NATIVE_TIME_ARG(pTime, tTest) \
  1250. X{ \
  1251. X    LVAL        pXTime; \
  1252. X    TTimeStamp        tRead; \
  1253. X\
  1254. X    if (xlgetkeyarg(k_TestTime, &pXTime) && !null(pXTime)) { \
  1255. X    XELT2TIME(pXTime, tTest); \
  1256. X    pTime = &tTest; \
  1257. X\
  1258. X    GET_TIME(tRead); \
  1259. X    TIME2XELT(tRead, pXTime); \
  1260. X    } \
  1261. X    else \
  1262. X    pTime = nil; \
  1263. X    }
  1264. X
  1265. X
  1266. X#define NATIVE_FREQ_ARG(iFlag) \
  1267. X{ \
  1268. X    LVAL    pXFreq; \
  1269. X\
  1270. X    if (xlgetkeyarg(k_Freq, &pXFreq) && \
  1271. X    (strcmp((char *)getstring(pXFreq), "all") == 0)) \
  1272. X    iFlag = NANCY_MatchMany; \
  1273. X    else \
  1274. X    iFlag = NANCY_MatchOne; \
  1275. X    }
  1276. X
  1277. X/****************************************************************************************/
  1278. X
  1279. X
  1280. END_OF_FILE
  1281. if test 3846 -ne `wc -c <'src/kernel_current/include/xv_native.h'`; then
  1282.     echo shar: \"'src/kernel_current/include/xv_native.h'\" unpacked with wrong size!
  1283. fi
  1284. # end of 'src/kernel_current/include/xv_native.h'
  1285. fi
  1286. if test -f 'src/xlisp/xcore/c/xldbug.c' -a "${1}" != "-c" ; then 
  1287.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xldbug.c'\"
  1288. else
  1289. echo shar: Extracting \"'src/xlisp/xcore/c/xldbug.c'\" \(6382 characters\)
  1290. sed "s/^X//" >'src/xlisp/xcore/c/xldbug.c' <<'END_OF_FILE'
  1291. X/* -*-C-*-
  1292. X********************************************************************************
  1293. X*
  1294. X* File:         xldebug.c
  1295. X* RCS:          $Header: xldbug.c,v 1.4 90/08/07 16:32:28 mayer Exp $
  1296. X* Description:  xlisp debugging support
  1297. X* Author:       David Michael Betz; Niels Mayer
  1298. X* Created:      
  1299. X* Modified:     Tue Aug  7 16:32:16 1990 (Niels Mayer) mayer@hplnpm
  1300. X* Language:     C
  1301. X* Package:      N/A
  1302. X* Status:       X11r4 contrib tape release
  1303. X*
  1304. X* WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  1305. X* XLISP version 2.1, Copyright (c) 1989, by David Betz.
  1306. X*
  1307. X* Permission to use, copy, modify, distribute, and sell this software and its
  1308. X* documentation for any purpose is hereby granted without fee, provided that
  1309. X* the above copyright notice appear in all copies and that both that
  1310. X* copyright notice and this permission notice appear in supporting
  1311. X* documentation, and that the name of Hewlett-Packard and David Betz not be
  1312. X* used in advertising or publicity pertaining to distribution of the software
  1313. X* without specific, written prior permission.  Hewlett-Packard and David Betz
  1314. X* make no representations about the suitability of this software for any
  1315. X* purpose. It is provided "as is" without express or implied warranty.
  1316. X*
  1317. X* HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  1318. X* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  1319. X* IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  1320. X* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1321. X* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1322. X* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1323. X* PERFORMANCE OF THIS SOFTWARE.
  1324. X*
  1325. X* See ./winterp/COPYRIGHT for information on contacting the authors.
  1326. X* 
  1327. X* Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  1328. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  1329. X*
  1330. X********************************************************************************
  1331. X*/
  1332. Xstatic char rcs_identity[] = "@(#)$Header: xldbug.c,v 1.4 90/08/07 16:32:28 mayer Exp $";
  1333. X
  1334. X#include "xlisp.h"
  1335. X
  1336. X/* external variables */
  1337. Xextern int xldebug;
  1338. Xextern int xlsample;
  1339. Xextern LVAL s_debugio,s_unbound;
  1340. Xextern LVAL s_tracenable,s_tlimit,s_breakenable;
  1341. Xextern LVAL true;
  1342. Xextern char buf[];
  1343. X
  1344. X/* external routines */
  1345. Xextern char *malloc();
  1346. X
  1347. X/* forward declarations */
  1348. XFORWARD LVAL stacktop();
  1349. X
  1350. X/* xlabort - xlisp serious error handler */
  1351. Xxlabort(emsg)
  1352. X  char *emsg;
  1353. X{
  1354. X    xlsignal(emsg,s_unbound);
  1355. X    xlerrprint("error",NULL,emsg,s_unbound);
  1356. X    xlbrklevel();
  1357. X}
  1358. X
  1359. X/* xlbreak - enter a break loop */
  1360. Xxlbreak(emsg,arg)
  1361. X  char *emsg; LVAL arg;
  1362. X{
  1363. X    breakloop("break","return from BREAK",emsg,arg,TRUE);
  1364. X}
  1365. X
  1366. X/* xlfail - xlisp error handler */
  1367. Xxlfail(emsg)
  1368. X  char *emsg;
  1369. X{
  1370. X    xlerror(emsg,s_unbound);
  1371. X}
  1372. X
  1373. X/* xlerror - handle a fatal error */
  1374. X#ifdef BOGUS
  1375. Xstatic xlerror_zero = 0;
  1376. X#endif
  1377. Xxlerror(emsg,arg)
  1378. X  char *emsg; LVAL arg;
  1379. X{
  1380. X#ifdef BOGUS
  1381. Xprintf( "\ncrashing in xlerror, emsg s= '%s'", emsg );
  1382. Xprintf( "\ndummy printf %x, %x", 1 / xlerror_zero, *(int*)xlerror_zero );
  1383. X#endif
  1384. X    if (getvalue(s_breakenable) != NIL) {
  1385. X    breakloop("error",NULL,emsg,arg,FALSE);
  1386. X    } else {
  1387. X    xlsignal(emsg,arg);
  1388. X    xlerrprint("error",NULL,emsg,arg);
  1389. X    xlbrklevel();
  1390. X    }
  1391. X}
  1392. X
  1393. X/* xlcerror - handle a recoverable error */
  1394. Xxlcerror(cmsg,emsg,arg)
  1395. X  char *cmsg,*emsg; LVAL arg;
  1396. X{
  1397. X    if (getvalue(s_breakenable) != NIL)
  1398. X    breakloop("error",cmsg,emsg,arg,TRUE);
  1399. X    else {
  1400. X    xlsignal(emsg,arg);
  1401. X    xlerrprint("error",NULL,emsg,arg);
  1402. X    xlbrklevel();
  1403. X    }
  1404. X}
  1405. X
  1406. X/* xlerrprint - print an error message */
  1407. Xxlerrprint(hdr,cmsg,emsg,arg)
  1408. X  char *hdr,*cmsg,*emsg; LVAL arg;
  1409. X{
  1410. X    /* print the error message */
  1411. X    sprintf(buf,"%s: %s",hdr,emsg);
  1412. X    errputstr(buf);
  1413. X
  1414. X    /* print the argument */
  1415. X    if (arg != s_unbound) {
  1416. X    errputstr(" - ");
  1417. X    errprint(arg);
  1418. X    }
  1419. X
  1420. X    /* no argument, just end the line */
  1421. X    else
  1422. X    errputstr("\n");
  1423. X
  1424. X    /* print the continuation message */
  1425. X    if (cmsg) {
  1426. X    sprintf(buf,"if continued: %s\n",cmsg);
  1427. X    errputstr(buf);
  1428. X    }
  1429. X}
  1430. X
  1431. X#ifdef NEED_TO_REPLACE_BREAKLOOP
  1432. X/* Include hybrid-class functions: *//* JSP */
  1433. X#define MODULE_XLDBUG_C_BREAKLOOP_REPLACEMENT
  1434. X#include "../../xmodules.h"
  1435. X#undef MODULE_XLDBUG_C_BREAKLOOP_REPLACEMENT
  1436. X#else
  1437. X
  1438. X/* breakloop - the debug read-eval-print loop */
  1439. XLOCAL int breakloop(hdr,cmsg,emsg,arg,cflag)
  1440. X  char *hdr,*cmsg,*emsg; LVAL arg; int cflag;
  1441. X{
  1442. X    LVAL expr,val;
  1443. X    CONTEXT cntxt;
  1444. X    int type;
  1445. X
  1446. X    /* print the error message */
  1447. X    xlerrprint(hdr,cmsg,emsg,arg);
  1448. X
  1449. X    /* flush the input buffer */
  1450. X    xlflush();
  1451. X
  1452. X    /* do the back trace */
  1453. X    if (getvalue(s_tracenable)) {
  1454. X    val = getvalue(s_tlimit);
  1455. X    xlbaktrace(fixp(val) ? (int)getfixnum(val) : -1);
  1456. X    }
  1457. X
  1458. X    /* protect some pointers */
  1459. X    xlsave1(expr);
  1460. X
  1461. X    /* increment the debug level */
  1462. X    ++xldebug;
  1463. X
  1464. X    /* debug command processing loop */
  1465. X    xlbegin(&cntxt,CF_BRKLEVEL|CF_CLEANUP|CF_CONTINUE,true);
  1466. X    for (type = 0; type == 0; ) {
  1467. X
  1468. X    /* setup the continue trap */
  1469. X    if (type = xlsetjmp(cntxt.c_jmpbuf))
  1470. X        switch (type) {
  1471. X        case CF_CLEANUP:
  1472. X        continue;
  1473. X        case CF_BRKLEVEL:
  1474. X        type = 0;
  1475. X        break;
  1476. X        case CF_CONTINUE:
  1477. X        if (cflag) {
  1478. X            dbgputstr("[ continue from break loop ]\n");
  1479. X            continue;
  1480. X        }
  1481. X        else xlabort("this error can't be continued");
  1482. X        }
  1483. X
  1484. X    /* print a prompt */
  1485. X    sprintf(buf,"%d> ",xldebug);
  1486. X    dbgputstr(buf);
  1487. X
  1488. X    /* read an expression and check for eof */
  1489. X    if (!xlread(getvalue(s_debugio),&expr,FALSE)) {
  1490. X        type = CF_CLEANUP;
  1491. X        break;
  1492. X    }
  1493. X
  1494. X    /* save the input expression */
  1495. X    xlrdsave(expr);
  1496. X
  1497. X    /* evaluate the expression */
  1498. X    expr = xleval(expr);
  1499. X
  1500. X    /* save the result */
  1501. X    xlevsave(expr);
  1502. X
  1503. X    /* print it */
  1504. X    dbgprint(expr);
  1505. X    }
  1506. X    xlend(&cntxt);
  1507. X
  1508. X    /* decrement the debug level */
  1509. X    --xldebug;
  1510. X
  1511. X    /* restore the stack */
  1512. X    xlpop();
  1513. X
  1514. X    /* check for aborting to the previous level */
  1515. X    if (type == CF_CLEANUP)
  1516. X    xlbrklevel();
  1517. X}
  1518. X
  1519. X#endif
  1520. X
  1521. X/* baktrace - do a back trace */
  1522. Xxlbaktrace(n)
  1523. X  int n;
  1524. X{
  1525. X    LVAL *fp,*p;
  1526. X    int argc;
  1527. X    for (fp = xlfp; (n < 0 || n--) && *fp; fp = fp - (int)getfixnum(*fp)) {
  1528. X    p = fp + 1;
  1529. X    errputstr("Function: ");
  1530. X    errprint(*p++);
  1531. X    if (argc = (int)getfixnum(*p++))
  1532. X        errputstr("Arguments:\n");
  1533. X    while (--argc >= 0) {
  1534. X        errputstr("  ");
  1535. X        errprint(*p++);
  1536. X    }
  1537. X    }
  1538. X}
  1539. X
  1540. X/* xldinit - debug initialization routine */
  1541. Xxldinit()
  1542. X{
  1543. X    xlsample = 0;
  1544. X    xldebug = 0;
  1545. X}
  1546. X
  1547. END_OF_FILE
  1548. if test 6382 -ne `wc -c <'src/xlisp/xcore/c/xldbug.c'`; then
  1549.     echo shar: \"'src/xlisp/xcore/c/xldbug.c'\" unpacked with wrong size!
  1550. fi
  1551. # end of 'src/xlisp/xcore/c/xldbug.c'
  1552. fi
  1553. if test -f 'src/xlisp/xcore/c/xlglob.c' -a "${1}" != "-c" ; then 
  1554.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xlglob.c'\"
  1555. else
  1556. echo shar: Extracting \"'src/xlisp/xcore/c/xlglob.c'\" \(4866 characters\)
  1557. sed "s/^X//" >'src/xlisp/xcore/c/xlglob.c' <<'END_OF_FILE'
  1558. X/* -*-C-*-
  1559. X********************************************************************************
  1560. X*
  1561. X* File:         xlglobals.c
  1562. X* RCS:          $Header: xlglob.c,v 1.4 89/11/25 05:30:06 mayer Exp $
  1563. X* Description:  xlisp global variables
  1564. X* Author:       David Michael Betz
  1565. X* Created:      
  1566. X* Modified:     Sat Nov 25 05:29:22 1989 (Niels Mayer) mayer@hplnpm
  1567. X* Language:     C
  1568. X* Package:      N/A
  1569. X* Status:       X11r4 contrib tape release
  1570. X*
  1571. X* WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  1572. X* XLISP version 2.1, Copyright (c) 1989, by David Betz.
  1573. X*
  1574. X* Permission to use, copy, modify, distribute, and sell this software and its
  1575. X* documentation for any purpose is hereby granted without fee, provided that
  1576. X* the above copyright notice appear in all copies and that both that
  1577. X* copyright notice and this permission notice appear in supporting
  1578. X* documentation, and that the name of Hewlett-Packard and David Betz not be
  1579. X* used in advertising or publicity pertaining to distribution of the software
  1580. X* without specific, written prior permission.  Hewlett-Packard and David Betz
  1581. X* make no representations about the suitability of this software for any
  1582. X* purpose. It is provided "as is" without express or implied warranty.
  1583. X*
  1584. X* HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  1585. X* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  1586. X* IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  1587. X* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1588. X* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1589. X* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1590. X* PERFORMANCE OF THIS SOFTWARE.
  1591. X*
  1592. X* See ./winterp/COPYRIGHT for information on contacting the authors.
  1593. X* 
  1594. X* Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  1595. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  1596. X*
  1597. X********************************************************************************
  1598. X*/
  1599. Xstatic char rcs_identity[] = "@(#)$Header: xlglob.c,v 1.4 89/11/25 05:30:06 mayer Exp $";
  1600. X
  1601. X
  1602. X#include "xlisp.h"
  1603. X
  1604. X/* symbols */
  1605. XLVAL true=NIL,obarray=NIL;
  1606. XLVAL s_unbound=NIL,s_dot=NIL;
  1607. XLVAL s_quote=NIL,s_function=NIL;
  1608. XLVAL s_bquote=NIL,s_comma=NIL,s_comat=NIL;
  1609. XLVAL s_evalhook=NIL,s_applyhook=NIL,s_tracelist;
  1610. XLVAL s_lambda=NIL,s_macro=NIL;
  1611. XLVAL s_send=NIL; /*91Jun15jsp*/
  1612. XLVAL s_stdin=NIL,s_stdout=NIL,s_stderr=NIL,s_debugio=NIL,s_traceout=NIL;
  1613. XLVAL s_rtable=NIL;
  1614. XLVAL s_tracenable=NIL,s_tlimit=NIL,s_breakenable=NIL;
  1615. XLVAL s_setf=NIL,s_car=NIL,s_cdr=NIL,s_nth=NIL,s_aref=NIL,s_get=NIL;
  1616. XLVAL s_svalue=NIL,s_sfunction=NIL,s_splist=NIL;
  1617. XLVAL s_eql=NIL,s_gcflag=NIL,s_gchook=NIL;
  1618. XLVAL s_ifmt=NIL,s_ffmt=NIL;
  1619. XLVAL s_1plus=NIL,s_2plus=NIL,s_3plus=NIL;
  1620. XLVAL s_1star=NIL,s_2star=NIL,s_3star=NIL;
  1621. XLVAL s_minus=NIL,s_printcase=NIL;
  1622. X
  1623. X/* keywords */
  1624. XLVAL k_test=NIL,k_tnot=NIL;
  1625. XLVAL k_wspace=NIL,k_const=NIL,k_nmacro=NIL,k_tmacro=NIL;
  1626. XLVAL k_sescape=NIL,k_mescape=NIL;
  1627. XLVAL k_direction=NIL,k_input=NIL,k_output=NIL;
  1628. XLVAL k_start=NIL,k_end=NIL,k_1start=NIL,k_1end=NIL;
  1629. XLVAL k_2start=NIL,k_2end=NIL,k_count=NIL,k_key=NIL;
  1630. XLVAL k_verbose=NIL,k_print=NIL;
  1631. XLVAL k_upcase=NIL,k_downcase=NIL;
  1632. X
  1633. X/* lambda list keywords */
  1634. XLVAL lk_optional=NIL,lk_rest=NIL,lk_key=NIL,lk_aux=NIL;
  1635. XLVAL lk_allow_other_keys=NIL;
  1636. X
  1637. X/* type names */
  1638. XLVAL a_subr=NIL,a_fsubr=NIL;
  1639. XLVAL a_cons=NIL,a_symbol=NIL,a_fixnum=NIL,a_flonum=NIL;
  1640. XLVAL a_string=NIL,a_object=NIL,a_stream=NIL,a_vector=NIL;
  1641. XLVAL a_closure=NIL,a_char=NIL,a_ustream=NIL;
  1642. X
  1643. X/* evaluation variables */
  1644. XLVAL **xlstack = NULL,**xlstkbase = NULL,**xlstktop = NULL;
  1645. XLVAL xlenv=NIL,xlfenv=NIL,xldenv=NIL;
  1646. X
  1647. X/* argument stack */
  1648. XLVAL *xlargstkbase = NULL;    /* argument stack base */
  1649. XLVAL *xlargstktop = NULL;    /* argument stack top */
  1650. XLVAL *xlfp = NULL;        /* argument frame pointer */
  1651. XLVAL *xlsp = NULL;        /* argument stack pointer */
  1652. XLVAL *xlargv = NULL;        /* current argument vector */
  1653. Xint xlargc = 0;            /* current argument count */
  1654. X
  1655. X/* exception handling variables */
  1656. XCONTEXT *xlcontext = NULL;    /* current exception handler */
  1657. XCONTEXT *xltarget = NULL;    /* target context (for xljump) */
  1658. XLVAL xlvalue=NIL;        /* exception value (for xljump) */
  1659. Xint xlmask=0;            /* exception type (for xljump) */
  1660. X
  1661. X/* debugging variables */
  1662. Xint xldebug = 0;        /* debug level */
  1663. Xint xlsample = 0;        /* control character sample rate */
  1664. Xint xltrcindent = 0;        /* trace indent level */
  1665. X
  1666. X/* gensym variables */
  1667. Xchar gsprefix[STRMAX+1] = { 'G',0 };    /* gensym prefix string */
  1668. Xint gsnumber = 1;        /* gensym number */
  1669. X
  1670. X/* i/o variables */
  1671. Xint xlfsize = 0;        /* flat size of current print call */
  1672. XFILE *tfp = NULL;        /* transcript file pointer */
  1673. X
  1674. X/* general purpose string buffer */
  1675. Xchar buf[STRMAX+1] = { 0 };
  1676. X
  1677. X/* Include hybrid-class functions: *//* JSP */
  1678. X#define MODULE_XLGLOB_C_GLOBALS
  1679. X#include "../../xmodules.h"
  1680. X#undef MODULE_XLGLOB_C_GLOBALS
  1681. X
  1682. END_OF_FILE
  1683. if test 4866 -ne `wc -c <'src/xlisp/xcore/c/xlglob.c'`; then
  1684.     echo shar: \"'src/xlisp/xcore/c/xlglob.c'\" unpacked with wrong size!
  1685. fi
  1686. # end of 'src/xlisp/xcore/c/xlglob.c'
  1687. fi
  1688. if test -f 'src/xlisp/xcore/c/xlio.c' -a "${1}" != "-c" ; then 
  1689.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xlio.c'\"
  1690. else
  1691. echo shar: Extracting \"'src/xlisp/xcore/c/xlio.c'\" \(6016 characters\)
  1692. sed "s/^X//" >'src/xlisp/xcore/c/xlio.c' <<'END_OF_FILE'
  1693. X/* -*-C-*-
  1694. X********************************************************************************
  1695. X*
  1696. X* File:         xlio.c
  1697. X* RCS:          $Header: xlio.c,v 1.2 89/11/25 05:33:04 mayer Exp $
  1698. X* Description:  xlisp i/o routines
  1699. X* Author:       David Michael Betz
  1700. X* Created:      
  1701. X* Modified:     Sat Nov 25 05:32:45 1989 (Niels Mayer) mayer@hplnpm
  1702. X* Language:     C
  1703. X* Package:      N/A
  1704. X* Status:       X11r4 contrib tape release
  1705. X*
  1706. X* WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  1707. X* XLISP version 2.1, Copyright (c) 1989, by David Betz.
  1708. X*
  1709. X* Permission to use, copy, modify, distribute, and sell this software and its
  1710. X* documentation for any purpose is hereby granted without fee, provided that
  1711. X* the above copyright notice appear in all copies and that both that
  1712. X* copyright notice and this permission notice appear in supporting
  1713. X* documentation, and that the name of Hewlett-Packard and David Betz not be
  1714. X* used in advertising or publicity pertaining to distribution of the software
  1715. X* without specific, written prior permission.  Hewlett-Packard and David Betz
  1716. X* make no representations about the suitability of this software for any
  1717. X* purpose. It is provided "as is" without express or implied warranty.
  1718. X*
  1719. X* HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  1720. X* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  1721. X* IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  1722. X* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1723. X* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1724. X* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1725. X* PERFORMANCE OF THIS SOFTWARE.
  1726. X*
  1727. X* See ./winterp/COPYRIGHT for information on contacting the authors.
  1728. X* 
  1729. X* Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  1730. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  1731. X*
  1732. X********************************************************************************
  1733. X*/
  1734. Xstatic char rcs_identity[] = "@(#)$Header: xlio.c,v 1.2 89/11/25 05:33:04 mayer Exp $";
  1735. X
  1736. X#include "xlisp.h"
  1737. X
  1738. X/* external variables */
  1739. Xextern LVAL s_stdin,s_stdout,s_stderr,s_debugio,s_traceout,s_unbound;
  1740. Xextern int xlfsize;
  1741. X
  1742. X/* xlgetc - get a character from a file or stream */
  1743. Xint xlgetc(fptr)
  1744. X  LVAL fptr;
  1745. X{
  1746. X    LVAL lptr,cptr;
  1747. X    FILE *fp;
  1748. X    int ch;
  1749. X
  1750. X    /* check for input from nil */
  1751. X    if (fptr == NIL)
  1752. X    ch = EOF;
  1753. X
  1754. X    /* otherwise, check for input from a stream */
  1755. X    else if (ustreamp(fptr)) {
  1756. X    if ((lptr = gethead(fptr)) == NIL)
  1757. X        ch = EOF;
  1758. X    else {
  1759. X        if (!consp(lptr) || (cptr = car(lptr)) == NIL || !charp(cptr))
  1760. X        xlfail("bad stream");
  1761. X        sethead(fptr,lptr = cdr(lptr));
  1762. X        if (lptr == NIL)
  1763. X        settail(fptr,NIL);
  1764. X        ch = getchcode(cptr);
  1765. X    }
  1766. X    }
  1767. X
  1768. X    /* otherwise, check for a buffered character */
  1769. X    else if (ch = getsavech(fptr))
  1770. X    setsavech(fptr,'\0');
  1771. X
  1772. X    /* otherwise, check for terminal input or file input */
  1773. X    else {
  1774. X    fp = getfile(fptr);
  1775. X    if (fp == stdin || fp == stderr)
  1776. X        ch = ostgetc();
  1777. X    else
  1778. X        ch = osagetc(fp);
  1779. X    }
  1780. X
  1781. X    /* return the character */
  1782. X    return (ch);
  1783. X}
  1784. X
  1785. X/* xlungetc - unget a character */
  1786. Xxlungetc(fptr,ch)
  1787. X  LVAL fptr; int ch;
  1788. X{
  1789. X    LVAL lptr;
  1790. X    
  1791. X    /* check for ungetc from nil */
  1792. X    if (fptr == NIL)
  1793. X    ;
  1794. X    
  1795. X    /* otherwise, check for ungetc to a stream */
  1796. X    if (ustreamp(fptr)) {
  1797. X    if (ch != EOF) {
  1798. X        lptr = cons(cvchar(ch),gethead(fptr));
  1799. X        if (gethead(fptr) == NIL)
  1800. X        settail(fptr,lptr);
  1801. X        sethead(fptr,lptr);
  1802. X    }
  1803. X    }
  1804. X    
  1805. X    /* otherwise, it must be a file */
  1806. X    else
  1807. X    setsavech(fptr,ch);
  1808. X}
  1809. X
  1810. X/* xlpeek - peek at a character from a file or stream */
  1811. Xint xlpeek(fptr)
  1812. X  LVAL fptr;
  1813. X{
  1814. X    LVAL lptr,cptr;
  1815. X    int ch;
  1816. X
  1817. X    /* check for input from nil */
  1818. X    if (fptr == NIL)
  1819. X    ch = EOF;
  1820. X
  1821. X    /* otherwise, check for input from a stream */
  1822. X    else if (ustreamp(fptr)) {
  1823. X    if ((lptr = gethead(fptr)) == NIL)
  1824. X        ch = EOF;
  1825. X    else {
  1826. X        if (!consp(lptr) || (cptr = car(lptr)) == NIL || !charp(cptr))
  1827. X        xlfail("bad stream");
  1828. X        ch = getchcode(cptr);
  1829. X    }
  1830. X    }
  1831. X
  1832. X    /* otherwise, get the next file character and save it */
  1833. X    else {
  1834. X    ch = xlgetc(fptr);
  1835. X    setsavech(fptr,ch);
  1836. X    }
  1837. X
  1838. X    /* return the character */
  1839. X    return (ch);
  1840. X}
  1841. X
  1842. X/* xlputc - put a character to a file or stream */
  1843. Xxlputc(fptr,ch)
  1844. X  LVAL fptr; int ch;
  1845. X{
  1846. X    LVAL lptr;
  1847. X    FILE *fp;
  1848. X
  1849. X    /* count the character */
  1850. X    ++xlfsize;
  1851. X
  1852. X    /* check for output to nil */
  1853. X    if (fptr == NIL)
  1854. X    ;
  1855. X
  1856. X    /* otherwise, check for output to an unnamed stream */
  1857. X    else if (ustreamp(fptr)) {
  1858. X    lptr = consa(cvchar(ch));
  1859. X    if (gettail(fptr))
  1860. X        rplacd(gettail(fptr),lptr);
  1861. X    else
  1862. X        sethead(fptr,lptr);
  1863. X    settail(fptr,lptr);
  1864. X    }
  1865. X
  1866. X    /* otherwise, check for terminal output or file output */
  1867. X    else {
  1868. X    fp = getfile(fptr);
  1869. X    if (fp == stdout || fp == stderr)
  1870. X        ostputc(ch);
  1871. X    else
  1872. X        osaputc(ch,fp);
  1873. X    }
  1874. X}
  1875. X
  1876. X/* xlflush - flush the input buffer */
  1877. Xint xlflush()
  1878. X{
  1879. X    osflush();
  1880. X}
  1881. X
  1882. X/* stdprint - print to *standard-output* */
  1883. Xstdprint(expr)
  1884. X  LVAL expr;
  1885. X{
  1886. X    xlprint(getvalue(s_stdout),expr,TRUE);
  1887. X    xlterpri(getvalue(s_stdout));
  1888. X}
  1889. X
  1890. X/* stdputstr - print a string to *standard-output* */
  1891. Xstdputstr(str)
  1892. X  char *str;
  1893. X{
  1894. X    xlputstr(getvalue(s_stdout),str);
  1895. X}
  1896. X
  1897. X/* errprint - print to *error-output* */
  1898. Xerrprint(expr)
  1899. X  LVAL expr;
  1900. X{
  1901. X    xlprint(getvalue(s_stderr),expr,TRUE);
  1902. X    xlterpri(getvalue(s_stderr));
  1903. X}
  1904. X
  1905. X/* errputstr - print a string to *error-output* */
  1906. Xerrputstr(str)
  1907. X  char *str;
  1908. X{
  1909. X    xlputstr(getvalue(s_stderr),str);
  1910. X}
  1911. X
  1912. X/* dbgprint - print to *debug-io* */
  1913. Xdbgprint(expr)
  1914. X  LVAL expr;
  1915. X{
  1916. X    xlprint(getvalue(s_debugio),expr,TRUE);
  1917. X    xlterpri(getvalue(s_debugio));
  1918. X}
  1919. X
  1920. X/* dbgputstr - print a string to *debug-io* */
  1921. Xdbgputstr(str)
  1922. X  char *str;
  1923. X{
  1924. X    xlputstr(getvalue(s_debugio),str);
  1925. X}
  1926. X
  1927. X/* trcprin1 - print to *trace-output* */
  1928. Xtrcprin1(expr)
  1929. X  LVAL expr;
  1930. X{
  1931. X    xlprint(getvalue(s_traceout),expr,TRUE);
  1932. X}
  1933. X
  1934. X/* trcputstr - print a string to *trace-output* */
  1935. Xtrcputstr(str)
  1936. X  char *str;
  1937. X{
  1938. X    xlputstr(getvalue(s_traceout),str);
  1939. X}
  1940. X
  1941. X
  1942. END_OF_FILE
  1943. if test 6016 -ne `wc -c <'src/xlisp/xcore/c/xlio.c'`; then
  1944.     echo shar: \"'src/xlisp/xcore/c/xlio.c'\" unpacked with wrong size!
  1945. fi
  1946. # end of 'src/xlisp/xcore/c/xlio.c'
  1947. fi
  1948. if test -f 'src/xlisp/xcore/c/xljump.c' -a "${1}" != "-c" ; then 
  1949.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xljump.c'\"
  1950. else
  1951. echo shar: Extracting \"'src/xlisp/xcore/c/xljump.c'\" \(5855 characters\)
  1952. sed "s/^X//" >'src/xlisp/xcore/c/xljump.c' <<'END_OF_FILE'
  1953. X/* -*-C-*-
  1954. X********************************************************************************
  1955. X*
  1956. X* File:         xljump.c
  1957. X* RCS:          $Header: xljump.c,v 1.2 89/11/25 05:38:38 mayer Exp $
  1958. X* Description:  execution context routines
  1959. X* Author:       David Michael Betz
  1960. X* Created:      
  1961. X* Modified:     Sat Nov 25 05:38:31 1989 (Niels Mayer) mayer@hplnpm
  1962. X* Language:     C
  1963. X* Package:      N/A
  1964. X* Status:       X11r4 contrib tape release
  1965. X*
  1966. X* WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  1967. X* XLISP version 2.1, Copyright (c) 1989, by David Betz.
  1968. X*
  1969. X* Permission to use, copy, modify, distribute, and sell this software and its
  1970. X* documentation for any purpose is hereby granted without fee, provided that
  1971. X* the above copyright notice appear in all copies and that both that
  1972. X* copyright notice and this permission notice appear in supporting
  1973. X* documentation, and that the name of Hewlett-Packard and David Betz not be
  1974. X* used in advertising or publicity pertaining to distribution of the software
  1975. X* without specific, written prior permission.  Hewlett-Packard and David Betz
  1976. X* make no representations about the suitability of this software for any
  1977. X* purpose. It is provided "as is" without express or implied warranty.
  1978. X*
  1979. X* HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  1980. X* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  1981. X* IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  1982. X* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1983. X* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1984. X* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1985. X* PERFORMANCE OF THIS SOFTWARE.
  1986. X*
  1987. X* See ./winterp/COPYRIGHT for information on contacting the authors.
  1988. X* 
  1989. X* Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  1990. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  1991. X*
  1992. X********************************************************************************
  1993. X*/
  1994. Xstatic char rcs_identity[] = "@(#)$Header: xljump.c,v 1.2 89/11/25 05:38:38 mayer Exp $";
  1995. X
  1996. X
  1997. X#include "xlisp.h"
  1998. X
  1999. X/* external variables */
  2000. Xextern CONTEXT *xlcontext,*xltarget;
  2001. Xextern LVAL xlvalue,xlenv,xlfenv,xldenv;
  2002. Xextern int xlmask;
  2003. X
  2004. X/* xlbegin - beginning of an execution context */
  2005. Xxlbegin(cptr,flags,expr)
  2006. X  CONTEXT *cptr; int flags; LVAL expr;
  2007. X{
  2008. X    cptr->c_flags = flags;
  2009. X    cptr->c_expr = expr;
  2010. X    cptr->c_xlstack = xlstack;
  2011. X    cptr->c_xlenv = xlenv;
  2012. X    cptr->c_xlfenv = xlfenv;
  2013. X    cptr->c_xldenv = xldenv;
  2014. X    cptr->c_xlcontext = xlcontext;
  2015. X    cptr->c_xlargv = xlargv;
  2016. X    cptr->c_xlargc = xlargc;
  2017. X    cptr->c_xlfp = xlfp;
  2018. X    cptr->c_xlsp = xlsp;
  2019. X    xlcontext = cptr;
  2020. X}
  2021. X
  2022. X/* xlend - end of an execution context */
  2023. Xxlend(cptr)
  2024. X  CONTEXT *cptr;
  2025. X{
  2026. X    xlcontext = cptr->c_xlcontext;
  2027. X}
  2028. X
  2029. X/* xlgo - go to a label */
  2030. Xxlgo(label)
  2031. X  LVAL label;
  2032. X{
  2033. X    CONTEXT *cptr;
  2034. X    LVAL *argv;
  2035. X    int argc;
  2036. X
  2037. X    /* find a tagbody context */
  2038. X    for (cptr = xlcontext; cptr; cptr = cptr->c_xlcontext)
  2039. X    if (cptr->c_flags & CF_GO) {
  2040. X        argc = cptr->c_xlargc;
  2041. X        argv = cptr->c_xlargv;
  2042. X        while (--argc >= 0)
  2043. X        if (*argv++ == label) {
  2044. X            cptr->c_xlargc = argc;
  2045. X            cptr->c_xlargv = argv;
  2046. X            xljump(cptr,CF_GO,NIL);
  2047. X        }
  2048. X    }
  2049. X    xlfail("no target for GO");
  2050. X}
  2051. X
  2052. X/* xlreturn - return from a block */
  2053. Xxlreturn(name,val)
  2054. X  LVAL name,val;
  2055. X{
  2056. X    CONTEXT *cptr;
  2057. X
  2058. X    /* find a block context */
  2059. X    for (cptr = xlcontext; cptr; cptr = cptr->c_xlcontext)
  2060. X    if (cptr->c_flags & CF_RETURN && cptr->c_expr == name)
  2061. X        xljump(cptr,CF_RETURN,val);
  2062. X    xlfail("no target for RETURN");
  2063. X}
  2064. X
  2065. X/* xlthrow - throw to a catch */
  2066. Xxlthrow(tag,val)
  2067. X  LVAL tag,val;
  2068. X{
  2069. X    CONTEXT *cptr;
  2070. X
  2071. X    /* find a catch context */
  2072. X    for (cptr = xlcontext; cptr; cptr = cptr->c_xlcontext)
  2073. X    if ((cptr->c_flags & CF_THROW) && cptr->c_expr == tag)
  2074. X        xljump(cptr,CF_THROW,val);
  2075. X    xlfail("no target for THROW");
  2076. X}
  2077. X
  2078. X/* xlsignal - signal an error */
  2079. Xxlsignal(emsg,arg)
  2080. X  char *emsg; LVAL arg;
  2081. X{
  2082. X    CONTEXT *cptr;
  2083. X
  2084. X    /* find an error catcher */
  2085. X    for (cptr = xlcontext; cptr; cptr = cptr->c_xlcontext)
  2086. X    if (cptr->c_flags & CF_ERROR) {
  2087. X        if (cptr->c_expr && emsg)
  2088. X        xlerrprint("error",NULL,emsg,arg);
  2089. X        xljump(cptr,CF_ERROR,NIL);
  2090. X    }
  2091. X}
  2092. X
  2093. X/* xltoplevel - go back to the top level */
  2094. Xxltoplevel()
  2095. X{
  2096. X    stdputstr("[ back to top level ]\n");
  2097. X    findandjump(CF_TOPLEVEL,"no top level");
  2098. X}
  2099. X
  2100. X/* xlbrklevel - go back to the previous break level */
  2101. Xxlbrklevel()
  2102. X{
  2103. X    findandjump(CF_BRKLEVEL,"no previous break level");
  2104. X}
  2105. X
  2106. X/* xlcleanup - clean-up after an error */
  2107. Xxlcleanup()
  2108. X{
  2109. X    stdputstr("[ back to previous break level ]\n");
  2110. X    findandjump(CF_CLEANUP,"not in a break loop");
  2111. X}
  2112. X
  2113. X/* xlcontinue - continue from an error */
  2114. Xxlcontinue()
  2115. X{
  2116. X    findandjump(CF_CONTINUE,"not in a break loop");
  2117. X}
  2118. X
  2119. X/* xljump - jump to a saved execution context */
  2120. Xxljump(target,mask,val)
  2121. X  CONTEXT *target; int mask; LVAL val;
  2122. X{
  2123. X    /* unwind the execution stack */
  2124. X    for (; xlcontext != target; xlcontext = xlcontext->c_xlcontext)
  2125. X
  2126. X    /* check for an UNWIND-PROTECT */
  2127. X    if ((xlcontext->c_flags & CF_UNWIND)) {
  2128. X        xltarget = target;
  2129. X        xlmask = mask;
  2130. X        break;
  2131. X    }
  2132. X       
  2133. X    /* restore the state */
  2134. X    xlstack = xlcontext->c_xlstack;
  2135. X    xlenv = xlcontext->c_xlenv;
  2136. X    xlfenv = xlcontext->c_xlfenv;
  2137. X    xlunbind(xlcontext->c_xldenv);
  2138. X    xlargv = xlcontext->c_xlargv;
  2139. X    xlargc = xlcontext->c_xlargc;
  2140. X    xlfp = xlcontext->c_xlfp;
  2141. X    xlsp = xlcontext->c_xlsp;
  2142. X    xlvalue = val;
  2143. X
  2144. X    /* call the handler */
  2145. X    xllongjmp(xlcontext->c_jmpbuf,mask);
  2146. X}
  2147. X
  2148. X/* findandjump - find a target context frame and jump to it */
  2149. XLOCAL findandjump(mask,error)
  2150. X  int mask; char *error;
  2151. X{
  2152. X    CONTEXT *cptr;
  2153. X
  2154. X    /* find a block context */
  2155. X    for (cptr = xlcontext; cptr; cptr = cptr->c_xlcontext)
  2156. X    if (cptr->c_flags & mask)
  2157. X        xljump(cptr,mask,NIL);
  2158. X    xlabort(error);
  2159. X}
  2160. X
  2161. END_OF_FILE
  2162. if test 5855 -ne `wc -c <'src/xlisp/xcore/c/xljump.c'`; then
  2163.     echo shar: \"'src/xlisp/xcore/c/xljump.c'\" unpacked with wrong size!
  2164. fi
  2165. # end of 'src/xlisp/xcore/c/xljump.c'
  2166. fi
  2167. if test -f 'src/xlisp/xcore/c/xlpp.c' -a "${1}" != "-c" ; then 
  2168.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xlpp.c'\"
  2169. else
  2170. echo shar: Extracting \"'src/xlisp/xcore/c/xlpp.c'\" \(4222 characters\)
  2171. sed "s/^X//" >'src/xlisp/xcore/c/xlpp.c' <<'END_OF_FILE'
  2172. X/* -*-C-*-
  2173. X********************************************************************************
  2174. X*
  2175. X* File:         xlpp.c
  2176. X* RCS:          $Header: xlpp.c,v 1.2 89/11/25 05:42:08 mayer Exp $
  2177. X* Description:  xlisp pretty printer
  2178. X* Author:       David Michael Betz
  2179. X* Created:      
  2180. X* Modified:     Sat Nov 25 05:42:00 1989 (Niels Mayer) mayer@hplnpm
  2181. X* Language:     C
  2182. X* Package:      N/A
  2183. X* Status:       X11r4 contrib tape release
  2184. X*
  2185. X* WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  2186. X* XLISP version 2.1, Copyright (c) 1989, by David Betz.
  2187. X*
  2188. X* Permission to use, copy, modify, distribute, and sell this software and its
  2189. X* documentation for any purpose is hereby granted without fee, provided that
  2190. X* the above copyright notice appear in all copies and that both that
  2191. X* copyright notice and this permission notice appear in supporting
  2192. X* documentation, and that the name of Hewlett-Packard and David Betz not be
  2193. X* used in advertising or publicity pertaining to distribution of the software
  2194. X* without specific, written prior permission.  Hewlett-Packard and David Betz
  2195. X* make no representations about the suitability of this software for any
  2196. X* purpose. It is provided "as is" without express or implied warranty.
  2197. X*
  2198. X* HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  2199. X* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  2200. X* IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  2201. X* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  2202. X* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  2203. X* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  2204. X* PERFORMANCE OF THIS SOFTWARE.
  2205. X*
  2206. X* See ./winterp/COPYRIGHT for information on contacting the authors.
  2207. X* 
  2208. X* Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  2209. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  2210. X*
  2211. X********************************************************************************
  2212. X*/
  2213. Xstatic char rcs_identity[] = "@(#)$Header: xlpp.c,v 1.2 89/11/25 05:42:08 mayer Exp $";
  2214. X
  2215. X
  2216. X#include "xlisp.h"
  2217. X
  2218. X/* external variables */
  2219. Xextern LVAL s_stdout, s_stderr;
  2220. Xextern int xlfsize;
  2221. X
  2222. X/* local variables */
  2223. Xstatic int pplevel,ppmargin,ppmaxlen;
  2224. Xstatic LVAL ppfile;
  2225. X
  2226. X/* xpp - pretty-print an expression */
  2227. XLVAL xpp()
  2228. X{
  2229. X    LVAL expr;
  2230. X
  2231. X    /* get expression to print and file pointer */
  2232. X    expr = xlgetarg();
  2233. X    ppfile = (moreargs() ? xlgetfile() : getvalue(s_stdout));
  2234. X    xllastarg();
  2235. X
  2236. X    /* pretty print the expression */
  2237. X    pplevel = ppmargin = 0; ppmaxlen = 40;
  2238. X    pp(expr); ppterpri(ppfile);
  2239. X
  2240. X    /* return nil */
  2241. X    return (NIL);
  2242. X}
  2243. X
  2244. X/* pp - pretty print an expression */
  2245. XLOCAL pp(expr)
  2246. X  LVAL expr;
  2247. X{
  2248. X    if (consp(expr))
  2249. X    pplist(expr);
  2250. X    else
  2251. X    ppexpr(expr);
  2252. X}
  2253. X
  2254. X/* pplist - pretty print a list */
  2255. XLOCAL pplist(expr)
  2256. X  LVAL expr;
  2257. X{
  2258. X    int n;
  2259. X
  2260. X    /* if the expression will fit on one line, print it on one */
  2261. X    if ((n = sexpflatsize(expr)) < ppmaxlen) {
  2262. X    xlprint(ppfile,expr,TRUE);
  2263. X    pplevel += n;
  2264. X    }
  2265. X
  2266. X    /* otherwise print it on several lines */
  2267. X    else {
  2268. X    n = ppmargin;
  2269. X    ppputc('(');
  2270. X    if (atom(car(expr))) {
  2271. X        ppexpr(car(expr));
  2272. X        ppputc(' ');
  2273. X        ppmargin = pplevel;
  2274. X        expr = cdr(expr);
  2275. X    }
  2276. X    else
  2277. X        ppmargin = pplevel;
  2278. X    for (; consp(expr); expr = cdr(expr)) {
  2279. X        pp(car(expr));
  2280. X        if (consp(cdr(expr)))
  2281. X        ppterpri();
  2282. X    }
  2283. X    if (expr != NIL) {
  2284. X        ppputc(' '); ppputc('.'); ppputc(' ');
  2285. X        ppexpr(expr);
  2286. X    }
  2287. X    ppputc(')');
  2288. X    ppmargin = n;
  2289. X    }
  2290. X}
  2291. X
  2292. X/* ppexpr - print an expression and update the indent level */
  2293. XLOCAL ppexpr(expr)
  2294. X  LVAL expr;
  2295. X{
  2296. X    xlprint(ppfile,expr,TRUE);
  2297. X    pplevel += sexpflatsize(expr);
  2298. X}
  2299. X
  2300. X/* ppputc - output a character and update the indent level */
  2301. XLOCAL ppputc(ch)
  2302. X  int ch;
  2303. X{
  2304. X    xlputc(ppfile,ch);
  2305. X    pplevel++;
  2306. X}
  2307. X
  2308. X/* ppterpri - terminate the print line and indent */
  2309. XLOCAL ppterpri()
  2310. X{
  2311. X    xlterpri(ppfile);
  2312. X    for (pplevel = 0; pplevel < ppmargin; pplevel++)
  2313. X    xlputc(ppfile,' ');
  2314. X}
  2315. X
  2316. X/* sexpflatsize - compute the flat size of an expression */
  2317. X/* name change from flatsize to sexpflatsize */ /* Voodoo */
  2318. XLOCAL int sexpflatsize(expr)    
  2319. X  LVAL expr;
  2320. X{
  2321. X    xlfsize = 0;
  2322. X    xlprint(NIL,expr,TRUE);
  2323. X    return (xlfsize);
  2324. X}
  2325. END_OF_FILE
  2326. if test 4222 -ne `wc -c <'src/xlisp/xcore/c/xlpp.c'`; then
  2327.     echo shar: \"'src/xlisp/xcore/c/xlpp.c'\" unpacked with wrong size!
  2328. fi
  2329. # end of 'src/xlisp/xcore/c/xlpp.c'
  2330. fi
  2331. if test -f 'src/xlisp/xcore/c/xlsubr.c' -a "${1}" != "-c" ; then 
  2332.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xlsubr.c'\"
  2333. else
  2334. echo shar: Extracting \"'src/xlisp/xcore/c/xlsubr.c'\" \(6250 characters\)
  2335. sed "s/^X//" >'src/xlisp/xcore/c/xlsubr.c' <<'END_OF_FILE'
  2336. X/* -*-C-*-
  2337. X********************************************************************************
  2338. X*
  2339. X* File:         xlsubr.c
  2340. X* RCS:          $Header: xlsubr.c,v 1.2 89/11/25 05:48:29 mayer Exp $
  2341. X* Description:  xlisp builtin function support routines
  2342. X* Author:       David Michael Betz
  2343. X* Created:      
  2344. X* Modified:     Sat Nov 25 05:48:21 1989 (Niels Mayer) mayer@hplnpm
  2345. X* Language:     C
  2346. X* Package:      N/A
  2347. X* Status:       X11r4 contrib tape release
  2348. X*
  2349. X* WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  2350. X* XLISP version 2.1, Copyright (c) 1989, by David Betz.
  2351. X*
  2352. X* Permission to use, copy, modify, distribute, and sell this software and its
  2353. X* documentation for any purpose is hereby granted without fee, provided that
  2354. X* the above copyright notice appear in all copies and that both that
  2355. X* copyright notice and this permission notice appear in supporting
  2356. X* documentation, and that the name of Hewlett-Packard and David Betz not be
  2357. X* used in advertising or publicity pertaining to distribution of the software
  2358. X* without specific, written prior permission.  Hewlett-Packard and David Betz
  2359. X* make no representations about the suitability of this software for any
  2360. X* purpose. It is provided "as is" without express or implied warranty.
  2361. X*
  2362. X* HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  2363. X* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  2364. X* IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  2365. X* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  2366. X* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  2367. X* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  2368. X* PERFORMANCE OF THIS SOFTWARE.
  2369. X*
  2370. X* See ./winterp/COPYRIGHT for information on contacting the authors.
  2371. X* 
  2372. X* Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  2373. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  2374. X*
  2375. X********************************************************************************
  2376. X*/
  2377. Xstatic char rcs_identity[] = "@(#)$Header: xlsubr.c,v 1.2 89/11/25 05:48:29 mayer Exp $";
  2378. X
  2379. X
  2380. X#include "xlisp.h"
  2381. X
  2382. X/* external variables */
  2383. Xextern LVAL k_test,k_tnot,s_eql;
  2384. X
  2385. X/* xlsubr - define a builtin function */
  2386. XLVAL xlsubr(sname,type,fcn,offset)
  2387. X  char *sname; int type; LVAL (*fcn)(); int offset;
  2388. X{
  2389. X    LVAL sym;
  2390. X    sym = xlenter(sname);
  2391. X    setfunction(sym,cvsubr(fcn,type,offset));
  2392. X    return (sym);
  2393. X}
  2394. X
  2395. X/* xlgetkeyarg - get a keyword argument */
  2396. Xint xlgetkeyarg(key,pval)
  2397. X  LVAL key,*pval;
  2398. X{
  2399. X    LVAL *argv;
  2400. X    int argc;
  2401. X
  2402. X    for (argv = xlargv, argc = xlargc; (argc -= 2) >= 0; argv += 2) {
  2403. X    if (*argv == key) {
  2404. X        *pval = *++argv;
  2405. X        return (TRUE);
  2406. X    }
  2407. X    }
  2408. X    return (FALSE);
  2409. X}
  2410. X
  2411. X/* xlgkfixnum - get a fixnum keyword argument */
  2412. Xint xlgkfixnum(key,pval)
  2413. X  LVAL key,*pval;
  2414. X{
  2415. X    if (xlgetkeyarg(key,pval)) {
  2416. X    if (!fixp(*pval))
  2417. X        xlbadtype(*pval);
  2418. X    return (TRUE);
  2419. X    }
  2420. X    return (FALSE);
  2421. X}
  2422. X
  2423. X/* xltest - get the :test or :test-not keyword argument */
  2424. Xxltest(pfcn,ptresult)
  2425. X  LVAL *pfcn; int *ptresult;
  2426. X{
  2427. X    if (xlgetkeyarg(k_test,pfcn))    /* :test */
  2428. X    *ptresult = TRUE;
  2429. X    else if (xlgetkeyarg(k_tnot,pfcn))    /* :test-not */
  2430. X    *ptresult = FALSE;
  2431. X    else {
  2432. X    *pfcn = getfunction(s_eql);
  2433. X    *ptresult = TRUE;
  2434. X    }
  2435. X}
  2436. X
  2437. X/* xlgetfile - get a file or stream */
  2438. XLVAL xlgetfile()
  2439. X{
  2440. X    LVAL arg;
  2441. X
  2442. X    /* get a file or stream (cons) or nil */
  2443. X    if (arg = xlgetarg()) {
  2444. X    if (streamp(arg)) {
  2445. X        if (getfile(arg) == NULL)
  2446. X        xlfail("file not open");
  2447. X    }
  2448. X    else if (!ustreamp(arg))
  2449. X        xlerror("bad argument type",arg);
  2450. X    }
  2451. X    return (arg);
  2452. X}
  2453. X
  2454. X/* xlgetfname - get a filename */
  2455. XLVAL xlgetfname()
  2456. X{
  2457. X    LVAL name;
  2458. X
  2459. X    /* get the next argument */
  2460. X    name = xlgetarg();
  2461. X
  2462. X    /* get the filename string */
  2463. X    if (symbolp(name))
  2464. X    name = getpname(name);
  2465. X    else if (!stringp(name))
  2466. X    xlerror("bad argument type",name);
  2467. X
  2468. X    /* return the name */
  2469. X    return (name);
  2470. X}
  2471. X
  2472. X/* needsextension - check if a filename needs an extension */
  2473. Xint needsextension(name)
  2474. X  char *name;
  2475. X{
  2476. X    char *p;
  2477. X
  2478. X    /* check for an extension */
  2479. X    for (p = &name[strlen(name)]; --p >= &name[0]; )
  2480. X    if (*p == '.')
  2481. X        return (FALSE);
  2482. X    else if (!islower(*p) && !isupper(*p) && !isdigit(*p))
  2483. X        return (TRUE);
  2484. X
  2485. X    /* no extension found */
  2486. X    return (TRUE);
  2487. X}
  2488. X
  2489. X/* xlbadtype - report a "bad argument type" error */
  2490. XLVAL xlbadtype(arg)
  2491. X  LVAL arg;
  2492. X{
  2493. X    xlerror("bad argument type",arg);
  2494. X}
  2495. X
  2496. X/* xlbadinit - report a "bad initializer list" error */
  2497. XLVAL xlbadinit(arg)
  2498. X  LVAL arg;
  2499. X{
  2500. X    xlerror("bad initializer list",arg);
  2501. X}
  2502. X
  2503. X/* xltoofew - report a "too few arguments" error */
  2504. XLVAL xltoofew()
  2505. X{
  2506. X    xlfail("too few arguments");
  2507. X}
  2508. X
  2509. X/* xltoomany - report a "too many arguments" error */
  2510. Xxltoomany()
  2511. X{
  2512. X
  2513. X    xlfail("too many arguments");
  2514. X}
  2515. X
  2516. X/* eq - internal eq function */
  2517. Xint eq(arg1,arg2)
  2518. X  LVAL arg1,arg2;
  2519. X{
  2520. X    return (arg1 == arg2);
  2521. X}
  2522. X
  2523. X/* eql - internal eql function */
  2524. Xint eql(arg1,arg2)
  2525. X  LVAL arg1,arg2;
  2526. X{
  2527. X    /* compare the arguments */
  2528. X    if (arg1 == arg2)
  2529. X    return (TRUE);
  2530. X    else if (arg1) {
  2531. X    switch (ntype(arg1)) {
  2532. X    case FIXNUM:
  2533. X        return (fixp(arg2) ? getfixnum(arg1)==getfixnum(arg2) : FALSE);
  2534. X    case FLONUM:
  2535. X        return (floatp(arg2) ? getflonum(arg1)==getflonum(arg2) : FALSE);
  2536. X    default:
  2537. X        return (FALSE);
  2538. X    }
  2539. X    }
  2540. X    else
  2541. X    return (FALSE);
  2542. X}
  2543. X
  2544. X/* equal - internal equal function */
  2545. Xint equal(arg1,arg2)
  2546. X  LVAL arg1,arg2;
  2547. X{
  2548. X    /* compare the arguments */
  2549. X    if (arg1 == arg2)
  2550. X    return (TRUE);
  2551. X    else if (arg1) {
  2552. X    switch (ntype(arg1)) {
  2553. X    case FIXNUM:
  2554. X        return (fixp(arg2) ? getfixnum(arg1)==getfixnum(arg2) : FALSE);
  2555. X    case FLONUM:
  2556. X        return (floatp(arg2) ? getflonum(arg1)==getflonum(arg2) : FALSE);
  2557. X    case STRING:
  2558. X        return (stringp(arg2) ? strcmp(getstring(arg1),
  2559. X                       getstring(arg2)) == 0 : FALSE);
  2560. X    case CONS:
  2561. X        return (consp(arg2) ? equal(car(arg1),car(arg2))
  2562. X                   && equal(cdr(arg1),cdr(arg2)) : FALSE);
  2563. X/* awm */
  2564. X    case VECTOR:
  2565. X        if( vectorp( arg2) && (getsz( arg1) == getsz( arg2))) {
  2566. X          int i;
  2567. X          for( i = 0; i < getsz( arg1); i++) {
  2568. X        if( !equal( getelement( arg1, i), getelement( arg2, i)))
  2569. X          return FALSE;
  2570. X          }
  2571. X          return TRUE;
  2572. X        }
  2573. X        else {
  2574. X          return FALSE;
  2575. X        }
  2576. X/* awm */
  2577. X    default:
  2578. X        return (FALSE);
  2579. X    }
  2580. X    }
  2581. X    else
  2582. X    return (FALSE);
  2583. X}
  2584. END_OF_FILE
  2585. if test 6250 -ne `wc -c <'src/xlisp/xcore/c/xlsubr.c'`; then
  2586.     echo shar: \"'src/xlisp/xcore/c/xlsubr.c'\" unpacked with wrong size!
  2587. fi
  2588. # end of 'src/xlisp/xcore/c/xlsubr.c'
  2589. fi
  2590. if test -f 'src/xlisp/xcore/c/xlsym.c' -a "${1}" != "-c" ; then 
  2591.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xlsym.c'\"
  2592. else
  2593. echo shar: Extracting \"'src/xlisp/xcore/c/xlsym.c'\" \(7019 characters\)
  2594. sed "s/^X//" >'src/xlisp/xcore/c/xlsym.c' <<'END_OF_FILE'
  2595. X/* -*-C-*-
  2596. X********************************************************************************
  2597. X*
  2598. X* File:         xlsym.c
  2599. X* RCS:          $Header: xlsym.c,v 1.2 89/11/25 05:49:24 mayer Exp $
  2600. X* Description:  symbol handling routines
  2601. X* Author:       David Michael Betz
  2602. X* Created:      
  2603. X* Modified:     Sat Nov 25 05:49:18 1989 (Niels Mayer) mayer@hplnpm
  2604. X* Language:     C
  2605. X* Package:      N/A
  2606. X* Status:       X11r4 contrib tape release
  2607. X*
  2608. X* WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  2609. X* XLISP version 2.1, Copyright (c) 1989, by David Betz.
  2610. X*
  2611. X* Permission to use, copy, modify, distribute, and sell this software and its
  2612. X* documentation for any purpose is hereby granted without fee, provided that
  2613. X* the above copyright notice appear in all copies and that both that
  2614. X* copyright notice and this permission notice appear in supporting
  2615. X* documentation, and that the name of Hewlett-Packard and David Betz not be
  2616. X* used in advertising or publicity pertaining to distribution of the software
  2617. X* without specific, written prior permission.  Hewlett-Packard and David Betz
  2618. X* make no representations about the suitability of this software for any
  2619. X* purpose. It is provided "as is" without express or implied warranty.
  2620. X*
  2621. X* HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  2622. X* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  2623. X* IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  2624. X* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  2625. X* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  2626. X* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  2627. X* PERFORMANCE OF THIS SOFTWARE.
  2628. X*
  2629. X* See ./winterp/COPYRIGHT for information on contacting the authors.
  2630. X* 
  2631. X* Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  2632. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  2633. X*
  2634. X********************************************************************************
  2635. X*/
  2636. Xstatic char rcs_identity[] = "@(#)$Header: xlsym.c,v 1.2 89/11/25 05:49:24 mayer Exp $";
  2637. X
  2638. X
  2639. X#include "xlisp.h"
  2640. X
  2641. X/* external variables */
  2642. Xextern LVAL obarray,s_unbound;
  2643. Xextern LVAL xlenv,xlfenv,xldenv;
  2644. X
  2645. X/* forward declarations */
  2646. XFORWARD LVAL findprop();
  2647. X
  2648. X/* xlenter - enter a symbol into the obarray */
  2649. XLVAL xlenter(name)
  2650. X  char *name;
  2651. X{
  2652. X    LVAL sym,array;
  2653. X    int i;
  2654. X
  2655. X    /* check for nil */
  2656. X    if (strcmp(name,"NIL") == 0)
  2657. X    return (NIL);
  2658. X
  2659. X    /* check for symbol already in table */
  2660. X    array = getvalue(obarray);
  2661. X    i = hash(name,HSIZE);
  2662. X    for (sym = getelement(array,i); sym; sym = cdr(sym))
  2663. X    if (strcmp(name,getstring(getpname(car(sym)))) == 0)
  2664. X        return (car(sym));
  2665. X
  2666. X    /* make a new symbol node and link it into the list */
  2667. X    xlsave1(sym);
  2668. X    sym = consd(getelement(array,i));
  2669. X    rplaca(sym,xlmakesym(name));
  2670. X    setelement(array,i,sym);
  2671. X    xlpop();
  2672. X
  2673. X    /* return the new symbol */
  2674. X    return (car(sym));
  2675. X}
  2676. X
  2677. X/* xlmakesym - make a new symbol node */
  2678. XLVAL xlmakesym(name)
  2679. X  char *name;
  2680. X{
  2681. X    LVAL sym;
  2682. X    sym = cvsymbol(name);
  2683. X    if (*name == ':')
  2684. X    setvalue(sym,sym);
  2685. X    return (sym);
  2686. X}
  2687. X
  2688. X/* xlgetvalue - get the value of a symbol (with check) */
  2689. XLVAL xlgetvalue(sym)
  2690. X  LVAL sym;
  2691. X{
  2692. X    LVAL val;
  2693. X
  2694. X    /* look for the value of the symbol */
  2695. X    while ((val = xlxgetvalue(sym)) == s_unbound)
  2696. X    xlunbound(sym);
  2697. X
  2698. X    /* return the value */
  2699. X    return (val);
  2700. X}
  2701. X
  2702. X/* xlxgetvalue - get the value of a symbol */
  2703. XLVAL xlxgetvalue(sym)
  2704. X  LVAL sym;
  2705. X{
  2706. X    register LVAL fp,ep;
  2707. X    LVAL val;
  2708. X
  2709. X    /* check the environment list */
  2710. X    for (fp = xlenv; fp; fp = cdr(fp))
  2711. X
  2712. X    /* check for an instance variable */
  2713. X    if ((ep = car(fp)) && objectp(car(ep))) {
  2714. X        if (xlobgetvalue(ep,sym,&val))
  2715. X        return (val);
  2716. X    }
  2717. X
  2718. X    /* check an environment stack frame */
  2719. X    else {
  2720. X        for (; ep; ep = cdr(ep))
  2721. X        if (sym == car(car(ep)))
  2722. X            return (cdr(car(ep)));
  2723. X    }
  2724. X
  2725. X    /* return the global value */
  2726. X    return (getvalue(sym));
  2727. X}
  2728. X
  2729. X/* xlsetvalue - set the value of a symbol */
  2730. Xxlsetvalue(sym,val)
  2731. X  LVAL sym,val;
  2732. X{
  2733. X    register LVAL fp,ep;
  2734. X
  2735. X    /* look for the symbol in the environment list */
  2736. X    for (fp = xlenv; fp; fp = cdr(fp))
  2737. X
  2738. X    /* check for an instance variable */
  2739. X    if ((ep = car(fp)) && objectp(car(ep))) {
  2740. X        if (xlobsetvalue(ep,sym,val))
  2741. X        return;
  2742. X    }
  2743. X
  2744. X    /* check an environment stack frame */
  2745. X    else {
  2746. X        for (; ep; ep = cdr(ep))
  2747. X        if (sym == car(car(ep))) {
  2748. X            rplacd(car(ep),val);
  2749. X            return;
  2750. X        }
  2751. X    }
  2752. X
  2753. X    /* store the global value */
  2754. X    setvalue(sym,val);
  2755. X}
  2756. X
  2757. X/* xlgetfunction - get the functional value of a symbol (with check) */
  2758. XLVAL xlgetfunction(sym)
  2759. X  LVAL sym;
  2760. X{
  2761. X    LVAL val;
  2762. X
  2763. X    /* look for the functional value of the symbol */
  2764. X    while ((val = xlxgetfunction(sym)) == s_unbound)
  2765. X    xlfunbound(sym);
  2766. X
  2767. X    /* return the value */
  2768. X    return (val);
  2769. X}
  2770. X
  2771. X/* xlxgetfunction - get the functional value of a symbol */
  2772. XLVAL xlxgetfunction(sym)
  2773. X  LVAL sym;
  2774. X{
  2775. X    register LVAL fp,ep;
  2776. X
  2777. X    /* check the environment list */
  2778. X    for (fp = xlfenv; fp; fp = cdr(fp))
  2779. X    for (ep = car(fp); ep; ep = cdr(ep))
  2780. X        if (sym == car(car(ep)))
  2781. X        return (cdr(car(ep)));
  2782. X
  2783. X    /* return the global value */
  2784. X    return (getfunction(sym));
  2785. X}
  2786. X
  2787. X/* xlsetfunction - set the functional value of a symbol */
  2788. Xxlsetfunction(sym,val)
  2789. X  LVAL sym,val;
  2790. X{
  2791. X    register LVAL fp,ep;
  2792. X
  2793. X    /* look for the symbol in the environment list */
  2794. X    for (fp = xlfenv; fp; fp = cdr(fp))
  2795. X    for (ep = car(fp); ep; ep = cdr(ep))
  2796. X        if (sym == car(car(ep))) {
  2797. X        rplacd(car(ep),val);
  2798. X        return;
  2799. X        }
  2800. X
  2801. X    /* store the global value */
  2802. X    setfunction(sym,val);
  2803. X}
  2804. X
  2805. X/* xlgetprop - get the value of a property */
  2806. XLVAL xlgetprop(sym,prp)
  2807. X  LVAL sym,prp;
  2808. X{
  2809. X    LVAL p;
  2810. X    return ((p = findprop(sym,prp)) ? car(p) : NIL);
  2811. X}
  2812. X
  2813. X/* xlputprop - put a property value onto the property list */
  2814. Xxlputprop(sym,val,prp)
  2815. X  LVAL sym,val,prp;
  2816. X{
  2817. X    LVAL pair;
  2818. X    if (pair = findprop(sym,prp))
  2819. X    rplaca(pair,val);
  2820. X    else
  2821. X    setplist(sym,cons(prp,cons(val,getplist(sym))));
  2822. X}
  2823. X
  2824. X/* xlremprop - remove a property from a property list */
  2825. Xxlremprop(sym,prp)
  2826. X  LVAL sym,prp;
  2827. X{
  2828. X    LVAL last,p;
  2829. X    last = NIL;
  2830. X    for (p = getplist(sym); consp(p) && consp(cdr(p)); p = cdr(last)) {
  2831. X    if (car(p) == prp)
  2832. X        if (last)
  2833. X        rplacd(last,cdr(cdr(p)));
  2834. X        else
  2835. X        setplist(sym,cdr(cdr(p)));
  2836. X    last = cdr(p);
  2837. X    }
  2838. X}
  2839. X
  2840. X/* findprop - find a property pair */
  2841. XLOCAL LVAL findprop(sym,prp)
  2842. X  LVAL sym,prp;
  2843. X{
  2844. X    LVAL p;
  2845. X    for (p = getplist(sym); consp(p) && consp(cdr(p)); p = cdr(cdr(p)))
  2846. X    if (car(p) == prp)
  2847. X        return (cdr(p));
  2848. X    return (NIL);
  2849. X}
  2850. X
  2851. X/* hash - hash a symbol name string */
  2852. Xint hash(str,len)
  2853. X  char *str;
  2854. X{
  2855. X    int i;
  2856. X    for (i = 0; *str; )
  2857. X    i = (i << 2) ^ *str++;
  2858. X    i %= len;
  2859. X    return (i < 0 ? -i : i);
  2860. X}
  2861. X
  2862. X/* xlsinit - symbol initialization routine */
  2863. Xxlsinit()
  2864. X{
  2865. X    LVAL array,p;
  2866. X
  2867. X    /* initialize the obarray */
  2868. X    obarray = xlmakesym("*OBARRAY*");
  2869. X    array = newvector(HSIZE);
  2870. X    setvalue(obarray,array);
  2871. X
  2872. X    /* add the symbol *OBARRAY* to the obarray */
  2873. X    p = consa(obarray);
  2874. X    setelement(array,hash("*OBARRAY*",HSIZE),p);
  2875. X}
  2876. END_OF_FILE
  2877. if test 7019 -ne `wc -c <'src/xlisp/xcore/c/xlsym.c'`; then
  2878.     echo shar: \"'src/xlisp/xcore/c/xlsym.c'\" unpacked with wrong size!
  2879. fi
  2880. # end of 'src/xlisp/xcore/c/xlsym.c'
  2881. fi
  2882. if test -f 'src/xlisp/xcore/c/xlsys.c' -a "${1}" != "-c" ; then 
  2883.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xlsys.c'\"
  2884. else
  2885. echo shar: Extracting \"'src/xlisp/xcore/c/xlsys.c'\" \(5566 characters\)
  2886. sed "s/^X//" >'src/xlisp/xcore/c/xlsys.c' <<'END_OF_FILE'
  2887. X/* -*-C-*-
  2888. X********************************************************************************
  2889. X*
  2890. X* File:         xlsys.c
  2891. X* RCS:          $Header: xlsys.c,v 1.5 89/11/25 05:49:55 mayer Exp $
  2892. X* Description:  xlisp builtin system functions
  2893. X* Author:       David Michael Betz
  2894. X* Created:      
  2895. X* Modified:     Sat Nov 25 05:49:49 1989 (Niels Mayer) mayer@hplnpm
  2896. X* Language:     C
  2897. X* Package:      N/A
  2898. X* Status:       X11r4 contrib tape release
  2899. X*
  2900. X* WINTERP 1.0 Copyright 1989 Hewlett-Packard Company (by Niels Mayer).
  2901. X* XLISP version 2.1, Copyright (c) 1989, by David Betz.
  2902. X*
  2903. X* Permission to use, copy, modify, distribute, and sell this software and its
  2904. X* documentation for any purpose is hereby granted without fee, provided that
  2905. X* the above copyright notice appear in all copies and that both that
  2906. X* copyright notice and this permission notice appear in supporting
  2907. X* documentation, and that the name of Hewlett-Packard and David Betz not be
  2908. X* used in advertising or publicity pertaining to distribution of the software
  2909. X* without specific, written prior permission.  Hewlett-Packard and David Betz
  2910. X* make no representations about the suitability of this software for any
  2911. X* purpose. It is provided "as is" without express or implied warranty.
  2912. X*
  2913. X* HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  2914. X* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  2915. X* IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  2916. X* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  2917. X* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  2918. X* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  2919. X* PERFORMANCE OF THIS SOFTWARE.
  2920. X*
  2921. X* See ./winterp/COPYRIGHT for information on contacting the authors.
  2922. X* 
  2923. X* Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  2924. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  2925. X*
  2926. X********************************************************************************
  2927. X*/
  2928. Xstatic char rcs_identity[] = "@(#)$Header: xlsys.c,v 1.5 89/11/25 05:49:55 mayer Exp $";
  2929. X
  2930. X
  2931. X#include "xlisp.h"
  2932. X
  2933. X/* external variables */
  2934. Xextern jmp_buf top_level;
  2935. Xextern FILE *tfp;
  2936. X
  2937. X/* external symbols */
  2938. Xextern LVAL a_subr,a_fsubr,a_cons,a_symbol;
  2939. Xextern LVAL a_fixnum,a_flonum,a_string,a_object,a_stream;
  2940. Xextern LVAL a_vector,a_closure,a_char,a_ustream;
  2941. Xextern LVAL k_verbose,k_print;
  2942. Xextern LVAL true;
  2943. X
  2944. X
  2945. X/* external routines */
  2946. Xextern FILE *osaopen();
  2947. X
  2948. X/* Include hybrid-class functions: *//* JSP */
  2949. X#define MODULE_XLSYS_C_GLOBALS
  2950. X#include "../../xmodules.h"
  2951. X#undef MODULE_XLSYS_C_GLOBALS
  2952. X
  2953. X
  2954. X/* xload - read and evaluate expressions from a file */
  2955. XLVAL xload()
  2956. X{
  2957. X    unsigned char *name;
  2958. X    int vflag,pflag;
  2959. X    LVAL arg;
  2960. X
  2961. X    /* get the file name */
  2962. X    name = getstring(xlgetfname());
  2963. X
  2964. X    /* get the :verbose flag */
  2965. X    if (xlgetkeyarg(k_verbose,&arg))
  2966. X    vflag = (arg != NIL);
  2967. X    else
  2968. X    vflag = TRUE;
  2969. X
  2970. X    /* get the :print flag */
  2971. X    if (xlgetkeyarg(k_print,&arg))
  2972. X    pflag = (arg != NIL);
  2973. X    else
  2974. X    pflag = FALSE;
  2975. X
  2976. X    /* load the file */
  2977. X    return (xlload(name,vflag,pflag) ? true : NIL);
  2978. X}
  2979. X
  2980. X/* xtranscript - open or close a transcript file */
  2981. XLVAL xtranscript()
  2982. X{
  2983. X    unsigned char *name;
  2984. X
  2985. X    /* get the transcript file name */
  2986. X    name = (moreargs() ? getstring(xlgetfname()) : NULL);
  2987. X    xllastarg();
  2988. X
  2989. X    /* close the current transcript */
  2990. X    if (tfp) osclose(tfp);
  2991. X
  2992. X    /* open the new transcript */
  2993. X    tfp = (name ? osaopen(name,"w") : NULL);
  2994. X
  2995. X    /* return T if a transcript is open, NIL otherwise */
  2996. X    return (tfp ? true : NIL);
  2997. X}
  2998. X
  2999. X/* xtype - return type of a thing */
  3000. XLVAL xtype()
  3001. X{
  3002. X    LVAL arg;
  3003. X
  3004. X    if (!(arg = xlgetarg()))
  3005. X    return (NIL);
  3006. X
  3007. X    switch (ntype(arg)) {
  3008. X    case SUBR:        return (a_subr);
  3009. X    case FSUBR:        return (a_fsubr);
  3010. X    case CONS:        return (a_cons);
  3011. X    case SYMBOL:    return (a_symbol);
  3012. X    case FIXNUM:    return (a_fixnum);
  3013. X    case FLONUM:    return (a_flonum);
  3014. X    case STRING:    return (a_string);
  3015. X    case OBJECT:    return (a_object);
  3016. X    case STREAM:    return (a_stream);
  3017. X    case VECTOR:    return (a_vector);
  3018. X    case CLOSURE:    return (a_closure);
  3019. X    case CHAR:        return (a_char);
  3020. X    case USTREAM:    return (a_ustream);
  3021. X    case STRUCT:    return (getelement(arg,0));
  3022. X/* Include hybrid-class functions: *//* JSP */
  3023. X#define MODULE_XLSYS_C_XTYPE
  3024. X#include "../../xmodules.h"
  3025. X#undef MODULE_XLSYS_C_XTYPE
  3026. X    default:        xlfail("bad node type");
  3027. X    }
  3028. X}
  3029. X
  3030. X/* xbaktrace - print the trace back stack */
  3031. XLVAL xbaktrace()
  3032. X{
  3033. X    LVAL num;
  3034. X    int n;
  3035. X
  3036. X    if (moreargs()) {
  3037. X    num = xlgafixnum();
  3038. X    n = getfixnum(num);
  3039. X    }
  3040. X    else
  3041. X    n = -1;
  3042. X    xllastarg();
  3043. X    xlbaktrace(n);
  3044. X    return (NIL);
  3045. X}
  3046. X
  3047. X/* xexit - get out of xlisp */
  3048. XLVAL xexit()
  3049. X{
  3050. X    xllastarg();
  3051. X    wrapup();
  3052. X}
  3053. X
  3054. X/* xpeek - peek at a location in memory */
  3055. XLVAL xpeek()
  3056. X{
  3057. X    LVAL num;
  3058. X    int *adr;
  3059. X
  3060. X    /* get the address */
  3061. X    num = xlgafixnum(); adr = (int *)getfixnum(num);
  3062. X    xllastarg();
  3063. X
  3064. X    /* return the value at that address */
  3065. X    return (cvfixnum((FIXTYPE)*adr));
  3066. X}
  3067. X
  3068. X/* xpoke - poke a value into memory */
  3069. XLVAL xpoke()
  3070. X{
  3071. X    LVAL val;
  3072. X    int *adr;
  3073. X
  3074. X    /* get the address and the new value */
  3075. X    val = xlgafixnum(); adr = (int *)getfixnum(val);
  3076. X    val = xlgafixnum();
  3077. X    xllastarg();
  3078. X
  3079. X    /* store the new value */
  3080. X    *adr = (int)getfixnum(val);
  3081. X
  3082. X    /* return the new value */
  3083. X    return (val);
  3084. X}
  3085. X
  3086. X/* xaddrs - get the address of an XLISP node */
  3087. XLVAL xaddrs()
  3088. X{
  3089. X    LVAL val;
  3090. X
  3091. X    /* get the node */
  3092. X    val = xlgetarg();
  3093. X    xllastarg();
  3094. X
  3095. X    /* return the address of the node */
  3096. X    return (cvfixnum((FIXTYPE)val));
  3097. X}
  3098. X
  3099. END_OF_FILE
  3100. if test 5566 -ne `wc -c <'src/xlisp/xcore/c/xlsys.c'`; then
  3101.     echo shar: \"'src/xlisp/xcore/c/xlsys.c'\" unpacked with wrong size!
  3102. fi
  3103. # end of 'src/xlisp/xcore/c/xlsys.c'
  3104. fi
  3105. if test -f 'src/xlisp/xcore/c/xmain.c' -a "${1}" != "-c" ; then 
  3106.   echo shar: Will not clobber existing file \"'src/xlisp/xcore/c/xmain.c'\"
  3107. else
  3108. echo shar: Extracting \"'src/xlisp/xcore/c/xmain.c'\" \(3942 characters\)
  3109. sed "s/^X//" >'src/xlisp/xcore/c/xmain.c' <<'END_OF_FILE'
  3110. X/* xlisp.c - a small implementation of lisp with object-oriented programming */
  3111. X/*    Copyright (c) 1987, by David Michael Betz */
  3112. X
  3113. X#include "xlisp.h"
  3114. X
  3115. X/* define the banner line string */
  3116. X#define BANNER    "XLISP version 2.1, Copyright (c) 1989, by David Betz"
  3117. X
  3118. X/* global variables */
  3119. Xjmp_buf top_level;
  3120. X
  3121. X/* external variables */
  3122. Xextern LVAL s_stdin,s_evalhook,s_applyhook;
  3123. Xextern LVAL s_1plus,s_2plus,s_3plus,s_1star,s_2star,s_3star,s_minus;
  3124. Xextern int xltrcindent;
  3125. Xextern int xldebug;
  3126. Xextern LVAL true;
  3127. Xextern char buf[];
  3128. Xextern FILE *tfp;
  3129. X
  3130. X/* external routines */
  3131. Xextern FILE *osaopen();
  3132. Xextern void xlshutdown_hybrid();  /* Voodoo */
  3133. X
  3134. X/* xmain - the main routine */
  3135. Xxmain(argc,argv)
  3136. X  int argc; char *argv[];
  3137. X{
  3138. X    char *transcript;
  3139. X    CONTEXT cntxt;
  3140. X    int verbose,i;
  3141. X    LVAL expr;
  3142. X
  3143. X    /* setup default argument values */
  3144. X    transcript = NULL;
  3145. X    verbose = FALSE;
  3146. X
  3147. X    /* parse the argument list switches */
  3148. X#ifndef LSC
  3149. X    for (i = 1; i < argc; ++i) {
  3150. X    if (argv[i][0] == '-') {
  3151. X        switch(argv[i][1]) {
  3152. X        case 't':
  3153. X        case 'T':
  3154. X        transcript = &argv[i][2];
  3155. X        break;
  3156. X        case 'v':
  3157. X        case 'V':
  3158. X        verbose = TRUE;
  3159. X        break;
  3160. X        }
  3161. X        }
  3162. X    }
  3163. X#endif
  3164. X
  3165. X    /* initialize and print the banner line */
  3166. X    osinit(BANNER);
  3167. X
  3168. X    /* setup initialization error handler */
  3169. X    xlbegin(&cntxt,CF_TOPLEVEL|CF_CLEANUP|CF_BRKLEVEL,(LVAL)1);
  3170. X    if (xlsetjmp(cntxt.c_jmpbuf))
  3171. X    xlfatal("fatal initialization error");
  3172. X    if (xlsetjmp(top_level))
  3173. X    xlfatal("RESTORE not allowed during initialization");
  3174. X
  3175. X    /* initialize xlisp */
  3176. X    xlinit();
  3177. X    xlend(&cntxt);
  3178. X
  3179. X    /* reset the error handler */
  3180. X    xlbegin(&cntxt,CF_TOPLEVEL|CF_CLEANUP|CF_BRKLEVEL,true);
  3181. X
  3182. X    /* open the transcript file */
  3183. X    if (transcript && (tfp = osaopen(transcript,"w")) == NULL) {
  3184. X    sprintf(buf,"error: can't open transcript file: %s",transcript);
  3185. X    stdputstr(buf);
  3186. X    }
  3187. X
  3188. X    /* load "init.lsp" */
  3189. X    if (xlsetjmp(cntxt.c_jmpbuf) == 0)
  3190. X    xlload("init.lsp",TRUE,FALSE);
  3191. X
  3192. X    /* load any files mentioned on the command line */
  3193. X    if (xlsetjmp(cntxt.c_jmpbuf) == 0)
  3194. X    for (i = 1; i < argc; i++)
  3195. X        if (argv[i][0] != '-' && !xlload(argv[i],TRUE,verbose))
  3196. X        xlerror("can't load file",cvstring(argv[i]));
  3197. X
  3198. X    /* target for restore */
  3199. X    if (xlsetjmp(top_level))
  3200. X    xlbegin(&cntxt,CF_TOPLEVEL|CF_CLEANUP|CF_BRKLEVEL,true);
  3201. X
  3202. X    /* protect some pointers */
  3203. X    xlsave1(expr);
  3204. X
  3205. X    /* main command processing loop */
  3206. X    for (;;) {
  3207. X
  3208. X    /* setup the error return */
  3209. X    if (xlsetjmp(cntxt.c_jmpbuf)) {
  3210. X        setvalue(s_evalhook,NIL);
  3211. X        setvalue(s_applyhook,NIL);
  3212. X        xltrcindent = 0;
  3213. X        xldebug = 0;
  3214. X        xlflush();
  3215. X    }
  3216. X
  3217. X    /* print a prompt */
  3218. X    stdputstr("> ");
  3219. X
  3220. X    /* read an expression */
  3221. X    if (!xlread(getvalue(s_stdin),&expr,FALSE))
  3222. X        break;
  3223. X
  3224. X    /* save the input expression */
  3225. X    xlrdsave(expr);
  3226. X
  3227. X    /* evaluate the expression */
  3228. X    expr = xleval(expr);
  3229. X
  3230. X    /* save the result */
  3231. X    xlevsave(expr);
  3232. X
  3233. X    /* print it */
  3234. X    stdprint(expr);
  3235. X    }
  3236. X    xlend(&cntxt);
  3237. X
  3238. X    /* clean up */
  3239. X    wrapup();
  3240. X}
  3241. X
  3242. X/* xlrdsave - save the last expression returned by the reader */
  3243. Xxlrdsave(expr)
  3244. X  LVAL expr;
  3245. X{
  3246. X    setvalue(s_3plus,getvalue(s_2plus));
  3247. X    setvalue(s_2plus,getvalue(s_1plus));
  3248. X    setvalue(s_1plus,getvalue(s_minus));
  3249. X    setvalue(s_minus,expr);
  3250. X}
  3251. X
  3252. X/* xlevsave - save the last expression returned by the evaluator */
  3253. Xxlevsave(expr)
  3254. X  LVAL expr;
  3255. X{
  3256. X    setvalue(s_3star,getvalue(s_2star));
  3257. X    setvalue(s_2star,getvalue(s_1star));
  3258. X    setvalue(s_1star,expr);
  3259. X}
  3260. X
  3261. X/* xlfatal - print a fatal error message and exit */
  3262. X#ifndef BOGUS
  3263. Xxlfatal(msg)
  3264. X  char *msg;
  3265. X{
  3266. X    xoserror(msg);
  3267. X    wrapup();
  3268. X}
  3269. X#else
  3270. Xstatic xlfatal_zero = 0;
  3271. Xxlfatal(msg)
  3272. X  char *msg;
  3273. X{
  3274. X    xoserror(msg);
  3275. Xprintf( "\ndummy printf %x, %x", 1 / xlfatal_zero, *(int*)xlfatal_zero );
  3276. X    wrapup();
  3277. X}
  3278. X#endif
  3279. X
  3280. X
  3281. X/* wrapup - clean up and exit to the operating system */
  3282. Xwrapup()
  3283. X{
  3284. X    /* pass last ditch control to user packages */ /* Voodoo */
  3285. X    xlshutdown_hybrid();
  3286. X
  3287. X    if (tfp)   osclose(tfp);
  3288. X
  3289. X    osfinish();
  3290. X    exit(0);
  3291. X}
  3292. X
  3293. X
  3294. END_OF_FILE
  3295. if test 3942 -ne `wc -c <'src/xlisp/xcore/c/xmain.c'`; then
  3296.     echo shar: \"'src/xlisp/xcore/c/xmain.c'\" unpacked with wrong size!
  3297. fi
  3298. # end of 'src/xlisp/xcore/c/xmain.c'
  3299. fi
  3300. if test -f 'src/xlisp/xmodules.h' -a "${1}" != "-c" ; then 
  3301.   echo shar: Will not clobber existing file \"'src/xlisp/xmodules.h'\"
  3302. else
  3303. echo shar: Extracting \"'src/xlisp/xmodules.h'\" \(3358 characters\)
  3304. sed "s/^X//" >'src/xlisp/xmodules.h' <<'END_OF_FILE'
  3305. X/* -*-C-*-                                                                   CrT
  3306. X********************************************************************************
  3307. X*
  3308. X* File:         xmodules.h
  3309. X* Description:  Master #include file for xlisp extension modules.
  3310. X* Author:       Jeff Prothero
  3311. X* Created:      90Nov16
  3312. X* Modified:     
  3313. X* Language:     C
  3314. X* Package:      N/A
  3315. X* Status:       
  3316. X*
  3317. X* Copyright (c) 1991, University of Washington (by Jeff Prothero)
  3318. X*
  3319. X* Permission to use, copy, modify, distribute, and sell this software
  3320. X* and its documentation for any purpose is hereby granted without fee,
  3321. X* provided that the above copyright notice appear in all copies and that
  3322. X* both that copyright notice and this permission notice appear in
  3323. X* supporting documentation, and that the name of University of
  3324. X* Washington and Jeff Prothero not be used in advertising or
  3325. X* publicity pertaining to distribution of the software without specific,
  3326. X* written prior permission.  University of Washington and Jeff Prothero make no
  3327. X* representations about the suitability of this software for any
  3328. X* purpose. It is provided "as is" without express or implied warranty.
  3329. X* 
  3330. X* UNIVERITY OF WASHINGTON AND JEFF PROTHERO DISCLAIM ALL WARRANTIES WITH
  3331. X* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  3332. X* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL UNIVERSITY OF WASHINGTON
  3333. X* NOR JEFF PROTHERO BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  3334. X* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  3335. X* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  3336. X* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  3337. X* PERFORMANCE OF THIS SOFTWARE.
  3338. X*
  3339. X* Please send modifications, improvements and bugfixes to jsp@milton.u.washington.edu
  3340. X* Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  3341. X*
  3342. X********************************************************************************
  3343. X*/
  3344. X
  3345. X/**************************************************************************/
  3346. X/* Some xlisp functions are written in C.  We call them "primitive        */
  3347. X/* functions" because they look atomic to xlisp code.              */
  3348. X/*                                       */
  3349. X/* Some xlisp classes need C language support.  We call them "hybrid      */
  3350. X/* classes", since they are written partly in xlisp and partly in C.      */
  3351. X/* Sometimes the C part accesses special host facilities like graphics      */
  3352. X/* hardware, and sometimes it simply speeds up critical operations.      */
  3353. X/*                                       */
  3354. X/* This file provides a central, single point of connection between the   */
  3355. X/* xlisp interpreter code and the code for xlisp extension modules --     */
  3356. X/* hybrid classes and optional libraries of primitive functions.  Rather  */
  3357. X/* than scattering "#ifdef"s all through the xlisp interpreter, you should*/
  3358. X/* simply add a single '#include "myclass/c/xmyclass.h"' line to this     */
  3359. X/* file.  See the file "xcore/doc/mymodule.h" to find out what you should */
  3360. X/* put in "xmyclass.h".                              */
  3361. X/**************************************************************************/
  3362. X
  3363. X/* Order is important! */
  3364. X/*#include "winterp/c/xwinterp.h"/* Just a skeleton at the moment. */
  3365. X
  3366. X#ifdef banana
  3367. X#include   "gobject/c/xgbj.h"    /* General objects.           */
  3368. X#include   "3d/c/x3d.h"          /* Some 3-D graphics stuff.       */
  3369. X#include "gplotlib/c/xgplot.h" /* gplotlib + interface.          */
  3370. X#endif
  3371. END_OF_FILE
  3372. if test 3358 -ne `wc -c <'src/xlisp/xmodules.h'`; then
  3373.     echo shar: \"'src/xlisp/xmodules.h'\" unpacked with wrong size!
  3374. fi
  3375. # end of 'src/xlisp/xmodules.h'
  3376. fi
  3377. echo shar: End of archive 2 \(of 16\).
  3378. cp /dev/null ark2isdone
  3379. MISSING=""
  3380. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
  3381.     if test ! -f ark${I}isdone ; then
  3382.     MISSING="${MISSING} ${I}"
  3383.     fi
  3384. done
  3385. if test "${MISSING}" = "" ; then
  3386.     echo You have unpacked all 16 archives.
  3387.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  3388. else
  3389.     echo You still need to unpack the following archives:
  3390.     echo "        " ${MISSING}
  3391. fi
  3392. ##  End of shell archive.
  3393. exit 0
  3394.