rc.conf: Add and document the missing root_rw_mount=YES
[dragonfly.git] / usr.bin / calendar / calendar.h
blobbb4828696a2cb5e539799dc900aeb5d659c6bde8
1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2020 The DragonFly Project. All rights reserved.
5 * Copyright (c) 1989, 1993, 1994
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to The DragonFly Project
9 * by Aaron LI <aly@aaronly.me>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
35 * $FreeBSD: head/usr.bin/calendar/calendar.h 326025 2017-11-20 19:49:47Z pfg $
38 #ifndef CALENDAR_H_
39 #define CALENDAR_H_
41 #include <stdbool.h>
42 #include <stddef.h>
44 #ifndef __unused
45 #define __unused __attribute__((__unused__))
46 #endif
47 #ifndef __daed2
48 #define __dead2 __attribute__((__noreturn__))
49 #endif
52 * Maximum number of repeats of an event. 100 should be enough, which is
53 * about the number of weeks in 2 years). If you need more, then you may
54 * be using this program wrong...
56 #define CAL_MAX_REPEAT 100
58 #define DPRINTF(...) \
59 if (Options.debug) fprintf(stderr, __VA_ARGS__)
60 #define DPRINTF2(...) \
61 if (Options.debug >= 2) fprintf(stderr, __VA_ARGS__)
62 #define DPRINTF3(...) \
63 if (Options.debug >= 3) fprintf(stderr, __VA_ARGS__)
66 struct location;
67 struct cal_day;
69 struct cal_options {
70 struct location *location;
71 double time; /* [0, 1) time of now in unit of days */
72 int today; /* R.D. of today to remind events */
73 int day_begin; /* beginning of date range to remind events */
74 int day_end; /* end of date range to remind events */
75 int debug; /* debug log level (higher means more verbose) */
76 bool allmode; /* whether to process calendars for all users */
79 /* IDs of supported calendars */
80 enum {
81 CAL_GREGORIAN,
82 CAL_JULIAN,
83 CAL_CHINESE,
86 struct calendar {
87 int id; /* enum ID of the calendar */
88 const char *name;
89 int (*format_date)(char *buf, size_t size, int rd);
90 int (*find_days_ymd)(int year, int month, int day,
91 struct cal_day **dayp, char **edp);
92 int (*find_days_dom)(int dom, struct cal_day **dayp, char **edp);
93 int (*find_days_month)(int month, struct cal_day **dayp,
94 char **edp);
95 int (*find_days_mdow)(int month, int dow, int index,
96 struct cal_day **dayp, char **edp);
99 extern struct cal_options Options;
100 extern struct calendar *Calendar;
101 extern const char *calendarDirs[]; /* paths to search for calendar files */
103 bool set_calendar(const char *name);
105 #endif