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