本文整理汇总了C++中IRC_WriteStrClient函数的典型用法代码示例。如果您正苦于以下问题:C++ IRC_WriteStrClient函数的具体用法?C++ IRC_WriteStrClient怎么用?C++ IRC_WriteStrClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IRC_WriteStrClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: join_send_topic
/**
* Acknowledge user JOIN request and send "channel info" numerics.
*
* @param Client Client used to prefix the genrated commands
* @param target Forward commands/numerics to this user
* @param chan Channel structure
* @param channame Channel name
*/
static bool
join_send_topic(CLIENT *Client, CLIENT *target, CHANNEL *chan,
const char *channame)
{
const char *topic;
if (Client_Type(Client) != CLIENT_USER)
return true;
/* acknowledge join */
if (!IRC_WriteStrClientPrefix(Client, target, "JOIN :%s", channame))
return false;
/* Send topic to client, if any */
topic = Channel_Topic(chan);
assert(topic != NULL);
if (*topic) {
if (!IRC_WriteStrClient(Client, RPL_TOPIC_MSG,
Client_ID(Client), channame, topic))
return false;
#ifndef STRICT_RFC
if (!IRC_WriteStrClient(Client, RPL_TOPICSETBY_MSG,
Client_ID(Client), channame,
Channel_TopicWho(chan),
Channel_TopicTime(chan)))
return false;
#endif
}
/* send list of channel members to client */
if (!IRC_Send_NAMES(Client, chan))
return false;
return IRC_WriteStrClient(Client, RPL_ENDOFNAMES_MSG, Client_ID(Client),
Channel_Name(chan));
} /* join_send_topic */
示例2: Channel_Part
/**
* Part client from channel.
* This function lets a client part from a channel. First, the function checks
* if the channel exists and the client is a member of it and sends out
* appropriate error messages if not. The real work is done by the function
* Remove_Client().
*/
GLOBAL bool
Channel_Part(CLIENT * Client, CLIENT * Origin, const char *Name, const char *Reason)
{
CHANNEL *chan;
assert(Client != NULL);
assert(Name != NULL);
assert(Reason != NULL);
/* Check that specified channel exists */
chan = Channel_Search(Name);
if (!chan) {
IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Client), Name);
return false;
}
/* Check that the client is in the channel */
if (!Get_Cl2Chan(chan, Client)) {
IRC_WriteStrClient(Client, ERR_NOTONCHANNEL_MSG,
Client_ID(Client), Name);
return false;
}
if (Conf_MorePrivacy)
Reason = "";
/* Part client from channel */
if (!Remove_Client(REMOVE_PART, chan, Client, Origin, Reason, true))
return false;
else
return true;
} /* Channel_Part */
示例3: Help
/**
* Send help for a given topic to the client.
*
* @param Client The client requesting help.
* @param Topic The help topic requested.
* @return CONNECTED or DISCONNECTED.
*/
static bool
Help(CLIENT *Client, const char *Topic)
{
char *line;
size_t helptext_len, len_str, idx_start, lines = 0;
bool in_article = false;
assert(Client != NULL);
assert(Topic != NULL);
helptext_len = array_bytes(&Conf_Helptext);
line = array_start(&Conf_Helptext);
while (helptext_len > 0) {
len_str = strlen(line) + 1;
assert(helptext_len >= len_str);
helptext_len -= len_str;
if (in_article) {
/* The first character in each article text line must
* be a TAB (ASCII 9) character which will be stripped
* in the output. If it is not a TAB, the end of the
* article has been reached. */
if (line[0] != '\t') {
if (lines > 0)
return CONNECTED;
else
break;
}
/* A single '.' character indicates an empty line */
if (line[1] == '.' && line[2] == '\0')
idx_start = 2;
else
idx_start = 1;
if (!IRC_WriteStrClient(Client, "NOTICE %s :%s",
Client_ID(Client),
&line[idx_start]))
return DISCONNECTED;
lines++;
} else {
if (line[0] == '-' && line[1] == ' '
&& strcasecmp(&line[2], Topic) == 0)
in_article = true;
}
line += len_str;
}
/* Help topic not found (or empty)! */
if (!IRC_WriteStrClient(Client, "NOTICE %s :No help for \"%s\" found!",
Client_ID(Client), Topic))
return DISCONNECTED;
return CONNECTED;
}
示例4: Login_User_PostAuth
/**
* Finish client registration.
*
* Introduce the new client to the network and send all "hello messages"
* to it after authentication has been succeeded.
*
* @param Client The client logging in.
* @return CONNECTED or DISCONNECTED.
*/
GLOBAL bool
Login_User_PostAuth(CLIENT *Client)
{
REQUEST Req;
char modes[CLIENT_MODE_LEN + 1];
assert(Client != NULL);
if (Class_HandleServerBans(Client) != CONNECTED)
return DISCONNECTED;
Client_Introduce(NULL, Client, CLIENT_USER);
if (!IRC_WriteStrClient
(Client, RPL_WELCOME_MSG, Client_ID(Client), Client_Mask(Client)))
return false;
if (!IRC_WriteStrClient
(Client, RPL_YOURHOST_MSG, Client_ID(Client),
Client_ID(Client_ThisServer()), PACKAGE_VERSION, HOST_CPU,
HOST_VENDOR, HOST_OS))
return false;
if (!IRC_WriteStrClient
(Client, RPL_CREATED_MSG, Client_ID(Client), NGIRCd_StartStr))
return false;
if (!IRC_WriteStrClient
(Client, RPL_MYINFO_MSG, Client_ID(Client),
Client_ID(Client_ThisServer()), PACKAGE_VERSION, USERMODES,
CHANMODES))
return false;
/* Features supported by this server (005 numeric, ISUPPORT),
* see <http://www.irc.org/tech_docs/005.html> for details. */
if (!IRC_Send_ISUPPORT(Client))
return DISCONNECTED;
if (!IRC_Send_LUSERS(Client))
return DISCONNECTED;
if (!IRC_Show_MOTD(Client))
return DISCONNECTED;
/* Set default user modes */
if (Conf_DefaultUserModes[0]) {
snprintf(modes, sizeof(modes), "+%s", Conf_DefaultUserModes);
Req.prefix = Client_ID(Client_ThisServer());
Req.command = "MODE";
Req.argc = 2;
Req.argv[0] = Client_ID(Client);
Req.argv[1] = modes;
IRC_MODE(Client, &Req);
} else
IRC_SetPenalty(Client, 1);
return CONNECTED;
}
示例5: Channel_Mode_Answer_Request
/*
* Reply to a channel mode request.
*
* @param Origin The originator of the MODE command (prefix).
* @param Channel The channel of which the modes should be sent.
* @return CONNECTED or DISCONNECTED.
*/
static bool
Channel_Mode_Answer_Request(CLIENT *Origin, CHANNEL *Channel)
{
char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], argadd[CLIENT_PASS_LEN];
const char *mode_ptr;
if (!Channel_IsMemberOf(Channel, Origin)) {
/* Not a member: "simple" mode reply */
if (!IRC_WriteStrClient(Origin, RPL_CHANNELMODEIS_MSG,
Client_ID(Origin), Channel_Name(Channel),
Channel_Modes(Channel)))
return DISCONNECTED;
} else {
/* The sender is a member: generate extended reply */
strlcpy(the_modes, Channel_Modes(Channel), sizeof(the_modes));
mode_ptr = the_modes;
the_args[0] = '\0';
while(*mode_ptr) {
switch(*mode_ptr) {
case 'l':
snprintf(argadd, sizeof(argadd), " %lu",
Channel_MaxUsers(Channel));
strlcat(the_args, argadd, sizeof(the_args));
break;
case 'k':
strlcat(the_args, " ", sizeof(the_args));
strlcat(the_args, Channel_Key(Channel),
sizeof(the_args));
break;
}
mode_ptr++;
}
if (the_args[0])
strlcat(the_modes, the_args, sizeof(the_modes));
if (!IRC_WriteStrClient(Origin, RPL_CHANNELMODEIS_MSG,
Client_ID(Origin), Channel_Name(Channel),
the_modes))
return DISCONNECTED;
}
#ifndef STRICT_RFC
/* Channel creation time */
if (!IRC_WriteStrClient(Origin, RPL_CREATIONTIME_MSG,
Client_ID(Origin), Channel_Name(Channel),
Channel_CreationTime(Channel)))
return DISCONNECTED;
#endif
return CONNECTED;
}
示例6: IRC_HELP
/**
* Handler for the IRC "HELP" command.
*
* @param Client The client from which this command has been received.
* @param Req Request structure with prefix and all parameters.
* @return CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_HELP(CLIENT *Client, REQUEST *Req)
{
COMMAND *cmd;
assert(Client != NULL);
assert(Req != NULL);
if ((Req->argc == 0 && array_bytes(&Conf_Helptext) > 0)
|| (Req->argc >= 1 && strcasecmp(Req->argv[0], "Commands") != 0)) {
/* Help text available and requested */
if (Req->argc >= 1)
return Help(Client, Req->argv[0]);
if (!Help(Client, "Intro"))
return DISCONNECTED;
return CONNECTED;
}
cmd = Parse_GetCommandStruct();
while(cmd->name) {
if (!IRC_WriteStrClient(Client, "NOTICE %s :%s",
Client_ID(Client), cmd->name))
return DISCONNECTED;
cmd++;
}
return CONNECTED;
} /* IRC_HELP */
示例7: Channel_Join
/**
* Join Channel
* This function lets a client join a channel. First, the function
* checks that the specified channel name is valid and that the client
* isn't already a member. If the specified channel doesn't exist,
* a new channel is created. Client is added to channel by function
* Add_Client().
*/
GLOBAL bool
Channel_Join( CLIENT *Client, const char *Name )
{
CHANNEL *chan;
assert(Client != NULL);
assert(Name != NULL);
/* Check that the channel name is valid */
if (! Channel_IsValidName(Name)) {
IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG,
Client_ID(Client), Name);
return false;
}
chan = Channel_Search(Name);
if(chan) {
/* Check if the client is already in the channel */
if (Get_Cl2Chan(chan, Client))
return false;
} else {
/* If the specified channel does not exist, the channel
* is now created */
chan = Channel_Create(Name);
if (!chan)
return false;
}
/* Add user to Channel */
if (! Add_Client(chan, Client))
return false;
return true;
} /* Channel_Join */
示例8: Synchronize_Lists
/**
* Synchronize invite, ban, except, and G-Line lists between servers.
*
* @param Client New server.
* @return CONNECTED or DISCONNECTED.
*/
static bool
Synchronize_Lists(CLIENT * Client)
{
CHANNEL *c;
struct list_head *head;
struct list_elem *elem;
time_t t;
assert(Client != NULL);
/* g-lines */
head = Class_GetList(CLASS_GLINE);
elem = Lists_GetFirst(head);
while (elem) {
t = Lists_GetValidity(elem) - time(NULL);
if (!IRC_WriteStrClient(Client, "GLINE %s %ld :%s",
Lists_GetMask(elem),
t > 0 ? (long)t : 0,
Lists_GetReason(elem)))
return DISCONNECTED;
elem = Lists_GetNext(elem);
}
c = Channel_First();
while (c) {
if (!Send_List(Client, c, Channel_GetListExcepts(c), 'e'))
return DISCONNECTED;
if (!Send_List(Client, c, Channel_GetListBans(c), 'b'))
return DISCONNECTED;
if (!Send_List(Client, c, Channel_GetListInvites(c), 'I'))
return DISCONNECTED;
c = Channel_Next(c);
}
return CONNECTED;
}
示例9: Announce_Server
/**
* Announce new server in the network
* @param Client New server
* @param Server Existing server in the network
*/
static bool
Announce_Server(CLIENT * Client, CLIENT * Server)
{
CLIENT *c;
if (Client_Conn(Server) > NONE) {
/* Announce the new server to the one already registered
* which is directly connected to the local server */
if (!IRC_WriteStrClient
(Server, "SERVER %s %d %d :%s", Client_ID(Client),
Client_Hops(Client) + 1, Client_MyToken(Client),
Client_Info(Client)))
return DISCONNECTED;
}
if (Client_Hops(Server) == 1)
c = Client_ThisServer();
else
c = Client_TopServer(Server);
/* Inform new server about the one already registered in the network */
return IRC_WriteStrClientPrefix(Client, c, "SERVER %s %d %d :%s",
Client_ID(Server), Client_Hops(Server) + 1,
Client_MyToken(Server), Client_Info(Server));
} /* Announce_Server */
示例10: Handle_CAP_LIST
/**
* Handler for the "CAP LIST" command.
*
* @param Client The client from which this command has been received.
* @param Arg Command argument or NULL.
* @returns CONNECTED or DISCONNECTED.
*/
bool
Handle_CAP_LIST(CLIENT *Client, UNUSED char *Arg)
{
assert(Client != NULL);
return IRC_WriteStrClient(Client, "CAP %s LIST :%s", Client_ID(Client),
Get_CAP_String(Client_Cap(Client)));
}
示例11: Add_To_List
/**
* Add entries to channel invite, ban and exception lists.
*
* @param what Can be 'I' for invite, 'b' for ban, and 'e' for exception list.
* @param Prefix The originator of the command.
* @param Client The sender of the command.
* @param Channel The channel of which the list should be modified.
* @param Pattern The pattern to add to the list.
* @return CONNECTED or DISCONNECTED.
*/
static bool
Add_To_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
const char *Pattern)
{
char mask[MASK_LEN];
struct list_head *list = NULL;
long int current_count;
assert(Client != NULL);
assert(Channel != NULL);
assert(Pattern != NULL);
assert(what == 'I' || what == 'b' || what == 'e');
Lists_MakeMask(Pattern, mask, sizeof(mask));
current_count = Lists_Count(Channel_GetListInvites(Channel))
+ Lists_Count(Channel_GetListExcepts(Channel))
+ Lists_Count(Channel_GetListBans(Channel));
switch(what) {
case 'I':
list = Channel_GetListInvites(Channel);
break;
case 'b':
list = Channel_GetListBans(Channel);
break;
case 'e':
list = Channel_GetListExcepts(Channel);
break;
}
if (Lists_CheckDupeMask(list, mask))
return CONNECTED;
if (Client_Type(Client) == CLIENT_USER &&
current_count >= MAX_HNDL_CHANNEL_LISTS)
return IRC_WriteStrClient(Client, ERR_LISTFULL_MSG,
Client_ID(Client),
Channel_Name(Channel), mask,
MAX_HNDL_CHANNEL_LISTS);
switch (what) {
case 'I':
if (!Channel_AddInvite(Channel, mask, false))
return CONNECTED;
break;
case 'b':
if (!Channel_AddBan(Channel, mask))
return CONNECTED;
break;
case 'e':
if (!Channel_AddExcept(Channel, mask))
return CONNECTED;
break;
}
return Send_ListChange(true, what, Prefix, Client, Channel, mask);
}
示例12: Handle_CAP_LS
/**
* Handler for the "CAP LS" command.
*
* @param Client The client from which this command has been received.
* @param Arg Command argument or NULL.
* @returns CONNECTED or DISCONNECTED.
*/
bool
Handle_CAP_LS(CLIENT *Client, UNUSED char *Arg)
{
assert(Client != NULL);
Set_CAP_Negotiation(Client);
return IRC_WriteStrClient(Client,
"CAP %s LS :multi-prefix",
Client_ID(Client));
}
示例13: Handle_CAP_REQ
/**
* Handler for the "CAP REQ" command.
*
* @param Client The client from which this command has been received.
* @param Arg Command argument.
* @returns CONNECTED or DISCONNECTED.
*/
bool
Handle_CAP_REQ(CLIENT *Client, char *Arg)
{
int new_cap;
assert(Client != NULL);
assert(Arg != NULL);
Set_CAP_Negotiation(Client);
new_cap = Parse_CAP(Client_Cap(Client), Arg);
if (new_cap < 0)
return IRC_WriteStrClient(Client, "CAP %s NAK :%s",
Client_ID(Client), Arg);
Client_CapSet(Client, new_cap);
return IRC_WriteStrClient(Client, "CAP %s ACK :%s",
Client_ID(Client), Arg);
}
示例14: IRC_WEBIRC
/**
* Handler for the IRC "WEBIRC" command.
*
* See doc/Protocol.txt, section II.4:
* "Update webchat/proxy client information".
*
* @param Client The client from which this command has been received.
* @param Req Request structure with prefix and all parameters.
* @returns CONNECTED or DISCONNECTED.
*/
GLOBAL bool
IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
{
/* Exactly 4 parameters are requited */
if (Req->argc != 4)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
if (!Conf_WebircPwd[0] || strcmp(Req->argv[0], Conf_WebircPwd) != 0)
return IRC_WriteStrClient(Client, ERR_PASSWDMISMATCH_MSG,
Client_ID(Client));
LogDebug("Connection %d: got valid WEBIRC command: user=%s, host=%s, ip=%s",
Client_Conn(Client), Req->argv[1], Req->argv[2], Req->argv[3]);
Client_SetUser(Client, Req->argv[1], true);
Client_SetOrigUser(Client, Req->argv[1]);
Client_SetHostname(Client, Req->argv[2]);
return CONNECTED;
} /* IRC_WEBIRC */
示例15: Channel_Write
GLOBAL bool
Channel_Write(CHANNEL *Chan, CLIENT *From, CLIENT *Client, const char *Command,
bool SendErrors, const char *Text)
{
if (!Can_Send_To_Channel(Chan, From)) {
if (! SendErrors)
return CONNECTED; /* no error, see RFC 2812 */
if (strchr(Channel_Modes(Chan), 'M'))
return IRC_WriteStrClient(From, ERR_NEEDREGGEDNICK_MSG,
Client_ID(From), Channel_Name(Chan));
else
return IRC_WriteStrClient(From, ERR_CANNOTSENDTOCHAN_MSG,
Client_ID(From), Channel_Name(Chan));
}
if (Client_Conn(From) > NONE)
Conn_UpdateIdle(Client_Conn(From));
return IRC_WriteStrChannelPrefix(Client, Chan, From, true,
"%s %s :%s", Command, Channel_Name(Chan), Text);
}