2010-03-29 06:49:20 +00:00
|
|
|
/*-
|
2017-11-20 19:49:47 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
1996-02-03 10:58:11 +00:00
|
|
|
* Copyright (c) 1989, 1993, 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1996-02-03 10:58:11 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
2000-05-04 11:28:55 +00:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
1996-02-03 10:58:11 +00:00
|
|
|
*/
|
|
|
|
|
2004-05-28 17:41:36 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/uio.h>
|
1996-02-03 10:58:11 +00:00
|
|
|
|
2010-03-29 06:49:20 +00:00
|
|
|
#define SECSPERDAY (24 * 60 * 60)
|
|
|
|
#define SECSPERHOUR (60 * 60)
|
|
|
|
#define SECSPERMINUTE (60)
|
|
|
|
#define MINSPERHOUR (60)
|
|
|
|
#define HOURSPERDAY (24)
|
|
|
|
#define FSECSPERDAY (24.0 * 60.0 * 60.0)
|
|
|
|
#define FSECSPERHOUR (60.0 * 60.0)
|
|
|
|
#define FSECSPERMINUTE (60.0)
|
|
|
|
#define FMINSPERHOUR (60.0)
|
|
|
|
#define FHOURSPERDAY (24.0)
|
|
|
|
|
|
|
|
#define DAYSPERYEAR 365
|
|
|
|
#define DAYSPERLEAPYEAR 366
|
|
|
|
|
|
|
|
/* Not yet categorized */
|
|
|
|
|
1996-02-03 10:58:11 +00:00
|
|
|
extern struct passwd *pw;
|
|
|
|
extern int doall;
|
2010-03-29 06:49:20 +00:00
|
|
|
extern time_t t1, t2;
|
2001-12-02 22:44:14 +00:00
|
|
|
extern const char *calendarFile;
|
2007-06-09 05:54:13 +00:00
|
|
|
extern int yrdays;
|
2010-03-29 06:49:20 +00:00
|
|
|
extern struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon;
|
|
|
|
extern struct fixs nmarequinox, nsepequinox, njunsolstice, ndecsolstice;
|
|
|
|
extern double UTCOffset;
|
|
|
|
extern int EastLongitude;
|
2019-02-20 06:40:52 +00:00
|
|
|
#ifdef WITH_ICONV
|
|
|
|
extern const char *outputEncoding;
|
|
|
|
#endif
|
1996-02-03 10:58:11 +00:00
|
|
|
|
1996-05-10 16:30:22 +00:00
|
|
|
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
1996-02-03 10:58:11 +00:00
|
|
|
|
2010-03-29 06:49:20 +00:00
|
|
|
/* Flags to determine the returned values by determinestyle() in parsedata.c */
|
|
|
|
#define F_NONE 0x00000
|
|
|
|
#define F_MONTH 0x00001
|
|
|
|
#define F_DAYOFWEEK 0x00002
|
|
|
|
#define F_DAYOFMONTH 0x00004
|
|
|
|
#define F_MODIFIERINDEX 0x00008
|
|
|
|
#define F_MODIFIEROFFSET 0x00010
|
|
|
|
#define F_SPECIALDAY 0x00020
|
|
|
|
#define F_ALLMONTH 0x00040
|
|
|
|
#define F_ALLDAY 0x00080
|
|
|
|
#define F_VARIABLE 0x00100
|
|
|
|
#define F_EASTER 0x00200
|
|
|
|
#define F_CNY 0x00400
|
|
|
|
#define F_PASKHA 0x00800
|
|
|
|
#define F_NEWMOON 0x01000
|
|
|
|
#define F_FULLMOON 0x02000
|
|
|
|
#define F_MAREQUINOX 0x04000
|
|
|
|
#define F_SEPEQUINOX 0x08000
|
|
|
|
#define F_JUNSOLSTICE 0x10000
|
|
|
|
#define F_DECSOLSTICE 0x20000
|
2010-08-30 22:45:32 +00:00
|
|
|
#define F_YEAR 0x40000
|
2010-03-29 06:49:20 +00:00
|
|
|
|
|
|
|
#define STRING_EASTER "Easter"
|
|
|
|
#define STRING_PASKHA "Paskha"
|
|
|
|
#define STRING_CNY "ChineseNewYear"
|
|
|
|
#define STRING_NEWMOON "NewMoon"
|
|
|
|
#define STRING_FULLMOON "FullMoon"
|
|
|
|
#define STRING_MAREQUINOX "MarEquinox"
|
|
|
|
#define STRING_SEPEQUINOX "SepEquinox"
|
|
|
|
#define STRING_JUNSOLSTICE "JunSolstice"
|
|
|
|
#define STRING_DECSOLSTICE "DecSolstice"
|
1996-02-03 10:58:11 +00:00
|
|
|
|
2010-03-29 06:49:20 +00:00
|
|
|
#define MAXCOUNT 125 /* Random number of maximum number of
|
|
|
|
* repeats of an event. Should be 52
|
|
|
|
* (number of weeks per year), if you
|
|
|
|
* want to show two years then it
|
|
|
|
* should be 104. If you are seeing
|
|
|
|
* more than this you are using this
|
|
|
|
* program wrong.
|
|
|
|
*/
|
|
|
|
|
2013-06-12 07:52:49 +00:00
|
|
|
/*
|
2010-03-29 06:49:20 +00:00
|
|
|
* All the astronomical calculations are carried out for the meridian 120
|
|
|
|
* degrees east of Greenwich.
|
|
|
|
*/
|
2013-06-12 07:52:49 +00:00
|
|
|
#define UTCOFFSET_CNY 8.0
|
2010-03-29 06:49:20 +00:00
|
|
|
|
|
|
|
extern int debug; /* show parsing of the input */
|
|
|
|
extern int year1, year2;
|
|
|
|
|
|
|
|
/* events.c */
|
|
|
|
/*
|
|
|
|
* Event sorting related functions:
|
|
|
|
* - Use event_add() to create a new event
|
|
|
|
* - Use event_continue() to add more text to the last added event
|
|
|
|
* - Use event_print_all() to display them in time chronological order
|
|
|
|
*/
|
|
|
|
struct event *event_add(int, int, int, char *, int, char *, char *);
|
|
|
|
void event_continue(struct event *events, char *txt);
|
|
|
|
void event_print_all(FILE *fp);
|
|
|
|
struct event {
|
|
|
|
int year;
|
|
|
|
int month;
|
|
|
|
int day;
|
|
|
|
int var;
|
|
|
|
char *date;
|
|
|
|
char *text;
|
|
|
|
char *extra;
|
|
|
|
struct event *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* locale.c */
|
1996-05-10 17:32:06 +00:00
|
|
|
|
2008-08-05 08:11:54 +00:00
|
|
|
struct fixs {
|
|
|
|
char *name;
|
2010-03-29 06:49:20 +00:00
|
|
|
size_t len;
|
2008-08-05 08:11:54 +00:00
|
|
|
};
|
2010-03-29 06:49:20 +00:00
|
|
|
|
|
|
|
extern const char *days[];
|
|
|
|
extern const char *fdays[];
|
|
|
|
extern const char *fmonths[];
|
|
|
|
extern const char *months[];
|
|
|
|
extern const char *sequences[];
|
|
|
|
extern struct fixs fndays[8]; /* full national days names */
|
|
|
|
extern struct fixs fnmonths[13]; /* full national months names */
|
|
|
|
extern struct fixs ndays[8]; /* short national days names */
|
|
|
|
extern struct fixs nmonths[13]; /* short national month names */
|
|
|
|
extern struct fixs nsequences[10];
|
|
|
|
|
|
|
|
void setnnames(void);
|
|
|
|
void setnsequences(char *);
|
|
|
|
|
|
|
|
/* day.c */
|
|
|
|
extern const struct tm tm0;
|
|
|
|
extern char dayname[];
|
|
|
|
void settimes(time_t,int before, int after, int friday, struct tm *tp1, struct tm *tp2);
|
|
|
|
time_t Mktime(char *);
|
|
|
|
|
|
|
|
/* parsedata.c */
|
|
|
|
int parsedaymonth(char *, int *, int *, int *, int *, char **);
|
|
|
|
void dodebug(char *type);
|
|
|
|
|
|
|
|
/* io.c */
|
|
|
|
void cal(void);
|
|
|
|
void closecal(FILE *);
|
2013-09-19 20:17:50 +00:00
|
|
|
FILE *opencalin(void);
|
|
|
|
FILE *opencalout(void);
|
|
|
|
|
2010-12-25 11:52:04 +00:00
|
|
|
/* ostern.c / paskha.c */
|
2010-03-29 06:49:20 +00:00
|
|
|
int paskha(int);
|
|
|
|
int easter(int);
|
2011-02-18 13:41:45 +00:00
|
|
|
int j2g(int);
|
2010-03-29 06:49:20 +00:00
|
|
|
|
|
|
|
/* dates.c */
|
|
|
|
extern int cumdaytab[][14];
|
2013-06-12 07:52:49 +00:00
|
|
|
extern int monthdaytab[][14];
|
2010-03-29 06:49:20 +00:00
|
|
|
extern int debug_remember;
|
|
|
|
void generatedates(struct tm *tp1, struct tm *tp2);
|
|
|
|
void dumpdates(void);
|
|
|
|
int remember_ymd(int y, int m, int d);
|
|
|
|
int remember_yd(int y, int d, int *rm, int *rd);
|
|
|
|
int first_dayofweek_of_year(int y);
|
|
|
|
int first_dayofweek_of_month(int y, int m);
|
|
|
|
int walkthrough_dates(struct event **e);
|
|
|
|
void addtodate(struct event *e, int year, int month, int day);
|
|
|
|
|
|
|
|
/* pom.c */
|
|
|
|
#define MAXMOONS 18
|
|
|
|
void pom(int year, double UTCoffset, int *fms, int *nms);
|
|
|
|
void fpom(int year, double utcoffset, double *ffms, double *fnms);
|
|
|
|
|
|
|
|
/* sunpos.c */
|
|
|
|
void equinoxsolstice(int year, double UTCoffset, int *equinoxdays, int *solsticedays);
|
|
|
|
void fequinoxsolstice(int year, double UTCoffset, double *equinoxdays, double *solsticedays);
|
|
|
|
int calculatesunlongitude30(int year, int degreeGMToffset, int *ichinesemonths);
|
2019-02-20 06:40:52 +00:00
|
|
|
|
|
|
|
#ifdef WITH_ICONV
|
|
|
|
void set_new_encoding(void);
|
|
|
|
#endif
|