summaryrefslogtreecommitdiff
path: root/server/src/macrotool_fieldnames.cc
diff options
context:
space:
mode:
authordeva <deva>2009-07-17 13:02:45 +0000
committerdeva <deva>2009-07-17 13:02:45 +0000
commit177cea995d02fd14dd82fa010957ebfbc1c5e760 (patch)
tree62703ddc11b83a054e8068c0e9c79ce1951959a6 /server/src/macrotool_fieldnames.cc
parenta619ccc300a00947207600e11fac848b7d37b26b (diff)
More work on the macrotool. Now fieldnames can be added and deleted, and a filehandler is able to add new macros assuring no conflicts in macro names/version/filenames happen. Error messages in MacroParser has been made more elaborate.
Diffstat (limited to 'server/src/macrotool_fieldnames.cc')
-rw-r--r--server/src/macrotool_fieldnames.cc30
1 files changed, 22 insertions, 8 deletions
diff --git a/server/src/macrotool_fieldnames.cc b/server/src/macrotool_fieldnames.cc
index eeed648..3c3f8b7 100644
--- a/server/src/macrotool_fieldnames.cc
+++ b/server/src/macrotool_fieldnames.cc
@@ -37,17 +37,21 @@
static const char usage_str[] =
" help Prints this helptext.\n"
-" set name desc Add a field (or update) called 'name', described as 'desc'\n"
+" add name desc Add a field called 'name', described as 'desc'\n"
+" del name Delete a field called 'name'\n"
+" list List all fieldnames as well as their macro references.\n"
;
static void add(std::string name, std::string desc)
{
-#ifndef WITHOUT_DB
- PRACRO_DEBUG("SET (name: %s - desc: %s)\n", name.c_str(), desc.c_str());
-#else /*WITHOUT_DB*/
- printf("Project not compiled with db spport.")
-#endif/*WITHOUT_DB*/
+ Database db("pgsql", Conf::database_addr, "", Conf::database_user, Conf::database_passwd, "");
+ db.addFieldname(name, desc);
+}
+static void del(std::string name)
+{
+ Database db("pgsql", Conf::database_addr, "", Conf::database_user, Conf::database_passwd, "");
+ db.delFieldname(name);
}
static std::vector<std::string> getWidgetNames(Widget &w)
@@ -170,9 +174,9 @@ void macrotool_fieldnames(std::vector<std::string> params)
return;
}
- if(params[0] == "set") {
+ if(params[0] == "add") {
if(params.size() != 3) {
- printf("The command 'set' needs 2 parameters.\n");
+ printf("The command 'add' needs 2 parameters.\n");
printf(usage_str);
return;
}
@@ -180,6 +184,16 @@ void macrotool_fieldnames(std::vector<std::string> params)
return;
}
+ if(params[0] == "del") {
+ if(params.size() != 2) {
+ printf("The command 'del' needs 1 parameter.\n");
+ printf(usage_str);
+ return;
+ }
+ del(params[1]);
+ return;
+ }
+
if(params[0] == "help") {
printf(usage_str);
return;