0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-16 08:58:20 +02:00

Upgrade user struct.

This commit is contained in:
Jason Volk 2016-08-20 17:51:50 -07:00
parent 9a22cfd393
commit 90093b82e6
23 changed files with 106 additions and 200 deletions

View file

@ -24,6 +24,6 @@ h_can_create_channel_authenticated(hook_data_client_approval *data)
{
struct Client *source_p = data->client;
if (*source_p->user->suser == '\0' && !IsOper(source_p))
if (source_p->user->suser.empty() && !IsOper(source_p))
data->approved = ERR_NEEDREGGEDNICK;
}

View file

@ -37,7 +37,7 @@ static int eb_account(const char *data, struct Client *client_p,
(void)chptr;
/* $a alone matches any logged in user */
if (data == NULL)
return EmptyString(client_p->user->suser) ? NOMATCH : MATCH;
return client_p->user->suser.empty()? NOMATCH : MATCH;
/* $a:MASK matches users logged in under matching account */
return match(data, client_p->user->suser) ? MATCH : NOMATCH;
}

View file

@ -125,7 +125,7 @@ h_hdl_stats_request(hook_data_int *hdata)
{
target_p = (Client *)helper_ptr->data;
if(target_p->user->away)
if (target_p->user->away.size())
continue;
count++;
@ -186,7 +186,7 @@ h_hdl_whois(hook_data_client *hdata)
struct Client *source_p = hdata->client;
struct Client *target_p = hdata->target;
if ((target_p->umodes & UMODE_HELPOPS) && EmptyString(target_p->user->away))
if ((target_p->umodes & UMODE_HELPOPS) && target_p->user->away.empty())
{
sendto_one_numeric(source_p, RPL_WHOISHELPOP, form_str(RPL_WHOISHELPOP), target_p->name);
}

View file

@ -380,7 +380,7 @@ hurt_check_event(void *arg)
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) {
client_p = (Client *)ptr->data;
if (!EmptyString(client_p->user->suser))
if (client_p->user->suser.size())
{
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
sendto_one_notice(client_p, ":HURT restriction removed for this session");
@ -431,7 +431,7 @@ client_exit_hook(hook_data_client_exit *data)
static void
new_local_user_hook(struct Client *source_p)
{
if (IsAnyDead(source_p) || !EmptyString(source_p->user->suser) ||
if (IsAnyDead(source_p) || source_p->user->suser.size() ||
IsExemptKline(source_p))
return;

View file

@ -22,7 +22,7 @@ hack_channel_access(void *vdata)
if (!MyClient(data->client))
return;
if (EmptyString(data->client->user->suser))
if (data->client->user->suser.empty())
data->approved = 0;
}

View file

@ -53,7 +53,6 @@ struct Whowas;
struct DNSReply;
struct Listener;
struct Client;
struct User;
struct Server;
struct LocalUser;
struct PreClient;
@ -63,22 +62,19 @@ struct ws_ctl;
typedef int SSL_OPEN_CB(struct Client *, int status);
/*
* Client structures
*/
struct User
struct user
{
std::map<chan::chan *, chan::membership *> channel;
std::set<chan::chan *> invited;
char *away; /* pointer to away message */
int refcnt; /* Number of times this block is referenced */
std::string away;
std::string suser;
char suser[NICKLEN+1];
user(const std::string &suser = {}): suser(suser) {}
};
struct Server
{
struct User *user; /* who activated this connection */
std::unique_ptr<struct user> user; // who activated this connection
char by[NICKLEN];
rb_dlink_list servers;
rb_dlink_list users;
@ -101,7 +97,7 @@ struct Client
{
rb_dlink_node node;
rb_dlink_node lnode;
struct User *user; /* ...defined, if this is a User */
std::unique_ptr<struct user> user; // ...defined, if this is a user
struct Server *serv; /* ...defined, if this is a server */
struct Client *servptr; /* Points to server this Client is on */
struct Client *from; /* == self, if Local Client, *NEVER* NULL! */
@ -621,16 +617,11 @@ extern int show_ip(struct Client *source_p, struct Client *target_p);
extern int show_ip_conf(struct ConfItem *aconf, struct Client *source_p);
extern int show_ip_whowas(struct Whowas *whowas, struct Client *source_p);
extern void free_user(struct User *, struct Client *);
extern struct User *make_user(struct Client *);
extern struct Server *make_server(struct Client *);
extern void close_connection(struct Client *);
extern void init_uid(void);
extern char *generate_uid(void);
void allocate_away(struct Client *);
void free_away(struct Client *);
uint32_t connid_get(struct Client *client_p);
void connid_put(uint32_t id);
void client_release_connids(struct Client *client_p);

View file

@ -42,8 +42,7 @@ extern void send_umode_out(struct Client *, struct Client *, int);
extern void show_lusers(struct Client *source_p);
extern int register_local_user(struct Client *, struct Client *);
extern void introduce_client(struct Client *client_p, struct Client *source_p,
struct User *user, const char *nick, int use_euid);
void introduce_client(struct Client *client_p, struct Client *source_p, user &user, const char *nick, int use_euid);
extern void change_nick_user_host(struct Client *target_p, const char *nick, const char *user,
const char *host, int newts, const char *format, ...);

View file

@ -292,17 +292,17 @@ chan::send_join(chan &chan,
client.username,
client.host,
chan.name.c_str(),
EmptyString(client.user->suser)? "*" : client.user->suser,
client.user->suser.empty()? "*" : client.user->suser.c_str(),
client.info);
// Send away message to away-notify enabled clients.
if (client.user->away)
if (!client.user->away.empty())
sendto_channel_local_with_capability_butone(&client, ALL_MEMBERS, CLICAP_AWAY_NOTIFY, NOCAPS, &chan,
":%s!%s@%s AWAY :%s",
client.name,
client.username,
client.host,
client.user->away);
client.user->away.c_str());
}
chan::membership &
@ -817,7 +817,7 @@ chan::can_join(client *source_p, chan *chptr, const char *key, const char **forw
if(chptr->mode.limit && size(chptr->members) >= ulong(chptr->mode.limit))
i = ERR_CHANNELISFULL;
if(chptr->mode.mode & mode::REGONLY && EmptyString(source_p->user->suser))
if(chptr->mode.mode & mode::REGONLY && source_p->user->suser.empty())
i = ERR_NEEDREGGEDNICK;
/* join throttling stuff --nenolod */
else if(chptr->mode.join_num > 0 && chptr->mode.join_time > 0)

View file

@ -41,11 +41,8 @@ static int qs_server(struct Client *, struct Client *, struct Client *, const ch
static EVH check_pings;
static rb_bh *client_heap = NULL;
static rb_bh *lclient_heap = NULL;
static rb_bh *pclient_heap = NULL;
static rb_bh *user_heap = NULL;
static rb_bh *away_heap = NULL;
static char current_uid[IDLEN];
static uint32_t current_connid = 0;
@ -86,11 +83,8 @@ init_client(void)
* start off the check ping event .. -- adrian
* Every 30 seconds is plenty -- db
*/
client_heap = rb_bh_create(sizeof(struct Client), CLIENT_HEAP_SIZE, "client_heap");
lclient_heap = rb_bh_create(sizeof(struct LocalUser), LCLIENT_HEAP_SIZE, "lclient_heap");
pclient_heap = rb_bh_create(sizeof(struct PreClient), PCLIENT_HEAP_SIZE, "pclient_heap");
user_heap = rb_bh_create(sizeof(struct User), USER_HEAP_SIZE, "user_heap");
away_heap = rb_bh_create(AWAYLEN, AWAY_HEAP_SIZE, "away_heap");
rb_event_addish("check_pings", check_pings, NULL, 30);
rb_event_addish("free_exited_clients", &free_exited_clients, NULL, 4);
@ -193,7 +187,7 @@ struct Client *
make_client(struct Client *from)
{
struct LocalUser *localClient;
struct Client *client_p(reinterpret_cast<Client *>(rb_bh_alloc(client_heap)));
struct Client *client_p = new Client;
if(from == NULL)
{
@ -305,7 +299,7 @@ free_client(struct Client *client_p)
free_local_client(client_p);
free_pre_client(client_p);
rb_free(client_p->certfp);
rb_bh_free(client_heap, client_p);
delete client_p;
}
/*
@ -776,14 +770,14 @@ update_client_exit_stats(struct Client *client_p)
static void
release_client_state(struct Client *client_p)
{
if(client_p->user != NULL)
if (client_p->user)
client_p->user.reset();
if (client_p->serv)
{
free_user(client_p->user, client_p); /* try this here */
}
if(client_p->serv)
{
if(client_p->serv->user != NULL)
free_user(client_p->serv->user, client_p);
if (client_p->serv->user)
client_p->serv->user.reset();
if(client_p->serv->fullcaps)
rb_free(client_p->serv->fullcaps);
rb_free(client_p->serv);
@ -1653,9 +1647,8 @@ count_local_client_memory(size_t * count, size_t * local_client_memory_used)
void
count_remote_client_memory(size_t * count, size_t * remote_client_memory_used)
{
size_t lcount, rcount;
size_t lcount(0), rcount(0);
rb_bh_usage(lclient_heap, &lcount, NULL, NULL, NULL);
rb_bh_usage(client_heap, &rcount, NULL, NULL, NULL);
*count = rcount - lcount;
*remote_client_memory_used = *count * (sizeof(void *) + sizeof(struct Client));
}
@ -1774,29 +1767,6 @@ show_ip_whowas(struct Whowas *whowas, struct Client *source_p)
return 1;
}
/*
* make_user
*
* inputs - pointer to client struct
* output - pointer to struct User
* side effects - add's an User information block to a client
* if it was not previously allocated.
*/
struct User *
make_user(struct Client *client_p)
{
struct User *user;
user = client_p->user;
if(!user)
{
user = (struct User *) rb_bh_alloc(user_heap);
user->refcnt = 1;
client_p->user = user;
}
return user;
}
/*
* make_server
*
@ -1818,66 +1788,6 @@ make_server(struct Client *client_p)
return client_p->serv;
}
/*
* free_user
*
* inputs - pointer to user struct
* - pointer to client struct
* output - none
* side effects - Decrease user reference count by one and release block,
* if count reaches 0
*/
void
free_user(struct User *user, struct Client *client_p)
{
free_away(client_p);
if(--user->refcnt <= 0)
{
if(user->away)
rb_free((char *) user->away);
/*
* sanity check
*/
if(user->refcnt < 0 || !user->invited.empty() || !user->channel.empty())
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"* %p user (%s!%s@%s) %p %lu %lu %d *",
client_p,
client_p ? client_p->
name : "<noname>",
client_p->username,
client_p->host,
user,
user->invited.size(),
user->channel.size(),
user->refcnt);
s_assert(!user->refcnt);
s_assert(user->invited.empty());
s_assert(user->channel.empty());
}
rb_bh_free(user_heap, user);
}
}
void
allocate_away(struct Client *client_p)
{
if(client_p->user->away == NULL)
client_p->user->away = reinterpret_cast<char *>(rb_bh_alloc(away_heap));
}
void
free_away(struct Client *client_p)
{
if(client_p->user != NULL && client_p->user->away != NULL) {
rb_bh_free(away_heap, client_p->user->away);
client_p->user->away = NULL;
}
}
void
init_uid(void)
{

View file

@ -599,7 +599,7 @@ burst_TS6(struct Client *client_p)
IsIPSpoof(target_p) ? "0" : target_p->sockhost,
target_p->id,
IsDynSpoof(target_p) ? target_p->orighost : "*",
EmptyString(target_p->user->suser) ? "*" : target_p->user->suser,
target_p->user->suser.empty() ? "*" : target_p->user->suser.c_str(),
target_p->info);
else
sendto_one(client_p, ":%s UID %s %d %ld %s %s %s %s %s :%s",
@ -619,15 +619,17 @@ burst_TS6(struct Client *client_p)
if(IsDynSpoof(target_p))
sendto_one(client_p, ":%s ENCAP * REALHOST %s",
use_id(target_p), target_p->orighost);
if(!EmptyString(target_p->user->suser))
if (!target_p->user->suser.empty())
sendto_one(client_p, ":%s ENCAP * LOGIN %s",
use_id(target_p), target_p->user->suser);
use_id(target_p),
target_p->user->suser.c_str());
}
if(ConfigFileEntry.burst_away && !EmptyString(target_p->user->away))
if(ConfigFileEntry.burst_away && !target_p->user->away.empty())
sendto_one(client_p, ":%s AWAY :%s",
use_id(target_p),
target_p->user->away);
target_p->user->away.c_str());
hclientinfo.target = target_p;
call_hook(h_burst_client, &hclientinfo);

View file

@ -320,7 +320,7 @@ int
register_local_user(struct Client *client_p, struct Client *source_p)
{
struct ConfItem *aconf, *xconf;
struct User *user = source_p->user;
const auto user(source_p->user.get());
char tmpstr2[BUFSIZE];
char ipaddr[HOSTIPLEN];
char myusername[USERLEN+1];
@ -452,7 +452,7 @@ register_local_user(struct Client *client_p, struct Client *source_p)
}
}
if(IsNeedSasl(aconf) && !*user->suser)
if(IsNeedSasl(aconf) && user->suser.empty())
{
ServerStats.is_ref++;
sendto_one_notice(source_p, ":*** Notice -- You need to identify via SASL to use this server");
@ -637,7 +637,7 @@ register_local_user(struct Client *client_p, struct Client *source_p)
free_pre_client(source_p);
introduce_client(client_p, source_p, user, source_p->name, 1);
introduce_client(client_p, source_p, *user, source_p->name, 1);
return 0;
}
@ -651,7 +651,7 @@ register_local_user(struct Client *client_p, struct Client *source_p)
* from a remote connect.
*/
void
introduce_client(struct Client *client_p, struct Client *source_p, struct User *user, const char *nick, int use_euid)
introduce_client(struct Client *client_p, struct Client *source_p, user &user, const char *nick, int use_euid)
{
char ubuf[BUFSIZE];
struct Client *identifyservice_p;
@ -682,7 +682,7 @@ introduce_client(struct Client *client_p, struct Client *source_p, struct User *
IsIPSpoof(source_p) ? "0" : source_p->sockhost,
source_p->id,
IsDynSpoof(source_p) ? source_p->orighost : "*",
EmptyString(source_p->user->suser) ? "*" : source_p->user->suser,
source_p->user->suser.empty()? "*" : source_p->user->suser.c_str(),
source_p->info);
sendto_server(client_p, NULL, CAP_TS6, use_euid ? CAP_EUID : NOCAPS,
@ -705,10 +705,10 @@ introduce_client(struct Client *client_p, struct Client *source_p, struct User *
use_id(source_p), source_p->orighost);
}
if (!EmptyString(source_p->user->suser))
if (!source_p->user->suser.empty())
{
sendto_server(client_p, NULL, CAP_TS6, use_euid ? CAP_EUID : NOCAPS, ":%s ENCAP * LOGIN %s",
use_id(source_p), source_p->user->suser);
use_id(source_p), source_p->user->suser.c_str());
}
if(MyConnect(source_p) && source_p->localClient->passwd)
@ -1523,7 +1523,7 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use
":%s!%s@%s JOIN %s", nick, user, host, chan.name.c_str());
sendto_channel_local_with_capability_butone(target_p, chan::ALL_MEMBERS, CLICAP_EXTENDED_JOIN, CLICAP_CHGHOST, &chan,
":%s!%s@%s JOIN %s %s :%s", nick, user, host, chan.name.c_str(),
EmptyString(target_p->user->suser) ? "*" : target_p->user->suser,
target_p->user->suser.empty()? "*" : target_p->user->suser.c_str(),
target_p->info);
if(*mode)
@ -1534,10 +1534,10 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use
}
/* Resend away message to away-notify enabled clients. */
if (target_p->user->away)
if (!target_p->user->away.empty())
sendto_common_channels_local_butone(target_p, CLICAP_AWAY_NOTIFY, CLICAP_CHGHOST, ":%s!%s@%s AWAY :%s",
nick, user, host,
target_p->user->away);
target_p->user->away.c_str());
sendto_common_channels_local_butone(target_p, CLICAP_CHGHOST, NOCAPS,
":%s!%s@%s CHGHOST %s %s",

View file

@ -42,8 +42,8 @@ cap_account_tag_process(hook_data *data)
{
struct MsgBuf *msgbuf = (MsgBuf *)data->arg1;
if (data->client != NULL && IsPerson(data->client) && *data->client->user->suser)
msgbuf_append_tag(msgbuf, "account", data->client->user->suser, CLICAP_ACCOUNT_TAG);
if (data->client != NULL && IsPerson(data->client) && !data->client->user->suser.empty())
msgbuf_append_tag(msgbuf, "account", data->client->user->suser.c_str(), CLICAP_ACCOUNT_TAG);
}
DECLARE_MODULE_AV2(cap_account_tag, NULL, NULL, NULL, NULL, cap_account_tag_hfnlist, cap_account_tag_cap_list, NULL, cap_account_tag_desc);

View file

@ -787,9 +787,9 @@ msg_client(enum message_type msgtype,
return;
}
if(MyConnect(source_p) && (msgtype != MESSAGE_TYPE_NOTICE) && target_p->user && target_p->user->away)
if(MyConnect(source_p) && (msgtype != MESSAGE_TYPE_NOTICE) && target_p->user && target_p->user->away.size())
sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
target_p->name, target_p->user->away);
target_p->name, target_p->user->away.c_str());
if(MyClient(target_p))
{
@ -818,7 +818,7 @@ msg_client(enum message_type msgtype,
/* XXX Controversial? allow opers always to send through a +g */
if(!IsServer(source_p) && (IsSetCallerId(target_p) ||
(IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])))
(IsSetRegOnlyMsg(target_p) && source_p->user->suser.empty())))
{
/* Here is the anti-flood bot/spambot code -db */
if(accept_message(source_p, target_p) || IsOper(source_p))
@ -829,7 +829,7 @@ msg_client(enum message_type msgtype,
source_p->username,
source_p->host, cmdname[msgtype], target_p->name, text);
}
else if (IsSetRegOnlyMsg(target_p) && !source_p->user->suser[0])
else if (IsSetRegOnlyMsg(target_p) && source_p->user->suser.empty())
{
if (msgtype != MESSAGE_TYPE_NOTICE)
sendto_one_numeric(source_p, ERR_NONONREG,

View file

@ -990,13 +990,12 @@ register_client(struct Client *client_p, struct Client *server,
const char *nick, time_t newts, int parc, const char *parv[])
{
struct Client *source_p;
struct User *user;
struct nd_entry *nd;
const char *m;
int flag;
source_p = make_client(client_p);
user = make_user(source_p);
source_p->user.reset(new user);
rb_dlinkAddTail(source_p, &source_p->node, &global_client_list);
source_p->hopcount = atoi(parv[2]);
@ -1020,7 +1019,7 @@ register_client(struct Client *client_p, struct Client *server,
SetDynSpoof(source_p);
}
if (strcmp(parv[10], "*"))
rb_strlcpy(source_p->user->suser, parv[10], sizeof(source_p->user->suser));
source_p->user->suser = parv[10];
}
else if(parc == 10)
{
@ -1094,7 +1093,7 @@ register_client(struct Client *client_p, struct Client *server,
call_hook(h_new_remote_user, source_p);
introduce_client(client_p, source_p, user, nick, parc == 12);
introduce_client(client_p, source_p, *source_p->user, nick, parc == 12);
}
/* Check if we can do SAVE. target_p can be a client to save or a

View file

@ -68,12 +68,11 @@ m_away(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
if(parc < 2 || EmptyString(parv[1]))
{
/* Marking as not away */
if(source_p->user->away != NULL)
if(source_p->user->away.size())
{
/* we now send this only if they were away before --is */
sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
":%s AWAY", use_id(source_p));
free_away(source_p);
sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, NOCAPS, ":%s!%s@%s AWAY",
source_p->name, source_p->username, source_p->host);
@ -101,20 +100,25 @@ m_away(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
ConfigFileEntry.away_interval;
}
if(source_p->user->away == NULL)
allocate_away(source_p);
if(strncmp(source_p->user->away, parv[1], AWAYLEN - 1))
std::string p1(parv[1]);
if (p1.size() >= AWAYLEN)
p1.resize(AWAYLEN-1);
if (source_p->user->away != p1)
{
rb_strlcpy(source_p->user->away, parv[1], AWAYLEN);
source_p->user->away = std::move(p1);
sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
":%s AWAY :%s", use_id(source_p), source_p->user->away);
":%s AWAY :%s",
use_id(source_p),
source_p->user->away.c_str());
sendto_common_channels_local_butone(source_p,
CLICAP_AWAY_NOTIFY, NOCAPS,
":%s!%s@%s AWAY :%s",
source_p->name,
source_p->username,
source_p->host,
source_p->user->away);
source_p->user->away.c_str());
}
if(MyConnect(source_p))

