コード例 #1
0
ファイル: repository.c プロジェクト: Asquera/libgit2
int git_repository_open_ext(
	git_repository **repo_ptr,
	const char *start_path,
	uint32_t flags,
	const char *ceiling_dirs)
{
	int error;
	git_buf path = GIT_BUF_INIT, parent = GIT_BUF_INIT;
	git_repository *repo;

	*repo_ptr = NULL;

	if ((error = find_repo(&path, &parent, start_path, flags, ceiling_dirs)) < 0)
		return error;

	repo = repository_alloc();
	GITERR_CHECK_ALLOC(repo);

	repo->path_repository = git_buf_detach(&path);
	GITERR_CHECK_ALLOC(repo->path_repository);

	if ((error = load_config_data(repo)) < 0 ||
		(error = load_workdir(repo, &parent)) < 0)
	{
		git_repository_free(repo);
		return error;
	}

	git_buf_free(&parent);
	*repo_ptr = repo;
	return 0;
}
コード例 #2
0
int git_repository_open_ext(
	git_repository **repo_ptr,
	const char *start_path,
	unsigned int flags,
	const char *ceiling_dirs)
{
	int error;
	git_buf path = GIT_BUF_INIT, parent = GIT_BUF_INIT;
	git_repository *repo;

	if (repo_ptr)
		*repo_ptr = NULL;

	error = find_repo(&path, &parent, start_path, flags, ceiling_dirs);
	if (error < 0 || !repo_ptr)
		return error;

	repo = repository_alloc();
	GITERR_CHECK_ALLOC(repo);

	repo->path_repository = git_buf_detach(&path);
	GITERR_CHECK_ALLOC(repo->path_repository);

	if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0)
		repo->is_bare = 1;
	else {
		git_config *config = NULL;

		if ((error = git_repository_config_snapshot(&config, repo)) < 0 ||
			(error = load_config_data(repo, config)) < 0 ||
			(error = load_workdir(repo, config, &parent)) < 0)
			git_repository_free(repo);

		git_config_free(config);
	}

	if (!error)
		*repo_ptr = repo;
	git_buf_free(&parent);

	return error;
}
コード例 #3
0
// read config file, compare the ctrl values.
int compare_update(void)
{
	load_config_data(&cur_ctrl);
	//printf("webcam=%d, fan=%d, feed=%d, car=%d\n", cur_ctrl.iCtrl_webcam, 
	//		cur_ctrl.iCtrl_fan, cur_ctrl.iCtrl_feed, cur_ctrl.iCtrl_car);

	if(cur_ctrl.iCtrl_webcam != last_ctrl.iCtrl_webcam)
	{
		//printf("last_ctrl.webcam=%d, cur_ctrl.webcam=%d\n", 
		//		last_ctrl.iCtrl_webcam, cur_ctrl.iCtrl_webcam);
		webcam_operation(cur_ctrl.iCtrl_webcam);
		last_ctrl.iCtrl_webcam = cur_ctrl.iCtrl_webcam;
	}

	if(cur_ctrl.iCtrl_fan != last_ctrl.iCtrl_fan)
	{
		//printf("last_ctrl.fan=%d, cur_ctrl.fan=%d\n", 
		//		last_ctrl.iCtrl_fan, cur_ctrl.iCtrl_fan);
		fan_operation(cur_ctrl.iCtrl_fan);
		last_ctrl.iCtrl_fan = cur_ctrl.iCtrl_fan;
	}

	if(cur_ctrl.iCtrl_feed != last_ctrl.iCtrl_feed)
	{
		//printf("last_ctrl.feed=%d, cur_ctrl.feed=%d\n", 
		//		last_ctrl.iCtrl_feed, cur_ctrl.iCtrl_feed);
		feed_operation(cur_ctrl.iCtrl_feed);
		last_ctrl.iCtrl_feed = cur_ctrl.iCtrl_feed;
	}
    
    if(cur_ctrl.iCtrl_car != last_ctrl.iCtrl_car)
	{
		//printf("last_ctrl.car=%d, cur_ctrl.car=%d\n",  
		//		last_ctrl.iCtrl_car, cur_ctrl.iCtrl_car);
		car_operation(cur_ctrl.iCtrl_car);
		last_ctrl.iCtrl_car = cur_ctrl.iCtrl_car;
	}

	return 0;
}
コード例 #4
0
ファイル: vgyro.c プロジェクト: lawrencejones/raspi-gpio
void							generate_vgyro()
{
	// Allocates memory for new Iteration and Params_Vaccel structures.
	Iterate *iter = generate_iter();
  Params_Vgyro *params_ = malloc(sizeof(Params_Vgyro));
  // Create a kalman filter using the data configuration for it.
  Conf *c = load_config_data();
  params_->kf = build_kalman(c);
  free_conf(c);
	// Initializes iter's fields.
	iter->compute_result = &compute_result_vgyro;
	iter->initialize_per_axis = &initialize_per_axis_vgyro;
	iter->free_params = &free_params_vgyro;
  iter->scan = &scan_vgyro;
  iter->params->params = params_;
  iter->params->result_type = GYROSCOPE;
  iter->params->result_model = VIRTUAL;
	// Iterates.
	iterate_devices(iter);
	// Frees allocated ressources.
	free_iter(iter);
}