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


C++ ACL_SAFE_STRNCPY函数代码示例

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


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

示例1: http_hdr_req_new

HTTP_HDR_REQ *http_hdr_req_clone(const HTTP_HDR_REQ* hdr_req)
{
	HTTP_HDR_REQ *hh;

	hh = http_hdr_req_new();
	http_hdr_clone(&hdr_req->hdr, &hh->hdr);

	hh->port = hdr_req->port;
	ACL_SAFE_STRNCPY(hh->method, hdr_req->method, sizeof(hh->method));
	ACL_SAFE_STRNCPY(hh->host, hdr_req->host, sizeof(hh->host));
	acl_vstring_strcpy(hh->url_part, acl_vstring_str(hdr_req->url_part));
	acl_vstring_strcpy(hh->url_path, acl_vstring_str(hdr_req->url_path));
	acl_vstring_strcpy(hh->url_params, acl_vstring_str(hdr_req->url_params));
	acl_vstring_strcpy(hh->file_path, acl_vstring_str(hdr_req->file_path));

	if (hdr_req->params_table) {
		hh->params_table = acl_htable_create(__http_hdr_max_request, 0);
		acl_htable_walk(hdr_req->params_table, clone_table_entry,
				(void*) hh->params_table);
	}
	if (hdr_req->cookies_table) {
		hh->cookies_table = acl_htable_create(__http_hdr_max_cookies, 0);
		acl_htable_walk(hdr_req->cookies_table, clone_table_entry,
				(void*) hh->cookies_table);
	}

	return hh;
}
开发者ID:1514louluo,项目名称:acl,代码行数:28,代码来源:http_hdr_req.c

示例2: dbconn_init

static void dbconn_init(const char *addr, const char *name, const char *usr,
	const char *pass, int dbpool_max, int dbping, int dbtimeout)
{
	const char *myname = "dbconn_init";
	ACL_DB_INFO db_info;

	memset(&db_info, 0, sizeof(ACL_DB_INFO));

	ACL_SAFE_STRNCPY(db_info.db_addr, addr, sizeof(db_info.db_addr));
	ACL_SAFE_STRNCPY(db_info.db_name, name, sizeof(db_info.db_name));
	ACL_SAFE_STRNCPY(db_info.db_user, usr, sizeof(db_info.db_user));
	ACL_SAFE_STRNCPY(db_info.db_pass, pass, sizeof(db_info.db_pass));

	db_info.db_max = dbpool_max;
	db_info.ping_inter = dbping;
	db_info.timeout_inter = dbtimeout;
	db_info.auto_commit = 1;

	//db_info.db_before_connect = db_before_connect;
	//db_info.db_after_connect = db_after_connect;

	__db_pool = acl_dbpool_create("mysql", &db_info);

	if (__db_pool == NULL)
		acl_msg_fatal("%s(%d): init db pool error", myname, __LINE__);

}
开发者ID:aaronshang,项目名称:acl,代码行数:27,代码来源:main.cpp

示例3: xml_new_gid

static int xml_new_gid(ACL_VSTREAM *client, int keep_alive, ACL_XML_NODE *node)
{
	acl_int64 gid;
	char  buf[256], tag[64];
	const char *ptr;
	int   errnum = 0;

#define	STR	acl_vstring_str

	ACL_SAFE_STRNCPY(tag, "default:", sizeof(tag));
	ptr = acl_xml_getElementAttrVal(node, "tag");
	if (ptr && *ptr) {
		ACL_SAFE_STRNCPY(tag, ptr, sizeof(tag));
	}

	gid = gid_next(var_cfg_gid_path, tag, var_cfg_gid_step, &errnum);
	if (gid >= 0)
		snprintf(buf, sizeof(buf),
			"<respond status='ok' gid='%lld' tag='%s' />\r\n", gid, tag);
	else
		snprintf(buf, sizeof(buf),
			"<respond status='error' gid='%lld' tag='%s'"
			" err='%d' msg='%s' />\r\n",
			gid, tag, errnum, gid_serror(errnum));

	return (http_server_send_respond(client, 200, keep_alive,
			buf, (int) strlen(buf)));
}
开发者ID:10jschen,项目名称:acl,代码行数:28,代码来源:http_xml.c

