当前位置: 首页>>代码示例>>C++>>正文


C++ rb_strlcpy函数代码示例

本文整理汇总了C++中rb_strlcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_strlcpy函数的具体用法?C++ rb_strlcpy怎么用?C++ rb_strlcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rb_strlcpy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rsdb_init

int
rsdb_init(rsdb_error_cb * ecb)
{
    const char *bandb_dbpath_env;
    char dbpath[PATH_MAX];
    char errbuf[128];
    error_cb = ecb;

    /* try a path from the environment first, useful for basedir overrides */
    bandb_dbpath_env = getenv("BANDB_DBPATH");

    if(bandb_dbpath_env != NULL)
        rb_strlcpy(dbpath, bandb_dbpath_env, sizeof(dbpath));
    else
        rb_strlcpy(dbpath, DBPATH, sizeof(dbpath));

    if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK) {
        snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
                 sqlite3_errmsg(rb_bandb));
        mlog(errbuf);
        return -1;
    }
    if(access(dbpath, W_OK)) {
        snprintf(errbuf, sizeof(errbuf),  "Unable to open sqlite database for write: %s", strerror(errno));
        mlog(errbuf);
        return -1;
    }
    return 0;
}
开发者ID:CustomIRCd,项目名称:elemental-ircd,代码行数:29,代码来源:rsdb_sqlite3.c

示例2: do_local_user

static int
do_local_user(struct Client *client_p, struct Client *source_p,
              const char *username, const char *realname)
{
    s_assert(NULL != source_p);
    s_assert(source_p->username != username);

    make_user(source_p);

    lookup_blacklists(source_p);
    source_p->flags |= FLAGS_SENTUSER;

    rb_strlcpy(source_p->info, realname, sizeof(source_p->info));

    if(!IsGotId(source_p))
        rb_strlcpy(source_p->username, username, sizeof(source_p->username));

    if(source_p->name[0])
    {
        /* NICK already received, now I have USER... */
        return register_local_user(client_p, source_p);
    }

    return 0;
}
开发者ID:ntchambers,项目名称:charybdis,代码行数:25,代码来源:m_user.c

示例3: do_local_user

static int
do_local_user(struct Client *client_p, struct Client *source_p,
	      const char *username, const char *realname)
{
	s_assert(NULL != source_p);
	s_assert(source_p->username != username);

	make_user(source_p);

	if (!(source_p->flags & FLAGS_SENTUSER))
	{
		lookup_blacklists(source_p);
		source_p->flags |= FLAGS_SENTUSER;
	}

	rb_strlcpy(source_p->info, realname, sizeof(source_p->info));

	if(!IsGotId(source_p))
	{
		/* This is in this location for a reason..If there is no identd
		 * and ping cookies are enabled..we need to have a copy of this
		 */
		rb_strlcpy(source_p->username, username, sizeof(source_p->username));
	}

	if(source_p->name[0])
	{
		/* NICK already received, now I have USER... */
		return register_local_user(client_p, source_p, username);
	}

	return 0;
}
开发者ID:Acidburn0zzz,项目名称:charybdis,代码行数:33,代码来源:m_user.c

示例4: match_ips

/*
 * match_ips()
 *
 * Input - cidr ip mask, address
 */
int
match_ips(const char *s1, const char *s2)
{
	struct rb_sockaddr_storage ipaddr, maskaddr;
	char mask[IRCD_BUFSIZE];
	char address[HOSTLEN + 1];
	char *len;
	void *ipptr, *maskptr;
	int cidrlen, aftype;

	rb_strlcpy(mask, s1, sizeof(mask));
	rb_strlcpy(address, s2, sizeof(address));

	len = strrchr(mask, '/');
	if(len == NULL)
		return 0;

	*len++ = '\0';

	cidrlen = atoi(len);
	if(cidrlen <= 0)
		return 0;

#ifdef RB_IPV6
	if(strchr(mask, ':') && strchr(address, ':'))
	{
		if(cidrlen > 128)
			return 0;	
        
		aftype = AF_INET6;
		ipptr = &((struct sockaddr_in6 *)&ipaddr)->sin6_addr;
		maskptr = &((struct sockaddr_in6 *)&maskaddr)->sin6_addr;
	}
	else
#endif
	if(!strchr(mask, ':') && !strchr(address, ':'))
	{
		if(cidrlen > 32)
			return 0;
		aftype = AF_INET;
		ipptr = &((struct sockaddr_in *)&ipaddr)->sin_addr;
		maskptr = &((struct sockaddr_in *)&maskaddr)->sin_addr;
	}
	else
		return 0;

	if(rb_inet_pton(aftype, address, ipptr) <= 0)
		return 0;
	if(rb_inet_pton(aftype, mask, maskptr) <= 0)
		return 0;
	if(comp_with_mask(ipptr, maskptr, cidrlen))
		return 1;
	else
		return 0;
}
开发者ID:ratbox-mirrors,项目名称:ircd-ratbox,代码行数:60,代码来源:match.c

