Пример #1
0
/**
 * pcmcia_loop_config() - loop over configuration options
 * @p_dev:	the struct pcmcia_device which we need to loop for.
 * @conf_check:	function to call for each configuration option.
 *		It gets passed the struct pcmcia_device, the CIS data
 *		describing the configuration option, and private data
 *		being passed to pcmcia_loop_config()
 * @priv_data:	private data to be passed to the conf_check function.
 *
 * pcmcia_loop_config() loops over all configuration options, and calls
 * the driver-specific conf_check() for each one, checking whether
 * it is a valid one. Returns 0 on success or errorcode otherwise.
 */
int pcmcia_loop_config(struct pcmcia_device *p_dev,
		       int	(*conf_check)	(struct pcmcia_device *p_dev,
						 cistpl_cftable_entry_t *cfg,
						 cistpl_cftable_entry_t *dflt,
						 unsigned int vcc,
						 void *priv_data),
		       void *priv_data)
{
	struct pcmcia_cfg_mem *cfg_mem;

	tuple_t *tuple;
	int ret;
	unsigned int vcc;

	cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL);
	if (cfg_mem == NULL)
		return -ENOMEM;

	/* get the current Vcc setting */
	vcc = p_dev->socket->socket.Vcc;

	tuple = &cfg_mem->tuple;
	tuple->TupleData = cfg_mem->buf;
	tuple->TupleDataMax = 255;
	tuple->TupleOffset = 0;
	tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
	tuple->Attributes = 0;

	ret = pcmcia_get_first_tuple(p_dev, tuple);
	while (!ret) {
		cistpl_cftable_entry_t *cfg = &cfg_mem->parse.cftable_entry;

		if (pcmcia_get_tuple_data(p_dev, tuple))
			goto next_entry;

		if (pcmcia_parse_tuple(tuple, &cfg_mem->parse))
			goto next_entry;

		/* default values */
		p_dev->conf.ConfigIndex = cfg->index;
		if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
			cfg_mem->dflt = *cfg;

		ret = conf_check(p_dev, cfg, &cfg_mem->dflt, vcc, priv_data);
		if (!ret)
			break;

next_entry:
		ret = pcmcia_get_next_tuple(p_dev, tuple);
	}

	return ret;
}
Пример #2
0
void kadnode_loop(void)
{
	if (gconf && gconf->is_running == 0) {
		conf_check();

		main_setup();

		// Loop over all sockets and file descriptors
		net_loop();

		// Export peers if a file is provided
		peerfile_export();

		main_free();

		conf_free();
	}
}
Пример #3
0
int
main(int argc, char **args)
{
	int rc;
	gs_error_t *err = NULL;
	gs_grid_storage_t *gs = NULL;
	gs_container_t *container = NULL;

	signal(SIGPIPE, sig_pipe);

	if (argc <= 1) {
		help();
		return 1;
	}

	if (!parse_opt(argc, args)) {
		PRINT_ERROR("Cannot parse the arguments\n");
		help();
		return 1;
	}

	if (!conf_check()) {
		PRINT_ERROR("Missing parameters\n");
		help();
		return 1;
	}

	/*open the connection to the META0 */
	gs = gs_grid_storage_init(meta0_url, &err);
	if (!gs) {
		PRINT_ERROR("grid storage error : cannot init the namespace configuration from %s\n", meta0_url);
		return -1;
	}
	PRINT_DEBUG("Connected to the GridStorage namespace %s\n", meta0_url);

	/*find the container */
	container = gs_get_container(gs, container_name, 0, &err);
	if (!container) {
		PRINT_ERROR("grid storage error : cannot find the container %s : %s\n",
			container_name, err->msg);
		gs_grid_storage_free(gs);
		return -1;
	}
	PRINT_DEBUG("container %s found\n", container_name);

	switch (action) {
	case A_CONTAINER_GET:
		rc = get_service_for_container(container,&err);
		if (rc != 0)
			PRINT_ERROR("Failed to list the index services used in container [%s] : %s\n",
				container_name, gs_error_get_message(err));
		break;
	case A_CONTAINER_LIST:
		rc = list_services_used_by_container(container,&err);
		if (rc != 0)
			PRINT_ERROR("Failed to list the index services used in container [%s] : %s\n",
				container_name, gs_error_get_message(err));
		break;
	case A_LISTSRV:
		rc = list_services_used(container,&err);
		if (rc != 0)
			PRINT_ERROR("Failed to list the index services used in container [%s] : %s\n",
				container_name, gs_error_get_message(err));
		break;
		
	case A_LISTCONTENT:
		rc = list_services_for_path(container,&err, remote_path);
		if (rc != 0)
			PRINT_ERROR("Failed to list the index services used in container [%s] for path [%s] : %s\n",
				container_name, remote_path, gs_error_get_message(err));
		break;

	default:
		PRINT_ERROR("Action not set, please provide at least '-l' or '-c'\n");
		rc = -1;
		break;
	}

	gs_container_free(container);
	gs_grid_storage_free(gs);
	return 0;
}
Пример #4
0
int
main(int argc, char **argv)
{
	int ch;
	char conf_path[MAXPATHLEN];
	int conf=0;
	st_cn_t conn;

	conn = st_connection_alloc();

	conn->st_config = conf_create_with_defaults();

	(void)strncpy(conf_path, STUNEL_CONFIG, MAXPATHLEN-1);

	/* Parse command line args */
	/* TODO: Add options for port, destination ip, key and user so using conf file is not necessary*/
	while ((ch = getopt(argc, argv, "hqvDAf:p:d:i:u:")) != -1) {
		switch (ch) {
			case 'A':
				conf_set_authtype(conn->st_config, STUNEL_AUTH_AGENT);
				break;
			case 'f':
				if (argc == 3) {
					memset(conf_path, 0, MAXPATHLEN);
					(void)strncpy(conf_path, optarg, MAXPATHLEN-1);
					conf_path[MAXPATHLEN - 1]='\0';
					conf=1;
				}
				break;
			case 'p':
				conf_set_port(conn->st_config, atoi(optarg));
				break;
			case 'd':
				conf_set_address(conn->st_config, optarg);
				break;
			case 'i':
				conf_set_sshkey(conn->st_config, optarg);
				break;
			case 'u':
				conf_set_login(conn->st_config, optarg);
				break;
			case 'q':
				conf_set_log_level(conn->st_config, STUNEL_NORMAL);
				break;
			case 'v':
				conf_set_log_level(conn->st_config, STUNEL_VERBOSE);
				break;
			case 'D':
				conf_set_log_level(conn->st_config, STUNEL_DEBUG);
				break;
			case '?':
			case 'h':
			default:
				usage();
		}
	}
	argc -= optind;
	argv += optind;

	if ( conf ) {
		printf("Reading configuration from file: %s\n", conf_path);
		conf_destroy(conn->st_config);
		conn->st_config = conf_get_file(conf_path);
	}
	printf("Config file: \n%s\n", conf_dump(conn->st_config));

	if (conf_check(conn->st_config)) {
		st_connection_destroy(conn);
		exit(1);
	}

	printf("User is set to %s, port to %d\n",  conf_get_login(conn->st_config),
		conf_get_port(conn->st_config));

	printf("Connecting with libssh\n");
	st_ssh_connect(conn);

	st_connection_destroy(conn);
	return 0;
}
Пример #5
0
int
main(int argc, char **args)
{
	int rc = ~0;
	gs_error_t *err = NULL;
	gs_grid_storage_t *gs = NULL;

	close(0);

	if (!parse_opt(argc, args)) {
		PRINT_ERROR("cannot parse the options, see the help section (--help option)\n");
		return ~0;
	}

	if (flag_help) {
		help();
		return 0;
	}

	if (!conf_check()) {
		PRINT_ERROR("invalid configuration, see the help section (--help option)\n");
		help();
		return ~0;
	}

	if (0 > chdir(base_dir)) {
		PRINT_ERROR("Failed to change the working directory : %s\n", strerror(errno));
		return ~0;
	}

	gs = gs_grid_storage_init(meta0_url, &err);
	if (gs == NULL) {
		if (optind<argc){
			free(meta0_url);
			meta0_url=strtok(args[optind],"/");
			free(container_name);
			container_name=strtok(NULL,"/");
			if(container_name!=NULL){
				gs = gs_grid_storage_init(meta0_url, &err);
				if(!gs){
					PRINT_ERROR("cannot init the GridStorage client\n");
					goto error_gs;
				}
			}
			else{
				PRINT_ERROR("missing options\n");
				help();
				return 0;
			}
		}
		else{
			PRINT_ERROR("missing options\n");
			help();
			return 0;
		}
	}

	if (0 > list_container(gs, container_name)) {
		PRINT_ERROR("cannot list %s in namespace %s\n", container_name, meta0_url);
		goto error_list;
	}

	rc = 0;
      error_list:
	gs_grid_storage_free(gs);
      error_gs:
	if (err)
		gs_error_free(err);
	return rc;
}