Skip to content

Commit

Permalink
Rudimentäre Regelverwaltung funktioniert
Browse files Browse the repository at this point in the history
  • Loading branch information
drolbr committed Jan 23, 2009
1 parent b07cd7b commit a92a151
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ report_$(suffix) \
detect_odd_nodes_$(suffix)

objects = expat_justparse_interface.o cgi-helper.o user_interface.o script_queries.o script_tools.o vigilance_control.o $(stmts)
executables_objects = script-interpreter.o add_rule.o update_rule.o osm2load_infile.o
executables = cgi-bin/interpreter cgi-bin/add_rule cgi-bin/update_rule import_osm osmy_vigilance
executables_objects = script-interpreter.o add_rule.o get_rule.o update_rule.o osm2load_infile.o
executables = cgi-bin/interpreter cgi-bin/add_rule cgi-bin/get_rule cgi-bin/update_rule import_osm osmy_vigilance
tool_headers = expat_justparse_interface.h script_datatypes.h script_queries.h script_tools.h user_interface.h

main: $(executables)
Expand All @@ -29,6 +29,11 @@ cgi-bin/add_rule: suffix = statement.o
cgi-bin/add_rule: $(objects) add_rule.o
g++ -o cgi-bin/add_rule -O3 -Wall -lexpat $(objects) add_rule.o `mysql_config --libs`

suffix = statement.o
cgi-bin/get_rule: suffix = statement.o
cgi-bin/get_rule: $(objects) get_rule.o
g++ -o cgi-bin/get_rule -O3 -Wall -lexpat $(objects) get_rule.o `mysql_config --libs`

suffix = statement.o
cgi-bin/update_rule: suffix = statement.o
cgi-bin/update_rule: $(objects) update_rule.o
Expand Down Expand Up @@ -69,6 +74,10 @@ suffix = statement.h
add_rule.o: add_rule.c expat_justparse_interface.h user_interface.h script_datatypes.h script_queries.h script_tools.h $(stmts) statement_factory.h
g++ -c -O3 -Wall `mysql_config --include` add_rule.c

suffix = statement.h
get_rule.o: get_rule.c expat_justparse_interface.h user_interface.h script_datatypes.h script_queries.h script_tools.h $(stmts) statement_factory.h
g++ -c -O3 -Wall `mysql_config --include` get_rule.c

suffix = statement.h
update_rule.o: update_rule.c expat_justparse_interface.h user_interface.h script_datatypes.h script_queries.h script_tools.h $(stmts) statement_factory.h
g++ -c -O3 -Wall `mysql_config --include` update_rule.c
Expand Down
5 changes: 4 additions & 1 deletion add_rule.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ int main(int argc, char *argv[])
return 0;
// getting special information for rules
string rule_name("");
int rule_replace(0);
int rule_replace(0), rule_version(0);
Root_Statement* root_statement(dynamic_cast< Root_Statement* >(statement_stack.front()));
if (root_statement)
{
rule_name = root_statement->get_rule_name();
rule_replace = root_statement->get_rule_replace();
rule_version = root_statement->get_rule_version();
}
if (rule_name == "")
add_static_error("Adding a rule requires the name of the rule.");
if (rule_replace)
add_static_error("Providing which version to replace while adding a rule is not allowed.");
if (rule_version)
add_static_error("Providing a version-id while adding a rule is not allowed.");

xml_raw = xml_raw.substr(xml_raw.find("<osm-script"));
Expand Down
21 changes: 14 additions & 7 deletions html/testseite.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@
<h1>Eingabe f&uuml;r Interpreter</h1>

<form action="cgi-bin/interpreter" method="post" accept-charset="UTF-8">
<textarea name="data" rows="25" cols="80"></textarea>
<textarea name="data" rows="10" cols="80"></textarea>
<input type="submit">
</form>

<h1>Eingabe f&uuml;r "Update Rule"</h1>
<h1>Eingabe f&uuml;r "Add Rule"</h1>

<form action="cgi-bin/update_rule" method="post" accept-charset="UTF-8">
<textarea name="data" rows="25" cols="80"></textarea>
<form action="cgi-bin/add_rule" method="post" accept-charset="UTF-8">
<textarea name="data" rows="10" cols="80"></textarea>
<input type="submit">
</form>

<h1>Eingabe f&uuml;r "Add Rule"</h1>
<h1>Eingabe f&uuml;r "Get Rule"</h1>

<form action="cgi-bin/add_rule" method="post" accept-charset="UTF-8">
<textarea name="data" rows="25" cols="80"></textarea>
<form action="cgi-bin/get_rule" method="post" accept-charset="UTF-8">
<textarea name="data" rows="2" cols="80"></textarea>
<input type="submit">
</form>

<h1>Eingabe f&uuml;r "Update Rule"</h1>

<form action="cgi-bin/update_rule" method="post" accept-charset="UTF-8">
<textarea name="data" rows="10" cols="80"></textarea>
<input type="submit">
</form>

Expand Down
2 changes: 2 additions & 0 deletions script_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ void Root_Statement::set_attributes(const char **attr)
attributes["timeout"] = "0";
attributes["name"] = "";
attributes["replace"] = "0";
attributes["version"] = "0";

eval_cstr_array(get_name(), attributes, attr);

name = attributes["name"];
replace = atoi(attributes["replace"].c_str());
timeout = atoi(attributes["timeout"].c_str());
version = atoi(attributes["version"].c_str());
}

void Root_Statement::add_statement(Statement* statement, string text)
Expand Down
3 changes: 2 additions & 1 deletion script_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ class Root_Statement : public Statement

string get_rule_name() { return name; }
int get_rule_replace() { return replace; }
int get_rule_version() { return version; }

private:
vector< Statement* > substatements;
int timeout;
string name;
int replace;
int replace, version;
};

#endif
5 changes: 4 additions & 1 deletion update_rule.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,20 @@ int main(int argc, char *argv[])
return 0;
// getting special information for rules
string rule_name("");
int rule_replace(0);
int rule_replace(0), rule_version(0);
Root_Statement* root_statement(dynamic_cast< Root_Statement* >(statement_stack.front()));
if (root_statement)
{
rule_name = root_statement->get_rule_name();
rule_replace = root_statement->get_rule_replace();
rule_version = root_statement->get_rule_version();
}
if (rule_name == "")
add_static_error("Updating a rule requires the name of the rule.");
if (!rule_replace)
add_static_error("Updating a rule requires providing its last version-id.");
if (rule_version)
add_static_error("Providing a version-id while updating a rule is not allowed.");

xml_raw = xml_raw.substr(xml_raw.find("<osm-script"));
xml_raw = xml_raw.substr(xml_raw.find('>') + 1);
Expand Down

0 comments on commit a92a151

Please sign in to comment.