View file

@ -142,7 +142,7 @@ m_invite(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
* for +l/+j just check if the mode is set, this varies over time
*/
if(chptr->mode.mode & chan::mode::INVITEONLY ||
(chptr->mode.mode & chan::mode::REGONLY && EmptyString(target_p->user->suser)) ||
(chptr->mode.mode & chan::mode::REGONLY && target_p->user->suser.empty()) ||
chptr->mode.limit || chptr->mode.join_num)
store_invite = 1;
@ -159,9 +159,9 @@ m_invite(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
sendto_one(source_p, form_str(RPL_INVITING),
me.name, source_p->name,
target_p->name, parv[2]);
if(target_p->user->away)
if(target_p->user->away.size())
sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
target_p->name, target_p->user->away);
target_p->name, target_p->user->away.c_str());
}
/* invite timestamp */
else if(parc > 3 && !EmptyString(parv[3]))

View file

@ -115,13 +115,13 @@ me_su(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
return;
if(EmptyString(parv[2]))
target_p->user->suser[0] = '\0';
target_p->user->suser.clear();
else
rb_strlcpy(target_p->user->suser, parv[2], sizeof(target_p->user->suser));
target_p->user->suser = parv[2];
sendto_common_channels_local_butone(target_p, CLICAP_ACCOUNT_NOTIFY, NOCAPS, ":%s!%s@%s ACCOUNT %s",
target_p->name, target_p->username, target_p->host,
EmptyString(target_p->user->suser) ? "*" : target_p->user->suser);
target_p->user->suser.empty()? "*" : target_p->user->suser.c_str());
chan::invalidate_bancache_user(target_p);
}
@ -133,7 +133,7 @@ me_login(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
if(!IsPerson(source_p))
return;
rb_strlcpy(source_p->user->suser, parv[1], sizeof(source_p->user->suser));
source_p->user->suser = parv[1];
}
static void
@ -293,22 +293,25 @@ h_svc_server_introduced(hook_data_client *hdata)
static void
h_svc_whois(hook_data_client *data)
{
char *p = data->target->user->suser;
if(!EmptyString(p))
{
/* Try to strip off any leading digits as this may be used to
* store both an ID number and an account name in one field.
* If only digits are present, leave as is.
*/
while(rfc1459::is_digit(*p))
p++;
if(*p == '\0')
p = data->target->user->suser;
const auto &suser(data->target->user->suser);
if (suser.empty())
return;
sendto_one_numeric(data->client, RPL_WHOISLOGGEDIN,
form_str(RPL_WHOISLOGGEDIN),
data->target->name, p);
}
/* Try to strip off any leading digits as this may be used to
* store both an ID number and an account name in one field.
* If only digits are present, leave as is.
*/
const char *p(suser.c_str());
while(rfc1459::is_digit(*p))
p++;
if(*p == '\0')
p = suser.c_str();
sendto_one_numeric(data->client, RPL_WHOISLOGGEDIN,
form_str(RPL_WHOISLOGGEDIN),
data->target->name,
p);
}
static void

