|
rllib
1
|
00001 /*************************************************************************** 00002 rlinterpreter.cpp - description 00003 ------------------- 00004 begin : Tue Jan 02 2001 00005 copyright : (C) 2001 by Rainer Lehrig 00006 email : lehrig@t-online.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This library is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as * 00013 * published by the Free Software Foundation * 00014 * * 00015 ***************************************************************************/ 00016 #include <stdlib.h> 00017 #include "rlinterpreter.h" 00018 00019 rlInterpreter::rlInterpreter(int Maxline) 00020 { 00021 line = NULL; 00022 maxline = Maxline; 00023 if(maxline <= 0) return; 00024 line = new char[maxline]; 00025 } 00026 00027 rlInterpreter::~rlInterpreter() 00028 { 00029 //if(line != NULL) delete [] line; 00030 } 00031 00032 int rlInterpreter::isCommand(const char *command) 00033 { 00034 int i = 0; 00035 while(command[i] != '\0') 00036 { 00037 if(command[i] != line[i]) return 0; 00038 i++; 00039 } 00040 return 1; 00041 } 00042 00043 void rlInterpreter::copyStringParam(char *destination, int index) 00044 { 00045 int iparen = 0; 00046 int i = 0; 00047 int ndest; 00048 *destination = '\0'; 00049 // find " number index*2 00050 while(line[i] != '\0') 00051 { 00052 if(line[i] == '\"' && (i > 0 || line[i-1] != '\\')) iparen++; 00053 if(iparen == (2*index + 1)) 00054 { 00055 ndest = 0; 00056 i++; 00057 while(line[i] != '\0' && (line[i] != '\"' && line[i-1] != '\\')) 00058 { 00059 if(ndest >= maxline-1) 00060 { 00061 *destination = '\0'; 00062 return; 00063 } 00064 *destination++ = line[i++]; 00065 ndest++; 00066 } 00067 *destination = '\0'; 00068 return; 00069 } 00070 i++; 00071 } 00072 } 00073 00074 int rlInterpreter::maxchar() 00075 { 00076 return maxline-1; 00077 } 00078
1.7.5.1