int init_weekcnv(struct weekcnv *weekv) {
	memset(weekv, 0, sizeof(*weekv));

	weekv->array[0] = alloc_week_name();
	if (!weekv->array[0]) {
		pr_err("weekv: failed to alloc week name\n");
		goto return_err;
	}

	weekv->array[1] = alloc_week();
	if (!weekv->array[1]) {
		pr_err("weekv: failed to alloc week\n");
		goto free_week_name;
	}

	weekv->text = alloc_text_view("week", weekv->array, ARRAY_SIZE(weekv->array));
	if (!weekv->text) {
		pr_err("weekv: failed to alloc week cn\n");
		goto free_week;
	}

	return 0;
free_week:
	free_view(weekv->array[1]);
free_week_name:
	free_view(weekv->array[0]);
return_err:
	return -EINVAL;
}
Beispiel #2
0
TEARDOWN()
{
	reset_cmds();

	free(cfg.slow_fs_list);
	cfg.slow_fs_list = NULL;

	free_view(&lwin);
	free_view(&rwin);
}
Beispiel #3
0
TEARDOWN()
{
	reset_cmds();

	update_string(&cfg.slow_fs_list, NULL);

	cfg.chase_links = 0;

	free_view(&lwin);
	free_view(&rwin);
}
int init_datecnv(struct datecnv *datev) {
	memset(datev, 0, sizeof(*datev));

	datev->array2[0] = alloc_mon(&datev->array[0]);
	if (!datev->array2[0]) {
		pr_err("datev: failed to alloc mon\n");
		goto return_err;
	}

	datev->array2[1] = datev->array[2] = alloc_mon_name();
	if (!datev->array2[1]) {
		pr_err("datev: failed to alloc month name\n");
		goto free_mon;
	}

	datev->array2[2] = alloc_day(&datev->array[3]);
	if (!datev->array2[2]) {
		pr_err("datev: failed to alloc day\n");
		goto free_mon_name;
	}

	datev->array2[3] = datev->array[5] = alloc_day_name();
	if (!datev->array2[3]) {
		pr_err("datev: failed to alloc day name\n");
		goto free_day;
	}

	datev->text = alloc_text_view("date", datev->array2, ARRAY_SIZE(datev->array2));
	if (!datev->text) {
		pr_err("datev: failed to alloc text view\n");
		goto free_day_name;
	}

	return 0;
free_day_name:
	free_view(datev->array2[3]);
free_day:
	free_view(datev->array2[2]);
free_mon_name:
	free_view(datev->array2[1]);
free_mon:
	free_view(datev->array2[0]);
return_err:
	return -EINVAL;
}
int init_timev(struct timev *timev) {
	memset(timev, 0, sizeof(*timev));

	timev->array2[0] = alloc_hour(&timev->array[0]);
	if (!timev->array2[0]) {
		pr_err("timev: failed to alloc hor\n");
		goto return_err;
	}

	timev->array2[1] = timev->array[2] = alloc_timesep();
	if (!timev->array2[1]) {
		pr_err("timev: failed to alloc timesep\n");
		goto free_hour;
	}

	timev->array2[2] = alloc_min(&timev->array[3]);
	if (!timev->array2[2]) {
		pr_err("timev: failed to alloc min\n");
		goto free_timesep;
	}

	timev->text = alloc_text_view("time", timev->array2, ARRAY_SIZE(timev->array2));
	if (!timev->text) {
		pr_err("timev: failed to alloc text view\n");
		goto free_min;
	}

	return 0;
free_min:
	free_view(timev->array2[2]);
free_timesep:
	free_view(timev->array2[1]);
free_hour:
	free_view(timev->array2[0]);
return_err:
	return -EINVAL;
}
/**
 * method_create_view() - create a view in slpt
 * @argv[0] - view_type : view_type in view_utils.c, like "time-view"
 * @argv[1] - view_name : the view's name
 *
 * @return_val: return 0 if success, nagative value if failed.
 */
int method_create_view(int argc, char *argv[]) {

	struct view *v;
	struct slpt_app_res *clock_dir;
	char *view_type, *view_name;

	if(argc != 2) {
		pr_err("error: your param is error!\n");
		return -1;
	}

	clock_dir = slpt_kernel_name_to_app_res("clock", uboot_slpt_task);
	assert(clock_dir);

	/* argv[0] is the view_type, argv[1] is view_name */
	view_type = argv[0];
	view_name = argv[1];
	v = alloc_view_by_str(view_name, view_type);
	if(v == NULL) {
		pr_err("error: malloc view error.\n");
		return -1;
	}

	if (!slpt_register_view(v, clock_dir, NULL, 0)) {
		slpt_kernel_printf("failed to register clock\n");
		goto slpt_register_view_error;
	}

	slpt_display_add_view(v);

	return 0;

slpt_register_view_error:
	free_view(v);
	return -EINVAL;
}
Beispiel #7
0
TEARDOWN()
{
	free_view(&lwin);
	free_view(&rwin);
}
void destory_weekcnv(struct weekcnv *weekv) {
	free_view(weekv->text);
}
void destory_datecnv(struct datecnv *datev) {
	free_view(datev->text);
}
void destory_timev(struct timev *timev) {
	free_view(timev->text);
}