View file

@ -144,7 +144,7 @@ me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
if(*parv[5] == '*')
{
if(target_p->user)
rb_strlcpy(login, target_p->user->suser, NICKLEN + 1);
rb_strlcpy(login, target_p->user->suser.c_str(), NICKLEN + 1);
else
login[0] = '\0';
}
@ -199,8 +199,6 @@ me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
if(IsUnknown(target_p))
{
struct User *user_p = make_user(target_p);
if(valid & NICK_VALID)
rb_strlcpy(target_p->preClient->spoofnick, nick, sizeof(target_p->preClient->spoofnick));
@ -210,7 +208,7 @@ me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
if(valid & HOST_VALID)
rb_strlcpy(target_p->preClient->spoofhost, host, sizeof(target_p->preClient->spoofhost));
rb_strlcpy(user_p->suser, login, NICKLEN + 1);
target_p->user = std::make_unique<struct user>(login);
}
else
{
@ -391,7 +389,7 @@ send_signon(struct Client *client_p, struct Client *target_p,
use_id(target_p), nick, user, host,
(long) target_p->tsinfo, *login ? login : "0");
rb_strlcpy(target_p->user->suser, login, sizeof(target_p->user->suser));
target_p->user->suser = login;
change_nick_user_host(target_p, nick, user, host, newts, "Signing %s (%s)", *login ? "in" : "out", nick);
}

