summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IcePack/.depend11
-rw-r--r--cpp/src/IcePack/AdminI.cpp2
-rw-r--r--cpp/src/IcePack/AdminI.h4
-rw-r--r--cpp/src/IcePack/Client.cpp220
-rw-r--r--cpp/src/IcePack/Forward.cpp2
-rw-r--r--cpp/src/IcePack/Forward.h4
-rw-r--r--cpp/src/IcePack/Grammer.y98
-rw-r--r--cpp/src/IcePack/Makefile22
-rw-r--r--cpp/src/IcePack/Parser.cpp240
-rw-r--r--cpp/src/IcePack/Parser.h88
-rw-r--r--cpp/src/IcePack/Scanner.l260
-rw-r--r--cpp/src/IcePack/Server.cpp62
-rw-r--r--cpp/src/Slice/GrammerUtil.h4
-rw-r--r--cpp/src/Slice/Makefile2
14 files changed, 895 insertions, 124 deletions
diff --git a/cpp/src/IcePack/.depend b/cpp/src/IcePack/.depend
index be209f9bb99..5d6fa0ce74a 100644
--- a/cpp/src/IcePack/.depend
+++ b/cpp/src/IcePack/.depend
@@ -1,5 +1,8 @@
Admin.o: Admin.cpp ../../include/IcePack/Admin.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Shared.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/LocalObject.h ../../include/Ice/LocalException.h
-Client.o: Client.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h Forward.h
-Server.o: Server.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h Forward.h
-Forward.o: Forward.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h Forward.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h
-AdminI.o: AdminI.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h
+Grammer.o: Grammer.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Parser.h
+Scanner.o: Scanner.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Parser.h ../IcePack/Grammer.h
+Parser.o: Parser.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Parser.h
+Client.o: Client.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../IcePack/Forward.h ../IcePack/Parser.h
+Server.o: Server.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h ../IcePack/Forward.h
+Forward.o: Forward.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/Forward.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h
+AdminI.o: AdminI.cpp ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ValueFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ValueFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../IcePack/AdminI.h ../../include/IcePack/Admin.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../../include/Ice/Object.h ../../include/Ice/Outgoing.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h ../../include/Ice/Incoming.h
diff --git a/cpp/src/IcePack/AdminI.cpp b/cpp/src/IcePack/AdminI.cpp
index 9315d441c70..6829d012152 100644
--- a/cpp/src/IcePack/AdminI.cpp
+++ b/cpp/src/IcePack/AdminI.cpp
@@ -9,7 +9,7 @@
// **********************************************************************
#include <Ice/Ice.h>
-#include <AdminI.h>
+#include <IcePack/AdminI.h>
using namespace std;
using namespace Ice;
diff --git a/cpp/src/IcePack/AdminI.h b/cpp/src/IcePack/AdminI.h
index 3d6586c7d07..8541f1a2f63 100644
--- a/cpp/src/IcePack/AdminI.h
+++ b/cpp/src/IcePack/AdminI.h
@@ -8,8 +8,8 @@
//
// **********************************************************************
-#ifndef ADMIN_I_H
-#define ADMIN_I_H
+#ifndef ICE_PACK_ADMIN_I_H
+#define ICE_PACK_ADMIN_I_H
#include <IcePack/Admin.h>
#include <map>
diff --git a/cpp/src/IcePack/Client.cpp b/cpp/src/IcePack/Client.cpp
index 3f9ae3b08d4..4f27f3ad5cc 100644
--- a/cpp/src/IcePack/Client.cpp
+++ b/cpp/src/IcePack/Client.cpp
@@ -9,8 +9,8 @@
// **********************************************************************
#include <Ice/Ice.h>
-#include <AdminI.h>
-#include <Forward.h>
+#include <IcePack/Parser.h>
+#include <fstream>
using namespace std;
using namespace Ice;
@@ -19,35 +19,116 @@ using namespace IcePack;
void
usage(const char* n)
{
- cerr << "Usage: " << n << " [options] add reference...|remove reference...|shutdown\n";
+ cerr << "Usage: " << n << " [options] [file...]\n";
cerr <<
"Options:\n"
"-h, --help Show this message.\n"
"-v, --version Display the Ice version.\n"
+ "-DNAME Define NAME as 1.\n"
+ "-DNAME=DEF Define NAME as DEF.\n"
+ "-UNAME Remove any definition for NAME.\n"
+ "-IDIR Put DIR in the include file search path.\n"
+ "-e COMMANDS Execute COMMANDS.\n"
+ "-d, --debug Print debug messages.\n"
;
}
int
run(int argc, char* argv[], CommunicatorPtr communicator)
{
+ string cpp("cpp");
+ string commands;
+ bool debug = false;
- PropertiesPtr properties = communicator->getProperties();
-
- string adminEndpoints = properties->getProperty("Ice.Adapter.Admin.Endpoints");
- if(adminEndpoints.length() == 0)
+ int idx = 1;
+ while (idx < argc)
{
- cerr << argv[0] << ": `Ice.Adapter.Admin.Endpoints' property is not set" << endl;
- return EXIT_FAILURE;
+ if (strncmp(argv[idx], "-I", 2) == 0)
+ {
+ cpp += ' ';
+ cpp += argv[idx];
+
+ for (int i = idx ; i + 1 < argc ; ++i)
+ {
+ argv[i] = argv[i + 1];
+ }
+ --argc;
+ }
+ else if (strncmp(argv[idx], "-D", 2) == 0 || strncmp(argv[idx], "-U", 2) == 0)
+ {
+ cpp += ' ';
+ cpp += argv[idx];
+
+ for (int i = idx ; i + 1 < argc ; ++i)
+ {
+ argv[i] = argv[i + 1];
+ }
+ --argc;
+ }
+ else if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0)
+ {
+ usage(argv[0]);
+ return EXIT_SUCCESS;
+ }
+ else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0)
+ {
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
+ }
+ else if (strcmp(argv[idx], "-e") == 0)
+ {
+ if (idx + 1 >= argc)
+ {
+ cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ commands += argv[idx + 1];
+ commands += ';';
+
+ for (int i = idx ; i + 2 < argc ; ++i)
+ {
+ argv[i] = argv[i + 2];
+ }
+ argc -= 2;
+ }
+ else if (strcmp(argv[idx], "-d") == 0 || strcmp(argv[idx], "--debug") == 0)
+ {
+ debug = true;
+ for (int i = idx ; i + 1 < argc ; ++i)
+ {
+ argv[i] = argv[i + 1];
+ }
+ --argc;
+ }
+ else if (argv[idx][0] == '-')
+ {
+ cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ else
+ {
+ ++idx;
+ }
}
- if (argc < 2)
+ if (argc >= 2 && !commands.empty())
{
- cerr << argv[0] << ": no command" << endl;
+ cerr << argv[0] << ": `-e' option cannot be used if input files are given" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
- string cmd = argv[1];
+ PropertiesPtr properties = communicator->getProperties();
+
+ string adminEndpoints = properties->getProperty("Ice.Adapter.Admin.Endpoints");
+ if(adminEndpoints.length() == 0)
+ {
+ cerr << argv[0] << ": `Ice.Adapter.Admin.Endpoints' property is not set" << endl;
+ return EXIT_FAILURE;
+ }
Ice::ObjectPrx adminBase = communicator->stringToProxy("admin:" + adminEndpoints);
AdminPrx admin = AdminPrx::checkedCast(adminBase);
@@ -57,92 +138,79 @@ run(int argc, char* argv[], CommunicatorPtr communicator)
return EXIT_FAILURE;
}
- if (cmd == "add")
- {
- if (argc < 3)
- {
- cerr << argv[0] << ": no reference" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
+ ParserPtr parser = Parser::createParser(communicator, admin);
+ int status = EXIT_SUCCESS;
- for (int i = 2; i < argc; ++i)
- {
- ServerDescriptionPtr desc = new ServerDescription;
- desc->object = communicator->stringToProxy(argv[i]);
- admin->add(desc);
- }
- }
- else if (cmd == "remove")
+ if (argc < 2) // No files given, let's use standard input
{
- if (argc < 3)
+ if (!commands.empty())
{
- cerr << argv[0] << ": no reference" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ int parseStatus = parser->parse(commands, debug);
+ if (parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
}
-
- for (int i = 2; i < argc; ++i)
+ else
{
- admin->remove(communicator->stringToProxy(argv[i]));
+ int parseStatus = parser->parse(stdin, debug);
+ if (parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
}
}
- else if (cmd == "shutdown")
+ else // Process files given on the command line
{
- if (argc > 2)
+ for (idx = 1 ; idx < argc ; ++idx)
{
- usage(argv[0]);
- return EXIT_FAILURE;
+ ifstream test(argv[idx]);
+ if (!test)
+ {
+ cerr << argv[0] << ": can't open `" << argv[idx] << "' for reading: " << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
+ test.close();
+
+ string cmd = cpp + " " + argv[idx];
+#ifdef WIN32
+ FILE* cppHandle = _popen(cmd.c_str(), "r");
+#else
+ FILE* cppHandle = popen(cmd.c_str(), "r");
+#endif
+ if (cppHandle == NULL)
+ {
+ cerr << argv[0] << ": can't run C++ preprocessor: " << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
+
+ int parseStatus = parser->parse(cppHandle, debug);
+
+#ifdef WIN32
+ _pclose(cppHandle);
+#else
+ pclose(cppHandle);
+#endif
+
+ if (parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
}
-
- admin->shutdown();
- }
- else
- {
- cerr << argv[0] << ": invalid command `" << cmd << "'" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
}
- return EXIT_SUCCESS;
+ return status;
}
int
main(int argc, char* argv[])
{
- PropertiesPtr properties = getDefaultProperties(argc, argv);
-
- int idx = 1;
- while (idx < argc)
- {
- if (strcmp(argv[idx], "-h") == 0 || strcmp(argv[idx], "--help") == 0)
- {
- usage(argv[0]);
- return EXIT_SUCCESS;
- }
- else if (strcmp(argv[idx], "-v") == 0 || strcmp(argv[idx], "--version") == 0)
- {
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
- }
- else if (argv[idx][0] == '-')
- {
- cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- else
- {
- ++idx;
- }
- }
-
int status;
CommunicatorPtr communicator;
try
{
- communicator = initializeWithProperties(properties);
+ communicator = initialize(argc, argv);
status = run(argc, argv, communicator);
}
catch(const LocalException& ex)
diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp
index 490e508e4db..91b85dfd06a 100644
--- a/cpp/src/IcePack/Forward.cpp
+++ b/cpp/src/IcePack/Forward.cpp
@@ -9,7 +9,7 @@
// **********************************************************************
#include <Ice/Ice.h>
-#include <Forward.h>
+#include <IcePack/Forward.h>
using namespace std;
using namespace Ice;
diff --git a/cpp/src/IcePack/Forward.h b/cpp/src/IcePack/Forward.h
index 2a2cbdd44be..b3e56a8eb5d 100644
--- a/cpp/src/IcePack/Forward.h
+++ b/cpp/src/IcePack/Forward.h
@@ -8,8 +8,8 @@
//
// **********************************************************************
-#ifndef FORWARD_H
-#define FORWARD_H
+#ifndef ICE_PACK_FORWARD_H
+#define ICE_PACK_FORWARD_H
#include <IcePack/Admin.h>
#include <map>
diff --git a/cpp/src/IcePack/Grammer.y b/cpp/src/IcePack/Grammer.y
new file mode 100644
index 00000000000..782754764af
--- /dev/null
+++ b/cpp/src/IcePack/Grammer.y
@@ -0,0 +1,98 @@
+%{
+
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <IcePack/Parser.h>
+
+using namespace std;
+using namespace Ice;
+using namespace IcePack;
+
+void
+yyerror(const char* s)
+{
+ parser->error(s);
+}
+
+%}
+
+%token ICE_PACK_ADD
+%token ICE_PACK_REMOVE
+%token ICE_PACK_SHUTDOWN
+%token ICE_PACK_REFERENCE
+
+%%
+
+// ----------------------------------------------------------------------
+start
+// ----------------------------------------------------------------------
+: commands
+{
+}
+
+// ----------------------------------------------------------------------
+commands
+// ----------------------------------------------------------------------
+: commands command
+{
+}
+| command
+{
+}
+|
+{
+}
+;
+
+// ----------------------------------------------------------------------
+command
+// ----------------------------------------------------------------------
+: ICE_PACK_ADD references ';'
+{
+ parser->add($2);
+}
+| ICE_PACK_REMOVE references ';'
+{
+ parser->remove($2);
+}
+| ICE_PACK_SHUTDOWN ';'
+{
+ parser->shutdown();
+}
+| error ';'
+{
+ yyerrok;
+}
+| ';'
+{
+}
+;
+
+// ----------------------------------------------------------------------
+references
+// ----------------------------------------------------------------------
+: ICE_PACK_REFERENCE references
+{
+ $1.front().erase(0, 1);
+ $1.front().erase($1.front().size() - 2);
+ $$ = $2;
+ $$.push_front($1.front());
+}
+| ICE_PACK_REFERENCE
+{
+ $1.front().erase(0, 1);
+ $1.front().erase($1.front().size() - 2);
+ $$ = $1
+}
+;
+
+%%
diff --git a/cpp/src/IcePack/Makefile b/cpp/src/IcePack/Makefile
index a6b07224c52..916873c29a6 100644
--- a/cpp/src/IcePack/Makefile
+++ b/cpp/src/IcePack/Makefile
@@ -23,7 +23,10 @@ TARGETS = $(NAME) $(VERSIONED_NAME) $(CLIENT) $(SERVER)
OBJS = Admin.o
-COBJS = Client.o
+COBJS = Grammer.o \
+ Scanner.o \
+ Parser.o \
+ Client.o
SOBJS = Server.o \
Forward.o \
@@ -39,7 +42,7 @@ SLICECMD = $(SLICE) --include-dir IcePack --dll-export ICE_PACK_API -I$(slicedir
include $(top_srcdir)/config/Make.rules
-CPPFLAGS := -I. -I.. $(CPPFLAGS)
+CPPFLAGS := -I.. $(CPPFLAGS)
$(VERSIONED_NAME): $(OBJS)
rm -f $@
@@ -51,12 +54,25 @@ $(NAME): $(VERSIONED_NAME)
$(CLIENT): $(COBJS)
rm -f $@
- $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(COBJS) -lIcePack $(LIBS)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(COBJS) -lIcePack $(LIBS) -lreadline -lcurses
$(SERVER): $(SOBJS)
rm -f $@
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(SOBJS) -lIcePack $(LIBS)
+Grammer.cpp Grammer.h: Grammer.y
+ bison -dvt Grammer.y
+ rm -f Grammer.cpp ; mv Grammer.tab.c Grammer.cpp
+ rm -f Grammer.h ; mv Grammer.tab.h Grammer.h
+
+Scanner.cpp: Scanner.l Grammer.h
+ flex Scanner.l
+ rm -f Scanner.cpp ; mv lex.yy.c Scanner.cpp
+
+clean::
+ -rm -f Grammer.cpp Grammer.h Grammer.output
+ -rm -f Scanner.cpp lex.yy.c
+
$(HDIR)/Admin.h Admin.cpp: $(IDIR)/Admin.ice $(SLICE)
rm -f $(HDIR)/Admin.h Admin.cpp
$(SLICECMD) $(IDIR)/Admin.ice
diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp
new file mode 100644
index 00000000000..58fbbeb4734
--- /dev/null
+++ b/cpp/src/IcePack/Parser.cpp
@@ -0,0 +1,240 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <IcePack/Parser.h>
+
+using namespace std;
+using namespace Ice;
+using namespace IcePack;
+
+extern FILE* yyin;
+extern const char* yycommands;
+
+namespace IcePack
+{
+
+Parser* parser;
+
+}
+
+void IceInternal::incRef(Parser* p) { p->__incRef(); }
+void IceInternal::decRef(Parser* p) { p->__decRef(); }
+
+// ----------------------------------------------------------------------
+// Parser
+// ----------------------------------------------------------------------
+
+ParserPtr
+IcePack::Parser::createParser(const CommunicatorPtr& communicator, const AdminPrx& admin)
+{
+ return new Parser(communicator, admin);
+}
+
+void
+IcePack::Parser::add(const list<string>& references)
+{
+ for (list<string>::const_iterator p = references.begin(); p != references.end(); ++p)
+ {
+ try
+ {
+ ServerDescriptionPtr desc = new ServerDescription;
+ desc->object = _communicator->stringToProxy(*p);
+ _admin->add(desc);
+ }
+ catch(const LocalException& ex)
+ {
+ error(ex.toString());
+ }
+ }
+}
+
+void
+IcePack::Parser::remove(const list<string>& references)
+{
+ for (list<string>::const_iterator p = references.begin(); p != references.end(); ++p)
+ {
+ try
+ {
+ _admin->remove(_communicator->stringToProxy(*p));
+ }
+ catch(const LocalException& ex)
+ {
+ error(ex.toString());
+ }
+ }
+}
+
+void
+IcePack::Parser::shutdown()
+{
+ try
+ {
+ _admin->shutdown();
+ }
+ catch(const LocalException& ex)
+ {
+ error(ex.toString());
+ }
+
+}
+
+void
+IcePack::Parser::nextLine()
+{
+ _currentLine++;
+}
+
+void
+IcePack::Parser::continueLine()
+{
+ _continue = true;
+}
+
+char*
+IcePack::Parser::getPrompt()
+{
+ if (_continue)
+ {
+ _continue = false;
+ return "(cont) ";
+ }
+ else
+ {
+ return ">>> ";
+ }
+}
+
+void
+IcePack::Parser::scanPosition(const char* s)
+{
+ string line(s);
+ string::size_type idx;
+
+ idx = line.find("line");
+ if (idx != string::npos)
+ {
+ line.erase(0, idx + 4);
+ }
+
+ idx = line.find_first_not_of(" \t\r#");
+ if (idx != string::npos)
+ {
+ line.erase(0, idx);
+ }
+
+ _currentLine = atoi(line.c_str()) - 1;
+
+ idx = line.find_first_of(" \t\r");
+ if (idx != string::npos)
+ {
+ line.erase(0, idx);
+ }
+
+ idx = line.find_first_not_of(" \t\r\"");
+ if (idx != string::npos)
+ {
+ line.erase(0, idx);
+
+ idx = line.find_first_of(" \t\r\"");
+ if (idx != string::npos)
+ {
+ _currentFile = line.substr(0, idx);
+ line.erase(0, idx + 1);
+ }
+ else
+ {
+ _currentFile = line;
+ }
+ }
+}
+
+void
+IcePack::Parser::error(const char* s)
+{
+ if (!yycommands && !isatty(fileno(yyin)))
+ {
+ cerr << _currentFile << ':' << _currentLine << ' ';
+ }
+ cerr << "error: " << s << endl;
+ yynerrs++;
+}
+
+void
+IcePack::Parser::error(const string& s)
+{
+ error(s.c_str());
+}
+
+void
+IcePack::Parser::warning(const char* s)
+{
+ if (!yycommands && !isatty(fileno(yyin)))
+ {
+ cerr << _currentFile << ':' << _currentLine << ' ';
+ }
+ cerr << "warning: " << s << endl;
+}
+
+void
+IcePack::Parser::warning(const string& s)
+{
+ warning(s.c_str());
+}
+
+int
+IcePack::Parser::parse(FILE* file, bool debug)
+{
+ extern int yydebug;
+ yydebug = debug ? 1 : 0;
+
+ assert(!parser);
+ parser = this;
+
+ _currentFile = "<standard input>";
+ _currentLine = 0;
+ _continue = false;
+ nextLine();
+
+ yyin = file;
+ yycommands = 0;
+ int status = yyparse();
+
+ parser = 0;
+ return status;
+}
+
+int
+IcePack::Parser::parse(const std::string& commands, bool debug)
+{
+ extern int yydebug;
+ yydebug = debug ? 1 : 0;
+
+ assert(!parser);
+ parser = this;
+
+ _currentFile = "<command line>";
+ _currentLine = 0;
+ _continue = false;
+ nextLine();
+
+ yyin = 0;
+ yycommands = commands.c_str();
+ int status = yyparse();
+
+ parser = 0;
+ return status;
+}
+
+IcePack::Parser::Parser(const CommunicatorPtr& communicator, const AdminPrx& admin) :
+ _communicator(communicator),
+ _admin(admin)
+{
+}
diff --git a/cpp/src/IcePack/Parser.h b/cpp/src/IcePack/Parser.h
new file mode 100644
index 00000000000..13ba922ef7f
--- /dev/null
+++ b/cpp/src/IcePack/Parser.h
@@ -0,0 +1,88 @@
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_PACK_PARSER_H
+#define ICE_PACK_PARSER_H
+
+#include <IcePack/Admin.h>
+#include <list>
+
+#define YYSTYPE std::list<std::string>
+
+extern int yynerrs;
+
+int yyparse();
+int yylex();
+
+namespace IcePack
+{
+
+class Parser;
+
+}
+
+namespace IceInternal
+{
+
+void incRef(::IcePack::Parser*);
+void decRef(::IcePack::Parser*);
+
+}
+
+namespace IcePack
+{
+
+typedef ::IceInternal::Handle<Parser> ParserPtr;
+
+}
+
+namespace IcePack
+{
+
+class Parser : public ::IceInternal::SimpleShared
+{
+public:
+
+ static ParserPtr createParser(const Ice::CommunicatorPtr&, const IcePack::AdminPrx&);
+
+ void add(const std::list<std::string>&);
+ void remove(const std::list<std::string>&);
+ void shutdown();
+
+ void nextLine();
+ void continueLine();
+ char* getPrompt();
+ void scanPosition(const char*);
+
+ void error(const char*);
+ void error(const std::string&);
+
+ void warning(const char*);
+ void warning(const std::string&);
+
+ int parse(FILE*, bool);
+ int parse(const std::string&, bool);
+
+private:
+
+ Parser(const Ice::CommunicatorPtr&, const IcePack::AdminPrx&);
+
+ Ice::CommunicatorPtr _communicator;
+ IcePack::AdminPrx _admin;
+ bool _continue;
+ int _currentLine;
+ std::string _currentFile;
+};
+
+extern Parser* parser; // The current parser for bison/flex
+
+}
+
+#endif
diff --git a/cpp/src/IcePack/Scanner.l b/cpp/src/IcePack/Scanner.l
new file mode 100644
index 00000000000..62be428235a
--- /dev/null
+++ b/cpp/src/IcePack/Scanner.l
@@ -0,0 +1,260 @@
+%{
+
+// **********************************************************************
+//
+// Copyright (c) 2001
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <Ice/Ice.h>
+#include <IcePack/Parser.h>
+#include <IcePack/Grammer.h>
+
+using namespace std;
+using namespace Ice;
+using namespace IcePack;
+
+const char* yycommands;
+
+#ifdef HAVE_READLINE
+
+# include <readline/readline.h>
+# include <readline/history.h>
+
+# define YY_INPUT(buf, result, maxSize) \
+\
+if (yycommands) \
+{ \
+ if (strcmp(yycommands, ";") == 0) \
+ { \
+ buf[0] = EOF; \
+ result = 1; \
+ } \
+ else \
+ { \
+ result = strlen(yycommands); \
+ if (result >= maxSize) \
+ { \
+ YY_FATAL_ERROR("fatal error in flex scanner: command line too long"); \
+ } \
+ else \
+ { \
+ strcpy(buf, yycommands); \
+ yycommands = ";"; \
+ } \
+ }\
+} \
+else if (yy_current_buffer->yy_is_interactive) \
+{ \
+ char* line = readline(parser->getPrompt()); \
+ if (line && *line) \
+ { \
+ add_history(line); \
+ } \
+ if (!line) \
+ { \
+ buf[0] = EOF; \
+ result = 1; \
+ } \
+ else \
+ { \
+ result = strlen(line) + 1; \
+ if (result >= maxSize) \
+ { \
+ free(line); \
+ YY_FATAL_ERROR("fatal error in flex scanner: input line too long"); \
+ } \
+ else \
+ { \
+ strcpy(buf, line); \
+ strcat(buf, "\n"); \
+ free(line); \
+ } \
+ } \
+} \
+else \
+{ \
+ if (((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) \
+ { \
+ YY_FATAL_ERROR("input in flex scanner failed"); \
+ } \
+}
+
+#else
+
+# define YY_INPUT(buf, result, maxSize) \
+\
+if (yycommands) \
+{ \
+ if (strcmp(yycommands, ";") == 0) \
+ { \
+ buf[0] = EOF; \
+ result = 1; \
+ } \
+ else \
+ { \
+ result = strlen(yycommands); \
+ if (result >= maxSize) \
+ { \
+ YY_FATAL_ERROR("fatal error in flex scanner: command line too long"); \
+ } \
+ else \
+ { \
+ strcpy(buf, yycommands); \
+ yycommands = ";"; \
+ } \
+ }\
+} \
+else if (yy_current_buffer->yy_is_interactive) \
+{ \
+ int c = '*', n; \
+ for (n = 0; n < maxSize && (c = getc(yyin)) != EOF && c != '\n'; ++n ) \
+ { \
+ buf[n] = (char)c; \
+ } \
+ if (c == '\n') \
+ { \
+ buf[n++] = (char)c; \
+ } \
+ if (c == EOF && ferror(yyin)) \
+ { \
+ YY_FATAL_ERROR("input in flex scanner failed"); \
+ } \
+ result = n; \
+} \
+else \
+{ \
+ if (((result = fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin)) \
+ { \
+ YY_FATAL_ERROR("input in flex scanner failed"); \
+ } \
+}
+
+#endif
+
+%}
+
+WS [ \t\v\f]
+NL [\n\r]
+S [ \t]
+D [0-9]
+L [a-zA-Z_]
+
+%option noyywrap
+
+%%
+
+^"#"{S}*{D}+{S}*$ {
+ parser->scanPosition(yytext);
+}
+
+^"#"{S}*{D}+{S}+"\""[^\"]*"\"".*$ {
+ parser->scanPosition(yytext);
+}
+
+^"#"{S}*"line"{S}+{D}+{S}*$ {
+ parser->scanPosition(yytext);
+}
+
+^"#"{S}*"line"{S}+{D}+{S}+"\""[^\"]*"\"".*$ {
+ parser->scanPosition(yytext);
+}
+
+"//" {
+ // C++-style comment
+
+ int c;
+
+ do
+ {
+ c = yyinput();
+ if (c == '\n')
+ {
+ parser->nextLine();
+ }
+ }
+ while (c != '\n' && c != EOF);
+}
+
+"/*" {
+ // C-style comment
+
+ while (true)
+ {
+ int c = yyinput();
+
+ if (c == '\n')
+ {
+ parser->nextLine();
+ }
+ else if (c == '*')
+ {
+ int next = yyinput();
+
+ if (next == '/')
+ break;
+ else
+ unput(next);
+ }
+ else if (c == EOF)
+ {
+ parser->warning("EOF in comment");
+ break;
+ }
+ }
+}
+
+"add" {
+ return ICE_PACK_ADD;
+}
+
+"remove" {
+ return ICE_PACK_REMOVE;
+}
+
+"shutdown" {
+ return ICE_PACK_SHUTDOWN;
+}
+
+\"[^\"\n]+(:[^\"\n]+)+\" {
+ yylval.empty();
+ yylval.push_back(yytext);
+ return ICE_PACK_REFERENCE;
+}
+
+{WS}*(\\{WS}*{NL})? {
+ int len = strlen(yytext);
+ for (int i = 0; i < len; ++i)
+ {
+ if (yytext[i] == '\\')
+ {
+ parser->continueLine();
+ }
+ else if (yytext[i] == '\n')
+ {
+ parser->nextLine();
+ }
+ }
+}
+
+{NL}|; {
+ int len = strlen(yytext);
+ for (int i = 0; i < len; ++i)
+ {
+ if (yytext[i] == '\n')
+ {
+ parser->nextLine();
+ }
+ }
+ return ';';
+}
+
+. {
+ return yytext[0];
+}
+
+%%
diff --git a/cpp/src/IcePack/Server.cpp b/cpp/src/IcePack/Server.cpp
index 5387708f0bb..9dbc4b479c9 100644
--- a/cpp/src/IcePack/Server.cpp
+++ b/cpp/src/IcePack/Server.cpp
@@ -9,8 +9,8 @@
// **********************************************************************
#include <Ice/Ice.h>
-#include <AdminI.h>
-#include <Forward.h>
+#include <IcePack/AdminI.h>
+#include <IcePack/Forward.h>
using namespace std;
using namespace Ice;
@@ -29,8 +29,33 @@ usage(const char* n)
}
int
-run(int argc, char* argv[], CommunicatorPtr communicator, bool nowarn)
+run(int argc, char* argv[], CommunicatorPtr communicator)
{
+ bool nowarn = false;
+ for (int i = 1; i < argc; ++i)
+ {
+ if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
+ {
+ usage(argv[0]);
+ return EXIT_SUCCESS;
+ }
+ else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
+ {
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
+ }
+ else if(strcmp(argv[i], "--nowarn") == 0)
+ {
+ nowarn = true;
+ }
+ else
+ {
+ cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ }
+
PropertiesPtr properties = communicator->getProperties();
string adminEndpoints = properties->getProperty("Ice.Adapter.Admin.Endpoints");
@@ -67,40 +92,13 @@ run(int argc, char* argv[], CommunicatorPtr communicator, bool nowarn)
int
main(int argc, char* argv[])
{
- PropertiesPtr properties = getDefaultProperties(argc, argv);
-
- bool nowarn = false;
- for (int i = 1; i < argc; ++i)
- {
- if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
- {
- usage(argv[0]);
- return EXIT_SUCCESS;
- }
- else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
- {
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
- }
- else if(strcmp(argv[i], "--nowarn") == 0)
- {
- nowarn = true;
- }
- else
- {
- cerr << argv[0] << ": unknown option `" << argv[i] << "'" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- }
-
int status;
CommunicatorPtr communicator;
try
{
- communicator = initializeWithProperties(properties);
- status = run(argc, argv, communicator, nowarn);
+ communicator = initialize(argc, argv);
+ status = run(argc, argv, communicator);
}
catch(const LocalException& ex)
{
diff --git a/cpp/src/Slice/GrammerUtil.h b/cpp/src/Slice/GrammerUtil.h
index d14a544b7ec..258955dc1cb 100644
--- a/cpp/src/Slice/GrammerUtil.h
+++ b/cpp/src/Slice/GrammerUtil.h
@@ -8,8 +8,8 @@
//
// **********************************************************************
-#ifndef GRAMMER_UTIL_H
-#define GRAMMER_UTIL_H
+#ifndef SLICE_GRAMMER_UTIL_H
+#define SLICE_GRAMMER_UTIL_H
#include <Slice/Parser.h>
diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile
index 596d1f28552..7c08096d7c1 100644
--- a/cpp/src/Slice/Makefile
+++ b/cpp/src/Slice/Makefile
@@ -29,7 +29,7 @@ SRCS = $(OBJS:.o=.cpp)
include $(top_srcdir)/config/Make.rules
-CPPFLAGS := -I. -I.. $(CPPFLAGS)
+CPPFLAGS := -I.. $(CPPFLAGS)
$(VERSIONED_NAME): $(OBJS)
rm -f $@