示例5: m_part

/*
** m_part
**      parv[1] = channel
**      parv[2] = reason
*/
static int
m_part(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    char *p, *name;
    char reason[REASONLEN + 1];
    char *s = LOCAL_COPY(parv[1]);

    reason[0] = '\0';

    if(parc > 2)
        rb_strlcpy(reason, parv[2], sizeof(reason));

    name = rb_strtok_r(s, ",", &p);

    /* Finish the flood grace period... */
    if(MyClient(source_p) && !IsFloodDone(source_p))
        flood_endgrace(source_p);

    while(name)
    {
        part_one_client(client_p, source_p, name, reason);
        name = rb_strtok_r(NULL, ",", &p);
    }
    return 0;
}
开发者ID:carriercomm,项目名称:blitzed-charybdis,代码行数:30,代码来源:m_part.c

示例6: h_can_send

static void
h_can_send(void *vdata)
{
    char *text, *filtered;
    hook_data_channel_approval *data = (hook_data_channel_approval *) vdata;

    if(data->chptr->mode.mode & mymode &&
            ((strchr(ConfigChannel.exemptchanops, 'c') == NULL) ||
             !is_any_op(data->msptr)))
    {
        /* colour == 3 */
        text = ((char **)data->data)[3];

        /* Filtered == 0 */
        filtered = ((char **)data->data)[0];

        if (EmptyString(text))
        {
            if(data->cmd == COMMAND_PRIVMSG)
                sendto_one(data->client, form_str(ERR_NOTEXTTOSEND), me.name, data->client->name);
            data->approved = CAN_SEND_NO_NONOTIFY;
            return;
        }

        /* Copy coloured into filtered */
        rb_strlcpy(filtered, text, BUFSIZE);
    }

    return;
}
开发者ID:alyx,项目名称:sporksircd,代码行数:30,代码来源:chm_nocolour.c

示例7: mr_pong

static int
mr_pong(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	if(parc == 2 && !EmptyString(parv[1]))
	{
		if(ConfigFileEntry.ping_cookie && source_p->flags & FLAGS_SENTUSER && source_p->name[0])
		{
			unsigned long incoming_ping = strtoul(parv[1], NULL, 16);
			if(incoming_ping)
			{
				if(source_p->localClient->random_ping == incoming_ping)
				{
					char buf[USERLEN + 1];
					rb_strlcpy(buf, source_p->username, sizeof(buf));
					source_p->flags |= FLAGS_PING_COOKIE;
					register_local_user(client_p, source_p, buf);
				}
				else
				{
					sendto_one(source_p, form_str(ERR_WRONGPONG),
						   me.name, source_p->name,
						   source_p->localClient->random_ping);
					return 0;
				}
			}
		}

	}
	else
		sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, source_p->name);

	source_p->flags &= ~FLAGS_PINGSENT;

	return 0;
}
开发者ID:alyx,项目名称:sporksircd,代码行数:35,代码来源:m_pong.c

示例8: m_away

