1205821Sedwin/*- 213877Swosch * Copyright (c) 1989, 1993, 1994 313877Swosch * The Regents of the University of California. All rights reserved. 413877Swosch * 513877Swosch * Redistribution and use in source and binary forms, with or without 613877Swosch * modification, are permitted provided that the following conditions 713877Swosch * are met: 813877Swosch * 1. Redistributions of source code must retain the above copyright 913877Swosch * notice, this list of conditions and the following disclaimer. 1013877Swosch * 2. Redistributions in binary form must reproduce the above copyright 1113877Swosch * notice, this list of conditions and the following disclaimer in the 1213877Swosch * documentation and/or other materials provided with the distribution. 1313877Swosch * 4. Neither the name of the University nor the names of its contributors 1413877Swosch * may be used to endorse or promote products derived from this software 1513877Swosch * without specific prior written permission. 1613877Swosch * 1713877Swosch * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1813877Swosch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1913877Swosch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2013877Swosch * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2113877Swosch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2213877Swosch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2313877Swosch * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2413877Swosch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2513877Swosch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2613877Swosch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2713877Swosch * SUCH DAMAGE. 2859945Sphantom * 2959945Sphantom * $FreeBSD: releng/10.2/usr.bin/calendar/calendar.h 285291 2015-07-08 21:06:19Z bapt $ 3013877Swosch */ 3113877Swosch 32129814Sstefanf#include <sys/types.h> 33129814Sstefanf#include <sys/uio.h> 3413877Swosch 35205821Sedwin#define SECSPERDAY (24 * 60 * 60) 36205821Sedwin#define SECSPERHOUR (60 * 60) 37205821Sedwin#define SECSPERMINUTE (60) 38205821Sedwin#define MINSPERHOUR (60) 39205821Sedwin#define HOURSPERDAY (24) 40205821Sedwin#define FSECSPERDAY (24.0 * 60.0 * 60.0) 41205821Sedwin#define FSECSPERHOUR (60.0 * 60.0) 42205821Sedwin#define FSECSPERMINUTE (60.0) 43205821Sedwin#define FMINSPERHOUR (60.0) 44205821Sedwin#define FHOURSPERDAY (24.0) 45205821Sedwin 46205821Sedwin#define DAYSPERYEAR 365 47205821Sedwin#define DAYSPERLEAPYEAR 366 48205821Sedwin 49205821Sedwin/* Not yet categorized */ 50205821Sedwin 5113877Swoschextern struct passwd *pw; 5213877Swoschextern int doall; 53205821Sedwinextern time_t t1, t2; 5487235Smarkmextern const char *calendarFile; 55170447Sgrogextern int yrdays; 56205821Sedwinextern struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon; 57205821Sedwinextern struct fixs nmarequinox, nsepequinox, njunsolstice, ndecsolstice; 58205821Sedwinextern double UTCOffset; 59205821Sedwinextern int EastLongitude; 6013877Swosch 61205821Sedwin#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) 62205821Sedwin 63205821Sedwin/* Flags to determine the returned values by determinestyle() in parsedata.c */ 64205821Sedwin#define F_NONE 0x00000 65205821Sedwin#define F_MONTH 0x00001 66205821Sedwin#define F_DAYOFWEEK 0x00002 67205821Sedwin#define F_DAYOFMONTH 0x00004 68205821Sedwin#define F_MODIFIERINDEX 0x00008 69205821Sedwin#define F_MODIFIEROFFSET 0x00010 70205821Sedwin#define F_SPECIALDAY 0x00020 71205821Sedwin#define F_ALLMONTH 0x00040 72205821Sedwin#define F_ALLDAY 0x00080 73205821Sedwin#define F_VARIABLE 0x00100 74205821Sedwin#define F_EASTER 0x00200 75205821Sedwin#define F_CNY 0x00400 76205821Sedwin#define F_PASKHA 0x00800 77205821Sedwin#define F_NEWMOON 0x01000 78205821Sedwin#define F_FULLMOON 0x02000 79205821Sedwin#define F_MAREQUINOX 0x04000 80205821Sedwin#define F_SEPEQUINOX 0x08000 81205821Sedwin#define F_JUNSOLSTICE 0x10000 82205821Sedwin#define F_DECSOLSTICE 0x20000 83212035Sedwin#define F_YEAR 0x40000 84205821Sedwin 85205821Sedwin#define STRING_EASTER "Easter" 86205821Sedwin#define STRING_PASKHA "Paskha" 87205821Sedwin#define STRING_CNY "ChineseNewYear" 88205821Sedwin#define STRING_NEWMOON "NewMoon" 89205821Sedwin#define STRING_FULLMOON "FullMoon" 90205821Sedwin#define STRING_MAREQUINOX "MarEquinox" 91205821Sedwin#define STRING_SEPEQUINOX "SepEquinox" 92205821Sedwin#define STRING_JUNSOLSTICE "JunSolstice" 93205821Sedwin#define STRING_DECSOLSTICE "DecSolstice" 94205821Sedwin 95205821Sedwin#define MAXCOUNT 125 /* Random number of maximum number of 96205821Sedwin * repeats of an event. Should be 52 97205821Sedwin * (number of weeks per year), if you 98205821Sedwin * want to show two years then it 99205821Sedwin * should be 104. If you are seeing 100205821Sedwin * more than this you are using this 101205821Sedwin * program wrong. 102205821Sedwin */ 103205821Sedwin 104251647Sgrog/* 105205821Sedwin * All the astronomical calculations are carried out for the meridian 120 106205821Sedwin * degrees east of Greenwich. 107205821Sedwin */ 108251647Sgrog#define UTCOFFSET_CNY 8.0 109205821Sedwin 110205821Sedwinextern int debug; /* show parsing of the input */ 111205821Sedwinextern int year1, year2; 112205821Sedwin 113205821Sedwin/* events.c */ 114205821Sedwin/* 115205821Sedwin * Event sorting related functions: 116205821Sedwin * - Use event_add() to create a new event 117205821Sedwin * - Use event_continue() to add more text to the last added event 118205821Sedwin * - Use event_print_all() to display them in time chronological order 119205821Sedwin */ 120205821Sedwinstruct event *event_add(int, int, int, char *, int, char *, char *); 121205821Sedwinvoid event_continue(struct event *events, char *txt); 122205821Sedwinvoid event_print_all(FILE *fp); 123205821Sedwinstruct event { 124205821Sedwin int year; 125205821Sedwin int month; 126205821Sedwin int day; 127205821Sedwin int var; 128205821Sedwin char *date; 129205821Sedwin char *text; 130205821Sedwin char *extra; 131205821Sedwin struct event *next; 132205821Sedwin}; 133205821Sedwin 134205821Sedwin/* locale.c */ 135205821Sedwin 136205821Sedwinstruct fixs { 137205821Sedwin char *name; 138205821Sedwin size_t len; 139205821Sedwin}; 140205821Sedwin 141205821Sedwinextern const char *days[]; 142205821Sedwinextern const char *fdays[]; 143205821Sedwinextern const char *fmonths[]; 144205821Sedwinextern const char *months[]; 145205821Sedwinextern const char *sequences[]; 146205821Sedwinextern struct fixs fndays[8]; /* full national days names */ 147205821Sedwinextern struct fixs fnmonths[13]; /* full national months names */ 148205821Sedwinextern struct fixs ndays[8]; /* short national days names */ 149205821Sedwinextern struct fixs nmonths[13]; /* short national month names */ 150205821Sedwinextern struct fixs nsequences[10]; 151205821Sedwin 152205821Sedwinvoid setnnames(void); 153205821Sedwinvoid setnsequences(char *); 154205821Sedwin 155205821Sedwin/* day.c */ 156205821Sedwinextern const struct tm tm0; 157205821Sedwinextern char dayname[]; 158205821Sedwinvoid settimes(time_t,int before, int after, int friday, struct tm *tp1, struct tm *tp2); 159205821Sedwintime_t Mktime(char *); 160205821Sedwin 161205821Sedwin/* parsedata.c */ 162205821Sedwinint parsedaymonth(char *, int *, int *, int *, int *, char **); 163205821Sedwinvoid dodebug(char *type); 164205821Sedwin 165205821Sedwin/* io.c */ 166181322Sedwinvoid cal(void); 167181322Sedwinvoid closecal(FILE *); 168255715SdbFILE *opencalin(void); 169255715SdbFILE *opencalout(void); 17013877Swosch 171216697Sosa/* ostern.c / paskha.c */ 172205821Sedwinint paskha(int); 173205821Sedwinint easter(int); 174218797Sosaint j2g(int); 17513877Swosch 176205821Sedwin/* dates.c */ 177205821Sedwinextern int cumdaytab[][14]; 178251647Sgrogextern int monthdaytab[][14]; 179205821Sedwinextern int debug_remember; 180205821Sedwinvoid generatedates(struct tm *tp1, struct tm *tp2); 181205821Sedwinvoid dumpdates(void); 182205821Sedwinint remember_ymd(int y, int m, int d); 183205821Sedwinint remember_yd(int y, int d, int *rm, int *rd); 184205821Sedwinint first_dayofweek_of_year(int y); 185205821Sedwinint first_dayofweek_of_month(int y, int m); 186205821Sedwinint walkthrough_dates(struct event **e); 187205821Sedwinvoid addtodate(struct event *e, int year, int month, int day); 18813877Swosch 189205821Sedwin/* pom.c */ 190205821Sedwin#define MAXMOONS 18 191205821Sedwinvoid pom(int year, double UTCoffset, int *fms, int *nms); 192205821Sedwinvoid fpom(int year, double utcoffset, double *ffms, double *fnms); 19315720Sache 194205821Sedwin/* sunpos.c */ 195205821Sedwinvoid equinoxsolstice(int year, double UTCoffset, int *equinoxdays, int *solsticedays); 196205821Sedwinvoid fequinoxsolstice(int year, double UTCoffset, double *equinoxdays, double *solsticedays); 197205821Sedwinint calculatesunlongitude30(int year, int degreeGMToffset, int *ichinesemonths); 198