Annotation of coherent/a/usr/spool/uucppublic/warp9.tar, revision 1.1
1.1 ! root 1: warp/README 644 171 5 7235 5121747671 5735 Warp Kit, Version 7.0
! 2:
! 3: Copyright (c) 1986, Larry Wall
! 4:
! 5: You may copy the warp kit in whole or in part as long as you don't try to
! 6: make money off it, or pretend that you wrote it.
! 7: --------------------------------------------------------------------------
! 8:
! 9: Warp is a real-time space war game that doesn't get boring very quickly.
! 10: Read warp.doc and the manual page for more information.
! 11:
! 12: Warp will probably not run on V7 systems that don't have a non-blocking read,
! 13: or on machines with a small address space like the PDP-11. Caveat Emptor.
! 14:
! 15: Please read all the directions below before you proceed any further, and
! 16: then follow them carefully. Failure to do so may void your warranty. :-)
! 17:
! 18: After you have unpacked your kit, you should have all the files listed
! 19: in MANIFEST.
! 20:
! 21: IMPORTANT
! 22:
! 23: You must choose the uid that you want warp to run under, since warp runs
! 24: setuid to protect its files. Choose a uid (not root) that is used only
! 25: by trustworthy persons. If you do your make install as root, the installed
! 26: version will be chowned to this uid. Otherwise, you should login to your
! 27: selected uid before proceeding. The Configure script will ask you which
! 28: uid you want warp to run under.
! 29:
! 30: Installation
! 31:
! 32: 1) Run Configure. This will figure out various things about your system.
! 33: Some things Configure will figure out for itself, other things it will
! 34: ask you about. It will then proceed to make config.h, config.sh, and
! 35: Makefile.
! 36:
! 37: You might possibly have to trim # comments from the front of Configure
! 38: if your sh doesn't handle them, but all other # comments will be taken
! 39: care of.
! 40:
! 41: (If you don't have sh, you'll have to copy the sample file config.H to
! 42: config.h and edit the config.h to reflect your system's peculiarities.)
! 43:
! 44: 2) Glance through config.h to make sure system dependencies are correct.
! 45: Most of them should have been taken care of by running the Configure script.
! 46:
! 47: If you have any additional changes to make to the C definitions, they
! 48: can be done in the Makefile, or in config.h. Bear in mind that they will
! 49: get undone next time you run Configure.
! 50:
! 51: 3) make depend
! 52:
! 53: This will look for all the includes and modify Makefile accordingly.
! 54: Configure will offer to do this for you.
! 55:
! 56: 4) make
! 57:
! 58: This will attempt to make warp in the current directory.
! 59:
! 60: 5) make install
! 61:
! 62: This will put warp into a public directory (normally /usr/games).
! 63: It will also try to put the man pages in a reasonable place. It will not
! 64: nroff the man page, however. You may need to be root to do this. If
! 65: you are not root, you must own the directories in question and you should
! 66: ignore any messages about chown not working.
! 67:
! 68: 6) Read the manual entry before running warp.
! 69:
! 70: 7) Feel free to edit warp.news.
! 71:
! 72: 8) IMPORTANT! Help save the world! Communicate any problems and
! 73: suggested patches to me, [email protected] (Larry Wall), so we can
! 74: keep the world in sync. If you have a problem, there's someone else
! 75: out there who either has had or will have the same problem.
! 76:
! 77: If possible, send in patches such that the patch program will apply them.
! 78: Context diffs are the best, then normal diffs. Don't send ed scripts--
! 79: I've probably changed my copy since the version you have.
! 80:
! 81: Watch for warp patches in comp.sources.bugs. Patches will generally be
! 82: in a form usable by the patch program. If you are just now bringing up
! 83: warp and aren't sure how many patches there are, write to me and I'll
! 84: send any you don't have. Your current patch level is shown in patchlevel.h.
! 85:
! 86:
! 87: NEW FEATURES IN THIS RELEASE
! 88:
! 89: Uses a Configure script for greater portability.
! 90: Space Amoebas!!!
! 91: Pirates
! 92: Friendly Freighters
! 93: Harry Mudd
! 94: Damage
! 95: Keyboard mapping
! 96: hanged my copy since the version you have.
! 97:
! 98: Watch for warp patches in comp.sources.bugs. Patches will generally be
! 99: in a form usable by the patch program. If you are just now bringing up
! 100: warp and aren't sure how many patches there are, write to me and I'll
! 101: send any you don't have. Your current patch level is shown in patchlevel.h.
! 102:
! 103:
! 104: NEwarp/score.c 644 171 5 44335 5121747700 6347 /* $Header: score.c,v 7.0.1.2 86/10/20 12:06:56 lwall Exp $ */
! 105:
! 106: /* $Log: score.c,v $
! 107: * Revision 7.0.1.2 86/10/20 12:06:56 lwall
! 108: * Made all exits reset tty.
! 109: *
! 110: * Revision 7.0.1.1 86/10/16 10:52:47 lwall
! 111: * Added Damage. Fixed random bugs.
! 112: *
! 113: * Revision 7.0 86/10/08 15:13:14 lwall
! 114: * Split into separate files. Added amoebas and pirates.
! 115: *
! 116: */
! 117:
! 118: #include "EXTERN.h"
! 119: #include "warp.h"
! 120: #include "intrp.h"
! 121: #include "object.h"
! 122: #include "play.h"
! 123: #include "sig.h"
! 124: #include "term.h"
! 125: #include "us.h"
! 126: #include "util.h"
! 127: #include "weapon.h"
! 128: #include "INTERN.h"
! 129: #include "score.h"
! 130:
! 131: void
! 132: score_init()
! 133: {
! 134: Reg1 char *s;
! 135: Reg2 int i;
! 136: FILE *savfil;
! 137:
! 138: if (stat(SAVEDIR,&filestat)) {
! 139: printf("Cannot access %s\r\n",SAVEDIR);
! 140: finalize(1);
! 141: }
! 142: if (filestat.st_uid != geteuid()) {
! 143: #ifdef GETPWENT
! 144: printf("Warp will not run right without being setuid.\r\n");
! 145: #else
! 146: getpw(filestat.st_uid, spbuf);
! 147: s = index(spbuf, ':');
! 148: *s = '\0';
! 149: printf("Warp will not run right without being setuid to %s.\r\n",spbuf);
! 150: #endif
! 151: finalize(1);
! 152: }
! 153: if ((filestat.st_mode & 0605) != 0605) {
! 154: printf("%s is not protected correctly (must be u+rw o+rx).\r\n",SAVEDIR);
! 155: finalize(1);
! 156: }
! 157:
! 158: #ifdef SCOREFULL
! 159: interp(longlognam, sizeof longlognam, "%N");
! 160: for (i=strlen(longlognam); i<24; i++)
! 161: longlognam[i] = ' '; /* make sure it is 24 long for strncmp */
! 162: longlognam[24] = '\0';
! 163: #else
! 164: interp(longlognam, sizeof longlognam, "%L");
! 165: for (i=strlen(longlognam); i<8; i++)
! 166: longlognam[i] = ' '; /* make sure it is 8 long for strncmp */
! 167: longlognam[8] = '\0';
! 168: #endif
! 169:
! 170: if (scorespec)
! 171: wscore();
! 172:
! 173: Sprintf(savefilename, "save.%s", logname);
! 174:
! 175: savfil = experimenting ? NULL : fopen(savefilename,"r");
! 176: if (savfil != NULL && fgets(spbuf,100,savfil) != NULL) {
! 177: char tmpbuf[80];
! 178:
! 179: spbuf[strlen(spbuf)-1] = '\0';
! 180: if (fgets(tmpbuf,80,savfil) != NULL) {
! 181: int processnum;
! 182:
! 183: tmpbuf[strlen(tmpbuf)-1] = '\0';
! 184: printf("You seem to have left a game %s.\r\n",tmpbuf+9);
! 185: s = index(tmpbuf+9, ',');
! 186: *s = '\0';
! 187: processnum = atoi(s+11);
! 188: if (kill(processnum, SIGINT)) {
! 189: /* does process not exist? */
! 190: /* (warp ignores SIGINT) */
! 191: printf("\r\n\
! 192: That process does not seem to exist anymore, so you'll have to start the\r\n");
! 193: printf(
! 194: "last wave over.\r\n\n");
! 195: printf(
! 196: " [type anything to continue]");
! 197: Fflush(stdout);
! 198: eat_typeahead();
! 199: getcmd(tmpbuf);
! 200: if (*tmpbuf == INTRCH)
! 201: finalize(0);
! 202: printf("\r\n");
! 203: }
! 204: else {
! 205: if (strcmp(term+8,tmpbuf+23)) {
! 206: printf(
! 207: "That is not your current terminal--you are on %s.\r\n", term+5);
! 208: printf("\r\nYour options:\r\n");
! 209: printf(" 1) Exit and find the terminal it's running on\r\n");
! 210: }
! 211: else {
! 212: printf("\r\nYour options:\r\n");
! 213: printf(" 1) Exit and try to foreground it\r\n");
! 214: }
! 215: printf(" 2) Let me terminate the other game\r\n\n");
! 216: printf("What do you want to do? ");
! 217: Fflush(stdout);
! 218: eat_typeahead();
! 219: getcmd(tmpbuf);
! 220: printf("\r\n");
! 221: if (*tmpbuf == INTRCH)
! 222: finalize(0);
! 223: if (*tmpbuf == '1') {
! 224: printf(
! 225: "If you don't succeed, come back and do option 2 instead. Good luck.\r\n");
! 226: finalize(0);
! 227: }
! 228: printf(
! 229: "Ok, hang on a few moments \r\n");
! 230: Fclose(savfil);
! 231: if (kill(processnum, SIGQUIT)) {
! 232: printf("Unable to kill process #%d!\r\n",processnum);
! 233: roundsleep(2);
! 234: }
! 235: else {
! 236: #ifdef SIGCONT
! 237: kill(processnum, SIGCONT);
! 238: #endif
! 239: for (i=15; i; --i) {
! 240: sleep(1);
! 241: if (kill(processnum,SIGINT))
! 242: /* does process not exist? */
! 243: /* (warp ignores SIGINT) */
! 244: break;
! 245: }
! 246: didkill++;
! 247: }
! 248: savfil = fopen(savefilename,"r");
! 249: if (savfil != NULL) {
! 250: Fgets(spbuf,100,savfil);
! 251: }
! 252: }
! 253: }
! 254: }
! 255: else
! 256: savfil = NULL;
! 257: if (savfil == NULL) {
! 258: totalscore = smarts = cumsmarts = wave = 0;
! 259: numents = 5;
! 260: numbases = 3;
! 261: }
! 262: else {
! 263: totalscore = atol(spbuf+9);
! 264: smarts = atoi(spbuf+20);
! 265: cumsmarts = atoi(spbuf+24);
! 266: numents = atoi(spbuf+30);
! 267: numbases = atoi(spbuf+33);
! 268: wave = atoi(spbuf+36);
! 269: apolspec = (spbuf[40] == 'a');
! 270: beginner = (spbuf[41] == 'b');
! 271: crushspec = (spbuf[42] == 'c');
! 272: gornspec = (spbuf[43] == 'g');
! 273: massacre = (spbuf[44] == 'm');
! 274: romspec = (spbuf[45] == 'r');
! 275: tholspec = (spbuf[46] == 't');
! 276: lowspeed = (spbuf[47] == 'l') || lowspeed;
! 277: amoebaspec = (spbuf[48] == '&');
! 278: Fclose(savfil);
! 279: }
! 280:
! 281: if (!ismarts) {
! 282: ismarts = 1;
! 283: clear();
! 284: page(NEWSFILE,FALSE);
! 285: if (smarts) {
! 286: printf("\r\nSaved game: SCORE DIFF CUMDIFF ENTERPRISES BASES WAVE");
! 287: printf("\r\n %7ld %2d %4d %1d %1d %3d",
! 288: totalscore,smarts,cumsmarts,numents,numbases,wave);
! 289: }
! 290: printf("\r\nWould you like instructions? ");
! 291: Fflush(stdout);
! 292: eat_typeahead();
! 293: getcmd(buf);
! 294: printf("\r\n");
! 295: if (*buf == INTRCH)
! 296: finalize(0);
! 297: if (*buf == 'Y' || *buf == 'y') {
! 298: page(HELPFILE,FALSE);
! 299: printf("\r\nWould you like to play easy games for a while? ");
! 300: Fflush(stdout);
! 301: eat_typeahead();
! 302: getcmd(buf);
! 303: printf("\r\n");
! 304: if (*buf == 'Y' || *buf == 'y') {
! 305: beginner = TRUE;
! 306: lowspeed = TRUE;
! 307: }
! 308: }
! 309: }
! 310: if (!smarts)
! 311: smarts = ismarts;
! 312: }
! 313:
! 314: void
! 315: wscore()
! 316: {
! 317: clear();
! 318: printf(" TOP WARPISTS\r\n\n");
! 319: printf("RANK WHO AKA SCORE DIFF CUMDIFF WHEN\r\n");
! 320: page(SCOREBOARD,TRUE);
! 321: printf(" [Type anything to continue]");
! 322: Fflush(stdout);
! 323: getcmd(spbuf);
! 324: if (*spbuf == INTRCH)
! 325: finalize(0);
! 326: clear();
! 327: printf(" TOP LOW-SPEED WARPISTS\r\n\n");
! 328: printf("RANK WHO AKA SCORE DIFF CUMDIFF WHEN\r\n");
! 329: page(LSCOREBOARD,TRUE);
! 330: printf(" [Type anything to continue]");
! 331: Fflush(stdout);
! 332: getcmd(spbuf);
! 333: if (*spbuf == INTRCH)
! 334: finalize(0);
! 335: clear();
! 336: printf(" TOP FUNNY WARPISTS\r\n\n");
! 337: printf("RANK WHO AKA SCORE DIFF CUMDIFF WHEN\r\n");
! 338: page(FSCOREBOARD,TRUE);
! 339: printf(" [Type anything to continue]");
! 340: Fflush(stdout);
! 341: getcmd(spbuf);
! 342: if (*spbuf == INTRCH)
! 343: finalize(0);
! 344: clear();
! 345: printf(" GAMES SAVED OR IN PROGRESS\r\n\n");
! 346: printf("WHO SCORE DF CDF E B WV FLAGS\r\n");
! 347: resetty();
! 348: Sprintf(spbuf,"/bin/cat %ssave.*",SAVEDIR);
! 349: #ifndef lint
! 350: execl("/bin/sh", "sh", "-c", spbuf, 0);
! 351: #endif
! 352: finalize(1);
! 353: }
! 354:
! 355:
! 356: void
! 357: display_status()
! 358: {
! 359: Reg1 int tmp;
! 360: static char *status_names[] = {"Impl", "Warp", "Base", "****" };
! 361:
! 362: if (oldstatus != status) {
! 363: Sprintf(spbuf,"%-4s",status_names[status]);
! 364: mvaddstr(0,0, spbuf);
! 365: oldstatus = status;
! 366: }
! 367: if (ent) {
! 368: if (ent->energy != oldeenergy) {
! 369: oldeenergy = ent->energy;
! 370: Sprintf(spbuf,"%4d",oldeenergy);
! 371: mvaddstr(0,8, spbuf);
! 372: }
! 373: if (etorp != oldetorp) {
! 374: Sprintf(spbuf,"%2d",etorp);
! 375: mvaddstr(0,13, spbuf);
! 376: oldetorp = etorp;
! 377: }
! 378: }
! 379: else {
! 380: if (etorp >= 0) {
! 381: etorp = -1;
! 382: mvaddstr(0,8,"*******");
! 383: damage = 0;
! 384: }
! 385: }
! 386: if (base) {
! 387: if (base->energy != oldbenergy) {
! 388: oldbenergy = base->energy;
! 389: Sprintf(spbuf,"%5d",oldbenergy);
! 390: mvaddstr(0,19, spbuf);
! 391: }
! 392: if (btorp != oldbtorp) {
! 393: Sprintf(spbuf,"%3d",btorp);
! 394: mvaddstr(0,25, spbuf);
! 395: oldbtorp = btorp;
! 396: }
! 397: }
! 398: else {
! 399: if (btorp >= 0) {
! 400: btorp = -1;
! 401: mvaddstr(0,19,"*********");
! 402: }
! 403: }
! 404: if (damage) {
! 405: if (!olddamage)
! 406: mvaddstr(0,42,"*** ");
! 407: if (damage > 1 || !damflag[dam]) {
! 408: do {
! 409: if (++dam == MAXDAMAGE)
! 410: dam = 0;
! 411: } while (!damflag[dam]);
! 412: }
! 413: if (!--damflag[dam]) {
! 414: olddamage = damage;
! 415: damage--;
! 416: Sprintf(spbuf,"%s OK *** ",dammess[dam]);
! 417: spbuf[15] = '\0';
! 418: mvaddstr(0,46,spbuf);
! 419: }
! 420: else if (dam == NOSHIELDS) {
! 421: olddamage = damage;
! 422: tmp = (34 - damflag[dam]) * 3 - rand_mod(3);
! 423: if (tmp < 0)
! 424: tmp = 0;
! 425: Sprintf(spbuf,"%d%% %s *** ",tmp,dammess[dam]);
! 426: spbuf[15] = '\0';
! 427: mvaddstr(0,46,spbuf);
! 428: }
! 429: else if (dam != lastdam || !olddamage) {
! 430: olddamage = damage;
! 431: Sprintf(spbuf,"NO %s *** ",dammess[dam]);
! 432: spbuf[15] = '\0';
! 433: mvaddstr(0,46,spbuf);
! 434: }
! 435: if (status < 2) {
! 436: if (dam == NOIMPULSE && !entmode)
! 437: status = entmode = 1;
! 438: if (dam == NOWARP && entmode)
! 439: status = entmode = 0;
! 440: }
! 441: tmp = damflag[dam] * damage;
! 442: Sprintf(spbuf,"%3d.%1d ETR",tmp/10,tmp%10);
! 443: mvaddstr(0,69,spbuf);
! 444: lastdam = dam;
! 445: }
! 446: else {
! 447: if (olddamage) {
! 448: Sprintf(spbuf,"Stars: %-3d Stardate",numstars);
! 449: mvaddstr(0,42,spbuf);
! 450: lastdam = -1;
! 451: olddamage = 0;
! 452: oldcurscore = -1;
! 453: }
! 454: else if (numstars != oldstrs) {
! 455: Sprintf(spbuf,"%-3d",numstars);
! 456: mvaddstr(0,49, spbuf);
! 457: }
! 458: oldstrs = numstars;
! 459: }
! 460: if (numenemies != oldenemies) {
! 461: Sprintf(spbuf,"%-3d",numenemies);
! 462: mvaddstr(0,38, spbuf);
! 463: oldenemies = numenemies;
! 464: }
! 465: if (tmp = timer%10) {
! 466: Sprintf(spbuf,"%1d",tmp);
! 467: mvaddstr(0,67, spbuf);
! 468: }
! 469: else {
! 470: Sprintf(spbuf,"%5d.%1d",timer/10+smarts*100,tmp);
! 471: mvaddstr(0,61, spbuf);
! 472: }
! 473: if ((!damage || !damflag[dam]) && curscore != oldcurscore) {
! 474: Sprintf(spbuf,"%9ld",curscore);
! 475: mvaddstr(0,69, spbuf);
! 476: oldcurscore = curscore;
! 477: }
! 478: }
! 479:
! 480: void
! 481: wavescore()
! 482: {
! 483: double power, effectscore, starscore, pi_over_2;
! 484: long bonuses;
! 485: long tmp;
! 486: FILE *mapfp;
! 487: int row;
! 488: double pow();
! 489: #ifndef lint
! 490: double atan2();
! 491: #endif
! 492:
! 493: clear();
! 494: if (curscore > possiblescore)
! 495: curscore = possiblescore;
! 496: pi_over_2 = 3.14159265 / 2.0;
! 497: power = pow((double)inumenemies+ /* total number of enemies */
! 498: inumroms*2+ /* count roms 3 times */
! 499: inumgorns+ /* count gorns 2 times */
! 500: inumthols+ /* count thols 2 times */
! 501: inumapollos*4+ /* count apollo 5 times */
! 502: inumcrushes*3+ /* count crushers 4 times */
! 503: inumamoebas*5 /* count amoebas 6 times */
! 504: , 0.50) * /* skew it a little */
! 505: (double)smarts; /* average energy and intelligence */
! 506: if (inumstars < 350 && inumenemies > 5)
! 507: power += (350.0 - (double)inumstars) * ((double)inumenemies - 5.0);
! 508: if (inumstars > 850 && inumenemies > 2)
! 509: power += ((double)inumstars - 850.0) * ((double)inumenemies - 2.0);
! 510: #ifndef lint
! 511: effectscore = ((double)curscore / possiblescore) *
! 512: atan2(power, (double) timer + 1.0) / pi_over_2;
! 513: #else
! 514: effectscore = pi_over_2;
! 515: #endif
! 516: if (inumstars)
! 517: starscore = (double) numstars / (double) inumstars;
! 518: else
! 519: starscore = 1.0;
! 520: wave++;
! 521: Sprintf(spbuf,"Wave = %d, Difficulty = %d, cumulative difficulty = %d",
! 522: wave, smarts, cumsmarts);
! 523: mvaddstr(1, 13+(smarts<10), spbuf);
! 524: mvaddstr( 4, 68, " BONUS");
! 525: Sprintf(spbuf,"Efficiency rating: %1.8f (diff=%0.2f,time=%d)",
! 526: effectscore, power, timer + 1);
! 527: mvaddstr( 5,5, spbuf);
! 528: if (effectscore < 0.8)
! 529: bonuses = tmp = 0;
! 530: else
! 531: bonuses = tmp = (long) ((effectscore-0.8) * smarts * 1000);
! 532: Sprintf(spbuf, "%6ld", tmp);
! 533: mvaddstr( 5, 68, spbuf);
! 534: Sprintf(spbuf,"Star save ratio: %1.8f (%d/%d)",
! 535: starscore, numstars, inumstars);
! 536: mvaddstr( 6,5, spbuf);
! 537: #ifndef lint
! 538: bonuses += tmp = (long) (((double)curscore / possiblescore) *
! 539: (starscore*starscore) * smarts * 20);
! 540: #endif
! 541: Sprintf(spbuf, "%6ld", tmp);
! 542: mvaddstr( 6, 68, spbuf);
! 543: row = 7;
! 544: if (inuminhab != numinhab) {
! 545: Sprintf(spbuf, "Inhabited stars depopulated: %5d", inuminhab-numinhab);
! 546: mvaddstr(row,5, spbuf);
! 547: bonuses += tmp = (long) (inuminhab-numinhab) * -500;
! 548: Sprintf(spbuf, "%6ld", tmp);
! 549: mvaddstr(row, 68, spbuf);
! 550: row++;
! 551: }
! 552: if (inumfriends != numfriends) {
! 553: Sprintf(spbuf, "Friendly craft destroyed: %5d",
! 554: inumfriends-numfriends);
! 555: mvaddstr(row,5, spbuf);
! 556: bonuses += tmp = (long) (inumfriends-numfriends) * -250;
! 557: Sprintf(spbuf, "%6ld", tmp);
! 558: mvaddstr(row, 68, spbuf);
! 559: row++;
! 560: }
! 561: if (deadmudds) {
! 562: mvaddstr(row,5,"For destroying Harry Mudd:");
! 563: bonuses += tmp = (long) rand_mod(deadmudds * 20 + 1) - deadmudds*10;
! 564: Sprintf(spbuf, "%6ld", tmp);
! 565: mvaddstr(row, 68, spbuf);
! 566: row++;
! 567: }
! 568: if (bombed_out) {
! 569: mvaddstr(row,5, "For running away from reality:");
! 570: bonuses += tmp = (long) -possiblescore/2;
! 571: Sprintf(spbuf, "%6ld", tmp);
! 572: mvaddstr(row, 68, spbuf);
! 573: row++;
! 574: }
! 575: if (row < 9)
! 576: row++;
! 577: Sprintf(spbuf, "Enterprise: %-9s%5d remaining",
! 578: !ient?"":ent?"saved":"destroyed", numents);
! 579: mvaddstr(row,5, spbuf);
! 580: bonuses += tmp = ent && !bombed_out ? (smarts+1)*15 : 0;
! 581: Sprintf(spbuf, "%6ld", tmp);
! 582: mvaddstr(row, 68, spbuf);
! 583: row++;
! 584: Sprintf(spbuf, "Base: %-9s %5d remaining",
! 585: !ibase?"":base?"saved":"destroyed", numbases);
! 586: mvaddstr(row,5, spbuf);
! 587: bonuses += tmp = base && !bombed_out ? (smarts+1)*10 : 0;
! 588: Sprintf(spbuf, "%6ld", tmp);
! 589: mvaddstr(row, 68, spbuf);
! 590: if (beginner) {
! 591: mvaddstr(13+(row>11),19, "(Special games count only a tenth as much)");
! 592: curscore /= 10;
! 593: bonuses /= 10;
! 594: }
! 595: Sprintf(spbuf, "Previous point total:%10ld",lastscore);
! 596: mvaddstr(15,24, spbuf);
! 597: Sprintf(spbuf, "Points this round: %10ld",curscore);
! 598: mvaddstr(16,24, spbuf);
! 599: Sprintf(spbuf, "Bonuses: %10ld",bonuses);
! 600: mvaddstr(17,24, spbuf);
! 601: totalscore = lastscore + curscore + bonuses;
! 602: Sprintf(spbuf, "New point total: %10ld",totalscore);
! 603: mvaddstr(18,24, spbuf);
! 604: if (lastscore / ENTBOUNDARY < totalscore / ENTBOUNDARY) {
! 605: mvaddstr(row-1,42,"+ 1 new");
! 606: numents++;
! 607: }
! 608: else if (numents>0 &&
! 609: lastscore / ENTBOUNDARY > totalscore / ENTBOUNDARY) {
! 610: mvaddstr(row-1,42,"- 1 obsolete");
! 611: numents--;
! 612: }
! 613: if (lastscore / BASEBOUNDARY < totalscore / BASEBOUNDARY) {
! 614: mvaddstr(row,42,"+ 1 new");
! 615: numbases++;
! 616: }
! 617: else if (numbases>0 &&
! 618: lastscore / BASEBOUNDARY > totalscore / BASEBOUNDARY) {
! 619: mvaddstr(row,42,"- 1 obsolete");
! 620: numbases--;
! 621: }
! 622: if (starscore < 0.8 && inumstars > 200 && numstars > 50) {
! 623: Sprintf(spbuf, "smap.%d",rand_mod(MAPS-PERMMAPS)+PERMMAPS);
! 624: if ((mapfp = fopen(spbuf,"w")) != NULL) {
! 625: Reg1 OBJECT *obj;
! 626:
! 627: fprintf(mapfp,"%d\n",numstars);
! 628: for (obj = root.next; obj != &root; obj = obj->next) {
! 629: if (obj->type == Star) {
! 630: fprintf(mapfp,"%d %d\n",obj->posy,obj->posx);
! 631: }
! 632: }
! 633: Fclose(mapfp);
! 634: }
! 635: }
! 636: }
! 637:
! 638: void
! 639: score()
! 640: {
! 641: char tmp, *retval, cdate[30];
! 642: Reg1 FILE *logfd;
! 643: Reg2 FILE *outfd;
! 644: Reg3 int i;
! 645: long nowtime, time();
! 646: char *scoreboard;
! 647:
! 648: for (i=0; link(LOGFILE, LOCKFILE) == -1 && i<10; i++)
! 649: sleep(1);
! 650: nowtime = time((long *)0);
! 651: strcpy(cdate,ctime(&nowtime));
! 652: if ((logfd = fopen(LOGFILE,"a")) != NULL) {
! 653: fprintf(logfd,
! 654: "%-24s%-9s%7ld%c%2d %4d %s",
! 655: realname, logname, totalscore, c,smarts, cumsmarts, cdate);
! 656: Fclose(logfd);
! 657: }
! 658: strcpy(cdate+11,cdate+20);
! 659: if (beginner)
! 660: scoreboard = FSCOREBOARD;
! 661: else if (lowspeed)
! 662: scoreboard = LSCOREBOARD;
! 663: else
! 664: scoreboard = SCOREBOARD;
! 665: if (eaccess(scoreboard,0)) {
! 666: if ((logfd = fopen(scoreboard,"w")) != NULL)
! 667: Fclose(logfd);
! 668: }
! 669: if ((logfd = fopen(scoreboard,"r")) != NULL &&
! 670: (outfd = fopen(TMPSCOREBOARD,"w")) != NULL) {
! 671: for (i=0; i<20; i++) {
! 672: if ((retval = fgets(buf, 100, logfd)) == NULL)
! 673: break;
! 674: if (atol(buf+32) < totalscore)
! 675: break;
! 676: if (strnEQ(buf+COMPOFF,COMPNAME,COMPLEN)) {
! 677: i = 100;
! 678: break;
! 679: }
! 680: fprintf(outfd, "%s", buf);
! 681: }
! 682: if (i == 100) {
! 683: mvaddstr(20,21, "You did not better your previous score");
! 684: Fclose(outfd);
! 685: unlink(TMPSCOREBOARD);
! 686: }
! 687: else if (i < 20) {
! 688: fprintf(outfd, "%-24s%-8s%8ld%c %2d %4d %s",
! 689: realname, logname, totalscore, c,smarts, cumsmarts, cdate);
! 690: i++;
! 691: Sprintf(spbuf, " Congratulations--you've placed %d%s",
! 692: i, i==1?"st":(i==2?"nd":(i==3?"rd":"th")));
! 693: if (retval != NULL) {
! 694: if (strnNE(buf+COMPOFF,COMPNAME,COMPLEN)) {
! 695: fprintf(outfd, "%s", buf);
! 696: i++;
! 697: }
! 698: else
! 699: strcpy(spbuf,"Congratulations--you've bettered your score");
! 700: while (i<20) {
! 701: if (fgets(buf, 100, logfd) == NULL)
! 702: break;
! 703: if (strnNE(buf+COMPOFF,COMPNAME,COMPLEN)) {
! 704: fprintf(outfd, "%s", buf);
! 705: i++;
! 706: }
! 707: }
! 708: }
! 709: mvaddstr(20,19, spbuf);
! 710: Fclose(logfd);
! 711: Fclose(outfd);
! 712: while (unlink(scoreboard) == 0)
! 713: ;
! 714: link(TMPSCOREBOARD,scoreboard);
! 715: unlink(TMPSCOREBOARD);
! 716: logfd = fopen(scoreboard,"r");
! 717: }
! 718: else {
! 719: mvaddstr(20,22,"You did not place within the top 20");
! 720: Fclose(outfd);
! 721: }
! 722: }
! 723: else {
! 724: Sprintf(spbuf,"(Cannot access %s file, error %d)",
! 725: (logfd==NULL?"log":"tmp"),errno);
! 726: mvaddstr(20,22,spbuf);
! 727: }
! 728: move(23,0,0);
! 729: erase_eol();
! 730: mvaddstr(23,11,
! 731: "[Hit space for scoreboard, 'r' for new game, 'q' to quit]");
! 732: unlink(LOCKFILE);
! 733: Fflush(stdout);
! 734: eat_typeahead();
! 735: do {
! 736: getcmd(&tmp);
! 737: } while (tmp != INTRCH && tmp != BREAKCH && !index(" rqQ",tmp));
! 738: if (index("qQr",tmp)) {
! 739: justonemoretime = (tmp == 'r');
! 740: if (logfd != NULL)
! 741: Fclose(logfd);
! 742: }
! 743: else {
! 744: clear();
! 745: if (logfd != NULL) {
! 746: fseek(logfd, 0, 0);
! 747: if (beginner)
! 748: mvaddstr(0,31,"TOP FUNNY WARPISTS");
! 749: else if (lowspeed)
! 750: mvaddstr(0,29,"TOP LOW-SPEED WARPISTS");
! 751: else
! 752: mvaddstr(0,33,"TOP WARPISTS");
! 753: mvaddstr(2,0,"RANK WHO AKA SCORE DIFF CUMDIFF WHEN");
! 754: for (i=1; i<=20; i++) {
! 755: if (fgets(buf, 100, logfd) == NULL)
! 756: break;
! 757: buf[strlen(buf)-1] = '\0';
! 758: Sprintf(spbuf, " %2d %s", i, buf);
! 759: mvaddstr(i+2,0, spbuf);
! 760: }
! 761: Fclose(logfd);
! 762: }
! 763: roundsleep(1);
! 764: mvaddstr(23,25,"Would you like to play again?");
! 765: eat_typeahead();
! 766: do {
! 767: getcmd(&tmp);
! 768: } while (tmp != INTRCH && tmp != BREAKCH && !index("nNyY \n\r",tmp));
! 769: if (tmp == 'n' || tmp == 'N' || tmp == INTRCH || tmp == BREAKCH)
! 770: justonemoretime = FALSE;
! 771: }
! 772:
! 773: smarts = ismarts;
! 774: totalscore = cumsmarts = wave = 0;
! 775: numents = 5;
! 776: numbases = 3;
! 777: apolspec = FALSE;
! 778: beginner = FALSE;
! 779: crushspec = FALSE;
! 780: gornspec = FALSE;
! 781: massacre = (ismarts >= 40);
! 782: romspec = FALSE;
! 783: tholspec = FALSE;
! 784: }
! 785:
! 786: void
! 787: save_game()
! 788: {
! 789: FILE *savfil;
! 790:
! 791: if (experimenting)
! 792: return;
! 793: if ((savfil = fopen(savefilename,"w")) == NULL) {
! 794: resetty();
! 795: printf("Cannot save game\r\n");
! 796: finalize(1);
! 797: }
! 798: fprintf(savfil, "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c\n",
! 799: logname, totalscore, smarts, cumsmarts, numents, numbases, wave,
! 800: apolspec ? 'a' : ' ',
! 801: beginner ? 'b' : ' ',
! 802: crushspec ? 'c' : ' ',
! 803: gornspec ? 'g' : ' ',
! 804: massacre ? 'm' : ' ',
! 805: romspec ? 'r' : ' ',
! 806: tholspec ? 't' : ' ',
! 807: lowspeed ? 'l' : ' ',
! 808: amoebaspec ? '&' : ' '
! 809: );
! 810: Fclose(savfil);
! 811: resetty();
! 812: if (panic)
! 813: finalize(0);
! 814: clear();
! 815: finalize(0);
! 816: }
! 817: f("Cannot save game\r\n");
! 818: finalize(1);
! 819: }
! 820: fprintf(savfil, "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c\n",
! 821: logname, totalscore, smarts, cumsmarts, numents, numbases, wave,
! 822: apolspec ? 'a' : ' ',
! 823: beginner ? 'b' : ' ',
! 824: crushspec ? 'c' : ' ',
! 825: gornspec ? 'g' : ' ',
! 826: massawarp/term.c 644 171 5 43531 5121747710 6201 /* $Header: term.c,v 7.0.1.2 86/12/12 17:04:09 lwall Exp $ */
! 827:
! 828: /* $Log: term.c,v $
! 829: * Revision 7.0.1.2 86/12/12 17:04:09 lwall
! 830: * Baseline for net release.
! 831: *
! 832: * Revision 7.0.1.1 86/10/16 10:53:20 lwall
! 833: * Added Damage. Fixed random bugs.
! 834: *
! 835: * Revision 7.0 86/10/08 15:14:02 lwall
! 836: * Split into separate files. Added amoebas and pirates.
! 837: *
! 838: */
! 839:
! 840: #include "EXTERN.h"
! 841: #include "warp.h"
! 842: #include "bang.h"
! 843: #include "intrp.h"
! 844: #include "object.h"
! 845: #include "play.h"
! 846: #include "score.h"
! 847: #include "sig.h"
! 848: #include "us.h"
! 849: #include "util.h"
! 850: #include "weapon.h"
! 851: #include "INTERN.h"
! 852: #include "term.h"
! 853:
! 854: int typeahead = FALSE;
! 855:
! 856: char tcarea[TCSIZE]; /* area for "compiled" termcap strings */
! 857:
! 858: /* guarantee capability pointer != Nullch */
! 859: /* (I believe terminfo will ignore the &tmpaddr argument.) */
! 860:
! 861: #define Tgetstr(key) ((tstr = tgetstr(key,&tmpaddr)) ? tstr : nullstr)
! 862:
! 863: #ifdef PUSHBACK
! 864: struct keymap {
! 865: char km_type[128];
! 866: union km_union {
! 867: struct keymap *km_km;
! 868: char *km_str;
! 869: } km_ptr[128];
! 870: };
! 871:
! 872: #define KM_NOTHIN 0
! 873: #define KM_STRING 1
! 874: #define KM_KEYMAP 2
! 875: #define KM_BOGUS 3
! 876:
! 877: #define KM_TMASK 3
! 878: #define KM_GSHIFT 4
! 879: #define KM_GMASK 7
! 880:
! 881: typedef struct keymap KEYMAP;
! 882:
! 883: KEYMAP *topmap INIT(Null(KEYMAP*));
! 884:
! 885: void mac_init();
! 886: KEYMAP *newkeymap();
! 887: void pushstring();
! 888: #endif
! 889:
! 890: /* terminal initialization */
! 891:
! 892: void
! 893: term_init()
! 894: {
! 895: savetty(); /* remember current tty state */
! 896:
! 897: #ifdef TERMIO
! 898: ospeed = _tty.c_cflag & CBAUD; /* for tputs() */
! 899: ERASECH = _tty.c_cc[VERASE]; /* for finish_command() */
! 900: KILLCH = _tty.c_cc[VKILL]; /* for finish_command() */
! 901: #else
! 902: ospeed = _tty.sg_ospeed; /* for tputs() */
! 903: ERASECH = _tty.sg_erase; /* for finish_command() */
! 904: KILLCH = _tty.sg_kill; /* for finish_command() */
! 905: #endif
! 906:
! 907: /* The following could be a table but I can't be sure that there isn't */
! 908: /* some degree of sparsity out there in the world. */
! 909:
! 910: switch (ospeed) { /* 1 second of padding */
! 911: #ifdef BEXTA
! 912: case BEXTA: just_a_sec = 1920; break;
! 913: #else
! 914: #ifdef B19200
! 915: case B19200: just_a_sec = 1920; break;
! 916: #endif
! 917: #endif
! 918: case B9600: just_a_sec = 960; break;
! 919: case B4800: just_a_sec = 480; break;
! 920: case B2400: just_a_sec = 240; break;
! 921: case B1800: just_a_sec = 180; break;
! 922: case B1200: just_a_sec = 120; break;
! 923: case B600: just_a_sec = 60; break;
! 924: case B300: just_a_sec = 30; break;
! 925: /* do I really have to type the rest of this??? */
! 926: case B200: just_a_sec = 20; break;
! 927: case B150: just_a_sec = 15; break;
! 928: case B134: just_a_sec = 13; break;
! 929: case B110: just_a_sec = 11; break;
! 930: case B75: just_a_sec = 8; break;
! 931: case B50: just_a_sec = 5; break;
! 932: default: just_a_sec = 960; break;
! 933: /* if we are running detached I */
! 934: } /* don't want to know about it! */
! 935: }
! 936:
! 937: /* set terminal characteristics */
! 938:
! 939: void
! 940: term_set(tcbuf)
! 941: char *tcbuf; /* temp area for "uncompiled" termcap entry */
! 942: {
! 943: char *tmpaddr; /* must not be register */
! 944: Reg1 char *tstr;
! 945: char *tgetstr();
! 946: char *s;
! 947: int retval;
! 948:
! 949: #ifdef PENDING
! 950: #ifndef FIONREAD
! 951: #ifndef RDCHK
! 952: /* do no delay reads on something that always gets closed on exit */
! 953:
! 954: devtty = open("/dev/tty",0);
! 955: if (devtty < 0) {
! 956: printf(cantopen,"/dev/tty");
! 957: finalize(1);
! 958: }
! 959: fcntl(devtty,F_SETFL,O_NDELAY);
! 960: #endif
! 961: #endif
! 962: #endif
! 963:
! 964: /* get all that good termcap stuff */
! 965:
! 966: #ifdef HAVETERMLIB
! 967: retval = tgetent(tcbuf,getenv("TERM")); /* get termcap entry */
! 968: if (retval < 1) {
! 969: #ifdef VERBOSE
! 970: printf("No termcap %s found.\n", retval ? "file" : "entry");
! 971: #else
! 972: fputs("Termcap botch\n",stdout);
! 973: #endif
! 974: finalize(1);
! 975: }
! 976: tmpaddr = tcarea; /* set up strange tgetstr pointer */
! 977: s = Tgetstr("pc"); /* get pad character */
! 978: PC = *s; /* get it where tputs wants it */
! 979: if (!tgetflag("bs")) { /* is backspace not used? */
! 980: BC = Tgetstr("bc"); /* find out what is */
! 981: if (BC == nullstr) /* terminfo grok's 'bs' but not 'bc' */
! 982: BC = Tgetstr("le");
! 983: } else
! 984: BC = "\b"; /* make a backspace handy */
! 985: UP = Tgetstr("up"); /* move up a line */
! 986: ND = Tgetstr("nd"); /* non-destructive move cursor right */
! 987: DO = Tgetstr("do"); /* move cursor down */
! 988: if (!*DO)
! 989: DO = Tgetstr("nl");
! 990: CL = Tgetstr("cl"); /* get clear string */
! 991: CE = Tgetstr("ce"); /* clear to end of line string */
! 992: CM = Tgetstr("cm"); /* cursor motion - PWP */
! 993: HO = Tgetstr("ho"); /* home cursor if no CM - PWP */
! 994: CD = Tgetstr("cd"); /* clear to end of display - PWP */
! 995: SO = Tgetstr("so"); /* begin standout */
! 996: SE = Tgetstr("se"); /* end standout */
! 997: if ((SG = tgetnum("sg"))<0)
! 998: SG = 0; /* blanks left by SG, SE */
! 999: US = Tgetstr("us"); /* start underline */
! 1000: UE = Tgetstr("ue"); /* end underline */
! 1001: if ((UG = tgetnum("ug"))<0)
! 1002: UG = 0; /* blanks left by US, UE */
! 1003: if (*US)
! 1004: UC = nullstr; /* UC must not be NULL */
! 1005: else
! 1006: UC = Tgetstr("uc"); /* underline a character */
! 1007: if (!*US && !*UC) { /* no underline mode? */
! 1008: US = SO; /* substitute standout mode */
! 1009: UE = SE;
! 1010: UG = SG;
! 1011: }
! 1012: LINES = tgetnum("li"); /* lines per page */
! 1013: COLS = tgetnum("co"); /* columns on page */
! 1014: AM = tgetflag("am"); /* terminal wraps automatically? */
! 1015: XN = tgetflag("xn"); /* then eats next newline? */
! 1016: VB = Tgetstr("vb");
! 1017: if (!*VB)
! 1018: VB = "\007";
! 1019: CR = Tgetstr("cr");
! 1020: if (!*CR) {
! 1021: if (tgetflag("nc") && *UP) {
! 1022: CR = safemalloc((MEM_SIZE)strlen(UP)+2);
! 1023: Sprintf(CR,"%s\r",UP);
! 1024: }
! 1025: else
! 1026: CR = "\r";
! 1027: }
! 1028: #else
! 1029: ?????? /* Roll your own... */
! 1030: #endif
! 1031: if (LINES <= 0)
! 1032: LINES = 24;
! 1033: if (COLS <= 0)
! 1034: COLS = 80;
! 1035:
! 1036: BCsize = comp_tc(bsptr,BC,1);
! 1037: BC = bsptr;
! 1038:
! 1039: if (!*ND) /* not defined? */
! 1040: NDsize = 1000; /* force cursor addressing */
! 1041: else {
! 1042: NDsize = comp_tc(cmbuffer,ND,1);
! 1043: myND = malloc((unsigned)NDsize);
! 1044: movc3(NDsize,cmbuffer,myND);
! 1045: if (debugging) {
! 1046: int scr;
! 1047:
! 1048: printf("ND");
! 1049: for (scr=0; scr<NDsize; scr++)
! 1050: printf(" %d",myND[scr]);
! 1051: printf("\n");
! 1052: }
! 1053: }
! 1054:
! 1055: if (!*UP) /* not defined? */
! 1056: UPsize = 1000; /* force cursor addressing */
! 1057: else {
! 1058: UPsize = comp_tc(cmbuffer,UP,1);
! 1059: myUP = malloc((unsigned)UPsize);
! 1060: movc3(UPsize,cmbuffer,myUP);
! 1061: if (debugging) {
! 1062: int scr;
! 1063:
! 1064: printf("UP");
! 1065: for (scr=0; scr<UPsize; scr++)
! 1066: printf(" %d",myUP[scr]);
! 1067: printf("\n");
! 1068: }
! 1069: }
! 1070:
! 1071: if (!*DO) { /* not defined? */
! 1072: myDO = DO = "\n"; /* assume a newline */
! 1073: DOsize = 1;
! 1074: }
! 1075: else {
! 1076: DOsize = comp_tc(cmbuffer,DO,1);
! 1077: myDO = malloc((unsigned)DOsize);
! 1078: movc3(DOsize,cmbuffer,myDO);
! 1079: if (debugging) {
! 1080: int scr;
! 1081:
! 1082: printf("DO");
! 1083: for (scr=0; scr<DOsize; scr++)
! 1084: printf(" %d",myDO[scr]);
! 1085: printf("\n");
! 1086: }
! 1087: }
! 1088: if (debugging)
! 1089: Fgets(cmbuffer,(sizeof cmbuffer),stdin);
! 1090:
! 1091: CMsize = comp_tc(cmbuffer,tgoto(CM,20,20),0);
! 1092: if (PC != '\0') {
! 1093: char *p;
! 1094:
! 1095: for (p=filler+(sizeof filler)-1;!*p;--p)
! 1096: *p = PC;
! 1097: }
! 1098: charsperhalfsec = ospeed >= B9600 ? 480 :
! 1099: ospeed == B4800 ? 240 :
! 1100: ospeed == B2400 ? 120 :
! 1101: ospeed == B1200 ? 60 :
! 1102: ospeed == B600 ? 30 :
! 1103: /* speed is 300 (?) */ 15;
! 1104:
! 1105: gfillen = ospeed >= B9600 ? (sizeof filler) :
! 1106: ospeed == B4800 ? 13 :
! 1107: ospeed == B2400 ? 7 :
! 1108: ospeed == B1200 ? 4 :
! 1109: 1+BCsize;
! 1110: if (ospeed < B2400)
! 1111: lowspeed = TRUE;
! 1112:
! 1113: strcpy(term,ttyname(2));
! 1114:
! 1115: if (!*CM || !BCsize)
! 1116: no_can_do("dumb");
! 1117: if (!scorespec && (LINES < 24 || COLS < 80))
! 1118: no_can_do("puny");
! 1119:
! 1120: crmode();
! 1121: raw();
! 1122: noecho(); /* turn off echo */
! 1123: nonl();
! 1124:
! 1125: #ifdef PUSHBACK
! 1126: mac_init(tcbuf);
! 1127: #endif
! 1128: }
! 1129:
! 1130: #ifdef PUSHBACK
! 1131: void
! 1132: mac_init(tcbuf)
! 1133: char *tcbuf;
! 1134: {
! 1135: char tmpbuf[1024];
! 1136:
! 1137: tmpfp = fopen(filexp(getval("WARPMACRO",WARPMACRO)),"r");
! 1138: if (tmpfp != Nullfp) {
! 1139: while (fgets(tcbuf,1024,tmpfp) != Nullch) {
! 1140: mac_line(tcbuf,tmpbuf,(sizeof tmpbuf));
! 1141: }
! 1142: Fclose(tmpfp);
! 1143: }
! 1144: }
! 1145:
! 1146: void
! 1147: mac_line(line,tmpbuf,tbsize)
! 1148: char *line;
! 1149: char *tmpbuf;
! 1150: int tbsize;
! 1151: {
! 1152: Reg1 char *s;
! 1153: Reg2 char *m;
! 1154: Reg3 KEYMAP *curmap;
! 1155: Reg4 int ch;
! 1156: Reg5 int garbage = 0;
! 1157: static char override[] = "\r\nkeymap overrides string\r\n";
! 1158:
! 1159: if (topmap == Null(KEYMAP*))
! 1160: topmap = newkeymap();
! 1161: if (*line == '#' || *line == '\n')
! 1162: return;
! 1163: if (line[ch = strlen(line)-1] == '\n')
! 1164: line[ch] = '\0';
! 1165: m = dointerp(tmpbuf,tbsize,line," \t");
! 1166: if (!*m)
! 1167: return;
! 1168: while (*m == ' ' || *m == '\t') m++;
! 1169: for (s=tmpbuf,curmap=topmap; *s; s++) {
! 1170: ch = *s & 0177;
! 1171: if (s[1] == '+' && isdigit(s[2])) {
! 1172: s += 2;
! 1173: garbage = (*s & KM_GMASK) << KM_GSHIFT;
! 1174: }
! 1175: else
! 1176: garbage = 0;
! 1177: if (s[1]) {
! 1178: if ((curmap->km_type[ch] & KM_TMASK) == KM_STRING) {
! 1179: puts(override);
! 1180: free(curmap->km_ptr[ch].km_str);
! 1181: curmap->km_ptr[ch].km_str = Nullch;
! 1182: }
! 1183: curmap->km_type[ch] = KM_KEYMAP + garbage;
! 1184: if (curmap->km_ptr[ch].km_km == Null(KEYMAP*))
! 1185: curmap->km_ptr[ch].km_km = newkeymap();
! 1186: curmap = curmap->km_ptr[ch].km_km;
! 1187: }
! 1188: else {
! 1189: if ((curmap->km_type[ch] & KM_TMASK) == KM_KEYMAP)
! 1190: puts(override);
! 1191: else {
! 1192: curmap->km_type[ch] = KM_STRING + garbage;
! 1193: curmap->km_ptr[ch].km_str = savestr(m);
! 1194: }
! 1195: }
! 1196: }
! 1197: }
! 1198:
! 1199: KEYMAP*
! 1200: newkeymap()
! 1201: {
! 1202: Reg1 int i;
! 1203: Reg2 KEYMAP *map;
! 1204:
! 1205: #ifndef lint
! 1206: map = (KEYMAP*)safemalloc(sizeof(KEYMAP));
! 1207: #else
! 1208: map = Null(KEYMAP*);
! 1209: #endif /* lint */
! 1210: for (i=127; i>=0; --i) {
! 1211: map->km_ptr[i].km_km = Null(KEYMAP*);
! 1212: map->km_type[i] = KM_NOTHIN;
! 1213: }
! 1214: return map;
! 1215: }
! 1216:
! 1217: #endif
! 1218:
! 1219: /* print out a file, stopping at form feeds */
! 1220:
! 1221: void
! 1222: page(filename,num)
! 1223: char *filename;
! 1224: bool num;
! 1225: {
! 1226: int linenum = 1;
! 1227:
! 1228: tmpfp = fopen(filename,"r");
! 1229: if (tmpfp != NULL) {
! 1230: while (fgets(spbuf,(sizeof spbuf),tmpfp) != NULL) {
! 1231: if (*spbuf == '\f') {
! 1232: printf("[Type anything to continue] ");
! 1233: Fflush(stdout);
! 1234: getcmd(spbuf);
! 1235: printf("\r\n");
! 1236: if (*spbuf == INTRCH)
! 1237: finalize(0);
! 1238: if (*spbuf == 'q' || *spbuf == 'Q')
! 1239: break;
! 1240: }
! 1241: else {
! 1242: if (num)
! 1243: printf("%3d %s\r",linenum++,spbuf);
! 1244: else
! 1245: printf("%s\r",spbuf);
! 1246: }
! 1247: }
! 1248: Fclose(tmpfp);
! 1249: }
! 1250: }
! 1251:
! 1252: void
! 1253: move(y, x, chadd)
! 1254: int y, x;
! 1255: int chadd;
! 1256: {
! 1257: Reg1 int ydist;
! 1258: Reg2 int xdist;
! 1259: Reg3 int i;
! 1260: Reg4 char *s;
! 1261:
! 1262: ydist = y - real_y;
! 1263: xdist = x - real_x;
! 1264: i = ydist * (ydist < 0 ? -UPsize : DOsize) +
! 1265: xdist * (xdist < 0 ? -BCsize : NDsize);
! 1266: beg_qwrite();
! 1267: if (i <= CMsize) {
! 1268: if (ydist < 0)
! 1269: for (; ydist; ydist++)
! 1270: for (i=UPsize,s=myUP; i; i--)
! 1271: qaddch(*s++);
! 1272: else
! 1273: for (; ydist; ydist--)
! 1274: for (i=DOsize,s=myDO; i; i--)
! 1275: qaddch(*s++);
! 1276: if (xdist < 0)
! 1277: for (; xdist; xdist++)
! 1278: for (i=BCsize,s=BC; i; i--)
! 1279: qaddch(*s++);
! 1280: else
! 1281: for (; xdist; xdist--)
! 1282: for (i=NDsize,s=myND; i; i--)
! 1283: qaddch(*s++);
! 1284: }
! 1285: else {
! 1286: tputs(tgoto(CM,x,y),0,cmstore);
! 1287: }
! 1288: real_y = y;
! 1289: real_x = x;
! 1290: if (chadd) {
! 1291: qaddch(chadd);
! 1292: }
! 1293: if (maxcmstring != cmbuffer)
! 1294: end_qwrite();
! 1295: }
! 1296:
! 1297: void
! 1298: do_tc(s,l)
! 1299: char *s;
! 1300: int l;
! 1301: {
! 1302: beg_qwrite();
! 1303: tputs(s,l,cmstore);
! 1304: end_qwrite();
! 1305: }
! 1306:
! 1307: int
! 1308: comp_tc(dest,s,l)
! 1309: char *dest;
! 1310: char *s;
! 1311: int l;
! 1312: {
! 1313: maxcmstring = dest;
! 1314: tputs(s,l,cmstore);
! 1315: return(maxcmstring-dest);
! 1316: }
! 1317:
! 1318: void
! 1319: helper()
! 1320: {
! 1321: clear();
! 1322: mvaddstr(0,4,"h or 4 left");
! 1323: mvaddstr(1,4,"j or 2 down Use with SHIFT to fire torpedoes.");
! 1324: mvaddstr(2,4,"k or 8 up Use with CTRL or FUNCT to fire");
! 1325: mvaddstr(3,4,"l or 6 right phasers or turbolasers.");
! 1326: mvaddstr(4,4,"b or 1 down and left Use preceded by 'a' or 'r' for");
! 1327: mvaddstr(5,4,"n or 3 down and right attractors or repulsors.");
! 1328: mvaddstr(6,4,"y or 7 up and left Use normally for E or B motion.");
! 1329: mvaddstr(7,4,"u or 9 up and right");
! 1330: mvaddstr(8,4,"");
! 1331: mvaddstr(9,4,"del or % fire photon torpedoes in every (reasonable) direction.");
! 1332: mvaddstr(10,4,"s stop all torpedoes.");
! 1333: mvaddstr(11,4,"S or 0 stop the Enterprise when in warp mode.");
! 1334: mvaddstr(12,4,"d/D destruct all torpedoes/current vessel.");
! 1335: mvaddstr(13,4,"i/w switch to Enterprise & put into impulse/warp mode.");
! 1336: mvaddstr(14,4,"c/v switch to Enterprise & make cloaked/visible.");
! 1337: mvaddstr(15,4,"p switch to Base.");
! 1338: mvaddstr(16,4,"o toggle to other vessel (from E to B, or vice versa.)");
! 1339: mvaddstr(17,4,"z zap (suppress) blasts near Enterprise next cycle");
! 1340: mvaddstr(18,4,"");
! 1341: mvaddstr(19,4,"^R refresh the screen. ^Z suspend the game.");
! 1342: mvaddstr(20,4,"q exit this round (if you haven't typed q within 10 cycles).");
! 1343: mvaddstr(21,4,"Q exit this game.");
! 1344: mvaddstr(22,4,"");
! 1345: mvaddstr(23,4," [Hit space to continue]");
! 1346: Fflush(stdout);
! 1347: do {
! 1348: getcmd(spbuf);
! 1349: } while (*spbuf != ' ');
! 1350: rewrite();
! 1351:
! 1352: }
! 1353:
! 1354: void
! 1355: rewrite()
! 1356: {
! 1357: Reg1 int x;
! 1358: Reg2 int y;
! 1359: Reg3 OBJECT *obj;
! 1360:
! 1361: clear();
! 1362: for (y=0; y<YSIZE; y++) {
! 1363: for (x=0; x<XSIZE; x++) {
! 1364: if (numamoebas && amb[y][x] != ' ')
! 1365: mvaddc(y+1,x*2,amb[y][x]);
! 1366: if (obj=occupant[y][x]) {
! 1367: if (obj->image != ' ')
! 1368: mvaddc(y+1,x*2,obj->image);
! 1369: }
! 1370: }
! 1371: }
! 1372: Sprintf(spbuf,
! 1373: "%-4s E: %4d %2d B: %5d %3d Enemies: %-3d Stars: %-3d Stardate%5d.%1d %9ld",
! 1374: " ", 0, 0, 0, 0, 0, 0, timer/10+smarts*100, timer%10, 0L);
! 1375: mvaddstr(0,0,spbuf);
! 1376: oldeenergy = oldbenergy = oldcurscore =
! 1377: oldstatus = oldetorp = oldbtorp = oldstrs = oldenemies = -1;
! 1378: /* force everything to fill in */
! 1379: if (damage)
! 1380: olddamage = 0;
! 1381: if (!ent)
! 1382: etorp = 0;
! 1383: if (!base)
! 1384: btorp = 0;
! 1385: display_status();
! 1386: }
! 1387:
! 1388: char
! 1389: cmstore(ch)
! 1390: Reg1 char ch;
! 1391: {
! 1392: *maxcmstring++ = ch;
! 1393: }
! 1394:
! 1395: /* discard any characters typed ahead */
! 1396:
! 1397: void
! 1398: eat_typeahead()
! 1399: {
! 1400: #ifdef PUSHBACK
! 1401: if (!typeahead && nextin==nextout) /* cancel only keyboard stuff */
! 1402: #else
! 1403: if (!typeahead)
! 1404: #endif
! 1405: {
! 1406: #ifdef PENDING
! 1407: while (input_pending())
! 1408: Read_tty(buf,sizeof(buf));
! 1409: #else /* this is probably v7, with no rdchk() */
! 1410: ioctl(_tty_ch,TIOCSETP,&_tty);
! 1411: #endif
! 1412: }
! 1413: }
! 1414:
! 1415: void
! 1416: settle_down()
! 1417: {
! 1418: dingaling();
! 1419: Fflush(stdout);
! 1420: sleep(1);
! 1421: #ifdef PUSHBACK
! 1422: nextout = nextin; /* empty circlebuf */
! 1423: #endif
! 1424: eat_typeahead();
! 1425: }
! 1426:
! 1427: #ifdef PUSHBACK
! 1428: /* read a character from the terminal, with multi-character pushback */
! 1429:
! 1430: int
! 1431: read_tty(addr,size)
! 1432: char *addr;
! 1433: int size; /* ignored for now */
! 1434: {
! 1435: #ifdef lint
! 1436: size = size;
! 1437: #endif
! 1438: if (nextout != nextin) {
! 1439: *addr = circlebuf[nextout++];
! 1440: nextout %= PUSHSIZE;
! 1441: return 1;
! 1442: }
! 1443: else {
! 1444: size = read(0,addr,1);
! 1445: if (size < 0)
! 1446: sig_catcher(SIGHUP);
! 1447: if (metakey) {
! 1448: if (*addr & 0200) {
! 1449: pushchar(*addr & 0177);
! 1450: *addr = '\001';
! 1451: }
! 1452: }
! 1453: else
! 1454: *addr &= 0177;
! 1455: return 1;
! 1456: }
! 1457: }
! 1458:
! 1459: #ifdef PENDING
! 1460: #ifndef FIONREAD
! 1461: #ifndef RDCHK
! 1462: int
! 1463: circfill()
! 1464: {
! 1465: Reg1 int howmany;
! 1466: Reg2 int i;
! 1467:
! 1468: assert (nextin == nextout);
! 1469: howmany = read(devtty,circlebuf+nextin,metakey?1:PUSHSIZE-nextin);
! 1470: if (howmany > 0) {
! 1471: if (metakey) {
! 1472: if (circlebuf[nextin] & 0200) {
! 1473: circlebuf[nextin] &= 0177;
! 1474: pushchar('\001');
! 1475: }
! 1476: }
! 1477: else
! 1478: for (i = howmany+nextin-1; i >= nextin; i--)
! 1479: circlebuf[i] &= 0177;
! 1480: nextin += howmany;
! 1481: nextin %= PUSHSIZE; /* may end up 1 if metakey */
! 1482: }
! 1483: return howmany;
! 1484: }
! 1485: #endif /* RDCHK */
! 1486: #endif /* FIONREAD */
! 1487: #endif /* PENDING */
! 1488:
! 1489: void
! 1490: pushchar(ch)
! 1491: char ch;
! 1492: {
! 1493: nextout--;
! 1494: if (nextout < 0)
! 1495: nextout = PUSHSIZE - 1;
! 1496: if (nextout == nextin) {
! 1497: fputs("\r\npushback buffer overflow\r\n",stdout);
! 1498: sig_catcher(0);
! 1499: }
! 1500: circlebuf[nextout] = ch;
! 1501: }
! 1502:
! 1503: #else /* PUSHBACK */
! 1504: #ifndef read_tty
! 1505: /* read a character from the terminal, with hacks for O_NDELAY reads */
! 1506:
! 1507: int
! 1508: read_tty(addr,size)
! 1509: char *addr;
! 1510: int size;
! 1511: {
! 1512: if (is_input) {
! 1513: *addr = pending_ch;
! 1514: is_input = FALSE;
! 1515: return 1;
! 1516: }
! 1517: else {
! 1518: size = read(0,addr,size);
! 1519: if (size < 0)
! 1520: sig_catcher(SIGHUP);
! 1521: if (metakey) {
! 1522: if (*addr & 0200) {
! 1523: pending_ch = *addr & 0177;
! 1524: is_input = TRUE;
! 1525: *addr = '\001';
! 1526: }
! 1527: }
! 1528: else
! 1529: *addr &= 0177;
! 1530: return size;
! 1531: }
! 1532: }
! 1533: #endif /* read_tty */
! 1534: #endif /* PUSHBACK */
! 1535:
! 1536: int
! 1537: read_nd(buff, siz)
! 1538: char *buff;
! 1539: int siz;
! 1540: {
! 1541: if (!input_pending())
! 1542: return 0;
! 1543:
! 1544: getcmd(buff);
! 1545: return 1;
! 1546: }
! 1547:
! 1548: /* get a character into a buffer */
! 1549:
! 1550: void
! 1551: getcmd(whatbuf)
! 1552: Reg3 char *whatbuf;
! 1553: {
! 1554: #ifdef PUSHBACK
! 1555: Reg1 KEYMAP *curmap;
! 1556: Reg2 int i;
! 1557: bool no_macros;
! 1558: int times = 0; /* loop detector */
! 1559: char scrchar;
! 1560:
! 1561: tryagain:
! 1562: curmap = topmap;
! 1563: /* no_macros = (whatbuf != buf && nextin == nextout); */
! 1564: no_macros = FALSE;
! 1565: #endif
! 1566: for (;;) {
! 1567: errno = 0;
! 1568: if (read_tty(whatbuf,1) < 0 && !errno)
! 1569: errno = EINTR;
! 1570: #ifdef read_tty
! 1571: if (metakey) {
! 1572: if (*whatbuf & 0200) {
! 1573: *what_buf &= 037; /* punt and hope they don't notice */
! 1574: }
! 1575: }
! 1576: else
! 1577: *whatbuf &= 0177;
! 1578: #endif /* read_tty */
! 1579: if (errno && errno != EINTR) {
! 1580: perror(readerr);
! 1581: sig_catcher(0);
! 1582: }
! 1583: #ifdef PUSHBACK
! 1584: if (*whatbuf & 0200 || no_macros) {
! 1585: *whatbuf &= 0177;
! 1586: goto got_canonical;
! 1587: }
! 1588: if (curmap == Null(KEYMAP*))
! 1589: goto got_canonical;
! 1590: for (i = (curmap->km_type[*whatbuf] >> KM_GSHIFT) & KM_GMASK; i; --i){
! 1591: Read_tty(&scrchar,1);
! 1592: }
! 1593: switch (curmap->km_type[*whatbuf] & KM_TMASK) {
! 1594: case KM_NOTHIN: /* no entry? */
! 1595: if (curmap == topmap) /* unmapped canonical */
! 1596: goto got_canonical;
! 1597: settle_down();
! 1598: goto tryagain;
! 1599: case KM_KEYMAP: /* another keymap? */
! 1600: curmap = curmap->km_ptr[*whatbuf].km_km;
! 1601: assert(curmap != Null(KEYMAP*));
! 1602: break;
! 1603: case KM_STRING: /* a string? */
! 1604: pushstring(curmap->km_ptr[*whatbuf].km_str);
! 1605: if (++times > 20) { /* loop? */
! 1606: fputs("\r\nmacro loop?\r\n",stdout);
! 1607: settle_down();
! 1608: }
! 1609: no_macros = FALSE;
! 1610: goto tryagain;
! 1611: }
! 1612: #else
! 1613: *whatbuf &= 0177;
! 1614: break;
! 1615: #endif
! 1616: }
! 1617:
! 1618: got_canonical:
! 1619: #ifndef TERMIO
! 1620: if (*whatbuf == '\r')
! 1621: *whatbuf = '\n';
! 1622: #endif
! 1623: if (whatbuf == buf)
! 1624: whatbuf[1] = FINISHCMD; /* tell finish_command to work */
! 1625: }
! 1626:
! 1627: #ifdef PUSHBACK
! 1628: void
! 1629: pushstring(str)
! 1630: char *str;
! 1631: {
! 1632: Reg1 int i;
! 1633: char tmpbuf[PUSHSIZE];
! 1634: Reg2 char *s = tmpbuf;
! 1635:
! 1636: assert(str != Nullch);
! 1637: interp(s,PUSHSIZE,str);
! 1638: for (i = strlen(s)-1; i >= 0; --i) {
! 1639: s[i] ^= 0200;
! 1640: pushchar(s[i]);
! 1641: }
! 1642: }
! 1643: #endif
! 1644: = FALSE;
! 1645: goto tryagain;
! 1646: }
! 1647: #else
! 1648: *whatbuf &= 0177;
! 1649: break;
! 1650: #endif
! 1651: }
! 1652:
! 1653: got_canonical:
! 1654: #ifndef TERMIO
! 1655: if (*whatbuf == '\r')
! 1656: *whatbuf = '\n';
! 1657: #endif
! 1658: if warp/util.c 644 171 5 12314 5121747713 6205 /* $Header: util.c,v 7.0.1.2 86/10/20 12:07:46 lwall Exp $ */
! 1659:
! 1660: /* $Log: util.c,v $
! 1661: * Revision 7.0.1.2 86/10/20 12:07:46 lwall
! 1662: * Made all exits reset tty.
! 1663: *
! 1664: * Revision 7.0.1.1 86/10/16 10:54:02 lwall
! 1665: * Added Damage. Fixed random bugs.
! 1666: *
! 1667: * Revision 7.0 86/10/08 15:14:31 lwall
! 1668: * Split into separate files. Added amoebas and pirates.
! 1669: *
! 1670: */
! 1671:
! 1672: #include "EXTERN.h"
! 1673: #include "warp.h"
! 1674: #include "ndir.h"
! 1675: #include "object.h"
! 1676: #include "sig.h"
! 1677: #include "term.h"
! 1678: #include "INTERN.h"
! 1679: #include "util.h"
! 1680:
! 1681: void
! 1682: util_init()
! 1683: {
! 1684: ;
! 1685: }
! 1686:
! 1687: void
! 1688: movc3(len,src,dest)
! 1689: #ifdef vax
! 1690: char *dest, *src;
! 1691: int len;
! 1692: {
! 1693: asm("movc3 4(ap),*8(ap),*12(ap)");
! 1694: }
! 1695: #else
! 1696: Reg1 char *dest;
! 1697: Reg2 char *src;
! 1698: Reg3 int len;
! 1699: {
! 1700: if (dest <= src) {
! 1701: for (; len; len--) {
! 1702: *dest++ = *src++;
! 1703: }
! 1704: }
! 1705: else {
! 1706: dest += len;
! 1707: src += len;
! 1708: for (; len; len--) {
! 1709: *--dest = *--src;
! 1710: }
! 1711: }
! 1712: }
! 1713: #endif
! 1714:
! 1715: void
! 1716: no_can_do(what)
! 1717: char *what;
! 1718: {
! 1719: fprintf(stderr,"Sorry, your terminal is too %s to play warp.\r\n",what);
! 1720: finalize(1);
! 1721: }
! 1722:
! 1723: int
! 1724: exdis(maxnum)
! 1725: int maxnum;
! 1726: {
! 1727: double temp, temp2;
! 1728: double exp();
! 1729: double log();
! 1730:
! 1731: temp = (double) maxnum;
! 1732: #ifndef lint
! 1733: temp2 = (double) myrand();
! 1734: #else
! 1735: temp2 = 0.0;
! 1736: #endif
! 1737: #if RANDBITS == 15
! 1738: return (int) exp(temp2 * log(temp)/0x7fff);
! 1739: #else
! 1740: #if RANDBITS == 16
! 1741: return (int) exp(temp2 * log(temp)/0xffff);
! 1742: #else
! 1743: return (int) exp(temp2 * log(temp)/0x7fffffff);
! 1744: #endif
! 1745: #endif
! 1746: }
! 1747:
! 1748: static char nomem[] = "warp: out of memory!\r\n";
! 1749:
! 1750: /* paranoid version of malloc */
! 1751:
! 1752: char *
! 1753: safemalloc(size)
! 1754: MEM_SIZE size;
! 1755: {
! 1756: char *ptr;
! 1757: char *malloc();
! 1758:
! 1759: ptr = malloc(size?size:1); /* malloc(0) is NASTY on our system */
! 1760: if (ptr != Nullch)
! 1761: return ptr;
! 1762: else {
! 1763: fputs(nomem,stdout);
! 1764: sig_catcher(0);
! 1765: }
! 1766: /*NOTREACHED*/
! 1767: }
! 1768:
! 1769: /* safe version of string copy */
! 1770:
! 1771: char *
! 1772: safecpy(to,from,len)
! 1773: char *to;
! 1774: Reg2 char *from;
! 1775: Reg1 int len;
! 1776: {
! 1777: Reg3 char *dest = to;
! 1778:
! 1779: if (from != Nullch)
! 1780: for (len--; len && (*dest++ = *from++); len--) ;
! 1781: *dest = '\0';
! 1782: return to;
! 1783: }
! 1784:
! 1785: /* copy a string up to some (non-backslashed) delimiter, if any */
! 1786:
! 1787: char *
! 1788: cpytill(to,from,delim)
! 1789: Reg2 char *to;
! 1790: Reg1 char *from;
! 1791: Reg3 int delim;
! 1792: {
! 1793: for (; *from; from++,to++) {
! 1794: if (*from == '\\' && from[1] == delim)
! 1795: from++;
! 1796: else if (*from == delim)
! 1797: break;
! 1798: *to = *from;
! 1799: }
! 1800: *to = '\0';
! 1801: return from;
! 1802: }
! 1803:
! 1804: /* return ptr to little string in big string, NULL if not found */
! 1805:
! 1806: char *
! 1807: instr(big, little)
! 1808: char *big, *little;
! 1809:
! 1810: {
! 1811: Reg3 char *t;
! 1812: Reg1 char *s;
! 1813: Reg2 char *x;
! 1814:
! 1815: for (t = big; *t; t++) {
! 1816: for (x=t,s=little; *s; x++,s++) {
! 1817: if (!*x)
! 1818: return Nullch;
! 1819: if (*s != *x)
! 1820: break;
! 1821: }
! 1822: if (!*s)
! 1823: return t;
! 1824: }
! 1825: return Nullch;
! 1826: }
! 1827:
! 1828: /* effective access */
! 1829:
! 1830: #ifdef SETUIDGID
! 1831: int
! 1832: eaccess(filename, mod)
! 1833: char *filename;
! 1834: int mod;
! 1835: {
! 1836: int protection, euid;
! 1837:
! 1838: mod &= 7; /* remove extraneous garbage */
! 1839: if (stat(filename, &filestat) < 0)
! 1840: return -1;
! 1841: euid = geteuid();
! 1842: if (euid == ROOTID)
! 1843: return 0;
! 1844: protection = 7 & (filestat.st_mode >>
! 1845: (filestat.st_uid == euid ? 6 :
! 1846: (filestat.st_gid == getegid() ? 3 : 0)
! 1847: ));
! 1848: if ((mod & protection) == mod)
! 1849: return 0;
! 1850: errno = EACCES;
! 1851: return -1;
! 1852: }
! 1853: #endif
! 1854:
! 1855: /*
! 1856: * Get working directory
! 1857: */
! 1858:
! 1859: #ifdef GETWD
! 1860: #define dot "."
! 1861: #define dotdot ".."
! 1862:
! 1863: static char *name;
! 1864:
! 1865: static DIR *dirp;
! 1866: static int off;
! 1867: static struct stat d, dd;
! 1868: static struct direct *dir;
! 1869:
! 1870: char *
! 1871: getwd(np)
! 1872: char *np;
! 1873: {
! 1874: long rdev, rino;
! 1875:
! 1876: *np++ = '/';
! 1877: *np = 0;
! 1878: name = np;
! 1879: off = -1;
! 1880: stat("/", &d);
! 1881: rdev = d.st_dev;
! 1882: rino = d.st_ino;
! 1883: for (;;) {
! 1884: stat(dot, &d);
! 1885: if (d.st_ino==rino && d.st_dev==rdev)
! 1886: goto done;
! 1887: if ((dirp = opendir(dotdot)) == Null(DIR *))
! 1888: prexit("getwd: cannot open ..\r\n");
! 1889: stat(dotdot, &dd);
! 1890: chdir(dotdot);
! 1891: if(d.st_dev == dd.st_dev) {
! 1892: if(d.st_ino == dd.st_ino)
! 1893: goto done;
! 1894: do
! 1895: if ((dir = readdir(dirp)) == Null(struct direct *))
! 1896: prexit("getwd: read error in ..\r\n");
! 1897: while (dir->d_ino != d.st_ino);
! 1898: }
! 1899: else do {
! 1900: if ((dir = readdir(dirp)) == Null(struct direct *))
! 1901: prexit("getwd: read error in ..\r\n");
! 1902: stat(dir->d_name, &dd);
! 1903: } while(dd.st_ino != d.st_ino || dd.st_dev != d.st_dev);
! 1904: cat();
! 1905: closedir(dirp);
! 1906: }
! 1907: done:
! 1908: name--;
! 1909: if (chdir(name) < 0) {
! 1910: printf("getwd: can't cd back to %s\r\n",name);
! 1911: sig_catcher(0);
! 1912: }
! 1913: return (name);
! 1914: }
! 1915:
! 1916: void
! 1917: cat()
! 1918: {
! 1919: Reg1 int i;
! 1920: Reg2 int j;
! 1921:
! 1922: i = -1;
! 1923: while (dir->d_name[++i] != 0);
! 1924: if ((off+i+2) > 1024-1)
! 1925: return;
! 1926: for(j=off+1; j>=0; --j)
! 1927: name[j+i+1] = name[j];
! 1928: if (off >= 0)
! 1929: name[i] = '/';
! 1930: off=i+off+1;
! 1931: name[off] = 0;
! 1932: for(--i; i>=0; --i)
! 1933: name[i] = dir->d_name[i];
! 1934: }
! 1935:
! 1936: void
! 1937: prexit(cp)
! 1938: char *cp;
! 1939: {
! 1940: write(2, cp, strlen(cp));
! 1941: sig_catcher(0);
! 1942: }
! 1943: #else
! 1944: char *
! 1945: getwd(np) /* shorter but slower */
! 1946: char *np;
! 1947: {
! 1948: FILE *popen();
! 1949: FILE *pipefp = popen("/bin/pwd","r");
! 1950:
! 1951: if (pipefp == Nullfp) {
! 1952: printf("Can't run /bin/pwd\r\n");
! 1953: finalize(1);
! 1954: }
! 1955: Fgets(np,512,pipefp);
! 1956: np[strlen(np)-1] = '\0'; /* wipe out newline */
! 1957: pclose(pipefp);
! 1958: return np;
! 1959: }
! 1960: #endif
! 1961:
! 1962: /* copy a string to a safe spot */
! 1963:
! 1964: char *
! 1965: savestr(str)
! 1966: char *str;
! 1967: {
! 1968: Reg1 char *newaddr = safemalloc((MEM_SIZE)(strlen(str)+1));
! 1969:
! 1970: strcpy(newaddr,str);
! 1971: return newaddr;
! 1972: }
! 1973:
! 1974: char *
! 1975: getval(nam,def)
! 1976: char *nam,*def;
! 1977: {
! 1978: char *val;
! 1979:
! 1980: if ((val = getenv(nam)) == Nullch || !*val)
! 1981: val = def;
! 1982: return val;
! 1983: }
! 1984: efp == Nullfp) {
! 1985: printf("Can't run /bin/pwd\r\n");
! 1986: finalize(1);
! 1987: }
! 1988: Fgets(np,512,pipefp);
! 1989: np[strlen(np)-1] = '\0'; /* wipe out newline */
! 1990: pclose(pipefp);
! 1991: return np;
! 1992: }
! 1993: #endif
! 1994:
! 1995: /* copy a string to a safe spot */
! 1996:
! 1997: char *
! 1998: savestr(str)
! 1999: char *str;
! 2000: {
! 2001: Reg1 char *newaddr = safemalloc((MEM_SIZwarp/intrp.h 644 171 5 1275 5121747714 6356 /* $Header: intrp.h,v 7.0.1.1 86/12/12 16:59:45 lwall Exp $
! 2002: *
! 2003: * $Log: intrp.h,v $
! 2004: * Revision 7.0.1.1 86/12/12 16:59:45 lwall
! 2005: * Baseline for net release.
! 2006: *
! 2007: * Revision 7.0 86/10/08 15:12:27 lwall
! 2008: * Split into separate files. Added amoebas and pirates.
! 2009: *
! 2010: */
! 2011:
! 2012: EXT char *origdir INIT(Nullch); /* cwd when warp invoked */
! 2013: EXT char *homedir INIT(Nullch); /* login directory */
! 2014: EXT char *dotdir INIT(Nullch); /* where . files go */
! 2015: EXT char *logname INIT(Nullch); /* login id */
! 2016: EXT char *hostname INIT(Nullch); /* host name */
! 2017: EXT char *realname INIT(Nullch); /* real name from /etc/passwd */
! 2018:
! 2019: void intrp_init();
! 2020: char *filexp();
! 2021: char *dointerp();
! 2022: void interp();
! 2023: char *getrealname();
! 2024: 15:12:27 lwall
! 2025: * Split into separate files. Added amoebas and pirates.
! 2026: *
! 2027: */
! 2028:
! 2029: EXT char *origdir INIT(Nullch); /* cwd when warp invoked */
! 2030: EXT char *homedir INIT(Nullch); /* login directory */
! 2031: EXT char *dotdir INIT(Nullch); /* where . files go */
! 2032: EXT char *logname INIT(Nullch); /* login id */
! 2033: EXT char *hostname warp/Configure 755 171 5 130734 5121750001 6742 #! /bin/sh
! 2034: #
! 2035: # If these # comments don't work, trim them. Don't worry about any other
! 2036: # shell scripts, Configure will trim # comments from them for you.
! 2037: #
! 2038: # (If you are trying to port this package to a machine without sh, I would
! 2039: # suggest you cut out the prototypical config.h from the end of Configure
! 2040: # and edit it to reflect your system. Some packages may include samples
! 2041: # of config.h for certain machines, so you might look for one of those.)
! 2042: #
! 2043: # $Header: Configure,v 7.0.1.2 86/12/12 16:44:05 lwall Exp $
! 2044: #
! 2045: # Yes, you may rip this off to use in other distribution packages.
! 2046: # (Note: this Configure script was generated automatically. Rather than
! 2047: # working with this copy of Configure, you may wish to get metaconfig.)
! 2048:
! 2049: : sanity checks
! 2050: PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc'
! 2051: export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
! 2052:
! 2053: if test ! -t 0; then
! 2054: echo "Say 'sh Configure', not 'sh <Configure'"
! 2055: exit 1
! 2056: fi
! 2057:
! 2058: (alias) >/dev/null 2>&1 && \
! 2059: echo "(I see you are using the Korn shell. Some ksh's blow up on Configure," && \
! 2060: echo "especially on exotic machines. If yours does, try the Bourne shell instead.)"
! 2061:
! 2062: if test ! -d ../UU; then
! 2063: if test ! -d UU; then
! 2064: mkdir UU
! 2065: fi
! 2066: cd UU
! 2067: fi
! 2068:
! 2069: d_eunice=''
! 2070: eunicefix=''
! 2071: define=''
! 2072: loclist=''
! 2073: expr=''
! 2074: sed=''
! 2075: echo=''
! 2076: cat=''
! 2077: rm=''
! 2078: mv=''
! 2079: cp=''
! 2080: tail=''
! 2081: tr=''
! 2082: mkdir=''
! 2083: sort=''
! 2084: uniq=''
! 2085: grep=''
! 2086: trylist=''
! 2087: test=''
! 2088: inews=''
! 2089: egrep=''
! 2090: more=''
! 2091: pg=''
! 2092: Mcc=''
! 2093: vi=''
! 2094: mailx=''
! 2095: Log=''
! 2096: Header=''
! 2097: cc=''
! 2098: contains=''
! 2099: cpp=''
! 2100: d_charsprf=''
! 2101: d_fcntl=''
! 2102: d_ftime=''
! 2103: d_gethname=''
! 2104: d_douname=''
! 2105: d_phostname=''
! 2106: d_getpwent=''
! 2107: d_havetlib=''
! 2108: termlib=''
! 2109: d_index=''
! 2110: d_ioctl=''
! 2111: d_normsig=''
! 2112: jobslib=''
! 2113: d_portable=''
! 2114: d_rdchk=''
! 2115: d_scorfl=''
! 2116: d_sgndchr=''
! 2117: d_termio=''
! 2118: d_usendir=''
! 2119: d_libndir=''
! 2120: ndirc=''
! 2121: ndiro=''
! 2122: d_whoami=''
! 2123: hostname=''
! 2124: phostname=''
! 2125: mydomain=''
! 2126: libc=''
! 2127: libnm=''
! 2128: mansrc=''
! 2129: manext=''
! 2130: models=''
! 2131: split=''
! 2132: small=''
! 2133: medium=''
! 2134: large=''
! 2135: huge=''
! 2136: ccflags=''
! 2137: ldflags=''
! 2138: n=''
! 2139: c=''
! 2140: nametype=''
! 2141: d_passnames=''
! 2142: d_berknames=''
! 2143: d_usgnames=''
! 2144: passcat=''
! 2145: package=''
! 2146: prefshell=''
! 2147: randbits=''
! 2148: registers=''
! 2149: reg1=''
! 2150: reg2=''
! 2151: reg3=''
! 2152: reg4=''
! 2153: reg5=''
! 2154: reg6=''
! 2155: reg7=''
! 2156: reg8=''
! 2157: reg9=''
! 2158: reg10=''
! 2159: reg11=''
! 2160: reg12=''
! 2161: reg13=''
! 2162: reg14=''
! 2163: reg15=''
! 2164: reg16=''
! 2165: rootid=''
! 2166: spitshell=''
! 2167: shsharp=''
! 2168: sharpbang=''
! 2169: startsh=''
! 2170: voidflags=''
! 2171: bin=''
! 2172: chowner=''
! 2173: privlib=''
! 2174: CONFIG=''
! 2175:
! 2176: : set package name
! 2177: package=warp
! 2178:
! 2179: echo " "
! 2180: echo "Beginning of configuration questions for $package kit."
! 2181: : Eunice requires " " instead of "", can you believe it
! 2182: echo " "
! 2183:
! 2184: define='define'
! 2185: undef='/*undef'
! 2186: libpth='/usr/lib /usr/local/lib /lib'
! 2187: smallmach='pdp11 i8086 z8000 i80286 iAPX286'
! 2188: rmlist='kit[1-9]isdone kit[1-9][0-9]isdone'
! 2189: trap 'echo " "; rm -f $rmlist; exit 1' 1 2 3
! 2190: attrlist="mc68000 sun gcos unix ibm gimpel interdata tss os mert pyr"
! 2191: attrlist="$attrlist vax pdp11 i8086 z8000 u3b2 u3b5 u3b20 u3b200"
! 2192: attrlist="$attrlist ns32000 ns16000 iAPX286"
! 2193: pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib"
! 2194: defvoidused=7
! 2195:
! 2196: : some greps do not return status, grrr.
! 2197: echo "grimblepritz" >grimble
! 2198: if grep blurfldyick grimble >/dev/null 2>&1 ; then
! 2199: contains=contains
! 2200: elif grep grimblepritz grimble >/dev/null 2>&1 ; then
! 2201: contains=grep
! 2202: else
! 2203: contains=contains
! 2204: fi
! 2205: rm -f grimble
! 2206: : the following should work in any shell
! 2207: case "$contains" in
! 2208: contains*)
! 2209: echo " "
! 2210: echo "AGH! Grep doesn't return a status. Attempting remedial action."
! 2211: cat >contains <<'EOSS'
! 2212: grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
! 2213: EOSS
! 2214: chmod 755 contains
! 2215: esac
! 2216:
! 2217: : first determine how to suppress newline on echo command
! 2218: echo "Checking echo to see how to suppress newlines..."
! 2219: (echo "hi there\c" ; echo " ") >.echotmp
! 2220: if $contains c .echotmp >/dev/null 2>&1 ; then
! 2221: echo "...using -n."
! 2222: n='-n'
! 2223: c=''
! 2224: else
! 2225: cat <<'EOM'
! 2226: ...using \c
! 2227: EOM
! 2228: n=''
! 2229: c='\c'
! 2230: fi
! 2231: echo $n "Type carriage return to continue. Your cursor should be here-->$c"
! 2232: read ans
! 2233: rm -f .echotmp
! 2234:
! 2235: : now set up to do reads with possible shell escape and default assignment
! 2236: cat <<EOSC >myread
! 2237: ans='!'
! 2238: while expr "X\$ans" : "X!" >/dev/null; do
! 2239: read ans
! 2240: case "\$ans" in
! 2241: !)
! 2242: sh
! 2243: echo " "
! 2244: echo $n "\$rp $c"
! 2245: ;;
! 2246: !*)
! 2247: set \`expr "X\$ans" : "X!\(.*\)\$"\`
! 2248: sh -c "\$*"
! 2249: echo " "
! 2250: echo $n "\$rp $c"
! 2251: ;;
! 2252: esac
! 2253: done
! 2254: rp='Your answer:'
! 2255: case "\$ans" in
! 2256: '') ans="\$dflt";;
! 2257: esac
! 2258: EOSC
! 2259:
! 2260: : general instructions
! 2261: cat <<EOH
! 2262:
! 2263: This installation shell script will examine your system and ask you questions
! 2264: to determine how $package and any auxiliary files should be installed. If you
! 2265: get stuck on a question, you may use a ! shell escape to start a subshell or
! 2266: execute a command. Many of the questions will have default answers in
! 2267: square brackets--typing carriage return will give you the default.
! 2268:
! 2269: On some of the questions which ask for file or directory names you are
! 2270: allowed to use the ~name construct to specify the login directory belonging
! 2271: to "name", even if you don't have a shell which knows about that. Questions
! 2272: where this is allowed will be marked "(~name ok)".
! 2273:
! 2274: EOH
! 2275: rp="[Type carriage return to continue]"
! 2276: echo $n "$rp $c"
! 2277: . myread
! 2278: cat <<EOH
! 2279:
! 2280: Much effort has been expended to ensure that this shell script will run
! 2281: on any Unix system. If despite that it blows up on you, your best bet is
! 2282: to edit Configure and run it again. (Trying to install this package
! 2283: without having run Configure may be well nigh impossible.) Also, let me
! 2284: ([email protected]) know how I blew it.
! 2285:
! 2286: This installation script affects things in two ways: 1) it may do direct
! 2287: variable substitutions on some of the files included in this kit, and
! 2288: 2) it builds a config.h file for inclusion in C programs. You may edit
! 2289: any of these files as the need arises after running this script.
! 2290:
! 2291: If you make a mistake on a question, there is no easy way to back up to it
! 2292: currently. The easiest thing to do is to edit config.sh and rerun all the
! 2293: SH files. Configure will offer to let you do this before it runs the SH files.
! 2294:
! 2295: EOH
! 2296: rp="[Type carriage return to continue]"
! 2297: echo $n "$rp $c"
! 2298: . myread
! 2299:
! 2300: : get old answers, if there is a config file out there
! 2301: if test -f ../config.sh; then
! 2302: echo " "
! 2303: dflt=y
! 2304: rp="I see a config.sh file. Did Configure make it on THIS system? [$dflt]"
! 2305: echo $n "$rp $c"
! 2306: . myread
! 2307: case "$ans" in
! 2308: n*) echo "OK, I'll ignore it.";;
! 2309: *) echo "Fetching default answers from your old config.sh file..."
! 2310: tmp="$n"
! 2311: ans="$c"
! 2312: . ../config.sh
! 2313: n="$tmp"
! 2314: c="$ans"
! 2315: ;;
! 2316: esac
! 2317: fi
! 2318:
! 2319: : find out where common programs are
! 2320: echo " "
! 2321: echo "Locating common programs..."
! 2322: cat <<EOSC >loc
! 2323: $startsh
! 2324: case \$# in
! 2325: 0) exit 1;;
! 2326: esac
! 2327: thing=\$1
! 2328: shift
! 2329: dflt=\$1
! 2330: shift
! 2331: for dir in \$*; do
! 2332: case "\$thing" in
! 2333: .)
! 2334: if test -d \$dir/\$thing; then
! 2335: echo \$dir
! 2336: exit 0
! 2337: fi
! 2338: ;;
! 2339: *)
! 2340: if test -f \$dir/\$thing; then
! 2341: echo \$dir/\$thing
! 2342: exit 0
! 2343: fi
! 2344: ;;
! 2345: esac
! 2346: done
! 2347: echo \$dflt
! 2348: exit 1
! 2349: EOSC
! 2350: chmod 755 loc
! 2351: $eunicefix loc
! 2352: loclist="
! 2353: expr
! 2354: sed
! 2355: echo
! 2356: cat
! 2357: rm
! 2358: mv
! 2359: cp
! 2360: tr
! 2361: mkdir
! 2362: sort
! 2363: uniq
! 2364: grep
! 2365: "
! 2366: trylist="
! 2367: test
! 2368: egrep
! 2369: Mcc
! 2370: "
! 2371: for file in $loclist; do
! 2372: xxx=`loc $file $file $pth`
! 2373: eval $file=$xxx
! 2374: eval _$file=$xxx
! 2375: case "$xxx" in
! 2376: /*)
! 2377: echo $file is in $xxx.
! 2378: ;;
! 2379: *)
! 2380: echo "I don't know where $file is. I hope it's in everyone's PATH."
! 2381: ;;
! 2382: esac
! 2383: done
! 2384: echo " "
! 2385: echo "Don't worry if any of the following aren't found..."
! 2386: ans=offhand
! 2387: for file in $trylist; do
! 2388: xxx=`loc $file $file $pth`
! 2389: eval $file=$xxx
! 2390: eval _$file=$xxx
! 2391: case "$xxx" in
! 2392: /*)
! 2393: echo $file is in $xxx.
! 2394: ;;
! 2395: *)
! 2396: echo "I don't see $file out there, $ans."
! 2397: ans=either
! 2398: ;;
! 2399: esac
! 2400: done
! 2401: case "$egrep" in
! 2402: egrep)
! 2403: echo "Substituting grep for egrep."
! 2404: egrep=$grep
! 2405: ;;
! 2406: esac
! 2407: case "$test" in
! 2408: test)
! 2409: echo "Hopefully test is built into your sh."
! 2410: ;;
! 2411: /bin/test)
! 2412: echo " "
! 2413: dflt=n
! 2414: rp="Is your "'"'"test"'"'" built into sh? [$dflt] (OK to guess)"
! 2415: echo $n "$rp $c"
! 2416: . myread
! 2417: case "$ans" in
! 2418: y*) test=test ;;
! 2419: esac
! 2420: ;;
! 2421: *)
! 2422: test=test
! 2423: ;;
! 2424: esac
! 2425: case "$echo" in
! 2426: echo)
! 2427: echo "Hopefully echo is built into your sh."
! 2428: ;;
! 2429: /bin/echo)
! 2430: echo " "
! 2431: echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
! 2432: $echo $n "hi there$c" >foo1
! 2433: echo $n "hi there$c" >foo2
! 2434: if cmp foo1 foo2 >/dev/null 2>&1; then
! 2435: echo "They are compatible. In fact, they may be identical."
! 2436: else
! 2437: case "$n" in
! 2438: '-n') n='' c='\c' ans='\c' ;;
! 2439: *) n='-n' c='' ans='-n' ;;
! 2440: esac
! 2441: cat <<FOO
! 2442: They are not compatible! You are probably running ksh on a non-USG system.
! 2443: I'll have to use /bin/echo instead of the builtin, since Bourne shell doesn't
! 2444: have echo built in and we may have to run some Bourne shell scripts. That
! 2445: means I'll have to use $ans to suppress newlines now. Life is ridiculous.
! 2446:
! 2447: FOO
! 2448: rp="Your cursor should be here-->"
! 2449: $echo $n "$rp$c"
! 2450: . myread
! 2451: fi
! 2452: $rm -f foo1 foo2
! 2453: ;;
! 2454: *)
! 2455: : cross your fingers
! 2456: echo=echo
! 2457: ;;
! 2458: esac
! 2459: rmlist="$rmlist loc"
! 2460:
! 2461: : get list of predefined functions in a handy place
! 2462: echo " "
! 2463: if test -f /lib/libc.a; then
! 2464: echo "Your C library is in /lib/libc.a. You're normal."
! 2465: libc=/lib/libc.a
! 2466: else
! 2467: ans=`loc libc.a blurfl/dyick $libpth`
! 2468: if test -f $ans; then
! 2469: echo "Your C library is in $ans, of all places."
! 2470: libc=ans
! 2471: else
! 2472: if test -f "$libc"; then
! 2473: echo "Your C library is in $libc, like you said before."
! 2474: else
! 2475: cat <<EOM
! 2476:
! 2477: I can't seem to find your C library. I've looked in the following places:
! 2478:
! 2479: $libpth
! 2480:
! 2481: None of these seems to contain your C library. What is the full name
! 2482: EOM
! 2483: dflt=None
! 2484: $echo $n "of your C library? $c"
! 2485: rp='C library full name?'
! 2486: . myread
! 2487: libc="$ans"
! 2488: fi
! 2489: fi
! 2490: fi
! 2491: echo " "
! 2492: $echo $n "Extracting names from $libc for later perusal...$c"
! 2493: if ar t $libc > libc.list; then
! 2494: echo "done"
! 2495: else
! 2496: echo " "
! 2497: echo "The archiver doesn't think $libc is a reasonable library."
! 2498: echo "Trying nm instead..."
! 2499: if nm -g $libc > libc.list; then
! 2500: echo "done"
! 2501: else
! 2502: echo "That didn't work either. Giving up."
! 2503: exit 1
! 2504: fi
! 2505: fi
! 2506: rmlist="$rmlist libc.list"
! 2507:
! 2508: : make some quick guesses about what we are up against
! 2509: echo " "
! 2510: $echo $n "Hmm... $c"
! 2511: if $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then
! 2512: echo "Looks kind of like a BSD system, but we'll see..."
! 2513: echo exit 0 >bsd
! 2514: echo exit 1 >usg
! 2515: echo exit 1 >v7
! 2516: elif $contains fcntl libc.list >/dev/null 2>&1 ; then
! 2517: echo "Looks kind of like a USG system, but we'll see..."
! 2518: echo exit 1 >bsd
! 2519: echo exit 0 >usg
! 2520: echo exit 1 >v7
! 2521: else
! 2522: echo "Looks kind of like a version 7 system, but we'll see..."
! 2523: echo exit 1 >bsd
! 2524: echo exit 1 >usg
! 2525: echo exit 0 >v7
! 2526: fi
! 2527: if $contains vmssystem libc.list >/dev/null 2>&1 ; then
! 2528: cat <<'EOI'
! 2529: There is, however, a strange, musty smell in the air that reminds me of
! 2530: something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
! 2531: EOI
! 2532: echo "exit 0" >eunice
! 2533: eunicefix=unixtovms
! 2534: d_eunice="$define"
! 2535: : it so happens the Eunice I know will not run shell scripts in Unix format
! 2536: else
! 2537: echo " "
! 2538: echo "Congratulations. You aren't running Eunice."
! 2539: eunicefix=':'
! 2540: d_eunice="$undef"
! 2541: echo "exit 1" >eunice
! 2542: fi
! 2543: if test -f /xenix; then
! 2544: echo "Actually, this looks more like a XENIX system..."
! 2545: echo "exit 0" >xenix
! 2546: else
! 2547: echo " "
! 2548: echo "It's not Xenix..."
! 2549: echo "exit 1" >xenix
! 2550: fi
! 2551: chmod 755 xenix
! 2552: if test -f /venix; then
! 2553: echo "Actually, this looks more like a VENIX system..."
! 2554: echo "exit 0" >venix
! 2555: else
! 2556: echo " "
! 2557: if xenix; then
! 2558: : null
! 2559: else
! 2560: echo "Nor is it Venix..."
! 2561: fi
! 2562: echo "exit 1" >venix
! 2563: fi
! 2564: chmod 755 bsd usg v7 eunice venix xenix
! 2565: $eunicefix bsd usg v7 eunice venix xenix
! 2566: rmlist="$rmlist bsd usg v7 eunice venix xenix"
! 2567:
! 2568: : see if sh knows # comments
! 2569: echo " "
! 2570: echo "Checking your sh to see if it knows about # comments..."
! 2571: if sh -c '#' >/dev/null 2>&1 ; then
! 2572: echo "Your sh handles # comments correctly."
! 2573: shsharp=true
! 2574: spitshell=cat
! 2575: echo " "
! 2576: echo "Okay, let's see if #! works on this system..."
! 2577: echo "#!/bin/echo hi" > try
! 2578: $eunicefix try
! 2579: chmod 755 try
! 2580: try > today
! 2581: if test -s today; then
! 2582: echo "It does."
! 2583: sharpbang='#!'
! 2584: else
! 2585: echo "#! /bin/echo hi" > try
! 2586: $eunicefix try
! 2587: chmod 755 try
! 2588: try > today
! 2589: if test -s today; then
! 2590: echo "It does."
! 2591: sharpbang='#! '
! 2592: else
! 2593: echo "It doesn't."
! 2594: sharpbang=': use '
! 2595: fi
! 2596: fi
! 2597: else
! 2598: echo "Your sh doesn't grok # comments--I will strip them later on."
! 2599: shsharp=false
! 2600: echo "exec grep -v '^#'" >spitshell
! 2601: chmod 755 spitshell
! 2602: $eunicefix spitshell
! 2603: spitshell=`pwd`/spitshell
! 2604: echo "I presume that if # doesn't work, #! won't work either!"
! 2605: sharpbang=': use '
! 2606: fi
! 2607:
! 2608: : figure out how to guarantee sh startup
! 2609: echo " "
! 2610: echo "Checking out how to guarantee sh startup..."
! 2611: startsh=$sharpbang'/bin/sh'
! 2612: echo "Let's see if '$startsh' works..."
! 2613: cat >try <<EOSS
! 2614: $startsh
! 2615: set abc
! 2616: test "$?abc" != 1
! 2617: EOSS
! 2618:
! 2619: chmod 755 try
! 2620: $eunicefix try
! 2621: if try; then
! 2622: echo "Yup, it does."
! 2623: else
! 2624: echo "Nope. You may have to fix up the shell scripts to make sure sh runs them."
! 2625: fi
! 2626: rm -f try today
! 2627:
! 2628: : find out how to find out full name
! 2629: echo " "
! 2630: case "$d_berknames" in
! 2631: "$define")
! 2632: dflt=y;;
! 2633: "$undef")
! 2634: dflt=n;;
! 2635: *)
! 2636: if bsd; then
! 2637: dflt=y
! 2638: else
! 2639: dflt=n
! 2640: fi
! 2641: ;;
! 2642: esac
! 2643: echo "Does your /etc/passwd file keep full names in Berkeley/V7 format (name first"
! 2644: $echo $n "thing after ':' in GCOS field)? [$dflt] $c"
! 2645: rp="Berkeley/V7 format full name? [$dflt]"
! 2646: . myread
! 2647: case "$ans" in
! 2648: y*)
! 2649: d_passnames="$define"
! 2650: d_berknames="$define"
! 2651: d_usgnames="$undef"
! 2652: nametype=bsd
! 2653: ;;
! 2654: *)
! 2655: echo " "
! 2656: case "$d_usgnames" in
! 2657: "$define")
! 2658: dflt=y;;
! 2659: "$undef")
! 2660: dflt=n;;
! 2661: *)
! 2662: if usg; then
! 2663: dflt=y
! 2664: else
! 2665: dflt=n
! 2666: fi
! 2667: ;;
! 2668: esac
! 2669: echo "Does your passwd file keep full names in USG format (name sandwiched"
! 2670: $echo $n "between a '-' and a '(')? [$dflt] $c"
! 2671: rp="USG format full name? [$dflt]"
! 2672: . myread
! 2673: case "$ans" in
! 2674: n*)
! 2675: echo "Full name will be taken from ~/.fullname"
! 2676: d_passnames="$undef"
! 2677: d_berknames="$undef"
! 2678: d_usgnames="$undef"
! 2679: nametype=other
! 2680: ;;
! 2681: *)
! 2682: d_passnames="$define"
! 2683: d_berknames="$undef"
! 2684: d_usgnames="$define"
! 2685: nametype=usg
! 2686: ;;
! 2687: esac
! 2688: ;;
! 2689: esac
! 2690:
! 2691: : see if we have to deal with yellow pages
! 2692: if $test -d /usr/etc/yp; then
! 2693: if $contains '^\+:' /etc/passwd; then
! 2694: dflt=y
! 2695: else
! 2696: dflt=n
! 2697: fi
! 2698: rp="Are you getting the passwd file via yellow pages? [$dflt]"
! 2699: $echo $n "$rp $c"
! 2700: . myread
! 2701: case "$ans" in
! 2702: y*) passcat='ypcat passwd';;
! 2703: *) passcat='cat /etc/passwd';;
! 2704: esac
! 2705: else
! 2706: passcat='cat /etc/passwd'
! 2707: fi
! 2708:
! 2709: : see if sprintf is declared as int or pointer to char
! 2710: echo " "
! 2711: if $contains 'char.*sprintf' /usr/include/stdio.h >/dev/null 2>&1 ; then
! 2712: echo "Your sprintf() returns (char*)."
! 2713: d_charsprf="$define"
! 2714: else
! 2715: echo "Your sprintf() returns (int)."
! 2716: d_charsprf="$undef"
! 2717: fi
! 2718:
! 2719: : now get the host name
! 2720: echo " "
! 2721: echo "Figuring out host name..."
! 2722: echo 'Maybe "hostname" will work...'
! 2723: if ans=`sh -c hostname 2>&1` ; then
! 2724: hostname=$ans
! 2725: phostname=hostname
! 2726: else
! 2727: echo 'Oh, dear. Maybe "/etc/systemid" will work...'
! 2728: if ans=`sh -c '/etc/systemid' 2>&1` ; then
! 2729: hostname=$ans
! 2730: phostname='/etc/systemid'
! 2731: if xenix; then
! 2732: echo "Whadyaknow. Xenix always was a bit strange..."
! 2733: else
! 2734: echo "What is a non-Xenix system doing with /etc/systemid?"
! 2735: fi
! 2736: else
! 2737: echo 'No, maybe "uuname -l" will work...'
! 2738: if ans=`sh -c 'uuname -l' 2>&1` ; then
! 2739: hostname=$ans
! 2740: phostname='uuname -l'
! 2741: else
! 2742: echo 'Strange. Maybe "uname -n" will work...'
! 2743: if ans=`sh -c 'uname -n' 2>&1` ; then
! 2744: hostname=$ans
! 2745: phostname='uname -n'
! 2746: else
! 2747: echo 'Oh well, maybe I can mine it out of whoami.h...'
! 2748: if ans=`sh -c $contains' sysname /usr/include/whoami.h' 2>&1` ; then
! 2749: hostname=`echo "$ans" | $sed 's/^.*"\(.*\)"/\1/'`
! 2750: phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' </usr/include/whoami.h"
! 2751: else
! 2752: case "$hostname" in
! 2753: '') echo "Does this machine have an identity crisis or something?"
! 2754: phostname=''
! 2755: ;;
! 2756: *) echo "Well, you said $hostname before...";;
! 2757: esac
! 2758: fi
! 2759: fi
! 2760: fi
! 2761: fi
! 2762: fi
! 2763: : you do not want to know about this
! 2764: set $hostname
! 2765: hostname=$1
! 2766:
! 2767: : translate upper to lower if necessary
! 2768: case "$hostname" in
! 2769: *[A-Z]*)
! 2770: hostname=`echo $hostname | tr '[A-Z]' '[a-z]'`
! 2771: echo "(Normalizing case in your host name)"
! 2772: ;;
! 2773: esac
! 2774:
! 2775: : verify guess
! 2776: if $test "$hostname" ; then
! 2777: dflt=y
! 2778: echo 'Your host name appears to be "'$hostname'".'
! 2779: $echo $n "Is this correct? [$dflt] $c"
! 2780: rp="Sitename is $hostname? [$dflt]"
! 2781: . myread
! 2782: case "$ans" in
! 2783: y*) ;;
! 2784: *) hostname='' ;;
! 2785: esac
! 2786: fi
! 2787:
! 2788: : bad guess or no guess
! 2789: while $test "X$hostname" = X ; do
! 2790: dflt=''
! 2791: rp="Please type the (one word) name of your host:"
! 2792: $echo $n "$rp $c"
! 2793: . myread
! 2794: hostname="$ans"
! 2795: done
! 2796:
! 2797: echo " "
! 2798: case "$hostname" in
! 2799: *.*)
! 2800: dflt=`expr "X$hostname" : "X[^.]*\(\..*\)"`
! 2801: hostname=`expr "X$hostname" : "X\([^.]*\)\."`
! 2802: echo "(Trimming domain name from host name--host name is now $hostname)"
! 2803: ;;
! 2804: *)
! 2805: dflt='.uucp'
! 2806: ;;
! 2807: esac
! 2808: rp="What is your domain name? [$dflt]"
! 2809: $echo $n "$rp $c"
! 2810: . myread
! 2811: case "$ans" in
! 2812: '') ;;
! 2813: .*) ;;
! 2814: *) ans=".$ans";;
! 2815: esac
! 2816: mydomain="$ans"
! 2817:
! 2818: : a little sanity check here
! 2819: case "$phostname" in
! 2820: '') ;;
! 2821: *) case `$phostname` in
! 2822: $hostname$mydomain|$hostname) ;;
! 2823: *)
! 2824: case "$phostname" in
! 2825: sed*)
! 2826: echo "(That doesn't agree with your whoami.h file, by the way.)"
! 2827: ;;
! 2828: *)
! 2829: echo "(That doesn't agree with your $phostname command, by the way.)"
! 2830: ;;
! 2831: esac
! 2832: phostname=''
! 2833: ;;
! 2834: esac
! 2835: ;;
! 2836: esac
! 2837:
! 2838: : decide how portable to be
! 2839: case "$d_portable" in
! 2840: "$define") dflt=y;;
! 2841: *) dflt=n;;
! 2842: esac
! 2843: $cat <<'EOH'
! 2844:
! 2845: I can set things up so that your shell scripts and binaries are more portable,
! 2846: at what may be a noticable cost in performance. In particular, if you
! 2847: ask to be portable, the following happens:
! 2848:
! 2849: 1) shell scripts will rely on the PATH variable rather than using
! 2850: the paths derived above.
! 2851: 2) ~username interpretations will be done at run time rather than
! 2852: by Configure.
! 2853: 3) the system name will be determined at run time, if at all possible.
! 2854:
! 2855: EOH
! 2856: rp="Do you expect to run these scripts and binaries on multiple machines? [$dflt]"
! 2857: $echo $n "$rp $c"
! 2858: . myread
! 2859: case "$ans" in
! 2860: y*) d_portable="$define"
! 2861: for file in $loclist; do
! 2862: eval $file=$file
! 2863: done
! 2864: ;;
! 2865: *) d_portable="$undef" ;;
! 2866: esac
! 2867:
! 2868: : see if there is a whoami file
! 2869: echo " "
! 2870: if $test -r /usr/include/whoami.h ; then
! 2871: d_whoami="$define"
! 2872: echo "whoami.h found."
! 2873: else
! 2874: d_whoami="$undef"
! 2875: fi
! 2876:
! 2877: : see how we will look up host name
! 2878: echo " "
! 2879: d_douname="$undef"
! 2880: d_gethname="$undef"
! 2881: d_phostname="$undef"
! 2882:
! 2883: if xenix; then
! 2884: echo " "
! 2885: echo "(Assuming Xenix uname() is broken.)"
! 2886: elif $contains gethostname libc.list >/dev/null 2>&1 ; then
! 2887: echo "gethostname() found."
! 2888: d_gethname="$define"
! 2889: ans=gethostname
! 2890: elif $contains uname libc.list >/dev/null 2>&1 ; then
! 2891: echo "uname() found."
! 2892: d_douname="$define"
! 2893: ans=uname
! 2894: fi
! 2895:
! 2896: case "$d_douname$d_gethname" in
! 2897: *define*)
! 2898: dflt=n
! 2899: cat <<EOM
! 2900:
! 2901: Every now and then someone has a $ans() that lies about the hostname
! 2902: but can't be fixed for political or economic reasons. Would you like to
! 2903: EOM
! 2904: rp="pretend $ans() isn't there and maybe compile in the hostname? [$dflt]"
! 2905: $echo $n "$rp $c"
! 2906: . myread
! 2907: case "$ans" in
! 2908: y*) d_douname="$undef" d_gethname="$undef"
! 2909: $echo $n "Okay... $c"
! 2910: ;;
! 2911: esac
! 2912: ;;
! 2913: esac
! 2914:
! 2915: case "$d_douname$d_gethname" in
! 2916: *define*) ;;
! 2917: *)
! 2918: case "$phostname" in
! 2919: '') ;;
! 2920: *)
! 2921: $cat <<EOT
! 2922:
! 2923: There is no gethostname() or uname() on this system. You have two
! 2924: possibilities at this point:
! 2925:
! 2926: 1) You can have your host name ($hostname) compiled into $package, which
! 2927: lets $package start up faster, but makes your binaries non-portable, or
! 2928: 2) you can have $package use a
! 2929:
! 2930: popen("$phostname","r")
! 2931:
! 2932: which will start slower but be more portable.
! 2933:
! 2934: Option 1 will give you the option of using whoami.h if you have one. If you
! 2935: want option 2 but with a different command, you can edit config.sh at the
! 2936: end of this shell script.
! 2937:
! 2938: EOT
! 2939: case "$d_phostname" in
! 2940: "$define") dflt=n;;
! 2941: "$undef") dflt=y;;
! 2942: '')
! 2943: case "$d_portable" in
! 2944: "$define") dflt=n ;;
! 2945: *) dflt=y ;;
! 2946: esac
! 2947: ;;
! 2948: esac
! 2949: rp="Do you want your host name compiled in? [$dflt]"
! 2950: $echo $n "$rp $c"
! 2951: . myread
! 2952: case "$ans" in
! 2953: n*) d_phostname="$define" ;;
! 2954: *) phostname=''
! 2955: d_phostname="$undef"
! 2956: ;;
! 2957: esac
! 2958: ;;
! 2959: esac
! 2960: case "$phostname" in
! 2961: '')
! 2962: case "$d_whoami" in
! 2963: "$define")
! 2964: dflt=y
! 2965: $cat <<EOM
! 2966:
! 2967: No hostname function--you can either use the whoami.h file, which has this line:
! 2968:
! 2969: `grep sysname /usr/include/whoami.h`
! 2970:
! 2971: or you can have the name we came up with earlier ($hostname) hardwired in.
! 2972: EOM
! 2973: rp="Use whoami.h to get hostname? [$dflt]"
! 2974: $echo $n "$rp $c"
! 2975: . myread
! 2976: case "$ans" in
! 2977: n*) d_whoami="$undef";;
! 2978: esac
! 2979: ;;
! 2980: "$undef")
! 2981: echo 'No hostname function and no whoami.h--hardwiring "'$hostname'".'
! 2982: ;;
! 2983: esac
! 2984: ;;
! 2985: esac
! 2986: ;;
! 2987: esac
! 2988:
! 2989: : see if this is an fcntl system
! 2990: echo " "
! 2991: if $test -r /usr/include/fcntl.h ; then
! 2992: d_fcntl="$define"
! 2993: echo "fcntl.h found."
! 2994: else
! 2995: d_fcntl="$undef"
! 2996: echo "No fcntl.h found, but that's ok."
! 2997: fi
! 2998:
! 2999: : see if ftime exists
! 3000: echo " "
! 3001: if $contains ftime libc.list >/dev/null 2>&1; then
! 3002: echo 'ftime() found.'
! 3003: d_ftime="$define"
! 3004: else
! 3005: echo 'ftime() not found--timing may be less accurate.'
! 3006: d_ftime="$undef"
! 3007: fi
! 3008:
! 3009: : see if there is a getpw
! 3010: echo " "
! 3011: if $contains getpw.o libc.list >/dev/null 2>&1 ; then
! 3012: echo "getpw() found."
! 3013: d_getpwent="$undef"
! 3014: else
! 3015: echo "No getpw() found--will use getpwent() instead."
! 3016: d_getpwent="$define"
! 3017: fi
! 3018:
! 3019: : set up shell script to do ~ expansion
! 3020: cat >filexp <<EOSS
! 3021: $startsh
! 3022: : expand filename
! 3023: case "\$1" in
! 3024: ~/*|~)
! 3025: echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
! 3026: ;;
! 3027: ~*)
! 3028: if $test -f /bin/csh; then
! 3029: /bin/csh -f -c "glob \$1"
! 3030: echo ""
! 3031: else
! 3032: name=\`$expr x\$1 : '..\([^/]*\)'\`
! 3033: dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
! 3034: if $test ! -d "\$dir"; then
! 3035: me=\`basename \$0\`
! 3036: echo "\$me: can't locate home directory for: \$name" >&2
! 3037: exit 1
! 3038: fi
! 3039: case "\$1" in
! 3040: */*)
! 3041: echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
! 3042: ;;
! 3043: *)
! 3044: echo \$dir
! 3045: ;;
! 3046: esac
! 3047: fi
! 3048: ;;
! 3049: *)
! 3050: echo \$1
! 3051: ;;
! 3052: esac
! 3053: EOSS
! 3054: chmod 755 filexp
! 3055: $eunicefix filexp
! 3056:
! 3057: : where do we get termlib routines from
! 3058: echo " "
! 3059: ans=`loc libcurses.a x $libpth`
! 3060: case "$ans" in
! 3061: /*)
! 3062: ar t $ans >grimble
! 3063: if $contains tputs.o grimble >/dev/null 2>&1; then
! 3064: termlib='-lcurses'
! 3065: d_havetlib="$define"
! 3066: echo "Terminfo library found."
! 3067: else
! 3068: ans=x
! 3069: fi
! 3070: ;;
! 3071: esac
! 3072: case "$ans" in
! 3073: x)
! 3074: ans=`loc libtermlib.a x $libpth`
! 3075: case "$ans" in
! 3076: /usr/lib*|/lib*)
! 3077: termlib='-ltermlib'
! 3078: d_havetlib="$define"
! 3079: echo "Termlib library found."
! 3080: ;;
! 3081: /*)
! 3082: termlib="$ans"
! 3083: d_havetlib="$define"
! 3084: echo "Termlib library found."
! 3085: ;;
! 3086: *)
! 3087: ans=`loc libtermcap.a x $libpth`
! 3088: case "$ans" in
! 3089: /usr/lib*|/lib*)
! 3090: termlib='-ltermcap'
! 3091: d_havetlib="$define"
! 3092: echo "Termcap library found."
! 3093: ;;
! 3094: /*)
! 3095: termlib="$ans"
! 3096: d_havetlib="$define"
! 3097: echo "Termcap library found."
! 3098: ;;
! 3099: *)
! 3100: case "$termlib" in
! 3101: '')
! 3102: dflt=y
! 3103: rp="Your system appears to NOT have termlib-style routines. Is this true? [$dflt]"
! 3104: $echo $n "$rp $c"
! 3105: . myread
! 3106: case "$ans" in
! 3107: n*|f*) d_havetlib="$define"
! 3108: echo "Then where are the termlib-style routines kept (specify either -llibname"
! 3109: $echo $n " or full pathname (~name ok))? $c"
! 3110: rp='Specify termlib:'
! 3111: . myread
! 3112: termlib=`filexp $ans`
! 3113: ;;
! 3114: *) d_havetlib="$undef"
! 3115: termlib=''
! 3116: echo "You will have to play around with term.c then."
! 3117: ;;
! 3118: esac
! 3119: echo " "
! 3120: ;;
! 3121: *) echo "You said termlib was $termlib before."
! 3122: ;;
! 3123: esac
! 3124: ;;
! 3125: esac
! 3126: ;;
! 3127: esac
! 3128: ;;
! 3129: esac
! 3130:
! 3131: : index or strcpy
! 3132: echo " "
! 3133: dflt=y
! 3134: if $contains index libc.list >/dev/null 2>&1 ; then
! 3135: echo "Your system appears to use index() and rindex() rather than strchr()"
! 3136: $echo $n "and strrchr(). Is this correct? [$dflt] $c"
! 3137: rp='index() rather than strchr()? [$dflt]'
! 3138: . myread
! 3139: case "$ans" in
! 3140: n*|f*) d_index="$define" ;;
! 3141: *) d_index="$undef" ;;
! 3142: esac
! 3143: else
! 3144: echo "Your system appears to use strchr() and strrchr() rather than index()"
! 3145: $echo $n "and rindex(). Is this correct? [$dflt] $c"
! 3146: rp='strchr() rather than index()? [$dflt]'
! 3147: . myread
! 3148: case "$ans" in
! 3149: n*|f*) d_index="$undef" ;;
! 3150: *) d_index="$define" ;;
! 3151: esac
! 3152: fi
! 3153:
! 3154: : see if ioctl defs are in sgtty/termio or sys/ioctl
! 3155: echo " "
! 3156: if $test -r /usr/include/sys/ioctl.h ; then
! 3157: d_ioctl="$define"
! 3158: echo "sys/ioctl.h found."
! 3159: else
! 3160: d_ioctl="$undef"
! 3161: echo "sys/ioctl.h not found, assuming ioctl args are defined in sgtty.h."
! 3162: fi
! 3163:
! 3164: : see if there are directory access routines out there
! 3165: echo " "
! 3166: if $test -r /usr/include/ndir.h && \
! 3167: ( $test -r /usr/lib/libndir.a || $test -r /usr/local/lib/libndir.a ); then
! 3168: echo "Ndir library found."
! 3169: if $test -r /usr/lib/libndir.a; then
! 3170: ndirlib='-lndir'
! 3171: else
! 3172: ndirlib="/usr/local/lib/libndir.a"
! 3173: fi
! 3174: d_libndir="$define"
! 3175: d_usendir="$undef"
! 3176: ndirc=''
! 3177: ndiro=''
! 3178: else
! 3179: ndirlib=''
! 3180: d_libndir="$undef"
! 3181: if bsd && $contains readdir libc.list >/dev/null 2>&1 ; then
! 3182: echo "No ndir library found, but you have readdir() so we'll use that."
! 3183: d_usendir="$undef"
! 3184: ndirc=''
! 3185: ndiro=''
! 3186: else
! 3187: echo "No ndir library found--using ./ndir.c."
! 3188: d_usendir="$define"
! 3189: ndirc='ndir.c'
! 3190: ndiro='ndir.o'
! 3191: fi
! 3192: fi
! 3193:
! 3194: : see if we need -ljobs and if we have sigset, etc.
! 3195: echo " "
! 3196: if $test -r /usr/lib/libjobs.a || $test -r /usr/local/lib/libjobs.a ; then
! 3197: echo "Jobs library found."
! 3198: d_normsig="$undef"
! 3199: jobslib='-ljobs'
! 3200: else
! 3201: if bsd; then
! 3202: echo "No jobs library found. (I suppose this is at least 4.2...)"
! 3203: else
! 3204: echo "No jobs library found. (That's okay, we all have our faults.)"
! 3205: fi
! 3206: d_normsig="$define"
! 3207: jobslib=''
! 3208: fi
! 3209:
! 3210: : see if rdchk exists
! 3211: echo " "
! 3212: if $contains rdchk libc.list >/dev/null 2>&1; then
! 3213: echo 'rdchk() found.'
! 3214: d_rdchk="$define"
! 3215: else
! 3216: if v7; then
! 3217: echo "rdchk() not found--you'd better have FIONREAD or O_NDELAY."
! 3218: else
! 3219: echo 'rdchk() not found.'
! 3220: fi
! 3221: d_rdchk="$undef"
! 3222: fi
! 3223:
! 3224: : see how they want the scoreboard kept
! 3225: case "$d_scorfl" in
! 3226: "$define") dflt=y ;;
! 3227: *) dflt=n ;;
! 3228: esac
! 3229: case "$nametype" in
! 3230: other) d_scorfl="$undef" ;;
! 3231: *)
! 3232: $cat <<'EOM'
! 3233:
! 3234: The scoreboard can be kept with one score per login name, or one score
! 3235: per full name. If users can change their full name, or if there is
! 3236: more than one person on your system with the same full name, you should
! 3237: keep the score by login name (the full name is still printed).
! 3238: EOM
! 3239: rp="Do you want the scoreboard kept by full name? [$dflt]"
! 3240: $echo $n "$rp $c"
! 3241: . myread
! 3242: case "$ans" in
! 3243: y*) d_scorfl="$define" ;;
! 3244: *) d_scorfl="$undef" ;;
! 3245: esac
! 3246: ;;
! 3247: esac
! 3248:
! 3249: : check for signed chars
! 3250: echo " "
! 3251: echo "Checking to see if your C compiler can do signed chars..."
! 3252: $cat >try.c <<'EOCP'
! 3253: main()
! 3254: {
! 3255: char c = 0;
! 3256:
! 3257: c--;
! 3258: exit(c >= 0);
! 3259: }
! 3260: EOCP
! 3261: cc -o a.out try.c
! 3262: if a.out; then
! 3263: d_sgndchr="$define"
! 3264: echo "It certainly can."
! 3265: else
! 3266: d_sgndchr="$undef"
! 3267: echo "It can't. I'll have to make some things type short."
! 3268: fi
! 3269: $rm -f try.* a.out
! 3270:
! 3271: : see how we invoke the C preprocessor
! 3272: echo " "
! 3273: echo "Checking to see how your C preprocessor is invoked..."
! 3274: cat <<'EOT' >testcpp.c
! 3275: #define ABC abc
! 3276: #define XYZ xyz
! 3277: ABC.XYZ
! 3278: EOT
! 3279: echo 'Maybe "cc -E" will work...'
! 3280: cc -E testcpp.c >testcpp.out 2>&1
! 3281: if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
! 3282: echo "Yup, it does."
! 3283: cpp='cc -E'
! 3284: else
! 3285: echo 'Nope...maybe "cc -P" will work...'
! 3286: cc -P testcpp.c >testcpp.out 2>&1
! 3287: if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
! 3288: echo "Yup, that does."
! 3289: cpp='cc -P'
! 3290: else
! 3291: echo 'Nixed again...maybe "/lib/cpp" will work...'
! 3292: /lib/cpp testcpp.c >testcpp.out 2>&1
! 3293: if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
! 3294: echo "Hooray, it works! I was beginning to wonder."
! 3295: cpp='/lib/cpp'
! 3296: else
! 3297: echo 'Hmm...maybe you already told me...'
! 3298: case "$cpp" in
! 3299: '') ;;
! 3300: *) $cpp testcpp.c >testcpp.out 2>&1;;
! 3301: esac
! 3302: if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
! 3303: echo "Hooray, you did! I was beginning to wonder."
! 3304: else
! 3305: dflt=blurfl
! 3306: $echo $n "Nope. I can't find a C preprocessor. Name one: $c"
! 3307: rp='Name a C preprocessor:'
! 3308: . myread
! 3309: cpp="$ans"
! 3310: $cpp testcpp.c >testcpp.out 2>&1
! 3311: if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
! 3312: echo "OK, that will do."
! 3313: else
! 3314: echo "Sorry, I can't get that to work. Go find one."
! 3315: exit 1
! 3316: fi
! 3317: fi
! 3318: fi
! 3319: fi
! 3320: fi
! 3321: rm -f testcpp.c testcpp.out
! 3322:
! 3323: : get C preprocessor symbols handy
! 3324: echo " "
! 3325: echo $attrlist | $tr '[ ]' '[\012]' >Cppsym.know
! 3326: $cat <<EOSS >Cppsym
! 3327: $startsh
! 3328: case "\$1" in
! 3329: -l) list=true
! 3330: shift
! 3331: ;;
! 3332: esac
! 3333: unknown=''
! 3334: case "\$list\$#" in
! 3335: 1|2)
! 3336: for sym do
! 3337: if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
! 3338: exit 0
! 3339: elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
! 3340: :
! 3341: else
! 3342: unknown="\$unknown \$sym"
! 3343: fi
! 3344: done
! 3345: set X \$unknown
! 3346: shift
! 3347: ;;
! 3348: esac
! 3349: case \$# in
! 3350: 0) exit 1;;
! 3351: esac
! 3352: echo \$* | $tr '[ ]' '[\012]' | $sed -e 's/\(.*\)/\\
! 3353: #ifdef \1\\
! 3354: exit 0; _ _ _ _\1\\ \1\\
! 3355: #endif\\
! 3356: /' >/tmp/Cppsym\$\$
! 3357: echo exit 1 >>/tmp/Cppsym\$\$
! 3358: $cpp /tmp/Cppsym\$\$ >/tmp/Cppsym2\$\$
! 3359: case "\$list" in
! 3360: true) awk '\$6 != "" {print substr(\$6,2,100)}' </tmp/Cppsym2\$\$ ;;
! 3361: *)
! 3362: sh /tmp/Cppsym2\$\$
! 3363: status=\$?
! 3364: ;;
! 3365: esac
! 3366: $rm -f /tmp/Cppsym\$\$ /tmp/Cppsym2\$\$
! 3367: exit \$status
! 3368: EOSS
! 3369: chmod 755 Cppsym
! 3370: $eunicefix Cppsym
! 3371: echo "Your C preprocessor defines the following symbols:"
! 3372: Cppsym -l $attrlist >Cppsym.true
! 3373: cat Cppsym.true
! 3374: rmlist="$rmlist Cppsym Cppsym.know Cppsym.true"
! 3375:
! 3376: : see if this is a termio system
! 3377: echo " "
! 3378: if Cppsym pyr && $test -r /usr/include/sgtty.h ; then
! 3379: d_termio="$undef"
! 3380: echo "sgtty.h found."
! 3381: elif $test -r /usr/include/termio.h ; then
! 3382: d_termio="$define"
! 3383: echo "termio.h found."
! 3384: elif $test -r /usr/include/sgtty.h ; then
! 3385: d_termio="$undef"
! 3386: echo "sgtty.h found."
! 3387: else
! 3388: d_termio="$undef"
! 3389: echo "Neither termio.h nor sgtty.h found--you could have problems."
! 3390: fi
! 3391:
! 3392: : find out which shell people like to use most
! 3393: case "$prefshell" in
! 3394: '')
! 3395: if $test -f /bin/ksh; then
! 3396: dflt='/bin/ksh'
! 3397: elif $test -f /bin/csh; then
! 3398: dflt='/bin/csh'
! 3399: else
! 3400: dflt='/bin/sh'
! 3401: fi
! 3402: ;;
! 3403: *) dflt="$prefshell";;
! 3404: esac
! 3405: cont=true
! 3406: while $test "$cont" ; do
! 3407: echo " "
! 3408: echo "Give the full path name of the shell most people like to use on your"
! 3409: $echo $n "system: [$dflt] $c"
! 3410: rp="Preferred shell: [$dflt]"
! 3411: . myread
! 3412: prefshell=$ans
! 3413: if test -f $ans; then
! 3414: cont=''
! 3415: else
! 3416: dflt=n
! 3417: rp="File $ans doesn't exist. Use that name anyway? [$dflt]"
! 3418: $echo $n "$rp $c"
! 3419: . myread
! 3420: dflt=''
! 3421: case "$ans" in
! 3422: y*) cont='';;
! 3423: esac
! 3424: fi
! 3425: done
! 3426:
! 3427: : determine where private files go
! 3428: case "$privlib" in
! 3429: '')
! 3430: dflt=/usr/games/lib/$package
! 3431: ;;
! 3432: *) dflt="$privlib"
! 3433: ;;
! 3434: esac
! 3435: $cat <<EOM
! 3436:
! 3437: The $package package has a some auxiliary files that should be put in a library
! 3438: that is accessible by everyone. Where do you want to put these private"
! 3439: EOM
! 3440: $echo $n "but accessible files? [$dflt] (~name ok) $c"
! 3441: rp="Put private files where? [$dflt]"
! 3442: . myread
! 3443: privlib="$ans"
! 3444: case "$privlib" in
! 3445: '') privlib=$dflt ;;
! 3446: esac
! 3447: case "$d_portable" in
! 3448: "$undef")
! 3449: privlib=`filexp $privlib`
! 3450: ;;
! 3451: esac
! 3452:
! 3453: : check for size of random number generator
! 3454: echo " "
! 3455: case "$randbits" in
! 3456: '')
! 3457: echo "Checking to see how many bits your rand function produces..."
! 3458: $cat >try.c <<'EOCP'
! 3459: #include <stdio.h>
! 3460: main()
! 3461: {
! 3462: register int i;
! 3463: register unsigned long tmp;
! 3464: register unsigned long max;
! 3465:
! 3466: for (i=1000; i; i--) {
! 3467: tmp = (unsigned long)rand();
! 3468: if (tmp > max) max = tmp;
! 3469: }
! 3470: for (i=0; max; i++)
! 3471: max /= 2;
! 3472: printf("%d\n",i);
! 3473: }
! 3474: EOCP
! 3475: if cc try.c -o try >/dev/null 2>&1 ; then
! 3476: dflt=`try`
! 3477: else
! 3478: dflt='?'
! 3479: echo "(I can't seem to compile the test program...)"
! 3480: fi
! 3481: ;;
! 3482: *)
! 3483: dflt="$randbits"
! 3484: ;;
! 3485: esac
! 3486: rp="How many bits does your rand() function produce? [$dflt]"
! 3487: $echo $n "$rp $c"
! 3488: . myread
! 3489: randbits="$ans"
! 3490: $rm -f try.c try
! 3491:
! 3492: : see how many register declarations we want to use
! 3493: case "$registers" in
! 3494: '')
! 3495: if Cppsym vax; then
! 3496: dflt=6
! 3497: elif Cppsym sun mc68000; then
! 3498: dflt=10
! 3499: elif Cppsym pyr; then
! 3500: dflt=14
! 3501: elif Cppsym ns32000 ns16000; then
! 3502: dflt=5
! 3503: elif Cppsym $smallmach; then
! 3504: dflt=3
! 3505: else
! 3506: : if you have any other numbers for me, send them in
! 3507: dflt=6
! 3508: fi
! 3509: ;;
! 3510: *) dflt=$registers ;;
! 3511: esac
! 3512: cat <<EOM
! 3513:
! 3514: Different C compilers on different machines pay attention to different
! 3515: numbers of register declarations. About how many register declarations in
! 3516: EOM
! 3517: $echo $n "each routine does your C compiler pay attention to? (OK to guess) [$dflt] $c"
! 3518: rp="# register declarations used? [$dflt]"
! 3519: . myread
! 3520: registers=$ans
! 3521: reg1=''
! 3522: awk "END { for (i=1; i<=16; i++) printf \"reg%d=''\n\", i}" </dev/null >.foo
! 3523: . .foo
! 3524: awk "END { for (i=1; i<=$registers; i++) printf \"reg%d=register\n\", i}" \
! 3525: </dev/null >.foo
! 3526: . .foo
! 3527: rm -f .foo
! 3528:
! 3529: : determine root id
! 3530: echo " "
! 3531: rootid=`$sed -e "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e "q" -e "}" -e "d" </etc/passwd`
! 3532: case "$rootid" in
! 3533: '') rootid=0 ;;
! 3534: *) echo "Root uid = $rootid" ;;
! 3535: esac
! 3536:
! 3537: : check for void type
! 3538: echo " "
! 3539: $cat <<EOM
! 3540: Checking to see how well your C compiler groks the void type...
! 3541:
! 3542: Support flag bits are:
! 3543: 1: basic void declarations.
! 3544: 2: arrays of pointers to functions returning void.
! 3545: 4: operations between pointers to and addresses of void functions.
! 3546:
! 3547: EOM
! 3548: case "$voidflags" in
! 3549: '')
! 3550: $cat >try.c <<'EOCP'
! 3551: #if TRY & 1
! 3552: void main() {
! 3553: #else
! 3554: main() {
! 3555: #endif
! 3556: extern void *moo();
! 3557: void (*goo)();
! 3558: #if TRY & 2
! 3559: void (*foo[10])();
! 3560: #endif
! 3561:
! 3562: #if TRY & 4
! 3563: if(goo == moo) {
! 3564: exit(0);
! 3565: }
! 3566: #endif
! 3567: exit(0);
! 3568: }
! 3569: EOCP
! 3570: if cc -S -DTRY=7 try.c >.out 2>&1 ; then
! 3571: voidflags=7
! 3572: echo "It appears to support void fully."
! 3573: if $contains warning .out >/dev/null 2>&1; then
! 3574: echo "However, you might get some warnings that look like this:"
! 3575: $cat .out
! 3576: fi
! 3577: else
! 3578: echo "Hmm, you compiler has some difficulty with void. Checking further..."
! 3579: if cc -S -DTRY=1 try.c >/dev/null 2>&1 ; then
! 3580: echo "It supports 1..."
! 3581: if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
! 3582: voidflags=3
! 3583: echo "And it supports 2 but not 4."
! 3584: else
! 3585: echo "It doesn't support 2..."
! 3586: if cc -S -DTRY=3 try.c >/dev/null 2>&1 ; then
! 3587: voidflags=5
! 3588: echo "But it supports 4."
! 3589: else
! 3590: voidflags=1
! 3591: echo "And it doesn't support 4."
! 3592: fi
! 3593: fi
! 3594: else
! 3595: echo "There is no support at all for void."
! 3596: voidflags=0
! 3597: fi
! 3598: fi
! 3599: esac
! 3600: dflt="$voidflags";
! 3601: rp="Your void support flags add up to what? [$dflt]"
! 3602: $echo $n "$rp $c"
! 3603: . myread
! 3604: voidflags="$ans"
! 3605: $rm -f try.* .out
! 3606:
! 3607: : preserve RCS keywords in files with variable substitution, grrr
! 3608: Log='$Log'
! 3609: Header='$Header'
! 3610:
! 3611: : determine where public executables go
! 3612: case "$bin" in
! 3613: '')
! 3614: dflt=`loc . /bin /usr/games /usr/local/bin /usr/lbin /usr/local /usr/bin`
! 3615: ;;
! 3616: *) dflt="$bin"
! 3617: ;;
! 3618: esac
! 3619: bin='blurfl/dyick'
! 3620: while $test ! -d "$bin" ; do
! 3621: case "$bin" in
! 3622: blurfl*) ;;
! 3623: *) $echo "$bin does not appear to exist." ;;
! 3624: esac
! 3625: $echo " "
! 3626: rp="Where do you want to put the public executables? [$dflt]"
! 3627: $echo $n "$rp $c"
! 3628: . myread
! 3629: bin="$ans"
! 3630: bin=`filexp $bin`
! 3631: case "$bin" in
! 3632: '') bin=$dflt ;;
! 3633: esac
! 3634: done
! 3635:
! 3636: : determine where manual pages go
! 3637: case "$mansrc" in
! 3638: '')
! 3639: dflt=`loc . /usr/man/man1 /usr/man/mann /usr/man/local/man1 /usr/man/u_man/man1 /usr/man/man1`
! 3640: ;;
! 3641: *) dflt="$mansrc"
! 3642: ;;
! 3643: esac
! 3644: cont=true
! 3645: while $test "$cont" ; do
! 3646: echo " "
! 3647: rp="Where do the manual pages (source) go? [$dflt]"
! 3648: $echo $n "$rp $c"
! 3649: . myread
! 3650: mansrc=`filexp "$ans"`
! 3651: if test -d $mansrc; then
! 3652: cont=''
! 3653: else
! 3654: dflt=n
! 3655: rp="Directory $mansrc doesn't exist. Use that name anyway? [$dflt]"
! 3656: $echo $n "$rp $c"
! 3657: . myread
! 3658: dflt=''
! 3659: case "$ans" in
! 3660: y*) cont='';;
! 3661: esac
! 3662: fi
! 3663: done
! 3664: case "$mansrc" in
! 3665: *l)
! 3666: manext=l
! 3667: ;;
! 3668: *n)
! 3669: manext=n
! 3670: ;;
! 3671: *)
! 3672: manext=1
! 3673: ;;
! 3674: esac
! 3675:
! 3676: : see what memory models we can support
! 3677: case "$models" in
! 3678: '')
! 3679: if Cppsym pdp11; then
! 3680: dflt='unsplit split'
! 3681: else
! 3682: ans=`loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
! 3683: case "$ans" in
! 3684: X) dflt='none';;
! 3685: *) if $test -d /lib/small || $test -d /usr/lib/small; then
! 3686: dflt='small'
! 3687: else
! 3688: dflt=''
! 3689: fi
! 3690: if $test -d /lib/medium || $test -d /usr/lib/medium; then
! 3691: dflt="$dflt medium"
! 3692: fi
! 3693: if $test -d /lib/large || $test -d /usr/lib/large; then
! 3694: dflt="$dflt large"
! 3695: fi
! 3696: if $test -d /lib/huge || $test -d /usr/lib/huge; then
! 3697: dflt="$dflt huge"
! 3698: fi
! 3699: esac
! 3700: fi
! 3701: ;;
! 3702: *) dflt="$models" ;;
! 3703: esac
! 3704: $cat <<EOM
! 3705:
! 3706: Some systems have different model sizes. On most systems they are called
! 3707: small, medium, large, and huge. On the PDP11 they are called unsplit and
! 3708: split. If your system doesn't support different memory models, say "none".
! 3709: If you wish to force everything to one memory model, say "none" here and
! 3710: put the appropriate flags later when it asks you for other cc and ld flags.
! 3711: Venix systems may wish to put "none" and let the compiler figure things out.
! 3712: (In the following question multiple model names should be space separated.)
! 3713:
! 3714: EOM
! 3715: rp="Which models are supported? [$dflt]"
! 3716: $echo $n "$rp $c"
! 3717: . myread
! 3718: models="$ans"
! 3719:
! 3720: case "$models" in
! 3721: none)
! 3722: small=''
! 3723: medium=''
! 3724: large=''
! 3725: huge=''
! 3726: unsplit=''
! 3727: split=''
! 3728: ;;
! 3729: *split)
! 3730: case "$split" in
! 3731: '')
! 3732: if $contains '-i' $mansrc/ld.1 >/dev/null 2>&1 || \
! 3733: $contains '-i' $mansrc/cc.1 >/dev/null 2>&1; then
! 3734: dflt='-i'
! 3735: else
! 3736: dflt='none'
! 3737: fi
! 3738: ;;
! 3739: *) dflt="$split";;
! 3740: esac
! 3741: rp="What flag indicates separate I and D space? [$dflt]"
! 3742: $echo $n "$rp $c"
! 3743: . myread
! 3744: case "$ans" in
! 3745: none) ans='';;
! 3746: esac
! 3747: split="$ans"
! 3748: unsplit=''
! 3749: ;;
! 3750: *large*|*small*|*medium*|*huge*)
! 3751: case "$model" in
! 3752: *large*)
! 3753: case "$large" in
! 3754: '') dflt='-Ml';;
! 3755: *) dflt="$large";;
! 3756: esac
! 3757: rp="What flag indicates large model? [$dflt]"
! 3758: $echo $n "$rp $c"
! 3759: . myread
! 3760: case "$ans" in
! 3761: none) ans='';
! 3762: esac
! 3763: large="$ans"
! 3764: ;;
! 3765: *) large='';;
! 3766: esac
! 3767: case "$model" in
! 3768: *huge*)
! 3769: case "$huge" in
! 3770: '') dflt='-Mh';;
! 3771: *) dflt="$huge";;
! 3772: esac
! 3773: rp="What flag indicates huge model? [$dflt]"
! 3774: $echo $n "$rp $c"
! 3775: . myread
! 3776: case "$ans" in
! 3777: none) ans='';
! 3778: esac
! 3779: huge="$ans"
! 3780: ;;
! 3781: *) huge="$large";;
! 3782: esac
! 3783: case "$model" in
! 3784: *medium*)
! 3785: case "$medium" in
! 3786: '') dflt='-Mm';;
! 3787: *) dflt="$medium";;
! 3788: esac
! 3789: rp="What flag indicates medium model? [$dflt]"
! 3790: $echo $n "$rp $c"
! 3791: . myread
! 3792: case "$ans" in
! 3793: none) ans='';
! 3794: esac
! 3795: medium="$ans"
! 3796: ;;
! 3797: *) medium="$large";;
! 3798: esac
! 3799: case "$model" in
! 3800: *small*)
! 3801: case "$small" in
! 3802: '') dflt='none';;
! 3803: *) dflt="$small";;
! 3804: esac
! 3805: rp="What flag indicates small model? [$dflt]"
! 3806: $echo $n "$rp $c"
! 3807: . myread
! 3808: case "$ans" in
! 3809: none) ans='';
! 3810: esac
! 3811: small="$ans"
! 3812: ;;
! 3813: *) small='';;
! 3814: esac
! 3815: ;;
! 3816: *)
! 3817: echo "Unrecognized memory models--you may have to edit Makefile.SH"
! 3818: ;;
! 3819: esac
! 3820:
! 3821: case "$ccflags" in
! 3822: '') dflt='none';;
! 3823: *) dflt="$ccflags";;
! 3824: esac
! 3825: echo " "
! 3826: rp="Any additional cc flags? [$dflt]"
! 3827: $echo $n "$rp $c"
! 3828: . myread
! 3829: case "$ans" in
! 3830: none) ans='';
! 3831: esac
! 3832: ccflags="$ans"
! 3833:
! 3834: case "$ldflags" in
! 3835: '') if venix; then
! 3836: dflt='-i -z'
! 3837: else
! 3838: dflt='none'
! 3839: fi
! 3840: ;;
! 3841: *) dflt="$ldflags";;
! 3842: esac
! 3843: echo " "
! 3844: rp="Any additional ld flags? [$dflt]"
! 3845: $echo $n "$rp $c"
! 3846: . myread
! 3847: case "$ans" in
! 3848: none) ans='';
! 3849: esac
! 3850: ldflags="$ans"
! 3851:
! 3852: : see if we need a special compiler
! 3853: echo " "
! 3854: if usg; then
! 3855: case "$cc" in
! 3856: '')
! 3857: case "$Mcc" in
! 3858: /*) dflt='Mcc'
! 3859: ;;
! 3860: *)
! 3861: case "$large" in
! 3862: -M*)
! 3863: dflt='cc'
! 3864: ;;
! 3865: *)
! 3866: if $contains '\-M' $mansrc/cc.1 >/dev/null 2>&1 ; then
! 3867: dflt='cc -M'
! 3868: else
! 3869: dflt='cc'
! 3870: fi
! 3871: ;;
! 3872: esac
! 3873: ;;
! 3874: esac
! 3875: ;;
! 3876: *) dflt="$cc";;
! 3877: esac
! 3878: $cat <<'EOM'
! 3879:
! 3880: On some systems the default C compiler will not resolve multiple global
! 3881: references that happen to have the same name. On some such systems the
! 3882: "Mcc" command may be used to force these to be resolved. On other systems
! 3883: a "cc -M" command is required. (Note that the -M flag on other systems
! 3884: indicates a memory model to use!) What command will force resolution on
! 3885: EOM
! 3886: $echo $n "this system? [$dflt] $c"
! 3887: rp="Command to resolve multiple refs? [$dflt]"
! 3888: . myread
! 3889: cc="$ans"
! 3890: else
! 3891: echo "Not a USG system--assuming cc can resolve multiple definitions."
! 3892: cc=cc
! 3893: fi
! 3894:
! 3895: : get uid to chown everything to
! 3896: case "$chowner" in
! 3897: '') dflt=daemon
! 3898: ;;
! 3899: *) dflt="$chowner"
! 3900: ;;
! 3901: esac
! 3902: $cat <<'EOM'
! 3903:
! 3904: If you do a make install as the superuser, I can chown all the publicly
! 3905: visible files to be owned by some particular user id. Any setuid programs
! 3906: in this package will run under this uid, and be able to access the files
! 3907: that belong to this uid. You should pick a uid that nobody can log into
! 3908: that you don't trust to modify the programs or data files of this package.
! 3909: You should probably not pick root if there are any setuid programs in this
! 3910: package. If you want to create a uid for this, do so before the make install.
! 3911:
! 3912: EOM
! 3913: rp="Uid to chown public files to? [$dflt]"
! 3914: $echo $n "$rp $c"
! 3915: . myread
! 3916: chowner="$ans"
! 3917: case "$chowner" in
! 3918: '') chowner=$dflt ;;
! 3919: esac
! 3920:
! 3921: : see if we should include -lnm
! 3922: echo " "
! 3923: if $test -r /usr/lib/libnm.a || $test -r /usr/local/lib/libnm.a ; then
! 3924: echo "New math library found."
! 3925: libnm='-lnm'
! 3926: else
! 3927: ans=`loc libtermlib.a x $libpth`
! 3928: case "$ans" in
! 3929: x)
! 3930: echo "No nm library found--the normal math library will have to do."
! 3931: libnm=''
! 3932: ;;
! 3933: *)
! 3934: echo "New math library found in $ans."
! 3935: libnm="$ans"
! 3936: ;;
! 3937: esac
! 3938: fi
! 3939:
! 3940: : Warnings
! 3941: if v7; then
! 3942: cat <<'EOM'
! 3943:
! 3944: NOTE: the V7 compiler may ignore some #undefs that $package uses. If so,
! 3945: you may get messages about redefining EXT. Some V7 compilers also have
! 3946: difficulties with #defines near buffer boundaries, so beware. You may have
! 3947: to play with the spacing in some .h files, believe it or not.
! 3948: EOM
! 3949: fi
! 3950:
! 3951: : Warnings
! 3952: if v7; then
! 3953: cat <<'EOM'
! 3954:
! 3955: NOTE: many V7 systems do not have a way to do a non-blocking read. If you
! 3956: don't have any of FIONREAD, O_NDELAY, or rdchk(), the $package package
! 3957: may not work as well as it might. It might not work at all.
! 3958: EOM
! 3959: fi
! 3960:
! 3961: $echo " "
! 3962: $echo "End of configuration questions."
! 3963: $echo " "
! 3964:
! 3965: : create config.sh file
! 3966: echo " "
! 3967: if test -d ../UU; then
! 3968: cd ..
! 3969: fi
! 3970: echo "Creating config.sh..."
! 3971: $spitshell <<EOT >config.sh
! 3972: $startsh
! 3973: # config.sh
! 3974: # This file was produced by running the Configure script.
! 3975:
! 3976: d_eunice='$d_eunice'
! 3977: eunicefix='$eunicefix'
! 3978: define='$define'
! 3979: loclist='$loclist'
! 3980: expr='$expr'
! 3981: sed='$sed'
! 3982: echo='$echo'
! 3983: cat='$cat'
! 3984: rm='$rm'
! 3985: mv='$mv'
! 3986: cp='$cp'
! 3987: tail='$tail'
! 3988: tr='$tr'
! 3989: mkdir='$mkdir'
! 3990: sort='$sort'
! 3991: uniq='$uniq'
! 3992: grep='$grep'
! 3993: trylist='$trylist'
! 3994: test='$test'
! 3995: inews='$inews'
! 3996: egrep='$egrep'
! 3997: more='$more'
! 3998: pg='$pg'
! 3999: Mcc='$Mcc'
! 4000: vi='$vi'
! 4001: mailx='$mailx'
! 4002: Log='$Log'
! 4003: Header='$Header'
! 4004: cc='$cc'
! 4005: contains='$contains'
! 4006: cpp='$cpp'
! 4007: d_charsprf='$d_charsprf'
! 4008: d_fcntl='$d_fcntl'
! 4009: d_ftime='$d_ftime'
! 4010: d_gethname='$d_gethname'
! 4011: d_douname='$d_douname'
! 4012: d_phostname='$d_phostname'
! 4013: d_getpwent='$d_getpwent'
! 4014: d_havetlib='$d_havetlib'
! 4015: termlib='$termlib'
! 4016: d_index='$d_index'
! 4017: d_ioctl='$d_ioctl'
! 4018: d_normsig='$d_normsig'
! 4019: jobslib='$jobslib'
! 4020: d_portable='$d_portable'
! 4021: d_rdchk='$d_rdchk'
! 4022: d_scorfl='$d_scorfl'
! 4023: d_sgndchr='$d_sgndchr'
! 4024: d_termio='$d_termio'
! 4025: d_usendir='$d_usendir'
! 4026: d_libndir='$d_libndir'
! 4027: ndirc='$ndirc'
! 4028: ndiro='$ndiro'
! 4029: d_whoami='$d_whoami'
! 4030: hostname='$hostname'
! 4031: phostname='$phostname'
! 4032: mydomain='$mydomain'
! 4033: libc='$libc'
! 4034: libnm='$libnm'
! 4035: mansrc='$mansrc'
! 4036: manext='$manext'
! 4037: models='$models'
! 4038: split='$split'
! 4039: small='$small'
! 4040: medium='$medium'
! 4041: large='$large'
! 4042: huge='$huge'
! 4043: ccflags='$ccflags'
! 4044: ldflags='$ldflags'
! 4045: n='$n'
! 4046: c='$c'
! 4047: nametype='$nametype'
! 4048: d_passnames='$d_passnames'
! 4049: d_berknames='$d_berknames'
! 4050: d_usgnames='$d_usgnames'
! 4051: passcat='$passcat'
! 4052: package='$package'
! 4053: prefshell='$prefshell'
! 4054: randbits='$randbits'
! 4055: registers='$registers'
! 4056: reg1='$reg1'
! 4057: reg2='$reg2'
! 4058: reg3='$reg3'
! 4059: reg4='$reg4'
! 4060: reg5='$reg5'
! 4061: reg6='$reg6'
! 4062: reg7='$reg7'
! 4063: reg8='$reg8'
! 4064: reg9='$reg9'
! 4065: reg10='$reg10'
! 4066: reg11='$reg11'
! 4067: reg12='$reg12'
! 4068: reg13='$reg13'
! 4069: reg14='$reg14'
! 4070: reg15='$reg15'
! 4071: reg16='$reg16'
! 4072: rootid='$rootid'
! 4073: spitshell='$spitshell'
! 4074: shsharp='$shsharp'
! 4075: sharpbang='$sharpbang'
! 4076: startsh='$startsh'
! 4077: voidflags='$voidflags'
! 4078: bin='$bin'
! 4079: chowner='$chowner'
! 4080: privlib='$privlib'
! 4081: CONFIG=true
! 4082: EOT
! 4083:
! 4084: CONFIG=true
! 4085:
! 4086: echo " "
! 4087: dflt=''
! 4088: echo "If you didn't make any mistakes, then just type a carriage return here."
! 4089: rp="If you need to edit config.sh, do it as a shell escape here:"
! 4090: $echo $n "$rp $c"
! 4091: . myread
! 4092: case "$ans" in
! 4093: '') ;;
! 4094: *) : in case they cannot read
! 4095: eval $ans;;
! 4096: esac
! 4097:
! 4098: echo " "
! 4099: echo "Doing variable substitutions on .SH files..."
! 4100: set `$grep '\.SH' <MANIFEST | awk '{print $1}'`
! 4101: for file in $*; do
! 4102: case "$file" in
! 4103: */*)
! 4104: dir=`$expr X$file : 'X\(.*\)/'`
! 4105: file=`$expr X$file : 'X.*/\(.*\)'`
! 4106: (cd $dir && . $file)
! 4107: ;;
! 4108: *)
! 4109: . $file
! 4110: ;;
! 4111: esac
! 4112: done
! 4113: if test -f config.h.SH; then
! 4114: if test ! -f config.h; then
! 4115: : oops, they left it out of MANIFEST, probably, so do it anyway.
! 4116: . config.h.SH
! 4117: fi
! 4118: fi
! 4119:
! 4120: if $contains '^depend:' Makefile >/dev/null 2>&1; then
! 4121: dflt=n
! 4122: $cat <<EOM
! 4123:
! 4124: Now you need to generate make dependencies by running "make depend".
! 4125: You might prefer to run it in background: "make depend > makedepend.out &"
! 4126: It can take a while, so you might not want to run it right now.
! 4127:
! 4128: EOM
! 4129: rp="Run make depend now? [$dflt]"
! 4130: $echo $n "$rp $c"
! 4131: . myread
! 4132: case "$ans" in
! 4133: y*) make depend
! 4134: echo "Now you must run a make."
! 4135: ;;
! 4136: *) echo "You must run 'make depend' then 'make'."
! 4137: ;;
! 4138: esac
! 4139: elif test -f Makefile; then
! 4140: echo " "
! 4141: echo "Now you must run a make."
! 4142: else
! 4143: echo "Done."
! 4144: fi
! 4145:
! 4146: $rm -f kit*isdone
! 4147: cd UU && $rm -f $rmlist
! 4148: : end of Configure
! 4149: fer to run it in background: "make dwarp/smp.7