-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend.c
122 lines (104 loc) · 3.13 KB
/
send.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* Routines for sending stuff to the network.
* Magick IRC Services are copyright (c) 1996-1998 Preston A. Elder.
* E-mail: <[email protected]> IRC: PreZ@RelicNet
* Originally based on EsperNet services (c) 1996-1998 Andy Church
* This program is free but copyrighted software; see the file COPYING for
* details.
*/
#include "services.h"
/*************************************************************************/
/* Send a command to the server. The two forms here are like
* printf()/vprintf() and friends. */
void
send_cmd (const char *source, const char *fmt,...)
{
va_list args;
va_start (args, fmt);
vsend_cmd (source, fmt, args);
va_end (args);
}
void
vsend_cmd (const char *source, const char *fmt, va_list args)
{
char buf[2048]; /* better not get this big... */
if (runflags & RUN_NOSEND) /* Run silent, Run deep! */
return;
vsnprintf (buf, sizeof (buf), fmt, args);
if (source)
{
if (outlet_on==TRUE&&(stricmp (source, s_OperServ) == 0 && finduser (s_OperServ)))
sockprintf (servsock, ":%s %s\r\n", s_Outlet, buf);
else
sockprintf (servsock, ":%s %s\r\n", source, buf);
if (runflags & RUN_DEBUG)
write_log ("debug: Sent: :%s %s", source, buf);
}
else
{
sockprintf (servsock, "%s\r\n", buf);
if (runflags & RUN_DEBUG)
write_log ("debug: Sent: %s", buf);
}
}
/*************************************************************************/
/* Send out a GLOBOPS. This is called wallops() because it historically
* sent a WALLOPS -- Still does on NON-DALnet servers. */
void
wallops (const char *whoami, const char *fmt,...)
{
va_list args;
char buf[2048];
va_start (args, fmt);
#ifdef IRC_DALNET
snprintf (buf, sizeof (buf), "GLOBOPS :%s", fmt);
#else
snprintf (buf, sizeof (buf), "WALLOPS :%s", fmt);
#endif
if (whoami)
vsend_cmd (whoami, buf, args);
else
vsend_cmd (server_name, buf, args);
va_end (args);
}
/*************************************************************************/
/* Send a NOTICE from the given source to the given nick. */
void
notice (const char *source, const char *dest, const char *fmt,...)
{
va_list args;
char buf[2048];
NickInfo *ni;
va_start (args, fmt);
if (nickserv_on && ((ni = findnick (dest)) && (host (ni)->flags & NI_PRIVMSG) &&
(ni->flags & (NI_IDENTIFIED | NI_RECOGNIZED))))
snprintf (buf, sizeof (buf), "PRIVMSG %s :%s", dest, fmt);
else
snprintf (buf, sizeof (buf), "NOTICE %s :%s", dest, fmt);
vsend_cmd (source, buf, args);
va_end (args);
}
void
noticeall (const char *source, const char *fmt,...)
{
User *u;
for (u = userlist; u; u = u->next)
notice (source, u->nick, fmt);
}
/* Send a NULL-terminated array of text as NOTICEs. */
void
notice_list (const char *source, const char *dest, const char **text)
{
while (*text)
{
/* Have to kludge around an ircII bug here: if a notice includes
* no text, it is ignored, so we replace blank lines by lines
* with a single space.
*/
if (**text)
notice (source, dest, *text);
else
notice (source, dest, " ");
text++;
}
}
/*************************************************************************/