home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / blurb-20.zip / BLURB.CPP next >
C/C++ Source or Header  |  1992-04-28  |  18KB  |  615 lines

  1. //--------------------------------BLURB.CPP---------------------------------
  2. //
  3. //  Blurb v2.0  This is the updated version of the fortune program.
  4. //
  5. //--------------------------------------------------------------------------
  6. //
  7. //                                 Notice:
  8. //
  9. //                      Confidential and Proprietary
  10. //
  11. //  This work contains valuable confidential and proprietary information.
  12. //  Disclosure, use or reproduction without the written authorization from
  13. //  Jon Privatt is prohibited.  This unpublished work by Jon Privatt is
  14. //  protected by the laws of the United States and other countries.
  15. //
  16. //  If publication of the work should occur the following notice shall apply:
  17. //
  18. //  "Copyright (c) 1992, Jon Privatt, All Rights Reserved"
  19. //
  20. //--------------------------------------------------------------------------
  21.  
  22. #include <time.h>
  23. #include <stdio.h>
  24. #include <dos.h>
  25. #include <conio.h>
  26. #include <dir.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <io.h>
  30. #include <ctype.h>
  31.  
  32.  
  33. //===========================COMPILER DEFINITIONS===========================
  34.  
  35.  
  36. //===============================GLOBAL TYPES===============================
  37.  
  38.  
  39. //=============================GLOBAL VARIABLES=============================
  40. char  ch,
  41.       *p,
  42.       *q,
  43.       outlines[26][134],
  44.       blurb[1001];                // blurb input.
  45.  
  46. unsigned long
  47.       choice,
  48.       next=0,
  49.       num;                     // number of blurbs
  50.  
  51. unsigned seed=0;
  52.  
  53. time_t first, second;
  54. long curpos;
  55.  
  56. int   x=2,                     // current x position
  57.       y=1,                     // current y position
  58.       n=0,                     // position within blurb string!
  59.       delayvalue=50,
  60.       length,
  61.       aa=2,
  62.       nodelay=0,
  63.       lines,
  64.       words,                   // number of words in the blurb.
  65.       mxx,                     // maximum x position
  66.       mxy,                     // maximum y position
  67.       bcolor=9,                // background color
  68.       fcolor=15;               // foreground color
  69.  
  70. struct ftime
  71.       fnow,                    // time/date of last reindex
  72.       fthen;                   // time/date now
  73.  
  74. struct text_info
  75.       ti;
  76.  
  77. enum BOOLEAN {false, true}
  78.       quit=false,
  79.       end=false,
  80.       displayblurb=true,
  81.       mixup=false,
  82.       inorder=false,
  83.       autodelay=false,
  84.       border=true,
  85.       hide=false,               // hide the author line.  Alters aa=0
  86.       ERROR=false,              // error, Blurb renamed or altered if ==true.
  87.       codes=true;
  88.  
  89. FILE *blurbs,                   // file containing the blurbs
  90.      *cfg,                      // file containing configuration info.
  91.      *idx;                      // index file to blurbs
  92.  
  93.  
  94. //----------------------------------title------------------------------------
  95. void title() {
  96.   //Prints "Blurb v2.0"...encoded to prevent alteration.
  97.   cprintf("%c%c%c%c%c%c%c%c%c%c",66,108,117,114,98,32,118,50,46,48);
  98.  
  99.   gotoxy((mxy-18),1);
  100.   //Prints "Jon Privatt (c)1992"...encoded to prevent alternation.
  101.   cprintf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",74,111,110,32,80,114,105,118,97,116,116,32,40,99,41,49,57,57,50);
  102.   }
  103.  
  104. //--------------------------------get_cfg-----------------------------------
  105. int get_cfg() {
  106.  
  107.   p=searchpath("blurb.cfg");
  108.   if((cfg=fopen(p,"rb"))==NULL) return 1;
  109.  
  110.   fseek(cfg,39,SEEK_SET);              // position past file header.
  111.  
  112.   fread(&num, sizeof(unsigned long), 1, cfg);
  113.   fread(&border, sizeof(BOOLEAN), 1, cfg);
  114.   fread(&hide,sizeof(BOOLEAN),1,cfg);
  115.   fread(&bcolor, sizeof(int), 1, cfg);
  116.   fread(&fcolor, sizeof(int), 1, cfg);
  117.   fread(&delayvalue, sizeof(int), 1, cfg);
  118.   fread(&codes,sizeof(BOOLEAN),1,cfg);
  119.   fread(&autodelay,sizeof(BOOLEAN),1,cfg);
  120.   fread(&fthen, sizeof(fthen), 1, cfg);
  121.   fread(&next, sizeof(unsigned long), 1, cfg);
  122.   fread(&inorder,sizeof(BOOLEAN),1,cfg);
  123.   fread(&seed,sizeof(seed),1,cfg);
  124.   fclose(cfg);
  125.   return 0;
  126. }
  127.  
  128.  
  129. //-------------------------------save_cfg-----------------------------------
  130. void save_cfg() {
  131.   int yyyy;
  132.  
  133.   p=searchpath("blurb.cfg");
  134.   if (p==NULL) {                  // file not in path. Create new one
  135.     q=searchpath("blurb.exe");    //   wherever blurb.exe is located.
  136.     yyyy=strlen(q)-3;
  137.     q[yyyy++]='c';
  138.     q[yyyy++]='f';
  139.     q[yyyy]='g';
  140.       if ((cfg=fopen(q,"w+b"))==NULL) {
  141.       printf("Unable to create BLURB.CFG\n");
  142.       exit(1);
  143.       }
  144.     }
  145.     else {
  146.       if((cfg=fopen(p,"w+b"))==NULL) {
  147.     printf("Unable to create BLURB.CFG\n");
  148.     exit(1);
  149.     }
  150.       }
  151.   fputs("Blurb version 2.0\r\nConfiguration File\n",cfg); // File header.
  152.   fputc(26,cfg);                                          // EOF mark.
  153.   fwrite(&num, sizeof(unsigned long), 1, cfg);
  154.   fwrite(&border, sizeof(BOOLEAN), 1, cfg);
  155.   fwrite(&hide,sizeof(BOOLEAN),1,cfg);
  156.   fwrite(&bcolor, sizeof(int), 1, cfg);
  157.   fwrite(&fcolor, sizeof(int), 1, cfg);
  158.   fwrite(&delayvalue, sizeof(int), 1, cfg);
  159.   fwrite(&codes,sizeof(BOOLEAN),1,cfg);
  160.   fwrite(&autodelay,sizeof(BOOLEAN),1,cfg);
  161.   fwrite(&fthen, sizeof(fthen), 1, cfg);
  162.   fwrite(&next, sizeof(unsigned long),1,cfg);
  163.   fwrite(&inorder, sizeof(BOOLEAN), 1, cfg);
  164.   fwrite(&seed,sizeof(seed),1,cfg);
  165.   fclose(cfg);
  166. }
  167.  
  168. //------------------------------reindex-----------------------------------
  169. void reindex() {
  170.   long fl;                           // total length of the file.
  171.   long temp, percent, prev=-1;
  172.   int yyyy;
  173.  
  174.   num=1;
  175.   textcolor(7);
  176.   textbackground(0);
  177.   clrscr();
  178.   title();
  179.   gotoxy(1,3);
  180.   cprintf("%clurbs has been altered.  %cuto-%ceindex %cngaged...",66,65,82,69);
  181.   p=searchpath("blurbs");
  182.   if((blurbs=fopen(p,"rt"))==NULL) {
  183.     printf("Unable to find BLURBS\n");
  184.     exit(1);
  185.     }
  186.   p=searchpath("blurb.idx");
  187.   if (p==NULL) {                  // file not in path. Create new one
  188.     q=searchpath("blurb.exe");    //   wherever blurb.exe is located.
  189.     yyyy=strlen(q)-3;
  190.     q[yyyy++]='i';
  191.     q[yyyy++]='d';
  192.     q[yyyy]='x';
  193.     if ((idx=fopen(q,"w+b"))==NULL) {
  194.       printf("Unable to create BLURB.IDX\n");
  195.       fclose(blurbs);
  196.       exit(1);
  197.       }
  198.     }
  199.   else {
  200.     if((idx=fopen(p,"w+b"))==NULL) {
  201.       printf("Unable to create BLURB.IDX\n");
  202.       fclose(blurbs);
  203.       exit(1);
  204.       }
  205.     }
  206.   fseek(blurbs,0L,SEEK_END);
  207.   fl=ftell(blurbs);
  208.   gotoxy(1,4);
  209.   printf("%ceindexing:",82);
  210.   if (fl>100) temp=fl/100;
  211.   else percent=50;
  212.   rewind(blurbs);
  213.   curpos=ftell(blurbs);                 // write first record.
  214.   fwrite(&curpos,sizeof(long),1,idx);
  215.   while (fgets(blurb,1000,blurbs)!=NULL) {
  216.     num++;
  217.     curpos=ftell(blurbs);
  218.     if (fl>100) percent=curpos/temp;
  219.     if (percent!=prev) {
  220.       gotoxy(13,4);
  221.       prev=percent;
  222.       printf("%ld%%",percent);
  223.       }
  224.     fwrite(&curpos, sizeof(long), 1, idx);
  225.     }
  226.   gotoxy(13,4);
  227.   printf("100%%");
  228.   gotoxy(1,5);
  229.   printf("%lu BLURBS now indexed for maximum speed.\n",(num-1));
  230.   displayblurb=false;
  231.   fclose(idx);
  232.   getftime(fileno(blurbs),&fthen);
  233.   fclose(blurbs);
  234.   save_cfg();
  235. }
  236.  
  237.  
  238. //-------------------------------get_idx-----------------------------------
  239. void get_idx() {
  240.  
  241.   p=searchpath("blurbs");
  242.   if((blurbs=fopen(p,"rt"))==NULL) {  // check for updated BLURBS
  243.     printf("Unable to find BLURBS\n");
  244.     exit(1);
  245.     }
  246.   getftime(fileno(blurbs),&fnow);
  247.   fclose(blurbs);
  248.   if ((fnow.ft_tsec!=fthen.ft_tsec)||(fnow.ft_min!=fthen.ft_min)||(fnow.ft_hour!=fthen.ft_hour)||(fnow.ft_day!=fthen.ft_day)||(fnow.ft_month!=fthen.ft_month)||(fnow.ft_year!=fthen.ft_year))
  249.     reindex();
  250.  
  251.   p=searchpath("blurb.idx");
  252.   if((idx=fopen(p,"rb"))==NULL) reindex();
  253.   next++;
  254.   if (next>num) next=0;
  255.   if (inorder==true)
  256.     choice = next;
  257.   else
  258.     choice = (rand()%num);
  259.   curpos=(sizeof(long)*choice);
  260.   fseek(idx,curpos,SEEK_SET);
  261.   fread(&curpos,sizeof(long),1,idx);
  262.   fclose(idx);
  263.  
  264.   p=searchpath("blurbs");
  265.   if((blurbs=fopen(p,"rt"))==NULL) {
  266.     printf("Unable to find BLURBS\n");
  267.     exit(1);
  268.     }
  269.   fseek(blurbs,curpos,SEEK_SET);
  270.   fgets(blurb,1000,blurbs);
  271.   fclose(blurbs);
  272. }
  273.  
  274.  
  275. //----------------------------linelength-----------------------------------
  276. int linelength() {
  277.   int l;
  278.   while (blurb[n]==' ') n++;
  279.   if (border==true) {
  280.     if ((length-n)<=(mxy-6)) {
  281.       l=length-n;
  282.       quit=true;
  283.       }
  284.     else {
  285.       l=mxy-6;
  286.       while (blurb[(n+l)]!=' ') l--;
  287.       }
  288.     }
  289.   else {
  290.     if ((length-n)<=mxy) {
  291.       l=length-n;
  292.       quit=true;
  293.       }
  294.     else {
  295.       l=mxy;
  296.       while (blurb[(n+l)]!=' ') l--;
  297.       }
  298.     }
  299.   return l;
  300. }
  301.  
  302. //-------------------------------printout------------------------------------
  303. void printout() {
  304.   int
  305.       loop,
  306.       pos;
  307.   lines=0;
  308.   if (border==true) {               // Set up the top line border.
  309.     pos=0;
  310.     while(pos<mxy) outlines[lines][pos++]='─';
  311.     outlines[lines][0]='┌';
  312.     outlines[lines][(mxy-1)]='┐';
  313.     lines++;
  314.     }
  315.  
  316.   while(quit==false) {              // MAIN LOOP OF SUBROUTINE
  317.     pos=0;
  318.     if (border==true) {             // Set up the left margin.
  319.       outlines[lines][pos++]='│';
  320.       outlines[lines][pos++]=' ';
  321.       outlines[lines][pos++]=' ';
  322.       }
  323.     y=linelength();                 // Add a line.
  324.     for (loop=0;loop<y;loop++)
  325.       outlines[lines][pos++]=blurb[loop+n];
  326.     n=n+y;
  327.     while (pos<mxy) outlines[lines][pos++]=' ';
  328.     if (border==true) {             // Set up the right margin.
  329.       outlines[lines][(mxy-1)]='│';
  330.       }
  331.     lines++;
  332.     } // end while(quit==false)
  333.  
  334.   if (border==true) {               // Set up the bottom line border.
  335.     pos=0;
  336.     while(pos<mxy) outlines[lines][pos++]='─';
  337.     outlines[lines][0]='└';
  338.     outlines[lines][(mxy-1)]='┘';
  339.     }
  340.   else lines--;
  341. }
  342.  
  343. //-------------------------------printit-----------------------------------
  344.  
  345. void printit() {
  346.   int loop, loop2;
  347.  
  348.   for (loop=0;loop<=lines;loop++) {          // PRINT-OUT LOOP
  349.     gotoxy(1,(loop+1+aa));
  350.     for (loop2=0;loop2<mxy;loop2++)
  351.       cprintf("%c",outlines[loop][loop2]);
  352.     } // end loop
  353.   }
  354.  
  355. //-------------------------------controlpanel--------------------------------
  356. void controlpanel() {
  357.   int i,ii;
  358.  
  359.   textcolor(fcolor);
  360.   textbackground(bcolor);
  361.   ii=((mxy/2)-20);
  362.   gotoxy(ii,3);
  363.   cprintf("┌───────────── %cetup %cenu ─────────────┐",83,77);
  364.   gotoxy(ii,4);
  365.   cprintf("│                                      │");
  366.   gotoxy(ii,5);
  367.   cprintf("│ <%c>uto %cime %celay: ",65,84,68);
  368.     if (autodelay==true) cprintf("%c%c                │",79,78);
  369.     else cprintf("%c%c%c               │",79,70,70);
  370.   gotoxy(ii,6);
  371.   cprintf("│ <%c>elay:  %d/100 second per word. ",68,delayvalue);
  372.   if (delayvalue<10000) cprintf(" ");
  373.   if (delayvalue<1000) cprintf(" ");
  374.   if (delayvalue<100) cprintf(" ");
  375.   if (delayvalue<10) cprintf(" ");
  376.   cprintf("│");
  377.   gotoxy(ii,7);
  378.   cprintf("│ <%c>ackground %color                   │",66,67);
  379.   gotoxy(ii,8);
  380.   cprintf("│ <%c>oreground %color                   │",70,67);
  381.   gotoxy(ii,9);
  382.   cprintf("│ <%c>ide the %citle: ",72,84);
  383.     if (hide==true) cprintf("%c%c%c%c%c%c             │",72,73,68,68,69,78);
  384.       else cprintf("%c%c%c%c%c%c%c            │",86,73,83,73,66,76,69);
  385.   gotoxy(ii,10);
  386.   cprintf("│ <%c>utlining %corder: ",79,66);
  387.     if (border==true) cprintf("%c%c               │",79,78);
  388.       else cprintf("%c%c%c              │",79,70,70);
  389.   gotoxy(ii,11);
  390.   cprintf("│ <%c>election %cethod: ",83,77);
  391.     if (inorder==true) cprintf("%c%c%c%c%c%c%c          │",73,78,79,82,68,69,82);
  392.     else cprintf("%c%c%c%c%c%c%c%c%c%c       │",82,65,78,68,79,77,73,90,69,68);
  393.   gotoxy(ii,12);
  394.   cprintf("│                                      │");
  395.   gotoxy(ii,13);
  396.   cprintf("│ <%c>uit.                              │",81);
  397.   gotoxy(ii,14);
  398.   cprintf("│                                      │");
  399.   gotoxy(ii,15);
  400.   cprintf("└──────────────────────────────────────┘");
  401.   gotoxy(mxy,mxx);
  402. }
  403.  
  404. //-----------------------------------setup-----------------------------------
  405. void setup() {
  406.   int i,ii;
  407.   long iii;
  408.  
  409.   clrscr();
  410.   title();
  411.  
  412.   displayblurb=false;
  413.   quit=false;
  414.   while(quit==false) {
  415.     controlpanel();
  416.     ch=getch();
  417.     switch (ch) {
  418.       case 'a':
  419.       case 'A':  if (autodelay==true) autodelay=false; else autodelay=true;
  420.          break;
  421.       case 'd':
  422.       case 'D':  gotoxy(1,16);
  423.          printf("Enter new delay value per word (100=1 second):");
  424.          scanf("%D",&iii);
  425.          if (iii<0) delayvalue=0;
  426.          else
  427.            if (iii>32000)delayvalue=32000;
  428.            else
  429.              delayvalue=(int)iii;
  430.          gotoxy(1,16);
  431.          printf("                                                      ");
  432.          break;
  433.       case 'h':
  434.       case 'H':  if (hide==true) hide=false;  else hide=true;
  435.          break;
  436.       case 'B':
  437.       case 'b':  bcolor++;
  438.          if (bcolor==16) bcolor=0;
  439.          break;
  440.       case 'S':
  441.       case 's':  if (inorder==true) inorder=false; else inorder=true;
  442.          break;
  443.       case 'F':
  444.       case 'f':  fcolor++;
  445.          if (fcolor==16) fcolor=0;
  446.          break;
  447.       case 'o':
  448.       case 'O':  if (border==true) border=false; else border=true;
  449.          break;
  450.       case 'q':
  451.       case 'Q':  quit=true;
  452.          if (delayvalue==0) autodelay=false;
  453.          save_cfg();
  454.          printf("\nInformation saved.\n");
  455.          break;
  456.       default :  break;
  457.       }
  458.     }
  459.   }
  460.  
  461. //----------------------------------info-------------------------------------
  462. void info() {
  463.   displayblurb=false;
  464.   gotoxy(1,3);
  465.   printf("%clurb v%c.%c %cnformation:\n\n",66,50,48,73);
  466.   printf("%ciles %currently in %cse:\n",70,67,85);
  467.   p=searchpath("blurb.exe"); printf("  %s\n",p);
  468.   p=searchpath("blurb.cfg"); printf("  %s\n",p);
  469.   p=searchpath("blurb.idx"); printf("  %s\n",p);
  470.   p=searchpath("blurbs");    printf("  %s\n\n",p);
  471.   printf("%clurbs on %cile:  %lu\n\n",66,70,num);
  472.   printf("%ccreen:\n",83);
  473.   printf("  %ceight:  %d\n",72,mxx);
  474.   printf("  %cidth:   %d\n",87,mxy);
  475.   exit(0);
  476.   }
  477.  
  478. //-----------------------------------hlp-------------------------------------
  479. void hlp() {
  480.   int i;
  481.  
  482.   displayblurb=false;
  483.  
  484.   gotoxy(1,2);
  485.   i=0;
  486.   while (i++<mxy) printf("─");
  487.  
  488.   gotoxy(1,4);
  489.   i=0;
  490.   while (i++<mxy) printf("─");
  491.  
  492.   gotoxy(((mxy-20)/2),3); printf("%candom %clurb %celector",82,66,83);
  493.   gotoxy(1,6);
  494.   printf("%cormat:  %clurb (argument)\n",70,66);
  495.   printf("(arguments)\n");
  496.   printf(" /setup   %clurb setup menu.\n",66);
  497.   printf(" /index   %corced reindexing.\n",70);
  498.   printf(" ?        %chis help screen.\n",84);
  499.   printf(" /info    %configuration information.\n",67);
  500.   printf(" /delay   %cverrides setup option and uses delay.\n",79);
  501.   printf(" /nodelay %cverrides setup option and uses no delay.\n\n",79);
  502.   printf("%clease see the file %c%c%c%c%c.%c%c%c for more information.\n\n",80,66,76,85,82,66,68,79,67);
  503.   if (1==0) printf("Error:  Adlib not responding.");
  504. //  printf("Blurb has no warranties, expressed or implied.  Responsiblity of any\n");
  505. //  printf("damage resulting from the use of this program falls completely upon the\n");
  506. //  printf("user, the author will not be held responsible for any damage caused by\n");
  507. //  printf("the program.  Blurb is freeware, however, donations would be appreciated\n");
  508. //  printf("to spur the author to develop further software.\n");
  509. //  printf("Blurb is written in C++ by a starving MBA student.  Any comments, questions,\n");
  510. //  printf("recommendations, or donations should be sent to:\n");
  511. //  printf("                           Jon Privatt\n");
  512. //  printf("                           1400 Warren St.\n");
  513. //  printf("                           Mankato, MN  56001");
  514.   exit(0);
  515. }
  516.  
  517. //---------------------------------timeout-----------------------------------
  518. void timeout() {
  519.   int i;
  520.   double tt,ttemp;
  521.  
  522.   first=time(NULL);
  523.   words=1;
  524.   for (i=0;i<n;i++)                // compute number of words in message
  525.     if (blurb[i]==32) words++;
  526.  
  527.   ttemp=(double)delayvalue;
  528.   tt=(ttemp/100)*words;             // time delay, watch keyboard.
  529.   save_cfg();
  530.   second=time(NULL);
  531.   while ((difftime(second,first)<tt)&&(words!=0)) {
  532.     if (kbhit()) {
  533.       words=0;
  534.       getch();
  535.       }
  536.     second=time(NULL);
  537.     }
  538.   }
  539.  
  540. //-----------------------------------main------------------------------------
  541. void main() {
  542.   int i;
  543.  
  544.   textcolor(7);
  545.   textbackground(0);
  546.   clrscr();
  547.   gettextinfo(&ti);
  548.   mxy=ti.screenwidth;
  549.   if (mxy>132) mxy=132;
  550.   mxx=ti.screenheight;
  551.   if (get_cfg()!=0) save_cfg();
  552.   title();
  553.  
  554.   // Future blurbs may print special messages the first time on mondays and
  555.   // fridays.  "I hate mondays"  "Thank God it's Friday!"
  556.   // This would require blurb.cfg to be updated on every run and save the
  557.   // date (maybe even the time) when it was last run.
  558.   // Lunchtime messages could also appear.  These messages are optional to
  559.   // the user.  Clock/Calendar-based messages:  Enabled/Disabled.
  560.   // (A sophisticated version would be a special text file which could define
  561.   //  when and what message to display...)
  562.  
  563.   // Still need the first liner option (as per user definition).
  564.  
  565.   p=searchpath("blurb.exe");                      // Check for Errors
  566.   if (p==NULL) ERROR=true;        // not in path or renamed.
  567.  
  568.  
  569.   if (ERROR==true) {
  570.     gotoxy(1,3);
  571.     printf("%cey!  I cannot find BLURB.EXE!\n\n",72);
  572.     printf("%clurb will not work properly when it\n",66);
  573.     printf("has been renamed, or isn't located\n");
  574.     printf("in the system's %c%c%c%c.\n\n",80,65,84,72);
  575.     exit(0);
  576.     }
  577.  
  578.   if (_argc>1) {
  579.     if (strstr(_argv[1],"?")!=NULL) hlp();
  580.     p=strupr(_argv[1]);
  581.     if (strstr(p,"INDEX")!=NULL) reindex();
  582.     if (strstr(p,"SETUP")!=NULL) setup();
  583.     if (strstr(p,"INFO")!=NULL)  info();
  584.     if (strstr(p,"DELAY")!=NULL) nodelay=2;
  585.     if (strstr(p,"NODELAY")!=NULL) nodelay=1;
  586.     }
  587.  
  588.   if (hide==true) aa=0;
  589.   textcolor(fcolor);
  590.   textbackground(bcolor);
  591.   if (seed>=65535) seed=0;        // randomize!!
  592.   else seed++;
  593.   srand(seed);
  594.  
  595.   get_idx();
  596.     if (displayblurb==true) {
  597.     while (strlen(blurb)<2) get_idx();
  598.     length=(strlen(blurb)-1);
  599.     printout();
  600.     printit();
  601.     if (nodelay==0) {
  602.       if (autodelay==true)
  603.     timeout();
  604.       else
  605.     save_cfg();
  606.       }
  607.     else
  608.       if (nodelay==2)
  609.     timeout();
  610.       else
  611.     save_cfg();
  612.     }
  613.   printf("\n");
  614.   }
  615.