View file

@ -836,7 +836,7 @@ stats_operedup (struct Client *source_p)
if(IsOperInvis(target_p) && !IsOper(source_p))
continue;
if(target_p->user->away)
if(target_p->user->away.size())
continue;
count++;
@ -1337,10 +1337,10 @@ stats_memory (struct Client *source_p)
users_counted++;
users_invited_count += target_p->user->invited.size();
user_channels += target_p->user->channel.size();
if(target_p->user->away)
if(target_p->user->away.size())
{
aways_counted++;
away_memory += (strlen(target_p->user->away) + 1);
away_memory += target_p->user->away.size() + 1;
}
}
}
@ -1377,7 +1377,7 @@ stats_memory (struct Client *source_p)
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"z :Users %u(%lu) Invites %u(%lu)",
users_counted,
(unsigned long) users_counted * sizeof(struct User),
(unsigned long) users_counted * sizeof(struct user),
users_invited_count,
(unsigned long) users_invited_count * sizeof(rb_dlink_node));

View file

@ -78,7 +78,7 @@ do_local_user(struct Client *client_p, struct Client *source_p,
s_assert(NULL != source_p);
s_assert(source_p->username != username);
make_user(source_p);
source_p->user.reset(new user);
source_p->flags |= FLAGS_SENTUSER;

View file

@ -76,7 +76,7 @@ m_userhost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
rl = sprintf(response, "%s%s=%c%s@%s ",
target_p->name,
IsOper(target_p) ? "*" : "",
(target_p->user->away) ? '-' : '+',
(target_p->user->away.size())? '-' : '+',
target_p->username,
target_p->sockhost);
}
@ -85,7 +85,7 @@ m_userhost(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sour
rl = sprintf(response, "%s%s=%c%s@%s ",
target_p->name,
IsOper(target_p) ? "*" : "",
(target_p->user->away) ? '-' : '+',
(target_p->user->away.size())? '-' : '+',
target_p->username, target_p->host);
}