/*
** m_away
**      parv[1] = away message
*/
static int
m_away(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
    if(MyClient(source_p) && source_p->localClient->next_away &&
       !IsFloodDone(source_p))
        flood_endgrace(source_p);

    if(!IsClient(source_p))
        return 0;

    if(parc < 2 || EmptyString(parv[1])) {
        /* Marking as not away */
        if(source_p->user->away != NULL) {
            /* 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!%[email protected]%s AWAY",
                                                source_p->name, source_p->username, source_p->host);
        }
        if(MyConnect(source_p))
            sendto_one_numeric(source_p, RPL_UNAWAY, form_str(RPL_UNAWAY));
        return 0;
    }

    /* Rate limit this because it is sent to common channels. */
    if (MyClient(source_p)) {
        if(!IsOper(source_p) &&
           source_p->localClient->next_away > rb_current_time()) {
            sendto_one(source_p, form_str(RPL_LOAD2HI),
                       me.name, source_p->name, "AWAY");
            return 0;
        }
        if(source_p->localClient->next_away < rb_current_time() -
           ConfigFileEntry.away_interval)
            source_p->localClient->next_away = rb_current_time();
        else
            source_p->localClient->next_away = rb_current_time() +
                                               ConfigFileEntry.away_interval;
    }


    if(source_p->user->away == NULL)
        allocate_away(source_p);
    if(strncmp(source_p->user->away, parv[1], AWAYLEN - 1)) {
        rb_strlcpy(source_p->user->away, parv[1], AWAYLEN);
        sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
                      ":%s AWAY :%s", use_id(source_p), source_p->user->away);
    }

    if(MyConnect(source_p))
        sendto_one_numeric(source_p, RPL_NOWAWAY, form_str(RPL_NOWAWAY));

    sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, NOCAPS, ":%s!%[email protected]%s AWAY :%s",
                                        source_p->name, source_p->username, source_p->host,
                                        source_p->user->away);

    return 0;
}
开发者ID:CustomIRCd,项目名称:elemental-ircd,代码行数:64,代码来源:m_away.c

示例9: rb_strerror

char *
rb_strerror(int error)
{
	static char buf[128];
	rb_strlcpy(buf, _rb_strerror(error), sizeof(buf));
	return buf;
}
开发者ID:ahf,项目名称:charybdis,代码行数:7,代码来源:win32.c

示例10: find_or_add

static struct scache_entry *
find_or_add(const char *name)
{
	int hash_index;
	struct scache_entry *ptr;

	ptr = scache_hash[hash_index = sc_hash(name)];
	for (; ptr; ptr = ptr->next)
	{
		if(!irccmp(ptr->name, name))
			return ptr;
	}

	ptr = (struct scache_entry *) rb_malloc(sizeof(struct scache_entry));
	s_assert(0 != ptr);

	rb_strlcpy(ptr->name, name, sizeof(ptr->name));
	ptr->info[0] = '\0';
	ptr->flags = 0;
	ptr->known_since = rb_current_time();
	ptr->last_connect = 0;
	ptr->last_split = 0;

	ptr->next = scache_hash[hash_index];
	scache_hash[hash_index] = ptr;
	return ptr;
}
开发者ID:Cloudxtreme,项目名称:ircd-seven,代码行数:27,代码来源:scache.c

示例11: m_quit

/*
** m_quit
**      parv[1] = comment
*/
static int
m_quit(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	char comment[REASONLEN + 1]; /* Better safe than sorry */
	char reason[REASONLEN + 1];

	source_p->flags |= FLAGS_NORMALEX;

	strip_colour((parc > 1 && parv[1]) ? parv[1] : client_p->name, comment, REASONLEN);

	if(ConfigFileEntry.client_exit && comment[0])
	{
		rb_snprintf(reason, sizeof(reason), "Quit: %s", comment);
		rb_strlcpy(comment, reason, REASONLEN + 1);
	}

	if(!IsOper(source_p) && !EmptyString(ConfigFileEntry.static_quit))
	{
		exit_client(client_p, source_p, source_p, ConfigFileEntry.static_quit);
		return 0;
	}

	if(!IsOper(source_p) &&
	   (source_p->localClient->firsttime + ConfigFileEntry.anti_spam_exit_message_time) >
	   rb_current_time())
	{
		exit_client(client_p, source_p, source_p, "Client Quit");
		return 0;
	}

	exit_client(client_p, source_p, source_p, comment);

	return 0;
}
开发者ID:fgt-transit,项目名称:aFailIRCd,代码行数:38,代码来源:m_quit.c

示例12: parse_resvconf

/* parse_resvconf()
 *
 * inputs - NONE
 * output - -1 if failure 0 if success
 * side effects - fills in irc_nsaddr_list
 */
