#include "internal/print_content.hpp"
#include "internal/storage_backend_serialized.hpp"
#include <iostream>
+#include <getopt.h>
+#include "libdbuspolicy1-private.h"
using namespace std;
+static const struct option options[] = {
+ {"system", no_argument, 0, 0 },
+ {"session", no_argument, 0, 0},
+ {0, 0, 0, 0}
+};
+
static void print_help(const char *name) {
cout << endl;
- cout << "usage: " << name << " <input_filename.serialized>" << endl;
+ cout << "usage: " << name << " [-i input_filename]" << endl;
+ cout << " " << name << " {--system|--session}" << endl;
cout << endl;
}
-int main(int argc, const char **argv) {
+int main(int argc, char *argv[]) {
+ std::string input_filename;
+ int c;
if (argc < 2) {
print_help(argv[0]);
return 1;
}
+ while (1) {
+ int option_index;
+ c = getopt_long(argc, argv, "i:", options, &option_index);
+ if (c == -1)
+ break;
+
+ switch(c) {
+ case 0:
+ if (option_index == 0)
+ input_filename = system_bus_conf_file_primary();
+ else
+ input_filename = session_bus_conf_file_primary();
+ input_filename.append(".serialized");
+ break;
+ case 'i':
+ input_filename = optarg;
+ break;
+ case '?':
+ break;
+ }
+ if (!input_filename.empty())
+ break;
+ }
+
+ if (input_filename.empty()) {
+ cout << "No input filename" << endl;
+ print_help(argv[0]);
+ return 1;
+ }
+
tslog::init(tslog::ldp_log_level::DEFAULT);
ldp_serialized::StorageBackendSerialized storage;
- if (!storage.init(argv[1], true))
+ if (!storage.init(input_filename.c_str(), true))
return 1;
storage.printContent();
static const struct option options[] = {
{"system", no_argument, 0, 0 },
- {"session", no_argument, 0, 0}
+ {"session", no_argument, 0, 0},
+ {0, 0, 0, 0}
};
static void print_help(const char *name) {