您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ str_to_uint函数代码示例

51自学网 2021-06-03 08:26:48
  C++
这篇教程C++ str_to_uint函数代码示例写得很实用,希望能帮到您。

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

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

示例1: connection_verify_version

int connection_verify_version(struct connection *conn,			      const char *const *args){	unsigned int recv_major_version;	/* VERSION <tab> service_name <tab> major version <tab> minor version */	if (str_array_length(args) != 4 ||	    strcmp(args[0], "VERSION") != 0 ||	    str_to_uint(args[2], &recv_major_version) < 0 ||	    str_to_uint(args[3], &conn->minor_version) < 0) {		i_error("%s didn't reply with a valid VERSION line",			conn->name);		return -1;	}	if (strcmp(args[1], conn->list->set.service_name_in) != 0) {		i_error("%s: Connected to wrong socket type. "			"We want '%s', but received '%s'", conn->name,			conn->list->set.service_name_in, args[1]);		return -1;	}	if (recv_major_version != conn->list->set.major_version) {		i_error("%s: Socket supports major version %u, "			"but we support only %u (mixed old and new binaries?)",			conn->name, recv_major_version,			conn->list->set.major_version);		return -1;	}	return 0;}
开发者ID:jkerihuel,项目名称:dovecot,代码行数:31,


示例2: open

