/* ScummVM - Scumm Interpreter * Copyright (C) 2006 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * $URL$ * $Id$ * */ #include "parallaction/defs.h" #include "parallaction/parser.h" #include "parallaction/parallaction.h" #include "parallaction/disk.h" namespace Parallaction { char _tokens[20][40]; Script::Script(const char* s, bool disposeSource) : _src(s), _disposeSource(disposeSource) { _pos = const_cast(_src); } Script::~Script() { if (_disposeSource) free(const_cast(_src)); } char *Script::readLine(char *buf, size_t bufSize) { uint16 _si; char v2 = 0; for ( _si = 0; _si 0 && i < 20) { line = parseNextToken(line, _tokens[i], 40, " \t\n"); if (_tokens[i][0] == '"' && _tokens[i][strlen(_tokens[i]) - 1] != '"') { line = parseNextToken(line, _tokens[i+1], 40, "\""); strcat(_tokens[i], _tokens[i+1]); _tokens[i][0] = ' '; line++; } line = Common::ltrim(line); i++; } return i; } uint16 fillBuffers(Common::SeekableReadStream &stream, bool errorOnEOF) { clearTokens(); char buf[200]; char *line = NULL; do { line = stream.readLine(buf, 200); if (line == NULL) { if (errorOnEOF) error("unexpected end of file while parsing"); else return 0; } line = Common::ltrim(line); } while (strlen(line) == 0 || line[0] == '#'); return fillTokens(line); } } // namespace Parallaction