Beispiel #1
0
/*
 * Returns a new allocated object with its contents
 * 		@content:
 * 			"generic" pointer to the stored object;
 * 		@type:
 * 			Define the type of the stored object. This information is useful
 * 			when unpacking, deleting and iterating through objects;
 *
 */
CP_Object* cp_newObject(void *content, CP_ObjectType type)
{
	CP_Object *obj;

	obj = cp_new(1, CP_Object);
	obj->type = type;
	obj->content = content;
	obj->next = NULL;
	obj->previous = NULL;

	return obj;
}
Beispiel #2
0
/*
 * This method allocates a new Series structure and returns a pointer
 * 		@label:
 * 			A label that might be used to name the series in the plot;
 * 		@type:
 * 			The object type defined at the enum _CP_OBJECT_TYPE_
 *
 * You probably won't use this function, you'll use some of the macros that
 * expands to this function, such as: cp_newDataSeries, cp_newColorSeries and
 * etc...
 *
 */
CP_Series *cp_newSeries(char *label, CP_ObjectType type)
{
	CP_Series *series;

	series = cp_new(1, CP_Series);
	series->label = label;
	series->type = type;
	series->first = NULL;
	series->last = NULL;
	series->iter = NULL;
	series->size = 0;

	return series;
}
Beispiel #3
0
static int		set_clock	(CalcHandle* handle, CalcClock* _clock)
{
	CalcParam *param;

	uint32_t calc_time;
	struct tm ref, cur;
	time_t r, c, now;

	time(&now);
	memcpy(&ref, localtime(&now), sizeof(struct tm));

	ref.tm_year = 1997 - 1900;
	ref.tm_mon = 0;
	ref.tm_yday = 0;
	ref.tm_mday = 1;
	ref.tm_wday = 3;
	ref.tm_hour = 0;
	ref.tm_min = 0;
	ref.tm_sec = 0;
	//ref.tm_isdst = 1;
	r = mktime(&ref);

	cur.tm_year = _clock->year - 1900;
	cur.tm_mon = _clock->month - 1;
	cur.tm_mday = _clock->day;
	cur.tm_hour = _clock->hours;
	cur.tm_min = _clock->minutes;
	cur.tm_sec = _clock->seconds;
	cur.tm_isdst = 1;
	c = mktime(&cur);

	calc_time = (uint32_t)difftime(c, r);

	g_snprintf(update_->text, sizeof(update_->text), _("Setting clock..."));
	update_label();

	param = cp_new(PID_CLK_SEC, 4);
	param->data[0] = MSB(MSW(calc_time));
	param->data[1] = LSB(MSW(calc_time));
	param->data[2] = MSB(LSW(calc_time));
	param->data[3] = LSB(LSW(calc_time));
	TRYF(cmd_s_param_set(handle, param));
	TRYF(cmd_r_data_ack(handle));
	cp_del(param);

	param = cp_new(PID_CLK_DATE_FMT, 1);
	param->data[0] = _clock->date_format == 3 ? 0 : _clock->date_format;
	TRYF(cmd_s_param_set(handle, param));
	TRYF(cmd_r_data_ack(handle));
	cp_del(param);

	param = cp_new(PID_CLK_TIME_FMT, 1);
	param->data[0] = _clock->time_format == 24 ? 1 : 0;
	TRYF(cmd_s_param_set(handle, param));
	TRYF(cmd_r_data_ack(handle));
	cp_del(param);

	param = cp_new(PID_CLK_ON, 1);
	param->data[0] = _clock->state;
	TRYF(cmd_s_param_set(handle, param));
	TRYF(cmd_r_data_ack(handle));
	cp_del(param);

	return 0;
}