home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / RDQWKSRC.ZIP / READLIB.C < prev    next >
C/C++ Source or Header  |  1991-01-15  |  19KB  |  873 lines

  1. ╔══════════════════════════════════════════════════════════════════════════╗
  2. ║                                                                          ║
  3. ║         Test routines to read, in Qmail Format - R.Cougnenc 90 -         ║
  4. ║                                                                          ║
  5. ║                            Public Domain                                 ║
  6. ║                                                                          ║
  7. ╟──────────────────────────────────────────────────────────────────────────╢
  8. ║                                                                          ║
  9. ║       These modules correspond to different tests at reading in          ║
  10. ║       Qmail Format. They were never planned to be released as a          ║
  11. ║       package.                                                           ║
  12. ║                                                                          ║
  13. ║       Source code is not beautified or optimised as they are work        ║
  14. ║       files and are distributed as is.                                   ║
  15. ║                                                                          ║
  16. ║       The program, even at it's rustic stage is fully fonctional,        ║
  17. ║       as I use it regularly...                                           ║
  18. ║                                                                          ║
  19. ║       Feel free to use any or all of these modules, if you can sort      ║
  20. ║       it out! :-)                                                        ║
  21. ║                                                                          ║
  22. ╚══════════════════════════════════════════════════════════════════════════╝
  23.  
  24.  
  25.  
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include <fcntl.h>
  29. #include <sys/types.h>
  30. #include <sys/stat.h>
  31. #include <stdlib.h>
  32. #include <time.h>
  33. #include <ctype.h>
  34. #include "reader.h"
  35. #include "qmail.h"
  36. #include "system.h"
  37.  
  38. #include "ansi.h"
  39. #include "readlib.h"
  40.  
  41. /*
  42.            Creates the Home Pathname.
  43.            Looks for the environment var :"READER" for systems which does not
  44.            pass the full pathname in argv[0];
  45.            If this variable is not found, assumes argv[0] contains the full
  46.            pathname and build the string from it.
  47. */
  48.  
  49. void MakeHomePath(path)
  50. char *path;
  51. {
  52.  int i;
  53.  char *pt;
  54.  
  55.     if(( pt = (char *) getenv("READER")) == NULL )
  56.         strcpy(HomePath,path);
  57.     else
  58.     {
  59.       strcpy(HomePath,pt);
  60.       PrePath(HomePath);
  61.     }
  62.     i = strlen(HomePath);
  63.     while(i)
  64.     {
  65.                 if(HomePath[i] == SEP || HomePath[i] == ':'||
  66.                    HomePath[i] == SEPDOS ) break ;
  67.         HomePath[i] = 0;
  68.         i--;
  69.     }
  70.  
  71.    pt = HomePath ;
  72.    while(*pt)
  73.    {
  74.      if( *pt == SEPDOS )
  75.        *pt = SEP ;
  76.      pt++;
  77.    }
  78. }
  79. /*----------------------------------------------------------------------*/
  80.  
  81.  
  82. /*
  83.  
  84.                        Read the configuration file.
  85.  
  86. */
  87.  
  88. int ReadConfig()
  89. {
  90.   char Path[MAXPATHS],
  91.        Line[MAXPATHS],
  92.        var[50],
  93.        sign[50],
  94.        value[50],
  95.        value2[50];
  96.   int count = 0;
  97.  
  98.   FILE *cnf;
  99.  
  100.   printf("%s...\n",txt[53]);  /* "REading config file" */
  101.   strcpy(Path,HomePath);
  102.   strcat(Path,CONFIG_FILE);
  103.   if(( cnf = fopen(Path,"r") ) == NULL )
  104.   {
  105.     printf("\n%s %s ! \n",txt[ 52], Path ); /* "Unable to open config file" */
  106.     return( ERROR );
  107.   }
  108.  
  109.   while( fgets(Line,255,cnf) )
  110.   {
  111.  
  112.     count++ ;
  113.     if(Line[0] == '#' || strlen(Line) < 2 )
  114.       continue;
  115.     sscanf(Line,"%s %s %s %s",var,sign,value,value2 );
  116.     if( affect(var,sign,value,value2) )
  117.      {
  118.          /* "error in config file in line..." */
  119.          printf("%s %s %s %d\n",txt[ 54 ],Path,txt[ 55],count);
  120.          printf("%s %d : %s\n", txt[ 56],count,Line);
  121.          return ( ERROR );
  122.      }
  123.   }
  124.   return( OK );
  125. }
  126.  
  127.  
  128.  
  129.  
  130. /*
  131.           Affects known configuration variables to their global values.
  132.           Returns ERROR on an invalid line.
  133.           Ignores unknown variables.
  134. */
  135.  
  136. int affect(var,sign,value,value2)
  137. char *var,*sign,*value,*value2;
  138. {
  139.   strlwr(var);
  140.   if(strcmp(sign,"=") )
  141.    return( ERROR );
  142.  
  143.    if( ! strcmp (var, "editor") )
  144.    {
  145.       strcpy(Editor,value);
  146.       return( OK );
  147.    }
  148.  
  149.    if( ! strcmp (var, "mail") )
  150.    {
  151.       strcpy(MailPath,value);
  152.       PrePath(MailPath);
  153.       return( OK );
  154.    }
  155.  
  156.    if( ! strcmp (var, "reply") )
  157.    {
  158.       strcpy(ReplyPath,value);
  159.       PrePath(ReplyPath);
  160.       return( OK );
  161.    }
  162.  
  163.    if( ! strcmp (var, "archiver") )
  164.    {
  165.       strcpy(Archiver,value);
  166.       return( OK );
  167.    }
  168.  
  169.    if( ! strcmp (var, "unarchiver") )
  170.    {
  171.       strcpy(UnArchiver,value);
  172.       return( OK );
  173.    }
  174.  
  175.    if( ! strcmp (var, "ansi") )   /* Starting in ansi mode or not... */
  176.    {
  177.       strlwr(value);
  178.       ansi = strcmp(value,"on") ? 0 : 1 ;
  179.       return( OK );
  180.    }
  181.  
  182.    if( ! strcmp (var, "user") )   /* Get User First & Last Name      */
  183.    {
  184.       strupr(value);
  185.       strupr(value2);
  186.       sprintf(UserName,"%s %s",value,value2);
  187.       return( OK );
  188.    }
  189.  
  190.   return( OK );
  191. }
  192.  
  193.  
  194.  
  195.  
  196. /*
  197.        Adds the last separator to a pathname.
  198.        Must be room enough for that in the string !
  199. */
  200.  
  201. void PrePath( path )
  202. char *path;
  203. {
  204.  int l ;
  205.  
  206.   l = strlen(path);
  207.   if( path [ l - 1 ] != SEP && path [ l - 1 ] !=  SEPDOS );
  208.   path[ l ]  = SEP ;
  209.   path[ l+1] = EOS ;
  210. }
  211.  
  212.  
  213.  
  214. /*
  215.             Builts the full work directory pathname, and
  216.             Deletes all files in the work directory.
  217.  
  218.            ( System dependants functions are in system.c )
  219. */
  220.  
  221. void Clean()
  222. {
  223.   strcpy(WorkPath,HomePath);
  224.   strcat(WorkPath,WORK_DIR );
  225.  
  226.   if( access(WorkPath,0) )
  227.      mkdir(WorkPath);
  228.   else
  229.   {
  230.     printf("%s %s...\n",txt[ 57],WorkPath);   /* "Cleaning" */
  231.     Erase(WorkPath);
  232.   }
  233. }
  234.  
  235.  
  236. /*
  237.    FGET : Get a string like fgets, without any space or lf on the right.
  238. */
  239.  
  240. char *fget (s,n,fp)
  241. char *s;
  242. int n;
  243. FILE *fp;
  244. {
  245.  char *p ;
  246.   p = fgets(s,n,fp);
  247.   if( s[strlen(s) -1] == '\n' )
  248.    s[strlen(s) -1] = '\0' ;
  249.    while( s[strlen(s) -1] == ' ' )
  250.       s[strlen(s) -1] = '\0' ;
  251.  return( p ) ;
  252. }
  253.  
  254.  
  255.  
  256.  
  257. /*
  258.            Get conference, open global files etc...
  259. */
  260.  
  261. int GetConf(num)
  262. int num;
  263. {
  264.  char tmp[MAXPATHS];
  265.  struct stat stats;
  266.  
  267.   sprintf(tmp,"%s%s/%d.idx",HomePath,CurBoard,num);
  268.  
  269.   if( FilesOpen )
  270.   {
  271.     fclose(fidx);
  272.     fclose(fmsg);
  273.     FilesOpen = 0 ;
  274.   }
  275.  
  276.   if( access(tmp))           /* File does not exists, no mail. */
  277.   {
  278.     {
  279.        red();
  280.        printf("%s %s\n",txt[ 44 ],tmp);  /* "No mail on conf" */
  281.        return(ERROR);
  282.     }
  283.   }
  284.   else                      /* Ok file exists, read it . */
  285.   {
  286.     if(( fidx = fopen(tmp,"r+b") )== NULL )
  287.     {
  288.        printf("%s %s\n",txt[49],tmp);  /* "unable to read file" */
  289.        return(ERROR);
  290.     }
  291.  
  292.     if( setvbuf(fidx,NULL,_IOFBF,1024 ) )
  293.       printf("%sGetConf() [index]\n",txt[ 94 ]);  /* "Setvbuf failed..." */
  294.  
  295.   }
  296.    CurConf = num ;
  297.  
  298.    stat(tmp,&stats );
  299.    TotMsg  = (int) (stats.st_size / sizeof(struct MyIndex) );
  300.  
  301.   sprintf(tmp,"%s%s/%d.cnf",HomePath,CurBoard,CurConf);
  302.   if ( (fmsg = fopen(tmp,"rb") ) == NULL )
  303.   {
  304.      printf("%s %s ! \n",txt[ 58 ],tmp ); /* "Error Reading file" */
  305.      return ERROR ;
  306.   }
  307.  
  308.   if( setvbuf(fmsg,NULL,_IOFBF,VBUF ) )
  309.     printf("%sGetConf() [data]\n",txt[ 94 ]);  /* "Setvbuf failed..." */
  310.                                              /* Go  to Last message read */
  311.   fread((char *)&Index.LastRead,1,sizeof(struct MyIndex),fidx);
  312.   fseek(fidx,(long) Index.LastRead * (long) sizeof(struct MyIndex), 0 );
  313.  
  314.  FilesOpen = 1 ;
  315.  return ( OK );
  316. }
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323. /* -----------------------------------------------------------------
  324.         Copy the current msg in file tmpname with quotes.
  325. */
  326. void QuoteMsg(tmpname)
  327. char *tmpname ;
  328. {
  329.  FILE *fq;
  330.  struct MsgHeaderType  *Msg ;
  331.  int i;
  332.  int col ;
  333.  byte *ptr ;
  334.  
  335.  char quote[10];
  336.  char tmp1[MAXPATHS];
  337.  char tmp2[50];
  338.  char tmp[MAXPATHS];
  339.  char ch ;
  340.  
  341.  Msg = ( struct MsgHeaderType *) rbuf ;
  342.  
  343.  tmp2[0]=0;
  344.  if( ! strncmp( Msg->Author,"SYSOP",5) )
  345.    strcpy (quote,"Sys > ");
  346.  else
  347.  {
  348.    sscanf(Msg->Author,"%s %s",tmp1,tmp2);         /* First & Last Name */
  349.    sprintf(quote,"%c%c > ",tmp1[0],tmp2[0] ? tmp2[0] : 32 ); /* Initials.. */
  350.  }
  351.  
  352.  printf("%s %s ...\n",txt[59],quote );  /* "Quoting message with " */
  353.  
  354.  if( ( fq = fopen(tmpname,"w")) == NULL )
  355.  {
  356.    printf("%s %s !\n",txt[50],tmpname ); /* "Unable to create file" */
  357.    return ;
  358.  }
  359.  if( setvbuf(fq,NULL,_IOFBF,VBUF ) )
  360.    printf("%sQuoteMsg() [temp file]\n",txt[ 94 ]);  /* "Setvbuf failed..." */
  361.  
  362.  RefMessage(fq,Msg);   /* Dear User, in a message to... */
  363.  
  364.   ptr = (byte *) (rbuf + sizeof(struct MsgHeaderType ) );
  365.   i = 0 ;
  366.   fprintf(fq,"%s",quote);
  367.   col = strlen(quote);
  368.   while (i < Index.Size)
  369.   {
  370.     if( *ptr == '\n' )
  371.     {
  372.        fprintf(fq,"\n%s",quote);
  373.        col = strlen(quote);
  374.     }
  375.     else
  376.     {
  377.       if( col < 78 )  /* Trunc quoted lines to 78 cols */
  378.         fprintf(fq,"%c",*ptr) ;
  379.       col ++ ;
  380.     }
  381.     i++;
  382.     ptr++;
  383.   }
  384.  fclose(fq);
  385. }
  386.  
  387.  
  388.  
  389. /*
  390.                 Réalise l'entête de la lettre...
  391. */
  392.  
  393. #define PUBLIC    1
  394. #define MYSELF    2
  395.  
  396. void RefMessage(fp,Msg)
  397. FILE *fp;
  398. struct MsgHeaderType *Msg ;
  399. {
  400.   char Destin[ 30 ];
  401.   char Ref   [ 30 ];
  402.   int mon,day,mod ;
  403.  
  404.   if( ! HeadLetter )
  405.      return ;
  406.  
  407.   sscanf(Msg->MsgDate,"%d-%d",&mon,&day);
  408.   Initials(Msg->Author,Destin,25);
  409.   Initials(Msg->ForWho,Ref, 25 );
  410.  
  411.   if( ! strncmp( Msg->ForWho,"ALL",3) )
  412.      mod = PUBLIC ;
  413.   else
  414.   if( ! strncmp( Msg->ForWho,UserName,strlen(UserName) ) )
  415.     mod  = MYSELF ;
  416.   else
  417.     mod  = 0 ;
  418.  
  419.  
  420.   fprintf(fp,"%s %s,\n",txt[96],Destin);              /* "Cher"           */
  421.                                                       /* "Dear"           */
  422.   fprintf(fp,"%s",txt[97]);                           /* "Dans un msg du" */
  423.   fprintf(fp," %d %s, ", day, Months[ mon - 1 ] );    /* "In a message of " */
  424.   switch( mod )
  425.   {
  426.         case PUBLIC :
  427.               fprintf(fp,"%s :\n\n",txt[98]);         /* "vous écrivez"   */
  428.         break ;                                       /* "you wrote"      */
  429.  
  430.         case MYSELF :
  431.               fprintf(fp,"%s :\n\n",txt[99]);         /* "vous m'écrivez" */
  432.         break ;                                       /* "wrote me"       */
  433.  
  434.         default :
  435.               fprintf(fp,"%s",txt[ 100 ]);            /* "destiné à"      */
  436.               fprintf(fp," %s, ",Ref);                /* "addressed to"   */
  437.               fprintf(fp,"%s :\n\n",txt[98]);         /* "vous écrivez"   */
  438.   }                                                   /* "you wrote       */
  439.  
  440. }
  441.  
  442.  
  443.  
  444. /*
  445. F        Formatte le nom en minuscules, avec les initiales Upcase,
  446. F        dans dst, null terminated.
  447.  
  448. E       Format name in lowercase with initials in Uppercase in dst,
  449. E       null terminated
  450.  
  451. */
  452. void Initials(str,dst,len)
  453. unsigned char *str,*dst ;
  454. int len ;
  455. {
  456.  int m,i;
  457.  
  458.    m = 1 ;
  459.    for( i = 0 ; i < len ; i++ )
  460.    {
  461.          *dst = *str  ;
  462.          if( *dst == '.' || *dst == '-' || *dst == ' ' )
  463.              m = 1 ; /* Next must be Upcase */
  464.          else
  465.          {
  466.             *dst = m ? toupper( *dst ) : tolower( *dst );
  467.             m = 0 ;
  468.          }
  469.  
  470.          str++;
  471.          dst++ ;
  472.    }
  473.  
  474.    *dst = 0 ;                /* build a null-terminated string */
  475.    dst --;
  476.    while ( *dst == 32 )
  477.    {
  478.         *dst = 0 ;
  479.         dst--;
  480.    }
  481. }
  482.  
  483.  
  484.  
  485. /*
  486.              more : prompts "more  ?" and wait for yes, oui, ja .
  487.              returns  1 for yes, 0 for no.
  488.              'def ' manages the CR default answer.
  489.  
  490. */
  491.  
  492. int more(def)
  493. int def;
  494. {
  495.  char tmp[10];
  496.  
  497.   for(;;)
  498.   {
  499.      high(); yellow();
  500.      printf(" %s ? : ",txt[ 60 ]);
  501.      fget(tmp,5,stdin);
  502.      switch( (int) tmp[0])
  503.      {
  504.             case 'o' :
  505.             case 'y' :
  506.             case 'O' :
  507.             case 'Y' :
  508.             case 'j'  :
  509.             case 'J'  :
  510.             clear();
  511.             up(1);
  512.             printf("\r              \r");
  513.             return ( 1 );
  514.  
  515.             case 'N' :
  516.             case 'n' :
  517.             clear();
  518.             return( 0 );
  519.  
  520.             case 0   :  /* CR */
  521.                 if( def == YES )
  522.                 {
  523.                      clear();
  524.                      up(1);
  525.                      printf("\r              \r");
  526.                      return ( 1 );
  527.                 }
  528.                 else
  529.                 {
  530.                      clear();
  531.                      return( 0 );
  532.                 }
  533.  
  534.      }
  535.   }
  536. }
  537.  
  538.  
  539.  
  540. /*
  541.              YesNo : prompts "Y/N : " and wait for yes, oui, ja .
  542.              returns  1 for yes, 0 for no.
  543.  
  544. */
  545.  
  546. int YesNo(def)
  547. int def;
  548. {
  549.  char tmp[10];
  550.  
  551.   for(;;)
  552.   {
  553.      printf(" %s : ",txt[ 61 ]);
  554.      fget(tmp,5,stdin);
  555.      switch( (int) tmp[0])
  556.      {
  557.             case 'o' :
  558.             case 'y' :
  559.             case 'O' :
  560.             case 'Y' :
  561.             case 'j'  :
  562.             case 'J'  :
  563.               printf("\r");
  564.             return ( 1 );
  565.  
  566.             case 'N' :
  567.             case 'n' :
  568.               printf ("\r");
  569.             return( 0 );
  570.  
  571.             case 0   :  /* CR */
  572.                 if( def == YES )
  573.                      return ( 1 );
  574.                 else
  575.                      return( 0 );
  576.  
  577.      }
  578.   }
  579. }
  580.  
  581.  
  582. void PackReply()
  583. {
  584.   char RepFile[MAXPATHS];
  585.   char MsgFile[MAXPATHS];
  586.   char Command[MAXPATHS];
  587.  
  588.   sprintf(RepFile,"%s%s.rep",ReplyPath,CurBoard);
  589.   if( !access(RepFile) )
  590.   {
  591.     red(); high();
  592.     /* "Warning ! file already exist " "delete it ?" */
  593.     printf("%s   %s %s %s...!\n",txt[2],txt[62],RepFile,txt[63]);
  594.     printf("            %s ",txt[ 64 ]);
  595.     if(YesNo(YES))
  596.      unlink(RepFile);
  597.   }
  598.   sprintf(MsgFile,"%s/%s.msg",WorkPath,CurBoard);
  599.   sprintf(Command,"%s %s %s",Archiver,RepFile,MsgFile);
  600.   yellow();high();
  601.   printf("%s %s\n",txt[ 65 ],RepFile );  /* "packing replies in" */
  602.   green();
  603.   system(Command);
  604.   ReplyExist = 0 ;
  605.   unlink(MsgFile);
  606. }
  607.  
  608.  
  609.  
  610. /*
  611.    UPDATECONF:  Write only if necessary the last read pointer in the
  612.    first index structure of the file.
  613. */
  614. void UpdateConf()
  615. {
  616.   struct MyIndex Idx ;
  617.   if( fseek( fidx,0L,SEEK_SET ) )
  618.   {
  619.         /* printf("Seek error...\n"); */
  620.         return ;
  621.   }
  622.   fread((char *)&Idx.LastRead,1,sizeof(struct MyIndex),fidx);
  623.   if( Idx.LastRead < Index.MsgNum )
  624.   {
  625.         Idx.LastRead = Index.MsgNum ;
  626.         fseek( fidx,0L,SEEK_SET );
  627.         fwrite((char *)&Idx.LastRead,1,sizeof(struct MyIndex),fidx);
  628.         printf("%s.\n",txt[66]); /* "Last read pointer updated" */
  629.   }
  630. }
  631.  
  632. /*------------------------------------------------------------------------*/
  633. /*
  634.     NPRINT: Print a string not null-terminated on stdout.
  635. */
  636. void nprint(str,len)
  637. byte *str;
  638. int len;
  639. {
  640.       while(len--) putchar(*str++);
  641. }
  642. /*------------------------------------------------------------------------*/
  643.  
  644. /*------------------------------------------------------------------------*/
  645. /*
  646.     NFPRINT: Print a string not null-terminated in file fp
  647. */
  648. void nfprint(fp,str,len)
  649. FILE *fp;
  650. byte *str;
  651. int len;
  652. {
  653.       while(len--) fputc(*str++,fp);
  654. }
  655. /*------------------------------------------------------------------------*/
  656.  
  657.  
  658.  
  659. /*----------------------------------------------------------------------*/
  660. /*  STR2MEM :
  661.             copies a string without the null character in order to fill
  662.             correctly the Qmail header.
  663. */
  664.  
  665. void str2mem(mem,str)
  666. char *mem, *str;
  667. {
  668.  
  669.      while(*str)
  670.       {
  671.             *mem = *str;
  672.             str++;
  673.             mem++;
  674.       }
  675. }
  676. /*----------------------------------------------------------------------*/
  677.  
  678.  
  679. /*
  680.     scpy : copies len bytes to src, deleting left spaces.
  681. */
  682. void scpy(dest,src,len)
  683. char *dest,*src;
  684. int len;
  685. {
  686.    register int i;
  687.  
  688.    for( i = 0 ; i < len ; i ++)
  689.       *(dest +i )= *(src + i );
  690.  
  691.    *(dest + i )  =  0 ;
  692.  
  693.    i--;
  694.    while( *(dest + i ) == 32 )
  695.    {
  696.       *(dest + i )  = 0 ;
  697.       i--;
  698.    }
  699.  
  700. }
  701.  
  702.  
  703.  
  704.  
  705. /*
  706.            FCOPY : fast copy of a file.
  707.                    return :  0 on success
  708.                              1 on error
  709. */
  710. int fcopy(source,destin )
  711. char *source;
  712. char *destin;
  713. {
  714.   int src,
  715.       dst;
  716.   int perm = S_IREAD | S_IWRITE ;
  717.   int acc  = O_RDWR | O_BINARY | O_CREAT | O_TRUNC ;
  718.   int nb;
  719.   char *buf;
  720.  
  721.   if(( buf = malloc ( 4096 ) ) == NULL )
  722.   {
  723.      printf("%s",txt[1] );
  724.      return ( 1 );
  725.   }
  726.  
  727.   if(  ( src  = open (source,O_RDONLY | O_BINARY) ) == -1 )
  728.   {
  729.       printf("%s %s\n",txt[49],source );  /* "unable to read file" */
  730.       free( buf );
  731.       return( 1 );
  732.   }
  733.  
  734.   if(  ( dst  = open (destin,acc,perm) ) == -1 )
  735.   {
  736.       printf("%s %s\n",txt[50],source ); /* "unable to create file" */
  737.       free( buf );
  738.       return( 1 );
  739.   }
  740.  
  741.   while( (nb  = read ( src, buf, 4096 )) )
  742.   {
  743.           write( dst,buf, nb  );
  744.   }
  745.   close( src );
  746.   close( dst );
  747.   free( buf );
  748.  return( 0 );
  749. }
  750.  
  751.  
  752. /*
  753.             VIEW :         View a file with more.
  754. */
  755. void view(Path,File)
  756. char *Path,*File;
  757. {
  758.   FILE *fp;
  759.   char tmp[MAXPATHS];
  760.   char buf[513];
  761.   int line =  0 ;
  762.  
  763.   sprintf(tmp,"%s/%s",Path,File );
  764.   if((fp = fopen(tmp,"r") )== NULL )
  765.   {
  766.      red();
  767.      printf("%s %s\n",txt[ 67 ], tmp ); /* "No file" */
  768.      return ;
  769.   }
  770.  
  771.   clear();
  772.   cyan();
  773.   printf("\n\n");
  774.   while( fget(buf,512,fp ) )
  775.   {
  776.    line++ ;
  777.     if( line > SCREENLINES - 7 )
  778.       {
  779.         line = 0 ;
  780.         if( ! more(YES) )
  781.           break ;
  782.         cyan();
  783.       }
  784.    puts(buf) ;
  785.   }
  786.   fclose(fp);
  787. }
  788.  
  789.  
  790. /*
  791.    Si un rigolo tape ce mot dans le shell...
  792.  
  793.    If a jerk were to type this word in a shell...
  794.  
  795.    BTW the word merde = shit
  796.  
  797. */
  798. void merde()
  799. {
  800.   magenta();high();
  801.   printf("\n");
  802.   printf("Espèce de petit connard, on t'a pas appris la politesse  ???%c\n",7);
  803.  
  804.  
  805.   /* Stupid jerk, haven't you been shown proper maners??? */
  806.  
  807.   printf("Va te faire foutre !!!\n\n");
  808.  
  809.   /* Go to hell !!! */
  810. }
  811.  
  812. /*
  813.     NUMERIC : Returns 1 if the string is a number, 0 if not.
  814. */
  815. int Numeric( str )
  816. char *str;
  817. {
  818.   if( *str == 0 )
  819.    return( 0 );
  820.   while( *str )
  821.   {
  822.     if( *str < '0' || *str > '9' )
  823.      return ( 0 );
  824.    str++;
  825.   }
  826.   return ( 1 );
  827. }
  828.  
  829. /*
  830.   IsQuoted(str)   Returns 1 if the string contains c in the 15 left chars.
  831. */
  832.  
  833. int IsQuoted(c,str)
  834. int c;
  835. char *str ;
  836. {
  837.  register int i;
  838.  
  839.  for(i = 0 ; i < 15 ; i ++ )
  840.   {
  841.     if( *str == 0 )   return ( 0 );
  842.     if( *str++ == c ) return ( 1 );
  843.   }
  844.  return ( 0 );
  845. }
  846.  
  847. /*
  848.      DATE : prints the date :-)
  849. */
  850.  
  851. void Date()
  852. {
  853.   long t;
  854.   blue(); high();
  855.   time(&t);
  856.   printf(ctime(&t) );
  857. }
  858.  
  859. /*
  860.     EmptyMsg : Tell that there is no BBs loaded.
  861. */
  862.  
  863. void EmptyMsg()
  864. {
  865.   red(); high();
  866.   printf("%s ",txt[ 68 ] );       /* "Hey !" */
  867.   clear();magenta();
  868.   printf("%s\n",txt[69]);         /* There is no bbs loaded !"*/
  869.   printf("%s...\n",txt[ 70 ]);    /* use 'read' 'load' or 'help' command"*/
  870.   clear();
  871. }
  872. /*_-----------------------------------------------------------------------*/
  873.