示例4: sizeof

bool http_utils::get_addr(const char* url, char* domain, size_t size,
	unsigned short* pport)
{
#define	HTTP_PREFIX	"http://"
#define	HTTPS_PREFIX	"https://"

	const char* ptr;
	unsigned short default_port;

	if (strncasecmp(url, HTTP_PREFIX, sizeof(HTTP_PREFIX) - 1) == 0)
	{
		ptr = url + sizeof(HTTP_PREFIX) - 1;
		default_port = 80;
	}
	else if (strncasecmp(url, HTTPS_PREFIX, sizeof(HTTPS_PREFIX) - 1) == 0)
	{
		ptr = url + sizeof(HTTPS_PREFIX) - 1;
		default_port = 443;
	}
	else
	{
		logger_error("invalid url: %s", url);
		return false;
	}

	if (*ptr == 0)
	{
		logger_error("invalid url: %s", url);
		return false;
	}

	char buf[256];
	ACL_SAFE_STRNCPY(buf, ptr, sizeof(buf));

	char* slash = strchr(buf, '/');
	if (slash)
		*slash = 0;

	unsigned short port;

	char* col = strchr(buf, ':');
	if (col == NULL)
		port = default_port;
	else
	{
		*col++ = 0;
		port = (unsigned short) atoi(col);
		if (port == 0 || port == 65535)
			port = default_port;
	}

	if (pport)
		*pport = port;
	ACL_SAFE_STRNCPY(domain, buf, size);
	return true;
}
开发者ID:10jschen,项目名称:acl,代码行数:56,代码来源:http_utils.cpp

示例5: acl_netdb_add_addr

void acl_netdb_add_addr(ACL_DNS_DB *dns_db, const char *ip, int hport)
{
	const char *myname = "acl_netdb_add_addr";
	ACL_HOSTNAME *phost;
	char  buf[256];

	if (dns_db == NULL || dns_db->h_db == NULL || ip == NULL) {
		acl_msg_error("%s(%d): input invalid", myname, __LINE__);
		return;
	}

	phost = acl_mycalloc(1, sizeof(ACL_HOSTNAME));
	if (phost == NULL) {
		acl_msg_error("%s(%d): calloc error(%s)",
			myname, __LINE__, acl_last_strerror(buf, sizeof(buf)));
		return;
	}

	memset(&phost->saddr, 0, sizeof(phost->saddr));
	ACL_SAFE_STRNCPY(phost->ip, ip, sizeof(phost->ip));
	phost->saddr.sin_addr.s_addr = (unsigned long) inet_addr(ip);
	phost->hport = hport;

	if (acl_array_append(dns_db->h_db, phost) < 0) {
		acl_msg_error("%s(%d): array append error(%s)",
			myname, __LINE__, acl_last_strerror(buf, sizeof(buf)));
		return;
	}

	dns_db->size++;
}
开发者ID:aaronshang,项目名称:acl,代码行数:31,代码来源:acl_netdb.c

示例6: acl_unix_listen

