home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume5 / omega2 / part05 / ofile.c < prev   
C/C++ Source or Header  |  1988-07-22  |  22KB  |  925 lines

  1. /* omega (c) 1987,1988 by Laurence Raphael Brothers */
  2. /* ofile.c */
  3. /* functions with file access in them. Also some direct calls to
  4.    curses functions */
  5.  
  6. #include <curses.h>
  7. #include <sys/file.h>
  8. #include "oglob.h"
  9.  
  10. #ifndef F_OK
  11. #define F_OK 00 
  12. #define R_OK 04
  13. #define W_OK 02
  14. #endif
  15.  
  16. FILE *checkfopen(filestring,optionstring)
  17. char *filestring,*optionstring;
  18. {
  19.   FILE *fd;
  20.   char response;
  21.   fd = fopen(filestring,optionstring);
  22.   clearmsg();
  23.   while (fd == NULL) {
  24.     print3("Warning! Error opening file:");
  25.     nprint3(filestring);
  26.     print1(" Abort or Retry? [ar] ");
  27.     do response = mcigetc(); while ((response != 'a') && (response != 'r'));
  28.     if (response == 'r') fd = fopen(filestring,optionstring);
  29.     else {
  30.       print2("Sorry 'bout that.... Bye!");
  31.       morewait();
  32.       endgraf();
  33.       exit(0);
  34.     }
  35.   }
  36.   return(fd);
  37. }
  38.  
  39. void commandlist()
  40. {
  41.   FILE *fd; 
  42.   strcpy(Str1,OMEGALIB);
  43.   if (Current_Environment == E_COUNTRYSIDE)
  44.     strcat(Str1,"occmds.txt");
  45.   else strcat(Str1,"ocmds.txt");
  46.   fd = checkfopen(Str1,"r");
  47.   showfile(fd);
  48.   fclose(fd);
  49.   clear();
  50.   refresh();
  51.   xredraw();
  52. }
  53.  
  54.  
  55. void user_intro()
  56. {
  57.   FILE *fd; 
  58.   strcpy(Str1,OMEGALIB);
  59.   strcat(Str1,"ointro.txt");
  60.   fd = checkfopen(Str1,"r");
  61.   showfile(fd);
  62.   fclose(fd);
  63.   clear();
  64.   refresh();
  65.   xredraw();
  66. }
  67.  
  68. void show_license()
  69. {
  70.   FILE *fd; 
  71.   strcpy(Str1,OMEGALIB);
  72.   strcat(Str1,"olicense.txt");
  73.   fd = checkfopen(Str1,"r");
  74.   showfile(fd);
  75.   fclose(fd);
  76.   clear();
  77.   refresh();
  78.   xredraw();
  79. }
  80.  
  81.  
  82.  
  83. void abyss_file()
  84. {
  85.   FILE *fd; 
  86.   strcpy(Str1,OMEGALIB);
  87.   strcat(Str1,"oabyss.txt");
  88.   fd = checkfopen(Str1,"r");
  89.   showfile(fd);
  90.   fclose(fd);
  91.   clear();
  92.   refresh();
  93. }
  94.  
  95.  
  96.  
  97.  
  98. void inv_help()
  99. {
  100.   FILE *fd; 
  101.   strcpy(Str1,OMEGALIB);
  102.   strcat(Str1,"ohelp3.txt");
  103.   fd = checkfopen(Str1,"r");
  104.   showfile(fd);
  105.   fclose(fd);
  106.   clear();
  107.   refresh();
  108.   xredraw();
  109. }
  110.  
  111.  
  112.  
  113. void combat_help()
  114. {
  115.   FILE *fd; 
  116.   strcpy(Str1,OMEGALIB);
  117.   strcat(Str1,"ohelp5.txt");
  118.   fd = checkfopen(Str1,"r");
  119.   showfile(fd);
  120.   fclose(fd);
  121.   clear();
  122.   refresh();
  123.   xredraw();
  124. }
  125.  
  126.  
  127.  
  128.  
  129. void cityguidefile()
  130. {
  131.   FILE *fd;
  132.   strcpy(Str1,OMEGALIB);
  133.   strcat(Str1,"oscroll2.txt");
  134.   fd = checkfopen(Str1,"r");
  135.   showfile(fd);
  136.   fclose(fd);
  137.   clear();
  138.   refresh();
  139.   xredraw();
  140. }
  141.  
  142.  
  143. void wishfile()
  144. {
  145.   FILE *fd;
  146.   strcpy(Str1,OMEGALIB);
  147.   strcat(Str1,"oscroll3.txt");
  148.   fd = checkfopen(Str1,"r");
  149.   showfile(fd);
  150.   fclose(fd);
  151.   clear();
  152.   refresh();
  153.   xredraw();
  154. }
  155.  
  156. void adeptfile()
  157. {
  158.   FILE *fd;
  159.   strcpy(Str1,OMEGALIB);
  160.   strcat(Str1,"oscroll4.txt");
  161.   fd = checkfopen(Str1,"r");
  162.   showfile(fd);
  163.   fclose(fd);
  164.   clear();
  165.   refresh();
  166.   xredraw();
  167. }
  168.  
  169. void theologyfile()
  170. {
  171.   FILE *fd;
  172.   strcpy(Str1,OMEGALIB);
  173.   strcat(Str1,"oscroll1.txt");
  174.   fd = checkfopen(Str1,"r");
  175.   showfile(fd);
  176.   fclose(fd);
  177.   clear();
  178.   refresh();
  179.   xredraw();
  180. }
  181.  
  182.  
  183. void showmotd()
  184. {
  185.   FILE *fd;
  186.   strcpy(Str1,OMEGALIB);
  187.   strcat(Str1,"omotd.txt");
  188.   fd = checkfopen(Str1,"r");
  189.   showfile(fd);
  190.   fclose(fd);
  191.   clear();
  192.   refresh();
  193. }
  194.  
  195.  
  196.  
  197.  
  198. /* display a file page at a time */
  199. void showfile(fd)
  200. FILE *fd;
  201. {
  202.   int c,d=' ';
  203.   int x,y;
  204.   clear();
  205.   refresh();
  206.   c = fgetc(fd);
  207.   while ((c != EOF)&&((char) d != 'q')&&((char) d!=ESCAPE)) {
  208.     getyx(stdscr,y,x);
  209.     if (y > ScreenLength) {
  210.       printw("\n-More-");
  211.       refresh();
  212.       d = wgetch(stdscr);
  213.       clear();
  214.     }
  215.     printw("%c",(char) c);
  216.     c = fgetc(fd);
  217.   }
  218.   if (((char) d != 'q')&&((char) d!=ESCAPE)) {
  219.     printw("\n-Done-");
  220.     refresh();
  221.     getch();
  222.   }
  223. }    
  224.  
  225.  
  226.  
  227. void showscores()
  228. {
  229.   FILE *fd;
  230.   int i;
  231.   strcpy(Str1,OMEGALIB);
  232.   strcat(Str1,"omega.hi");
  233.   fd = checkfopen(Str1,"r");
  234.   filescanstring(fd,Hiscorer);
  235.   filescanstring(fd,Hidescrip);
  236.   fscanf(fd,"%d\n%d\n%d\n",&Hiscore,&Hilevel,&Hibehavior);
  237.   filescanstring(fd,Chaoslord);
  238.   fscanf(fd,"%d\n%d\n%d\n",&Chaoslordlevel,&Chaos,&Chaoslordbehavior);
  239.   filescanstring(fd,Lawlord);
  240.   fscanf(fd,"%d\n%d\n%d\n",&Lawlordlevel,&Law,&Lawlordbehavior);
  241.   filescanstring(fd,Duke);
  242.   fscanf(fd,"%d\n%d\n",&Dukelevel,&Dukebehavior);
  243.   filescanstring(fd,Justiciar);
  244.   fscanf(fd,"%d\n%d\n",&Justiciarlevel,&Justiciarbehavior);
  245.   filescanstring(fd,Commandant);
  246.   fscanf(fd,"%d\n%d\n",&Commandantlevel,&Commandantbehavior);
  247.   filescanstring(fd,Champion);
  248.   fscanf(fd,"%d\n%d\n",&Championlevel,&Championbehavior);
  249.   filescanstring(fd,Archmage);
  250.   fscanf(fd,"%d\n%d\n",&Archmagelevel,&Archmagebehavior);
  251.   filescanstring(fd,Prime);
  252.   fscanf(fd,"%d\n%d\n",&Primelevel,&Primebehavior);
  253.   filescanstring(fd,Shadowlord);
  254.   fscanf(fd,"%d\n%d\n",&Shadowlordlevel,&Shadowlordbehavior);
  255.   for(i=1;i<7;i++) {
  256.     filescanstring(fd,Priest[i]);
  257.     fscanf(fd,"%d\n%d\n",&(Priestlevel[i]),&(Priestbehavior[i]));
  258.   }
  259.   fclose(fd);
  260.   clear();
  261.   printw("High Score: %d",Hiscore);
  262.   printw(", by %s (%s)",Hiscorer,levelname(Hilevel));
  263.   printw("\n%s\n",Hidescrip);
  264.   printw("\nLord of Chaos: %s (%s)",Chaoslord,levelname(Chaoslordlevel));
  265.   printw("\nLord of Law: %s (%s)",Lawlord,levelname(Lawlordlevel));
  266.   printw("\n\nDuke of Rampart:              ");
  267.   printw("%s (%s)",Duke,levelname(Dukelevel));
  268.   printw("\nJusticiar:                    ");
  269.   printw("%s (%s)",Justiciar,levelname(Justiciarlevel));
  270.   printw("\nCommandant:                   ");
  271.   printw("%s (%s)",Commandant,levelname(Commandantlevel));
  272.   printw("\nChampion:                     ");
  273.   printw("%s (%s)",Champion,levelname(Championlevel));
  274.   printw("\nArchmage:                     ");
  275.   printw("%s (%s)",Archmage,levelname(Archmagelevel));
  276.   printw("\nPrime Sorceror:               ");
  277.   printw("%s (%s)",Prime,levelname(Primelevel));
  278.   printw("\nShadowlord:                   ");
  279.   printw("%s (%s)",Shadowlord,levelname(Shadowlordlevel));
  280.   printw("\n\nHigh Priests:");
  281.   printw("\n of Odin:                     ");
  282.   printw("%s (%s)",Priest[ODIN],levelname(Priestlevel[ODIN]));
  283.   printw("\n of Set:                      ");
  284.   printw("%s (%s)",Priest[SET],levelname(Priestlevel[SET]));
  285.   printw("\n of Athena:                   ");
  286.   printw("%s (%s)",Priest[ATHENA],levelname(Priestlevel[ATHENA]));
  287.   printw("\n of Hecate:                   ");
  288.   printw("%s (%s)",Priest[HECATE],levelname(Priestlevel[HECATE]));
  289.   printw("\n of the Lords of Destiny:     ");
  290.   printw("%s (%s)",Priest[DESTINY],levelname(Priestlevel[DESTINY]));
  291.   printw("\nThe ArchDruid:                ");
  292.   printw("%s (%s)",Priest[DRUID],levelname(Priestlevel[DRUID]));
  293.   printw("\n\nHit any key to continue.");
  294.   refresh();
  295.   wgetch(stdscr);
  296. }
  297.  
  298.  
  299. /* writes a new high score file */
  300. void checkhigh(descrip,behavior)
  301. char *descrip;
  302. int behavior;
  303. {
  304.   int i,points;
  305.   FILE *fd;
  306.  
  307.   if (FixedPoints > 0) points = FixedPoints;
  308.   else points = calc_points();
  309.  
  310.   if (! gamestatusp(CHEATED)) {
  311.     strcpy(Str1,OMEGALIB);
  312.     strcat(Str1,"omega.hi");
  313.     fd = checkfopen(Str1,"w");
  314.     
  315.     if (Hiscore < points) {
  316.       morewait();
  317.       mprint("Yow! A new high score!");
  318.       fprintf(fd,"%s\n",Player.name);
  319.       fprintf(fd,"%s\n",descrip);
  320.       fprintf(fd,"%d\n",points);
  321.       fprintf(fd,"%d\n",Player.level);
  322.       fprintf(fd,"%d\n",behavior);
  323.     }
  324.     else {
  325.       fprintf(fd,"%s\n",Hiscorer);
  326.       fprintf(fd,"%s\n",Hidescrip);
  327.       fprintf(fd,"%d\n",Hiscore);
  328.       fprintf(fd,"%d\n",Hilevel);
  329.       fprintf(fd,"%d\n",Hibehavior);
  330.     }
  331.  
  332.  
  333.  
  334.     if (Player.alignment < Chaos) {
  335.       morewait();
  336.       mprint("Criminy! A new Lord of Chaos!");
  337.       fprintf(fd,"%s\n",Player.name);
  338.       fprintf(fd,"%d\n",Player.level);
  339.       fprintf(fd,"%d\n",Player.alignment);
  340.       fprintf(fd,"%d\n",behavior);
  341.     }
  342.     else {
  343.       fprintf(fd,"%s\n",Chaoslord);
  344.       fprintf(fd,"%d\n",Chaoslordlevel);
  345.       fprintf(fd,"%d\n",Chaos);
  346.       fprintf(fd,"%d\n",Chaoslordbehavior);
  347.     }
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.     if (Player.alignment > Law) {
  355.       morewait();
  356.       mprint("Gosh! A new Lord of Law!");
  357.       fprintf(fd,"%s\n",Player.name);
  358.       fprintf(fd,"%d\n",Player.level);
  359.       fprintf(fd,"%d\n",Player.alignment);
  360.       fprintf(fd,"%d\n",behavior);
  361.     }
  362.     else {
  363.       fprintf(fd,"%s\n",Lawlord);
  364.       fprintf(fd,"%d\n",Lawlordlevel);
  365.       fprintf(fd,"%d\n",Law);
  366.       fprintf(fd,"%d\n",Lawlordbehavior);
  367.     }
  368.  
  369.  
  370.  
  371.  
  372.     fprintf(fd,"%s",Duke);
  373.     fprintf(fd,"\n%d",Dukelevel);
  374.     if (Player.rank[NOBILITY] == DUKE)
  375.       fprintf(fd,"\n%d",behavior);
  376.     else fprintf(fd,"\n%d",Dukebehavior);
  377.     fprintf(fd,"\n%s",Justiciar);
  378.     fprintf(fd,"\n%d",Justiciarlevel);
  379.     if (Player.rank[ORDER] == JUSTICIAR)
  380.       fprintf(fd,"\n%d",behavior);
  381.     else fprintf(fd,"\n%d",Justiciarbehavior);
  382.     fprintf(fd,"\n%s",Commandant);
  383.     fprintf(fd,"\n%d",Commandantlevel);
  384.     if (Player.rank[LEGION] == COMMANDANT)
  385.       fprintf(fd,"\n%d",behavior);
  386.     else fprintf(fd,"\n%d",Commandantbehavior);
  387.     fprintf(fd,"\n%s",Champion);
  388.     fprintf(fd,"\n%d",Championlevel);
  389.     if (Player.rank[ARENA] == CHAMPION)
  390.       fprintf(fd,"\n%d",behavior);
  391.     else fprintf(fd,"\n%d",Championbehavior);
  392.     fprintf(fd,"\n%s",Archmage);
  393.     fprintf(fd,"\n%d",Archmagelevel);
  394.     if (Player.rank[COLLEGE] == ARCHMAGE)
  395.       fprintf(fd,"\n%d",behavior);
  396.     else fprintf(fd,"\n%d",Archmagebehavior);
  397.     fprintf(fd,"\n%s",Prime);
  398.     fprintf(fd,"\n%d",Primelevel);
  399.     if (Player.rank[CIRCLE] == PRIME)
  400.       fprintf(fd,"\n%d",behavior);
  401.     else fprintf(fd,"\n%d",Primebehavior);
  402.     fprintf(fd,"\n%s",Shadowlord);
  403.     fprintf(fd,"\n%d",Shadowlordlevel);
  404.     if (Player.rank[THIEVES] == SHADOWLORD)
  405.       fprintf(fd,"\n%d",behavior);
  406.     else fprintf(fd,"\n%d",Shadowlordbehavior);
  407.     for(i=1;i<7;i++) {
  408.       fprintf(fd,"\n%s",Priest[i]);
  409.       fprintf(fd,"\n%d",Priestlevel[i]);
  410.       if ((Player.rank[PRIESTHOOD] == HIGHPRIEST) && (Player.patron == i))
  411.     fprintf(fd,"\n%d",behavior);
  412.       else fprintf(fd,"\n%d",Priestbehavior[i]);
  413.     }
  414.     fprintf(fd,"\n");
  415.     fclose(fd);
  416.   }
  417. }
  418.  
  419. void extendlog(descrip,lifestatus)
  420. char *descrip;
  421. int lifestatus;
  422. {
  423.   FILE *fd;
  424.   char username[60];
  425.   int npcbehavior;
  426.   strcpy(username,getlogin());
  427.   if ((Player.level > 0) && (! gamestatusp(CHEATED))) {
  428.     npcbehavior=fixnpc(lifestatus);
  429.     checkhigh(descrip,npcbehavior);
  430.     strcpy(Str1,OMEGALIB);
  431.     strcat(Str1,"omega.log");
  432.     fd = checkfopen(Str1,"a");
  433.     fprintf(fd,
  434.         " %d %d %d %s\n",
  435.         lifestatus,
  436.         Player.level,
  437.         npcbehavior,
  438.         Player.name);
  439.     fclose(fd);
  440.   }
  441. }
  442.  
  443.  
  444.  
  445.  
  446.  
  447. /* reads a string from a file. If it is a line with more than 80 char's,
  448.    then remainder of line to \n is consumed */
  449. void filescanstring(fd,fstr)
  450. FILE *fd;
  451. char *fstr;
  452. {
  453.   int i= -1;
  454.   int byte='x';
  455.   while ((i<80) && (byte != '\n') && (byte != EOF)) {
  456.     i++;
  457.     byte=fgetc(fd);
  458.     fstr[i] = byte;
  459.   } 
  460.   if (byte != '\n')
  461.     while((byte!='\n') && (byte != EOF))
  462.       byte=fgetc(fd);
  463.   fstr[i]=0;
  464. }
  465.  
  466.  
  467. /* Checks existence of omega data files */
  468. /* Returns 1 if OK, 0 if impossible to run, -1 if possible but not OK */
  469. int filecheck()
  470. {
  471.   int impossible=FALSE,badbutpossible=FALSE;
  472.   int result;
  473.  
  474.   strcpy(Str1,OMEGALIB);
  475.   strcat(Str1,"ocity.dat");
  476.   result = access(Str1,F_OK|R_OK);
  477.   if (result == -1) {
  478.     impossible = TRUE;
  479.     printf("\nWarning! File not accessible:");
  480.     printf(Str1);
  481.   }
  482.  
  483.   strcpy(Str1,OMEGALIB);
  484.   strcat(Str1,"ocountry.dat");
  485.   result = access(Str1,F_OK|R_OK);
  486.   if (result == -1) {
  487.     impossible = TRUE;
  488.     printf("\nWarning! File not accessible:");
  489.     printf(Str1);
  490.   }
  491.  
  492.   strcpy(Str1,OMEGALIB);
  493.   strcat(Str1,"odlair.dat");
  494.   result = access(Str1,F_OK|R_OK);
  495.   if (result == -1) {
  496.     impossible = TRUE;
  497.     printf("\nWarning! File not accessible:");
  498.     printf(Str1);
  499.   }
  500.  
  501.   strcpy(Str1,OMEGALIB);
  502.   strcat(Str1,"omisle.dat");
  503.   result = access(Str1,F_OK|R_OK);
  504.   if (result == -1) {
  505.     impossible = TRUE;
  506.     printf("\nWarning! File not accessible:");
  507.     printf(Str1);
  508.   }
  509.   strcpy(Str1,OMEGALIB);
  510.   strcat(Str1,"ocourt.dat");
  511.   result = access(Str1,F_OK|R_OK);
  512.   if (result == -1) {
  513.     impossible = TRUE;
  514.     printf("\nWarning! File not accessible:");
  515.     printf(Str1);
  516.   }
  517.  
  518.   strcpy(Str1,OMEGALIB);
  519.   strcat(Str1,"ospeak.dat");
  520.   result = access(Str1,F_OK|R_OK);
  521.   if (result == -1) {
  522.     impossible = TRUE;
  523.     printf("\nWarning! File not accessible:");
  524.     printf(Str1);
  525.   }
  526.  
  527.   strcpy(Str1,OMEGALIB);
  528.   strcat(Str1,"otemple.dat");
  529.   result = access(Str1,F_OK|R_OK);
  530.   if (result == -1) {
  531.     impossible = TRUE;
  532.     printf("\nWarning! File not accessible:");
  533.     printf(Str1);
  534.   }
  535.  
  536.   strcpy(Str1,OMEGALIB);
  537.   strcat(Str1,"oabyss.dat");
  538.   result = access(Str1,F_OK|R_OK);
  539.   if (result == -1) {
  540.     impossible = TRUE;
  541.     printf("\nWarning! File not accessible:");
  542.     printf(Str1);
  543.   }
  544.  
  545.   strcpy(Str1,OMEGALIB);
  546.   strcat(Str1,"ovillage1.dat");
  547.   result = access(Str1,F_OK|R_OK);
  548.   if (result == -1) {
  549.     impossible = TRUE;
  550.     printf("\nWarning! File not accessible:");
  551.     printf(Str1);
  552.   }
  553.   strcpy(Str1,OMEGALIB);
  554.   strcat(Str1,"ovillage2.dat");
  555.   result = access(Str1,F_OK|R_OK);
  556.   if (result == -1) {
  557.     impossible = TRUE;
  558.     printf("\nWarning! File not accessible:");
  559.     printf(Str1);
  560.   }
  561.   strcpy(Str1,OMEGALIB);
  562.   strcat(Str1,"ovillage3.dat");
  563.   result = access(Str1,F_OK|R_OK);
  564.   if (result == -1) {
  565.     impossible = TRUE;
  566.     printf("\nWarning! File not accessible:");
  567.     printf(Str1);
  568.   }
  569.   strcpy(Str1,OMEGALIB);
  570.   strcat(Str1,"ovillage4.dat");
  571.   result = access(Str1,F_OK|R_OK);
  572.   if (result == -1) {
  573.     impossible = TRUE;
  574.     printf("\nWarning! File not accessible:");
  575.     printf(Str1);
  576.   }
  577.  
  578.   strcpy(Str1,OMEGALIB);
  579.   strcat(Str1,"ohome1.dat");
  580.   result = access(Str1,F_OK|R_OK);
  581.   if (result == -1) {
  582.     impossible = TRUE;
  583.     printf("\nWarning! File not accessible:");
  584.     printf(Str1);
  585.   }
  586.  
  587.   strcpy(Str1,OMEGALIB);
  588.   strcat(Str1,"ohome2.dat");
  589.   result = access(Str1,F_OK|R_OK);
  590.   if (result == -1) {
  591.     impossible = TRUE;
  592.     printf("\nWarning! File not accessible:");
  593.     printf(Str1);
  594.   }
  595.  
  596.   strcpy(Str1,OMEGALIB);
  597.   strcat(Str1,"ohome3.dat");
  598.   result = access(Str1,F_OK|R_OK);
  599.   if (result == -1) {
  600.     impossible = TRUE;
  601.     printf("\nWarning! File not accessible:");
  602.     printf(Str1);
  603.   }
  604.  
  605.   strcpy(Str1,OMEGALIB);
  606.   strcat(Str1,"oarena.dat");
  607.   result = access(Str1,F_OK|R_OK);
  608.   if (result == -1) {
  609.     impossible = TRUE;
  610.     printf("\nWarning! File not accessible:");
  611.     printf(Str1);
  612.   }
  613.   
  614.   
  615.   strcpy(Str1,OMEGALIB);
  616.   strcat(Str1,"omaze1.dat");
  617.   result = access(Str1,F_OK|R_OK);
  618.   if (result == -1) {
  619.     impossible = TRUE;
  620.     printf("\nWarning! File not appendable or accessible:");
  621.     printf(Str1);
  622.   }
  623.   strcpy(Str1,OMEGALIB);
  624.   strcat(Str1,"omaze2.dat");
  625.   result = access(Str1,F_OK|R_OK);
  626.   if (result == -1) {
  627.     impossible = TRUE;
  628.     printf("\nWarning! File not appendable or accessible:");
  629.     printf(Str1);
  630.   }
  631.   strcpy(Str1,OMEGALIB);
  632.   strcat(Str1,"omaze3.dat");
  633.   result = access(Str1,F_OK|R_OK);
  634.   if (result == -1) {
  635.     impossible = TRUE;
  636.     printf("\nWarning! File not appendable or accessible:");
  637.     printf(Str1);
  638.   }
  639.   strcpy(Str1,OMEGALIB);
  640.   strcat(Str1,"omaze4.dat");
  641.   result = access(Str1,F_OK|R_OK);
  642.   if (result == -1) {
  643.     impossible = TRUE;
  644.     printf("\nWarning! File not appendable or accessible:");
  645.     printf(Str1);
  646.   }
  647.  
  648.   strcpy(Str1,OMEGALIB);
  649.   strcat(Str1,"omega.hi");
  650.   result = access(Str1,F_OK|R_OK|W_OK);
  651.   if (result == -1) {
  652.     impossible = TRUE;
  653.     printf("\nWarning! File not appendable or accessible:");
  654.     printf(Str1);
  655.   }
  656.   
  657.   strcpy(Str1,OMEGALIB);
  658.   strcat(Str1,"omega.log");
  659.   result = access(Str1,F_OK|R_OK|W_OK);
  660.   if (result == -1) {
  661.     impossible = TRUE;
  662.     printf("\nWarning! File not appendable or accessible:");
  663.     printf(Str1);
  664.   }
  665.  
  666.   strcpy(Str1,OMEGALIB);
  667.   strcat(Str1,"omotd.txt");
  668.   result = access(Str1,F_OK|R_OK);
  669.   if (result == -1) {
  670.     impossible = TRUE;
  671.     printf("\nWarning! File not accessible:");
  672.     printf(Str1);
  673.   }
  674.  
  675.   strcpy(Str1,OMEGALIB);
  676.   strcat(Str1,"olicense.txt");
  677.   result = access(Str1,F_OK|R_OK);
  678.   if (result == -1) {
  679.     impossible = TRUE;
  680.     printf("\nWarning! File not accessible:");
  681.     printf(Str1);
  682.   }
  683.   
  684.   strcpy(Str1,OMEGALIB);
  685.   strcat(Str1,"ocircle.dat");
  686.   result = access(Str1,F_OK|R_OK);
  687.   if (result == -1) {
  688.     impossible = TRUE;
  689.     printf("\nWarning! File not accessible:");
  690.     printf(Str1);
  691.   }
  692.   strcpy(Str1,OMEGALIB);
  693.   strcat(Str1,"ocmds.txt");
  694.   result = access(Str1,F_OK|R_OK);
  695.   if (result == -1) {
  696.     badbutpossible = TRUE;
  697.     printf("\nWarning! File not accessible:");
  698.     printf(Str1);
  699.   }
  700.  
  701.   strcpy(Str1,OMEGALIB);
  702.   strcat(Str1,"occmds.txt");
  703.   result = access(Str1,F_OK|R_OK);
  704.   if (result == -1) {
  705.     badbutpossible = TRUE;
  706.     printf("\nWarning! File not accessible:");
  707.     printf(Str1);
  708.   }
  709.   
  710.  
  711.   strcpy(Str1,OMEGALIB);
  712.   strcat(Str1,"ohelp1.txt");
  713.   result = access(Str1,F_OK|R_OK);
  714.   if (result == -1) {
  715.     badbutpossible = TRUE;
  716.     printf("\nWarning! File not accessible:");
  717.     printf(Str1);
  718.   }
  719.   strcpy(Str1,OMEGALIB);
  720.   strcat(Str1,"ohelp2.txt");
  721.   result = access(Str1,F_OK|R_OK);
  722.   if (result == -1) {
  723.     badbutpossible = TRUE;
  724.     printf("\nWarning! File not accessible:");
  725.     printf(Str1);
  726.   }
  727.   strcpy(Str1,OMEGALIB);
  728.   strcat(Str1,"ohelp3.txt");
  729.   result = access(Str1,F_OK|R_OK);
  730.   if (result == -1) {
  731.     badbutpossible = TRUE;
  732.     printf("\nWarning! File not accessible:");
  733.     printf(Str1);
  734.   }
  735.   strcpy(Str1,OMEGALIB);
  736.   strcat(Str1,"ohelp4.txt");
  737.   result = access(Str1,F_OK|R_OK);
  738.   if (result == -1) {
  739.     badbutpossible = TRUE;
  740.     printf("\nWarning! File not accessible:");
  741.     printf(Str1);
  742.   }
  743.   strcpy(Str1,OMEGALIB);
  744.   strcat(Str1,"ohelp5.txt");
  745.   result = access(Str1,F_OK|R_OK);
  746.   if (result == -1) {
  747.     badbutpossible = TRUE;
  748.     printf("\nWarning! File not accessible:");
  749.     printf(Str1);
  750.   }
  751.   strcpy(Str1,OMEGALIB);
  752.   strcat(Str1,"ohelp6.txt");
  753.   result = access(Str1,F_OK|R_OK);
  754.   if (result == -1) {
  755.     badbutpossible = TRUE;
  756.     printf("\nWarning! File not accessible:");
  757.     printf(Str1);
  758.   }
  759.   strcpy(Str1,OMEGALIB);
  760.   strcat(Str1,"ohelp7.txt");
  761.   result = access(Str1,F_OK|R_OK);
  762.   if (result == -1) {
  763.     badbutpossible = TRUE;
  764.     printf("\nWarning! File not accessible:");
  765.     printf(Str1);
  766.   }
  767.   strcpy(Str1,OMEGALIB);
  768.   strcat(Str1,"ohelp8.txt");
  769.   result = access(Str1,F_OK|R_OK);
  770.   if (result == -1) {
  771.     badbutpossible = TRUE;
  772.     printf("\nWarning! File not accessible:");
  773.     printf(Str1);
  774.   }
  775.   strcpy(Str1,OMEGALIB);
  776.   strcat(Str1,"ohelp9.txt");
  777.   result = access(Str1,F_OK|R_OK);
  778.   if (result == -1) {
  779.     badbutpossible = TRUE;
  780.     printf("\nWarning! File not accessible:");
  781.     printf(Str1);
  782.   }
  783.   strcpy(Str1,OMEGALIB);
  784.   strcat(Str1,"ohelp10.txt");
  785.   result = access(Str1,F_OK|R_OK);
  786.   if (result == -1) {
  787.     badbutpossible = TRUE;
  788.     printf("\nWarning! File not accessible:");
  789.     printf(Str1);
  790.   }
  791.   strcpy(Str1,OMEGALIB);
  792.   strcat(Str1,"ohelp11.txt");
  793.   result = access(Str1,F_OK|R_OK);
  794.   if (result == -1) {
  795.     badbutpossible = TRUE;
  796.     printf("\nWarning! File not accessible:");
  797.     printf(Str1);
  798.   }
  799.   strcpy(Str1,OMEGALIB);
  800.   strcat(Str1,"ohelp12.txt");
  801.   result = access(Str1,F_OK|R_OK);
  802.   if (result == -1) {
  803.     badbutpossible = TRUE;
  804.     printf("\nWarning! File not accessible:");
  805.     printf(Str1);
  806.   }
  807.   strcpy(Str1,OMEGALIB);
  808.   strcat(Str1,"ohelp13.txt");
  809.   result = access(Str1,F_OK|R_OK);
  810.   if (result == -1) {
  811.     badbutpossible = TRUE;
  812.     printf("\nWarning! File not accessible:");
  813.     printf(Str1);
  814.   }
  815.   
  816.   
  817.   strcpy(Str1,OMEGALIB);
  818.   strcat(Str1,"oabyss.txt");
  819.   result = access(Str1,F_OK|R_OK);
  820.   if (result == -1) {
  821.     badbutpossible = TRUE;
  822.     printf("\nWarning! File not accessible:");
  823.     printf(Str1);
  824.   }
  825.   strcpy(Str1,OMEGALIB);
  826.   strcat(Str1,"oscroll1.txt");
  827.   result = access(Str1,F_OK|R_OK);
  828.   if (result == -1) {
  829.     badbutpossible = TRUE;
  830.     printf("\nWarning! File not accessible:");
  831.     printf(Str1);
  832.   }
  833.   
  834.   strcpy(Str1,OMEGALIB);
  835.   strcat(Str1,"oscroll2.txt");
  836.   result = access(Str1,F_OK|R_OK);
  837.   if (result == -1) {
  838.     badbutpossible = TRUE;
  839.     printf("\nWarning! File not accessible:");
  840.     printf(Str1);
  841.   }
  842.  
  843.  
  844.   strcpy(Str1,OMEGALIB);
  845.   strcat(Str1,"oscroll3.txt");
  846.   result = access(Str1,F_OK|R_OK);
  847.   if (result == -1) {
  848.     badbutpossible = TRUE;
  849.     printf("\nWarning! File not accessible:");
  850.     printf(Str1);
  851.   }
  852.  
  853.   strcpy(Str1,OMEGALIB);
  854.   strcat(Str1,"oscroll4.txt");
  855.   result = access(Str1,F_OK|R_OK);
  856.   if (result == -1) {
  857.     badbutpossible = TRUE;
  858.     printf("\nWarning! File not accessible:");
  859.     printf(Str1);
  860.   }
  861.   
  862.   if (impossible) {
  863.     printf("\nFurther execution is impossible. Sorry.");
  864.     printf("\nOMEGALIB may be badly #defined in odefs.h\n");
  865.     return(0);
  866.   }
  867.   else if (badbutpossible) {
  868.     printf("\nFurther execution may cause anomalous behavior.");
  869.     printf("\nContinue anyhow? [yn] ");
  870.     if (getchar()=='y') return(-1);
  871.     else return(0);
  872.   }
  873.   else return(1);
  874. }
  875.  
  876.  
  877. /* display a file given a string name of file */
  878. void displayfile(filestr)
  879. char *filestr;
  880. {
  881.   FILE *fd = checkfopen(filestr,"r");
  882.   int c,d=' ';
  883.   int x,y;
  884.   clear();
  885.   refresh();
  886.   c = fgetc(fd);
  887.   while ((c != EOF)&&((char) d != 'q')&&((char) d!=ESCAPE)) {
  888.     getyx(stdscr,y,x);
  889.     if (y > ScreenLength) { 
  890.       printw("\n-More-");
  891.       refresh();
  892.       d = wgetch(stdscr);
  893.       clear();
  894.     }
  895.     printw("%c",(char) c);
  896.     c = fgetc(fd);
  897.   }
  898.   if (((char) d != 'q')&&((char) d!=ESCAPE)) {
  899.     printw("\n-Done-");
  900.     refresh();
  901.     getch();
  902.   }
  903.   clear();
  904.   refresh();
  905. }    
  906.  
  907.  
  908. /* display a file given a string name of file */
  909. void copyfile(srcstr)
  910. char *srcstr;
  911. {
  912.   char deststr[80];
  913.   char cmd[200];
  914.   print1("Enter name of file to create: ");
  915.   strcpy(deststr,msgscanstring());
  916.   strcpy(cmd,"cp ");
  917.   strcat(cmd,srcstr);
  918.   strcat(cmd," ");
  919.   strcat(cmd,deststr);
  920.   print2("Copying file....");
  921.   system(cmd);
  922.   print3("Done.");
  923. }    
  924.  
  925.