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

  1. /***********************************************************************
  2.  
  3.                        CSA Library, Free Evaluation Version 2.0.5 
  4.                                        Release: January 22th 1997 
  5.  
  6.        Set of 'portable' functions, to overcome differences
  7.        between platforms and compilers.
  8.        The names of these functions are always of the format:
  9.            p<Capital><lowercase string>
  10.  
  11.        Example: The DOS function 'strupr()', has  now a portable
  12.         counterpart 'pStrupr()'.
  13.  
  14.  
  15.                                            Copyright(c) 1994-1997 
  16.                                                           ComBits 
  17.                                                   The Netherlands 
  18. ***********************************************************************/
  19.  
  20.  
  21. #ifndef __CSPORT_H
  22. #define __CSPORT_H
  23.  
  24.  
  25. #include "cstypes.h"
  26.  
  27. ////////////////////////// String releated /////////////////////////////////
  28.  
  29. /*
  30.    Compares at most the first 'len' bytes of the strings 'p' and 'q'.
  31.    The comparison is done case INsensitive.
  32.  
  33.    Return values:
  34.        < 0    'p' is before 'q' in the alphabet.
  35.        0      'p' and 'q' are equal.
  36.        >0     'p' comes after 'q' in the alphabet.
  37.  
  38.  
  39. */
  40.   int pStrnicmp(csCHAR *p,csCHAR *q,int len);
  41.   int pStricmp(csCHAR  *p,csCHAR *q);
  42.  
  43.  
  44.  
  45. //Converting to uppercase/lowercase.
  46. //This may not work for string constants because the
  47. //string is modified at its original location.
  48.  
  49.   csCHAR *pStrupr(csCHAR *str);
  50.   csCHAR *pStrlwr(csCHAR *str);
  51.  
  52. //Revers string.
  53. //Example: 'large'  becomes 'egral'.
  54. //The terminating zero remains in place.
  55.  
  56.   csCHAR *pStrrev(csCHAR *str);
  57.  
  58.  
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61.  
  62. /*
  63.    Returns the length of file 'file' in bytes.
  64.    This even works for symbolic links and 'sparse' files.
  65.  
  66.    If an error occurs (the file cannot be found) the function returns  -1.
  67.  
  68. */
  69.   long pFilelength(csCHAR *file);
  70.  
  71.  
  72. ///////////////////////// MAx & Min  /////////////////////////////////////////
  73.  
  74. /*
  75.    Just another version of the max and min functions.
  76.  
  77. */
  78.  
  79. inline long pMin(long x,long y) { return (x<y) ? x: y; }
  80. inline long pMax(long x,long y) { return (x>y) ? x: y; }
  81.  
  82.  
  83. //////////////////////// Integer 2 String conversions ///////////////////
  84.  
  85. csCHAR *pItoa(int  number,csCHAR *buf,int radix);
  86. csCHAR *pLtoa(long number,csCHAR *buf,int radix);
  87.  
  88.  
  89.  
  90. /////////////////////// Changing file size /////////////////////////////
  91. // Returns  0 on success
  92. //       -1 on failure.
  93.  
  94. int pChsize(int handle,U32 length);
  95.  
  96.  
  97. ////////////////////// Splitting a file name //////////////////////////
  98. // Splits a file name into drive,dir,name and ext.
  99. // This function is equivalent to Borland's fnsplit();
  100. //
  101. // It is valid to call the function with one or more NULL pointers.
  102. // Otherwise the pointer is supposed to point to a buffer large
  103. // enough to hold the returned string.
  104.  
  105. // These lengths are defined in csfile.h by the following constants:
  106. //
  107. //    MAXPATH        path
  108. //    MAXDRIVE        drive, includes colon  (Empty string under UNIX)
  109. //    MAXDIR        dir, includes leading and trailing slashes
  110. //    MAXFILE        name
  111. //    MAXEXT        ext, includes leading dot (.)
  112.  
  113. // In case there is  more then one dot in the name (UNIX), everything after
  114. // the *last* dot is taken as the extension.
  115. // Names of the form:  ..example  or  .file  are considered to have no extension.
  116. // In cases like  file..ext  it takes  ..ext  as extension.
  117.  
  118.  
  119. // The return value is a bit-or of the following five flags (csfile.h):
  120.  
  121. // CS_EXTENSION    an extension
  122. // CS_FILENAME       a filename
  123. // CS_DIRECTORY    a directory
  124. // CS_DRIVE       a drive specification
  125. // CS_WILDCARDS    wildcards (* or ?)
  126.  
  127. // The flag is set if the corresponding component was found in the name.
  128.  
  129.  
  130. int pFnsplit(const csCHAR *pathP,
  131.            csCHAR *drive, csCHAR *dir, csCHAR *name, csCHAR *ext);
  132.  
  133.  
  134.  
  135.  
  136.  
  137. #endif
  138.  
  139.