예제 #1
0
파일: rerule.c 프로젝트: juddy/edcde
static void
ConvertWeekly(
	RepeatEvent	*re,
	char		*subcommand,
	unsigned int	 subcommand_size)
{
	char	 tmp_buf[32];
	int	 size = 0,
		 num_items,
		 i;

	num_items = RE_WEEKLY(re)->wd_ndaytime;

	sprintf(subcommand, "W%d", re->re_interval);
	size += strlen(subcommand);

		/* walk through Day/time data (e.g. TU 1200 Th 2000)	*/
	for (i = 0; i < num_items; i++) {

			/* The day: MO TU TH etc. */
		WeekDayToString(RE_WEEKLY(re)->wd_daytime[i].dt_day, tmp_buf);
		size += strlen(tmp_buf);

			/* Make sure the size of our buffer does not overflow */
		if (size > subcommand_size) {
			printf ("Error: Internal buffer size exceeded\n");
			return;
		}

		strcat (subcommand, tmp_buf);

			/* The hours: 1000 1400 etc. */
		NumsToBuf((unsigned int *)RE_WEEKLY(re)->wd_daytime[i].dt_time,
			  RE_WEEKLY(re)->wd_daytime[i].dt_ntime, NUM_NUM,
			  subcommand, subcommand_size - size);

		size = strlen(subcommand);
	}
		/* Tack on the duration information */
	sprintf(tmp_buf, " #%d", re->re_duration);

	size += strlen(tmp_buf);
	if (size > subcommand_size) {
		printf ("Error: Internal buffer size exceeded\n");
		return;
	}
	strcat (subcommand, tmp_buf);
}
예제 #2
0
파일: rerule.c 프로젝트: juddy/edcde
/*
 * Takes an array of numbers, converts them back into their string
 * type (e.g. SU 1W etc) and puts them into a string buffer with end
 * marks as necessary, seperated by spaces.
 */
static void
NumsToBuf(
	unsigned int	*array,
	unsigned int	 array_size,
	NumType		 type,
	char		*buffer,
	unsigned int	 buf_size)
{
	int 	 i,
		 size = 0; 
	char	 tmp_buf[32],
		 tmp_buf2[32];

	for (i = 0; i < array_size; i++) {
		if (type == NUM_NUM)
			sprintf(tmp_buf2, " %d", RE_MASK_STOP(array[i]));
		else if (type == NUM_DAY)
			WeekDayToString(RE_MASK_STOP(array[i]), tmp_buf2);
		else if (type == NUM_WEEK)
			WeekNumberToString(RE_MASK_STOP(array[i]), tmp_buf2);
			
			/* Add end mark if needed */
		if (RE_STOP_IS_SET(array[i])) {
			sprintf(tmp_buf, "%s$", tmp_buf2);
			strcat (buffer, tmp_buf);
			size += strlen(tmp_buf);
		} else {
			strcat (buffer, tmp_buf2);
			size += strlen(tmp_buf2);
		}

			/* Make sure the size of our buffer does not overflow */
		if (size > buf_size) {
			printf ("Error: Internal buffer size exceeded\n");
			return;
		}
	}
}
예제 #3
0
파일: main.cpp 프로젝트: alexey-malov/oop
void main()
{
	std::cout << WeekDayToString(WeekDay::Sunday) << std::endl;
}