summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-20 09:23:57 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-20 09:23:57 +0000
commit4f78f5157f2a1db67628a922b0320f3162c12d87 (patch)
tree0d9340507c4185726bfa712357ba6a3271c25e03 /src
parent140bafe54469d7d7f97ffd77d44ce105ae2c6c52 (diff)
ConfigReader fixes to cope with tab characters (why didnt we notice this before?)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@680 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/InspIRCd.layout60
-rw-r--r--src/inspircd_io.cpp24
-rw-r--r--src/modules.cpp10
3 files changed, 52 insertions, 42 deletions
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout
index a79e0cd51..2085a6495 100644
--- a/src/InspIRCd.layout
+++ b/src/InspIRCd.layout
@@ -1,6 +1,6 @@
[Editors]
Focused=-1
-Order=1,2,4,6,3,7,25,5,24,-1,39,42,43
+Order=1,2,4,6,3,7,25,5,24,39,42,43,-1
[Editor_0]
Open=0
@@ -21,9 +21,9 @@ LeftChar=1
[Editor_2]
Open=1
Top=0
-CursorCol=8
-CursorRow=278
-TopLine=1
+CursorCol=4
+CursorRow=358
+TopLine=331
LeftChar=1
[Editor_3]
@@ -31,15 +31,15 @@ Open=1
Top=0
CursorCol=3
CursorRow=81
-TopLine=28
+TopLine=19
LeftChar=1
[Editor_4]
Open=1
Top=0
-CursorCol=18
-CursorRow=15
-TopLine=1
+CursorCol=9
+CursorRow=358
+TopLine=333
LeftChar=1
[Editor_5]
@@ -75,7 +75,7 @@ TopLine=1
LeftChar=1
[Editor_9]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=113
@@ -99,7 +99,7 @@ TopLine=1
LeftChar=1
[Editor_12]
-Open=1
+Open=0
Top=0
CursorCol=12
CursorRow=104
@@ -107,7 +107,7 @@ TopLine=1
LeftChar=1
[Editor_13]
-Open=1
+Open=0
Top=0
CursorCol=51
CursorRow=125
@@ -115,7 +115,7 @@ TopLine=34
LeftChar=1
[Editor_14]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=23
@@ -123,7 +123,7 @@ TopLine=1
LeftChar=1
[Editor_15]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=81
@@ -131,7 +131,7 @@ TopLine=41
LeftChar=1
[Editor_16]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=29
@@ -139,7 +139,7 @@ TopLine=1
LeftChar=1
[Editor_17]
-Open=1
+Open=0
Top=0
CursorCol=21
CursorRow=38
@@ -147,7 +147,7 @@ TopLine=1
LeftChar=1
[Editor_18]
-Open=1
+Open=0
Top=0
CursorCol=69
CursorRow=31
@@ -163,7 +163,7 @@ TopLine=1
LeftChar=1
[Editor_20]
-Open=1
+Open=0
Top=0
CursorCol=32
CursorRow=30
@@ -171,7 +171,7 @@ TopLine=573
LeftChar=1
[Editor_21]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=63
@@ -187,7 +187,7 @@ TopLine=83
LeftChar=1
[Editor_23]
-Open=1
+Open=0
Top=0
CursorCol=1
CursorRow=1
@@ -216,7 +216,7 @@ CursorRow=13
TopLine=23
LeftChar=1
[Editor_27]
-Open=1
+Open=0
Top=0
CursorCol=3
CursorRow=67
@@ -237,12 +237,12 @@ CursorRow=21
TopLine=1
LeftChar=1
[Editor_30]
-Open=0
+Open=1
Top=0
-CursorCol=87
-CursorRow=21
+CursorCol=1
+CursorRow=34
TopLine=1
-LeftChar=4
+LeftChar=1
[Editor_31]
Open=0
Top=0
@@ -288,9 +288,9 @@ LeftChar=1
[Editor_37]
Open=1
Top=1
-CursorCol=13
-CursorRow=22
-TopLine=1
+CursorCol=37
+CursorRow=150
+TopLine=119
LeftChar=1
[Editor_38]
Open=0
@@ -307,14 +307,14 @@ CursorRow=37
TopLine=103
LeftChar=1
[Editor_40]
-Open=1
+Open=0
Top=0
CursorCol=14
CursorRow=10
TopLine=1
LeftChar=1
[Editor_41]
-Open=1
+Open=0
Top=0
CursorCol=22
CursorRow=13
@@ -335,7 +335,7 @@ CursorRow=1095
TopLine=1115
LeftChar=1
[Editor_44]
-Open=1
+Open=0
Top=0
CursorCol=89
CursorRow=89
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index c69ba3b17..b9e7fa40b 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -324,30 +324,28 @@ int ConfValueEnum(char* tag, std::stringstream* config)
int ReadConf(std::stringstream *config, const char* tag, const char* var, int index, char *result)
{
int ptr = 0;
- char buffer[MAXBUF], c_tag[MAXBUF], c, lastc;
+ char buffer[65535], c_tag[MAXBUF], c, lastc;
int in_token, in_quotes, tptr, j, idx = 0;
char* key;
const char* buf = config->str().c_str();
long bptr = 0;
long len = strlen(buf);
+ log(DEBUG,"Data length: %d",len);
ptr = 0;
in_token = 0;
in_quotes = 0;
lastc = '\0';
+ c_tag[0] = '\0';
+ buffer[0] = '\0';
while (bptr<len)
{
lastc = c;
c = buf[bptr++];
- if ((c == '#') && (lastc == '\n'))
- {
- while ((c != '\n') && (bptr<len))
- {
- lastc = c;
- c = buf[bptr++];
- }
- }
+ // FIX: Treat tabs as spaces
+ if (c == 9)
+ c = 32;
if ((c == '<') && (!in_quotes))
{
tptr = 0;
@@ -359,7 +357,8 @@ int ReadConf(std::stringstream *config, const char* tag, const char* var, int in
c_tag[tptr++] = c;
c_tag[tptr] = '\0';
}
- } while (c != ' ');
+ // FIX: Tab can follow a tagname as well as space.
+ } while ((c != ' ') && (c != 9));
}
if (c == '"')
{
@@ -379,6 +378,7 @@ int ReadConf(std::stringstream *config, const char* tag, const char* var, int in
{
/* value not found in tag */
strcpy(result,"");
+ log(DEBUG,"ReadConf: value '%s' was not found in tag",var);
return 0;
}
else
@@ -390,6 +390,7 @@ int ReadConf(std::stringstream *config, const char* tag, const char* var, int in
{
/* missing quote */
strcpy(result,"");
+ log(DEBUG,"ReadConf: possible missing quote!");
return 0;
}
key++;
@@ -403,6 +404,7 @@ int ReadConf(std::stringstream *config, const char* tag, const char* var, int in
}
}
strcpy(result,key);
+ log(DEBUG,"ReadConf: Got value '%s'",result);
return 1;
}
}
@@ -410,6 +412,7 @@ int ReadConf(std::stringstream *config, const char* tag, const char* var, int in
}
if (!strcmp(c_tag,tag))
{
+ log(DEBUG,"Tag name correct but index value incorrect");
/* correct tag, but wrong index */
idx++;
}
@@ -427,6 +430,7 @@ int ReadConf(std::stringstream *config, const char* tag, const char* var, int in
}
}
}
+ log(DEBUG,"ReadConf: neither value '%s' or tag '%s' were found at all!",var,tag);
strcpy(result,""); // value or its tag not found at all
return 0;
}
diff --git a/src/modules.cpp b/src/modules.cpp
index c042a8fed..ca3c2e423 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -355,9 +355,15 @@ ConfigReader::ConfigReader(std::string filename)
std::string ConfigReader::ReadValue(std::string tag, std::string name, int index)
{
+ log(DEBUG,"ConfigReader::ReadValue '%s' '%s' %d",tag.c_str(),name.c_str(),index);
char val[MAXBUF];
- ReadConf(cache,tag.c_str(),name.c_str(),index,val);
- return val;
+ char t[MAXBUF];
+ char n[MAXBUF];
+ strncpy(t,tag.c_str(),MAXBUF);
+ strncpy(n,name.c_str(),MAXBUF);
+ ReadConf(cache,t,n,index,val);
+ log(DEBUG,"ConfigReader::ReadValue read '%s'",val);
+ return std::string(val);
}