rllib  1
rlinterpreter.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  rlinterpreter.cpp - description
3  -------------------
4  begin : Tue Jan 02 2001
5  copyright : (C) 2001 by R. Lehrig
6  email : lehrig@t-online.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as *
13  * published by the Free Software Foundation *
14  * *
15  ***************************************************************************/
16 #include <stdlib.h>
17 #include "rlinterpreter.h"
18 
20 {
21  line = NULL;
22  maxline = Maxline;
23  if(maxline <= 0) return;
24  line = new char[maxline];
25 }
26 
28 {
29  //if(line != NULL) delete [] line;
30 }
31 
32 int rlInterpreter::isCommand(const char *command)
33 {
34  int i = 0;
35  while(command[i] != '\0')
36  {
37  if(command[i] != line[i]) return 0;
38  i++;
39  }
40  return 1;
41 }
42 
43 void rlInterpreter::copyStringParam(char *destination, int index)
44 {
45  int iparen = 0;
46  int i = 0;
47  int ndest;
48  *destination = '\0';
49  // find " number index*2
50  while(line[i] != '\0')
51  {
52  if(line[i] == '\"' && (i > 0 || line[i-1] != '\\')) iparen++;
53  if(iparen == (2*index + 1))
54  {
55  ndest = 0;
56  i++;
57  while(line[i] != '\0' && (line[i] != '\"' && line[i-1] != '\\'))
58  {
59  if(ndest >= maxline-1)
60  {
61  *destination = '\0';
62  return;
63  }
64  *destination++ = line[i++];
65  ndest++;
66  }
67  *destination = '\0';
68  return;
69  }
70  i++;
71  }
72 }
73 
75 {
76  return maxline-1;
77 }
78 
rlInterpreter(int Maxline=rl_PRINTF_LENGTH)
virtual ~rlInterpreter()
int isCommand(const char *command)
void copyStringParam(char *destination, int index)