home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / lpopper.zip / addit.c < prev    next >
C/C++ Source or Header  |  1999-07-12  |  2KB  |  109 lines

  1. #include "popper.h"
  2.  
  3. int IsSpace( char Ch)
  4. { switch(Ch)
  5.    { case 0x20 :
  6.      case 0x0D :
  7.      case 0x0A :
  8.      case 0x08 : break;
  9.      default   : return(0);
  10.    }
  11.   return(1);
  12. }
  13.  
  14. int IsEmpty (char * Str)
  15. { register int i;
  16.   for(i=0;i<strlen(Str);i++)
  17.    { if(!IsSpace(Str[i])) return(0);
  18.    }
  19.   return(1);
  20. }
  21.  
  22. void DelEndSpaces( char * Str)
  23. { int End;
  24.  
  25.   if(Str[0]==0) return;
  26.  
  27.   for(End=strlen(Str);((IsSpace(Str[End-1])==1) && (End>=0));End--);
  28.   Str[End]=0;
  29. }
  30.  
  31. void DelBegSpaces( char * Str)
  32. { int Beg, i;
  33.  
  34.   if(Str[0]==0) return;
  35.  
  36.   for(Beg=0;IsSpace(Str[Beg])==1;Beg++);
  37.   for(i=0;Str[i+Beg-1]!=0;i++)
  38.    { Str[i]=Str[i+Beg];
  39.    }
  40. }
  41. void DelSpaces (char * Str)
  42. { DelBegSpaces(Str);
  43.   DelEndSpaces(Str);
  44. }
  45.  
  46. int IsCRLF (char Ch)
  47. { if((Ch==0x0D) || (Ch==0x0A)) return(1);
  48.   return(0);
  49. }
  50.  
  51. void DelEndCRLF (char * Str)
  52. { register int i;
  53.  
  54.   for(i=strlen(Str)-1;(i>0) && IsCRLF(Str[i]);i--)
  55.    Str[i]=0;
  56. }
  57.  
  58. static char cTbl[]="ßΓ≈τΣσ÷·ΘΩ"
  59.                    "δ∞φε∩≡≥≤⌠⌡"
  60.                    "µΦπ■√² ∙°ⁿ"
  61.                    "α±┴┬╫╟─┼╓┌"
  62.                    "╔╩╦╠═╬╧╨Éæ"
  63.                    "Æüç▓┤ºª╡í¿"
  64.                    "«¡¼âäëêåÇè"
  65.                    "»░½Ñ╗╕▒á╛╣"
  66.                    "║╢╖¬⌐óñ╜╝à"
  67.                    "éìîÄÅï╥╙╘╒"
  68.                    "╞╚├▐█▌▀┘╪▄"
  69.                    "└╤│úÖÿô¢ƒù"
  70.                    "£ò₧û┐¥ö ";
  71.  
  72.  
  73.  
  74. unsigned char cDOS2KOI (unsigned char Ch)
  75. {
  76.  if(Ch<128) return(Ch);
  77.  return(cTbl[Ch-128]);
  78. };
  79.  
  80.  
  81.  
  82. void _PrintTime (FILE * Fl)
  83. { time_t Timer;
  84.   struct tm * Time;
  85.  
  86.   time(&Timer);
  87.   Time=localtime(&Timer);
  88.  
  89.   fprintf(Fl, " %2.2u/%2.2u/%2.2u %2.2u:%2.2u ", (unsigned int)Time->tm_mday
  90.                                                , (unsigned int)Time->tm_mon+1
  91.                                                , (unsigned int)Time->tm_year
  92.                                                , (unsigned int)Time->tm_hour
  93.                                                , (unsigned int)Time->tm_min);
  94.  
  95. }
  96.  
  97. void PrintTime(void)
  98. { _PrintTime(stdout);
  99. }
  100.  
  101. void ePrintTime(void)
  102. { _PrintTime(stderr);
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109.