Example #1
0
extern void
print_week_range(Calendar * c, Tick start_tick, Tick end_tick)
{

    Props 		*p = (Props *)c->properties;
    register Tick 	first_date = start_tick;
    int 		num_weeks;
    Boolean 	done = False, first = True;
    int 		num_page = 1;
    void *xp = (void *)NULL;

    /* get number of weeks needed to print */

    num_weeks = ((end_tick - start_tick)/wksec) + 1;

    if (num_weeks <= 0)
        num_weeks = 1;

    first_date = first_dow(first_date);
    if (!timeok(first_date))
        first_date = get_bot();

    if ((xp = x_open_file(c)) == (void *)NULL)
        return;

    for (; num_weeks > 0; num_weeks--) {
        while (!done) {
            done = print_week(c, num_page, xp, first_date, p, first);
            num_page++;
            first = False;
        }
        done = False;
        num_page = 1;
    }

    x_print_file(xp, c);
}
Example #2
0
int proc_options(char *s, int *moonphases, char **nat, char **relig,
					char **date_form, char **time_form, char **ev_form,
					char **todo_form, int *iftodo, int *ifevent,
					int *weekout, int *fdow, char **astro)
{
	FILE *fp; int holder;
	char *line = NULL; size_t len = 0; ssize_t read;
	int ind;

	if (strcmp(s,"-") == 0)
		return 0;
	if ((fp = fopen(s,"r")) == NULL) {
		fprintf(stderr,"dozcal:  unable to open file "
			"\"%s\", with this error:\n\t%d: "
			"%s\n",s,errno,strerror(errno));
		return 0;
	}
	while ((read = getline(&line, &len, fp)) != -1) {
		chomp(line);
		if (strstr(line,"PRINT_TODOS")) {
			*iftodo = 1;
			continue;
		} else if (strstr(line,"UTCTIME")) {
			utc = 1;
			continue;
		} else if (strstr(line,"NO_EVENT")) {
			*ifevent = 0;
			continue;
		} else if (strstr(line,"WEEKLY")) {
			*weekout = 1;
			continue;
		} else if (strstr(line,"NOCOLOR")) {
			allopts[NOCOLOR].colconst = -1;
			continue;
		}
		if (check_line(line) >= 1)
			continue;
		if (strstr(line,"MOON")) {
			if (strstr(line,"major"))
				*moonphases = 2;
			if (strstr(line,"all"))
				*moonphases = 1;
		} else if (strstr(line,"RELIG")) {
			holder = get_impstr(line);
			*relig = realloc(*relig,((strlen(line)+1) * sizeof(char)));
			strcpy(*relig,line+holder);
		} else if (strstr(line,"NATION")) {
			holder = get_impstr(line);
			*nat = realloc(*nat,((strlen(line)+1) * sizeof(char)));
			strcpy(*nat,line+holder);
		} else if (strstr(line,"ASTRON")) {
			holder = get_impstr(line);
			*astro = realloc(*astro,((strlen(line)+1) * sizeof(char)));
			strcpy(*astro,line+holder);
		} else if (strstr(line,"TIMEZONE")) {
			holder = get_impstr(line);
			tzoffset = doztodec(line+holder);
		} else if (strstr(line,"GEOG")) {
			holder = get_impstr(line);
			proc_geog(line+holder);
		} else if (strstr(line,"DATE_FORMAT")) {
			holder = get_impstr(line);
			*date_form = realloc(*date_form,((strlen(line)+1) * sizeof(char)));
			strcpy(*date_form,line+holder);
		} else if (strstr(line,"TIME_FORMAT")) {
			holder = get_impstr(line);
			*time_form = realloc(*time_form,((strlen(line)+1) * sizeof(char)));
			strcpy(*time_form,line+holder);
		} else if (strstr(line,"EVENT_FORMAT")) {
			holder = get_impstr(line);
			*ev_form = realloc(*ev_form,((strlen(line)+1) * sizeof(char)));
			strcpy(*ev_form,line+holder);
		} else if (strstr(line,"TODO_FORMAT")) {
			holder = get_impstr(line);
			*todo_form = realloc(*todo_form,((strlen(line)+1) * sizeof(char)));
			strcpy(*todo_form,line+holder);
		} else if (strstr(line,"INPUT")) {
			holder = get_impstr(line);
			process_file(line+holder);
		} else if (strstr(line,"SCRIPT")) {
			holder = get_impstr(line);
			call_lua(line+holder);
		} else if (strstr(line,"FIRST_DOW")) {
			holder = get_impstr(line);
			*fdow = first_dow(line+holder);
		} else if (strstr(line,"WHOLE_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CALENDAR_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EVENT_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_TITLE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_TITLE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_WEEK_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_WEEK_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_TITLE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_TITLE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_LINE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_LINE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TODO_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_TITLE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_TITLE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_LINE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_LINE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"EV_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TITLE_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"TITLE_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"BOT_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"BOT_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"WARNING_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"WARNING_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"INACTIVE_BORDER_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"INACTIVE_BORDER_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"ACTIVE_BORDER_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"ACTIVE_BORDER_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"WHOLE_EV_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"WHOLE_TODO_BG")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_FORE")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else if (strstr(line,"CAL_BACK")) {
			ind = find_color_ind(line);
			holder = get_impstr(line);
			proc_color(line+holder,line,ind);
		} else {
			fprintf(stderr,"dozcal:  option \"%s\" is not "
				"recognized; skipping...\n",line);
		}
	}
	free(line);
	fclose(fp);
	return 0;
}