home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sources / x / 427 < prev    next >
Encoding:
Text File  |  1992-07-23  |  42.4 KB  |  1,362 lines

  1. Path: sparky!uunet!ogicse!uwm.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!mips!msi!dcmartin
  2. From: jung@dia.informatik.uni-stuttgart.de (Norbert Jung)
  3. Newsgroups: comp.sources.x
  4. Subject: v18i058: xvier v1.0 - cute GO'ish game, Part02/02
  5. Message-ID: <1992Jul23.141649.27434@msi.com>
  6. Date: 23 Jul 92 14:16:49 GMT
  7. Article-I.D.: msi.1992Jul23.141649.27434
  8. References: <csx-18i057-xview-1.0@uunet.UU.NET>
  9. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  10. Organization: Molecular Simulations, Inc.
  11. Lines: 1347
  12. Approved: dcmartin@msi.com
  13. Originator: dcmartin@fascet
  14.  
  15. Submitted-by: Norbert Jung <jung@dia.informatik.uni-stuttgart.de>
  16. Posting-number: Volume 18, Issue 58
  17. Archive-name: xview-1.0/part02
  18.  
  19. #!/bin/sh
  20. # this is part.02 (part 2 of a multipart archive)
  21. # do not concatenate these parts, unpack them in order with /bin/sh
  22. # file xvier.c continued
  23. #
  24. if test ! -r _shar_seq_.tmp; then
  25.     echo 'Please unpack part 1 first!'
  26.     exit 1
  27. fi
  28. (read Scheck
  29.  if test "$Scheck" != 2; then
  30.     echo Please unpack part "$Scheck" next!
  31.     exit 1
  32.  else
  33.     exit 0
  34.  fi
  35. ) < _shar_seq_.tmp || exit 1
  36. if test ! -f _shar_wnt_.tmp; then
  37.     echo 'x - still skipping xvier.c'
  38. else
  39. echo 'x - continuing file xvier.c'
  40. sed 's/^X//' << 'SHAR_EOF' >> 'xvier.c' &&
  41. X      goto usage;
  42. X      }
  43. X    else if (strcmp(argv[i], "-iconic") == 0)
  44. X      iconic++;
  45. X    else if (strcmp(argv[i], "-level") == 0)
  46. X      if (++i == argc)
  47. X    goto usage;
  48. X      else {
  49. X    if (argv[i][0] == '+' ||
  50. X        ('0' <= argv[i][0] && argv[i][0] <= '9'))
  51. X      level = atoi(argv[i]);
  52. X    else
  53. X      level = -1;
  54. X    if (level < 0 || level > 9) {
  55. X      fprintf(stderr, "%s: level should be in the range 0..9\n", *argv);
  56. X      exit(1);
  57. X    }
  58. X      }
  59. X    else {
  60. X    usage:
  61. X      fprintf(stderr, "usage: %s\t[-display <display>]\
  62. \n\t\t[-geometry <geometry>]\n\t\t[-fn <fontpattern>]\n\t\t[-iconic]\
  63. \n\t\t[-rows <rows>]\n\t\t[-columns <columns>]\
  64. \n\t\t[-prog <path>]\n\t\t[-level <num>]\n", *argv);
  65. X      exit(1);
  66. X    }
  67. X  }
  68. X  if ((mydisplay = XOpenDisplay(displayname)) == NULL) {
  69. X    if (displayname != NULL)
  70. X      fprintf(stderr, "%s: Couldn't open display \"%s\".\n",
  71. X          *argv, displayname);
  72. X    else
  73. X      fprintf(stderr, "%s: Couldn't open display.\n", *argv);
  74. X    exit(1);
  75. X  }
  76. X  if (pipe(pipeo) < 0 || pipe(pipei) < 0) {
  77. X    perror("xvier pipe failed");
  78. X    exit(1);
  79. X  }
  80. X  switch (pid = fork()) {
  81. X  case -1:
  82. X    perror("xvier fork failed");
  83. X    exit(1);
  84. X  case 0:
  85. X    if (dup2(pipeo[0], 0) < 0 || dup2(pipei[1], 1) < 0) {
  86. X      perror("xvier dup2 failed");
  87. X      exit(1);
  88. X    }
  89. #ifdef NO_GETDTABSIZE
  90. #ifdef hpux
  91. X    for (i = _NFILE; i > 2; i--)
  92. #else
  93. X    for (i = sysconf(_SC_OPEN_MAX); i > 2; i--)
  94. #endif
  95. #else
  96. X    for (i = getdtablesize(); i > 2; i--)
  97. #endif
  98. X      close(i);
  99. X    for (i = 0; i < NSIG; i++)
  100. X      signal(i, SIG_DFL);
  101. X    sprintf(row_string, "%d", rows);
  102. X    sprintf(column_string, "%d", columns);
  103. X    av[0] = "xvier_prog";
  104. X    av[1] = row_string;
  105. X    av[2] = column_string;
  106. X    av[3] = (char *) NULL;
  107. X    execvp(progname, av);
  108. X    perror("xvier child exec");
  109. X    exit(1);
  110. X  default:
  111. X    close(pipeo[0]);
  112. X    close(pipei[1]);
  113. X  }
  114. #ifdef NO_SELECT
  115. X  pfd[0].fd = ConnectionNumber(mydisplay);
  116. X  pfd[1].fd = pipei[0];
  117. X  pfd[0].events = pfd[1].events = POLLIN;
  118. X  npfd = 2L;
  119. #else
  120. #ifdef NO_FD_SET
  121. X  fullfds = (1 << ConnectionNumber(mydisplay)) | (1 << pipei[0]);
  122. #else
  123. X  FD_ZERO(&fullfds);
  124. X  FD_SET(ConnectionNumber(mydisplay), &fullfds);
  125. X  FD_SET(pipei[0], &fullfds);
  126. #endif
  127. #endif
  128. X  for (i = 0; i < 6; i++) {
  129. X    if (read(pipei[0], &text[i], 1) < 1) {
  130. X      fprintf(stderr, "%s: read from xvier_prog failed\n", *argv);
  131. X      exit(1);
  132. X    }
  133. X    if (text[i] == 'C') {
  134. X      text[i+1] = '\0';
  135. X      break;
  136. X    }
  137. X  }
  138. X  text[6] = '\0';
  139. X  if (sscanf(text, "%dR%dC", &rows, &columns) != 2 ||
  140. X      rows < 4 || rows > MAXRC || columns < 4 || columns > MAXRC) {
  141. X    fprintf(stderr, "%s: wrong format from xvier_prog\n", *argv);
  142. X    exit(1);
  143. X  }
  144. X  columnfill = (int *)malloc(columns * sizeof(int));
  145. X  for (i = 0; i < columns; i++)
  146. X    columnfill[i] = 0;
  147. X  stone_x[0] = (int *)malloc(((columns * rows + 1) >> 1) * sizeof(int));
  148. X  stone_x[1] = (int *)malloc(((columns * rows + 1) >> 1) * sizeof(int));
  149. X  stone_y[0] = (int *)malloc(((columns * rows + 1) >> 1) * sizeof(int));
  150. X  stone_y[1] = (int *)malloc(((columns * rows + 1) >> 1) * sizeof(int));
  151. X  stone[0] = (XArc *)malloc(((columns * rows + 1) >> 1) * sizeof(XArc));
  152. X  stone[1] = (XArc *)malloc(((columns * rows + 1) >> 1) * sizeof(XArc));
  153. X  holes = (XArc *)malloc((columns * rows) * sizeof(XArc));
  154. X  myscreen = DefaultScreen(mydisplay);
  155. X  if (geostring != NULL) {
  156. X    char defaultstring[10];
  157. X
  158. X    sprintf(defaultstring, "%dx%d", DEFAULTWIDTH, DEFAULTHEIGHT);
  159. X    geo_ret = XGeometry(mydisplay, myscreen, geostring, defaultstring,
  160. X            TOPBORDERWIDTH, 1, 1, 0, 0,
  161. X            &userx, &usery, &userwidth, &userheight);
  162. X  } else
  163. X    geo_ret = 0;
  164. X  for (i = 0; i < ((columns * rows + 1) >> 1); i++) {
  165. X    stone[0][i].angle1 = stone[1][i].angle1 = 0;
  166. X    stone[0][i].angle2 = stone[1][i].angle2 = 360 * 64;
  167. X  }
  168. X  for (i = 0; i < columns * rows; i++) {
  169. X    holes[i].angle1 = 0;
  170. X    holes[i].angle2 = 360 * 64;
  171. X  }
  172. X  valuemask = 0;
  173. X  playercolor[0] = "WHITE";
  174. X  playercolor[1] = "BLACK";
  175. X  if (DefaultDepth(mydisplay, myscreen) == 1) {
  176. X    WHITE = YELLOW = WhitePixel(mydisplay, myscreen);
  177. X    BLACK = BLUE = RED = BlackPixel(mydisplay, myscreen);
  178. X  } else {
  179. X    Visual *vis = DefaultVisual(mydisplay, myscreen);
  180. X
  181. X    if (vis->class == GrayScale || vis->class == StaticGray ||
  182. X    vis->map_entries < 5)
  183. X      rgb_values = gray_values;
  184. X    else {
  185. X      rgb_values = color_values;
  186. X      playercolor[0] = "YELLOW";
  187. X      playercolor[1] = "RED";
  188. X    }
  189. X    cmap = DefaultColormap(mydisplay, myscreen);
  190. X    for (i = 0; i < 5; i++) {
  191. X      XColor color;
  192. X
  193. X      color.red   = rgb_values[i].red;
  194. X      color.green = rgb_values[i].green;
  195. X      color.blue  = rgb_values[i].blue;
  196. X      color.flags = DoRed | DoGreen | DoBlue;
  197. X    retry:
  198. X      if (XAllocColor(mydisplay, cmap, &color) == 0)
  199. X    if (!private_cmap) {
  200. X      private_cmap = 1;
  201. X      cmap = XCopyColormapAndFree(mydisplay, cmap);
  202. X      goto retry;
  203. X    } else {
  204. X      fprintf(stderr, "%s: Couldn't allocate color %d\n", *argv, i);
  205. X      exit(2);
  206. X    }
  207. X      PixelArray[i] = color.pixel;
  208. X    }
  209. X    if (private_cmap) {
  210. X      attributes.colormap = cmap;
  211. X      valuemask |= CWColormap;
  212. X    }
  213. X  }
  214. X  sprintf(yellowmovestring, "%s to move", playercolor[0]);
  215. X  sprintf(redmovestring, "%s to move", playercolor[1]);
  216. X  messagestring[0] = yellowmovestring;
  217. X  messagestring[1] = redmovestring;
  218. X  messagestring[2] = "I win";
  219. X  messagestring[3] = "You win!";
  220. X  messagestring[4] = "Draw";
  221. X  attributes.background_pixel = WHITE;
  222. X  valuemask |= CWBackPixel;
  223. X  attributes.border_pixel = BLACK;
  224. X  valuemask |= CWBorderPixel;
  225. X  attributes.cursor = cursor_normal = XCreateFontCursor(mydisplay, XC_hand2);
  226. X  valuemask |= CWCursor;
  227. X  attributes.event_mask = KeyPressMask | ExposureMask | StructureNotifyMask;
  228. X  valuemask |= CWEventMask;
  229. X  attributes.do_not_propagate_mask = ButtonPressMask;
  230. X  valuemask |= CWDontPropagate;
  231. X  switch (geo_ret & (WidthValue | HeightValue)) {
  232. X  case 0:
  233. X    myhint.width = DEFAULTWIDTH;
  234. X    myhint.height = DEFAULTHEIGHT;
  235. X    myhint.flags = PSize;
  236. X    break;
  237. X  case WidthValue | HeightValue:
  238. X    if (userwidth < MINWIDTH) {
  239. X      if (geo_ret & XNegative)
  240. X    userx += userwidth - MINWIDTH;
  241. X      userwidth = MINWIDTH;
  242. X    }
  243. X    if (userheight < MINHEIGHT) {
  244. X      if (geo_ret & YNegative)
  245. X    usery += userheight - MINHEIGHT;
  246. X      userheight = MINHEIGHT;
  247. X    }
  248. #ifndef XVIER_WM_ASPECT_BUG
  249. X    if (userwidth * MINASPECTHEIGHT < userheight * MINASPECTWIDTH) {
  250. X      if (geo_ret & XNegative)
  251. X    userx += userwidth -
  252. X      (userheight * MINASPECTWIDTH) / MINASPECTHEIGHT;
  253. X      userwidth = (userheight * MINASPECTWIDTH) / MINASPECTHEIGHT;
  254. X    }
  255. X    if (userwidth * MAXASPECTHEIGHT > userheight * MAXASPECTWIDTH) {
  256. X      if (geo_ret & YNegative)
  257. X    usery += userheight -
  258. X      (userwidth * MAXASPECTHEIGHT) / MAXASPECTWIDTH;
  259. X      userheight = (userwidth * MAXASPECTHEIGHT) / MAXASPECTWIDTH;
  260. X    }
  261. #endif
  262. X    myhint.width = userwidth;
  263. X    myhint.height = userheight;
  264. X    myhint.flags = USSize;
  265. X    break;
  266. X  case WidthValue:
  267. X    if (userwidth < MINWIDTH) {
  268. X      if (geo_ret & XNegative)
  269. X    userx += userwidth - MINWIDTH;
  270. X      userwidth = MINWIDTH;
  271. X    }
  272. X    if (geo_ret & YNegative)
  273. X      usery += DEFAULTHEIGHT - (userwidth * DEFAULTHEIGHT) / DEFAULTWIDTH;
  274. X    myhint.width = userwidth;
  275. X    myhint.height = (userwidth * DEFAULTHEIGHT) / DEFAULTWIDTH;
  276. X    myhint.flags = USSize;
  277. X    break;
  278. X  case HeightValue:
  279. X    if (userheight < MINHEIGHT) {
  280. X      if (geo_ret & YNegative)
  281. X    usery += userheight - MINHEIGHT;
  282. X      userheight = MINHEIGHT;
  283. X    }
  284. X    if (geo_ret & XNegative)
  285. X      userx += DEFAULTWIDTH - (userheight * DEFAULTWIDTH) / DEFAULTHEIGHT;
  286. X    myhint.width = (userheight * DEFAULTWIDTH) / DEFAULTHEIGHT;
  287. X    myhint.height = userheight;
  288. X    myhint.flags = USSize;
  289. X    break;
  290. X  }
  291. X  if (geo_ret & XValue)
  292. X    myhint.x = userx;
  293. X  else
  294. X    myhint.x = (DisplayWidth(mydisplay, myscreen) - myhint.width) / 2;
  295. X  if (geo_ret & YValue)
  296. X    myhint.y = usery;
  297. X  else
  298. X    myhint.y = (DisplayHeight(mydisplay, myscreen) - myhint.height) / 2;
  299. X  if (geo_ret & (XValue | YValue))
  300. X    myhint.flags |= USPosition;
  301. X  else
  302. X    myhint.flags |= PPosition;
  303. X  topwindow = XCreateWindow(mydisplay, DefaultRootWindow(mydisplay),
  304. X                myhint.x, myhint.y, myhint.width, myhint.height,
  305. X                TOPBORDERWIDTH, CopyFromParent, InputOutput,
  306. X                CopyFromParent, valuemask, &attributes);
  307. X  qup = XCreateBitmapFromData(mydisplay, topwindow, qup_bits,
  308. X                  qup_width, qup_height);
  309. X  qupmask = XCreateBitmapFromData(mydisplay, topwindow, qupmask_bits,
  310. X                  qupmask_width, qupmask_height);
  311. X  qright = XCreateBitmapFromData(mydisplay, topwindow, qright_bits,
  312. X                 qright_width, qright_height);
  313. X  qrightmask = XCreateBitmapFromData(mydisplay, topwindow, qrightmask_bits,
  314. X                     qrightmask_width, qrightmask_height);
  315. X  qdown = XCreateBitmapFromData(mydisplay, topwindow, qdown_bits,
  316. X                qdown_width, qdown_height);
  317. X  qdownmask = XCreateBitmapFromData(mydisplay, topwindow, qdownmask_bits,
  318. X                    qdownmask_width, qdownmask_height);
  319. X  qleft = XCreateBitmapFromData(mydisplay, topwindow, qleft_bits,
  320. X                qleft_width, qleft_height);
  321. X  qleftmask = XCreateBitmapFromData(mydisplay, topwindow, qleftmask_bits,
  322. X                    qleftmask_width, qleftmask_height);
  323. X  cursorforeground.red = cursorforeground.green = cursorforeground.blue = 0;
  324. X  cursorforeground.flags = DoRed | DoGreen | DoBlue;
  325. X  cursorbackground.red = cursorbackground.green = cursorbackground.blue = 65535;
  326. X  cursorbackground.flags = DoRed | DoGreen | DoBlue;
  327. X  if ((cursor_q[0] = XCreatePixmapCursor(mydisplay, qup, qupmask,
  328. X                     &cursorforeground, &cursorbackground,
  329. X                     qup_x_hot, qup_y_hot)) == None ||
  330. X      (cursor_q[1] = XCreatePixmapCursor(mydisplay, qright, qrightmask,
  331. X                     &cursorforeground, &cursorbackground,
  332. X                     qright_x_hot, qright_y_hot)) == None ||
  333. X      (cursor_q[2] = XCreatePixmapCursor(mydisplay, qdown, qdownmask,
  334. X                     &cursorforeground, &cursorbackground,
  335. X                     qdown_x_hot, qdown_y_hot)) == None ||
  336. X      (cursor_q[3] = XCreatePixmapCursor(mydisplay, qleft, qleftmask,
  337. X                     &cursorforeground, &cursorbackground,
  338. X                     qleft_x_hot, qleft_y_hot)) == None) {
  339. X    fprintf(stderr, "%s: couldn't create cursors\n", *argv);
  340. X    exit(1);
  341. X  }
  342. #ifndef NO_SELECT
  343. X  selectval.tv_sec = 0;
  344. X  selectval.tv_usec = 500000;
  345. #endif
  346. X  iconsize = 0;
  347. X  if (XGetIconSizes(mydisplay, topwindow, &Ilist, &Ilistsize) != 0)
  348. X    for (i = 0; i < Ilistsize; i++) {
  349. X      if (Ilist[i].max_width < Ilist[i].max_height) {
  350. X    if (Ilist[i].max_width > iconsize &&
  351. X        (Ilist[i].max_width == Ilist[i].max_height ||
  352. X         (Ilist[i].max_width < Ilist[i].max_height &&
  353. X          Ilist[i].max_width >= Ilist[i].min_height &&
  354. X          (Ilist[i].max_width - Ilist[i].min_height) %
  355. X          Ilist[i].height_inc == 0)))
  356. X      iconsize = Ilist[i].max_width;
  357. X      } else
  358. X    if (Ilist[i].max_height > iconsize &&
  359. X        (Ilist[i].max_height == Ilist[i].max_width ||
  360. X         (Ilist[i].max_height < Ilist[i].max_width &&
  361. X          Ilist[i].max_height >= Ilist[i].min_width &&
  362. X          (Ilist[i].max_height - Ilist[i].min_width) %
  363. X          Ilist[i].width_inc == 0)))
  364. X      iconsize = Ilist[i].max_height;
  365. X    }
  366. X  if (iconsize == 0)
  367. X    iconsize = DEFAULTICONSIZE;
  368. X  {
  369. X    GC iconpgc;
  370. X    int spacing, width;
  371. X
  372. X    spacing = iconsize / 16;
  373. X    width = (iconsize - 4 * spacing) / 4;
  374. X    iconpixmap = XCreatePixmap(mydisplay, DefaultRootWindow(mydisplay),
  375. X                   iconsize, iconsize, 1);
  376. X    iconpgc = XCreateGC(mydisplay, iconpixmap, 0, 0);
  377. X    XSetForeground(mydisplay, iconpgc, 0L);
  378. X    XFillRectangle(mydisplay, iconpixmap, iconpgc, 0, 0, iconsize, iconsize);
  379. X    XSetForeground(mydisplay, iconpgc, ~0L);
  380. X    for (i = 0; i < 6; i++)
  381. X      XDrawArc(mydisplay, iconpixmap, iconpgc,
  382. X           spacing / 2 + icon_w_x[i] * (spacing + width),
  383. X           spacing / 2 + icon_w_y[i] * (spacing + width),
  384. X           width, width, 0, 360 * 64);
  385. X    for (i = 0; i < 6; i++)
  386. X      XFillArc(mydisplay, iconpixmap, iconpgc,
  387. X           spacing / 2 + icon_b_x[i] * (spacing + width),
  388. X           spacing / 2 + icon_b_y[i] * (spacing + width),
  389. X           width, width, 0, 360 * 64);
  390. X    XFreeGC(mydisplay, iconpgc);
  391. X  }
  392. X  myhint.min_width = MINWIDTH;
  393. X  myhint.min_height = MINHEIGHT;
  394. X  myhint.flags |= PMinSize;
  395. #ifndef XVIER_WM_ASPECT_BUG
  396. X  myhint.min_aspect.x = MINASPECTWIDTH;
  397. X  myhint.min_aspect.y = MINASPECTHEIGHT;
  398. X  myhint.max_aspect.x = MAXASPECTWIDTH;
  399. X  myhint.max_aspect.y = MAXASPECTHEIGHT;
  400. X  myhint.flags |= PAspect;
  401. #endif
  402. X  XSetStandardProperties(mydisplay, topwindow, Title, Title, iconpixmap,
  403. X             argv, argc, &myhint);
  404. X  myclass.res_name = "xvier";
  405. X  myclass.res_class = "Xvier";
  406. X  XSetClassHint(mydisplay, topwindow, &myclass);
  407. X  if (iconic) {
  408. X    mywmhints = XGetWMHints(mydisplay, topwindow);
  409. X    mywmhints->initial_state = IconicState;
  410. X    mywmhints->flags |= StateHint;
  411. X    XSetWMHints(mydisplay, topwindow, mywmhints);
  412. X  }
  413. X  valuemask = 0;
  414. X  if (DefaultDepth(mydisplay, myscreen) == 1) {
  415. X    unsigned int w, h, w_8;
  416. X    char *data;
  417. X
  418. X    XQueryBestStipple(mydisplay, topwindow, 8, 8, &w, &h);
  419. X    if (w & 1)
  420. X      w *= 2;
  421. X    if (h & 1)
  422. X      h *= 2;
  423. X    w_8 = (w + 7) / 8;
  424. X    data = malloc(w_8 * h);
  425. X    for (j = 0; j < h; j++)
  426. X      for (i = 0; i < w_8; i++)
  427. X    data[j * w_8 + i] = ((j & 1) ? 0xaa : 0x55);
  428. X    bgpixmap = XCreateBitmapFromData(mydisplay, topwindow, data, w, h);
  429. X    attributes.background_pixmap = bgpixmap;
  430. X    valuemask |= CWBackPixmap;
  431. X    free(data);
  432. X  } else {
  433. X    attributes.background_pixel = BLUE;
  434. X    valuemask |= CWBackPixel;
  435. X  }
  436. X  attributes.event_mask = ButtonPressMask | ExposureMask;
  437. X  valuemask |= CWEventMask;
  438. X  attributes.override_redirect = True;
  439. X  valuemask |= CWOverrideRedirect;
  440. X  attributes.win_gravity = UnmapGravity;
  441. X  valuemask |= CWWinGravity;
  442. X  boardwindow = XCreateWindow(mydisplay, topwindow, 0, 0, 10, 10, 0,
  443. X                  CopyFromParent, InputOutput, CopyFromParent,
  444. X                  valuemask, &attributes);
  445. X  valuemask = 0;
  446. X  attributes.background_pixel = WHITE;
  447. X  valuemask |= CWBackPixel;
  448. X  attributes.border_pixel = BLACK;
  449. X  valuemask |= CWBorderPixel;
  450. X  attributes.event_mask = ButtonPressMask | ExposureMask;
  451. X  valuemask |= CWEventMask;
  452. X  attributes.override_redirect = True;
  453. X  valuemask |= CWOverrideRedirect;
  454. X  attributes.win_gravity = UnmapGravity;
  455. X  valuemask |= CWWinGravity;
  456. X  quitwindow = XCreateWindow(mydisplay, topwindow, 0, 0, 10, 10, 0,
  457. X                 CopyFromParent, InputOutput, CopyFromParent,
  458. X                 valuemask, &attributes);
  459. X  newwindow = XCreateWindow(mydisplay, topwindow, 0, 0, 10, 10, 0,
  460. X                CopyFromParent, InputOutput, CopyFromParent,
  461. X                valuemask, &attributes);
  462. X  undowindow = XCreateWindow(mydisplay, topwindow, 0, 0, 10, 10, 0,
  463. X                 CopyFromParent, InputOutput, CopyFromParent,
  464. X                 valuemask, &attributes);
  465. X  startwindow = XCreateWindow(mydisplay, topwindow, 0, 0, 10, 10, 0,
  466. X                   CopyFromParent, InputOutput, CopyFromParent,
  467. X                   valuemask, &attributes);
  468. X  changewindow = XCreateWindow(mydisplay, topwindow, 0, 0, 10, 10, 0,
  469. X                   CopyFromParent, InputOutput, CopyFromParent,
  470. X                   valuemask, &attributes);
  471. X  if (fontpattern != NULL) {
  472. X    fontnames = XListFonts(mydisplay, fontpattern, MAXFONTS, &fontnum);
  473. X    if (fontnames != NULL && fontnum > 0) {
  474. X      for (i = 0; i < fontnum; i++)
  475. X    fontstructarray[i] = XLoadQueryFont(mydisplay, fontnames[i]);
  476. X      qsort((char *) fontstructarray, fontnum, sizeof(XFontStruct *), font_cmp);
  477. X      XFreeFontNames(fontnames);
  478. X      goto got_fonts;
  479. X    } else
  480. X      fprintf(stderr, "%s: no fonts found with pattern %s.\n",
  481. X          *argv, fontpattern);
  482. X  }
  483. X  fontnames = XListFonts(mydisplay, DEFAULTFONTPATTERN, MAXFONTS, &fontnum);
  484. X  if (fontnames == NULL || fontnum == 0) {
  485. X    fontstructarray[0] = XLoadQueryFont(mydisplay, "fixed");
  486. X    fontnum = 1;
  487. X  } else {
  488. X    for (i = 0; i < fontnum; i++)
  489. X      fontstructarray[i] = XLoadQueryFont(mydisplay, fontnames[i]);
  490. X    qsort((char *) fontstructarray, fontnum, sizeof(XFontStruct *), font_cmp);
  491. X    XFreeFontNames(fontnames);
  492. X  }
  493. X got_fonts:
  494. X  stonegc[0] = XCreateGC(mydisplay, topwindow, 0, 0);
  495. X  XSetForeground(mydisplay, stonegc[0], YELLOW);
  496. X  stonegc[1] = XCreateGC(mydisplay, topwindow, 0, 0);
  497. X  XSetForeground(mydisplay, stonegc[1], RED);
  498. X  buttongc = XCreateGC(mydisplay, topwindow, 0, 0);
  499. X  XSetBackground(mydisplay, buttongc, WHITE);
  500. X  XSetForeground(mydisplay, buttongc, BLACK);
  501. X  textgc = XCreateGC(mydisplay, topwindow, 0, 0);
  502. X  XSetBackground(mydisplay, textgc, WHITE);
  503. X  XSetForeground(mydisplay, textgc, BLACK);
  504. X  recalculate(myhint.width, myhint.height);
  505. X  levelnumstring[0] = '0' + level;
  506. X  write_prog(levelnumstring[0]);
  507. X  XMapSubwindows(mydisplay, topwindow);
  508. X  XMapRaised(mydisplay, topwindow);
  509. X  while (1) {
  510. X    while (XEventsQueued(mydisplay, QueuedAfterReading) > 0) {
  511. X      XNextEvent(mydisplay, &myevent);
  512. X      switch (myevent.type) {
  513. X      case Expose:
  514. X    if (myevent.xexpose.count == 0) {
  515. X      if (myevent.xexpose.window == boardwindow) {
  516. X        XDrawArcs(mydisplay, boardwindow, textgc, holes, columns * rows);
  517. X        if (stone_n[0] > 0)
  518. X          XFillArcs(mydisplay, boardwindow,
  519. X            stonegc[0], stone[0], stone_n[0]);
  520. X        if (stone_n[1] > 0)
  521. X          XFillArcs(mydisplay, boardwindow,
  522. X            stonegc[1], stone[1], stone_n[1]);
  523. X      } else if (myevent.xexpose.window == quitwindow) {
  524. X        XDrawImageString(mydisplay, quitwindow, buttongc,
  525. X                 quitposx, quitposy, "Quit", 4);
  526. X      } else if (myevent.xexpose.window == newwindow) {
  527. X        XDrawImageString(mydisplay, newwindow, buttongc,
  528. X                 newposx, newposy, "New", 3);
  529. X      } else if (myevent.xexpose.window == undowindow) {
  530. X        XDrawImageString(mydisplay, undowindow, buttongc,
  531. X                 undoposx, undoposy, "Undo", 4);
  532. X      } else if (myevent.xexpose.window == startwindow) {
  533. X        XDrawImageString(mydisplay, startwindow, buttongc,
  534. X                 startposx, startposy, "Start", 5);
  535. X      } else if (myevent.xexpose.window == changewindow) {
  536. X        XDrawImageString(mydisplay, changewindow, buttongc,
  537. X                 changeposx, changeposy, "Change", 6);
  538. X      } else if (myevent.xexpose.window == topwindow) {
  539. X        XDrawImageString(mydisplay, topwindow, textgc,
  540. X                 text1x, levely, "Level: ", 7);
  541. X        XDrawImageString(mydisplay, topwindow, textgc,
  542. X                 text2x, levely, levelnumstring, 1);
  543. X        XDrawImageString(mydisplay, topwindow, textgc,
  544. X                 text1x, humany, "You: ", 5);
  545. X        XDrawImageString(mydisplay, topwindow, textgc,
  546. X                 text2x, humany, playercolor[1 - c_index],
  547. X                 strlen(playercolor[1 - c_index]));
  548. X        XDrawImageString(mydisplay, topwindow, textgc,
  549. X                 text1x, compy, "Me: ", 4);
  550. X        XDrawImageString(mydisplay, topwindow, textgc,
  551. X                 text2x, compy, playercolor[c_index],
  552. X                 strlen(playercolor[c_index]));
  553. X        XDrawImageString(mydisplay, topwindow, textgc,
  554. X                 text1x, movey, messagestring[message_index],
  555. X                 strlen(messagestring[message_index]));
  556. X      }
  557. X    }
  558. X    break;
  559. X      case MappingNotify:
  560. X    XRefreshKeyboardMapping((XMappingEvent *) &myevent);
  561. X    break;
  562. X      case ConfigureNotify:
  563. X    recalculate(myevent.xconfigure.width, myevent.xconfigure.height);
  564. X    XMapSubwindows(mydisplay, topwindow);
  565. X    break;
  566. X      case ButtonPress:
  567. X    if (myevent.xbutton.window == quitwindow)
  568. X      goto xvier_end;
  569. X    if (myevent.xbutton.window == newwindow)
  570. X      write_prog('n');
  571. X    else if (myevent.xbutton.window == undowindow)
  572. X      write_prog('u');
  573. X    else if (myevent.xbutton.window == changewindow) {
  574. X      GC tmpgc;
  575. X      char *stmp;
  576. X
  577. X      tmpgc = stonegc[0];
  578. X      stonegc[0] = stonegc[1];
  579. X      stonegc[1] = tmpgc;
  580. X      stmp = playercolor[0];
  581. X      playercolor[0] = playercolor[1];
  582. X      playercolor[1] = stmp;
  583. X      stmp = messagestring[0];
  584. X      messagestring[0] = messagestring[1];
  585. X      messagestring[1] = stmp;
  586. X      if (stone_n[0] > 0)
  587. X        XFillArcs(mydisplay, boardwindow, stonegc[0], stone[0], stone_n[0]);
  588. X      if (stone_n[1] > 0)
  589. X        XFillArcs(mydisplay, boardwindow, stonegc[1], stone[1], stone_n[1]);
  590. X      Repaint_topwindow();
  591. X    } else if (myevent.xbutton.window == startwindow) {
  592. X      if (processing || message_index > 1 ||
  593. X          stone_n[0] > 0 || stone_n[1] > 0)
  594. X        XBell(mydisplay, 0);
  595. X      else {
  596. X        GC tmpgc;
  597. X        char *stmp;
  598. X
  599. X        write_prog('s');
  600. X        tmpgc = stonegc[0];
  601. X        stonegc[0] = stonegc[1];
  602. X        stonegc[1] = tmpgc;
  603. X        stmp = playercolor[0];
  604. X        playercolor[0] = playercolor[1];
  605. X        playercolor[1] = stmp;
  606. X        stmp = messagestring[0];
  607. X        messagestring[0] = messagestring[1];
  608. X        messagestring[1] = stmp;
  609. X        c_index = 1 - c_index;
  610. X        Repaint_topwindow();
  611. X      }
  612. X    } else if (myevent.xbutton.window == boardwindow) {
  613. X      if (processing || message_index > 1)
  614. X        XBell(mydisplay, 0);
  615. X      else {
  616. X        if ((myevent.xbutton.x % (piece_width + piece_dx)) > piece_dx) {
  617. X          int col = myevent.xbutton.x / (piece_width + piece_dx);
  618. X
  619. X          if (col < columns)
  620. X        if (columnfill[col] < rows) {
  621. X          write_prog('a' + col);
  622. X          domove(1 - c_index, col);
  623. X          message(1 - message_index);
  624. X        } else
  625. X          XBell(mydisplay, 0);
  626. X        }
  627. X      }
  628. X    }
  629. X    break;
  630. X      case KeyPress:
  631. X    if (XLookupString((XKeyEvent *) &myevent, text, 10, &mykey, 0) == 1) {
  632. X      switch (text[0]) {
  633. X      case 'q': case 'Q':
  634. X        goto xvier_end;
  635. X      case 'a': case 'b': case 'c': case 'd': case 'e':
  636. X      case 'f': case 'g': case 'h': case 'i': case 'j':
  637. X      case 'k': case 'l': case 'm':
  638. X        if (processing || message_index > 1 ||
  639. X        text[0] - 'a' >= columns || columnfill[text[0] - 'a'] >= rows)
  640. X          XBell(mydisplay, 0);
  641. X        else {
  642. X          write_prog(text[0]);
  643. X          domove(1 - c_index, text[0] - 'a');
  644. X          message(1 - message_index);
  645. X        }
  646. X        break;
  647. X      case 's': case 'S':
  648. X        if (processing || message_index > 1 ||
  649. X        stone_n[0] > 0 || stone_n[1] > 0)
  650. X          XBell(mydisplay, 0);
  651. X        else {
  652. X          GC tmpgc;
  653. X          char *stmp;
  654. X
  655. X          write_prog('s');
  656. X          tmpgc = stonegc[0];
  657. X          stonegc[0] = stonegc[1];
  658. X          stonegc[1] = tmpgc;
  659. X          stmp = playercolor[0];
  660. X          playercolor[0] = playercolor[1];
  661. X          playercolor[1] = stmp;
  662. X          stmp = messagestring[0];
  663. X          messagestring[0] = messagestring[1];
  664. X          messagestring[1] = stmp;
  665. X          c_index = 1 - c_index;
  666. X          Repaint_topwindow();
  667. X        }
  668. X        break;
  669. X      case 'N': case 'U':
  670. X        text[0] += 'a' - 'A';
  671. X      case 'n': case 'u':
  672. X      case '0': case '1': case '2': case '3': case '4':
  673. X      case '5': case '6': case '7': case '8': case '9':
  674. X        write_prog(text[0]);
  675. X        break;
  676. X      case 'C':
  677. X        {
  678. X          GC tmpgc;
  679. X          char *stmp;
  680. X
  681. X          tmpgc = stonegc[0];
  682. X          stonegc[0] = stonegc[1];
  683. X          stonegc[1] = tmpgc;
  684. X          stmp = playercolor[0];
  685. X          playercolor[0] = playercolor[1];
  686. X          playercolor[1] = stmp;
  687. X          stmp = messagestring[0];
  688. X          messagestring[0] = messagestring[1];
  689. X          messagestring[1] = stmp;
  690. X        }
  691. X        if (stone_n[0] > 0)
  692. X          XFillArcs(mydisplay, boardwindow,
  693. X            stonegc[0], stone[0], stone_n[0]);
  694. X        if (stone_n[1] > 0)
  695. X          XFillArcs(mydisplay, boardwindow,
  696. X            stonegc[1], stone[1], stone_n[1]);
  697. X        Repaint_topwindow();
  698. X        break;
  699. X      default:
  700. X        XBell(mydisplay, 0);
  701. X        break;
  702. X      }
  703. X    }
  704. X    break;
  705. X      }
  706. X    }
  707. X    XFlush(mydisplay);
  708. #ifdef NO_SELECT
  709. X    poll(pfd, npfd, 500);
  710. X    if (pfd[1].revents == POLLIN) {
  711. #else
  712. X    readfds = fullfds;
  713. #ifdef NO_FD_SET
  714. X    select(32, &readfds, 0, 0, &selectval);
  715. X    if (readfds & (1 << pipei[0])) {
  716. #else
  717. X    select(FD_SETSIZE, &readfds, (fd_set *) 0, (fd_set *) 0, &selectval);
  718. X    if (FD_ISSET(pipei[0], &readfds)) {
  719. #endif
  720. #endif
  721. X      char answer;
  722. X
  723. X      if (read(pipei[0], &answer, 1) < 1) {
  724. X    fprintf(stderr, "%s: read from xvier_prog failed\n", *argv);
  725. X    exit(1);
  726. X      }
  727. X      if (processing == 0) {
  728. X    fprintf(stderr, "%s: unexpected read from xvier_prog\n", *argv);
  729. X    goto xvier_end;
  730. X      }
  731. X      processing = 0;
  732. X      XDefineCursor(mydisplay, topwindow, cursor_normal);
  733. X      switch (answer) {
  734. X      case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
  735. X      case 'h': case 'i': case 'j': case 'k': case 'l': case 'm':
  736. X    if (answer - 'a' >= columns ||
  737. X        columnfill[answer - 'a'] >= rows) {
  738. X      fprintf(stderr, "%s: wrong move %c from xvier_prog\n",
  739. X          *argv, answer);
  740. X      goto xvier_end;
  741. X    }
  742. X    domove(c_index, answer - 'a');
  743. X    message(1 - message_index);
  744. X    break;
  745. X      case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
  746. X      case 'H': case 'I': case 'J': case 'K': case 'L': case 'M':
  747. X    if (answer - 'A' >= columns ||
  748. X        columnfill[answer - 'A'] >= rows) {
  749. X      fprintf(stderr, "%s: wrong move %c from xvier_prog\n",
  750. X          *argv, answer);
  751. X      goto xvier_end;
  752. X    }
  753. X    domove(c_index, answer - 'A');
  754. X    message(2);
  755. X    break;
  756. X      case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T':
  757. X      case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
  758. X    if (answer - 'N' >= columns ||
  759. X        columnfill[answer - 'N'] >= rows) {
  760. X      fprintf(stderr, "%s: wrong move %c from xvier_prog\n",
  761. X          *argv, answer);
  762. X      goto xvier_end;
  763. X    }
  764. X    domove(c_index, answer - 'N');
  765. X      case 'z':
  766. X    message(4);
  767. X    break;
  768. X      case 'w':
  769. X    message(3);
  770. X    break;
  771. X      case '0': case '1': case '2': case '3': case '4':
  772. X      case '5': case '6': case '7': case '8': case '9':
  773. X    levelnumstring[0] = answer;
  774. X    Repaint_topwindow();
  775. X    break;
  776. X      case 'n':
  777. X    XClearArea(mydisplay, boardwindow, 0, 0, 0, 0, False);
  778. X    XDrawArcs(mydisplay, boardwindow, textgc, holes, columns * rows);
  779. X    stone_n[0] = stone_n[1] = 0;
  780. X    for (i = 0; i < columns; i++)
  781. X      columnfill[i] = 0;
  782. X    message_index = 1 - c_index;
  783. X    Repaint_topwindow();
  784. X    break;
  785. X      case 'u':
  786. X    undomove(c_index);
  787. X      case 'v':
  788. X    undomove(1 - c_index);
  789. X    message_index = 1 - c_index;
  790. X    Repaint_topwindow();
  791. X    break;
  792. X      default:
  793. X    XBell(mydisplay, 0);
  794. X    break;
  795. X      }
  796. X    }
  797. X    if (processing)
  798. X      change_cursor();
  799. X  }
  800. X xvier_end:
  801. X  XCloseDisplay(mydisplay);
  802. X  kill(pid, SIGKILL);
  803. X  exit(0);
  804. }
  805. SHAR_EOF
  806. echo 'File xvier.c is complete' &&
  807. chmod 0644 xvier.c ||
  808. echo 'restore of xvier.c failed'
  809. Wc_c="`wc -c < 'xvier.c'`"
  810. test 39330 -eq "$Wc_c" ||
  811.     echo 'xvier.c: original size 39330, current size' "$Wc_c"
  812. rm -f _shar_wnt_.tmp
  813. fi
  814. # ============= xvier.h ==============
  815. if test -f 'xvier.h' -a X"$1" != X"-c"; then
  816.     echo 'x - skipping xvier.h (File already exists)'
  817.     rm -f _shar_wnt_.tmp
  818. else
  819. > _shar_wnt_.tmp
  820. echo 'x - extracting xvier.h (Text)'
  821. sed 's/^X//' << 'SHAR_EOF' > 'xvier.h' &&
  822. #define MAXRC 13
  823. X
  824. #if defined(hpux) || defined(__hpux)
  825. #define NO_GETDTABSIZE
  826. #define NO_FD_SET
  827. #endif
  828. X
  829. #if defined(_IBMR2)
  830. #define NO_FD_SET
  831. #endif
  832. SHAR_EOF
  833. chmod 0644 xvier.h ||
  834. echo 'restore of xvier.h failed'
  835. Wc_c="`wc -c < 'xvier.h'`"
  836. test 149 -eq "$Wc_c" ||
  837.     echo 'xvier.h: original size 149, current size' "$Wc_c"
  838. rm -f _shar_wnt_.tmp
  839. fi
  840. # ============= xvier.man ==============
  841. if test -f 'xvier.man' -a X"$1" != X"-c"; then
  842.     echo 'x - skipping xvier.man (File already exists)'
  843.     rm -f _shar_wnt_.tmp
  844. else
  845. > _shar_wnt_.tmp
  846. echo 'x - extracting xvier.man (Text)'
  847. sed 's/^X//' << 'SHAR_EOF' > 'xvier.man' &&
  848. .TH XVIER 6 "21 April 1992"
  849. .SH NAME
  850. xvier \- a X11 board game.
  851. .SH SYNOPSIS
  852. .B "xvier
  853. [
  854. .B \-display
  855. .I displayname
  856. ] [
  857. .B \-geometry
  858. .I geometry
  859. ] [
  860. .B \-fn
  861. .I fontpattern
  862. ] [
  863. .B \-iconic
  864. ] [
  865. .B \-rows
  866. .I rows
  867. ] [
  868. .B \-columns
  869. .I columns
  870. ] [
  871. .B \-prog
  872. .I programpath
  873. ] [
  874. .B \-level
  875. .I levelnumber
  876. ]
  877. .SH DESCRIPTION
  878. .I Xvier
  879. is a board game where you and the computer alternately throw stones
  880. into free columns. The stones pile up in the columns, and the goal is
  881. to get four stones in a row, in a column or diagonally. You can choose
  882. various board sizes and levels of difficulty.
  883. .LP
  884. During the game you click with the mouse onto the column where you
  885. want to put your stone. Another possibility is a lower case letter in
  886. the range 'a' to 'm' (maximally) where 'a' is the left column. If you
  887. want to change the level of difficulty, you must use the keyboard.
  888. Simply type the number of the desired level. These levels correspond
  889. to the search depth of the game program. The meaning of the command
  890. line options and buttons is given below.
  891. .LP
  892. While the game program computes a move, everything besides
  893. .I "Change"
  894. and
  895. .I "Quit"
  896. is blocked.
  897. .SH OPTIONS
  898. .TP
  899. .BI \-display " displayname"
  900. The X11 screen you want to use.
  901. .TP
  902. .BI \-geometry " geometry"
  903. The desired geometry of the game window.
  904. .TP
  905. .BI \-fn " fontpattern"
  906. A pattern describing the fonts which are used for the buttons and
  907. messages.
  908. .I Xvier
  909. chooses the biggest font that fits into the window. Therefore the
  910. pattern should describe different sizes of one font. The default is
  911. \fB*-Helvetica-Medium-R-Normal-*\fP.
  912. .TP
  913. .B \-iconic
  914. Start in iconic state.
  915. .TP
  916. .BI \-rows " rows"
  917. The number of rows of the board. The possible range is 4 to 13. The
  918. default is 6.
  919. .TP
  920. .BI \-columns " columns"
  921. The number of columns of the board. The possible range is 4 to 13. The
  922. default is 7.
  923. .TP
  924. .BI \-prog " programpath"
  925. The path of the game program.
  926. .TP
  927. .BI \-level " levelnumber"
  928. The level of difficulty to start with. The possible range is 0 to 9.
  929. The default is 0.
  930. .SH BUTTONS
  931. The keyboard equivalents of the buttons are given in brackets.
  932. .LP
  933. .IP "\fBQuit ['q' or 'Q']\fP" 20
  934. Finish the game.
  935. .IP "\fBNew ['n' or 'N']\fP" 20
  936. Start a new game.
  937. .IP "\fBUndo ['u' or 'U']\fP" 20
  938. Undo one move.
  939. .IP "\fBStart ['s' or 'S']\fP" 20
  940. Let the computer begin with the first move. The board must be empty.
  941. .IP "\fBChange ['C']\fP" 20
  942. Exchange the colours of your and the computer's stones.
  943. .SH AUTHOR
  944. .br
  945. Norbert Jung    jung@dia.informatik.uni-stuttgart.de
  946. SHAR_EOF
  947. chmod 0644 xvier.man ||
  948. echo 'restore of xvier.man failed'
  949. Wc_c="`wc -c < 'xvier.man'`"
  950. test 2486 -eq "$Wc_c" ||
  951.     echo 'xvier.man: original size 2486, current size' "$Wc_c"
  952. rm -f _shar_wnt_.tmp
  953. fi
  954. # ============= Makefile ==============
  955. if test -f 'Makefile' -a X"$1" != X"-c"; then
  956.     echo 'x - skipping Makefile (File already exists)'
  957.     rm -f _shar_wnt_.tmp
  958. else
  959. > _shar_wnt_.tmp
  960. echo 'x - extracting Makefile (Text)'
  961. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  962. # Makefile generated by imake - do not edit!
  963. # $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  964. #
  965. # The cpp used on this machine replaces all newlines and multiple tabs and
  966. # spaces in a macro expansion with a single space.  Imake tries to compensate
  967. # for this, but is not always successful.
  968. #
  969. X
  970. # -------------------------------------------------------------------------
  971. # Makefile generated from "Imake.tmpl" and </tmp/IIf.a01593>
  972. # $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  973. #
  974. # Platform-specific parameters may be set in the appropriate <vendor>.cf
  975. # configuration files.  Site-specific parameters should be set in the file
  976. # site.def.  Full rebuilds are recommended if any parameters are changed.
  977. #
  978. # If your C preprocessor does not define any unique symbols, you will need
  979. # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  980. # "make World" the first time).
  981. #
  982. X
  983. # -------------------------------------------------------------------------
  984. # site-specific configuration parameters that need to come before
  985. # the platform-specific parameters - edit site.def to change
  986. X
  987. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  988. X
  989. # -------------------------------------------------------------------------
  990. # platform-specific configuration parameters - edit sun.cf to change
  991. X
  992. # platform:  $XConsortium: sun.cf,v 1.68 91/07/30 11:34:39 rws Exp $
  993. X
  994. # operating system:  SunOS 4.1.1
  995. X
  996. # $XConsortium: sunLib.rules,v 1.6 91/03/24 17:55:58 rws Exp $
  997. X
  998. # -------------------------------------------------------------------------
  999. # site-specific configuration parameters that go after
  1000. # the platform-specific parameters - edit site.def to change
  1001. X
  1002. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  1003. X
  1004. X            SHELL = /bin/sh
  1005. X
  1006. X              TOP = .
  1007. X      CURRENT_DIR = .
  1008. X
  1009. X               AR = ar clq
  1010. X  BOOTSTRAPCFLAGS =
  1011. X               CC = cc
  1012. X               AS = as
  1013. X
  1014. X         COMPRESS = compress
  1015. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  1016. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  1017. X          INSTALL = install
  1018. X               LD = ld
  1019. X             LINT = lint
  1020. X      LINTLIBFLAG = -C
  1021. X         LINTOPTS = -axz
  1022. X               LN = ln -s
  1023. X             MAKE = make
  1024. X               MV = mv
  1025. X               CP = cp
  1026. X
  1027. X           RANLIB = ranlib
  1028. X  RANLIBINSTFLAGS =
  1029. X
  1030. X               RM = rm -f
  1031. X            TROFF = psroff
  1032. X         MSMACROS = -ms
  1033. X              TBL = tbl
  1034. X              EQN = eqn
  1035. X     STD_INCLUDES =
  1036. X  STD_CPP_DEFINES =
  1037. X      STD_DEFINES =
  1038. X EXTRA_LOAD_FLAGS =
  1039. X  EXTRA_LIBRARIES =
  1040. X             TAGS = ctags
  1041. X
  1042. X    SHAREDCODEDEF = -DSHAREDCODE
  1043. X         SHLIBDEF = -DSUNSHLIB
  1044. X
  1045. X    PROTO_DEFINES =
  1046. X
  1047. X     INSTPGMFLAGS =
  1048. X
  1049. X     INSTBINFLAGS = -m 0755
  1050. X     INSTUIDFLAGS = -m 4755
  1051. X     INSTLIBFLAGS = -m 0644
  1052. X     INSTINCFLAGS = -m 0444
  1053. X     INSTMANFLAGS = -m 0444
  1054. X     INSTDATFLAGS = -m 0444
  1055. X    INSTKMEMFLAGS = -m 4755
  1056. X
  1057. X      PROJECTROOT = /usr/X11/R5
  1058. X
  1059. X     TOP_INCLUDES = -I$(INCROOT)
  1060. X
  1061. X      CDEBUGFLAGS = -O
  1062. X        CCOPTIONS = -pipe
  1063. X
  1064. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  1065. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  1066. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  1067. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  1068. X
  1069. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  1070. X
  1071. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  1072. X
  1073. X   LDCOMBINEFLAGS = -X -r
  1074. X      DEPENDFLAGS =
  1075. X
  1076. X        MACROFILE = sun.cf
  1077. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  1078. X
  1079. X    IMAKE_DEFINES =
  1080. X
  1081. X         IRULESRC = $(CONFIGDIR)
  1082. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  1083. X
  1084. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  1085. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  1086. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  1087. X
  1088. # -------------------------------------------------------------------------
  1089. # X Window System Build Parameters
  1090. # $XConsortium: Project.tmpl,v 1.138 91/09/10 09:02:12 rws Exp $
  1091. X
  1092. # -------------------------------------------------------------------------
  1093. # X Window System make variables; this need to be coordinated with rules
  1094. X
  1095. X          PATHSEP = /
  1096. X        USRLIBDIR = /usr/X11/R5/lib
  1097. X           BINDIR = /usr/X11/R5/bin
  1098. X          INCROOT = /usr/X11/R5/include
  1099. X     BUILDINCROOT = $(TOP)
  1100. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  1101. X      BUILDINCTOP = ..
  1102. X           INCDIR = $(INCROOT)/X11
  1103. X           ADMDIR = /usr/adm
  1104. X           LIBDIR = $(USRLIBDIR)/X11
  1105. X        CONFIGDIR = $(LIBDIR)/config
  1106. X       LINTLIBDIR = $(USRLIBDIR)/lint
  1107. X
  1108. X          FONTDIR = $(LIBDIR)/fonts
  1109. X         XINITDIR = $(LIBDIR)/xinit
  1110. X           XDMDIR = $(LIBDIR)/xdm
  1111. X           TWMDIR = $(LIBDIR)/twm
  1112. X          MANPATH = /usr/X11/R5/man
  1113. X    MANSOURCEPATH = $(MANPATH)/man
  1114. X        MANSUFFIX = n
  1115. X     LIBMANSUFFIX = 3
  1116. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  1117. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  1118. X           NLSDIR = $(LIBDIR)/nls
  1119. X        PEXAPIDIR = $(LIBDIR)/PEX
  1120. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  1121. X       FONTCFLAGS = -t
  1122. X
  1123. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  1124. X
  1125. X            IMAKE = imake
  1126. X           DEPEND = makedepend
  1127. X              RGB = rgb
  1128. X
  1129. X            FONTC = bdftopcf
  1130. X
  1131. X        MKFONTDIR = mkfontdir
  1132. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier
  1133. X
  1134. X        CONFIGSRC = $(TOP)/config
  1135. X       DOCUTILSRC = $(TOP)/doc/util
  1136. X        CLIENTSRC = $(TOP)/clients
  1137. X          DEMOSRC = $(TOP)/demos
  1138. X           LIBSRC = $(TOP)/lib
  1139. X          FONTSRC = $(TOP)/fonts
  1140. X       INCLUDESRC = $(TOP)/X11
  1141. X        SERVERSRC = $(TOP)/server
  1142. X          UTILSRC = $(TOP)/util
  1143. X        SCRIPTSRC = $(UTILSRC)/scripts
  1144. X       EXAMPLESRC = $(TOP)/examples
  1145. X       CONTRIBSRC = $(TOP)/../contrib
  1146. X           DOCSRC = $(TOP)/doc
  1147. X           RGBSRC = $(TOP)/rgb
  1148. X        DEPENDSRC = $(UTILSRC)/makedepend
  1149. X         IMAKESRC = $(CONFIGSRC)
  1150. X         XAUTHSRC = $(LIBSRC)/Xau
  1151. X          XLIBSRC = $(LIBSRC)/X
  1152. X           XMUSRC = $(LIBSRC)/Xmu
  1153. X       TOOLKITSRC = $(LIBSRC)/Xt
  1154. X       AWIDGETSRC = $(LIBSRC)/Xaw
  1155. X       OLDXLIBSRC = $(LIBSRC)/oldX
  1156. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  1157. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  1158. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  1159. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  1160. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  1161. X         FSLIBSRC = $(FONTSRC)/lib/fs
  1162. X    FONTSERVERSRC = $(FONTSRC)/server
  1163. X     EXTENSIONSRC = $(TOP)/extensions
  1164. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  1165. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  1166. X
  1167. # $XConsortium: sunLib.tmpl,v 1.11 91/07/31 11:32:08 rws Exp $
  1168. X
  1169. SHLIBLDFLAGS = -assert pure-text
  1170. PICFLAGS = -pic
  1171. X
  1172. X  DEPEXTENSIONLIB =
  1173. X     EXTENSIONLIB = -lXext
  1174. X
  1175. X          DEPXLIB = $(DEPEXTENSIONLIB)
  1176. X             XLIB = $(EXTENSIONLIB) -lX11
  1177. X
  1178. X        DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV)
  1179. X           XMULIB = -lXmu
  1180. X
  1181. X       DEPOLDXLIB =
  1182. X          OLDXLIB = -loldX
  1183. X
  1184. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV)
  1185. X         XTOOLLIB = -lXt
  1186. X
  1187. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV)
  1188. X           XAWLIB = -lXaw
  1189. X
  1190. X        DEPXILIB =
  1191. X           XILIB = -lXi
  1192. X
  1193. X        SOXLIBREV = 4.10
  1194. X          SOXTREV = 4.10
  1195. X         SOXAWREV = 5.0
  1196. X        SOOLDXREV = 4.10
  1197. X         SOXMUREV = 4.10
  1198. X        SOXEXTREV = 4.10
  1199. X      SOXINPUTREV = 4.10
  1200. X
  1201. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  1202. X         XAUTHLIB =  -lXau
  1203. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  1204. X         XDMCPLIB =  -lXdmcp
  1205. X
  1206. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  1207. X           PHIGSLIB =  -lphigs
  1208. X
  1209. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  1210. X          XBSDLIB =  -lXbsd
  1211. X
  1212. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  1213. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  1214. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  1215. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  1216. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  1217. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  1218. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  1219. X
  1220. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  1221. X
  1222. X         DEPLIBS1 = $(DEPLIBS)
  1223. X         DEPLIBS2 = $(DEPLIBS)
  1224. X         DEPLIBS3 = $(DEPLIBS)
  1225. X
  1226. # -------------------------------------------------------------------------
  1227. # Imake rules for building libraries, programs, scripts, and data files
  1228. # rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  1229. X
  1230. # -------------------------------------------------------------------------
  1231. # start of Imakefile
  1232. X
  1233. # I've seen window managers which couldn't handle aspect ratio hints.
  1234. # Uncomment if you have resize problems.
  1235. #XVIER_ASPECT    = -DXVIER_WM_ASPECT_BUG
  1236. X
  1237. # Some systems don't provide FD_SET #define's. HP 9000 and IBM RS6000
  1238. # are handled in xvier.h, but on other systems you can uncomment this.
  1239. #NO_FD_SET = -DNO_FD_SET
  1240. X
  1241. # If "select" is missing, but you have "poll", try this:
  1242. #NO_SELECT = -DNO_SELECT
  1243. X
  1244. # And if "getdtablesize" is missing, use the following:
  1245. #NO_GETDTABSIZE = -DNO_GETDTABSIZE
  1246. X
  1247. PROGNAME    = $(LIBDIR)$(PATHSEP)xvier_prog
  1248. DEFINES        = $(XVIER_ASPECT) $(NO_FD_SET) $(NO_SELECT) \
  1249. X            $(NO_GETDTABSIZE) -DPROGNAME=\"$(PROGNAME)\"
  1250. X
  1251. PROGRAMS    = xvier xvier_prog
  1252. X
  1253. SRCS1        = xvier.c
  1254. OBJS1        = xvier.o
  1255. SRCS2        = vierinit.c vier.c
  1256. OBJS2        = vierinit.o vier.o
  1257. X
  1258. X OBJS = $(OBJS1) $(OBJS2) $(OBJS3)
  1259. X SRCS = $(SRCS1) $(SRCS2) $(SRCS3)
  1260. X
  1261. all:: $(PROGRAMS)
  1262. X
  1263. xvier: $(OBJS1) $(DEPLIBS1)
  1264. X    $(RM) $@
  1265. X    $(CC) -o $@ $(LDOPTIONS) $(OBJS1)  $(XLIB) $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  1266. X
  1267. install:: xvier
  1268. X    @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \
  1269. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi
  1270. X    $(INSTALL) -c $(INSTPGMFLAGS)  xvier $(DESTDIR)$(BINDIR)
  1271. X
  1272. install.man:: xvier.man
  1273. X    @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \
  1274. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi
  1275. X    $(INSTALL) -c $(INSTMANFLAGS) xvier.man $(DESTDIR)$(MANDIR)/xvier.$(MANSUFFIX)
  1276. X
  1277. saber_xvier:: $(SRCS1)
  1278. X    # load $(ALLDEFINES) $(SRCS1)  $(XLIB) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  1279. X
  1280. osaber_xvier:: $(OBJS1)
  1281. X    # load $(ALLDEFINES) $(OBJS1)  $(XLIB) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  1282. X
  1283. depend::
  1284. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  1285. X
  1286. lint:
  1287. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  1288. lint1:
  1289. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  1290. X
  1291. clean::
  1292. X    $(RM) $(PROGRAMS)
  1293. X
  1294. xvier_prog:  $(OBJS2)
  1295. X    $(RM) $@
  1296. X    $(CC) -o $@  $(OBJS2) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  1297. X
  1298. clean::
  1299. X    $(RM) xvier_prog
  1300. X
  1301. install:: xvier_prog
  1302. X    @if [ -d $(DESTDIR) $(PROGNAME) ]; then set +x; \
  1303. X    else (set -x; $(MKDIRHIER) $(DESTDIR) $(PROGNAME)); fi
  1304. X    $(INSTALL) -c $(INSTPGMFLAGS)  xvier_prog $(DESTDIR) $(PROGNAME)
  1305. X
  1306. # -------------------------------------------------------------------------
  1307. # common rules for all Makefiles - do not edit
  1308. X
  1309. emptyrule::
  1310. X
  1311. clean::
  1312. X    $(RM_CMD) "#"*
  1313. X
  1314. Makefile::
  1315. X    -@if [ -f Makefile ]; then set -x; \
  1316. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  1317. X    else exit 0; fi
  1318. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  1319. X
  1320. tags::
  1321. X    $(TAGS) -w *.[ch]
  1322. X    $(TAGS) -xw *.[ch] > TAGS
  1323. X
  1324. saber:
  1325. X    # load $(ALLDEFINES) $(SRCS)
  1326. X
  1327. osaber:
  1328. X    # load $(ALLDEFINES) $(OBJS)
  1329. X
  1330. # -------------------------------------------------------------------------
  1331. # empty rules for directories that do not have SUBDIRS - do not edit
  1332. X
  1333. install::
  1334. X    @echo "install in $(CURRENT_DIR) done"
  1335. X
  1336. install.man::
  1337. X    @echo "install.man in $(CURRENT_DIR) done"
  1338. X
  1339. Makefiles::
  1340. X
  1341. includes::
  1342. X
  1343. # -------------------------------------------------------------------------
  1344. # dependencies generated by makedepend
  1345. X
  1346. SHAR_EOF
  1347. chmod 0644 Makefile ||
  1348. echo 'restore of Makefile failed'
  1349. Wc_c="`wc -c < 'Makefile'`"
  1350. test 11332 -eq "$Wc_c" ||
  1351.     echo 'Makefile: original size 11332, current size' "$Wc_c"
  1352. rm -f _shar_wnt_.tmp
  1353. fi
  1354. rm -f _shar_seq_.tmp
  1355. echo You have unpacked the last part
  1356. exit 0
  1357. -- 
  1358. ---
  1359. Senior Systems Scientist        mail: dcmartin@msi.com
  1360. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  1361. 796 North Pastoria Avenue        at&t: 408/522-9236
  1362.