bool server_socket::open(const char* addr)
{
#ifndef ACL_WINDOWS
	if (strchr(addr, '/') != NULL)
	{
		fd_ = acl_unix_listen(addr, backlog_, block_
			? ACL_BLOCKING : ACL_NON_BLOCKING);
		unix_sock_ = true;
		ACL_SAFE_STRNCPY(addr_, addr, sizeof(addr_));
	}
	else
#endif
		fd_ = acl_inet_listen(addr, backlog_, block_
			? ACL_BLOCKING : ACL_NON_BLOCKING);

	if (fd_ == ACL_SOCKET_INVALID)
	{
		logger_error("listen %s error %s", addr, last_serror());
		unix_sock_ = false;
		ACL_SAFE_STRNCPY(addr_, addr, sizeof(addr_));
		return false;
	}

	if (unix_sock_)
		return true;

	// 之所以再用 getsockname 重新获得一些监听地址,主要是为了应对当输入的 addr 
	// 为 ip:0 的情形,即当给定的地址中的端口为 0 时要求操作系统自动分配一个端口号
	if (acl_getsockname(fd_, addr_, sizeof(addr_)) < 0)
	{
		logger_error("getsockname error: %s", acl_last_serror());
		ACL_SAFE_STRNCPY(addr_, addr, sizeof(addr_));
	}
	return true;
}
开发者ID:1514louluo,项目名称:acl,代码行数:35,代码来源:server_socket.cpp

示例7: main

int main(int argc, char *argv[])
{
	int   ch;
	char  url[256], dump[256];

	acl_init();  /* ³õʼ»¯ acl ¿â */

	url[0] = 0;
	dump[0] = 0;
	while ((ch = getopt(argc, argv, "hr:t:f:X:")) > 0) {
		switch (ch) {
		case 'h':
			usage(argv[0]);
			return (0);
		case 'r':
			ACL_SAFE_STRNCPY(url, optarg, sizeof(url));
			break;
		case 'f':
			ACL_SAFE_STRNCPY(dump, optarg, sizeof(dump));
			break;
		default:
			break;
		}
	}

	if (url[0] == 0) {
		usage(argv[0]);
		return (0);
	}

	get_url(url, dump);
	return (0);
}
开发者ID:1514louluo,项目名称:acl,代码行数:33,代码来源:main.c

示例8: buf

bool queue_file::move_file(const char* queueName, const char* extName)
{
	acl::string buf(256);
	bool once_again = false;

	while (true)
	{
		buf.clear();
		buf << m_home << PATH_SEP << queueName << PATH_SEP << m_queueSub
			<< PATH_SEP << m_partName << "." << extName;

#ifdef WIN32
		// 在win32下必须先关闭文件句柄
		this->close();
#endif

		if (rename(m_filePath.c_str(), buf.c_str()) == 0)
			break;

		// 如果返回错误原因是目标路径不存在,则尝试创建目录结构

		if (once_again || acl_last_error() != ENOENT)
		{
			logger_error("move from %s to %s error(%s), errno: %d, %d",
				m_filePath.c_str(), buf.c_str(), acl_last_serror(),
				acl_last_error(), ENOENT);
			return (false);
		}

		// 设置重试标志位
		once_again = true;

		buf.clear();
		buf << m_home << PATH_SEP << queueName
			<< PATH_SEP << m_queueSub;

		// 创建队列目录
		if (acl_make_dirs(buf.c_str(), 0700) == -1)
		{
			logger_error("mkdir: %s error(%s)",
				buf.c_str(), acl_last_serror());
			return false;
		}
	}

#ifdef WIN32
	// win32 下需要重新再打开
	return (open(m_home, queueName, m_queueSub, m_partName, extName));
#else
	if (m_queueName != queueName)
		ACL_SAFE_STRNCPY(m_queueName, queueName, sizeof(m_queueName));
	if (m_extName != extName)
		ACL_SAFE_STRNCPY(m_extName, extName, sizeof(m_extName));
	m_filePath.clear();
	m_filePath << m_home << PATH_SEP << m_queueName << PATH_SEP
		<< m_queueSub << PATH_SEP << m_partName << "." << m_extName;
#endif
	return (true);
}
开发者ID:JustinZhou,项目名称:acl,代码行数:59,代码来源:queue_file.cpp

示例9: ACL_SAFE_STRNCPY

