本文整理汇总了C++中s_assert函数的典型用法代码示例。如果您正苦于以下问题:C++ s_assert函数的具体用法?C++ s_assert怎么用?C++ s_assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s_assert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: comm_setselect
/*
* comm_setselect
*
* This is a needed exported function which will be called to register
* and deregister interest in a pending IO state for a given FD.
*/
void
comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
void *client_data, time_t timeout)
{
fde_t *F = &fd_table[fd];
s_assert(fd >= 0);
s_assert(F->flags.open);
if(type & COMM_SELECT_READ)
{
F->read_handler = handler;
F->read_data = client_data;
poll_update_pollfds(fd, POLLRDNORM, handler);
}
if(type & COMM_SELECT_WRITE)
{
F->write_handler = handler;
F->write_data = client_data;
poll_update_pollfds(fd, POLLWRNORM, handler);
}
if(timeout)
F->timeout = CurrentTime + (timeout / 1000);
}
示例2: comm_setselect
/*
* comm_setselect
*
* This is a needed exported function which will be called to register
* and deregister interest in a pending IO state for a given FD.
*/
void
comm_setselect(int fd, fdlist_t list, unsigned int type, PF * handler,
void *client_data)
{
fde_t *F = &fd_table[fd];
s_assert(fd >= 0);
s_assert(F->flags.open);
/* Update the list, even though we're not using it .. */
F->list = list;
if(type & COMM_SELECT_READ)
{
kq_update_events(F, EVFILT_READ, handler);
F->read_handler = handler;
F->read_data = client_data;
}
if(type & COMM_SELECT_WRITE)
{
kq_update_events(F, EVFILT_WRITE, handler);
F->write_handler = handler;
F->write_data = client_data;
}
}
示例3: mod_add_cmd
/* mod_add_cmd
*
* inputs - command name
* - pointer to struct Message
* output - none
* side effects - load this one command name
* msg->count msg->bytes is modified in place, in
* modules address space. Might not want to do that...
*/
void
mod_add_cmd(struct Message *msg)
{
s_assert(msg != NULL);
if(msg == NULL)
return;
if(hash_find(HASH_COMMAND, msg->cmd) != NULL)
return;
hash_add(HASH_COMMAND, msg->cmd, msg);
msg->count = 0;
msg->rcount = 0;
msg->bytes = 0;
}
示例4: mr_starttls
static int
mr_starttls(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
#ifdef HAVE_LIBCRYPTO
ssl_ctl_t *ctl;
rb_fde_t *F[2];
if (!MyConnect(client_p))
return 0;
if (!ssl_ok || !get_ssld_count())
{
sendto_one_numeric(client_p, ERR_STARTTLS, form_str(ERR_STARTTLS), "TLS is not configured");
return 1;
}
if (rb_socketpair(AF_UNIX, SOCK_STREAM, 0, &F[0], &F[1], "STARTTLS ssld session") == -1)
{
ilog_error("error creating SSL/TLS socketpair for ssld slave");
sendto_one_numeric(client_p, ERR_STARTTLS, form_str(ERR_STARTTLS), "Unable to create SSL/TLS socketpair for ssld offload slave");
return 1;
}
s_assert(client_p->localClient != NULL);
/* clear out any remaining plaintext lines */
rb_linebuf_donebuf(&client_p->localClient->buf_recvq);
sendto_one_numeric(client_p, RPL_STARTTLS, form_str(RPL_STARTTLS));
send_queued(client_p);
ctl = start_ssld_accept(client_p->localClient->F, F[1], rb_get_fd(F[0]));
if (ctl != NULL)
{
del_from_cli_fd_hash(client_p);
client_p->localClient->F = F[0];
add_to_cli_fd_hash(client_p);
client_p->localClient->ssl_ctl = ctl;
SetSSL(client_p);
}
else
return 1;
#else
sendto_one_numeric(client_p, ERR_STARTTLS, form_str(ERR_STARTTLS), "TLS is not configured");
#endif
return 0;
}
示例5: poll_findslot
/*
* find a spare slot in the fd list. We can optimise this out later!
* -- adrian
*/
static inline int
poll_findslot(void)
{
int i;
for (i = 0; i < MAXCONNECTIONS; i++)
{
if(pollfd_list.pollfds[i].fd == -1)
{
/* MATCH!!#$*&$ */
return i;
}
}
s_assert(1 == 0);
/* NOTREACHED */
return -1;
}
示例6: clean_user_name
/* clean_user_name()
*
* input - username
* output - none
* side effects - walks through the username, returning 0 if erroneous
*/
static int
clean_user_name(char *user)
{
s_assert(user);
if(user == NULL)
return 0;
for (; *user; user++)
{
if(!IsUserChar(*user))
return 0;
}
return 1;
}
示例7: mod_add_cmd
/* mod_add_cmd
*
* inputs - command name
* - pointer to struct Message
* output - none
* side effects - load this one command name
* msg->count msg->bytes is modified in place, in
* modules address space. Might not want to do that...
*/
void
mod_add_cmd(struct Message *msg)
{
s_assert(msg != NULL);
if(msg == NULL)
return;
if (rb_dictionary_find(cmd_dict, msg->cmd) != NULL)
return;
msg->count = 0;
msg->rcount = 0;
msg->bytes = 0;
rb_dictionary_add(cmd_dict, msg->cmd, msg);
}
示例8: add_history
void
add_history(struct Client *client_p, int online)
{
struct Whowas *who = &WHOWAS[whowas_next];
s_assert(NULL != client_p);
if(client_p == NULL)
return;
if(who->hashv != -1)
{
if(who->online)
del_whowas_from_clist(&(who->online->whowas), who);
del_whowas_from_list(&WHOWASHASH[who->hashv], who);
}
who->hashv = hash_whowas_name(client_p->name);
who->logoff = rb_current_time();
/*
* NOTE: strcpy ok here, the sizes in the client struct MUST
* match the sizes in the whowas struct
*/
rb_strlcpy(who->name, client_p->name, sizeof(who->name));
strcpy(who->username, client_p->username);
strcpy(who->hostname, client_p->host);
strcpy(who->realname, client_p->info);
strcpy(who->suser, client_p->user->suser);
if(!EmptyString(client_p->sockhost) && strcmp(client_p->sockhost, "0")
&& show_ip(NULL, client_p))
strcpy(who->sockhost, client_p->sockhost);
else
who->sockhost[0] = '\0';
who->servername = scache_get_name(client_p->servptr->serv->nameinfo);
if(online)
{
who->online = client_p;
add_whowas_to_clist(&(client_p->whowas), who);
}
else
who->online = NULL;
add_whowas_to_list(&WHOWASHASH[who->hashv], who);
whowas_next++;
if(whowas_next == NICKNAMEHISTORYLENGTH)
whowas_next = 0;
}
示例9: close_listener
/*
* close_listener - close a single listener
*/
void
close_listener(struct Listener *listener)
{
s_assert(listener != NULL);
if(listener == NULL)
return;
if(listener->F != NULL) {
rb_close(listener->F);
listener->F = NULL;
}
listener->active = 0;
if(listener->ref_count)
return;
free_listener(listener);
}
示例10: fbgetc
int
fbgetc(FBFILE * fb)
{
s_assert(fb);
if(fb == NULL)
{
errno = EINVAL;
return -1;
}
if(fb->pbptr)
{
if((fb->pbptr == (fb->pbuf + BUFSIZ)) || (!*fb->pbptr))
fb->pbptr = NULL;
}
if(fb->ptr < fb->endp || fbfill(fb) > 0)
return *fb->ptr++;
return EOF;
}
示例11: s_assert
void Graphics::Initialize(const GraphicsConfig &config)
{
s_assert(!Available());
mConfig = config;
switch (mConfig.Type)
{
case GraphicsType::OPENGL3:
mCanvas = new OpenGLCanvas;
mRenderer = new OpenGLRenderer;
mResourceManager = new OpenGLGraphicsResourceManager;
break;
default:
GetLog().Error("[Graphics::Initialize] unsupport GraphicsType!\n");
break;
}
mRenderer->Initialize(mConfig);
mCanvas->Initialize();
mResourceManager->Initialize(mConfig);
}
示例12: clean_nick_name
/* clean_nick_name()
*
* input - nickname
* output - none
* side effects - walks through the nickname, returning 0 if erroneous
*/
static int
clean_nick_name(char *nick)
{
s_assert(nick);
if(nick == NULL)
return 0;
/* nicks cant start with a digit or -, and must have a length */
if(*nick == '-' || IsDigit(*nick) || !*nick)
return 0;
for (; *nick; nick++)
{
if(!IsNickChar(*nick))
return 0;
}
return 1;
}
示例13: close_listener
/*
* close_listener - close a single listener
*/
void
close_listener(struct Listener *listener)
{
s_assert(listener != NULL);
if(listener == NULL)
return;
if(listener->fd >= 0)
{
comm_close(listener->fd);
listener->fd = -1;
}
listener->active = 0;
if(listener->ref_count)
return;
free_listener(listener);
}
示例14: fbungetc
void
fbungetc(char c, FBFILE * fb)
{
s_assert(fb);
if(fb == NULL)
{
errno = EINVAL;
return;
}
if(!fb->pbptr)
{
fb->pbptr = fb->pbuf + BUFSIZ;
}
if(fb->pbptr != fb->pbuf)
{
fb->pbptr--;
*fb->pbptr = c;
}
}
示例15: get_listener_name
/*
* get_listener_name - return displayable listener name and port
* returns "host.foo.org:6667" for a given listener
*/
const char *
get_listener_name(const struct Listener *listener)
{
static char buf[HOSTLEN + HOSTLEN + PORTNAMELEN + 4];
int port = 0;
s_assert(NULL != listener);
if(listener == NULL)
return NULL;
#ifdef RB_IPV6
if(listener->addr.ss_family == AF_INET6)
port = ntohs(((const struct sockaddr_in6 *)&listener->addr)->sin6_port);
else
#endif
port = ntohs(((const struct sockaddr_in *)&listener->addr)->sin_port);
rb_snprintf(buf, sizeof(buf), "%s[%s/%u]", me.name, listener->name, port);
return buf;
}