| 1 | #include "stdafx.h" |
| 2 | #include "TextFile.h" |
| 3 | #include "KmpSearch.h" |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <string.h> |
| 7 | |
| 8 | uint16 findCptId(char *name, TextFile *cptFile) { |
| 9 | KmpSearch *kmp = new KmpSearch(); |
| 10 | kmp->init(name); |
| 11 | int cLine = 0; |
| 12 | do { |
| 13 | cLine = cptFile->findLine(kmp, cLine); |
| 14 | if (cLine >= 0) { |
| 15 | char *line = cptFile->giveLine(cLine); |
| 16 | if ((strncmp(line, "COMPACT::", 9) == 0) || |
| 17 | (strncmp(line, "SCRATCH::", 9) == 0) || |
| 18 | (strncmp(line, "GET_TOS::", 9) == 0)) { |
| 19 | char *stopCh; |
| 20 | uint16 resId = (uint16)strtoul(line + 9, &stopCh, 16); |
| 21 | if ((stopCh[0] == ':') && (stopCh[1] == ':') && (strcmp(stopCh + 2, name) == 0)) { |
| 22 | delete kmp; |
| 23 | return resId; |
| 24 | } |
| 25 | } |
| 26 | cLine++; |
| 27 | } |
| 28 | } while (cLine != -1); |
| 29 | delete kmp; |
| 30 | return 0; |
| 31 | } |