connect_pool& connect_manager::set(const char* addr, int count)
{
	char key[256];
	ACL_SAFE_STRNCPY(key, addr, sizeof(key));
	acl_lowercase(key);

	lock_.lock();

	std::vector<connect_pool*>::iterator it = pools_.begin();
	for (; it != pools_.end(); ++it)
	{
		if (strcasecmp(key, (*it)->get_addr()) == 0)
		{
			lock_.unlock();
			return **it;
		}
	}

	connect_pool* pool = create_pool(key, count, pools_.size() - 1);
	pools_.push_back(pool);

	lock_.unlock();

	logger("Add one service, addr: %s, count: %d", addr, count);

	return *pool;
}
开发者ID:shitfSign,项目名称:acl,代码行数:27,代码来源:connect_manager.cpp

示例10: ACL_SAFE_STRNCPY

void queue_file::set_extName(const char* extName)
{
	ACL_SAFE_STRNCPY(m_extName, extName, sizeof(m_extName));
	m_filePath.clear();
	m_filePath << m_home << PATH_SEP << m_queueName << PATH_SEP
		<< m_queueSub << PATH_SEP << m_partName << "." << m_extName;
}
开发者ID:JustinZhou,项目名称:acl,代码行数:7,代码来源:queue_file.cpp

示例11: main

int main(int argc, char *argv[])
{
	char  ch, addr[32];
	int   n = 1, keep_alive = 0, cmd_num = 0;

	addr[0] = 0;
	while ((ch = getopt(argc, argv, "hks:n:i:")) > 0) {
		switch (ch) {
		case 's':
			ACL_SAFE_STRNCPY(addr, optarg, sizeof(addr));
			break;
		case 'n':
			n = atoi(optarg);
			break;
		case 'k':
			keep_alive = 1;
			break;
		case 'i':
			cmd_num = atoi(optarg);
			break;
		case 'h':
		default:
			usage(argv[0]);
			return (0);
		}
	}

	if (addr[0] == 0 || n <= 0) {
		usage(argv[0]);
		return (0);
	}

	run(addr, n, keep_alive, cmd_num);
	return (0);
}
开发者ID:1514louluo,项目名称:acl,代码行数:35,代码来源:main.c

示例12: acl_array_size

ACL_DNS_DB *acl_netdb_clone(const ACL_DNS_DB *db)
{
	ACL_DNS_DB *dbp;
	ACL_HOSTNAME *phost, *h_host;
	int  i, n;

	if (db == NULL || db->h_db == NULL)
		return NULL;

	n = acl_array_size(db->h_db);
	if (n <= 0) {
		acl_msg_error("%s, %s(%d): h_db's size(%d) <= 0",
			__FILE__, __FUNCTION__, __LINE__, n);
		return NULL;
	}

	dbp = acl_netdb_new(db->name);

	for (i = 0; i < n; i++) {
		phost = (ACL_HOSTNAME *) acl_array_index(db->h_db, i);
		acl_assert(phost);

		h_host = acl_mycalloc(1, sizeof(ACL_HOSTNAME));
		memcpy(&h_host->saddr, &phost->saddr, sizeof(h_host->saddr));
		ACL_SAFE_STRNCPY(h_host->ip, phost->ip, sizeof(h_host->ip));
		h_host->hport = phost->hport;

		(void) acl_array_append(dbp->h_db, h_host);
		dbp->size++;
	}

	return dbp;
}
开发者ID:zhengshuxin,项目名称:acl,代码行数:33,代码来源:acl_netdb.c

示例13: rfc1035BuildPTRQuery

