Commit 5dfaa593 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

intree/installed specfile treatment for parkinglot

added strerror() to CCSession if the spec file could not be opened


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@679 e5f2f494-b856-4b98-b285-d166d9295462
parent 2ac134c6
......@@ -3,7 +3,7 @@ pkglibexecdir = $(libexecdir)/@PACKAGE@
pkglibexec_SCRIPTS = b10-cmdctl
b10_cmdctldir = $(DESTDIR)$(pkgdatadir)
b10_cmdctl_DATA = passwd.csv
b10_cmdctl_DATA = passwd.csv b10-cmdctl.pem
CLEANFILES= b10-cmdctl.py
......
......@@ -13,6 +13,9 @@ b10_parkinglot_LDADD = $(top_builddir)/src/lib/dns/cpp/.libs/libdns.a
b10_parkinglot_LDADD += $(top_builddir)/src/lib/config/cpp/libclient.a
b10_parkinglot_LDADD += $(top_builddir)/src/lib/cc/cpp/libcc.a
b10_parkinglotdir = $(DESTDIR)$(pkgsrcdir)
b10_parkinglot_DATA = parkinglot.spec
# TODO: don't install this here
bin_PROGRAMS = builtin_bench
builtin_bench_SOURCES = builtin_bench.cc builtin.h builtin.cc
......
#define PARKINGLOT_SPECFILE_LOCATION "@abs_top_srcdir@/src/bin/parkinglot/parkinglot.spec"
#define PARKINGLOT_SPECFILE_LOCATION "@prefix@/share/bind/parkinglot.spec"
......@@ -45,7 +45,7 @@
using namespace std;
const string PROGRAM = "ParkingLot";
//const string PROGRAM = "ParkingLot";
const int DNSPORT = 5300;
/* need global var for config/command handlers.
......@@ -70,14 +70,11 @@ my_command_handler(isc::data::ElementPtr command)
{
isc::data::ElementPtr answer = isc::data::Element::createFromString("{ \"result\": [0] }");
cout << "[XX] Parkinglot handle command: " << endl << command->str() << endl;
if (command->get(0)->stringValue() == "print_message")
{
cout << command->get(1)->get("message") << endl;
/* let's add that message to our answer as well */
cout << "[XX] answer was: " << answer->str() << endl;
answer->get("result")->add(command->get(1));
cout << "[XX] answer now: " << answer->str() << endl;
}
return answer;
......@@ -107,7 +104,13 @@ main(int argc, char* argv[]) {
// initialize command channel
try {
CommandSession cs = CommandSession(PARKINGLOT_SPECFILE_LOCATION, my_config_handler, my_command_handler);
std::string specfile;
if (getenv("B10_FROM_SOURCE")) {
specfile = std::string(getenv("B10_FROM_SOURCE")) + "/src/bin/parkinglot/parkinglot.spec";
} else {
specfile = std::string(PARKINGLOT_SPECFILE_LOCATION);
}
CommandSession cs = CommandSession(specfile, my_config_handler, my_command_handler);
// main server loop
fd_set fds;
......@@ -116,7 +119,7 @@ main(int argc, char* argv[]) {
int nfds = max(ps, ss) + 1;
int counter = 0;
cout << "Server started." << endl;
cout << "[parkinglot] Server started." << endl;
while (true) {
FD_ZERO(&fds);
FD_SET(ps, &fds);
......@@ -124,7 +127,7 @@ main(int argc, char* argv[]) {
int n = select(nfds, &fds, NULL, NULL, NULL);
if (n < 0)
throw FatalError("select error");
throw FatalError("[parkinglot] select error");
if (FD_ISSET(ps, &fds)) {
++counter;
......
......@@ -29,6 +29,7 @@
#include <iostream>
#include <fstream>
#include <sstream>
#include <cerrno>
#include <boost/foreach.hpp>
......@@ -55,7 +56,7 @@ CommandSession::read_data_definition(const std::string& filename) {
// this file should be declared in a @something@ directive
file.open(filename.c_str());
if (!file) {
cout << "error opening " << filename << endl;
cout << "error opening " << filename << ": " << strerror(errno) << endl;
exit(1);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment