home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume14 / mine / part01 < prev    next >
Encoding:
Text File  |  1992-08-30  |  26.7 KB  |  1,366 lines

  1. Path: uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i032:  mine - MineSweeper for Unix, Part01/01
  5. Message-ID: <3346@master.CNA.TEK.COM>
  6. Date: 10 Aug 92 04:04:24 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1355
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Laurent.Thery@cl.cam.ac.uk (Laurent Thery)
  12. Posting-number: Volume 14, Issue 32
  13. Archive-name: mine/Part01
  14. Environment: System V curses, System V termio
  15.  
  16.     [This is a port of the VMS Minesweeper to System V Unix. The
  17.      makefile is setup for a Sun with "5include" and "5lib". Edit
  18.      to match your environment.  -br]
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 1 (of 1)."
  27. # Contents:  README MANIFEST file.c main.c makefile minesweeper.txt
  28. #   screen.c
  29. # Wrapped by billr@saab on Sun Aug  9 21:03:14 1992
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'README' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'README'\"
  33. else
  34. echo shar: Extracting \"'README'\" \(410 characters\)
  35. sed "s/^X//" >'README' <<'END_OF_FILE'
  36. XThis a version of MineSweeper that runs under Unix.
  37. X
  38. XTo compile it, update the FILE_NAME variable in the makefile
  39. Xand type
  40. X
  41. Xmake mine
  42. X
  43. XTo install it, type
  44. X
  45. Xmake install
  46. X
  47. X
  48. XHave fun !!!
  49. X
  50. X
  51. X---------------------------------------------------------------------------
  52. XThery Laurent                   email: tl@cl.cam.ac.uk
  53. X
  54. X---------------------------------------------------------------------------
  55. X
  56. X
  57. X
  58. X
  59. X
  60. X
  61. X
  62. X
  63. X
  64. X
  65. X
  66. X
  67. X
  68. X
  69. X
  70. X
  71. END_OF_FILE
  72. if test 410 -ne `wc -c <'README'`; then
  73.     echo shar: \"'README'\" unpacked with wrong size!
  74. fi
  75. # end of 'README'
  76. fi
  77. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  78.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  79. else
  80. echo shar: Extracting \"'MANIFEST'\" \(331 characters\)
  81. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  82. X   File Name        Archive #    Description
  83. X-----------------------------------------------------------
  84. X MANIFEST                   1    This shipping list
  85. X README                     1    
  86. X file.c                     1    
  87. X main.c                     1    
  88. X makefile                   1    
  89. X minesweeper.txt            1    
  90. X screen.c                   1    
  91. END_OF_FILE
  92. if test 331 -ne `wc -c <'MANIFEST'`; then
  93.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  94. fi
  95. # end of 'MANIFEST'
  96. fi
  97. if test -f 'file.c' -a "${1}" != "-c" ; then 
  98.   echo shar: Will not clobber existing file \"'file.c'\"
  99. else
  100. echo shar: Extracting \"'file.c'\" \(2363 characters\)
  101. sed "s/^X//" >'file.c' <<'END_OF_FILE'
  102. X#include <sys/types.h>
  103. X#include <sys/stat.h>
  104. X#include <fcntl.h>
  105. X#include <unistd.h>
  106. X
  107. X#define MAX_NAME 14
  108. X#define MAX_WIN    5
  109. X
  110. Xstruct score {
  111. X    short x; /* x rows */
  112. X    short y; /* y cols */
  113. X    long b;  /* bombs */
  114. X    struct w {
  115. X        char n[MAX_NAME]; /* name */
  116. X        short t; /* time */
  117. X    } s[MAX_WIN]; /* best scores */
  118. X};
  119. X
  120. X#define SCR_ENT    64
  121. X
  122. X#ifndef FILE_NAME
  123. X#define FILE_NAME    "/users/thery/jj/min/score.dat"
  124. X#endif
  125. X
  126. Xstatic struct score tbl_score[SCR_ENT];
  127. X
  128. Xf_lock();
  129. Xf_ulock();
  130. Xstruct score *find_score();
  131. X
  132. Xstruct w *
  133. Xget_score(x, y, b)
  134. Xint x;
  135. Xint y;
  136. Xint b;
  137. X{
  138. Xint fd;
  139. Xint i;
  140. Xstruct score *score;
  141. X
  142. X    f_lock();
  143. X    fd = open(FILE_NAME, O_RDONLY);
  144. X    i = read(fd, tbl_score, SCR_ENT * sizeof(struct score));
  145. X    close(fd);
  146. X    f_ulock();
  147. X    if(fd == -1 || i == -1) {
  148. X        
  149. X        return((struct w *)0);
  150. X    }
  151. X    score = find_score(x, y, b);
  152. X  return(score->s);
  153. X}
  154. X
  155. Xset_score(x, y, b, n, t)
  156. Xint x;
  157. Xint y;
  158. Xint b;
  159. Xchar *n;
  160. Xint t;
  161. X{
  162. Xint fd;
  163. Xint i, j;
  164. Xstruct score *score;
  165. X
  166. X    f_lock();
  167. X    fd = open(FILE_NAME, O_RDWR|O_CREAT, 0644);
  168. X    i = read(fd, tbl_score, SCR_ENT * sizeof(struct score));
  169. X    if(fd == -1) {
  170. X        f_ulock();
  171. X        return(0);
  172. X    }
  173. X    score = find_score(x, y, b);
  174. X    for(i = 0; i < MAX_WIN; i++) {
  175. X        if(score->s[i].t > t || score->s[i].t == 0) {
  176. X            for(j = MAX_WIN - 1; j != i; j--) {
  177. X                strncpy(score->s[j].n, score->s[j-1].n, MAX_NAME);
  178. X                score->s[j].t = score->s[j-1].t;
  179. X            }
  180. X            strncpy(score->s[j].n, n, MAX_NAME);
  181. X            score->s[j].t = t;
  182. X            break;
  183. X        }
  184. X    }
  185. X    lseek(fd, 0L, SEEK_SET);
  186. X    write(fd, tbl_score, SCR_ENT * sizeof(struct score));
  187. X    close(fd);
  188. X    f_ulock();
  189. X}
  190. X
  191. Xstruct score *
  192. Xfind_score(x, y, b)
  193. Xint x;
  194. Xint y;
  195. Xint b;
  196. X{
  197. Xint h = (x^y^b)%SCR_ENT;
  198. Xstruct score *s = &tbl_score[h];
  199. X
  200. X    do {
  201. X        if(s->x == 0) {
  202. X            s->x = x;
  203. X            s->y = y;
  204. X            s->b = b;
  205. X            return(s);
  206. X        } else if (s->x == x && s->y == y && s->b == b)
  207. X            return(s);
  208. X        if(++h == SCR_ENT)
  209. X            h = 0;
  210. X        s = &tbl_score[h];
  211. X    } while(1);
  212. X}
  213. X
  214. X#ifndef TMPNAME
  215. X#define TMPNAME "/tmp/min.lcf"
  216. X#endif
  217. X
  218. Xf_lock()
  219. X{
  220. Xint fd = open(TMPNAME, O_RDWR|O_CREAT|O_RDWR, 0644);
  221. Xstruct stat buf;
  222. Xint i;
  223. X
  224. X    while(fd == -1) {
  225. X        sleep(3);
  226. X        stat(TMPNAME, &buf);
  227. X        if(buf.st_atime < time(0) - 5) {
  228. X            fd = open(TMPNAME, O_RDONLY);
  229. X            i = -1;
  230. X            read(fd, &i, sizeof(i));
  231. X            if(kill(i, 0) == -1) {
  232. X                unlink(TMPNAME);
  233. X            }
  234. X            close(fd);
  235. X        }
  236. X        fd = open(TMPNAME, O_RDWR|O_CREAT|O_RDWR, 0644);
  237. X    }
  238. X    i = getpid();
  239. X    write(fd, &i, sizeof(i));
  240. X    close(fd);
  241. X}
  242. X
  243. Xf_ulock()
  244. X{
  245. X    unlink(TMPNAME);
  246. X}
  247. END_OF_FILE
  248. if test 2363 -ne `wc -c <'file.c'`; then
  249.     echo shar: \"'file.c'\" unpacked with wrong size!
  250. fi
  251. # end of 'file.c'
  252. fi
  253. if test -f 'main.c' -a "${1}" != "-c" ; then 
  254.   echo shar: Will not clobber existing file \"'main.c'\"
  255. else
  256. echo shar: Extracting \"'main.c'\" \(13818 characters\)
  257. sed "s/^X//" >'main.c' <<'END_OF_FILE'
  258. X#include <stdio.h>
  259. X#include <sys/types.h>
  260. X#include <sys/stat.h>
  261. X#include <errno.h>
  262. X#include <fcntl.h>
  263. X#include <termio.h>
  264. X#include <signal.h>
  265. X#include <unistd.h>
  266. X#include <sys/time.h>
  267. X#include <pwd.h>
  268. X
  269. Xstatic char copyright[] = "@(#) Copyright (c) O. Thery 1992";
  270. X
  271. X#define VERSION "1.4"
  272. X#define X_SCORE 60
  273. X#define Y_SCORE 7
  274. X
  275. Xextern int    errno;
  276. X
  277. Xchar *basename();
  278. Xchar *getenv();
  279. Xchar    *shell;
  280. X
  281. Xextern char    *logname;
  282. Xextern int logfile;
  283. X
  284. Xchar *k_lft = "h";    /* left key */
  285. Xchar *k_rgt = "l";    /* right key */
  286. Xchar *k_up = "k";    /* up key */
  287. Xchar *k_dwn = "j";    /* down key */
  288. X
  289. Xint l_lft = 1;
  290. Xint l_rgt = 1;
  291. Xint l_up = 1;
  292. Xint l_dwn = 1;
  293. X
  294. Xstatic ocount;
  295. Xstatic oremain;
  296. X
  297. X
  298. Xint found; /* Found bomds */
  299. Xint remain; /* Posed bomb */
  300. X
  301. Xint good_found;
  302. Xint max_found;
  303. X
  304. Xint best_count = 10000;
  305. Xint counter;
  306. Xint counter0;
  307. X
  308. X#define F_L 58
  309. X#define F_H 22
  310. X
  311. X#define F_X 32
  312. X#define F_Y 16
  313. X
  314. Xunsigned char field[F_L * F_H];
  315. X
  316. Xint f_x = F_X;
  317. Xint f_y = F_Y;
  318. X
  319. Xint f_x0; /* Left corner of the field */
  320. Xint f_y0;
  321. X
  322. Xint bomb;
  323. X
  324. Xint pos_x;
  325. Xint pos_y;
  326. Xint pos_n;
  327. X
  328. Xchar ibuf[128];
  329. X
  330. X#define BOOM 128
  331. X#define FLAG 64
  332. X#define DONE 32
  333. X#define MASK 31
  334. X
  335. X
  336. Xstruct termio tinit;
  337. X
  338. Xstruct w {
  339. X    char n[14];
  340. X    short t;
  341. X};
  342. X
  343. Xstruct w *score;
  344. Xstruct w *get_score();
  345. X
  346. Xmyexit(i)
  347. X{
  348. X    s_pc(0, 23, 0);
  349. X    sleep(1);
  350. X    ioctl(0, TCSETA, &tinit);
  351. X    s_term();
  352. X    if(i == 5)
  353. X        abort();
  354. X    exit(i);
  355. X}
  356. X
  357. Xsigalr()
  358. X{
  359. X    myexit(5);
  360. X}
  361. X
  362. Xmain(argc, argv)
  363. Xint    argc;
  364. Xchar    *argv[];
  365. X{
  366. X    struct fd_set ibits;
  367. X    struct timeval tim;
  368. X    int i = 0;
  369. X    int k;
  370. X
  371. X    signal(SIGALRM, sigalr);
  372. X    argc--, argv++;
  373. X    while (argc > 0) {
  374. X        switch (argv[0][0]) {
  375. X        case '-':
  376. X            if(argv[0][1] == 'n' && argv[0][2] == 0) {
  377. X                argv++;
  378. X                argc--;
  379. X                bomb = atoi(*argv);
  380. X            } else if(argv[0][1] == 'f' && argv[0][2] == 0) {
  381. X                bomb = 10;
  382. X                f_x = 8;
  383. X                f_y = 8;
  384. X            } else if(!strcmp(&argv[0][1], "score")) {
  385. X                char *n;
  386. X                int t;
  387. X                int chk;
  388. X                argv++;
  389. X                argc--;
  390. X                chk = f_x = atoi(*argv);
  391. X                argv++;
  392. X                argc--;
  393. X                chk ^= f_y = atoi(*argv);
  394. X                argv++;
  395. X                argc--;
  396. X                chk ^= bomb = atoi(*argv);
  397. X                argv++;
  398. X                argc--;
  399. X                n = *argv;
  400. X                t = 0;
  401. X                for(i = 0; n[i]; i++)
  402. X                    t += n[i]<<i;
  403. X                chk ^= t;
  404. X                argv++;
  405. X                argc--;
  406. X                chk ^= t = atoi(*argv);
  407. X                argv++;
  408. X                argc--;
  409. X                if(atoi(*argv) != chk)
  410. X                    exit(1);
  411. X                set_score(f_x, f_y, bomb, n, t);
  412. X                exit(0);
  413. X            } else
  414. X                usage();
  415. X            break;
  416. X        case '0':
  417. X        case '1':
  418. X        case '2':
  419. X        case '3':
  420. X        case '4':
  421. X        case '5':
  422. X        case '6':
  423. X        case '7':
  424. X        case '8':
  425. X        case '9':
  426. X            if(!i++) {
  427. X                k = atoi(*argv);
  428. X                if(k < 3)
  429. X                    break;
  430. X                if(k > F_L)
  431. X                    k = F_L;
  432. X                f_x = k;
  433. X            } else {
  434. X                k = atoi(*argv);
  435. X                if(k < 3)
  436. X                    break;
  437. X                if(k > F_H)
  438. X                    k = F_H;
  439. X                f_y = k;
  440. X            }
  441. X            break;
  442. X        default:
  443. X            usage();
  444. X        }
  445. X        argc--;
  446. X        argv++;
  447. X    }
  448. X
  449. X    tim.tv_sec = 0;
  450. X    tim.tv_usec = 0;
  451. X
  452. X    FD_ZERO(&ibits);
  453. X
  454. X    while(1) {
  455. X        char tmp[256];
  456. X        char c;
  457. X
  458. X        init();
  459. X        if(mloop())
  460. X            continue;
  461. X        FD_SET(0, &ibits);
  462. X        i = select(2, &ibits, (fd_set *)0, (fd_set *)0, &tim);
  463. X        if(i)
  464. X            read(0, tmp, 250);
  465. X        while(1) {
  466. X            FD_SET(0, &ibits);
  467. X            i = select(2, &ibits, (fd_set *)0, (fd_set *)0, 0);
  468. X            read(0, &c, 1);
  469. X            if(c == 'q' || c == 'Q')
  470. X                myexit(0);
  471. X            else if(c == 'n' || c == 'N')
  472. X                break;
  473. X            else if(c == 'c' || c == 'C') {
  474. X                chief();
  475. X                break;
  476. X            }
  477. X        }
  478. X    }
  479. X}
  480. X
  481. Xmloop()
  482. X{
  483. X    int i, k, rc, l = 0;
  484. X    struct fd_set ibits;
  485. X    struct timeval tim;
  486. X
  487. X    tim.tv_sec = 1;
  488. X    tim.tv_usec = 0;
  489. X
  490. X    FD_ZERO(&ibits);
  491. X
  492. X    for (; ; ) {
  493. X        FD_SET(0, &ibits);
  494. X        upd_counter();
  495. X        switch (select(2, &ibits, (fd_set *)0, (fd_set *)0, &tim)) {
  496. X        case -1:
  497. X            if (errno == EINTR)
  498. X                continue;
  499. X            myexit(1);
  500. X        case 0:
  501. X            break;
  502. X        case 1:
  503. X            rc = read(0, ibuf + l, sizeof(ibuf) - 1 - l);
  504. X            rc += l;
  505. X            l = 0;
  506. X            ibuf[rc] = 0;
  507. X            for(i = 0; i < rc;) {
  508. X                if(!strncmp(&ibuf[i], k_up, l_up))  {
  509. X                    if(pos_y) {
  510. X                        pos_y--;
  511. X                        pos_n -= f_x;
  512. X                        s_pc(f_x0 + pos_x, f_y0 + pos_y, 0);
  513. X                    }
  514. X                    i += l_up;
  515. X                } else if(!strncmp(&ibuf[i], k_dwn, l_dwn))  {
  516. X                    if(pos_y < f_y - 1) {
  517. X                        pos_y++;
  518. X                        pos_n += f_x;
  519. X                        s_pc(f_x0 + pos_x, f_y0 + pos_y, 0);
  520. X                    }
  521. X                    i += l_dwn;
  522. X                } else if(!strncmp(&ibuf[i], k_lft, l_lft))  {
  523. X                    if(pos_x) {
  524. X                        pos_x--;
  525. X                        pos_n -= 1;
  526. X                        s_pc(f_x0 + pos_x, f_y0 + pos_y, 0);
  527. X                    }
  528. X                    i += l_lft;
  529. X                } else if(!strncmp(&ibuf[i], k_rgt, l_rgt))  {
  530. X                    if(pos_x < f_x - 1) {
  531. X                        pos_x++;
  532. X                        pos_n += 1;
  533. X                        s_pc(f_x0 + pos_x, f_y0 + pos_y, 0);
  534. X                    }
  535. X                    i += l_rgt;
  536. X                } else if(ibuf[i] == 'F' || ibuf[i] == 'f') {
  537. X                    if(field[pos_n] & FLAG) {
  538. X                        s_pc(f_x0 + pos_x, f_y0 + pos_y, ' ');
  539. X                        field[pos_n] &= ~FLAG;
  540. X                        if(field[pos_n] & BOOM) {
  541. X                            found--;
  542. X                        }
  543. X                        remain++;
  544. X                    } else if(!(field[pos_n] & DONE)){
  545. X                        s_bold();
  546. X                        s_pc(f_x0 + pos_x, f_y0 + pos_y, 'F');
  547. X                        s_rmso();
  548. X                        field[pos_n] |= FLAG;
  549. X                        if(field[pos_n] & BOOM) {
  550. X                            found++;
  551. X                        }
  552. X                        remain--;
  553. X                    }
  554. X                    i = rc;
  555. X                    upd_counter();
  556. X                } else if (ibuf[i] == ' ') {
  557. X                    if(!counter0){
  558. X                        fill_field(pos_n);
  559. X                    }
  560. X                    if((field[pos_n] & BOOM) && !(field[pos_n] & FLAG)) {
  561. X                        sleep(1);
  562. X                        s_bold();
  563. X                        s_pc(f_x0 + pos_x, f_y0 + pos_y, '@');
  564. X                        s_rmso();
  565. X                        field[pos_n] |= FLAG;
  566. X                        bad_exit();
  567. X                        return(0);
  568. X                    } else if (!(field[pos_n]&(FLAG|DONE))) {
  569. X                        make_move(pos_n, pos_x, pos_y);
  570. X                        upd_counter();
  571. X
  572. X                        if(good_found == max_found) {
  573. X                            return(good_exit());
  574. X                        }
  575. X                    }
  576. X                    i = rc;
  577. X                } else if (ibuf[i] == 'q' || ibuf[i] == 'Q') {
  578. X                    myexit(0);
  579. X                } else if(ibuf[i] == 'n' || ibuf[i] == 'N') {
  580. X                    return(1);
  581. X                } else if(ibuf[i] == 'r' || ibuf[i] == 'R') {
  582. X                    redraw();
  583. X                    i = rc;
  584. X                } else if(ibuf[i] == 'c' || ibuf[i] == 'C') {
  585. X                    chief();
  586. X                    i = rc;
  587. X                } else if(ibuf[i] == 'p' || ibuf[i] == 'P') {
  588. X                    pausing();
  589. X                    i = rc;
  590. X                } else {
  591. X                    l = rc - i;
  592. X                    if(!strncmp(&ibuf[i], k_rgt, l) || !strncmp(&ibuf[i], k_lft, l) ||
  593. X!strncmp(&ibuf[i],
  594. X                        k_dwn, l) || !strncmp(&ibuf[i], k_up, l)) {
  595. X                        for(k = 0; k < l; k++)
  596. X                            ibuf[k] = ibuf[k+i];
  597. X                        i = rc;
  598. X                    } else {
  599. X                        l = 0;
  600. X                        i++;
  601. X                    }
  602. X                }
  603. X            }
  604. X        }
  605. X    }
  606. X}
  607. X
  608. Xmake_move(n, x, y)
  609. Xint n;
  610. Xint x;
  611. Xint y;
  612. X{
  613. X    if(field[n]&~MASK)
  614. X        return;
  615. X    field[n] |= DONE;
  616. X    good_found++;
  617. X    s_pc(f_x0 + x, f_y0 + y, '0' + (field[n]&MASK));
  618. X    if(field[n]&MASK)
  619. X        return;
  620. X    if(x > 0) {
  621. X        make_move(n - 1, x - 1, y);
  622. X        if(y > 0) {
  623. X            make_move(n - 1 - f_x, x - 1, y - 1);
  624. X        }
  625. X
  626. X    }
  627. X    if(y > 0) {
  628. X        make_move(n - f_x, x, y - 1);
  629. X        if(x < f_x - 1) {
  630. X            make_move(n + 1 - f_x, x + 1, y - 1);
  631. X        }
  632. X    }
  633. X    if(x < f_x - 1) {
  634. X        make_move(n + 1, x + 1, y);
  635. X        if(y < f_y - 1) {
  636. X            make_move(n + f_x + 1, x + 1, y + 1);
  637. X        }
  638. X    }
  639. X    if(y < f_y - 1) {
  640. X        make_move(n + f_x, x, y + 1);
  641. X        if(x > 0) {
  642. X            make_move(n - 1 + f_x, x - 1, y + 1);
  643. X        }
  644. X    }
  645. X}
  646. X
  647. Xgood_exit()
  648. X{
  649. X    char n[14];
  650. X    int i;
  651. X    char c;
  652. X    FILE *fd;
  653. X
  654. X    s_pr(X_SCORE + 3, Y_SCORE - 1, "Won !!!");
  655. X    if(counter >= best_count)
  656. X        return(0);
  657. X    sleep(1);
  658. X    for(i = 0; i < 14; i++)
  659. X        n[i] = 0;
  660. X#define X_NAME 30
  661. X#define Y_NAME 11
  662. X    s_box(X_NAME, Y_NAME, 15, 2);
  663. X    s_pr(X_NAME + 1, Y_NAME + 1, "              ");
  664. X    s_pc(X_NAME + 1, Y_NAME + 1, 0);
  665. X    i = 0;
  666. X    while(1) {
  667. X        read(0, &c, 1);
  668. X        switch(c) {
  669. X        case 8:
  670. X            if(i == 0)
  671. X                break;
  672. X            i--;
  673. X            s_pc(X_NAME + 1 + i, Y_NAME + 1, ' ');
  674. X            s_pc(X_NAME + 1 + i, Y_NAME + 1, 0);
  675. X            break;
  676. X        case '\n':
  677. X        case '\r':
  678. X            set_score(f_x, f_y, bomb, n, counter);
  679. X            fd = fopen("/etc/mine.score", "r");
  680. X            if(fd) {
  681. X                char cmd[256];
  682. X                char tmp[256];
  683. X                int chk = f_x ^ f_y ^ bomb ^ counter;
  684. X                int j;
  685. X                for(j = i = 0; n[i]; i++)
  686. X                    j += n[i] << i;
  687. X                chk ^= j;
  688. X                while(fgets(tmp, 255, fd)) {
  689. X                    tmp[strlen(tmp) - 1] = 0;
  690. X                    sprintf(cmd, "rshell %s mine -score %d %d %d \"\\\"%s\\\"\" %d %d&\n", tmp, f_x,
  691. X                        f_y, bomb, n, counter, chk);
  692. X                    system(cmd);
  693. X                }
  694. X                fclose(fd);
  695. X            }
  696. X            return(1);
  697. X            break;
  698. X        default:
  699. X            if(c < 32 || c > 126)
  700. X                break;
  701. X            n[i] = c;
  702. X            s_pc(X_NAME + 1 + i, Y_NAME + 1, c);
  703. X            if(i < 14)
  704. X                i++;
  705. X            s_pc(X_NAME + 1 + i, Y_NAME + 1, 0);
  706. X            break;
  707. X        }
  708. X    }
  709. X}
  710. X
  711. Xbad_exit()
  712. X{
  713. X    int i;
  714. X    int x, y;
  715. X    sleep(1);
  716. X    s_pr(X_SCORE + 3, Y_SCORE -1, "Lost !!!");
  717. X    s_bold();
  718. X    for(i = y = 0; y < f_y; y++) {
  719. X        for(x = 0; x < f_x; x++, i++) {
  720. X            if(field[i] & BOOM) {
  721. X                if(!(field[i] & FLAG))
  722. X                    s_pc(f_x0 +x, f_y0 + y, '*');
  723. X            } else if(field[i] & FLAG) {
  724. X                s_pc(f_x0 +x, f_y0 + y, '#');
  725. X            }
  726. X        }
  727. X    }
  728. X    s_rmso();
  729. X    return;
  730. X}
  731. X
  732. Xusage()
  733. X{
  734. X    fprintf(stderr, "usage:\n    mine [-f] [-n <bombs>] [<x>] [<y>]\n");
  735. X    exit(1);
  736. X}
  737. X
  738. Xinit()
  739. X{
  740. X    struct termio tem;
  741. X    static ft = 1;
  742. X    int i;
  743. X
  744. X    if(ft) {
  745. X        struct passwd *getpwnam();
  746. X        struct passwd *p;
  747. X        p = getpwnam("mine");
  748. X        if(p)
  749. X            setreuid(p->pw_uid, p->pw_uid);
  750. X        ioctl(0, TCGETA, &tinit);
  751. X        /* Mise du tty en mode raw */
  752. X        tem = tinit;
  753. X        tem.c_oflag = 0;
  754. X        tem.c_lflag = 0;
  755. X        tem.c_iflag = 0;
  756. X        tem.c_cc[VMIN] = 1;
  757. X        tem.c_cc[VTIME] = 1;
  758. X        ioctl(0, TCSETA, &tem);
  759. X        s_init();
  760. X        ft = 0;
  761. X    }
  762. X    s_clear();
  763. X    for(i = 0; i < F_H * F_L; i++)
  764. X        field[i] = 0;
  765. X    ocount = -1;
  766. X    oremain = -1;
  767. X    counter0 = 0;
  768. X    counter = 0;
  769. X    if(!bomb || bomb > f_x * f_y / 2) {
  770. X        bomb = 3 * f_x + 3;
  771. X        if(bomb > f_x * f_y / 2)
  772. X            bomb = (f_x * f_y) / 2;
  773. X    }
  774. X    remain = bomb;
  775. X    good_found = 0;
  776. X    max_found = f_x * f_y - bomb;
  777. X    pos_x = f_x / 2;
  778. X    pos_y = f_y / 2;
  779. X    pos_n =  pos_x + pos_y * f_x;
  780. X    f_x0 = (F_L - f_x) / 2 + 1;
  781. X    f_y0 = (F_H - f_y) / 2 + 1;
  782. X    s_box(f_x0 - 1, f_y0 - 1, f_x + 1, f_y + 1);
  783. X    score = get_score(f_x, f_y, bomb);
  784. X    if(score) {
  785. X        best_count = score[4].t ? score[4].t : 10000;
  786. X    }
  787. X    draw_screen();
  788. X    
  789. X}
  790. X
  791. Xdraw_screen()
  792. X{
  793. Xint i;
  794. X    s_bold();
  795. X    s_pr(X_SCORE + 3 , 1, "MineSweeper %s", VERSION);
  796. X    s_rmso();
  797. X    s_box(X_SCORE, Y_SCORE, 19, 8);
  798. X    s_bold();
  799. X    s_pr(X_SCORE + 1, Y_SCORE + 1, "    Top  scores   ");
  800. X    s_pr(X_SCORE + 1, Y_SCORE + 2, "------------------");
  801. X    if(score) {
  802. X        for(i = 0; i < 5; i++) {
  803. X            if(!score[i].n[0])
  804. X                break;
  805. X            s_pr(X_SCORE + 1, Y_SCORE + 3 + i, "%.14s", score[i].n);
  806. X            s_pr(X_SCORE + 16, Y_SCORE + 3 + i, "%.3d", score[i].t);
  807. X        }
  808. X    }
  809. X    s_rmso();
  810. X    s_pr(X_SCORE, Y_SCORE + 10, " f       : (un)mark");
  811. X    s_pr(X_SCORE, Y_SCORE + 11, " <SPACE> : discover");
  812. X    s_pr(X_SCORE, Y_SCORE + 12, " n       : new game");
  813. X    s_pr(X_SCORE, Y_SCORE + 13, " q       : quit");
  814. X    s_pr(X_SCORE, Y_SCORE + 14, " r       : redraw");
  815. X    s_pr(X_SCORE, Y_SCORE + 15, " p       : pause");
  816. X    s_pr(X_SCORE, Y_SCORE + 16, " c       : boss");
  817. X    s_box(63, 3, 6, 2);
  818. X    s_box(71, 3, 6, 2);
  819. X}
  820. X
  821. Xfill_field(n)
  822. Xint n;
  823. X{
  824. X    int i;
  825. X    int s = f_x * f_y;
  826. X
  827. X    counter0 = time(0);
  828. X    memset(field, 0, sizeof(field));
  829. X    found = 0;
  830. X    remain = 0;
  831. X    do {
  832. X        int x, y;
  833. X        i = aleat(s);
  834. X        if(field[i] & BOOM || i == n)
  835. X            continue;
  836. X        field[i] |= BOOM;
  837. X        if(field[i]&FLAG)
  838. X            found++;
  839. X        x = i % f_x;
  840. X        y = i / f_x;
  841. X        if(x > 0)
  842. X            field[i - 1]++;
  843. X        if(y > 0) {
  844. X            field[i - f_x]++;
  845. X            if(x > 0)
  846. X                field[i - 1 - f_x]++;
  847. X            if(x < f_x - 1)
  848. X                field[i + 1 - f_x]++;
  849. X        }
  850. X        if(y < f_y - 1) {
  851. X            field[i + f_x]++;
  852. X            if(x < f_x - 1)
  853. X                field[i + 1 + f_x]++;
  854. X            if(x > 0)
  855. X                field[i - 1 + f_x]++;
  856. X        }
  857. X        if(x < f_x - 1)
  858. X            field[i + 1]++;
  859. X        remain++;
  860. X    } while(remain != bomb);
  861. X}
  862. X
  863. Xaleat(s)
  864. Xunsigned int s;
  865. X{
  866. X    static unsigned int ft;
  867. X
  868. X    if(!ft) {
  869. X        ft = time(0);
  870. X    }
  871. X    ft *= 3793;
  872. X    ft ^= 49834897;
  873. X    ft >>= 2;
  874. X    return(ft % s);
  875. X}
  876. X
  877. Xupd_counter()
  878. X{
  879. X
  880. X    if(counter0) {
  881. X        counter = time(0) - counter0;
  882. X        if(counter > 999)
  883. X            counter = 999;
  884. X    }
  885. X    if(oremain == remain && ocount == counter) {
  886. X        s_pc(f_x0 + pos_x, f_y0 + pos_y, 0);
  887. X        return;
  888. X    }
  889. X    s_civis();
  890. X    if(ocount != counter) {
  891. X        s_pr(64, 4, " %3.3d", counter);
  892. X        ocount = counter;
  893. X    }
  894. X    if(remain != oremain) {
  895. X        if(remain < 0)
  896. X            s_pr(72, 4, "%3.3d", remain);
  897. X        else 
  898. X            s_pr(72, 4, " %3.3d", remain);
  899. X        oremain = remain;
  900. X    }
  901. X    s_cnorm();
  902. X    s_pc(f_x0 + pos_x, f_y0 + pos_y, 0);
  903. X}
  904. X
  905. Xredraw() {
  906. X    int i;
  907. X    int j;
  908. X    int k;
  909. X    int l;
  910. X    int p;
  911. X    char tmp[256];
  912. X
  913. X    s_clear();
  914. X    s_civis();
  915. X    s_box(f_x0 - 1, f_y0 - 1, f_x + 1, f_y + 1);
  916. X    for(i = 0, k = 0; i < f_y; i++) {
  917. X        for(j = 0, l = 0, p = 0; j < f_x; j++, k++) {
  918. X            if(field[k] & FLAG) {
  919. X                if(l) {
  920. X                    tmp[l] = 0;
  921. X                    s_pr(f_x0 + p, f_y0 + i, "%s", tmp);
  922. X                    l = 0;
  923. X                }
  924. X                s_bold();
  925. X                s_pc(f_x0 + j, f_y0 + i, 'F');
  926. X                s_rmso();
  927. X                p = j+1;
  928. X            } else {
  929. X                tmp[l++] = (field[k] & DONE) ? (field[k] & MASK) + '0' : ' ';
  930. X            }
  931. X        }
  932. X        if(l) {
  933. X            tmp[l] = 0;
  934. X            s_pr(f_x0 + p, f_y0 + i, "%s", tmp);
  935. X        }
  936. X    }
  937. X    draw_screen();
  938. X    s_pr(64, 4, " %3.3d", counter);
  939. X    if(remain < 0)
  940. X        s_pr(72, 4, "%3.3d", remain);
  941. X    else 
  942. X        s_pr(72, 4, " %3.3d", remain);
  943. X    s_pc(f_x0 + pos_x, f_y0 + pos_y, 0);
  944. X    s_cnorm();
  945. X}
  946. X
  947. X#define LENGTH  35
  948. X#define FORMAT "%35.35s"
  949. X#define X_MIDLE ((80 - LENGTH) / 2 - 1)
  950. X#define Y_MIDLE 11
  951. X
  952. Xpausing() {
  953. X    int i;
  954. X    int j;
  955. X    char tmp[256];
  956. X    int pos;
  957. X    int len;
  958. X    struct fd_set ibits;
  959. X    struct timeval tim;
  960. X    int t;
  961. X
  962. X    s_civis();
  963. X    for(j = 0; j < f_x; j++) {
  964. X        tmp[j] = ' ';
  965. X    }
  966. X    tmp[j] = 0;
  967. X    for(i = 0; i < f_y; i++) {
  968. X        s_pr(f_x0, f_y0 + i, "%s", tmp);
  969. X    }
  970. X
  971. X    s_box(X_MIDLE, Y_MIDLE, LENGTH + 1, 2);
  972. X    t = time(0);
  973. X    strftime(tmp, 256, "Local time is %R, press a key to continue. ", localtime(&t));
  974. X    len = strlen(tmp);
  975. X
  976. X    tim.tv_sec = 0;
  977. X    tim.tv_usec = 450000;
  978. X
  979. X    FD_ZERO(&ibits);
  980. X
  981. X    pos = 0;
  982. X    while(1) {
  983. X        FD_SET(0, &ibits);
  984. X        i = select(2, &ibits, (fd_set *)0, (fd_set *)0, &tim);
  985. X        if(i) {
  986. X            read(0, tmp, 250);
  987. X            redraw();
  988. X            if(counter0)
  989. X                counter0 = time(0) - counter;
  990. X            return;
  991. X        } else {
  992. X            s_pr(X_MIDLE + 1, Y_MIDLE + 1, FORMAT, tmp+pos++);
  993. X            if(pos + LENGTH == len) {
  994. X                t = time(0);
  995. X                strftime(tmp + len, 256 - len, "Local time is %R, press a key to continue. ", localtime(&t));
  996. X            } else if(pos == len) {
  997. X                strcpy(tmp, tmp+len);
  998. X                len = strlen(tmp);
  999. X                pos = 0;
  1000. X            }
  1001. X        }
  1002. X    }
  1003. X}
  1004. X
  1005. Xchief() {
  1006. Xchar *n = getenv("CHIEFCMD");
  1007. Xstruct fd_set ibits;
  1008. Xint i;
  1009. Xchar b[250];
  1010. Xstruct termio nterm;
  1011. X
  1012. X    s_clear();
  1013. X    if(n) {
  1014. X        ioctl(0, TCGETA, &nterm);
  1015. X        ioctl(0, TCSETA, &tinit);
  1016. X        system(n);
  1017. X        ioctl(0, TCSETA, &nterm);
  1018. X    } else {
  1019. X        printf("$ ");
  1020. X        fflush(stdout);
  1021. X    }
  1022. X    FD_ZERO(&ibits);
  1023. X    while(1) {
  1024. X        FD_SET(0, &ibits);
  1025. X        i = select(2, &ibits, (fd_set *)0, (fd_set *)0, 0);
  1026. X        if(i) {
  1027. X            read(0, b, 250);
  1028. X            redraw();
  1029. X            if(counter0)
  1030. X                counter0 = time(0) - counter;
  1031. X            return;
  1032. X        }
  1033. X    }
  1034. X}
  1035. END_OF_FILE
  1036. if test 13818 -ne `wc -c <'main.c'`; then
  1037.     echo shar: \"'main.c'\" unpacked with wrong size!
  1038. fi
  1039. # end of 'main.c'
  1040. fi
  1041. if test -f 'makefile' -a "${1}" != "-c" ; then 
  1042.   echo shar: Will not clobber existing file \"'makefile'\"
  1043. else
  1044. echo shar: Extracting \"'makefile'\" \(237 characters\)
  1045. sed "s/^X//" >'makefile' <<'END_OF_FILE'
  1046. XCFLAGS=-g -I/usr/5include -DFILE_NAME=\"/homes/tl/j/mine/score.dat\"
  1047. XOBJECTS=screen.o main.o file.o
  1048. X
  1049. Xmine:$(OBJECTS)
  1050. X    cc -g -o mine $(OBJECTS) -L/usr/5lib -lcurses
  1051. X
  1052. Xinstall:mine
  1053. X    cp mine /bin
  1054. X    chown root /bin/mine
  1055. X    chmod 04755 /bin/mine
  1056. END_OF_FILE
  1057. if test 237 -ne `wc -c <'makefile'`; then
  1058.     echo shar: \"'makefile'\" unpacked with wrong size!
  1059. fi
  1060. # end of 'makefile'
  1061. fi
  1062. if test -f 'minesweeper.txt' -a "${1}" != "-c" ; then 
  1063.   echo shar: Will not clobber existing file \"'minesweeper.txt'\"
  1064. else
  1065. echo shar: Extracting \"'minesweeper.txt'\" \(1006 characters\)
  1066. sed "s/^X//" >'minesweeper.txt' <<'END_OF_FILE'
  1067. Xmine [-f] [-n <bombs>] [<x>] [<y>]
  1068. X
  1069. XThe goal of this game is to discover a mine field.
  1070. XThe player can discover a square by going into it with the arrows
  1071. Xand then hitting the space bar. If this square contains  a mine
  1072. Xa '@' appears and the game is over. If not, a number appears that
  1073. Xrepresents the number of mines in the contiguous squares. 
  1074. XThe player wins when he has discovered all the empty squares.
  1075. X
  1076. XThe -f options starts the game with a smaller field than the default one.
  1077. XThe other options allow to specify the field and the number of mines.
  1078. X
  1079. X
  1080. XApart from the space bar and the arrows, the keys are
  1081. X        - 'f' to (un)mark the position of a mine
  1082. X        - 'n' to start a new game.
  1083. X        - 'q' to quit the game.
  1084. X        - 'p' to make a pause
  1085. X        - 'c' when your boss arrives
  1086. X
  1087. XTo install it, create  a 'mine' user, put root as owner of the game and
  1088. Xthe set user id bit. If you want to share the score file across the
  1089. Xnetwork, the /etc/mine.score must contain the list of the machines
  1090. Xfor which the score has to be updated.
  1091. X
  1092. END_OF_FILE
  1093. if test 1006 -ne `wc -c <'minesweeper.txt'`; then
  1094.     echo shar: \"'minesweeper.txt'\" unpacked with wrong size!
  1095. fi
  1096. # end of 'minesweeper.txt'
  1097. fi
  1098. if test -f 'screen.c' -a "${1}" != "-c" ; then 
  1099.   echo shar: Will not clobber existing file \"'screen.c'\"
  1100. else
  1101. echo shar: Extracting \"'screen.c'\" \(3895 characters\)
  1102. sed "s/^X//" >'screen.c' <<'END_OF_FILE'
  1103. X#include <curses.h>
  1104. X#include <term.h>
  1105. X
  1106. Xstatic char *st_smkx;
  1107. Xstatic char *st_rmkx;
  1108. Xextern int l_up;
  1109. Xextern char *k_up;
  1110. Xextern int l_dwn;
  1111. Xextern char *k_dwn;
  1112. Xextern int l_lft;
  1113. Xextern char *k_lft;
  1114. Xextern int l_rgt;
  1115. Xextern char *k_rgt;
  1116. Xstatic char *st_cup;
  1117. Xstatic char *st_clear;
  1118. Xstatic char *st_enacs;
  1119. Xstatic char *st_smacs;
  1120. Xstatic char *st_rmacs;
  1121. Xstatic char *st_acsc;
  1122. Xstatic int l_acsc;
  1123. Xstatic char *st_bold;
  1124. Xstatic char *st_rmso;
  1125. Xstatic int l_bold;
  1126. Xstatic int l_rmso;
  1127. Xstatic char *st_civis;
  1128. Xstatic char *st_cnorm;
  1129. Xstatic int l_cnorm;
  1130. Xstatic int l_civis;
  1131. X
  1132. Xchar A_UL = '+';
  1133. Xchar A_LL = '+';
  1134. Xchar A_UR = '+';
  1135. Xchar A_LR = '+';
  1136. Xchar A_VL = '|';
  1137. Xchar A_HL = '-';
  1138. X
  1139. Xint pc();
  1140. X
  1141. X#define TPUTS(x, y, z)  (tputs(y, z, pc), pc(0), pc(0), pc(0))
  1142. X
  1143. Xs_init()
  1144. X{
  1145. Xint result;
  1146. Xchar *t;
  1147. Xint i;
  1148. X
  1149. X    if(setupterm((char *)0, 1, &result) == ERR) {
  1150. X        switch(result) {
  1151. X            case 0:
  1152. X                fprintf(stderr, "Can't find terminal %s\n\r", getenv("TERM"));
  1153. X                myexit(1);
  1154. X            case -1:
  1155. X                fprintf(stderr, "Can't find termininfo database\n\r");
  1156. X                myexit(1);
  1157. X            default:
  1158. X                fprintf(stderr, "Bad terminfo error %d\n\r", result);
  1159. X                myexit(1);
  1160. X        }
  1161. X    }
  1162. X    st_cup = tigetstr("cup");
  1163. X    if(!st_cup) {
  1164. X        fprintf(stderr, "cup not found\n\r");
  1165. X        myexit(1);
  1166. X    }
  1167. X    st_clear = tigetstr("clear");
  1168. X    if(!st_clear) {
  1169. X        fprintf(stderr, "clear not found\n\r");
  1170. X        myexit(1);
  1171. X    }
  1172. X    st_smkx = tigetstr("smkx");
  1173. X    st_rmkx = tigetstr("rmkx");
  1174. X    if(st_smkx)
  1175. X        TPUTS(1, st_smkx, strlen(st_smkx));
  1176. X    st_bold = tigetstr("bold");
  1177. X    if(st_bold) {
  1178. X        l_bold = strlen(st_bold);
  1179. X        st_rmso = tigetstr("rmso");
  1180. X        if(st_rmso) {
  1181. X            l_rmso = strlen(st_rmso);
  1182. X        } else st_bold = 0;
  1183. X    }
  1184. X    st_civis = tigetstr("civis");
  1185. X    if(st_civis) {
  1186. X        l_civis = strlen(st_civis);
  1187. X        st_cnorm = tigetstr("cnorm");
  1188. X        if(st_cnorm) {
  1189. X            l_cnorm = strlen(st_cnorm);
  1190. X        } else st_civis = 0;
  1191. X    }
  1192. X    st_enacs = tigetstr("enacs");
  1193. X    st_rmacs = tigetstr("rmacs");
  1194. X    st_smacs = tigetstr("smacs");
  1195. X    if (t = tigetstr("kcuu1")) {
  1196. X        k_up = t;
  1197. X        l_up = strlen(t);
  1198. X    }
  1199. X    if (t = tigetstr("kcud1")) {
  1200. X        k_dwn = t;
  1201. X        l_dwn = strlen(t);
  1202. X    }
  1203. X    if (t = tigetstr("kcub1")) {
  1204. X        k_lft = t;
  1205. X        l_lft = strlen(t);
  1206. X    }
  1207. X    if (t = tigetstr("kcuf1")) {
  1208. X        k_rgt = t;
  1209. X        l_rgt = strlen(t);
  1210. X    }
  1211. X    if(st_smacs) {
  1212. X        if(st_enacs)
  1213. X            TPUTS(1, st_enacs, strlen(st_enacs));
  1214. X        st_acsc = tigetstr("acsc");
  1215. X        if(st_acsc) {
  1216. X            l_acsc = strlen(st_acsc);
  1217. X            for(i = 0; i < l_acsc; i+= 2) {
  1218. X                switch(st_acsc[i]) {
  1219. X                    case 'l':
  1220. X                        A_UL = st_acsc[i+1];
  1221. X                        break;
  1222. X                    case 'm':
  1223. X                        A_LL = st_acsc[i+1];
  1224. X                        break;
  1225. X                    case 'k':
  1226. X                        A_UR = st_acsc[i+1];
  1227. X                        break;
  1228. X                    case 'j':
  1229. X                        A_LR = st_acsc[i+1];
  1230. X                        break;
  1231. X                    case 'q':
  1232. X                        A_HL = st_acsc[i+1];
  1233. X                        break;
  1234. X                    case 'x':
  1235. X                        A_VL = st_acsc[i+1];
  1236. X                        break;
  1237. X                }
  1238. X            }
  1239. X        }
  1240. X    }
  1241. X    fl();
  1242. X}
  1243. X
  1244. Xs_term()
  1245. X{
  1246. X    if(st_rmkx)
  1247. X        TPUTS(1, st_rmkx, strlen(st_rmkx));
  1248. X    fl();
  1249. X}
  1250. X
  1251. Xstatic unsigned char buf[1024];
  1252. Xint pbuf;
  1253. X
  1254. Xstatic pc(c)
  1255. Xchar c;
  1256. X{
  1257. X    buf[pbuf++] = c;
  1258. X}
  1259. X
  1260. Xstatic fl()
  1261. X{
  1262. X    write(1, buf, pbuf);
  1263. X    pbuf = 0;
  1264. X}
  1265. X
  1266. Xs_pr(x, y, s, v1, v2)
  1267. Xint x;
  1268. Xint y;
  1269. Xchar *s;
  1270. Xint v1;
  1271. Xint v2;
  1272. X{
  1273. Xchar *p = tgoto(st_cup, x, y);
  1274. X    TPUTS(1, p, strlen(p));
  1275. X    pbuf += sprintf(buf+pbuf, s, v1, v2);
  1276. X    fl();
  1277. X}
  1278. X
  1279. Xs_pc(x, y, c)
  1280. Xint x;
  1281. Xint y;
  1282. Xchar c;
  1283. X{
  1284. Xchar *p = tgoto(st_cup, x, y);
  1285. X    TPUTS(1, p, strlen(p));
  1286. X    if(c != 0)
  1287. X        pc(c);
  1288. X    fl();
  1289. X}
  1290. X
  1291. Xs_clear()
  1292. X{
  1293. X    TPUTS(1, st_clear, strlen(st_clear));
  1294. X    fl();
  1295. X}
  1296. X
  1297. Xs_box(x, y, l, h)
  1298. Xint x,y;
  1299. Xint l,h;
  1300. X{
  1301. Xint i;
  1302. X    if(st_smacs)
  1303. X        TPUTS(1, st_smacs, strlen(st_smacs));
  1304. X    s_pc(x, y, A_UL);
  1305. X    s_pc(x + l, y, A_UR);
  1306. X    s_pc(x, y + h, A_LL);
  1307. X    s_pc(x + l, y + h, A_LR);
  1308. X    for(i = 1; i < l; i++) {
  1309. X        s_pc(x+i, y, A_HL);
  1310. X        s_pc(x+i, y+h, A_HL);
  1311. X    }
  1312. X    for(i = 1; i < h; i++) {
  1313. X        s_pc(x, y+i, A_VL);
  1314. X        s_pc(x+l, y+i, A_VL);
  1315. X    }
  1316. X    if(st_rmacs)
  1317. X        TPUTS(1, st_rmacs, strlen(st_rmacs));
  1318. X}
  1319. X
  1320. Xs_bold()
  1321. X{
  1322. X    if(st_bold)
  1323. X        TPUTS(1, st_bold, l_bold);
  1324. X}
  1325. X
  1326. Xs_rmso()
  1327. X{
  1328. X    if(st_rmso)
  1329. X        TPUTS(1, st_rmso, l_rmso);
  1330. X}
  1331. X
  1332. Xs_civis()
  1333. X{
  1334. X    if(st_civis)
  1335. X        TPUTS(1, st_civis, l_civis);
  1336. X}
  1337. X
  1338. Xs_cnorm()
  1339. X{
  1340. X    if(st_cnorm)
  1341. X        TPUTS(1, st_cnorm, l_cnorm);
  1342. X}
  1343. END_OF_FILE
  1344. if test 3895 -ne `wc -c <'screen.c'`; then
  1345.     echo shar: \"'screen.c'\" unpacked with wrong size!
  1346. fi
  1347. # end of 'screen.c'
  1348. fi
  1349. echo shar: End of archive 1 \(of 1\).
  1350. cp /dev/null ark1isdone
  1351. MISSING=""
  1352. for I in 1 ; do
  1353.     if test ! -f ark${I}isdone ; then
  1354.     MISSING="${MISSING} ${I}"
  1355.     fi
  1356. done
  1357. if test "${MISSING}" = "" ; then
  1358.     echo You have the archive.
  1359.     rm -f ark[1-9]isdone
  1360. else
  1361.     echo You still need to unpack the following archives:
  1362.     echo "        " ${MISSING}
  1363. fi
  1364. ##  End of shell archive.
  1365. exit 0
  1366.