This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.c
168 lines (151 loc) · 4.87 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*************************************************************************
** send.c Beta v2.0 (22 Aug 1988)
**
** This file is part of Internet Relay Chat v2.0
**
** Author: Jarkko Oikarinen
** Internet: [email protected]
** UUCP: ...!mcvax!tut!oulu!jto
** BITNET: toljto at finou
**
** Copyright (c) 1988 University of Oulu, Computing Center
**
** All rights reserved.
**
** See file COPYRIGHT in this package for full copyright.
**
*************************************************************************/
char send_id[] = "send.c v2.0 (c) 1988 University of Oulu, Computing Center";
#include "struct.h"
#define NULL ((char *) 0)
#define NEWLINE "\n"
char sendbuf[1024];
extern aClient *client;
extern aClient *find_server();
#ifdef BYE
#define DoBye(x,y) m_bye((x),(y))
#else
#define DoBye(x,y)
#endif
sendto_one(to, pattern, par1, par2, par3, par4, par5, par6, par7, par8)
aClient *to;
char *pattern, *par1, *par2, *par3, *par4, *par5, *par6, *par7, *par8;
{
aClient *cptr;
#if VMS
extern int goodbye;
if (Equal("QUIT", pattern)) goodbye = 1;
#endif
sprintf(sendbuf, pattern, par1, par2, par3, par4, par5, par6, par7,
par8);
strcat(sendbuf, NEWLINE);
if (!ISME(to))
debug(DEBUG_NOTICE,"%s", sendbuf);
if (to->fd < 0) {
if (to->fromhost[0] == '\0' && !ISME(to)) {
debug(DEBUG_ERROR,"Client %s with negative fd and no fromhost... AARGH!",
to->nickname);
if (to->fd != -20) m_bye(to, to, myhostname);
} else if (!ISME(to)){
if (!(cptr = find_server(to->fromhost, NULL)) || cptr->fd < 0)
return(-1);
if (deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
DoBye(cptr, cptr) ;
}
} else {
if (deliver_it(to->fd, sendbuf, strlen(sendbuf)) == -1)
DoBye(to, to) ;
}
}
sendto_channel_butone(one, channel, pattern,
par1, par2, par3, par4, par5, par6, par7, par8)
aClient *one;
char *pattern, *par1, *par2, *par3, *par4, *par5, *par6, *par7, *par8;
int channel;
{
aClient *cptr=client, *acptr;
sprintf(sendbuf, pattern, par1, par2, par3, par4, par5, par6, par7,
par8);
strcat(sendbuf, NEWLINE);
debug(DEBUG_NOTICE,"%s", sendbuf);
for (; cptr; cptr = cptr->next)
if (cptr != one && cptr->fd >= 0 &&
(ISSERVER(cptr) || (cptr->channel == channel &&
(ISOPER(cptr) || ISCLIENT(cptr))))) {
acptr = client;
if (ISSERVER(cptr)) {
for (; acptr; acptr = acptr->next)
if (acptr->channel == channel &&
(ISCLIENT(acptr) || ISOPER(acptr)) &&
Equal(acptr->fromhost, cptr->host) && cptr->host[0])
break;
}
if (acptr) {
if (cptr->fd >= 0 &&
deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
DoBye(cptr, cptr) ;
}
}
}
sendto_serv_butone(one, pattern, par1, par2, par3, par4, par5, par6,
par7, par8)
aClient *one;
char *pattern, *par1, *par2, *par3, *par4, *par5, *par6, *par7, *par8;
{
aClient *cptr = client;
sprintf(sendbuf, pattern, par1, par2, par3, par4, par5, par6, par7, par8);
strcat(sendbuf, NEWLINE);
debug(DEBUG_NOTICE,"%s", sendbuf);
for ( ; cptr ; cptr = cptr->next )
if (ISSERVER(cptr) && cptr != one && cptr->fd >= 0) {
if (deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
DoBye(cptr, cptr) ;
}
}
sendto_channel_butserv(channel, pattern,
par1, par2, par3, par4, par5, par6, par7, par8)
int channel;
char *pattern, *par1, *par2, *par3, *par4, *par5, *par6, *par7, *par8;
{
aClient *cptr = client;
sprintf(sendbuf, pattern, par1, par2, par3, par4, par5, par6, par7,
par8);
strcat(sendbuf, NEWLINE);
debug(DEBUG_NOTICE,"%s", sendbuf);
for( ; cptr; cptr = cptr->next)
if (!ISSERVER(cptr) && cptr->fd >= 0 &&
(cptr->channel == channel || channel == 0)) {
if (deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
DoBye(cptr, cptr) ;
}
}
sendto_all_butone(one, pattern, par1, par2, par3, par4, par5,
par6, par7, par8)
aClient *one;
char *pattern, *par1, *par2, *par3, *par4, *par5, *par6, *par7, *par8;
{
aClient *cptr = client;
sprintf(sendbuf, pattern, par1, par2, par3, par4, par5, par6, par7, par8);
strcat(sendbuf, NEWLINE);
debug(DEBUG_NOTICE,"%s", sendbuf);
for ( ; cptr; cptr = cptr->next)
if (one != cptr && cptr->fd >= 0) {
if (deliver_it(cptr->fd, sendbuf, strlen(sendbuf)) == -1)
DoBye(cptr, cptr) ;
}
}
sendto_ops(pattern, par1, par2, par3, par4, par5, par6, par7, par8)
char *pattern, *par1, *par2, *par3, *par4, *par5, *par6, *par7, *par8;
{
char buf[1024];
aClient *cptr = client;
sprintf(sendbuf, pattern, par1, par2, par3, par4, par5, par6, par7, par8);
strcat(sendbuf, NEWLINE);
debug(DEBUG_NOTICE, "%s", sendbuf);
for (; cptr; cptr = cptr->next)
if (cptr->fd >= 0 && ISOPER(cptr)) {
sprintf(buf, "NOTICE %s :*** Notice: %s", cptr->nickname, sendbuf);
if (deliver_it(cptr->fd, buf, strlen(buf)) == -1)
DoBye(cptr, cptr) ;
}
}