4 Copyright (C) Andrew Tridgell 2006
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "lib/events/events.h"
23 #include "system/filesys.h"
25 #include "system/wait.h"
28 static void block_signal(int signum)
32 memset(&act, 0, sizeof(act));
34 act.sa_handler = SIG_IGN;
35 sigemptyset(&act.sa_mask);
36 sigaddset(&act.sa_mask, signum);
37 sigaction(signum, &act, NULL);
44 int main(int argc, const char *argv[])
46 struct ctdb_context *ctdb;
47 const char *db_list = "test.tdb";
50 struct poptOption popt_options[] = {
53 { "dblist", 0, POPT_ARG_STRING, &db_list, 0, "list of databases", NULL },
57 const char **extra_argv;
61 struct event_context *ev;
63 pc = poptGetContext(argv[0], argc, argv, popt_options, POPT_CONTEXT_KEEP_FIRST);
65 while ((opt = poptGetNextOpt(pc)) != -1) {
68 fprintf(stderr, "Invalid option %s: %s\n",
69 poptBadOption(pc, 0), poptStrerror(opt));
74 /* setup the remaining options for the main program to use */
75 extra_argv = poptGetArgs(pc);
78 while (extra_argv[extra_argc]) extra_argc++;
81 block_signal(SIGPIPE);
83 ev = event_context_init(NULL);
85 ctdb = ctdb_cmdline_init(ev);
87 /* attach to the list of databases */
88 s = talloc_strdup(ctdb, db_list);
89 for (tok=strtok(s, ", "); tok; tok=strtok(NULL, ", ")) {
90 struct ctdb_db_context *ctdb_db;
91 ctdb_db = ctdb_attach(ctdb, tok, TDB_DEFAULT,
92 O_RDWR|O_CREAT|O_TRUNC, 0666);
94 printf("ctdb_attach to '%s'failed - %s\n", tok,
98 printf("Attached to database '%s'\n", tok);
101 /* start the protocol running */
102 ret = ctdb_start(ctdb);
104 /* event_loop_wait(ev);*/