/*
* rfc1035BuildPTRQuery()
* 
* Builds a message buffer with a QUESTION to lookup PTR records
* for an address.  Caller must allocate 'buf' which should
* probably be at least 512 octets.  The 'szp' initially
* specifies the size of the buffer, on return it contains
* the size of the message (i.e. how much to write).
* Returns the size of the query
*/
ssize_t rfc1035BuildPTRQuery(const struct in_addr addr, char *buf,
			size_t sz, unsigned short qid, rfc1035_query * query)
{
	const char *myname = "rfc1035BuildPTRQuery";
	rfc1035_message h;
	size_t offset = 0;
	static char rev[32];
	unsigned int i;

	memset(&h, '\0', sizeof(h));
	i = (unsigned int) ntohl(addr.s_addr);
	snprintf(rev, 32, "%u.%u.%u.%u.in-addr.arpa.",
		i & 255, (i >> 8) & 255, (i >> 16) & 255, (i >> 24) & 255);
	h.id = qid;
	h.qr = 0;
	h.rd = 1;
	h.opcode = 0;		/* QUERY */
	h.qdcount = (unsigned int) 1;
	offset += rfc1035HeaderPack(buf + offset, sz - offset, &h);
	offset += rfc1035QuestionPack(buf + offset, sz - offset, rev,
				RFC1035_TYPE_PTR, RFC1035_CLASS_IN);
	if (query) {
		query->qtype = RFC1035_TYPE_PTR;
		query->qclass = RFC1035_CLASS_IN;
		ACL_SAFE_STRNCPY(query->name, rev, sizeof(query->name));
	}
	if (offset > sz)
		acl_msg_fatal("%s: offset(%d) > sz(%d)", myname, offset, sz);
	return (ssize_t) offset;
}
开发者ID:DayBreakZhang,项目名称:acl,代码行数:40,代码来源:rfc1035.cpp

示例14: rfc1035BuildAQuery

/*
* rfc1035BuildAQuery()
* 
* Builds a message buffer with a QUESTION to lookup A records
* for a hostname.  Caller must allocate 'buf' which should
* probably be at least 512 octets.  The 'szp' initially
* specifies the size of the buffer, on return it contains
* the size of the message (i.e. how much to write).
* Returns the size of the query
*/
ssize_t rfc1035BuildAQuery(const char *hostname, char *buf, size_t sz,
			unsigned short qid, rfc1035_query * query)
{
	const char *myname = "rfc1035BuildAQuery";
	rfc1035_message h;
	size_t offset = 0;

	memset(&h, '\0', sizeof(h));
	h.id = qid;
	h.qr = 0;
	h.rd = 1;
	h.opcode = 0;		/* QUERY */
	h.qdcount = (unsigned int) 1;
	offset += rfc1035HeaderPack(buf + offset, sz - offset, &h);
	offset += rfc1035QuestionPack(buf + offset, sz - offset, hostname,
					RFC1035_TYPE_A, RFC1035_CLASS_IN);
	if (query) {
		query->qtype = RFC1035_TYPE_A;
		query->qclass = RFC1035_CLASS_IN;
		ACL_SAFE_STRNCPY(query->name, hostname, sizeof(query->name));
	}

	if (offset > sz)
		acl_msg_fatal("%s: offset(%d) > sz(%d)", myname, offset, sz);
	return (ssize_t) offset;
}
开发者ID:DayBreakZhang,项目名称:acl,代码行数:36,代码来源:rfc1035.cpp

示例15: ACL_SAFE_STRNCPY

connect_pool* connect_manager::get(const char* addr,
	bool exclusive /* = true */, bool restore /* = false */)
{
	char key[256];
	ACL_SAFE_STRNCPY(key, addr, sizeof(key));
	acl_lowercase(key);

	if (exclusive)
		lock_.lock();

	std::vector<connect_pool*>::iterator it = pools_.begin();
	for (; it != pools_.end(); ++it)
	{
		if (strcasecmp(key, (*it)->get_addr()) == 0)
		{
			if (restore && (*it)->aliving() == false)
				(*it)->set_alive(true);
			if (exclusive)
				lock_.unlock();
			return *it;
		}
	}

	if (exclusive)
		lock_.unlock();

	logger_error("no connect pool for addr %s", addr);
	return NULL;
}
开发者ID:DayBreakZhang,项目名称:acl,代码行数:29,代码来源:connect_manager.cpp


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