-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathirc_send.cpp
47 lines (36 loc) · 936 Bytes
/
irc_send.cpp
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
#include "includes.h"
#include "functions.h"
#include "externs.h"
// globals
extern FILE *fp;
// irc send functions
void irc_sendv(SOCKET sock, char *msg, ...)
{
char msgbuf[IRCLINE];
va_list argp;
va_start(argp, msg);
_vsnprintf(msgbuf, sizeof(msgbuf), msg, argp);
fsend(sock, msgbuf, strlen(msgbuf), 0);
#ifdef DEBUG_LOGGING
debuglog(msgbuf,FALSE);
#endif
return;
}
void irc_privmsg(SOCKET sock, char *dest, char *msg, BOOL notice, BOOL delay)
{
char msgbuf[IRCLINE], tmpbuf[IRCLINE], *action;
if (notice)
action = "NOTICE";
else
action = "PRIVMSG";
int bufsize = IRCLINE - strlen(action) - strlen(dest) - 6 ; // trust me
_snprintf(tmpbuf,bufsize,"%s",msg);
sprintf(msgbuf,"%s %s :%s\r\n", action, dest, tmpbuf);
fsend(sock, msgbuf, strlen(msgbuf), 0);
#ifdef DEBUG_LOGGING
debuglog(msgbuf,FALSE);
#endif
if(delay)
Sleep(FLOOD_DELAY);
return;
}