[2286] | 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 | *********************************************************************/
|
---|
[611] | 27 |
|
---|
[3810] | 28 | #include "text_t.h"
|
---|
| 29 |
|
---|
[611] | 30 | /*
|
---|
| 31 | Module Name: Parse
|
---|
| 32 | Purpose: General string parsing. These are functions that are not in string.h,
|
---|
| 33 | but are found in many other libraries and high level languages.
|
---|
| 34 | Public Functions:
|
---|
| 35 | Left
|
---|
| 36 | Right
|
---|
| 37 |
|
---|
| 38 | Trim
|
---|
| 39 | TrimLeft
|
---|
| 40 | TrimRight
|
---|
| 41 |
|
---|
| 42 | GetWord
|
---|
| 43 | GetLastWord
|
---|
| 44 |
|
---|
| 45 | Split Path
|
---|
| 46 | GetExtention
|
---|
| 47 | */
|
---|
| 48 |
|
---|
| 49 | /*
|
---|
| 50 | Function Name: Left
|
---|
| 51 | Purpose: Copies the leftmost x number of charactors of a string to a buffer
|
---|
| 52 | Parameters:
|
---|
| 53 | DestStr - Destination buffer for substring
|
---|
| 54 | SourceStr - Source string to make substing from
|
---|
| 55 | Len - Length of substring
|
---|
| 56 |
|
---|
| 57 | Notes: If Len is greater than strlen(SourceStr) a memory error may occur.
|
---|
| 58 | */
|
---|
| 59 | void Left(char *DestStr, const char *SourceStr, const int Len);
|
---|
| 60 |
|
---|
| 61 | /*
|
---|
| 62 | Function Name: Right
|
---|
| 63 | Purpose: Copies the rightmost x number of charactors of a string to a buffer
|
---|
| 64 | Parameters:
|
---|
| 65 | DestStr - Destination buffer for substring
|
---|
| 66 | SourceStr - Source string to make substing from
|
---|
| 67 | Len - Length of substring
|
---|
| 68 |
|
---|
| 69 | Notes: If Len is greater than strlen(SourceStr) then a memory error may
|
---|
| 70 | occur.
|
---|
| 71 | */
|
---|
| 72 | void Right(char *DestStr, const char *SourceStr, const int Len);
|
---|
| 73 |
|
---|
| 74 | /*
|
---|
| 75 | Function Name: TrimLeft
|
---|
| 76 | Purpose: Removes spaces and tabs from the left end of a string.
|
---|
| 77 | Parameters:
|
---|
| 78 | TargetString - String to be trimmed
|
---|
| 79 | */
|
---|
| 80 | void TrimLeft(char *TargetStr);
|
---|
| 81 |
|
---|
| 82 | /*
|
---|
| 83 | Function Name: TrimRight
|
---|
| 84 | Purpose: Removes spaces and tabs from the right end of a string.
|
---|
| 85 | Parameters:
|
---|
| 86 | TargetString - String to be trimmed
|
---|
| 87 | */
|
---|
| 88 | void TrimRight(char *TargetStr);
|
---|
| 89 |
|
---|
| 90 | /*
|
---|
| 91 | Function Name: Trim
|
---|
| 92 | Purpose: Removes spaces and tabs from both ends of a string.
|
---|
| 93 | Parameters:
|
---|
| 94 | TargetString - String to be trimmed
|
---|
| 95 | */
|
---|
| 96 | void Trim(char *TargetStr);
|
---|
| 97 |
|
---|
| 98 | /*
|
---|
| 99 | Function Name: GetWord
|
---|
[3810] | 100 | Purpose: Gets leftmost substring without a space in the string between the iterators
|
---|
| 101 | 'here' and 'end'. Sets 'DestStr' to the substring. Sets the 'next' iterator
|
---|
| 102 | to the next non-space charactor in the string. ' ' and '\t' and considered
|
---|
| 103 | spaces
|
---|
[611] | 104 | Parameters:
|
---|
| 105 | DestString - Destination buffer for substring
|
---|
[3810] | 106 | first - First character in source string
|
---|
| 107 | last - end iterator (one past last character) of source string
|
---|
| 108 | next - At end of function call is set to the location of next non-space
|
---|
| 109 | charactor in source string
|
---|
[611] | 110 | */
|
---|
[3810] | 111 | void GetWord(text_t &DestStr, text_t::const_iterator first,
|
---|
| 112 | text_t::const_iterator last, text_t::const_iterator &next);
|
---|
[611] | 113 |
|
---|
| 114 | /*
|
---|
| 115 | Function Name: GetLastWord
|
---|
[3810] | 116 | Purpose: Gets rightmost substring without a space sets Start to be the first
|
---|
| 117 | character of the substring in the original string.
|
---|
[611] | 118 | Parameters:
|
---|
| 119 | DestString - Destination buffer for substring
|
---|
[3810] | 120 | first and last - Source string to make substing from
|
---|
| 121 | Start - where the DestString starts at in the source string
|
---|
[611] | 122 | */
|
---|
[3810] | 123 | void GetLastWord(text_t &DestStr, text_t::const_iterator first, text_t::const_iterator last,
|
---|
| 124 | text_t::const_iterator &Start);
|
---|
[611] | 125 |
|
---|
| 126 |
|
---|
| 127 | /*
|
---|
| 128 | Function Name: Split Path
|
---|
| 129 | Purpose: Splits a path string into directory and file name
|
---|
| 130 | Parameters:
|
---|
| 131 | Path - Path string (example "c:\Fnord\SomeFile.Ext")
|
---|
| 132 | Dir - Directory part of the Path (example "c:\Fnord\")
|
---|
| 133 | FileName - File name part of the path (example "SomeFile.Ext")
|
---|
| 134 | */
|
---|
| 135 | void SplitPath(char *Path, char *Dir, char *FileName);
|
---|
| 136 |
|
---|
| 137 | /*
|
---|
| 138 | Function Name: Get Extention
|
---|
| 139 | Purpose: Splits a path string into directory and file name
|
---|
| 140 | Parameters:
|
---|
| 141 | Path - Path string or file name (example "c:\Fnord\SomeFile.Ext")
|
---|
| 142 | Extention - Extention part of the path (example "Ext")
|
---|
| 143 | */
|
---|
| 144 | void GetExtention(char *Path, char *Extention);
|
---|
| 145 |
|
---|
| 146 | /*
|
---|
| 147 | Function Name: Translate Escape String
|
---|
| 148 | Purpose: Translates all URL escape sequences, such as "%20" where "20" is
|
---|
| 149 | the resulting charactor in hexidecimal
|
---|
| 150 | Parameters:
|
---|
| 151 | TargetStr - String that may contain URL escape sequences. All sequences
|
---|
| 152 | are decoded on return.
|
---|
| 153 | */
|
---|
| 154 | void TranslateEscapeString(char *TargetStr);
|
---|
| 155 |
|
---|
| 156 | /*
|
---|
| 157 | Function Name: Hex Value
|
---|
| 158 | Purpose: Returns the value of a hexidecimal digit character as an integer
|
---|
| 159 | Parameters:
|
---|
| 160 | c - Charactor to translate
|
---|
| 161 | */
|
---|
| 162 | int HexVal(char c);
|
---|