home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1124 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  58.6 KB

  1. From: csimmons@jewel.oracle.com (Charles Simmons)
  2. Newsgroups: alt.sources
  3. Subject: Interactive Mandelbrots on a Heterogeneous Network (2 of 2)
  4. Message-ID: <1990Apr3.073107.5582@oracle.com>
  5. Date: 3 Apr 90 07:31:07 GMT
  6.  
  7.  
  8. # This is a shell archive.  Remove anything before this line, then
  9. # unpack it by saving it in a file and typing "sh file".  (Files
  10. # unpacked will be owned by you and have default permissions.)
  11. #
  12. # This archive contains:
  13. # LICENSE hostfile mandel.h mserver.c net.c net.h client.h colormap.data
  14. compute.c README
  15.  
  16. : =-=-=-=-=-=-= first line of shar 1 of 1 =-=-=-=-=-=-=-=-=-
  17. echo x - LICENSE
  18. sed -e 's/^X//' > "LICENSE" << '//E*O*F LICENSE//'
  19. X            GNU GENERAL PUBLIC LICENSE
  20. X             Version 1, February 1989
  21. X
  22. X Copyright (C) 1989 Free Software Foundation, Inc.
  23. X                    675 Mass Ave, Cambridge, MA 02139, USA
  24. X Everyone is permitted to copy and distribute verbatim copies
  25. X of this license document, but changing it is not allowed.
  26. X
  27. X                Preamble
  28. X
  29. X  The license agreements of most software companies try to keep users
  30. Xat the mercy of those companies.  By contrast, our General Public
  31. XLicense is intended to guarantee your freedom to share and change free
  32. Xsoftware--to make sure the software is free for all its users.  The
  33. XGeneral Public License applies to the Free Software Foundation's
  34. Xsoftware and to any other program whose authors commit to using it.
  35. XYou can use it for your programs, too.
  36. X
  37. X  When we speak of free software, we are referring to freedom, not
  38. Xprice.  Specifically, the General Public License is designed to make
  39. Xsure that you have the freedom to give away or sell copies of free
  40. Xsoftware, that you receive source code or can get it if you want it,
  41. Xthat you can change the software or use pieces of it in new free
  42. Xprograms; and that you know you can do these things.
  43. X
  44. X  To protect your rights, we need to make restrictions that forbid
  45. Xanyone to deny you these rights or to ask you to surrender the rights.
  46. XThese restrictions translate to certain responsibilities for you if you
  47. Xdistribute copies of the software, or if you modify it.
  48. X
  49. X  For example, if you distribute copies of a such a program, whether
  50. Xgratis or for a fee, you must give the recipients all the rights that
  51. Xyou have.  You must make sure that they, too, receive or can get the
  52. Xsource code.  And you must tell them their rights.
  53. X
  54. X  We protect your rights with two steps: (1) copyright the software, and
  55. X(2) offer you this license which gives you legal permission to copy,
  56. Xdistribute and/or modify the software.
  57. X
  58. X  Also, for each author's protection and ours, we want to make certain
  59. Xthat everyone understands that there is no warranty for this free
  60. Xsoftware.  If the software is modified by someone else and passed on, we
  61. Xwant its recipients to know that what they have is not the original, so
  62. Xthat any problems introduced by others will not reflect on the original
  63. Xauthors' reputations.
  64. X
  65. X  The precise terms and conditions for copying, distribution and
  66. Xmodification follow.
  67. X
  68. X            GNU GENERAL PUBLIC LICENSE
  69. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  70. X
  71. X  0. This License Agreement applies to any program or other work which
  72. Xcontains a notice placed by the copyright holder saying it may be
  73. Xdistributed under the terms of this General Public License.  The
  74. X"Program", below, refers to any such program or work, and a "work based
  75. Xon the Program" means either the Program or any work containing the
  76. XProgram or a portion of it, either verbatim or with modifications.  Each
  77. Xlicensee is addressed as "you".
  78. X
  79. X  1. You may copy and distribute verbatim copies of the Program's source
  80. Xcode as you receive it, in any medium, provided that you conspicuously and
  81. Xappropriately publish on each copy an appropriate copyright notice and
  82. Xdisclaimer of warranty; keep intact all the notices that refer to this
  83. XGeneral Public License and to the absence of any warranty; and give any
  84. Xother recipients of the Program a copy of this General Public License
  85. Xalong with the Program.  You may charge a fee for the physical act of
  86. Xtransferring a copy.
  87. X
  88. X  2. You may modify your copy or copies of the Program or any portion of
  89. Xit, and copy and distribute such modifications under the terms of Paragraph
  90. X1 above, provided that you also do the following:
  91. X
  92. X    a) cause the modified files to carry prominent notices stating that
  93. X    you changed the files and the date of any change; and
  94. X
  95. X    b) cause the whole of any work that you distribute or publish, that
  96. X    in whole or in part contains the Program or any part thereof, either
  97. X    with or without modifications, to be licensed at no charge to all
  98. X    third parties under the terms of this General Public License (except
  99. X    that you may choose to grant warranty protection to some or all
  100. X    third parties, at your option).
  101. X
  102. X    c) If the modified program normally reads commands interactively when
  103. X    run, you must cause it, when started running for such interactive use
  104. X    in the simplest and most usual way, to print or display an
  105. X    announcement including an appropriate copyright notice and a notice
  106. X    that there is no warranty (or else, saying that you provide a
  107. X    warranty) and that users may redistribute the program under these
  108. X    conditions, and telling the user how to view a copy of this General
  109. X    Public License.
  110. X
  111. X    d) You may charge a fee for the physical act of transferring a
  112. X    copy, and you may at your option offer warranty protection in
  113. X    exchange for a fee.
  114. X
  115. XMere aggregation of another independent work with the Program (or its
  116. Xderivative) on a volume of a storage or distribution medium does not bring
  117. Xthe other work under the scope of these terms.
  118. X
  119. X  3. You may copy and distribute the Program (or a portion or derivative of
  120. Xit, under Paragraph 2) in object code or executable form under the terms of
  121. XParagraphs 1 and 2 above provided that you also do one of the following:
  122. X
  123. X    a) accompany it with the complete corresponding machine-readable
  124. X    source code, which must be distributed under the terms of
  125. X    Paragraphs 1 and 2 above; or,
  126. X
  127. X    b) accompany it with a written offer, valid for at least three
  128. X    years, to give any third party free (except for a nominal charge
  129. X    for the cost of distribution) a complete machine-readable copy of the
  130. X    corresponding source code, to be distributed under the terms of
  131. X    Paragraphs 1 and 2 above; or,
  132. X
  133. X    c) accompany it with the information you received as to where the
  134. X    corresponding source code may be obtained.  (This alternative is
  135. X    allowed only for noncommercial distribution and only if you
  136. X    received the program in object code or executable form alone.)
  137. X
  138. XSource code for a work means the preferred form of the work for making
  139. Xmodifications to it.  For an executable file, complete source code means
  140. Xall the source code for all modules it contains; but, as a special
  141. Xexception, it need not include source code for modules which are standard
  142. Xlibraries that accompany the operating system on which the executable
  143. Xfile runs, or for standard header files or definitions files that
  144. Xaccompany that operating system.
  145. X
  146. X  4. You may not copy, modify, sublicense, distribute or transfer the
  147. XProgram except as expressly provided under this General Public License.
  148. XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
  149. Xthe Program is void, and will automatically terminate your rights to use
  150. Xthe Program under this License.  However, parties who have received
  151. Xcopies, or rights to use copies, from you under this General Public
  152. XLicense will not have their licenses terminated so long as such parties
  153. Xremain in full compliance.
  154. X
  155. X  5. By copying, distributing or modifying the Program (or any work based
  156. Xon the Program) you indicate your acceptance of this license to do so,
  157. Xand all its terms and conditions.
  158. X
  159. X  6. Each time you redistribute the Program (or any work based on the
  160. XProgram), the recipient automatically receives a license from the original
  161. Xlicensor to copy, distribute or modify the Program subject to these
  162. Xterms and conditions.  You may not impose any further restrictions on the
  163. Xrecipients' exercise of the rights granted herein.
  164. X
  165. X  7. The Free Software Foundation may publish revised and/or new versions
  166. Xof the General Public License from time to time.  Such new versions will
  167. Xbe similar in spirit to the present version, but may differ in detail to
  168. Xaddress new problems or concerns.
  169. X
  170. XEach version is given a distinguishing version number.  If the Program
  171. Xspecifies a version number of the license which applies to it and "any
  172. Xlater version", you have the option of following the terms and conditions
  173. Xeither of that version or of any later version published by the Free
  174. XSoftware Foundation.  If the Program does not specify a version number of
  175. Xthe license, you may choose any version ever published by the Free Software
  176. XFoundation.
  177. X
  178. X  8. If you wish to incorporate parts of the Program into other free
  179. Xprograms whose distribution conditions are different, write to the author
  180. Xto ask for permission.  For software which is copyrighted by the Free
  181. XSoftware Foundation, write to the Free Software Foundation; we sometimes
  182. Xmake exceptions for this.  Our decision will be guided by the two goals
  183. Xof preserving the free status of all derivatives of our free software and
  184. Xof promoting the sharing and reuse of software generally.
  185. X
  186. X                NO WARRANTY
  187. X
  188. X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  189. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  190. XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  191. XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  192. XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  193. XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  194. XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  195. XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  196. XREPAIR OR CORRECTION.
  197. X
  198. X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  199. XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  200. XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  201. XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  202. XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  203. XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  204. XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  205. XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  206. XPOSSIBILITY OF SUCH DAMAGES.
  207. X
  208. X             END OF TERMS AND CONDITIONS
  209. //E*O*F LICENSE//
  210.  
  211. echo x - hostfile
  212. sed -e 's/^X//' > "hostfile" << '//E*O*F hostfile//'
  213. Xhqsun7 9993 16
  214. //E*O*F hostfile//
  215.  
  216. echo x - mandel.h
  217. sed -e 's/^X//' > "mandel.h" << '//E*O*F mandel.h//'
  218. X/*
  219. X * Mandel by Rob Swiston and Chuck Simmons
  220. X * Copyright (C) 1989, 1990 by Rob Swiston and Chuck Simmons
  221. X *
  222. X * This program is free software; you can redistribute it and/or modify
  223. X * it under the terms of version 1 of the GNU General Public License as
  224. X * published by the Free Software Foundation.
  225. X *
  226. X * This program is distributed in the hope that it will be useful,
  227. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  228. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  229. X * GNU General Public License for more details.
  230. X *
  231. X * You should have received a copy of the GNU General Public License
  232. X * along with this program; if not, write to the Free Software
  233. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  234. X */
  235. X
  236. X/*
  237. X * Widely used definitions.
  238. X */
  239. X
  240. X/* Random defaults. */
  241. X#define HOSTFILE "hostfile"
  242. X#define HPIXELS 256 /* default screen width in pixels */
  243. X#define VPIXELS 256 /* default screen height in pixels */
  244. X
  245. Xtypedef struct color_x {
  246. X    short color;
  247. X    short x;
  248. X} color_x_t;
  249. X
  250. X#ifndef TRUE
  251. X# define TRUE 1
  252. X# define FALSE 0
  253. X#endif
  254. X
  255. //E*O*F mandel.h//
  256.  
  257. echo x - mserver.c
  258. sed -e 's/^X//' > "mserver.c" << '//E*O*F mserver.c//'
  259. X/*
  260. X * Mandel by Rob Swiston and Chuck Simmons
  261. X * Copyright (C) 1989, 1990 by Rob Swiston and Chuck Simmons
  262. X *
  263. X * This program is free software; you can redistribute it and/or modify
  264. X * it under the terms of version 1 of the GNU General Public License as
  265. X * published by the Free Software Foundation.
  266. X *
  267. X * This program is distributed in the hope that it will be useful,
  268. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  269. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  270. X * GNU General Public License for more details.
  271. X *
  272. X * You should have received a copy of the GNU General Public License
  273. X * along with this program; if not, write to the Free Software
  274. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  275. X */
  276. X
  277. X/*
  278. X * This is the glue that holds the server side of the mandelbrot
  279. X * program together.  We set up a listener process that will listen
  280. X * for connections.  In response to a connection, we fork off a child
  281. X * process that will service the client.
  282. X */
  283. X
  284. X#include <signal.h>
  285. X#include <stdio.h>
  286. X#include "mandel.h"
  287. X#include "net.h"
  288. X
  289. X#ifndef SIGCLD
  290. X# define SIGCLD SIGCHLD /* make the sequent happy */
  291. X#endif
  292. X
  293. Xvoid
  294. Xusage (name)
  295. Xchar *name;
  296. X{
  297. X    (void) fprintf (stderr, "%s: Usage %s port\n", name, name);
  298. X    exit (1);
  299. X}
  300. X
  301. X/*
  302. X * Clean up after a dead child.
  303. X */
  304. X
  305. Xvoid
  306. Xcleanup ()
  307. X{
  308. X    int stat;
  309. X
  310. X    wait (&stat);
  311. X}
  312. X
  313. Xint
  314. Xmain (argc, argv)
  315. Xint argc;
  316. Xchar **argv;
  317. X{
  318. X    int port;
  319. X    int sock;
  320. X
  321. X    if (argc != 2) usage (argv[0]);
  322. X
  323. X    port = atoi (argv[1]);
  324. X    if (port <= 0) usage (argv[0]);
  325. X
  326. X    /* Set up a signal handler to clean up after dead children. */
  327. X    (void) signal (SIGCLD, cleanup);
  328. X
  329. X    /* Start up the listener process, which will fork in
  330. X     * response to each new connection, returning the socket
  331. X     * that was created.
  332. X     */
  333. X    sock = net_slisten (port);
  334. X    if (sock == -1) {
  335. X        perror ("mserver: net_slisten failed");
  336. X        exit (1);
  337. X    }
  338. X
  339. X    net_server (sock); /* service the client */
  340. X    return 0;
  341. X}
  342. X    
  343. X
  344. //E*O*F mserver.c//
  345.  
  346. echo x - net.c
  347. sed -e 's/^X//' > "net.c" << '//E*O*F net.c//'
  348. X/*
  349. X * Mandel by Rob Swiston and Chuck Simmons
  350. X * Copyright (C) 1989, 1990 by Rob Swiston and Chuck Simmons
  351. X *
  352. X * This program is free software; you can redistribute it and/or modify
  353. X * it under the terms of version 1 of the GNU General Public License as
  354. X * published by the Free Software Foundation.
  355. X *
  356. X * This program is distributed in the hope that it will be useful,
  357. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  358. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  359. X * GNU General Public License for more details.
  360. X *
  361. X * You should have received a copy of the GNU General Public License
  362. X * along with this program; if not, write to the Free Software
  363. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  364. X */
  365. X
  366. X/*
  367. X * This file handles the code to implement a remote procedure call
  368. X * for the mandelbrot set.  There are two portions to this package:
  369. X * the portion linked into the client side (the side initiating the
  370. X * rpc), and the portion linked into the server side (the side implementing
  371. X * the procedure call).
  372. X *
  373. X * This 'rpc' is a bit wierd in that on the client side, the 'rpc'
  374. X * executes asynchronously.  That is, the client side will call a
  375. X * routine to initiate the rpc, passing arguments to the remote procedure
  376. X * and passing a special value that identifies this call.  Later, the
  377. X * client will notice that the 'rpc' has finished and will call another
  378. X * routine to pick up the results of the call.
  379. X *
  380. X * Since the special identifer value used on the client side is used
  381. X * purely to identify a packet, this identifier is not passed to the
  382. X * subroutine on the server side.
  383. X *
  384. X * We handle all necessary byte swapping in this routine.
  385. X */
  386. X
  387. X#include <sys/types.h>
  388. X#include <sys/socket.h>
  389. X#include <netinet/in.h>
  390. X#include <netdb.h>
  391. X#include <errno.h>
  392. X#include <stdio.h>
  393. X#include "mandel.h"
  394. X
  395. Xextern int errno; /* not defined in errno.h on pyramid */
  396. X
  397. X/*
  398. X * Routines to perform floating point conversion.  Our standard format
  399. X * is that used by the MIPS R2000, Sun, and Sequent systems.
  400. X */
  401. X
  402. X#ifdef VAX_BYTE_ORDER
  403. X/*
  404. X * Swap bytes for IEEE floating point.
  405. X */
  406. Xdouble
  407. Xhtond (x)
  408. Xdouble x;
  409. X{
  410. X    char *p, *q;
  411. X    double y;
  412. X    int i;
  413. X
  414. X    p = (char *) &x;
  415. X    q = (char *) &y;
  416. X
  417. X    for (i = 0; i < sizeof (double); i++) {
  418. X        q[sizeof (double) - i - 1] = p[i];
  419. X    }
  420. X
  421. X    return y;
  422. X}
  423. X
  424. X# define ntohd(x) htond (x)
  425. X# define double_done
  426. X#endif
  427. X
  428. X#ifdef CONVEX
  429. X/*
  430. X * Convert between Convex floating point format and IEEE floating point.
  431. X * We need to subtract two from the exponent of the Convex format.
  432. X *
  433. X * These routines aren't real robust for very small or very large numbers.
  434. X */
  435. X
  436. Xdouble
  437. Xhtond (x)
  438. Xdouble x;
  439. X{
  440. X    long *l1, *l2;
  441. X    double y;
  442. X
  443. X    l1 = (long *) &x;
  444. X    l2 = (long *) &y;
  445. X
  446. X    y = x; /* init result */
  447. X    l2[0] = l1[0] - 0x200000; /* fix up exponent */
  448. X    return y;
  449. X}
  450. X
  451. X/* Add two going the other way. */
  452. X
  453. Xdouble
  454. Xntohd (x)
  455. Xdouble x;
  456. X{
  457. X    long *l1, *l2;
  458. X    double y;
  459. X
  460. X    l1 = (long *) &x;
  461. X    l2 = (long *) &y;
  462. X
  463. X    y = x; /* init result */
  464. X    l2[0] = l1[0] + 0x200000; /* fix up exponent */
  465. X    return y;
  466. X}
  467. X
  468. X# define double_done
  469. X#endif
  470. X
  471. X#ifdef IS_370
  472. X/*
  473. X * Convert between IBM 370 floating point format and IEEE floating point
  474. X * format.
  475. X */
  476. X
  477. Xdouble
  478. Xhtond (x)
  479. Xdouble x;
  480. X{
  481. X    int exp;
  482. X    int sign;
  483. X    long long frac;
  484. X    double y;
  485. X    long *l;
  486. X    long long *ll;
  487. X
  488. X    ll = (long long *) &x;
  489. X    frac = *ll; /* fraction and other stuff */
  490. X    exp = (frac >> 56) & 0x7f; /* extract exponent */
  491. X    sign = (frac >> 32) & 0x80000000; /* extract sign */
  492. X
  493. X    /* build IEEE format */
  494. X    frac = (frac >> 4) & 0xfffffffffffff;
  495. X
  496. X    /*
  497. X     * Convert the exponent.  In IBM land, this is a signed
  498. X     * exponent used as a power of 16.  We want a power of
  499. X     * 2, so we make the exponent signed, multiply by 4,
  500. X     * and then add on the bias of 1023.
  501. X     */
  502. X    exp = (exp << 25) >> 25; /* make signed */
  503. X    exp *= 4; /* go from base 16 to base 2 */
  504. X    exp += 1023; /* add on the bias */
  505. X
  506. X    exp = (exp & 0x7ff) << 20;
  507. X
  508. X    ll = (long long *) &y;
  509. X    *ll = frac;
  510. X
  511. X    l = (long *) &y;
  512. X    *l |= sign | exp;
  513. X
  514. X(void) printf ("htond: converted (%f) 0x%x 0x%x to 0x%x 0x%x\n",
  515. X        %f, ((long *)(&x))[0], ((long *)(&x))[1],
  516. X        ((long *)(&y))[0], ((long *)(&y))[1]);
  517. X
  518. X    return y;
  519. X}
  520. X
  521. X/* Go the other way. */
  522. X
  523. Xdouble
  524. Xntohd (x)
  525. Xdouble x;
  526. X{
  527. X    int exp;
  528. X    int sign;
  529. X    long long frac;
  530. X    double y;
  531. X    long *l;
  532. X    long *ll;
  533. X    int i;
  534. X
  535. X    ll = (long long *) &x;
  536. X    frac = *ll; /* fraction and other stuff */
  537. X    exp = (frac >> 52) & 0x7ff; /* extract exponent */
  538. X    sign = (frac >> 32) & 0x80000000; /* extract sign */
  539. X
  540. X    /* build IEEE format */
  541. X    frac = frac << 4;
  542. X
  543. X    /*
  544. X     * Convert the exponent.  First we subtract off the IEEE bias.
  545. X     * Then, we need to divide by four.  If exp is not a multiple
  546. X     * of four, then we shift the fraction one to the right and
  547. X     * increment the exponent until the exponent is a multiple of
  548. X     * four.
  549. X     */
  550. X    exp -= 1023; /* add on the bias */
  551. X
  552. X    i = 4 - (exp & 3);
  553. X    exp += i;
  554. X    frac >>= i;
  555. X
  556. X    exp /= 2;
  557. X    exp = (exp << 24) & 0x7f000000;
  558. X
  559. X    ll = (long long *) &y;
  560. X    *ll = frac & 0xfffffffffffff;
  561. X
  562. X    l = (long *) &y;
  563. X    *l |= sign | exp;
  564. X
  565. X(void) printf ("ntohd: converted 0x%x 0x%x to 0x%x 0x%x (%f)\n",
  566. X        ((long *)(&x))[0], ((long *)(&x))[1],
  567. X        ((long *)(&y))[0], ((long *)(&y))[1], y);
  568. X
  569. X    return y;
  570. X}
  571. X
  572. X# define double_done
  573. X#endif
  574. X
  575. X#ifndef double_done
  576. X/*
  577. X * Use this for IEEE floating point when VAX byte ordering is not
  578. X * present.
  579. X */
  580. X# define htond(x) (x)    /* host-to-network double */
  581. X# define ntohd(x) (x)    /* network-to-host double */
  582. X#endif
  583. X
  584. X/*
  585. X * Define the structure we use for passing information between client
  586. X * and server.
  587. X */
  588. Xtypedef struct net_parms {
  589. X    double x_start, y_start; /* starting coords of line */
  590. X    double x_end; /* ending coord of line */
  591. X    short npixels; /* number of pixels in line */
  592. X    short max_color; /* maximum colors per pixel */
  593. X    long unused; /* pad this out to a multiple of 8 bytes */
  594. X} net_parms_t;
  595. X
  596. X/*
  597. X * Define the structure used for passing the response.
  598. X */
  599. X/* The following doesn't work very well because the pyramid pads this
  600. X * out to be four bytes instead of the desired two bytes:
  601. X *
  602. X *    typedef struct net_response {
  603. X *        short buflen; / * number of elements following this header * /
  604. X *    } net_response_t;
  605. X */
  606. Xtypedef short net_response_t;
  607. X
  608. X#ifdef CLIENT
  609. X/*
  610. X * Provide an interface to the remote routine for the client.
  611. X * Return 0 on success, -1 on error.  If an error occurs, 'errno'
  612. X * will be set.
  613. X */
  614. X
  615. Xint
  616. Xnet_csend (sock, x_start, y_start, x_end, npixels, max_color)
  617. Xint sock;
  618. Xdouble x_start, y_start;
  619. Xdouble x_end;
  620. Xint npixels, max_color;
  621. X{
  622. X    net_parms_t parms;
  623. X    int len;
  624. X
  625. X    /* package the parameters */
  626. X    parms.x_start = htond (x_start);
  627. X    parms.y_start = htond (y_start);
  628. X    parms.x_end = htond (x_end);
  629. X    parms.npixels = htons (npixels);
  630. X    parms.max_color = htons (max_color);
  631. X
  632. X    len = write (sock, &parms, sizeof (parms));
  633. X    if (len == -1) return -1; /* return any error */
  634. X
  635. X    if (len < sizeof (parms)) { /* partial write? */
  636. X        errno = EIO;
  637. X        return -1;
  638. X    }
  639. X
  640. X    return 0; /* success */
  641. X}
  642. X#endif
  643. X
  644. X/*
  645. X * Experience shows that when we issue a read, we may not read all
  646. X * of the requested bytes, probably because of packetizing on the
  647. X * network.  Here, we will issue multiple reads, if necessary, to
  648. X * read all desired bytes.
  649. X */
  650. X
  651. Xstatic int
  652. Xnet_read (sock, buf, buflen)
  653. Xint sock; /* socket to read */
  654. Xchar *buf; /* buffer to fill */
  655. Xint buflen; /* length to read */
  656. X{
  657. X    int left;
  658. X    int len;
  659. X    char *p;
  660. X
  661. X    left = buflen;
  662. X    p = buf;
  663. X    while (left > 0) {
  664. X        len = read (sock, p, left);
  665. X        if (len == -1) return -1; /* error occured */
  666. X        if (len == 0) break; /* can't read any more */
  667. X
  668. X        left -= len;
  669. X        p += len;
  670. X    }
  671. X
  672. X    return buflen - left;
  673. X}
  674. X
  675. X#ifdef CLIENT
  676. X/*
  677. X * Provide a routine to return values to the client.  The client gives
  678. X * us an array that we fill, and we return a length to the client.
  679. X */
  680. X
  681. Xint
  682. Xnet_crecv (sock, buf)
  683. Xint sock; /* socket to read */
  684. Xcolor_x_t *buf; /* buffer to fill */
  685. X{
  686. X    net_response_t response;
  687. X    int len;
  688. X    int buflen;
  689. X
  690. X    /* read the response header */
  691. X    len = net_read (sock, (char *) &response, sizeof (response));
  692. X    if (len == -1) return -1; /* oops */
  693. X    if (len < sizeof (response)) {
  694. X        (void) fprintf (stderr,
  695. X            "net_crecv: reading header received %d of %d bytes\n",
  696. X            len, sizeof (response));
  697. X        errno = EIO;
  698. X        return -1;
  699. X    }
  700. X
  701. X    /* read buffer */
  702. X    buflen = ntohs (response);
  703. X    len = net_read (sock, (char *) buf, sizeof (*buf) * buflen);
  704. X    if (len == -1) return -1;
  705. X    if (len < sizeof (*buf) * buflen) {
  706. X        (void) fprintf (stderr,
  707. X            "net_crecv: reading buffer received %d of %d bytes\n",
  708. X            len, sizeof (*buf) * buflen);
  709. X        errno = EIO;
  710. X        return -1;
  711. X    }
  712. X
  713. X    /* byteswap the buffer contents */
  714. X    for (len = 0; len < buflen; len++) {
  715. X        buf[len].x = ntohs (buf[len].x);
  716. X        buf[len].color = ntohs (buf[len].color);
  717. X    }
  718. X    return buflen;
  719. X}
  720. X#endif
  721. X
  722. X/*
  723. X * The server routine.  This routine loops reading requests from the
  724. X * client and sending back responses.
  725. X */
  726. X
  727. X#ifdef SERVER
  728. Xvoid
  729. Xnet_server (sock)
  730. Xint sock;
  731. X{
  732. X    net_parms_t parms;
  733. X    net_response_t *response;
  734. X    int len, wlen, i;
  735. X    color_x_t *buf;
  736. X
  737. X    for (;;) { /* until an error occurs */
  738. X        /* read a request */
  739. X        len = net_read (sock, &parms, sizeof (parms));
  740. X        if (len == -1) {
  741. X            perror ("net_server: cannot read socket");
  742. X            exit (1);
  743. X        }
  744. X        if (len != sizeof (parms)) {
  745. X            if (len == 0) exit (0); /* client went away */
  746. X            (void) fprintf (stderr,
  747. X                "net_server: read %d of %d bytes.\n",
  748. X                len, sizeof (parms));
  749. X            exit (1);
  750. X        }
  751. X
  752. X        /* Byte swap the request. */
  753. X        parms.x_start = ntohd (parms.x_start);
  754. X        parms.y_start = ntohd (parms.y_start);
  755. X        parms.x_end = ntohd (parms.x_end);
  756. X        parms.npixels = ntohs (parms.npixels);
  757. X        parms.max_color = ntohs (parms.max_color);
  758. X
  759. X        /* Allocate storage for the response. */
  760. X        len = sizeof (*response) + parms.npixels * sizeof (color_x_t);
  761. X        response = (net_response_t *) malloc (len);
  762. X        if (!response) {
  763. X            (void) fprintf (stderr, "net_server: Out of memory.\n");
  764. X            exit (1);
  765. X        }
  766. X        buf = (color_x_t *) (response + 1);
  767. X
  768. X        /* Call the remote procedure. */
  769. X        len = mandel_line (parms.x_start, parms.y_start, parms.x_end,
  770. X                    parms.npixels, parms.max_color, buf);
  771. X
  772. X        /* byteswap the buffer contents */
  773. X        for (i = 0; i < len; i++) {
  774. X            buf[i].x = htons (buf[i].x);
  775. X            buf[i].color = htons (buf[i].color);
  776. X        }
  777. X
  778. X        /* Send the response to the client. */
  779. X        *response = htons (len);
  780. X
  781. X        wlen = sizeof (*response) + len * sizeof (color_x_t);
  782. X        len = write (sock, (char *) response, wlen);
  783. X        if (len == -1) {
  784. X            perror ("net_server: cannot write socket");
  785. X            exit (1);
  786. X        }
  787. X        if (len != wlen) {
  788. X            (void) fprintf (stderr,
  789. X                "net_server: wrote %d of %d bytes.\n",
  790. X                len, wlen);
  791. X            exit (1);
  792. X        }
  793. X
  794. X        free ((char *) response);
  795. X    }
  796. X}
  797. X
  798. X/*
  799. X * Server routine to listen for a connection.  In response, we fork
  800. X * and return the created connection.  The parent routine continues
  801. X * to listen.  Return -1 and set errno if we fail at some point.
  802. X */
  803. X
  804. Xint
  805. Xnet_slisten (port)
  806. Xint port; /* port on which to listen */
  807. X{
  808. X    int sock, new_sock;
  809. X    struct sockaddr_in sin, from;
  810. X    int len;
  811. X
  812. X    bzero ((char *) &sin, sizeof (sin));
  813. X    sin.sin_family = AF_INET;
  814. X    sin.sin_port = port;
  815. X
  816. X    sock = socket (AF_INET, SOCK_STREAM, 0);
  817. X    if (sock < 0) return -1;
  818. X
  819. X    if (bind (sock, &sin, sizeof (sin)) < 0) return -1;
  820. X
  821. X    listen (sock, 1);
  822. X    for (;;) {
  823. X        len = sizeof (from);
  824. X        new_sock = accept (sock, &from, &len);
  825. X        if (new_sock < 0) {
  826. X            if (errno == EINTR) continue;
  827. X            return -1;
  828. X        }
  829. X
  830. X        switch (fork ()) {
  831. X        case -1: /* error? */
  832. X            return -1;
  833. X
  834. X        case 0: /* child */
  835. X            (void) close (sock);
  836. X            return new_sock;
  837. X
  838. X        default: /* parent */
  839. X            (void) close (new_sock);
  840. X            break;
  841. X        }
  842. X    }
  843. X    /* NOTREACHED */
  844. X}
  845. X#endif            
  846. X
  847. X/*
  848. X * On the client side, open a connection to a server process.  Return
  849. X * the socket for the connection.  If something goes wrong, return -1
  850. X * with 'errno' set.
  851. X */
  852. X
  853. X#ifdef CLIENT
  854. Xint
  855. Xnet_copen (host, port)
  856. Xchar *host;
  857. Xint port;
  858. X{
  859. X    int sock;
  860. X    struct sockaddr_in sin;
  861. X    struct hostent *hp;
  862. X
  863. X    hp = gethostbyname (host);
  864. X    if (!hp) return -1;
  865. X
  866. X    bzero ((char *) &sin, sizeof (sin));
  867. X    bcopy (hp->h_addr, (char *) &(sin.sin_addr), hp->h_length);
  868. X    sin.sin_family = hp->h_addrtype;
  869. X    sin.sin_port = port;
  870. X
  871. X    sock = socket (AF_INET, SOCK_STREAM, 0);
  872. X    if (sock < 0) return -1;
  873. X
  874. X    if (connect (sock, (char *) &sin, sizeof (sin)) < 0) return -1;
  875. X
  876. X    return sock;
  877. X}
  878. X#endif
  879. X
  880. //E*O*F net.c//
  881.  
  882. echo x - net.h
  883. sed -e 's/^X//' > "net.h" << '//E*O*F net.h//'
  884. X/*
  885. X * Mandel by Rob Swiston and Chuck Simmons
  886. X * Copyright (C) 1989, 1990 by Rob Swiston and Chuck Simmons
  887. X *
  888. X * This program is free software; you can redistribute it and/or modify
  889. X * it under the terms of version 1 of the GNU General Public License as
  890. X * published by the Free Software Foundation.
  891. X *
  892. X * This program is distributed in the hope that it will be useful,
  893. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  894. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  895. X * GNU General Public License for more details.
  896. X *
  897. X * You should have received a copy of the GNU General Public License
  898. X * along with this program; if not, write to the Free Software
  899. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  900. X */
  901. X
  902. X/*
  903. X * Definitions needed when using the 'net' package.
  904. X */
  905. X
  906. X/* Client routine to initiate an asynchronous rpc. */
  907. Xint net_csend (/*_ int sock, double x_start, double y_start,
  908. X            double x_end, int npixels, int max_color _*/);
  909. X
  910. X/* Client routine to get result of an asynchronous rpc. */
  911. Xint net_crecv (/*_ int sock, color_x_t *buf _*/);
  912. X
  913. X/* Client routine to open a connection. */
  914. Xint net_copen (/*_ char *host, int port _*/);
  915. X
  916. X/* Server routine to handle requests and respond. */
  917. Xvoid net_server (/*_ int sock _*/);
  918. X
  919. X/* Server routine to listen for a client and fork. */
  920. Xint net_slisten (/*_ int port _*/);
  921. X
  922. //E*O*F net.h//
  923.  
  924. echo x - client.h
  925. sed -e 's/^X//' > "client.h" << '//E*O*F client.h//'
  926. X/*
  927. X * Mandel by Rob Swiston and Chuck Simmons
  928. X * Copyright (C) 1989, 1990 by Rob Swiston and Chuck Simmons
  929. X *
  930. X * This program is free software; you can redistribute it and/or modify
  931. X * it under the terms of version 1 of the GNU General Public License as
  932. X * published by the Free Software Foundation.
  933. X *
  934. X * This program is distributed in the hope that it will be useful,
  935. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  936. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  937. X * GNU General Public License for more details.
  938. X *
  939. X * You should have received a copy of the GNU General Public License
  940. X * along with this program; if not, write to the Free Software
  941. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  942. X */
  943. X
  944. X/*
  945. X * Definitions for calling client routines.
  946. X */
  947. X
  948. Xchar *client_init (/* win_info_t *winp */);
  949. Xint   client_reset (/* char *clientp, win_info_t *winp */);
  950. Xint   client_resume (/* char *clientp, win_info_t *winp */);
  951. X
  952. //E*O*F client.h//
  953.  
  954. echo x - colormap.data
  955. sed -e 's/^X//' > "colormap.data" << '//E*O*F colormap.data//'
  956. X#bf0000 ; 0.000000 1.000000 0.375000
  957. X#cc0000 ; 0.000000 1.000000 0.400000
  958. X#d90000 ; 0.000000 1.000000 0.425000
  959. X#e60000 ; 0.000000 1.000000 0.450000
  960. X#f20000 ; 0.000000 1.000000 0.475000
  961. X#ff0000 ; 0.000000 1.000000 0.500000
  962. X#ff1a1a ; 0.000000 1.000000 0.550000
  963. X#ff2e2e ; 0.000000 1.000000 0.590000
  964. X#ff4242 ; 0.000000 1.000000 0.630000
  965. X#ff5757 ; 0.000000 1.000000 0.670000
  966. X#ff6b6b ; 0.000000 1.000000 0.710000
  967. X#ff8080 ; 0.000000 1.000000 0.750000
  968. X#ff8c8c ; 0.000000 1.000000 0.775000
  969. X#ff9999 ; 0.000000 1.000000 0.800000
  970. X#ffa6a6 ; 0.000000 1.000000 0.825000
  971. X#ffcba6 ; 0.070000 1.000000 0.825000
  972. X#ffc499 ; 0.070000 1.000000 0.800000
  973. X#ffbc8c ; 0.070000 1.000000 0.775000
  974. X#ffb580 ; 0.070000 1.000000 0.750000
  975. X#ffa96b ; 0.070000 1.000000 0.710000
  976. X#ff9d57 ; 0.070000 1.000000 0.670000
  977. X#ff9242 ; 0.070000 1.000000 0.630000
  978. X#ff862e ; 0.070000 1.000000 0.590000
  979. X#ff7a1a ; 0.070000 1.000000 0.550000
  980. X#ff6b00 ; 0.070000 1.000000 0.500000
  981. X#f26600 ; 0.070000 1.000000 0.475000
  982. X#e66000 ; 0.070000 1.000000 0.450000
  983. X#d95b00 ; 0.070000 1.000000 0.425000
  984. X#cc5600 ; 0.070000 1.000000 0.400000
  985. X#bf5000 ; 0.070000 1.000000 0.375000
  986. X#bf7e00 ; 0.110000 1.000000 0.375000
  987. X#cc8700 ; 0.110000 1.000000 0.400000
  988. X#d98f00 ; 0.110000 1.000000 0.425000
  989. X#e69700 ; 0.110000 1.000000 0.450000
  990. X#f2a000 ; 0.110000 1.000000 0.475000
  991. X#ffa800 ; 0.110000 1.000000 0.500000
  992. X#ffb11a ; 0.110000 1.000000 0.550000
  993. X#ffb82e ; 0.110000 1.000000 0.590000
  994. X#ffbf42 ; 0.110000 1.000000 0.630000
  995. X#ffc657 ; 0.110000 1.000000 0.670000
  996. X#ffcd6b ; 0.110000 1.000000 0.710000
  997. X#ffd480 ; 0.110000 1.000000 0.750000
  998. X#ffd88c ; 0.110000 1.000000 0.775000
  999. X#ffdc99 ; 0.110000 1.000000 0.800000
  1000. X#ffe1a6 ; 0.110000 1.000000 0.825000
  1001. X#fff1a6 ; 0.140000 1.000000 0.825000
  1002. X#ffef99 ; 0.140000 1.000000 0.800000
  1003. X#ffed8c ; 0.140000 1.000000 0.775000
  1004. X#ffeb80 ; 0.140000 1.000000 0.750000
  1005. X#ffe76b ; 0.140000 1.000000 0.710000
  1006. X#ffe457 ; 0.140000 1.000000 0.670000
  1007. X#ffe142 ; 0.140000 1.000000 0.630000
  1008. X#ffde2e ; 0.140000 1.000000 0.590000
  1009. X#ffda1a ; 0.140000 1.000000 0.550000
  1010. X#ffd600 ; 0.140000 1.000000 0.500000
  1011. X#f2cb00 ; 0.140000 1.000000 0.475000
  1012. X#e6c100 ; 0.140000 1.000000 0.450000
  1013. X#d9b600 ; 0.140000 1.000000 0.425000
  1014. X#ccab00 ; 0.140000 1.000000 0.400000
  1015. X#bfa100 ; 0.140000 1.000000 0.375000
  1016. X#b0bf00 ; 0.180000 1.000000 0.375000
  1017. X#bccc00 ; 0.180000 1.000000 0.400000
  1018. X#c7d900 ; 0.180000 1.000000 0.425000
  1019. X#d3e600 ; 0.180000 1.000000 0.450000
  1020. X#dff200 ; 0.180000 1.000000 0.475000
  1021. X#ebff00 ; 0.180000 1.000000 0.500000
  1022. X#edff1a ; 0.180000 1.000000 0.550000
  1023. X#eeff2e ; 0.180000 1.000000 0.590000
  1024. X#f0ff42 ; 0.180000 1.000000 0.630000
  1025. X#f2ff57 ; 0.180000 1.000000 0.670000
  1026. X#f3ff6b ; 0.180000 1.000000 0.710000
  1027. X#f5ff80 ; 0.180000 1.000000 0.750000
  1028. X#f6ff8c ; 0.180000 1.000000 0.775000
  1029. X#f7ff99 ; 0.180000 1.000000 0.800000
  1030. X#f8ffa6 ; 0.180000 1.000000 0.825000
  1031. X#ddffa6 ; 0.230000 1.000000 0.825000
  1032. X#d8ff99 ; 0.230000 1.000000 0.800000
  1033. X#d3ff8c ; 0.230000 1.000000 0.775000
  1034. X#cfff80 ; 0.230000 1.000000 0.750000
  1035. X#c7ff6b ; 0.230000 1.000000 0.710000
  1036. X#bfff57 ; 0.230000 1.000000 0.670000
  1037. X#b7ff42 ; 0.230000 1.000000 0.630000
  1038. X#b0ff2e ; 0.230000 1.000000 0.590000
  1039. X#a8ff1a ; 0.230000 1.000000 0.550000
  1040. X#9eff00 ; 0.230000 1.000000 0.500000
  1041. X#96f200 ; 0.230000 1.000000 0.475000
  1042. X#8ee600 ; 0.230000 1.000000 0.450000
  1043. X#86d900 ; 0.230000 1.000000 0.425000
  1044. X#7ecc00 ; 0.230000 1.000000 0.400000
  1045. X#77bf00 ; 0.230000 1.000000 0.375000
  1046. X#04bf00 ; 0.330000 1.000000 0.375000
  1047. X#04cc00 ; 0.330000 1.000000 0.400000
  1048. X#04d900 ; 0.330000 1.000000 0.425000
  1049. X#05e600 ; 0.330000 1.000000 0.450000
  1050. X#05f200 ; 0.330000 1.000000 0.475000
  1051. X#05ff00 ; 0.330000 1.000000 0.500000
  1052. X#1eff1a ; 0.330000 1.000000 0.550000
  1053. X#32ff2e ; 0.330000 1.000000 0.590000
  1054. X#46ff42 ; 0.330000 1.000000 0.630000
  1055. X#5aff57 ; 0.330000 1.000000 0.670000
  1056. X#6eff6b ; 0.330000 1.000000 0.710000
  1057. X#82ff80 ; 0.330000 1.000000 0.750000
  1058. X#8fff8c ; 0.330000 1.000000 0.775000
  1059. X#9bff99 ; 0.330000 1.000000 0.800000
  1060. X#a8ffa6 ; 0.330000 1.000000 0.825000
  1061. X#a6ffe4 ; 0.450000 1.000000 0.825000
  1062. X#99ffe0 ; 0.450000 1.000000 0.800000
  1063. X#8cffdd ; 0.450000 1.000000 0.775000
  1064. X#80ffd9 ; 0.450000 1.000000 0.750000
  1065. X#6bffd3 ; 0.450000 1.000000 0.710000
  1066. X#57ffcd ; 0.450000 1.000000 0.670000
  1067. X#42ffc6 ; 0.450000 1.000000 0.630000
  1068. X#2effc0 ; 0.450000 1.000000 0.590000
  1069. X#1affba ; 0.450000 1.000000 0.550000
  1070. X#00ffb3 ; 0.450000 1.000000 0.500000
  1071. X#00f2aa ; 0.450000 1.000000 0.475000
  1072. X#00e6a1 ; 0.450000 1.000000 0.450000
  1073. X#00d998 ; 0.450000 1.000000 0.425000
  1074. X#00cc8f ; 0.450000 1.000000 0.400000
  1075. X#00bf86 ; 0.450000 1.000000 0.375000
  1076. X#00a8bf ; 0.520000 1.000000 0.375000
  1077. X#00b4cc ; 0.520000 1.000000 0.400000
  1078. X#00bfd9 ; 0.520000 1.000000 0.425000
  1079. X#00cae6 ; 0.520000 1.000000 0.450000
  1080. X#00d5f2 ; 0.520000 1.000000 0.475000
  1081. X#00e0ff ; 0.520000 1.000000 0.500000
  1082. X#1ae3ff ; 0.520000 1.000000 0.550000
  1083. X#2ee6ff ; 0.520000 1.000000 0.590000
  1084. X#42e8ff ; 0.520000 1.000000 0.630000
  1085. X#57ebff ; 0.520000 1.000000 0.670000
  1086. X#6bedff ; 0.520000 1.000000 0.710000
  1087. X#80f0ff ; 0.520000 1.000000 0.750000
  1088. X#8cf1ff ; 0.520000 1.000000 0.775000
  1089. X#99f3ff ; 0.520000 1.000000 0.800000
  1090. X#a6f4ff ; 0.520000 1.000000 0.825000
  1091. X#a6d4ff ; 0.580000 1.000000 0.825000
  1092. X#99ceff ; 0.580000 1.000000 0.800000
  1093. X#8cc8ff ; 0.580000 1.000000 0.775000
  1094. X#80c2ff ; 0.580000 1.000000 0.750000
  1095. X#6bb8ff ; 0.580000 1.000000 0.710000
  1096. X#57aeff ; 0.580000 1.000000 0.670000
  1097. X#42a4ff ; 0.580000 1.000000 0.630000
  1098. X#2e9bff ; 0.580000 1.000000 0.590000
  1099. X#1a91ff ; 0.580000 1.000000 0.550000
  1100. X#0085ff ; 0.580000 1.000000 0.500000
  1101. X#007ef2 ; 0.580000 1.000000 0.475000
  1102. X#0077e6 ; 0.580000 1.000000 0.450000
  1103. X#0071d9 ; 0.580000 1.000000 0.425000
  1104. X#006acc ; 0.580000 1.000000 0.400000
  1105. X#0063bf ; 0.580000 1.000000 0.375000
  1106. X#0008bf ; 0.660000 1.000000 0.375000
  1107. X#0008cc ; 0.660000 1.000000 0.400000
  1108. X#0009d9 ; 0.660000 1.000000 0.425000
  1109. X#0009e6 ; 0.660000 1.000000 0.450000
  1110. X#000af2 ; 0.660000 1.000000 0.475000
  1111. X#000aff ; 0.660000 1.000000 0.500000
  1112. X#1a23ff ; 0.660000 1.000000 0.550000
  1113. X#2e36ff ; 0.660000 1.000000 0.590000
  1114. X#424aff ; 0.660000 1.000000 0.630000
  1115. X#575dff ; 0.660000 1.000000 0.670000
  1116. X#6b71ff ; 0.660000 1.000000 0.710000
  1117. X#8085ff ; 0.660000 1.000000 0.750000
  1118. X#8c91ff ; 0.660000 1.000000 0.775000
  1119. X#999dff ; 0.660000 1.000000 0.800000
  1120. X#a6a9ff ; 0.660000 1.000000 0.825000
  1121. X#d2a6ff ; 0.750000 1.000000 0.825000
  1122. X#cc99ff ; 0.750000 1.000000 0.800000
  1123. X#c68cff ; 0.750000 1.000000 0.775000
  1124. X#bf80ff ; 0.750000 1.000000 0.750000
  1125. X#b56bff ; 0.750000 1.000000 0.710000
  1126. X#ab57ff ; 0.750000 1.000000 0.670000
  1127. X#a142ff ; 0.750000 1.000000 0.630000
  1128. X#962eff ; 0.750000 1.000000 0.590000
  1129. X#8c1aff ; 0.750000 1.000000 0.550000
  1130. X#8000ff ; 0.750000 1.000000 0.500000
  1131. X#7900f2 ; 0.750000 1.000000 0.475000
  1132. X#7300e6 ; 0.750000 1.000000 0.450000
  1133. X#6c00d9 ; 0.750000 1.000000 0.425000
  1134. X#6600cc ; 0.750000 1.000000 0.400000
  1135. X#6000bf ; 0.750000 1.000000 0.375000
  1136. X#9900bf ; 0.800000 1.000000 0.375000
  1137. X#a300cc ; 0.800000 1.000000 0.400000
  1138. X#ad00d9 ; 0.800000 1.000000 0.425000
  1139. X#b800e6 ; 0.800000 1.000000 0.450000
  1140. X#c200f2 ; 0.800000 1.000000 0.475000
  1141. X#cc00ff ; 0.800000 1.000000 0.500000
  1142. X#d11aff ; 0.800000 1.000000 0.550000
  1143. X#d52eff ; 0.800000 1.000000 0.590000
  1144. X#d942ff ; 0.800000 1.000000 0.630000
  1145. X#dd57ff ; 0.800000 1.000000 0.670000
  1146. X#e16bff ; 0.800000 1.000000 0.710000
  1147. X#e680ff ; 0.800000 1.000000 0.750000
  1148. X#e88cff ; 0.800000 1.000000 0.775000
  1149. X#eb99ff ; 0.800000 1.000000 0.800000
  1150. X#eda6ff ; 0.800000 1.000000 0.825000
  1151. X#ffa6fb ; 0.840000 1.000000 0.825000
  1152. X#ff99fb ; 0.840000 1.000000 0.800000
  1153. X#ff8cfa ; 0.840000 1.000000 0.775000
  1154. X#ff80fa ; 0.840000 1.000000 0.750000
  1155. X#ff6bf9 ; 0.840000 1.000000 0.710000
  1156. X#ff57f8 ; 0.840000 1.000000 0.670000
  1157. X#ff42f7 ; 0.840000 1.000000 0.630000
  1158. X#ff2ef7 ; 0.840000 1.000000 0.590000
  1159. X#ff1af6 ; 0.840000 1.000000 0.550000
  1160. X#ff00f5 ; 0.840000 1.000000 0.500000
  1161. X#f200e9 ; 0.840000 1.000000 0.475000
  1162. X#e600dc ; 0.840000 1.000000 0.450000
  1163. X#d900d0 ; 0.840000 1.000000 0.425000
  1164. X#cc00c4 ; 0.840000 1.000000 0.400000
  1165. X#bf00b8 ; 0.840000 1.000000 0.375000
  1166. X#bf007e ; 0.890000 1.000000 0.375000
  1167. X#cc0087 ; 0.890000 1.000000 0.400000
  1168. X#d9008f ; 0.890000 1.000000 0.425000
  1169. X#e60097 ; 0.890000 1.000000 0.450000
  1170. X#f200a0 ; 0.890000 1.000000 0.475000
  1171. X#ff00a8 ; 0.890000 1.000000 0.500000
  1172. X#ff1ab1 ; 0.890000 1.000000 0.550000
  1173. X#ff2eb8 ; 0.890000 1.000000 0.590000
  1174. X#ff42bf ; 0.890000 1.000000 0.630000
  1175. X#ff57c6 ; 0.890000 1.000000 0.670000
  1176. X#ff6bcd ; 0.890000 1.000000 0.710000
  1177. X#ff80d4 ; 0.890000 1.000000 0.750000
  1178. X#ff8cd8 ; 0.890000 1.000000 0.775000
  1179. X#ff99dc ; 0.890000 1.000000 0.800000
  1180. X#ffa6e1 ; 0.890000 1.000000 0.825000
  1181. X#ffa6c6 ; 0.940000 1.000000 0.825000
  1182. X#ff99be ; 0.940000 1.000000 0.800000
  1183. X#ff8cb6 ; 0.940000 1.000000 0.775000
  1184. X#ff80ad ; 0.940000 1.000000 0.750000
  1185. X#ff6ba0 ; 0.940000 1.000000 0.710000
  1186. X#ff5793 ; 0.940000 1.000000 0.670000
  1187. X#ff4286 ; 0.940000 1.000000 0.630000
  1188. X#ff2e79 ; 0.940000 1.000000 0.590000
  1189. X#ff1a6c ; 0.940000 1.000000 0.550000
  1190. X#ff005c ; 0.940000 1.000000 0.500000
  1191. X#f20057 ; 0.940000 1.000000 0.475000
  1192. X#e60053 ; 0.940000 1.000000 0.450000
  1193. X#d9004e ; 0.940000 1.000000 0.425000
  1194. X#cc0049 ; 0.940000 1.000000 0.400000
  1195. X#bf0045 ; 0.940000 1.000000 0.375000
  1196. //E*O*F colormap.data//
  1197.  
  1198. echo x - compute.c
  1199. sed -e 's/^X//' > "compute.c" << '//E*O*F compute.c//'
  1200. X/*
  1201. X * Mandel by Rob Swiston and Chuck Simmons
  1202. X * Copyright (C) 1989, 1990 by Rob Swiston and Chuck Simmons
  1203. X *
  1204. X * This program is free software; you can redistribute it and/or modify
  1205. X * it under the terms of version 1 of the GNU General Public License as
  1206. X * published by the Free Software Foundation.
  1207. X *
  1208. X * This program is distributed in the hope that it will be useful,
  1209. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1210. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1211. X * GNU General Public License for more details.
  1212. X *
  1213. X * You should have received a copy of the GNU General Public License
  1214. X * along with this program; if not, write to the Free Software
  1215. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1216. X */
  1217. X
  1218. X/*
  1219. X * This file contains the code to perform mandelbrot calculations.
  1220. X * We are given a description of the line segment on the real plane
  1221. X * and the number of pixels that will be used to display that line
  1222. X * segment.  For each pixel, we compute a color to be used for drawing
  1223. X * that segment.  The resulting pixels are run-length encoded and
  1224. X * stored into a passed buffer.
  1225. X */
  1226. X
  1227. X#include "mandel.h"
  1228. X
  1229. X/* Return the number of elements we put in the buffer. */
  1230. X
  1231. Xint
  1232. Xmandel_line (x_start, y_start, x_end, npixels, max_color, buf)
  1233. Xdouble x_start, y_start; /* starting co-ordinates of line segment */
  1234. Xdouble x_end; /* ending co-ordinate of line segment */
  1235. Xint npixels; /* number of pixels to compute */
  1236. Xint max_color; /* maximum color we should use */
  1237. Xcolor_x_t *buf; /* output -- buffer of 'npixels' elements that we fill */
  1238. X{
  1239. X    double x, x_inc;
  1240. X    int buflen;
  1241. X    int i, color, old_color;
  1242. X
  1243. X    buflen = 0; /* nothing in buffer yet */
  1244. X    x = x_start;
  1245. X    x_inc = (x_end - x_start) / (double) npixels;
  1246. X    for (i = 0; i < npixels; i++) {
  1247. X        color = get_color (x, y_start, max_color);
  1248. X
  1249. X        if (i == 0) old_color = color;
  1250. X        else if (color != old_color) {
  1251. X            buf[buflen].x = i-1;
  1252. X            buf[buflen].color = old_color;
  1253. X            buflen += 1;
  1254. X            old_color = color;
  1255. X        }
  1256. X
  1257. X        x += x_inc;
  1258. X    }
  1259. X
  1260. X    /* save the last color */
  1261. X    buf[buflen].x = i-1;
  1262. X    buf[buflen].color = old_color;
  1263. X    buflen += 1;
  1264. X
  1265. X    return buflen;
  1266. X}
  1267. X
  1268. X/*
  1269. X * Given a location on a plane, perform up to N iterations on that point
  1270. X * in order to figure out whether or not the point is in the Mandelbrot
  1271. X * Set.
  1272. X *
  1273. X * We return a value in the range 0..ncolors.  If 'ncolors' is returned,
  1274. X * the point is probably in the set.  Lower values indicate how "close" the
  1275. X * point is to the set.  The lower the value, the farther away the point is.
  1276. X *
  1277. X * We loop computing "z = z*z + c", where 'c' is the initial complex
  1278. X * number 'x + i*y', and 'z' is a complex variable.  'c' is in the mandelbrot
  1279. X * set if, as N goes to infinity, the values assigned to 'z' converge.
  1280. X * Basically, if |z| > 4, then we know that the value won't converge.
  1281. X *
  1282. X * This version is written so as to encourage compilers to overlap
  1283. X * instructions and perform other optimizations. 
  1284. X */
  1285. X
  1286. X#ifndef NCUBE
  1287. Xint
  1288. Xget_color (cx, cy, ncolors)
  1289. Xregister double cx, cy;
  1290. Xregister int ncolors;
  1291. X{
  1292. X    register int i;
  1293. X    register double zx, zy, xx, xy, yy, t, xy2, four;
  1294. X
  1295. X    zx = cx;
  1296. X    zy = cy;
  1297. X    four = 4.0;
  1298. X    i = 0;
  1299. X
  1300. X    for (;;) {
  1301. X        xy = zx * zy;
  1302. X        xx = zx * zx;
  1303. X        xy2 = xy + xy;
  1304. X        yy = zy * zy;
  1305. X
  1306. X        zy = xy2 + cy;
  1307. X        t = xx + yy;
  1308. X        zx = xx - yy + cx;
  1309. X
  1310. X        if (t > four) break;
  1311. X        i += 1;
  1312. X        if (i == ncolors) break;
  1313. X    }
  1314. X
  1315. X    return i;
  1316. X}
  1317. X#endif
  1318. //E*O*F compute.c//
  1319.  
  1320. echo x - README
  1321. sed -e 's/^X//' > "README" << '//E*O*F README//'
  1322. X/*
  1323. X * Mandel by Rob Swiston and Chuck Simmons
  1324. X * Copyright (C) 1989, 1990 by Rob Swiston and Chuck Simmons
  1325. X *
  1326. X * This program is free software; you can redistribute it and/or modify
  1327. X * it under the terms of version 1 of the GNU General Public License as
  1328. X * published by the Free Software Foundation.
  1329. X *
  1330. X * This program is distributed in the hope that it will be useful,
  1331. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1332. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1333. X * GNU General Public License for more details.
  1334. X *
  1335. X * You should have received a copy of the GNU General Public License
  1336. X * along with this program; if not, write to the Free Software
  1337. X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1338. X */
  1339. X
  1340. XThis file contains all the documentation there is on this Mandelbrot program.
  1341. XIt provides porting hints and usage instructions.  If there isn't enough
  1342. Xinformation in here, you'll probably have to (*gasp*) read the source code.
  1343. X
  1344. XThis document contains the following sections:
  1345. X
  1346. X    Background     -- gives a real brief history and the motivation for
  1347. X              the structure of the program.
  1348. X
  1349. X    Porting Hints  -- talks about the program structure and gives
  1350. X              warnings about some problems that you might
  1351. X              encounter.
  1352. X
  1353. X    Installation   -- describes how to install the program with the
  1354. X              assumption that no portability problems will
  1355. X              arise.
  1356. X
  1357. X    Use            -- describes how to start up and run the program.
  1358. X
  1359. X    Options           -- briefly describes command line options to the
  1360. X              program.
  1361. X
  1362. X    Commands       -- briefly describes various mouse and keyboard
  1363. X              commands you can give to the program.
  1364. X
  1365. X
  1366. XBackground
  1367. X----------
  1368. X
  1369. XThis was one of the more interesting projects I've ever been involved in.
  1370. XIt all started when Lei Tung decided he wanted to draw pictures of the
  1371. XMandelbrot set on his HP machine.  After a week or two, Rob Swiston took
  1372. XLei's code and modified it to run over a network.  I think I then slapped
  1373. Xon an X windows interface.
  1374. X
  1375. XOne of the really nice things about working for Oracle is that they have
  1376. Xa fairly nice internal network, and they have *lots* of different kinds
  1377. Xof hardware.  We wanted a program where we could have a client running on
  1378. Xone machine which would make use of multiple compute servers running on
  1379. Xother machines.  And we wanted things to run in very heterogeneous
  1380. Xenvironments.  For the most part, I think we met these goals.
  1381. X
  1382. X
  1383. XPorting Hints
  1384. X-------------
  1385. X
  1386. XUnfortunately, it's impossible for me to verify this release of the code
  1387. Xon all the machines that it has run on in the past.  Additionally, there
  1388. Xwill probably be minor differences between your machine and my machine
  1389. Xwhich will keep things from working.  And I'll probably break something
  1390. Xwhen I package things up, if I haven't broken them already.  Hopefully,
  1391. Xthe porting process will be trivial, but if not, this section contains
  1392. Xvarious hints that may be useful.  If you find any bugs, I'll be interested
  1393. Xin hearing about them.
  1394. X
  1395. XLet's start with the program structure.  The program is fairly cleanly
  1396. Xseparated into a few different layers.  First, there's the user interface
  1397. Xlayer (gui.c).  All of the X specific code is in this layer.  In theory,
  1398. Xyou could rewrite this layer to use a different windowing system.  Next,
  1399. Xthere is the "client" layer (client.c).  This layer is responsible for
  1400. Xinitializing the network connections and subdividing the computation of
  1401. Xan image among multiple compute servers.
  1402. X
  1403. XThe next layer is the network layer (net.c).  The network layer
  1404. Xbasically implements a simple Remote Procedure Call (RPC) interface.
  1405. XCurrently, this layer uses TCP/IP as the underlying communications mechanism.
  1406. XIn theory, this layer could be rewritten to use an alternative communications
  1407. Xmechanism.  There are actually two parts to the network layer:  the
  1408. Xclient side, and the server side.  These are bundled into a single file
  1409. Xwhich leads to some wierdnesses in the makefile, but nothing real important.
  1410. X
  1411. X[For all of you out there just dying to use your NCube as a compute server,
  1412. XI have a version of the network layer that acts as a gateway between TCP/IP
  1413. Xand the NCube communications links.]
  1414. X
  1415. XFinally, there is the "compute" layer (compute.c).  This is a very simple
  1416. Xlayer where all the real work gets done.
  1417. X
  1418. XWhen you build the program, you will actually create two binaries.  One
  1419. Xbinary is the "client" program.  This program gets linked with the X libraries
  1420. Xand will need to run on a machine which can communicate with an X server.
  1421. XThe other binary is the "server" program.  This program requires TCP/IP
  1422. Xand libm.a but not much else.
  1423. X
  1424. XBecause we wanted the program to be portable and to run in a heterogeneous
  1425. Xnetwork, there are certain modifications you will need to make to the
  1426. Xmakefile, and possibly to the network layer.  When the network layer
  1427. Xtransmits data across the network, it first translates the data into
  1428. Xa network canonical format.  When reading data from the net, the data
  1429. Xis then translated into a local host format.  The network canonical format
  1430. Xis defined so as to be compatible with a Sun.  This means that integers
  1431. Xare transmitted so that they have the same byte order as on a Sun and
  1432. Xfloating point numbers are converted to IEEE representation.
  1433. X
  1434. XTransmitting the integers is real easy.  The TCP/IP package generally
  1435. Xprovides routines named 'ntohs', 'htons', etc.  [These stand for
  1436. Xnetwork-to-host-short and host-to-network-short.]  Floating point numbers
  1437. Xare somewhat more complex.  While it is rare to find a machine that
  1438. Xdoes not have 8-bit bytes, 16-bit words, 32-bit long words, etc; it
  1439. Xis fairly common to find machines that don't use IEEE floating point.
  1440. XTherefore, the network layer contains some routines that attempt to
  1441. Xperform conversions from certain types of formats to certain other types.
  1442. X
  1443. XWhat does the above mean to you as a porter?  First, if you are on
  1444. Xa machine that has the same byte order as the VAX, 80x86, NCube, or
  1445. XDecStation 3100, then you must define -DVAX_BYTE_ORDER when compiling
  1446. Xcode to run on that machine.  This will cause the network layer to
  1447. Xcorrectly convert integers when transmitting across the network.
  1448. X
  1449. XNext, you may need to define a flag to describe the floating point
  1450. Xformat of your machine.  Even worse, you may need to implement a
  1451. Xfloating point conversion routine.  The following flags currently exist:
  1452. X
  1453. X    -DCONVEX should be defined if you are runnong on the Convex
  1454. X    machine.  This was actually tested at one point.
  1455. X
  1456. X    -DIS_370 should be defined if you are running on an IBM 370
  1457. X    compatible machine such as an Amdahl 5990.  (Other IBM 370
  1458. X    machines probably don't have sufficient compute power for this
  1459. X    extremely demanding application. :-)  Now, I went off and wrote
  1460. X    code to perform floating point conversions between IBM 370
  1461. X    format and IEEE format, but...  I NEVER TESTED THE CODE!!!
  1462. X    I can virtually guarantee that it won't work.  But if you get
  1463. X    it working, I'd be interested in any changes you make.
  1464. X
  1465. XIf you are on some other type of non-IEEE machine, you'll need to
  1466. Xdefine your own floating point conversion routines in net.c.  [Also,
  1467. Xif you don't care about heterogeneous networks, then you can just
  1468. Xpretend you are on an IEEE type of machine.]
  1469. X
  1470. XOne problem cropped up when I ported the code to the Pyramid.  The
  1471. Xstructures that I use for passing information across the network were
  1472. Xpadded by the Pyramid compiler in strange and wonderful ways.  I just
  1473. Xadded the extra padding to my structure.  However, if you are on some
  1474. Xstrange machine, you may run into a similar problem.  If so, do whatever
  1475. Xyou think is best to fix the problem.
  1476. X
  1477. XOh yeah...  Color...  This program is designed to use color.  There are
  1478. Xactually hooks sitting around that allow you to run the program on a
  1479. Xblack and white terminal, but it's not as visually exciting.  We got
  1480. Xlucky on one Sun sparcstation and the colormap happened to be initialized
  1481. Xto reasonable values, and we got a recognizable black and white image.
  1482. XOn my Sparcstation we didn't get so lucky and we got a big black image.
  1483. XTweak the code in 'gui.c' or find an X guru to help you tweak the code.
  1484. X
  1485. X
  1486. XInstallation
  1487. X------------
  1488. X
  1489. X1)  Unpack the sources.  Presumably you have saved the sources in
  1490. Xsome file, say 'mandel.shar'.  Type
  1491. X
  1492. X    sh mandel.shar
  1493. X
  1494. XThis should leave a bunch of files lying around in your current directory.
  1495. X
  1496. X2)  Edit the makefile, "mandel.mk".
  1497. X
  1498. X    2a)  If you are on a machine that has the same byte
  1499. X    order as a Vax, 80x86, NCube, or DecStation 3100, then uncomment the line
  1500. X    that contains "-DVAX_BYTE_ORDER".
  1501. X
  1502. X    2b)  If you are on a Convex, uncomment the line that contains "-DCONVEX".
  1503. X
  1504. X    If you are on a 370 compatible machine, uncomment the line that contains
  1505. X    "-DIS_370", and then go read the porting notes above if you haven't
  1506. X    already done so.
  1507. X
  1508. X3)  Run the makefile.  Type
  1509. X
  1510. X    make -f mandel.mk
  1511. X
  1512. XThis should create a binary named 'mandel' and a binary named 'mserver'.
  1513. XIf any problems arise, fix them as you see fit.  The porting notes above
  1514. Xmight be useful.
  1515. X
  1516. X
  1517. XUse
  1518. X---
  1519. X
  1520. XThe user interface is not real wonderful.  First, let's talk about starting
  1521. Xup the program.
  1522. X
  1523. X1)  Edit the file named 'hostfile'.  [Note that this must be contained
  1524. Xin the directory from which you plan on running the mandelbrot program.
  1525. XSounds like a bug to me, too.]  This file needs to contain a list of
  1526. X"listener" processes.  This file contains a number of lines that look like:
  1527. X
  1528. X    fred 9993 4
  1529. X
  1530. XThe first word is the name of a machine on which you will run a compute
  1531. Xserver.  The next number is the TCP/IP socket address on which the compute
  1532. Xserver will listen for connections.  The final number is the number of
  1533. Xserver processes that the client should attempt to use on this machine.
  1534. XTypically, this number is equal to the number of processors available on
  1535. Xthat machine.  There will be examples below.
  1536. X
  1537. X2)  Generate an 'mserver' binary for each machine on which you plan on
  1538. Xrunning a compute server.  This will require probably require editing the
  1539. Xmakefile if you're really going to use more than one type of machine.  It's
  1540. Xsomething of a pain, but relatively easy.
  1541. X
  1542. X3)  Copy an appropriate 'mserver' binary to each machine on which you
  1543. Xwant to run a compute server.
  1544. X
  1545. X4)  Start up 'mserver' on each machine where you want to run a compute
  1546. Xserver.  Give a command like:
  1547. X
  1548. X    mserver 9993 &
  1549. X
  1550. XThis tells the server the port on which it should listen for connections
  1551. Xand puts the process in the background.
  1552. X
  1553. X5)  Go to the machine on which you want to run the client.  Make sure
  1554. Xyour DISPLAY environment variable is set correctly and that you are
  1555. X'xhost'ed on the machine which is running the X-Server for your display.
  1556. XGive the command "mandel".  [There are numerous options here which will
  1557. Xbe discussed below.]
  1558. X
  1559. X
  1560. XExample 1
  1561. X---------
  1562. X
  1563. XLet's suppose you want to do something real simple.  You have a workstation
  1564. Xnamed 'fred'.  You want to run both the client and the server on this
  1565. Xworkstation, with display output going to the workstation's screen.
  1566. X
  1567. X1)  If your DISPLAY variable is not set, set it.  Under the c-shell, this
  1568. Xwould look like:
  1569. X
  1570. X    setenv DISPLAY :0
  1571. X
  1572. X(or somesuch).
  1573. X
  1574. X2)  Edit the 'hostfile' to contain the line:
  1575. X
  1576. X    fred 9993 1
  1577. X
  1578. X3)  Start up the server listener process:
  1579. X
  1580. X    mserver 9993 &
  1581. X
  1582. X4)  Start up the mandelbrot program:
  1583. X
  1584. X    mandel
  1585. X
  1586. XAt this point, if all goes well, a window should appear on your
  1587. Xscreen and it should begin to fill with colors, and hopefully a
  1588. Xrecognizable mandelbrot set will form.
  1589. X
  1590. X
  1591. XExample 2
  1592. X---------
  1593. X
  1594. XLet's suppose it's the middle of the night and you talked some of
  1595. Xyour co-workers into lending you the use of their workstation's cpu's.
  1596. XYou have a dumb X terminal (but a dumb *color* X terminal), so you want
  1597. Xto run your client on the local fileserver.  So you will run programs
  1598. Xon the following machines:
  1599. X
  1600. X    fred -- a Sparcstation
  1601. X    mary -- a Sparcstation
  1602. X    jane -- a 4 processor Apollo DN10000
  1603. X    fs   -- a Sun 4 fileserver
  1604. X
  1605. X1)  Build the mandelbrot programs using the installation instructions above.
  1606. X
  1607. X2)  Install the mandelbrot program on 'jane' (the Apollo machine) and just
  1608. Xbuild the 'mserver'.  (That way you don't have to worry about having X lying
  1609. Xaround.)
  1610. X
  1611. X3)  Edit the 'hostfile' in one of your Sparcstation filesystems so it
  1612. Xlooks like:
  1613. X
  1614. X    fred 9993 1
  1615. X    mary 9993 1
  1616. X    jane 9993 4
  1617. X
  1618. X4)  On 'jane' (the Apollo), run the listener process:
  1619. X
  1620. X    mserver 9993 &
  1621. X
  1622. X5)  On each of 'fred' and 'mary' (the Sparcstations) run the listener process:
  1623. X
  1624. X    mserver 9993 &
  1625. X
  1626. X6)  On 'fs' (the fileserver) make sure your DISPLAY environment variable
  1627. Xis set correctly.  If necessary, tell your X terminal to 'xhost fs'.  Make
  1628. Xsure you are in the directory which contains the 'hostfile'.
  1629. X
  1630. X7)  Run the mandelbrot program:
  1631. X
  1632. X    mandel
  1633. X
  1634. X
  1635. XOptions
  1636. X-------
  1637. X
  1638. XWe tried to give 'mandel' as many options as 'ls'.  But this is
  1639. Xdifficult to do.  Here is a brief description of each of the options:
  1640. X
  1641. X    -help
  1642. X
  1643. X        This isn't really an option, but it will generate
  1644. X        an error message and cause the program to print out
  1645. X        a list of available options.
  1646. X
  1647. X    -c colorfile
  1648. X
  1649. X        I've shipped the mandelbrot program with a file named
  1650. X        'colormap.data'.  You can create your own colormap file.
  1651. X        Basically, this file contains the list of colors to
  1652. X        which the colormap should be initialized.  'colormap.data'
  1653. X        contains a list of colors that I particularly like.
  1654. X
  1655. X    -d host:display
  1656. X
  1657. X        If you haven't set your DISPLAY environment variable,
  1658. X        this argument should allow you to specify the same information.
  1659. X        I never use it, so maybe it doesn't work.
  1660. X
  1661. X    -g geometry
  1662. X
  1663. X        This specifies the geometry of the initial window to
  1664. X        create.  I believe the argument is in standard X syntax.
  1665. X        Again, I probably never use this option, so it might not
  1666. X        work.
  1667. X
  1668. X    -i count
  1669. X
  1670. X        This specifies the number of iterations that a compute
  1671. X        server will perform on a pixel before deciding that the
  1672. X        pixel is not in the mandelbrot set.  The larger the
  1673. X        value, the slower the program runs.  The network interface
  1674. X        imposes a limit of 32K on this value, and the program will
  1675. X        probably break silently if this value is exceeded.
  1676. X
  1677. X    -m mud_max
  1678. X    -n mud_num
  1679. X
  1680. X        These two variables provide another mechanism for
  1681. X        initializing the colormap.  I haven't used these since
  1682. X        I implemented the '-c' option above.  Experiment with
  1683. X        these if you want.  The arguments are relatively small
  1684. X        integers.  Something like "-m 10 -n 3" might be reasonable.
  1685. X
  1686. X    -p pixel_size
  1687. X
  1688. X        Basically, this specifies how much of the set you want
  1689. X        to appear in your window.  The argument should be a
  1690. X        real number less than 1.0.  Experiment with this if you
  1691. X        want, but it isn't all that useful.  (See -x and -y below.)
  1692. X
  1693. X    -r
  1694. X
  1695. X        This causes the program to use the root window as
  1696. X        its output window.  When this option is given, the
  1697. X        user interface is disabled and the program will
  1698. X        move around in the set selecting locations it wants
  1699. X        to look at.  Mildly interesting, but needs additional
  1700. X        work to select fun places to look at.
  1701. X
  1702. X    -s show_time
  1703. X
  1704. X        This causes the initial color map to be displayed on
  1705. X        your screen.  'show_time' specifies a sleep interval.
  1706. X        30 is a reasonable value.  This is primarily useful
  1707. X        for debugging a colormap file.
  1708. X
  1709. X    -x x
  1710. X    -y y
  1711. X
  1712. X        These two options are used to set the initial co-ordinates
  1713. X        of the screen.  These are only useful if you know the
  1714. X        co-ordinates of an area you want to look at.  Typically,
  1715. X        the -p option is used in conjunction with these two options.
  1716. X
  1717. XThe only options that I really use are "-i", "-c", and "-r".  I recommend:
  1718. X
  1719. X    mandel -c colormap.data -i 1000
  1720. X
  1721. Xfor starters.
  1722. X
  1723. X
  1724. XCommands
  1725. X--------
  1726. X
  1727. XOnce you've gotten mandelbrot up and running, you can give commands
  1728. Xto the user interface.  Commands are as follows:
  1729. X
  1730. X    resize the window
  1731. X
  1732. X        This is generally done by grabbing a handle on the
  1733. X        upper-right corner of the window and stretching the
  1734. X        window to be the desired shape.
  1735. X
  1736. X    click and drag
  1737. X
  1738. X        You can select a rectangular area of your window and
  1739. X        have that area of the screen blown up.  (er, expanded).
  1740. X        To do this, move the mouse to one corner of the rectangle.
  1741. X
  1742. X        Press and hold down a mouse buton.  (I always use the
  1743. X        left mouse button, but the code looks as if it will
  1744. X        work for any mouse button.)
  1745. X
  1746. X        Drag the mouse to the diagonally opposite corner of the
  1747. X        rectangle.  (While you are doing this, the program is
  1748. X        supposed to be drawing an outline around the box that
  1749. X        you are moving.  However, when I wrote the code, I didn't
  1750. X        understand the way the various bitblt operations worked
  1751. X        in X, and I screwed this up.  So you probably won't see
  1752. X        the box displayed on the screen.)
  1753. X
  1754. X        Release the mouse button.
  1755. X
  1756. X        At this point, a new window will be created which has
  1757. X        the shape of the rectangle you selected, but which has
  1758. X        the same area as the original window.  The contents of
  1759. X        the original window that lie within the selected rectangle
  1760. X        will expand to fill the new window.
  1761. X
  1762. X    'q'
  1763. X
  1764. X        Typing "q" in the window will quit the program.
  1765. X
  1766. X    'z'
  1767. X
  1768. X        Typing "z" in the window will "zoom out".  The current
  1769. X        image will be redrawn in the center 1/9th of the window,
  1770. X        while the remainder of the window will be filled with
  1771. X        the surrounding area.
  1772. X
  1773. X    'e'
  1774. X
  1775. X        Expands the window.  The width and height of the current
  1776. X        window will be doubled.
  1777. X
  1778. X    's'
  1779. X        Shrinks the window.  The width and height of the current
  1780. X        window will be halved.
  1781. X
  1782. X
  1783. XChuck Simmons
  1784. Xcsimmons@oracle.oracle.com
  1785. X29 March 1989
  1786. XFoster City, California
  1787. //E*O*F README//
  1788.  
  1789. exit 0
  1790.