| 130 | } |
| 131 | |
| 132 | BOOLEAN |
| 133 | FindSection ( |
| 134 | IN MEMORY_FILE *InputFile, |
| 135 | IN CHAR8 *Section |
| 136 | ) |
| 137 | /*++ |
| 138 | |
| 139 | Routine Description: |
| 140 | |
| 141 | This function parses a file from the beginning to find a section. |
| 142 | The section string may be anywhere within a line. |
| 143 | |
| 144 | Arguments: |
| 145 | |
| 146 | InputFile Memory file image. |
| 147 | Section Section to search for |
| 148 | |
| 149 | Returns: |
| 150 | |
| 151 | FALSE if error or EOF |
| 152 | TRUE if section found |
| 153 | |
| 154 | --*/ |
| 155 | { |
| 156 | CHAR8 InputBuffer[MAX_LONG_FILE_PATH]; |
| 157 | CHAR8 *CurrentToken; |
| 158 | |
| 159 | // |
| 160 | // Verify input is not NULL |
| 161 | // |
| 162 | assert (InputFile->FileImage); |
| 163 | assert (InputFile->Eof); |
| 164 | assert (InputFile->CurrentFilePointer); |
| 165 | assert (Section); |
| 166 | |
| 167 | // |
| 168 | // Rewind to beginning of file |
| 169 | // |
| 170 | InputFile->CurrentFilePointer = InputFile->FileImage; |
| 171 | |
| 172 | // |
| 173 | // Read lines until the section is found |
| 174 | // |
| 175 | while (InputFile->CurrentFilePointer < InputFile->Eof) { |
| 176 | // |
| 177 | // Read a line |
| 178 | // |
| 179 | ReadLine (InputFile, InputBuffer, MAX_LONG_FILE_PATH); |
| 180 | |
| 181 | // |
| 182 | // Check if the section is found |
| 183 | // |
| 184 | CurrentToken = strstr (InputBuffer, Section); |
| 185 | if (CurrentToken != NULL) { |
| 186 | return TRUE; |
| 187 | } |
| 188 | } |
| 189 | |