]> jfr.im git - solanum.git/blob - authd/notice.c
authd/res: clean up some horribly indented code
[solanum.git] / authd / notice.c
1 /* authd/notice.c - send notices back to the ircd and to clients
2 * Copyright (c) 2016 Elizabeth Myers <elizabeth@interlinked.me>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice is present in all copies.
7 *
8 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
9 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
11 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
12 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
13 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
14 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
15 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
16 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
17 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
18 * POSSIBILITY OF SUCH DAMAGE.
19 */
20
21 #include "authd.h"
22 #include "notice.h"
23
24 /* Send a notice to a client */
25 void
26 notice_client(uint32_t cid, const char *fmt, ...)
27 {
28 char buf[BUFSIZE];
29 va_list args;
30
31 va_start(args, fmt);
32 vsnprintf(buf, sizeof(buf), fmt, args);
33 va_end(args);
34
35 rb_helper_write(authd_helper, "N %x :%s", cid, buf);
36 }
37
38 /* Send a warning to the IRC daemon for logging, etc. */
39 void
40 warn_opers(notice_level_t level, const char *fmt, ...)
41 {
42 char buf[BUFSIZE];
43 va_list args;
44
45 va_start(args, fmt);
46 vsnprintf(buf, sizeof(buf), fmt, args);
47 va_end(args);
48
49 rb_helper_write(authd_helper, "W %c :%s", level, buf);
50 }
51
52 /* Send a stats result */
53 void
54 stats_result(uint32_t cid, char letter, const char *fmt, ...)
55 {
56 char buf[BUFSIZE];
57 va_list args;
58
59 va_start(args, fmt);
60 vsnprintf(buf, sizeof(buf), fmt, args);
61 va_end(args);
62
63 rb_helper_write(authd_helper, "Y %x %c %s", cid, letter, buf);
64 }
65
66 /* Send a stats error */
67 void
68 stats_error(uint32_t cid, char letter, const char *fmt, ...)
69 {
70 char buf[BUFSIZE];
71 va_list args;
72
73 va_start(args, fmt);
74 vsnprintf(buf, sizeof(buf), fmt, args);
75 va_end(args);
76
77 rb_helper_write(authd_helper, "X %x %c %s", cid, letter, buf);
78 }
79
80 void
81 stats_done(uint32_t cid, char letter)
82 {
83 rb_helper_write(authd_helper, "Z %x %c", cid, letter);
84 }