nrelease - fix/improve livecd
[dragonfly.git] / usr.bin / calendar / days.h
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 2020 The DragonFly Project.  All rights reserved.
5  *
6  * This code is derived from software contributed to The DragonFly Project
7  * by Aaron LI <aly@aaronly.me>
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in
17  *    the documentation and/or other materials provided with the
18  *    distribution.
19  * 3. Neither the name of The DragonFly Project nor the names of its
20  *    contributors may be used to endorse or promote products derived
21  *    from this software without specific, prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
27  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  */
36
37 #ifndef DAYS_H_
38 #define DAYS_H_
39
40 /* IDs of special days */
41 enum {
42         SD_NONE,
43         SD_EASTER,
44         SD_PASKHA,
45         SD_ADVENT,
46         SD_CNY,
47         SD_CQINGMING,
48         SD_CJIEQI,
49         SD_MAREQUINOX,
50         SD_SEPEQUINOX,
51         SD_JUNSOLSTICE,
52         SD_DECSOLSTICE,
53         SD_NEWMOON,
54         SD_FULLMOON,
55 };
56
57 struct cal_day;
58
59 struct specialday {
60         int              id;            /* enum ID of the special day */
61         const char      *name;          /* name of the special day */
62         size_t           len;           /* length of the name */
63         char            *n_name;        /* national name of the special day */
64         size_t           n_len;         /* length of the national name */
65
66         /* function to find days of the special day in [rd1, rd2] */
67         int     (*find_days)(int offset, struct cal_day **dayp, char **edp);
68 };
69
70 extern struct specialday specialdays[];
71
72 int     find_days_ymd(int year, int month, int day,
73                       struct cal_day **dayp, char **edp);
74 int     find_days_dom(int dom, struct cal_day **dayp, char **edp);
75 int     find_days_month(int month, struct cal_day **dayp, char **edp);
76 int     find_days_mdow(int month, int dow, int index,
77                        struct cal_day **dayp, char **edp);
78
79 #endif