static int
parse_resvconf(void)
{
  char *p;
  char *opt;
  char *arg;
  char input[DNS_MAXLINE];
  FILE *file;

  /* XXX "/etc/resolv.conf" should be from a define in setup.h perhaps
   * for cygwin support etc. this hardcodes it to unix for now -db
   */
  if ((file = fopen("/etc/resolv.conf", "r")) == NULL)
    return -1;

  while (fgets(input, sizeof(input), file) != NULL)
  {
    /* blow away any newline */
    if ((p = strpbrk(input, "\r\n")) != NULL)
      *p = '\0';

    p = input;
    /* skip until something thats not a space is seen */
    while (IsSpace(*p))
      p++;
    /* if at this point, have a '\0' then continue */
    if (*p == '\0')
      continue;

    /* Ignore comment lines immediately */
    if (*p == '#' || *p == ';')
      continue;

    /* skip until a space is found */
    opt = p;
    while (!IsSpace(*p) && *p != '\0')
      p++;
    if (*p == '\0')
      continue;  /* no arguments?.. ignore this line */
    /* blow away the space character */
    *p++ = '\0';

    /* skip these spaces that are before the argument */
    while (IsSpace(*p))
      p++;
    /* Now arg should be right where p is pointing */
    arg = p;
    if ((p = strpbrk(arg, " \t")) != NULL)
      *p = '\0';  /* take the first word */

    if (irccmp(opt, "domain") == 0)
      rb_strlcpy(irc_domain, arg, sizeof(irc_domain));
    else if (irccmp(opt, "nameserver") == 0)
      add_nameserver(arg);
  }

  fclose(file);
  return 0;
}
开发者ID:Cloudxtreme,项目名称:ircd-seven,代码行数:65,代码来源:reslib.c

示例13: me_mechlist

static int
me_mechlist(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p,
	    int parc, const char *parv[])
{
	rb_strlcpy(mechlist_buf, parv[1], sizeof mechlist_buf);

	return 0;
}
开发者ID:Elizafox,项目名称:charybdis,代码行数:8,代码来源:m_sasl.c

示例14: m_away

/*
** m_away
**      parv[0] = sender prefix
**      parv[1] = away message
*/
static int
m_away(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
	if(MyClient(source_p) && !IsFloodDone(source_p))
		flood_endgrace(source_p);

	if(!IsClient(source_p))
		return 0;

	if(parc < 2 || EmptyString(parv[1]))
	{
		/* Marking as not away */
		if(source_p->user->away != NULL)
		{
			/* 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));
			sendto_server(client_p, NULL, NOCAPS, CAP_TS6, ":%s AWAY", source_p->name);
			free_away(source_p);
		}
		if(MyConnect(source_p))
			sendto_one(source_p, form_str(RPL_UNAWAY), me.name, source_p->name);
		return 0;
	}


	if(source_p->user->away == NULL)
	{
		allocate_away(source_p);
		rb_strlcpy(source_p->user->away, parv[1], AWAYLEN);
		sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
			      ":%s AWAY :%s", use_id(source_p), source_p->user->away);
		sendto_server(client_p, NULL, NOCAPS, CAP_TS6,
			      ":%s AWAY :%s", source_p->name, source_p->user->away);

	}
	else
	{
		rb_strlcpy(source_p->user->away, parv[1], AWAYLEN);
	}

	if(MyConnect(source_p))
		sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, source_p->name);

	return 0;
}
开发者ID:Cloudxtreme,项目名称:ircd-ratbox,代码行数:51,代码来源:m_away.c

示例15: substitute_reject_reason

static
void substitute_reject_reason(void)
{
    rb_dlink_list subs = {0};
    substitution_append_var(&subs, "network-name", ServerInfo.network_name?: "${network-name}");
    substitution_append_var(&subs, "admin-email", AdminInfo.email?: "${admin-email}");
    const char *const substituted = substitution_parse(reject_reason, &subs);
    rb_strlcpy(reject_reason, substituted, sizeof(reject_reason));
    substitution_free(&subs);
}
开发者ID:grawity,项目名称:charybdis,代码行数:10,代码来源:chm_spamfilter.c


注:本文中的rb_strlcpy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。