View file

@ -464,7 +464,7 @@ do_who(struct Client *source_p, struct Client *target_p, chan::chan *chan, chan:
const char *q;
sprintf(status, "%c%s%s",
target_p->user->away ? 'G' : 'H', IsOper(target_p) ? "*" : "", msptr ? find_status(msptr, fmt->fields || IsCapable(source_p, CLICAP_MULTI_PREFIX)) : "");
target_p->user->away.size()? 'G' : 'H', IsOper(target_p) ? "*" : "", msptr ? find_status(msptr, fmt->fields || IsCapable(source_p, CLICAP_MULTI_PREFIX)) : "");
if (fmt->fields == 0)
sendto_one(source_p, form_str(RPL_WHOREPLY), me.name,
@ -507,13 +507,13 @@ do_who(struct Client *source_p, struct Client *target_p, chan::chan *chan, chan:
if (fmt->fields & FIELD_ACCOUNT)
{
/* display as in whois */
q = target_p->user->suser;
q = target_p->user->suser.c_str();
if (!EmptyString(q))
{
while(rfc1459::is_digit(*q))
q++;
if(*q == '\0')
q = target_p->user->suser;
q = target_p->user->suser.c_str();
}
else
q = "0";

View file

@ -288,9 +288,9 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy)
target_p->name, target_p->servptr->name,
target_p->servptr->info);
if(target_p->user->away)
if(target_p->user->away.size())
sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
target_p->name, target_p->user->away);
target_p->name, target_p->user->away.c_str());
if(IsOper(target_p) && (!ConfigFileEntry.hide_opers_in_whois || IsOper(source_p)))
{