1 | /*
|
---|
2 | * Unix SMB/CIFS implementation.
|
---|
3 | *
|
---|
4 | * Copyright (C) Volker Lendecke 2014
|
---|
5 | *
|
---|
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.
|
---|
10 | *
|
---|
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.
|
---|
15 | *
|
---|
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/>.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #include "replace.h"
|
---|
21 | #include "notifyd.h"
|
---|
22 | #include <tevent.h>
|
---|
23 | #include "lib/util/tevent_unix.h"
|
---|
24 |
|
---|
25 | int main(int argc, const char *argv[])
|
---|
26 | {
|
---|
27 | TALLOC_CTX *frame;
|
---|
28 | struct tevent_context *ev;
|
---|
29 | struct messaging_context *msg;
|
---|
30 | struct tevent_req *req;
|
---|
31 | int err, ret;
|
---|
32 | bool ok;
|
---|
33 |
|
---|
34 | talloc_enable_leak_report_full();
|
---|
35 |
|
---|
36 | frame = talloc_stackframe();
|
---|
37 |
|
---|
38 | setup_logging("notifyd", DEBUG_DEFAULT_STDOUT);
|
---|
39 | lp_set_cmdline("log level", "10");
|
---|
40 |
|
---|
41 | lp_load_initial_only(get_dyn_CONFIGFILE());
|
---|
42 |
|
---|
43 | ev = samba_tevent_context_init(frame);
|
---|
44 | if (ev == NULL) {
|
---|
45 | fprintf(stderr, "samba_tevent_context_init failed\n");
|
---|
46 | return 1;
|
---|
47 | }
|
---|
48 |
|
---|
49 | msg = messaging_init(ev, ev);
|
---|
50 | if (msg == NULL) {
|
---|
51 | fprintf(stderr, "messaging_init failed\n");
|
---|
52 | return 1;
|
---|
53 | }
|
---|
54 |
|
---|
55 | if (!lp_load_global(get_dyn_CONFIGFILE())) {
|
---|
56 | fprintf(stderr, "Can't load %s - run testparm to debug it\n",
|
---|
57 | get_dyn_CONFIGFILE());
|
---|
58 | return 1;
|
---|
59 | }
|
---|
60 |
|
---|
61 | req = notifyd_send(ev, ev, msg, messaging_ctdbd_connection(),
|
---|
62 | NULL, NULL);
|
---|
63 | if (req == NULL) {
|
---|
64 | fprintf(stderr, "notifyd_send failed\n");
|
---|
65 | return 1;
|
---|
66 | }
|
---|
67 |
|
---|
68 | ok = tevent_req_poll_unix(req, ev, &err);
|
---|
69 | if (!ok) {
|
---|
70 | fprintf(stderr, "tevent_req_poll_unix failed: %s\n",
|
---|
71 | strerror(err));
|
---|
72 | return 1;
|
---|
73 | }
|
---|
74 |
|
---|
75 | ret = notifyd_recv(req);
|
---|
76 |
|
---|
77 | printf("notifyd_recv returned %d (%s)\n", ret,
|
---|
78 | ret ? strerror(ret) : "ok");
|
---|
79 |
|
---|
80 | TALLOC_FREE(frame);
|
---|
81 |
|
---|
82 | return 0;
|
---|
83 | }
|
---|