summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/Bindings.cpp39
-rw-r--r--source/Bindings.h2
-rw-r--r--source/cWebAdmin.cpp8
-rw-r--r--source/cWebPlugin_Lua.cpp41
-rw-r--r--source/cWebPlugin_Lua.h4
5 files changed, 75 insertions, 19 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 45008bb32..c8bcc8123 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 01/31/12 19:40:39.
+** Generated automatically by tolua++-1.0.92 on 02/01/12 00:50:40.
*/
#ifndef __cplusplus
@@ -1707,6 +1707,42 @@ static int tolua_AllToLua_cIniFile_SetValueF00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: DeleteValueByID of class cIniFile */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteValueByID00
+static int tolua_AllToLua_cIniFile_DeleteValueByID00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cIniFile",0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnumber(tolua_S,3,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,4,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cIniFile* self = (cIniFile*) tolua_tousertype(tolua_S,1,0);
+ const unsigned keyID = ((const unsigned) tolua_tonumber(tolua_S,2,0));
+ const unsigned valueID = ((const unsigned) tolua_tonumber(tolua_S,3,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'DeleteValueByID'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->DeleteValueByID(keyID,valueID);
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'DeleteValueByID'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: DeleteValue of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_DeleteValue00
static int tolua_AllToLua_cIniFile_DeleteValue00(lua_State* tolua_S)
@@ -16278,6 +16314,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetValueI",tolua_AllToLua_cIniFile_SetValueI00);
tolua_function(tolua_S,"SetValueB",tolua_AllToLua_cIniFile_SetValueB00);
tolua_function(tolua_S,"SetValueF",tolua_AllToLua_cIniFile_SetValueF00);
+ tolua_function(tolua_S,"DeleteValueByID",tolua_AllToLua_cIniFile_DeleteValueByID00);
tolua_function(tolua_S,"DeleteValue",tolua_AllToLua_cIniFile_DeleteValue00);
tolua_function(tolua_S,"DeleteKey",tolua_AllToLua_cIniFile_DeleteKey00);
tolua_function(tolua_S,"NumHeaderComments",tolua_AllToLua_cIniFile_NumHeaderComments00);
diff --git a/source/Bindings.h b/source/Bindings.h
index 061f9231e..427b7595b 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 01/31/12 19:40:39.
+** Generated automatically by tolua++-1.0.92 on 02/01/12 00:50:40.
*/
/* Exported function */
diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp
index b99b8e779..901e24cd7 100644
--- a/source/cWebAdmin.cpp
+++ b/source/cWebAdmin.cpp
@@ -121,10 +121,10 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
cWebPlugin_Lua* LuaPlugin = dynamic_cast< cWebPlugin_Lua* >( WebPlugin );
if( LuaPlugin )
{
- std::list< std::string > NameList = LuaPlugin->GetTabNames();
- for( std::list< std::string >::iterator Name = NameList.begin(); Name != NameList.end(); ++Name )
+ std::list< std::pair<std::string, std::string> > NameList = LuaPlugin->GetTabNames();
+ for( std::list< std::pair<std::string, std::string> >::iterator Names = NameList.begin(); Names != NameList.end(); ++Names )
{
- Menu += "<li><a href='" + BaseURL + WebPlugin->GetName() + "/" + (*Name) + "'>" + (*Name) + "</a></li>";
+ Menu += "<li><a href='" + BaseURL + WebPlugin->GetName() + "/" + (*Names).second + "'>" + (*Names).first + "</a></li>";
}
}
else
@@ -164,7 +164,7 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
cWebPlugin_Lua* LuaPlugin = dynamic_cast< cWebPlugin_Lua* >( WebPlugin );
if( LuaPlugin )
{
- FoundPlugin += " - " + LuaPlugin->GetTabNameForRequest( &Request );
+ FoundPlugin += " - " + LuaPlugin->GetTabNameForRequest( &Request ).first;
}
break;
}
diff --git a/source/cWebPlugin_Lua.cpp b/source/cWebPlugin_Lua.cpp
index d1446ba24..bb3f79226 100644
--- a/source/cWebPlugin_Lua.cpp
+++ b/source/cWebPlugin_Lua.cpp
@@ -8,7 +8,20 @@
#include "cWebAdmin.h"
-
+static std::string SafeString( const std::string& a_String )
+{
+ std::string RetVal;
+ for( unsigned int i = 0; i < a_String.size(); ++i )
+ {
+ char c = a_String[i];
+ if( c == ' ' )
+ {
+ c = '_';
+ }
+ RetVal.push_back( c );
+ }
+ return RetVal;
+}
extern bool report_errors(lua_State* lua, int status);
@@ -47,7 +60,7 @@ bool cWebPlugin_Lua::AddTab( const char* a_Title, lua_State * a_LuaState, int a_
}
sWebPluginTab* Tab = new sWebPluginTab();
Tab->Title = a_Title;
- Tab->SafeTitle = a_Title; // TODO - Convert all non alphabet/digit letters to underscores
+ Tab->SafeTitle = SafeString( a_Title );
Tab->Reference = a_FunctionReference;
@@ -60,14 +73,15 @@ std::string cWebPlugin_Lua::HandleRequest( HTTPRequest* a_Request )
lua_State* LuaState = m_Plugin->GetLuaState();
std::string RetVal = "";
- std::string TabName = GetTabNameForRequest(a_Request);
- if( TabName.empty() )
+ std::pair< std::string, std::string > TabName = GetTabNameForRequest(a_Request);
+ std::string SafeTabName = TabName.second;
+ if( SafeTabName.empty() )
return "";
sWebPluginTab* Tab = 0;
for( TabList::iterator itr = m_Tabs.begin(); itr != m_Tabs.end(); ++itr )
{
- if( (*itr)->Title.compare( TabName ) == 0 ) // This is the one! Rawr
+ if( (*itr)->SafeTitle.compare( SafeTabName ) == 0 ) // This is the one! Rawr
{
Tab = *itr;
break;
@@ -113,8 +127,9 @@ void cWebPlugin_Lua::Initialize()
{
}
-std::string cWebPlugin_Lua::GetTabNameForRequest( HTTPRequest* a_Request )
+std::pair< std::string, std::string > cWebPlugin_Lua::GetTabNameForRequest( HTTPRequest* a_Request )
{
+ std::pair< std::string, std::string > Names;
std::vector<std::string> Split = StringSplit( a_Request->Path, "/" );
if( Split.size() > 1 )
@@ -139,19 +154,23 @@ std::string cWebPlugin_Lua::GetTabNameForRequest( HTTPRequest* a_Request )
if( Tab )
{
- return Tab->Title;
+ Names.first = Tab->Title;
+ Names.second = Tab->SafeTitle;
}
}
- return "";
+ return Names;
}
-std::list< std::string > cWebPlugin_Lua::GetTabNames()
+std::list< std::pair<std::string, std::string> > cWebPlugin_Lua::GetTabNames()
{
- std::list< std::string > NameList;
+ std::list< std::pair< std::string, std::string > > NameList;
for( TabList::iterator itr = m_Tabs.begin(); itr != m_Tabs.end(); ++itr )
{
- NameList.push_back( (*itr)->Title );
+ std::pair< std::string, std::string > StringPair;
+ StringPair.first = (*itr)->Title;
+ StringPair.second = (*itr)->SafeTitle;
+ NameList.push_back( StringPair );
}
return NameList;
} \ No newline at end of file
diff --git a/source/cWebPlugin_Lua.h b/source/cWebPlugin_Lua.h
index 98080e855..0444fb44f 100644
--- a/source/cWebPlugin_Lua.h
+++ b/source/cWebPlugin_Lua.h
@@ -17,9 +17,9 @@ public: //tolua_export
virtual std::string HandleRequest( HTTPRequest* a_Request );
virtual void Initialize();
- std::string GetTabNameForRequest( HTTPRequest* a_Request );
+ std::pair< std::string, std::string > GetTabNameForRequest( HTTPRequest* a_Request );
- std::list< std::string > GetTabNames();
+ std::list< std::pair<std::string, std::string> > GetTabNames();
private:
cPlugin_NewLua* m_Plugin;