1 | /*
|
---|
2 | Copyright (C) 1996
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
17 |
|
---|
18 | The author can be contacted via Email at [email protected]
|
---|
19 | */
|
---|
20 |
|
---|
21 | /*
|
---|
22 | Module Name: Parse
|
---|
23 | Purpose: General string parsing. These are functions that are not in string.h,
|
---|
24 | but are found in many other libraries and high level languages.
|
---|
25 | Public Functions:
|
---|
26 | Left
|
---|
27 | Right
|
---|
28 |
|
---|
29 | Trim
|
---|
30 | TrimLeft
|
---|
31 | TrimRight
|
---|
32 |
|
---|
33 | GetWord
|
---|
34 | GetLastWord
|
---|
35 |
|
---|
36 | Split Path
|
---|
37 | GetExtention
|
---|
38 | */
|
---|
39 |
|
---|
40 | /*
|
---|
41 | Function Name: Left
|
---|
42 | Purpose: Copies the leftmost x number of charactors of a string to a buffer
|
---|
43 | Parameters:
|
---|
44 | DestStr - Destination buffer for substring
|
---|
45 | SourceStr - Source string to make substing from
|
---|
46 | Len - Length of substring
|
---|
47 |
|
---|
48 | Notes: If Len is greater than strlen(SourceStr) a memory error may occur.
|
---|
49 | */
|
---|
50 | void Left(char *DestStr, const char *SourceStr, const int Len);
|
---|
51 |
|
---|
52 | /*
|
---|
53 | Function Name: Right
|
---|
54 | Purpose: Copies the rightmost x number of charactors of a string to a buffer
|
---|
55 | Parameters:
|
---|
56 | DestStr - Destination buffer for substring
|
---|
57 | SourceStr - Source string to make substing from
|
---|
58 | Len - Length of substring
|
---|
59 |
|
---|
60 | Notes: If Len is greater than strlen(SourceStr) then a memory error may
|
---|
61 | occur.
|
---|
62 | */
|
---|
63 | void Right(char *DestStr, const char *SourceStr, const int Len);
|
---|
64 |
|
---|
65 | /*
|
---|
66 | Function Name: TrimLeft
|
---|
67 | Purpose: Removes spaces and tabs from the left end of a string.
|
---|
68 | Parameters:
|
---|
69 | TargetString - String to be trimmed
|
---|
70 | */
|
---|
71 | void TrimLeft(char *TargetStr);
|
---|
72 |
|
---|
73 | /*
|
---|
74 | Function Name: TrimRight
|
---|
75 | Purpose: Removes spaces and tabs from the right end of a string.
|
---|
76 | Parameters:
|
---|
77 | TargetString - String to be trimmed
|
---|
78 | */
|
---|
79 | void TrimRight(char *TargetStr);
|
---|
80 |
|
---|
81 | /*
|
---|
82 | Function Name: Trim
|
---|
83 | Purpose: Removes spaces and tabs from both ends of a string.
|
---|
84 | Parameters:
|
---|
85 | TargetString - String to be trimmed
|
---|
86 | */
|
---|
87 | void Trim(char *TargetStr);
|
---|
88 |
|
---|
89 | /*
|
---|
90 | Function Name: GetWord
|
---|
91 | Purpose: Gets leftmost substring without a space, starts at any position at
|
---|
92 | the start string and sets End to be the next non-space charactor in the
|
---|
93 | string. ' ' and '\t' and considered spaces
|
---|
94 | Parameters:
|
---|
95 | DestString - Destination buffer for substring
|
---|
96 | SourceString - Source string to make substing from
|
---|
97 | Start - 0 based string index to start at
|
---|
98 | End - At end of function call is set to the location of next non-space
|
---|
99 | charactor
|
---|
100 |
|
---|
101 | Notes: If Start is greater than strlen(SourceStr) then a memory error may
|
---|
102 | occur.
|
---|
103 | */
|
---|
104 | void GetWord(char *DestStr, const char *SourceStr, const int Start, int &End);
|
---|
105 |
|
---|
106 | /*
|
---|
107 | Function Name: GetLastWord
|
---|
108 | Purpose: Gets rightmost substring without a space sets Start to be the 0 based
|
---|
109 | index of where the substring starts in the original string.
|
---|
110 | Parameters:
|
---|
111 | DestString - Destination buffer for substring
|
---|
112 | SourceString - Source string to make substing from
|
---|
113 | Start - 0 based string index where the DestString starts at
|
---|
114 | */
|
---|
115 | void GetLastWord(char *DestString, const char *SourceStr, int &Start);
|
---|
116 |
|
---|
117 |
|
---|
118 | /*
|
---|
119 | Function Name: Split Path
|
---|
120 | Purpose: Splits a path string into directory and file name
|
---|
121 | Parameters:
|
---|
122 | Path - Path string (example "c:\Fnord\SomeFile.Ext")
|
---|
123 | Dir - Directory part of the Path (example "c:\Fnord\")
|
---|
124 | FileName - File name part of the path (example "SomeFile.Ext")
|
---|
125 | */
|
---|
126 | void SplitPath(char *Path, char *Dir, char *FileName);
|
---|
127 |
|
---|
128 | /*
|
---|
129 | Function Name: Get Extention
|
---|
130 | Purpose: Splits a path string into directory and file name
|
---|
131 | Parameters:
|
---|
132 | Path - Path string or file name (example "c:\Fnord\SomeFile.Ext")
|
---|
133 | Extention - Extention part of the path (example "Ext")
|
---|
134 | */
|
---|
135 | void GetExtention(char *Path, char *Extention);
|
---|
136 |
|
---|
137 | /*
|
---|
138 | Function Name: Translate Escape String
|
---|
139 | Purpose: Translates all URL escape sequences, such as "%20" where "20" is
|
---|
140 | the resulting charactor in hexidecimal
|
---|
141 | Parameters:
|
---|
142 | TargetStr - String that may contain URL escape sequences. All sequences
|
---|
143 | are decoded on return.
|
---|
144 | */
|
---|
145 | void TranslateEscapeString(char *TargetStr);
|
---|
146 |
|
---|
147 | /*
|
---|
148 | Function Name: Hex Value
|
---|
149 | Purpose: Returns the value of a hexidecimal digit character as an integer
|
---|
150 | Parameters:
|
---|
151 | c - Charactor to translate
|
---|
152 | */
|
---|
153 | int HexVal(char c);
|
---|