s3:notifyd: Use lpcfg_set_cmdline()
[Samba.git] / source3 / smbd / notifyd / notifydd.c
blobb27a4ab5de593370c896f4fdadaeb8a293257b23
1 /*
2 * Unix SMB/CIFS implementation.
4 * Copyright (C) Volker Lendecke 2014
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "replace.h"
21 #include "notifyd.h"
22 #include "lib/messages_ctdb.h"
23 #include <tevent.h>
24 #include "lib/util/tevent_unix.h"
25 #include "lib/param/param.h"
27 int main(int argc, const char *argv[])
29 TALLOC_CTX *frame;
30 struct loadparm_context *lp_ctx = NULL;
31 struct tevent_context *ev;
32 struct messaging_context *msg;
33 struct tevent_req *req;
34 int err, ret;
35 bool ok;
37 talloc_enable_leak_report_full();
39 frame = talloc_stackframe();
41 lp_ctx = loadparm_init_s3(frame, loadparm_s3_helpers());
42 if (lp_ctx == NULL) {
43 fprintf(stderr,
44 "Failed to initialise the global parameter structure.\n");
45 return 1;
48 setup_logging("notifyd", DEBUG_DEFAULT_STDOUT);
49 lpcfg_set_cmdline(lp_ctx, "log level", "10");
51 ok = lp_load_initial_only(get_dyn_CONFIGFILE());
52 if (!ok) {
53 fprintf(stderr, "Can't load %s - run testparm to debug it\n",
54 get_dyn_CONFIGFILE());
55 return 1;
58 ev = samba_tevent_context_init(frame);
59 if (ev == NULL) {
60 fprintf(stderr, "samba_tevent_context_init failed\n");
61 return 1;
64 msg = messaging_init(ev, ev);
65 if (msg == NULL) {
66 fprintf(stderr, "messaging_init failed\n");
67 return 1;
70 if (!lp_load_global(get_dyn_CONFIGFILE())) {
71 fprintf(stderr, "Can't load %s - run testparm to debug it\n",
72 get_dyn_CONFIGFILE());
73 return 1;
76 req = notifyd_send(ev, ev, msg, messaging_ctdb_connection(),
77 NULL, NULL);
78 if (req == NULL) {
79 fprintf(stderr, "notifyd_send failed\n");
80 return 1;
83 ok = tevent_req_poll_unix(req, ev, &err);
84 if (!ok) {
85 fprintf(stderr, "tevent_req_poll_unix failed: %s\n",
86 strerror(err));
87 return 1;
90 ret = notifyd_recv(req);
92 printf("notifyd_recv returned %d (%s)\n", ret,
93 ret ? strerror(ret) : "ok");
95 TALLOC_FREE(frame);
97 return 0;