home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cons-010.zip / Console / src / common / strop.h < prev    next >
C/C++ Source or Header  |  1997-09-10  |  4KB  |  97 lines

  1. /******************************************************************************\
  2. |*                                                                            *|
  3. |* String manipulation routines: header file                                  *|
  4. |* Copyright (C) 1997 by FRIENDS software                                     *|
  5. |* All Rights Reserved                                                        *|
  6. |* Portability: Any OS with a C compiler                                      *|
  7. |*                                                                            *|
  8. |* This program is free software; you can redistribute it and/or modify       *|
  9. |* it under the terms of the GNU General Public License as published by       *|
  10. |* the Free Software Foundation; either version 2 of the License, or          *|
  11. |* (at your option) any later version.                                        *|
  12. |*                                                                            *|
  13. |* This program is distributed in the hope that it will be useful,            *|
  14. |* but WITHOUT ANY WARRANTY; without even the implied warranty of             *|
  15. |* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *|
  16. |* GNU General Public License for more details.                               *|
  17. |*                                                                            *|
  18. |* You should have received a copy of the GNU General Public License          *|
  19. |* along with this program; if not, write to the Free Software                *|
  20. |* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA  *|
  21. |*                                                                            *|
  22. \******************************************************************************/
  23.  
  24. #ifndef __STROP_H__
  25. #define __STROP_H__
  26.  
  27. #include "stype.h"
  28.  
  29. #ifdef __cplusplus
  30.  extern "C" {
  31. #endif
  32.  
  33. #define CR    '\r'
  34. #define LF    '\n'
  35. #define TAB   '\t'
  36. #define SPACE ' '
  37.  
  38. #ifdef __EMX__
  39. #define PATHSEP "\\/"
  40. #else
  41. #define PATHSEP "/"
  42. #endif
  43.  
  44. /* Convert a character to upper/lower case */
  45. char upCase(char Ch);
  46. char loCase(char Ch);
  47.  
  48. /* Extract directory from full pathname */
  49. char *extractDir(char *pathName);
  50.  
  51. /* Extract filename from full pathname */
  52. char *extractName(char *pathName);
  53.  
  54. /* Remove spaces/tabs at the beginning of string */
  55. char *removeStartSpaces(char * sz);
  56. /* Remove spaces/tabs at the ending of string */
  57. char *removeLastSpaces(char *sz);
  58.  
  59. /* Identifies first word in sz with a token from wordlist (delimted by \0) */
  60. /* and returns its ordinal (0 = not found). Then token is removed from sz. */
  61. int Token(char * sz, char * wordlist);
  62.  
  63. /* Returns a pointer to token number no in wordlist */
  64. char *GetToken(char *wordlist, int no);
  65.  
  66. /* Same as atoi() but removes number and stops at first non-decimal char */
  67. long decVal(char *s);
  68. /* Same as decVal but works in hexadecimal */
  69. ulong hexVal(char *s);
  70.  
  71. /* Converts a ulong to string */
  72. char *decStr(ulong val, int nch, char *buff);
  73. /* Same as decStr but works in hexadecimal */
  74. char *hexStr(ulong val, int nch, char *buff);
  75.  
  76. /* Converts Val into hexadecimal character (0-F) */
  77. char hexChar(char Val);
  78.  
  79. /* Sets string S to a string of Num characters Ch */
  80. char *Strg(char Ch, int Num, char *S);
  81.  
  82. /* Return position of first character Ch in string S */
  83. int strfirst(char Ch, char *S);
  84. /* Return position of last character Ch in string S */
  85. int strlast(char Ch, char *S);
  86.  
  87. /* Return length of first word in string (delimited by SPACE or TAB) */
  88. int firstwordlen(char *S);
  89.  
  90. void strdel(char *S, int start, int count);
  91.  
  92. #ifdef __cplusplus
  93.  };
  94. #endif
  95.  
  96. #endif __STROP_H__
  97.