vector<distributed_file_entry_t> distributed_file::get_entries( unsigned int vn_first, unsigned int vn_last ) {  vector<distributed_file_entry_t> entries;  string line;  // m_mutex.lock();  vector<string> broken_line;  vector<string> broken_ds;  unsigned int line_vn = 0;    open();    while ( file.good() ) {    std::getline( file, line );        if ( line == "/n" || line == "" ) {      continue;    }        // read version number of line.     broken_line = str_breakup( line, delimiters );    line_vn = str_to_uint( broken_line[0] );        // skip to the next entry    if ( line_vn < vn_first ) {      continue;    }        // stop reading. assumption: log file entries are sequential.    else if ( line_vn > vn_last ) {      break;    }        // parse it and push into entries to return    else {      distributed_file_entry_t next_entry;      next_entry.vn = str_to_uint( broken_line[0] );      next_entry.ru = str_to_uint( broken_line[1] );            broken_ds = str_breakup( broken_line[2], " " );      for ( unsigned int i = 0; i < broken_ds.size(); i++ ) {        next_entry.ds.insert( str_to_uint( broken_ds[i] ) );      }            strncpy( next_entry.text, broken_line[3].c_str(), sizeof(broken_line[3].c_str()) );            entries.push_back( next_entry );    }  }    close();    return entries;}
开发者ID:Siddharthsas07,项目名称:utd,代码行数:52,


示例3: str_list_to_nums

/* * NAME *   str_list_to_nums * * DESCRIPTION *   Converts string of characters representing list of numbers into array of *   numbers. Allowed formats are: *     0,1,2,3 *     0-10,20-18 *     1,3,5-8,10,0x10-12 * *   Numbers can be in decimal or hexadecimal format. * * PARAMETERS *   `s'         String representing list of unsigned numbers. *   `nums'      Array to put converted numeric values into. *   `nums_len'  Maximum number of elements that nums can accommodate. * * RETURN VALUE *    Number of elements placed into nums. */static size_t str_list_to_nums(char *s, unsigned *nums, size_t nums_len) {  char *saveptr = NULL;  char *token;  size_t idx = 0;  while ((token = strtok_r(s, ",", &saveptr))) {    char *pos;    unsigned start, end = 0;    s = NULL;    while (isspace(*token))      token++;    if (*token == '/0')      continue;    pos = strchr(token, '-');    if (pos) {      *pos = '/0';    }    if (str_to_uint(token, &start))      return 0;    if (pos) {      if (str_to_uint(pos + 1, &end))        return 0;    } else {      end = start;    }    if (start > end) {      unsigned swap = start;      start = end;      end = swap;    }    for (unsigned i = start; i <= end; i++) {      if (is_in_list(i, nums, idx))        continue;      if (idx >= nums_len) {        WARNING(UTIL_NAME ": exceeded the cores number limit: %" PRIsz,                nums_len);        return idx;      }      nums[idx] = i;      idx++;    }  }  return idx;}
开发者ID:collectd,项目名称:collectd,代码行数:71,


示例4: fts_queue_index

static void fts_queue_index(struct mailbox *box){	struct mail_user *user = box->storage->user;	string_t *str = t_str_new(256);	const char *path, *value;	unsigned int max_recent_msgs;	int fd;	path = t_strconcat(user->set->base_dir, "/"INDEXER_SOCKET_NAME, NULL);	fd = net_connect_unix(path);	if (fd == -1) {		i_error("net_connect_unix(%s) failed: %m", path);		return;	}	value = mail_user_plugin_getenv(user, "fts_autoindex_max_recent_msgs");	if (value == NULL || str_to_uint(value, &max_recent_msgs) < 0)		max_recent_msgs = 0;	str_append(str, INDEXER_HANDSHAKE);	str_append(str, "APPEND/t0/t");	str_append_tabescaped(str, user->username);	str_append_c(str, '/t');	str_append_tabescaped(str, box->vname);	str_printfa(str, "/t%u", max_recent_msgs);	str_append_c(str, '/t');	str_append_tabescaped(str, box->storage->user->session_id);	str_append_c(str, '/n');	if (write_full(fd, str_data(str), str_len(str)) < 0)		i_error("write(%s) failed: %m", path);	i_close_fd(&fd);}
开发者ID:Raffprta,项目名称:core,代码行数:32,


示例5: cmd_director_status_user

static voidcmd_director_status_user(struct director_context *ctx, char *argv[]){	const char *user = argv[0], *tag = argv[1];	const char *line, *const *args;	unsigned int expires;	director_send(ctx, t_strdup_printf("USER-LOOKUP/t%s/t%s/n", user,					   tag != NULL ? tag : ""));	line = i_stream_read_next_line(ctx->input);	if (line == NULL) {		i_error("Lookup failed");		doveadm_exit_code = EX_TEMPFAIL;		return;	}	args = t_strsplit_tab(line);	if (str_array_length(args) != 4 ||	    str_to_uint(args[1], &expires) < 0) {		i_error("Invalid reply from director");		doveadm_exit_code = EX_PROTOCOL;		return;	}	if (args[0][0] != '/0') {		printf("Current: %s (expires %s)/n",		       args[0], unixdate2str(expires));	} else {		printf("Current: not assigned/n");	}	printf("Hashed: %s/n", args[2]);	printf("Initial config: %s/n", args[3]);	director_disconnect(ctx);}
开发者ID:Raffprta,项目名称:core,代码行数:34,


示例6: parse_device_id

/** Extract device serial. */void parse_device_id( char* str ){	if (strncmp_upper(str,"MBUG-2810",9) == 0)		device_serial = mbug_serial_from_id(str);	else device_serial = str_to_uint(str);	if (device_serial < 0) errorf( "#### Invalid device id: %s", str );}
开发者ID:GHPS,项目名称:mbug_devel,代码行数:8,


示例7: auth_worker_handle_list

static boolauth_worker_handle_list(struct auth_worker_client *client,			unsigned int id, const char *const *args){	struct auth_worker_list_context *ctx;	struct auth_userdb *userdb;	unsigned int userdb_id;	if (str_to_uint(args[0], &userdb_id) < 0) {		i_error("BUG: Auth worker server sent us invalid LIST");		return FALSE;	}	userdb = auth_userdb_find_by_id(client->auth->userdbs, userdb_id);	if (userdb == NULL) {		i_error("BUG: LIST had invalid userdb ID");		return FALSE;	}	ctx = i_new(struct auth_worker_list_context, 1);	ctx->client = client;	ctx->id = id;	ctx->userdb = userdb->userdb;	io_remove(&ctx->client->io);	o_stream_set_flush_callback(ctx->client->output,				    auth_worker_list_output, ctx);	client->refcount++;	ctx->iter = ctx->userdb->iface->		iterate_init(userdb->userdb, list_iter_callback, ctx);	ctx->userdb->iface->iterate_next(ctx->iter);	return TRUE;}
开发者ID:aosm,项目名称:dovecot,代码行数:33,


示例8: auth_worker_handle_line

static boolauth_worker_handle_line(struct auth_worker_client *client, const char *line){	const char *const *args;	unsigned int id;	bool ret = FALSE;	args = t_strsplit(line, "/t");	if (args[0] == NULL || args[1] == NULL || args[2] == NULL ||	    str_to_uint(args[0], &id) < 0) {		i_error("BUG: Invalid input: %s", line);		return FALSE;	}	if (strcmp(args[1], "PASSV") == 0)		ret = auth_worker_handle_passv(client, id, args + 2);	else if (strcmp(args[1], "PASSL") == 0)		ret = auth_worker_handle_passl(client, id, args + 2);	else if (strcmp(args[1], "SETCRED") == 0)		ret = auth_worker_handle_setcred(client, id, args + 2);	else if (strcmp(args[1], "USER") == 0)		ret = auth_worker_handle_user(client, id, args + 2);	else if (strcmp(args[1], "LIST") == 0)		ret = auth_worker_handle_list(client, id, args + 2);	else {		i_error("BUG: Auth-worker received unknown command: %s",			args[1]);	}        return ret;}
开发者ID:aosm,项目名称:dovecot,代码行数:30,


示例9: zlib_mail_user_created

static void zlib_mail_user_created(struct mail_user *user){	struct mail_user_vfuncs *v = user->vlast;	struct zlib_user *zuser;	const char *name;	zuser = p_new(user->pool, struct zlib_user, 1);	zuser->module_ctx.super = *v;	user->vlast = &zuser->module_ctx.super;	v->deinit = zlib_mail_user_deinit;	name = mail_user_plugin_getenv(user, "zlib_save");	if (name != NULL && *name != '/0') {		zuser->save_handler = compression_lookup_handler(name);		if (zuser->save_handler == NULL)			i_error("zlib_save: Unknown handler: %s", name);		else if (zuser->save_handler->create_ostream == NULL) {			i_error("zlib_save: Support not compiled in for handler: %s", name);			zuser->save_handler = NULL;		}	}	name = mail_user_plugin_getenv(user, "zlib_save_level");	if (name != NULL) {		if (str_to_uint(name, &zuser->save_level) < 0 ||		    zuser->save_level < 1 || zuser->save_level > 9) {			i_error("zlib_save_level: Level must be between 1..9");			zuser->save_level = 0;		}	}	if (zuser->save_level == 0)		zuser->save_level = ZLIB_PLUGIN_DEFAULT_LEVEL;	MODULE_CONTEXT_SET(user, zlib_user_module, zuser);}
开发者ID:Distrotech,项目名称:dovecot,代码行数:33,


示例10: login_proxy_cmd_kick_director_hash

static voidlogin_proxy_cmd_kick_director_hash(struct ipc_cmd *cmd, const char *const *args){	struct login_proxy *proxy, *next;	unsigned int hash, count = 0;	if (args[0] == NULL || str_to_uint(args[0], &hash) < 0) {		ipc_cmd_fail(&cmd, "Invalid parameters");		return;	}	for (proxy = login_proxies; proxy != NULL; proxy = next) {		next = proxy->next;		if (director_username_hash(proxy->client) == hash) {			login_proxy_free_reason(&proxy, KILLED_BY_ADMIN_REASON);			count++;		}	}	for (proxy = login_proxies_pending; proxy != NULL; proxy = next) {		next = proxy->next;		if (director_username_hash(proxy->client) == hash) {			client_destroy(proxy->client, "Connection kicked");			count++;		}	}	ipc_cmd_success_reply(&cmd, t_strdup_printf("%u", count));}
开发者ID:Distrotech,项目名称:dovecot,代码行数:29,


示例11: master_login_auth_input_fail

static boolmaster_login_auth_input_fail(struct master_login_auth *auth,			     const char *args_line){	struct master_login_auth_request *request; 	const char *const *args, *error = NULL;	unsigned int i, id;	args = t_strsplit_tab(args_line);	if (args[0] == NULL || str_to_uint(args[0], &id) < 0) {		i_error("Auth server sent broken FAIL line");		return FALSE;	}	for (i = 1; args[i] != NULL; i++) {		if (strncmp(args[i], "reason=", 7) == 0)			error = args[i] + 7;	}	request = master_login_auth_lookup_request(auth, id);	if (request != NULL) {		if (error == NULL) {			request_internal_failure(request,						 "Internal auth failure");		} else {			i_error("Internal auth failure: %s "				"(client-pid=%u client-id=%u)",				error, request->client_pid, request->auth_id);			request->callback(NULL, error, request->context);		}		i_free(request);	}	return TRUE;}
开发者ID:jwm,项目名称:dovecot-notmuch,代码行数:33,


示例12: auth_worker_handle_user

static boolauth_worker_handle_user(struct auth_worker_client *client,			unsigned int id, const char *const *args){	/* lookup user */	struct auth_request *auth_request;	unsigned int userdb_id;	/* <userdb id> [<args>] */	if (str_to_uint(args[0], &userdb_id) < 0) {		i_error("BUG: Auth worker server sent us invalid USER");		return FALSE;	}	auth_request = worker_auth_request_new(client, id, args + 1);	if (auth_request->user == NULL || auth_request->service == NULL) {		i_error("BUG: USER had missing parameters");		auth_request_unref(&auth_request);		return FALSE;	}	auth_request->userdb =		auth_userdb_find_by_id(auth_request->userdb, userdb_id);	if (auth_request->userdb == NULL) {		i_error("BUG: USER had invalid userdb ID");		auth_request_unref(&auth_request);		return FALSE;	}	auth_request_init_userdb_reply(auth_request);	auth_request->userdb->userdb->iface->		lookup(auth_request, lookup_user_callback);	return TRUE;}
开发者ID:bsmr-dovecot,项目名称:core,代码行数:34,


示例13: auth_worker_handle_setcred

static boolauth_worker_handle_setcred(struct auth_worker_client *client,			   unsigned int id, const char *const *args){	struct auth_request *auth_request;	unsigned int passdb_id;	const char *creds;	/* <passdb id> <credentials> [<args>] */	if (str_to_uint(args[0], &passdb_id) < 0 || args[1] == NULL) {		i_error("BUG: Auth worker server sent us invalid SETCRED");		return FALSE;	}	creds = args[1];	auth_request = worker_auth_request_new(client, id, args + 2);	if (auth_request->user == NULL || auth_request->service == NULL) {		i_error("BUG: SETCRED had missing parameters");		auth_request_unref(&auth_request);		return FALSE;	}	while (auth_request->passdb->passdb->id != passdb_id) {		auth_request->passdb = auth_request->passdb->next;		if (auth_request->passdb == NULL) {			i_error("BUG: SETCRED had invalid passdb ID");			auth_request_unref(&auth_request);			return FALSE;		}	}	auth_request->passdb->passdb->iface.		set_credentials(auth_request, creds, set_credentials_callback);	return TRUE;}
开发者ID:bsmr-dovecot,项目名称:core,代码行数:35,


示例14: master_input_request

static boolmaster_input_request(struct auth_master_connection *conn, const char *args){	struct auth_client_connection *client_conn;	const char *const *list, *const *params;	unsigned int id, client_pid, client_id;	uint8_t cookie[MASTER_AUTH_COOKIE_SIZE];	buffer_t buf;	/* <id> <client-pid> <client-id> <cookie> [<parameters>] */	list = t_strsplit_tab(args);	if (str_array_length(list) < 4 ||	    str_to_uint(list[0], &id) < 0 ||	    str_to_uint(list[1], &client_pid) < 0 ||	    str_to_uint(list[2], &client_id) < 0) {		i_error("BUG: Master sent broken REQUEST");		return FALSE;	}	buffer_create_from_data(&buf, cookie, sizeof(cookie));	if (hex_to_binary(list[3], &buf) < 0) {		i_error("BUG: Master sent broken REQUEST cookie");		return FALSE;	}	params = list + 4;	client_conn = auth_client_connection_lookup(client_pid);	if (client_conn == NULL) {		i_error("Master requested auth for nonexistent client %u",			client_pid);		o_stream_nsend_str(conn->output,				   t_strdup_printf("FAIL/t%u/n", id));	} else if (memcmp(client_conn->cookie, cookie, sizeof(cookie)) != 0) {		i_error("Master requested auth for client %u with invalid cookie",			client_pid);		o_stream_nsend_str(conn->output,				   t_strdup_printf("FAIL/t%u/n", id));	} else if (!auth_request_handler_master_request(			client_conn->request_handler, conn, id, client_id, params)) {		i_error("Master requested auth for non-login client %u",			client_pid);		o_stream_nsend_str(conn->output,				   t_strdup_printf("FAIL/t%u/n", id));	}	return TRUE;}
开发者ID:Dexus,项目名称:ubuntu-trusty-dovecot,代码行数:46,


示例15: pop3c_sync_get_uidls

int pop3c_sync_get_uidls(struct pop3c_mailbox *mbox){	ARRAY_TYPE(const_string) uidls;	struct istream *input;	const char *error, *cline;	char *line, *p;	unsigned int seq, line_seq;	if (mbox->msg_uidls != NULL)		return 0;	if ((pop3c_client_get_capabilities(mbox->client) &	     POP3C_CAPABILITY_UIDL) == 0) {		mail_storage_set_error(mbox->box.storage,				       MAIL_ERROR_NOTPOSSIBLE,				       "UIDLs not supported by server");		return -1;	}	if (pop3c_client_cmd_stream(mbox->client, "UIDL/r/n",				    &input, &error) < 0) {		mail_storage_set_critical(mbox->box.storage,					  "UIDL failed: %s", error);		return -1;	}	mbox->uidl_pool = pool_alloconly_create("POP3 UIDLs", 1024*32);	p_array_init(&uidls, mbox->uidl_pool, 64); seq = 0;	while ((line = i_stream_read_next_line(input)) != NULL) {		seq++;		p = strchr(line, ' ');		if (p == NULL) {			mail_storage_set_critical(mbox->box.storage,				"Invalid UIDL line: %s", line);			break;		}		*p++ = '/0';		if (str_to_uint(line, &line_seq) < 0 || line_seq != seq) {			mail_storage_set_critical(mbox->box.storage,				"Unexpected UIDL seq: %s != %u", line, seq);			break;		}		cline = p_strdup(mbox->uidl_pool, p);		array_append(&uidls, &cline, 1);	}	i_stream_destroy(&input);	if (line != NULL) {		pool_unref(&mbox->uidl_pool);		return -1;	}	if (seq == 0) {		/* make msg_uidls non-NULL */		array_append_zero(&uidls);	}	mbox->msg_uidls = array_idx(&uidls, 0);	mbox->msg_count = seq;	return 0;}
开发者ID:manuelm,项目名称:dovecot,代码行数:58,


示例16: client_proxy_rcpt_parse_fields

static boolclient_proxy_rcpt_parse_fields(struct lmtp_proxy_rcpt_settings *set,			       const char *const *args, const char **address){	const char *p, *key, *value;	bool proxying = FALSE, port_set = FALSE;	for (; *args != NULL; args++) {		p = strchr(*args, '=');		if (p == NULL) {			key = *args;			value = "";		} else {			key = t_strdup_until(*args, p);			value = p + 1;		}		if (strcmp(key, "proxy") == 0)			proxying = TRUE;		else if (strcmp(key, "host") == 0)			set->host = value;		else if (strcmp(key, "port") == 0) {			if (net_str2port(value, &set->port) < 0) {				i_error("proxy: Invalid port number %s", value);				return FALSE;			}			port_set = TRUE;		} else if (strcmp(key, "proxy_timeout") == 0) {			if (str_to_uint(value, &set->timeout_msecs) < 0) {				i_error("proxy: Invalid proxy_timeout value %s", value);				return FALSE;			}			set->timeout_msecs *= 1000;		} else if (strcmp(key, "protocol") == 0) {			if (strcmp(value, "lmtp") == 0)				set->protocol = LMTP_CLIENT_PROTOCOL_LMTP;			else if (strcmp(value, "smtp") == 0) {				set->protocol = LMTP_CLIENT_PROTOCOL_SMTP;				if (!port_set)					set->port = 25;			} else {				i_error("proxy: Unknown protocol %s", value);				return FALSE;			}		} else if (strcmp(key, "user") == 0 ||			   strcmp(key, "destuser") == 0) {			/* changing the username */			*address = value;		} else {			/* just ignore it */		}	}	if (proxying && set->host == NULL) {		i_error("proxy: host not given");		return FALSE;	}	return proxying;}
开发者ID:makunterry,项目名称:core,代码行数:58,


示例17: pop3c_sync_get_sizes

int pop3c_sync_get_sizes(struct pop3c_mailbox *mbox){	struct istream *input;	const char *error;	char *line, *p;	unsigned int seq, line_seq;	i_assert(mbox->msg_sizes == NULL);	if (mbox->msg_uidls == NULL) {		if (pop3c_sync_get_uidls(mbox) < 0)			return -1;	}	if (mbox->msg_count == 0) {		mbox->msg_sizes = i_new(uoff_t, 1);		return 0;	}	if (pop3c_client_cmd_stream(mbox->client, "LIST/r/n",				    &input, &error) < 0) {		mail_storage_set_critical(mbox->box.storage,					  "LIST failed: %s", error);		return -1;	}	mbox->msg_sizes = i_new(uoff_t, mbox->msg_count); seq = 0;	while ((line = i_stream_read_next_line(input)) != NULL) {		if (++seq > mbox->msg_count) {			mail_storage_set_critical(mbox->box.storage,				"Too much data in LIST: %s", line);			break;		}		p = strchr(line, ' ');		if (p == NULL) {			mail_storage_set_critical(mbox->box.storage,				"Invalid LIST line: %s", line);			break;		}		*p++ = '/0';		if (str_to_uint(line, &line_seq) < 0 || line_seq != seq) {			mail_storage_set_critical(mbox->box.storage,				"Unexpected LIST seq: %s != %u", line, seq);			break;		}		if (str_to_uoff(p, &mbox->msg_sizes[seq-1]) < 0) {			mail_storage_set_critical(mbox->box.storage,				"Invalid LIST size: %s", p);			break;		}	}	i_stream_destroy(&input);	if (line != NULL) {		i_free_and_null(mbox->msg_sizes);		return -1;	}	return 0;}
开发者ID:manuelm,项目名称:dovecot,代码行数:57,


示例18: dbox_get_cached_metadata

static intdbox_get_cached_metadata(struct dbox_mail *mail, enum dbox_metadata_key key,			 enum index_cache_field cache_field,			 const char **value_r){	struct index_mail *imail = &mail->imail;	struct index_mailbox_context *ibox =		INDEX_STORAGE_CONTEXT(imail->mail.mail.box);	const char *value;	string_t *str;	uint32_t order;	str = str_new(imail->mail.data_pool, 64);	if (mail_cache_lookup_field(imail->mail.mail.transaction->cache_view,				    str, imail->mail.mail.seq,				    ibox->cache_fields[cache_field].idx) > 0) {		if (cache_field == MAIL_CACHE_POP3_ORDER) {			i_assert(str_len(str) == sizeof(order));			memcpy(&order, str_data(str), sizeof(order));			str_truncate(str, 0);			if (order != 0)				str_printfa(str, "%u", order);			else {				/* order=0 means it doesn't exist. we don't				   want to return "0" though, because then the				   mails get ordered to beginning, while				   nonexistent are supposed to be ordered at				   the end. */			}		}		*value_r = str_c(str);		return 0;	}	if (dbox_mail_metadata_get(mail, key, &value) < 0)		return -1;	if (value == NULL)		value = "";	if (cache_field != MAIL_CACHE_POP3_ORDER) {		index_mail_cache_add_idx(imail, ibox->cache_fields[cache_field].idx,					 value, strlen(value)+1);	} else {		if (str_to_uint(value, &order) < 0)			order = 0;		index_mail_cache_add_idx(imail, ibox->cache_fields[cache_field].idx,					 &order, sizeof(order));	}	/* don't return pointer to dbox metadata directly, since it may	   change unexpectedly */	str_truncate(str, 0);	str_append(str, value);	*value_r = str_c(str);	return 0;}
开发者ID:IvanKharpalev,项目名称:core,代码行数:56,


示例19: acl_backend_vfile_init

static intacl_backend_vfile_init(struct acl_backend *_backend, const char *data){	struct acl_backend_vfile *backend =		(struct acl_backend_vfile *)_backend;	struct stat st;	const char *const *tmp;	tmp = t_strsplit(data, ":");	backend->global_path = p_strdup_empty(_backend->pool, *tmp);	backend->cache_secs = ACL_VFILE_DEFAULT_CACHE_SECS;	if (*tmp != NULL)		tmp++;	for (; *tmp != NULL; tmp++) {		if (strncmp(*tmp, "cache_secs=", 11) == 0) {			if (str_to_uint(*tmp + 11, &backend->cache_secs) < 0) {				i_error("acl vfile: Invalid cache_secs value: %s",					*tmp + 11);				return -1;			}		} else {			i_error("acl vfile: Unknown parameter: %s", *tmp);			return -1;		}	}	if (backend->global_path != NULL) {		if (stat(backend->global_path, &st) < 0) {			if (errno != ENOENT) {				i_error("acl vfile: stat(%s) failed: %m",					backend->global_path);				return -1;			}		} else if (!S_ISDIR(st.st_mode)) {			_backend->global_file =				acl_global_file_init(backend->global_path, backend->cache_secs);		}	}	if (_backend->debug) {		if (backend->global_path == NULL)			i_debug("acl vfile: Global ACLs disabled");		else if (_backend->global_file != NULL) {			i_debug("acl vfile: Global ACL file: %s",				backend->global_path);		} else {			i_debug("acl vfile: Global ACL legacy directory: %s",				backend->global_path);		}	}	_backend->cache =		acl_cache_init(_backend,			       sizeof(struct acl_backend_vfile_validity));	return 0;}
开发者ID:dhultin,项目名称:dovecot-pop-uidl-proxy,代码行数:55,


示例20: auth_client_input_cpid

static boolauth_client_input_cpid(struct auth_client_connection *conn, const char *args){        struct auth_client_connection *old;	unsigned int pid;	i_assert(conn->pid == 0);	if (str_to_uint(args, &pid) < 0 || pid == 0) {		i_error("BUG: Authentication client said it's PID 0");		return FALSE;	}	if (conn->login_requests)		old = auth_client_connection_lookup(pid);	else {		/* the client is only authenticating, not logging in.		   the PID isn't necessary, and since we allow authentication		   via TCP sockets the PIDs may conflict, so ignore them. */		old = NULL;		pid = 0;	}	if (old != NULL) {		/* already exists. it's possible that it just reconnected,		   see if the old connection is still there. */		i_assert(old != conn);		if (i_stream_read(old->input) == -1) {			auth_client_disconnected(&old);			old = NULL;		}	}	if (old != NULL) {		i_error("BUG: Authentication client gave a PID "			"%u of existing connection", pid);		return FALSE;	}	/* handshake complete, we can now actually start serving requests */        conn->refcount++;	conn->request_handler =		auth_request_handler_create(conn->token_auth, auth_callback, conn,					    !conn->login_requests ? NULL :					    auth_master_request_callback);	auth_request_handler_set(conn->request_handler, conn->connect_uid, pid);	conn->pid = pid;	if (conn->auth->set->debug)		i_debug("auth client connected (pid=%u)", conn->pid);	return TRUE;}
开发者ID:bechtoldt,项目名称:dovecot-core,代码行数:52,


示例21: master_input_auth_request

static intmaster_input_auth_request(struct auth_master_connection *conn, const char *args,			  const char *cmd, struct auth_request **request_r,			  const char **error_r){	struct auth_request *auth_request;	const char *const *list, *name, *arg, *username;	unsigned int id;	/* <id> <userid> [<parameters>] */	list = t_strsplit_tab(args);	if (list[0] == NULL || list[1] == NULL ||	    str_to_uint(list[0], &id) < 0) {		i_error("BUG: Master sent broken %s", cmd);		return -1;	}	auth_request = auth_request_new_dummy();	auth_request->id = id;	auth_request->master = conn;	auth_master_connection_ref(conn);	username = list[1];	for (list += 2; *list != NULL; list++) {		arg = strchr(*list, '=');		if (arg == NULL) {			name = *list;			arg = "";		} else {			name = t_strdup_until(*list, arg);			arg++;		}		(void)auth_request_import_info(auth_request, name, arg);	}	if (auth_request->service == NULL) {		i_error("BUG: Master sent %s request without service", cmd);		auth_request_unref(&auth_request);		auth_master_connection_unref(&conn);		return -1;	}	auth_request_init(auth_request);	if (!auth_request_set_username(auth_request, username, error_r)) {		*request_r = auth_request;		return 0;	}	*request_r = auth_request;	return 1;}
开发者ID:Dexus,项目名称:ubuntu-trusty-dovecot,代码行数:52,


示例22: fs_compress_init

static intfs_compress_init(struct fs *_fs, const char *args, const		 struct fs_settings *set){	struct compress_fs *fs = (struct compress_fs *)_fs;	const char *p, *compression_name, *level_str, *error;	const char *parent_name, *parent_args;	/* get compression handler name */	p = strchr(args, ':');	if (p == NULL) {		fs_set_error(_fs, "Compression method not given as parameter");		return -1;	}	compression_name = t_strdup_until(args, p++);	args = p;	/* get compression level */	p = strchr(args, ':');	if (p == NULL || p[1] == '/0') {		fs_set_error(_fs, "Parent filesystem not given as parameter");		return -1;	}	level_str = t_strdup_until(args, p++);	if (str_to_uint(level_str, &fs->compress_level) < 0 ||	    fs->compress_level < 1 || fs->compress_level > 9) {		fs_set_error(_fs, "Invalid compression level parameter '%s'", level_str);		return -1;	}	args = p;	fs->handler = compression_lookup_handler(compression_name);	if (fs->handler == NULL) {		fs_set_error(_fs, "Compression method '%s' not support", compression_name);		return -1;	}	parent_args = strchr(args, ':');	if (parent_args == NULL) {		parent_name = args;		parent_args = "";	} else {		parent_name = t_strdup_until(args, parent_args);		parent_args++;	}	if (fs_init(parent_name, parent_args, set, &_fs->parent, &error) < 0) {		fs_set_error(_fs, "%s: %s", parent_name, error);		return -1;	}	return 0;}
开发者ID:nikwrt,项目名称:dovecot-core,代码行数:52,


示例23: auth_client_cancel

static boolauth_client_cancel(struct auth_client_connection *conn, const char *line){	unsigned int client_id;	if (str_to_uint(line, &client_id) < 0) {		i_error("BUG: Authentication client sent broken CANCEL");		return FALSE;	}	auth_request_handler_cancel_request(conn->request_handler, client_id);	return TRUE;}
开发者ID:bechtoldt,项目名称:dovecot-core,代码行数:13,


示例24: tw2_getchar_hash_value

万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。