home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cslio205.zip / INCLUDE / CSTOOLS.H < prev    next >
C/C++ Source or Header  |  1997-01-21  |  4KB  |  125 lines

  1. /***********************************************************************
  2.  
  3.                        CSA Library, Free Evaluation Version 2.0.5 
  4.                                        Release: January 22th 1997 
  5.  
  6.        Collection of general purpose functions.
  7.  
  8.  
  9.                                            Copyright(c) 1994-1997 
  10.                                                           ComBits 
  11.                                                   The Netherlands 
  12. ***********************************************************************/
  13.  
  14. #ifndef __CSTOOLS_H
  15. #define __CSTOOLS_H
  16.  
  17. #include "cswarnof.h"
  18. #include "csport.h"
  19. #include "string.h"
  20. #include "csborder.h"
  21.  
  22.  
  23.  
  24. ///////////////// String functions /////////////////////////////////////
  25.  
  26. csCHAR *notabs(csCHAR *s);        //STRIP tabs. It doesn't expand.
  27. csCHAR *remove_space(csCHAR *s);
  28.  
  29. inline
  30. csCHAR *str_lower(csCHAR *s) { return pStrlwr(s); }
  31. inline
  32. csCHAR *str_upper(csCHAR *s) { return pStrupr(s); }
  33.  
  34. csCHAR *filter_string(csCHAR *s,csCHAR *p);
  35. csCHAR *trim_string( csCHAR *s);
  36. void    str_left(    csCHAR *s,  csCHAR *d,int len);
  37. void    str_split(   csCHAR *src,csCHAR ch,csCHAR *frst,csCHAR *last);
  38. csCHAR *str_strip(   csCHAR *s,  csCHAR *f);
  39.  
  40. csCHAR *string_replace_ones(csCHAR *s,csCHAR *d,csCHAR *r);
  41. int     string_replace(csCHAR *s,csCHAR *d,csCHAR *r);
  42.  
  43.  
  44. inline
  45. csCHAR *str_addchar(csCHAR *s,csCHAR c)
  46. {  csCHAR *p=s+strlen(s);  *p++=c; *p=0; return s; }
  47.  
  48.  
  49.  
  50.  
  51. ///////////////// Text Screen functions ////////////////////////////////
  52.  
  53. void  box(int row,int col,int h,int w,int border,int color);
  54. void  desktop(void);
  55. void  disp_r_xy(int x,int y,csCHAR c, csCHAR color);
  56. void  disp_xy(int x,int y,csCHAR c, csCHAR color);
  57. void  disp_r_xy(int x,int y,csCHAR c);
  58. void  disp_xy(int x,int y,csCHAR c);
  59. int   is_color(void);
  60.  
  61. #ifdef _CP_001
  62. #include "conio.h"
  63. inline void gotoyx(int y,int x) { gotoxy(x,y); }
  64. #endif
  65.  
  66. inline int  make_color(int txt,int backg) {return txt|((backg&7)<<4); }
  67.  
  68. ///////////////// Keyboard //////////////////////////////////////////////
  69. void  empty_kb(void);
  70. void  wait(long msec);
  71. void  waitkb(long msec);
  72.  
  73. ///////////////// Numerical functions ///////////////////////////////////
  74. U32   csrand(U32);
  75. void  csrandomize(U32 n);
  76.  
  77. U32   cssqrtl(U32 l);
  78. U16   cssqrti(U16 i);
  79. U16   next_prime(U16 i);
  80. U32   lrandom(U32 amount);
  81.  
  82. ////// Returns a representation of a POSITIVE long as 'beautified' string.
  83. ////// Example: 17456 -> "17.456"
  84.  
  85. csCHAR *beautify_long(long l,csCHAR *buffer);
  86.  
  87. ///////////////// File related //////////////////////////////////////////
  88. inline long  filesize(csCHAR *name) { return pFilelength(name); }
  89. int   disk(csCHAR *s);
  90. // char *file_ext(csCHAR *naam,csCHAR *ext);
  91. int   file_exist(csCHAR *fnaam);
  92. int   add_path(csCHAR *filen,csCHAR *path);
  93. int   cstmpname(csCHAR *name);
  94. int   name_match_pattern(csCHAR *filename,csCHAR *pattern);
  95.  
  96. ///////////////// Miscellaneous /////////////////////////////////////////
  97. csCHAR *add2point(void *p,long l);
  98. U32    time_stamp(void);
  99. int    bit_masks(U32 l,U32 &off,U16 &shift);
  100.  
  101. csCHAR *Char2Hex(csCHAR *buffer, csCHAR c);
  102.  
  103. ///////////////// To avoid superfluous type checking ////////////////////////
  104.  
  105. inline char *csstrcpy(void *s,void *d) { return strcpy((char *)s,(const char *)d);  }
  106. inline int   csstrlen(void *s) { return strlen((const char *)s); }
  107. inline char *csstrcat(void *s,void *d) { return strcat((char *)s,(const char *)d);  }
  108.  
  109.  
  110. #ifndef TRUE
  111. #define TRUE      1
  112. #endif
  113.  
  114. #ifndef FALSE
  115. #define FALSE     0
  116. #endif
  117.  
  118. #define SWAP(x,y)  ((x) ^= (y) ^= (x) ^= (y))
  119. #define ABS(x)     MAX(x,-(x))
  120. #define MAX(x,y)   (( ((x)>(y)) ? (x):(y)))
  121. #define MIN(x,y)   (( ((x)<(y)) ? (x):(y)))
  122.  
  123.  
  124. #endif
  125.