Index: stable/8/usr.bin/calendar/Makefile =================================================================== --- stable/8/usr.bin/calendar/Makefile (revision 211722) +++ stable/8/usr.bin/calendar/Makefile (revision 211723) @@ -1,30 +1,34 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ PROG= calendar -SRCS= calendar.c io.c day.c ostern.c paskha.c +SRCS= calendar.c locale.c events.c dates.c parsedata.c io.c day.c \ + ostern.c paskha.c pom.c sunpos.c +LDADD= -lm INTER= de_AT.ISO_8859-15 de_DE.ISO8859-1 fr_FR.ISO8859-1 \ hr_HR.ISO8859-2 hu_HU.ISO8859-2 ru_RU.KOI8-R uk_UA.KOI8-U DE_LINKS= de_DE.ISO8859-15 FR_LINKS= fr_FR.ISO8859-15 TEXTMODE?= 444 + +WARNS?= 7 beforeinstall: ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \ ${.CURDIR}/calendars/calendar.* ${DESTDIR}${SHAREDIR}/calendar .for lang in ${INTER} mkdir -p ${DESTDIR}${SHAREDIR}/calendar/${lang} ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${TEXTMODE} \ ${.CURDIR}/calendars/${lang}/calendar.* \ ${DESTDIR}${SHAREDIR}/calendar/${lang} .endfor .for link in ${DE_LINKS} rm -rf ${DESTDIR}${SHAREDIR}/calendar/${link} ln -s de_DE.ISO8859-1 ${DESTDIR}${SHAREDIR}/calendar/${link} .endfor .for link in ${FR_LINKS} rm -rf ${DESTDIR}${SHAREDIR}/calendar/${link} ln -s fr_FR.ISO8859-1 ${DESTDIR}${SHAREDIR}/calendar/${link} .endfor .include Index: stable/8/usr.bin/calendar/calendar.1 =================================================================== --- stable/8/usr.bin/calendar/calendar.1 (revision 211722) +++ stable/8/usr.bin/calendar/calendar.1 (revision 211723) @@ -1,265 +1,317 @@ .\" Copyright (c) 1989, 1990, 1993 .\" 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. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" 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. .\" .\" @(#)calendar.1 8.1 (Berkeley) 6/29/93 .\" $FreeBSD$ .\" .Dd June 13, 2002 .Dt CALENDAR 1 .Os .Sh NAME .Nm calendar .Nd reminder service .Sh SYNOPSIS .Nm .Op Fl a .Op Fl A Ar num .Op Fl B Ar num .Op Fl F Ar friday .Op Fl f Ar calendarfile .Oo .Bk -words .Fl t Ar dd Ns .Sm off .Op . Ar mm Op . Ar year .Sm on .Ek .Oc .Op Fl W Ar num +.Op Fl U Ar UTC-offset +.Op Fl l Ar longitude .Sh DESCRIPTION The .Nm utility checks the current directory for a file named .Pa calendar and displays lines that begin with either today's date or tomorrow's. On the day before a weekend (normally Friday), events for the next three days are displayed. .Pp The following options are available: .Bl -tag -width Ds .It Fl A Ar num Print lines from today and the next .Ar num days (forward, future). .It Fl a Process the ``calendar'' files of all users and mail the results to them. This requires super-user privileges. .It Fl B Ar num Print lines from today and the previous .Ar num days (backward, past). .It Fl F Ar friday Specify which day of the week is ``Friday'' (the day before the weekend begins). Default is 5. .It Fl f Pa calendarfile Use .Pa calendarfile as the default calendar file. .It Xo Fl t .Sm off .Ar dd .Op . Ar mm Op . Ar year .Sm on .Xc For test purposes only: set date directly to argument values. +.It Fl l Ar longitude , Fl U Ar UTC-offset +Only one is needed: +Perform lunar and solar calculations from this longitude or from +this UTC offset. +If neither is specified, the calculations will be based on the +difference between UTC time and localtime. .It Fl W Ar num Print lines from today and the next .Ar num days (forward, future). Ignore weekends when calculating the number of days. .El .Pp To handle calendars in your national code table you can specify .Dq LANG= in the calendar file as early as possible. -To handle national Easter -names in the calendars -.Dq Easter= -(for Catholic Easter) or -.Dq Paskha= -(for Orthodox Easter) can be used. .Pp +To handle the local name of sequences, you can specify them as: +.Dq SEQUENCE= +in the calendar file as early as possible. +.Pp +The names of the following special days are recognized: +.Bl -tag -width 123456789012345 -compact +.It Easter +Catholic Easter. +.It Paskha +Orthodox Easter. +.It NewMoon +The lunar New Moon. +.It FullMoon +The lunar Full Moon. +.It MarEquinox +The solar equinox in March. +.It JunSolstice +The solar solstice in June. +.It SepEquinox +The solar equinox in March. +.It DecSolstice +The solar solstice in December. +.It ChineseNewYear +The first day of the Chinese year. +.El +These names may be reassigned to their local names via an assignment +like +.Dq Easter=Pasen +in the calendar file. +.Pp Other lines should begin with a month and day. They may be entered in almost any format, either numeric or as character strings. If the proper locale is set, national month and weekday names can be used. A single asterisk (``*'') matches every month. A day without a month matches that day of every week. A month without a day matches the first of that month. Two numbers default to the month followed by the day. Lines with leading tabs default to the last entered date, allowing multiple line specifications for a single date. .Pp -``Easter'', is Easter for this year, and may be followed by a positive -or negative integer. +The names of the recognized special days may be followed by a +positive or negative integer, like: +.Dq Easter+3 +or +.Dq Pashka-4 . .Pp -``Paskha'', is Orthodox Easter for this year, and may be followed by a -positive or negative integer. -.Pp Weekdays may be followed by ``-4'' ...\& ``+5'' (aliases for last, first, second, third, fourth) for moving events like ``the last Monday in April''. .Pp By convention, dates followed by an asterisk are not fixed, i.e., change from year to year. .Pp Day descriptions start after the first character in the line; if the line does not contain a character, it is not displayed. If the first character in the line is a character, it is treated as a continuation of the previous line. .Pp The ``calendar'' file is preprocessed by .Xr cpp 1 , allowing the inclusion of shared files such as lists of company holidays or meetings. If the shared file is not referenced by a full pathname, .Xr cpp 1 searches in the current (or home) directory first, and then in the directory .Pa /usr/share/calendar . Empty lines and lines protected by the C commenting syntax .Pq Li /* ... */ are ignored. .Pp Some possible calendar entries ( characters highlighted by \fB\et\fR sequence) .Bd -unfilled -offset indent LANG=C Easter=Ostern #include #include 6/15\fB\et\fRJune 15 (if ambiguous, will default to month/day). Jun. 15\fB\et\fRJune 15. 15 June\fB\et\fRJune 15. Thursday\fB\et\fREvery Thursday. June\fB\et\fREvery June 1st. 15 *\fB\et\fR15th of every month. May Sun+2\fB\et\fRsecond Sunday in May (Muttertag) 04/SunLast\fB\et\fRlast Sunday in April, \fB\et\fRsummer time in Europe Easter\fB\et\fREaster Ostern-2\fB\et\fRGood Friday (2 days before Easter) Paskha\fB\et\fROrthodox Easter .Ed .Sh FILES .Bl -tag -width calendar.christian -compact .It Pa calendar file in current directory .It Pa ~/.calendar .Pa calendar HOME directory. A chdir is done into this directory if it exists. .It Pa ~/.calendar/calendar calendar file to use if no calendar file exists in the current directory. .It Pa ~/.calendar/nomail do not send mail if this file exists. .El .Pp -The following default calendar files are provided: +The following default calendar files are provided in +.Pa /usr/share/calendars: .Pp .Bl -tag -width calendar.southafrica -compact .It Pa calendar.all File which includes all the default files. .It Pa calendar.australia Calendar of events in Australia. .It Pa calendar.birthday Births and deaths of famous (and not-so-famous) people. .It Pa calendar.christian Christian holidays. This calendar should be updated yearly by the local system administrator so that roving holidays are set correctly for the current year. .It Pa calendar.computer Days of special significance to computer people. .It Pa calendar.croatian Calendar of events in Croatia. +.It Pa calendar.dutch +Calendar of events in the Netherlands. .It Pa calendar.freebsd Birthdays of .Fx committers. .It Pa calendar.french Calendar of events in France. .It Pa calendar.german Calendar of events in Germany. .It Pa calendar.history Everything else, mostly U.S.\& historical events. .It Pa calendar.holiday Other holidays, including the not-well-known, obscure, and .Em really obscure. .It Pa calendar.judaic Jewish holidays. This calendar should be updated yearly by the local system administrator so that roving holidays are set correctly for the current year. .It Pa calendar.music Musical events, births, and deaths. Strongly oriented toward rock 'n' roll. .It Pa calendar.newzealand Calendar of events in New Zealand. .It Pa calendar.russian Russian calendar. .It Pa calendar.southafrica Calendar of events in South Africa. .It Pa calendar.usholiday U.S.\& holidays. This calendar should be updated yearly by the local system administrator so that roving holidays are set correctly for the current year. .It Pa calendar.world Includes all calendar files except for national files. .El .Sh COMPATIBILITY The .Nm program previously selected lines which had the correct date anywhere in the line. This is no longer true, the date is only recognized when it occurs at the beginning of a line. .Sh SEE ALSO .Xr at 1 , .Xr cpp 1 , .Xr mail 1 , .Xr cron 8 .Sh HISTORY A .Nm command appeared in .At v7 . +.Sh NOTES +Chinese New Year is calculated at 120 degrees east of Greenwich, +which roughly corresponds with the east coast of China. +For people west of China, this might result that the start of Chinese +New Year and the day of the related new moon might differ. +.Pp +The phases of the moon and the longitude of the sun are calculated +against the local position which corresponds with 30 degrees times +the time-difference towards Greenwich. +.Pp +The new and full moons are happening on the day indicated: They +might happen in the time period in the early night or in the late +evening. +It doesn't indicate that they are starting in the night on that date. +.Pp +Because of minor differences between the output of the formulas +used and other sources on the Internet, Druids and Werewolves should +double-check the start and end time of solar and lunar events. .Sh BUGS The .Nm -utility does not handle Jewish holidays and moon phases. +utility does not handle Jewish holidays. +.Pp +There is no possibility to properly specify the local position +needed for solar and lunar calculations. Index: stable/8/usr.bin/calendar/calendar.c =================================================================== --- stable/8/usr.bin/calendar/calendar.c (revision 211722) +++ stable/8/usr.bin/calendar/calendar.c (revision 211723) @@ -1,154 +1,225 @@ -/* +/*- * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * 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. */ #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif #if 0 #ifndef lint static char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; #endif #endif #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include +#include #include #include -#include "pathnames.h" #include "calendar.h" +#define UTCOFFSET_NOTSET 100 /* Expected between -24 and +24 */ +#define LONGITUDE_NOTSET 1000 /* Expected between -360 and +360 */ + struct passwd *pw; int doall = 0; +int debug = 0; +char *DEBUG = NULL; time_t f_time = 0; +double UTCOffset = UTCOFFSET_NOTSET; +int EastLongitude = LONGITUDE_NOTSET; -int f_dayAfter = 0; /* days after current date */ -int f_dayBefore = 0; /* days before current date */ -int Friday = 5; /* day before weekend */ - static void usage(void) __dead2; int main(int argc, char *argv[]) { + int f_dayAfter = 0; /* days after current date */ + int f_dayBefore = 0; /* days before current date */ + int Friday = 5; /* day before weekend */ + int ch; + struct tm tp1, tp2; (void)setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "-A:aB:F:f:t:W:")) != -1) + while ((ch = getopt(argc, argv, "-A:aB:dD:F:f:l:t:U:W:")) != -1) switch (ch) { case '-': /* backward contemptible */ case 'a': if (getuid()) { errno = EPERM; err(1, NULL); } doall = 1; break; case 'f': /* other calendar file */ calendarFile = optarg; break; - case 't': /* other date, undocumented, for tests */ - f_time = Mktime(optarg); - break; - case 'W': /* we don't need no steenking Fridays */ Friday = -1; - /* FALLTHROUGH */ + case 'A': /* days after current date */ f_dayAfter = atoi(optarg); break; case 'B': /* days before current date */ f_dayBefore = atoi(optarg); break; - case 'F': + case 'F': /* Change the time: When does weekend start? */ Friday = atoi(optarg); break; + case 'l': /* Change longitudal position */ + EastLongitude = strtol(optarg, NULL, 10); + break; + case 'U': /* Change UTC offset */ + UTCOffset = strtod(optarg, NULL); + break; + case 'd': + debug = 1; + break; + case 'D': + DEBUG = optarg; + break; + case 't': /* other date, undocumented, for tests */ + f_time = Mktime(optarg); + break; + case '?': default: usage(); } argc -= optind; argv += optind; if (argc) usage(); /* use current time */ if (f_time <= 0) (void)time(&f_time); - settime(f_time); + /* if not set, determine where I could be */ + { + if (UTCOffset == UTCOFFSET_NOTSET && + EastLongitude == LONGITUDE_NOTSET) { + /* Calculate on difference between here and UTC */ + time_t t; + struct tm tm; + long utcoffset, hh, mm, ss; + double uo; + time(&t); + localtime_r(&t, &tm); + utcoffset = tm.tm_gmtoff; + /* seconds -> hh:mm:ss */ + hh = utcoffset / SECSPERHOUR; + utcoffset %= SECSPERHOUR; + mm = utcoffset / SECSPERMINUTE; + utcoffset %= SECSPERMINUTE; + ss = utcoffset; + + /* hh:mm:ss -> hh.mmss */ + uo = mm + (100.0 * (ss / 60.0)); + uo /= 60.0 / 100.0; + uo = hh + uo / 100; + + UTCOffset = uo; + EastLongitude = UTCOffset * 15; + } else if (UTCOffset == UTCOFFSET_NOTSET) { + /* Base on information given */ + UTCOffset = EastLongitude / 15; + } else if (EastLongitude == LONGITUDE_NOTSET) { + /* Base on information given */ + EastLongitude = UTCOffset * 15; + } + } + + settimes(f_time, f_dayBefore, f_dayAfter, Friday, &tp1, &tp2); + generatedates(&tp1, &tp2); + + /* + * FROM now on, we are working in UTC. + * This will only affect moon and sun related events anyway. + */ + if (setenv("TZ", "UTC", 1) != 0) + errx(1, "setenv: %s", strerror(errno)); + tzset(); + + if (debug) + dumpdates(); + + if (DEBUG != NULL) { + dodebug(DEBUG); + exit(0); + } + if (doall) while ((pw = getpwent()) != NULL) { (void)setegid(pw->pw_gid); (void)initgroups(pw->pw_name, pw->pw_gid); (void)seteuid(pw->pw_uid); if (!chdir(pw->pw_dir)) cal(); (void)seteuid(0); } else cal(); exit(0); } static void __dead2 usage(void) { - fprintf(stderr, "%s\n%s\n", + fprintf(stderr, "%s\n%s\n%s\n", "usage: calendar [-a] [-A days] [-B days] [-F friday] " "[-f calendarfile]", - " [-t dd[.mm[.year]]] [-W days]"); + " [-d] [-t dd[.mm[.year]]] [-W days]", + " [-U utcoffset] [-l longitude]" + ); exit(1); } Index: stable/8/usr.bin/calendar/calendar.h =================================================================== --- stable/8/usr.bin/calendar/calendar.h (revision 211722) +++ stable/8/usr.bin/calendar/calendar.h (revision 211723) @@ -1,78 +1,194 @@ -/* +/*- * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * 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. * * $FreeBSD$ */ #include #include +#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 */ + extern struct passwd *pw; extern int doall; -extern struct iovec header[]; -extern struct tm *tp; +extern time_t t1, t2; extern const char *calendarFile; -extern int *cumdays; extern int yrdays; -extern struct fixs neaster, npaskha; +extern struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon; +extern struct fixs nmarequinox, nsepequinox, njunsolstice, ndecsolstice; +extern double UTCOffset; +extern int EastLongitude; -void cal(void); -void closecal(FILE *); -int getday(char *); -int getdayvar(char *); -int getfield(char *, char **, int *); -int getmonth(char *); -int geteaster(char *, int); -int getpaskha(char *, int); -int easter(int); -int isnow(char *, int *, int *, int *); -FILE *opencal(void); -void settime(time_t); -time_t Mktime(char *); -void setnnames(void); - #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) -/* some flags */ -#define F_ISMONTH 0x01 /* month (January ...) */ -#define F_ISDAY 0x02 /* day of week (Sun, Mon, ...) */ -#define F_ISDAYVAR 0x04 /* variables day of week, like SundayLast */ -#define F_EASTER 0x08 /* Easter or easter depending days */ +/* 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 -extern int f_dayAfter; /* days after current date */ -extern int f_dayBefore; /* days before current date */ -extern int Friday; /* day before weekend */ +#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" +#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. + */ + +/* + * All the astronomical calculations are carried out for the meridian 120 + * degrees east of Greenwich. + */ +#define UTCOFFSET_CNY 8.0 + +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 */ + struct fixs { char *name; - int len; + size_t len; }; + +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 *); +FILE *opencal(void); + +/* ostern.c / pashka.c */ +int paskha(int); +int easter(int); + +/* dates.c */ +extern int cumdaytab[][14]; +extern int mondaytab[][14]; +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); Index: stable/8/usr.bin/calendar/calendars/calendar.australia =================================================================== --- stable/8/usr.bin/calendar/calendars/calendar.australia (revision 211722) +++ stable/8/usr.bin/calendar/calendars/calendar.australia (revision 211723) @@ -1,58 +1,72 @@ /* * Australian holidays * * $FreeBSD$ */ #ifndef _calendar_australia_ #define _calendar_australia_ LANG=en_AU.ISO8859-1 /* Australia */ -Jan 26 Australia Day -Mar/SunLast Daylight Savings Time ends in ACT, NSW, SA, TAS and VIC. -Apr 25 Anzac Day +Jan 26 Australia Day +Apr/SunFirst Daylight Savings Time ends in ACT, NSW, SA, TAS and VIC. +Apr 25 Anzac Day Jun/MonSecond Queen's Birthday Holiday (Australia, except WA) -Oct/SunLast Daylight Savings Time starts in ACT, NSW, SA and VIC. +Oct/SunFirst Daylight Savings Time starts in ACT, NSW, SA and VIC. /* ACT, NSW, common */ -Mar 18 Canberra Day (ACT) -8/MonFirst Bank Holiday (ACT, NSW) -10/MonFirst Labour Day (ACT, NSW, SA) +Mar 18 Canberra Day (ACT) +Sep/MonLast Family & Community Day (ACT) +Aug/MonFirst Bank Holiday (ACT, NSW) +Oct/MonFirst Labour Day (ACT, NSW, SA) /* Victoria */ -3/MonSecond Labour Day (Vic) -Nov/TueFirst Melbourne Cup (Vic) +Mar/MonSecond Labour Day (VIC) +Nov/TueFirst Melbourne Cup (VIC) -/* Tasmania */ -Feb 11 Regatta Day (Tas) -Feb 27 Launceston Cup (Tas) -Mar 11 Eight Hours Day (Tas) -Oct/SunFirst Daylight Savings Time starts in TAS. -Oct 10 Launceston Show Day (Tas) -Oct 24 Hobart Show Day (Tas) -Nov 04 Recreation Day (N Tas) +/* Tasmania + * http://www.wst.tas.gov.au/employment_info/public_holidays/html/2010 + */ +Feb/MonSecond Regatta Day (TAS) +Feb/WedLast Launceston Cup (TAS) +Mar/TueFirst King Island show (TAS) +Mar/MonSecond Eight Hours Day (TAS) +Oct 10 Launceston Show Day (TAS) /* Thursday preceding second Saturday in October */ +Oct 24 Hobart Show Day (TAS) /* Thursday preceding fourth Saturday in October */ +Nov/MonFirst Recreation Day (N TAS) +/* +Oct/SatSecond-2 Launceston Show Day (TAS) // Thursday preceding second Sat in October +Oct/SatFourth-2 Hobart Show Day (TAS) // Thursday preceding fourth Sat in October +May/ThuFirst+1 Agfest (Circular Head only) // Friday following the first Thursday in May +Oct/SatFirst-1 Burnie Show // Friday preceding first Saturday in October +Oct/SatThird-1 Flinders Island Show // Friday preceding third Saturday in October + +DEVONPORT CUP Wednesday not earlier than fifth and not later than eleventh day of January +DEVONPORT SHOW Friday nearest last day in November, but not later than first day of December +*/ + /* South Australia */ May/MonThird Adelaide Cup (SA) -Dec 26 Proclamation Day holiday (SA) +Dec 26 Proclamation Day holiday (SA) /* Western Australia */ -3/MonFirst Labour Day (WA) -6/MonFirst Foundation Day (WA) -Sep 30 Queen's Birthday (WA) +Mar/MonFirst Labour Day (WA) +Jun/MonFirst Foundation Day (WA) +Sep 30 Queen's Birthday (WA) /* Northern Territory */ -5/MonFirst May Day (NT) -7/FriFirst Alice Springs Show Day (NT) -7/FriSecond Tennant Creek Show Day (NT) -7/FriThird Katherine Show Day (NT) -7/FriLast Darwin Show Day (NT) -8/MonFirst Picnic Day (NT) +May/MonFirst May Day (NT) +Jul/FriFirst Alice Springs Show Day (NT) +Jul/FriSecond Tennant Creek Show Day (NT) +Jul/FriThird Katherine Show Day (NT) +Jul/FriLast Darwin Show Day (NT) +Aug/MonFirst Picnic Day (NT) /* Queensland */ -5/MonFirst Labour Day (Qld) -Aug 14 RNA Show Day (Brisbane metro) +May/MonFirst Labour Day (QLD) +Aug/WedSecond RNA Show Day (Brisbane metro) /* Second Last Wednesday */ #endif Index: stable/8/usr.bin/calendar/calendars/calendar.dutch =================================================================== --- stable/8/usr.bin/calendar/calendars/calendar.dutch (revision 211722) +++ stable/8/usr.bin/calendar/calendars/calendar.dutch (revision 211723) @@ -1,79 +1,79 @@ /* * $FreeBSD$ * * Originally submitted by Edwin Groothuis */ LANG=nl_NL.ISO8859-15 Easter=Pasen /* * Feestdagen */ -01/01 Nieuwjaar -01/06 Driekoningen -04/01 Een April -04/30 Koninginendag -05/01 Dag van de Arbeid -05/04 Dodenherdenking -05/05 Bevrijdingsdag -10/04 Dierendag -11/01 Allerheilingen -11/02 Allerzielen -11/11 Sint Maarten -11/11 Elfde-van-de-elfde -12/05 Sinterklaas avond -12/15 Koninkrijksdag -12/24 Kerstavond -12/25 Eerste kerstdag -12/26 Tweede kerstdag -12/28 Feest der Onnozele Kinderen -12/31 Oudjaar +jan/01 Nieuwjaar +jan/06 Driekoningen +apr/01 1 april +apr/30 Koninginnedag +mei/01 Dag van de Arbeid +mei/04 Dodenherdenking +mei/05 Bevrijdingsdag +okt/04 Dierendag +nov/01 Allerheiligen +nov/02 Allerzielen +nov/11 Sint Maarten +nov/11 Elfde-van-de-elfde +dec/05 Sinterklaas avond +dec/15 Koninkrijksdag +dec/24 Kerstavond +dec/25 Eerste kerstdag +dec/26 Tweede kerstdag +dec/28 Feest der Onnozele Kinderen +dec/31 Oudjaar /* * Pasen gerelateerd */ Pasen-50 Carnaval Pasen-49 Carnaval Pasen-48 Carnaval Pasen-47 Carnaval (Vastenavond) Pasen-46 Aswoensdag -Pasen-7 Palmzondag -Pasen-3 Witte Donderdag -Pasen-2 Goede vrijdag -Pasen-1 Stille zaterdag +Pasen-7 Palmzondag +Pasen-3 Witte Donderdag +Pasen-2 Goede vrijdag +Pasen-1 Stille zaterdag Pasen Eerste paasdag -Pasen+1 Tweede paasdag +Pasen+1 Tweede paasdag Pasen+39 Hemelvaartsdag Pasen+49 Eerste Pinksterdag Pasen+50 Tweede Pinksterdag Pasen+56 Trinitatis /* * Misc */ -05/SunSecond Moederdag -06/SunThird Vaderdag -09/TueThird Prinsjesdag +mei/SunSecond Moederdag +jun/SunThird Vaderdag +sep/TueThird Prinsjesdag /* * Het koningshuis */ -01/19 Prinses Margriet (1943) -01/31 Koningin Beatrix (1938) -02/17 Prins Willem III (1817 - 1890) -02/18 Prinses Christina (1947) -04/10 Prinses Ariane (2007) -04/19 Prins Hendrik (1876 - 1934) -04/27 Kroonprins Willem Alexander (1967) -04/30 Koningin Juliana (1909 - 2004) -04/30 Mr. Pieter van Vollenhoven (1939) -05/17 Prinses Maxima (1971) -06/26 Prinses Alexia (2005) -06/29 Prins Bernhard (1911 - 2004) -08/05 Prinses Irene (1939) -08/31 Prinses Wilhelmina (1880 - 1962) -09/06 Prins Claus (1925 - 2002) -09/25 Prins Johan Friso (1968) -10/11 Prins Constantijn (1969) -12/07 Prinses Catharina-Amalia (2003) +jan/19 Prinses Margriet (1943) +jan/31 Koningin Beatrix (1938) +feb/17 Prins Willem III (1817 - 1890) +feb/18 Prinses Christina (1947) +apr/10 Prinses Ariane (2007) +apr/19 Prins Hendrik (1876 - 1934) +apr/27 Kroonprins Willem Alexander (1967) +apr/30 Koningin Juliana (1909 - 2004) +apr/30 Mr. Pieter van Vollenhoven (1939) +mei/17 Prinses Maxima (1971) +jun/26 Prinses Alexia (2005) +jun/29 Prins Bernhard (1911 - 2004) +aug/05 Prinses Irene (1939) +aug/31 Prinses Wilhelmina (1880 - 1962) +sep/06 Prins Claus (1925 - 2002) +sep/25 Prins Johan Friso (1968) +okt/11 Prins Constantijn (1969) +dec/07 Prinses Catharina-Amalia (2003) Index: stable/8/usr.bin/calendar/calendars/calendar.freebsd =================================================================== --- stable/8/usr.bin/calendar/calendars/calendar.freebsd (revision 211722) +++ stable/8/usr.bin/calendar/calendars/calendar.freebsd (revision 211723) @@ -1,318 +1,325 @@ /* * FreeBSD * * $FreeBSD$ */ #ifndef _calendar_freebsd_ #define _calendar_freebsd_ 01/01 Alexander Langer born in Duesseldorf, Nordrhein-Westfalen, Germany, 1981 01/02 Ion-Mihai "IOnut" Tetcu born in Bucharest, Romania, 1980 01/02 Patrick Li born in Beijing, People's Republic of China, 1985 01/03 Tetsurou Okazaki born in Mobara, Chiba, Japan, 1972 01/04 Hiroyuki Hanai born in Kagawa pre., Japan, 1969 01/06 Philippe Audeoud born in Bretigny-Sur-Orge, France, 1980 01/08 Michael L. Hostbaek born in Copenhagen, Denmark, 1977 01/10 Jean-Yves Lefort born in Charleroi, Belgium, 1980 01/12 Yen-Ming Lee born in Taipei, Taiwan, Republic of China, 1977 01/12 Ying-Chieh Liao born in Taipei, Taiwan, Republic of China, 1979 01/14 Yi-Jheng Lin born in Taichung, Taiwan, Republic of China, 1985 01/16 Ariff Abdullah born in Kuala Lumpur, Malaysia, 1978 01/16 Dmitry Sivachenko born in Moscow, USSR, 1978 01/16 Vanilla I. Shu born in Taipei, Taiwan, Republic of China, 1978 01/18 Dejan Lesjak born in Ljubljana, Slovenia, Yugoslavia, 1977 01/19 Marshall Kirk McKusick born in Wilmington, Delaware, United States, 1954 01/19 Marcelo S. Araujo born in Joinville, Santa Catarina, Brazil, 1981 01/19 Ruslan Ermilov born in Simferopol, USSR, 1974 01/20 Poul-Henning Kamp born in Korsoer, Denmark, 1966 01/22 Johann Visagie born in Cape Town, South Africa, 1970 01/23 Hideyuki KURASHINA born in Niigata, Japan, 1982 01/24 Matteo Riondato born in Padova, Italy, 1986 01/24 Fabien Thomas born in Avignon, France, 1971 01/25 Bernd Walter born in Moers, Nordrhein-Westfalen, Germany, 1974 01/26 Andrew Gallatin born in Buffalo, New York, United States, 1970 01/27 Nick Sayer born in San Diego, California, United States, 1968 01/27 Jacques Anthony Vidrine born in Baton Rouge, Louisiana, United States, 1971 01/31 Hidetoshi Shimokawa born in Yokohama, Kanagawa, Japan, 1970 02/01 Doug Rabson born in London, England, 1966 02/01 Nicola Vitale born in Busto Arsizio, Varese, Italy, 1976 02/01 Paul Saab born in Champaign-Urbana, Illinois, United States, 1978 02/01 Martin Wilke born in Ludwigsfelde, Brandenburg, Germany, 1980 02/01 Christian Brueffer born in Gronau, Nordrhein-Westfalen, Germany, 1982 02/01 Steven Kreuzer born in Oceanside, New York, 1982 02/01 Juli Mallett born in Washington, Pennsylvania, United States, 1985 02/02 Michael W Lucas born in Detroit, Michigan, United States, 1967 02/02 Diomidis D. Spinellis born in Athens, Greece, 1967 02/02 Yoichi Nakayama born in Tsu, Mie, Japan, 1976 02/05 Frank Laszlo born in Howell, Michigan, United States, 1983 02/10 David Greenman born in Portland, Oregon, United States, 1968 02/10 Paul Richards born in Ammanford, Carmarthenshire, United Kingdom, 1968 02/10 Simon Barner born in Rosenheim, Bayern, Germany, 1980 02/13 Jesper Skriver born in Aarhus, Denmark, 1975 02/13 Andrey Slusar born in Odessa, USSR, 1979 02/13 David W. Chapman Jr. born in Bethel, Connecticut, United States, 1981 02/14 Erwin Lansing born in 's-Hertogenbosch, the Netherlands, 1975 02/14 Manolis Kiagias born in Chania, Greece, 1970 02/14 Martin Blapp born in Olten, Switzerland, 1976 02/19 Murray Stokely born in Jacksonville, Florida, United States, 1979 02/20 Anders Nordby born in Oslo, Norway, 1976 02/21 Alexey Zelkin born in Simferopol, Ukraine, 1978 02/22 Brooks Davis born in Longview, Washington, United States, 1976 02/22 Jake Burkholder born in Maynooth, Ontario, Canada, 1979 02/23 Peter Wemm born in Perth, Western Australia, Australia, 1971 02/23 Mathieu Arnold born in Champigny sur Marne, Val de Marne, France, 1978 02/24 Johan Karlsson born in Mariannelund, Sweden, 1974 02/24 Colin Percival born in Burnaby, Canada, 1981 02/26 Pietro Cerutti born in Faido, Switzerland, 1984 02/28 Daichi GOTO born in Shimizu Suntou, Shizuoka, Japan, 1980 03/01 Hye-Shik Chang born in Daejeon, Republic of Korea, 1980 03/02 Cy Schubert born in Edmonton, Alberta, Canada, 1956 03/03 Sergey Matveychuk born in Moscow, Russian Federation, 1973 03/03 Doug White born in Eugene, Oregon, United States, 1977 03/03 Gordon Tetlow born in Reno, Nevada, United States, 1978 03/04 Oleksandr Tymoshenko born in Chernihiv, Ukraine, 1980 +03/05 Baptiste Daroussin born in Beauvais, France, 1980 03/05 Philip Paeps born in Leuven, Belgium, 1983 03/05 Ulf Lilleengen born in Hamar, Norway, 1985 03/06 Christopher Piazza born in Kamloops, British Columbia, Canada, 1981 03/07 Michael P. Pritchard born in Los Angeles, California, United States, 1964 03/07 Giorgos Keramidas born in Athens, Greece, 1976 03/10 Andreas Klemm born in Duesseldorf, Nordrhein-Westfalen, Germany, 1963 03/11 Soeren Straarup born in Andst, Denmark, 1978 03/12 Greg Lewis born in Adelaide, South Australia, Australia, 1969 03/13 Alexander Leidinger born in Neunkirchen, Saarland, Germany, 1976 03/13 Will Andrews born in Pontiac, Michigan, United States, 1982 +03/14 Bernhard Froehlich born in Graz, Styria, Austria, 1985 03/15 Paolo Pisati born in Lodi, Italy, 1977 03/15 Brian Fundakowski Feldman born in Alexandria, Virginia, United States, 1983 03/17 Michael Smith born in Bankstown, New South Wales, Australia, 1971 03/17 Alexander Motin born in Simferopol, Ukraine, 1979 03/18 Koop Mast born in Dokkum, the Netherlands, 1981 03/19 Mikhail Teterin born in Kyiv, Ukraine, 1972 03/20 MANTANI Nobutaka born in Hiroshima, Japan, 1978 03/20 Cameron Grant died in Hemel Hempstead, United Kingdom, 2005 03/20 Henrik Brix Andersen born in Aarhus, Denmark, 1978 +03/20 Joseph S. Atkinson born in Batesville, Arkansas, United States, 1977 03/22 Brad Davis born in Farmington, New Mexico, United States, 1983 03/23 Daniel C. Sobral born in Brasilia, Distrito Federal, Brazil, 1971 03/23 Benno Rice born in Adelaide, South Australia, Australia, 1977 03/24 Marcel Moolenaar born in Hilversum, the Netherlands, 1968 03/24 Emanuel Haupt born in Zurich, Switzerland, 1979 03/25 Andrew R. Reiter born in Springfield, Massachusetts, United States, 1980 03/27 Josef El-Rayes born in Linz, Austria, 1982 03/28 Sean C. Farley born in Indianapolis, Indiana, United States, 1970 03/29 Thierry Thomas born in Luxeuil les Bains, France, 1961 04/01 Matthew Jacob born in San Francisco, California, United States, 1958 04/01 Bill Fenner born in Bellefonte, Pennsylvania, United States, 1971 04/01 Peter Edwards born in Dublin, Ireland, 1973 04/03 Hellmuth Michaelis born in Kiel, Schleswig-Holstein, Germany, 1958 04/03 Tong Liu born in Beijing, People's Republic of China, 1981 04/03 Gabor Pali born in Kunhegyes, Hungary, 1982 04/05 Stacey Son born in Burley, Idaho, United States. 1967 04/07 Edward Tomasz Napierala born in Wolsztyn, Poland, 1981 04/08 Jordan K. Hubbard born in Honolulu, Hawaii, United States, 1963 04/09 Ceri Davies born in Haverfordwest, Pembrokeshire, United Kingdom, 1976 04/11 Bruce A. Mah born in Fresno, California, United States, 1969 04/12 Patrick Gardella born in Columbus, Ohio, United States, 1967 04/12 Ed Schouten born in Oss, the Netherlands, 1986 04/13 Oliver Braun born in Nuremberg, Bavaria, Germany, 1972 04/14 Crist J. Clark born in Milwaukee, Wisconsin, United States, 1970 04/15 David Malone born in Dublin, Ireland, 1973 04/17 Dryice Liu born in Jinan, Shandong, China, 1975 04/22 Joerg Wunsch born in Dresden, Sachsen, Germany, 1962 04/22 Jun Kuriyama born in Matsue, Shimane, Japan, 1973 04/26 Rene Ladan born in Geldrop, the Netherlands, 1980 04/29 Adam Weinberger born in Berkeley, California, United States, 1980 04/29 Eric Anholt born in Portland, Oregon, United States, 1983 05/01 Randall Stewart born in Spokane, Washington, United States, 1959 05/02 Wojciech A. Koszek born in Czestochowa, Poland, 1987 05/03 Brian Dean born in Elkins, West Virginia, United States, 1966 05/03 Robert Nicholas Maxwell Watson born in Harrow, Middlesex, United Kingdom, 1977 05/04 Denis Peplin born in Nizhniy Novgorod, Russian Federation, 1977 05/08 Kirill Ponomarew born in Volgograd, Russian Federation, 1977 05/08 Sean Kelly born in Walnut Creek, California, United States, 1982 05/09 Daniel Eischen born in Syracuse, New York, United States, 1963 05/09 Aaron Dalton born in Boise, Idaho, United States, 1973 05/10 Markus Brueffer born in Gronau, Nordrhein-Westfalen, Germany, 1977 05/11 Jesus Rodriguez born in Barcelona, Spain, 1972 05/11 Roman Kurakin born in Moscow, USSR, 1979 05/13 Pete Fritchman born in Lansdale, Pennsylvania, United States, 1983 +05/14 Bruce Cran born in Cambridge, United Kingdom, 1981 05/14 Tatsumi Hosokawa born in Tokyo, Japan, 1968 05/14 Shigeyuku Fukushima born in Osaka, Japan, 1974 05/16 Johann Kois born in Wolfsberg, Austria, 1975 05/16 Marcus Alves Grando born in Florianopolis, Santa Catarina, Brazil, 1979 05/17 Thomas Abthorpe born in Port Arthur, Ontario, Canada, 1968 05/19 Philippe Charnier born in Fontainebleau, France, 1966 05/19 Ian Dowse born in Dublin, Ireland, 1975 05/21 Kris Kennaway born in Winnipeg, Manitoba, Canada, 1978 05/22 Clive Tong-I Lin born in Changhua, Taiwan, Republic of China, 1978 05/22 Michael Bushkov born in Rostov-on-Don, Russia, 1985 05/22 Rui Paulo , born in Evora, Portugal, 1986 05/23 Munechika Sumikawa born in Osaka, Osaka, Japan, 1972 05/24 Duncan McLennan Barclay born in London, Middlesex, United Kingdom, 1970 05/24 Oliver Lehmann born in Karlsburg, Germany, 1981 05/25 Roman Divacky born in Brno, Czech Republic, 1983 05/25 Tom Rhodes born in Ellwood City, Pennsylvania, United States, 1981 05/26 Jim Pirzyk born in Chicago, Illinois, United States, 1968 05/27 Ollivier Robert born in Paris, France, 1967 05/29 Wilko Bulte born in Arnhem, the Netherlands, 1965 05/29 Seigo Tanimura born in Kitakyushu, Fukuoka, Japan, 1976 05/31 Ville Skytta born in Helsinki, Finland, 1974 06/02 Jean-Marc Zucconi born in Pontarlier, France, 1954 06/02 Alexander Botero-Lowry born in Austin, TX, USA, 1986 06/03 CHOI Junho born in Seoul, Korea, 1974 06/03 Wesley Shields born in Binghamton, NY, USA, 1981 06/04 Julian Elischer born in Perth, Australia, 1959 06/04 Jason Evans born in Greeley, Colorado, United States, 1973 06/04 Justin Gibbs born in San Pedro, California, United States, 1973 06/04 Thomas Moestl born in Braunschweig, Niedersachsen, Germany, 1980 06/06 Sergei Kolobov born in Karpinsk, Russian Federation, 1972 06/06 Alan Eldridge died in Denver, Colorado, 2003 06/07 Benjamin Close born in Adelaide, Australia, 1978 06/07 Jimmy Olgeni born in Milano, Italy, 1976 06/17 Tilman Linneweh born in Weinheim, Baden-Wuertemberg, Germany, 1978 06/18 Li-Wen Hsu born in Taipei, Taiwan, Republic of China, 1984 06/18 Roman Bogorodskiy born in Saratov, Russian Federation, 1986 06/19 Charlie Root born in Portland, Oregon, United States, 1993 06/21 Ganbold Tsagaankhuu born in Ulaanbaatar, Mongolia, 1971 06/21 Niels Heinen born in Markelo, the Netherlands, 1978 06/24 Chris Faulhaber born in Springfield, Illinois, United States, 1971 06/26 Brian Somers born in Dundrum, Dublin, Ireland, 1967 06/28 Mark Santcroos born in Rotterdam, the Netherlands, 1979 06/28 Xin Li born in Beijing, People's Republic of China, 1982 06/29 Wilfredo Sanchez Vega born in Majaguez, Puerto Rico, United States, 1972 06/29 Daniel Harris born in Lubbock, Texas, United States, 1985 06/29 Andrew Pantyukhin born in Moscow, Russian Federation, 1985 06/30 Guido van Rooij born in Best, Noord-Brabant, the Netherlands, 1965 07/01 Matthew Dillon born in San Francisco, California, United States, 1966 07/02 Mark Christopher Ovens born in Preston, Lancashire, United Kingdom, 1958 07/02 Vasil Venelinov Dimov born in Shumen, Bulgaria, 1982 07/04 Motoyuki Konno born in Musashino, Tokyo, Japan, 1969 07/04 Florent Thoumie born in Montmorency, Val d'Oise, France, 1982 07/07 Andrew Thompson born in Lower Hutt, Wellington, New Zealand, 1979 07/07 Maxime Henrion born in Metz, France, 1981 07/07 George Reid born in Frimley, Hampshire, United Kingdom, 1983 07/10 Jung-uk Kim born in Seoul, Korea, 1971 07/10 Justin Seger born in Harvard, Massachusetts, United States, 1981 07/10 David Schultz born in Oakland, California, United States, 1982 07/11 Jesus R. Camou born in Hermosillo, Sonora, Mexico, 1983 07/15 Gary Jennejohn born in Rochester, New York, United States, 1950 07/16 Suleiman Souhlal born in Roma, Italy, 1983 07/17 Michael Chin-Yuan Wu born in Taipei, Taiwan, Republic of China, 1980 07/19 Masafumi NAKANE born in Okazaki, Aichi, Japan, 1972 07/19 Simon L. Nielsen born in Copenhagen, Denmark, 1980 07/19 Gleb Smirnoff born in Kharkov, USSR, 1981 +07/20 Andrey V. Elsukov born in Kotelnich, Russian Federation, 1981 07/22 James Housley born in Chicago, Illinois, United States, 1965 07/22 Jens Schweikhardt born in Waiblingen, Baden-Wuerttemberg, Germany, 1967 07/22 Lukas Ertl born in Weissenbach/Enns, Steiermark, Austria, 1976 07/23 Sergey A. Osokin born in Krasnogorsky, Stepnogorsk, Akmolinskaya region, Kazakhstan, 1972 07/24 Alexander Nedotsukov born in Ulyanovsk, Russian Federation, 1974 07/24 Alberto Villa born in Vercelli, Italy, 1987 07/27 Andriy Gapon born in Kyrykivka, Sumy region, Ukraine, 1976 07/28 Jim Mock born in Bethlehem, Pennsylvania, United States, 1974 07/28 Tom Hukins born in Manchester, United Kingdom, 1976 07/29 Dirk Meyer born in Kassel, Hessen, Germany, 1965 07/29 Felippe M. Motta born in Maceio, Alagoas, Brazil, 1988 08/02 Gabor Kovesdan born in Budapest, Hungary, 1987 08/03 Peter Holm born in Copenhagen, Denmark, 1955 08/05 Alfred Perlstein born in Brooklyn, New York, United States, 1978 08/06 Anton Berezin born in Dnepropetrovsk, Ukraine, 1970 08/06 John-Mark Gurney born in Detroit, Michigan, United States, 1978 08/07 Jonathan Mini born in San Mateo, California, United States, 1979 08/10 Peter Pentchev born in Sofia, Bulgaria, 1977 08/12 Joe Marcus Clarke born in Lakeland, Florida, United States, 1976 08/12 Max Brazhnikov born in Leningradskaya, Russia, 1979 08/14 Stefan Esser born in Cologne, Nordrhein-Westfalen, Germany, 1961 08/17 Olivier Houchard born in Nancy, France, 1980 08/19 Pav Lucistnik born in Kutna Hora, Czech Republic, 1980 08/19 Chin-San Huang born in Yi-Lan, Taiwan, Republic of China, 1979 08/20 Michael Heffner born in Cleona, Pennsylvania, United States, 1981 08/24 Mark Linimon born in Houston, Texas, United States, 1955 08/25 Jean Milanez Melo born in Divinopolis, Minas Gerais, Brazil, 1982 08/25 Beech Rintoul born in Oakland, California, United States, 1952 08/26 Dima Ruban born in Nalchik, USSR, 1970 08/26 Marc Fonvieille born in Avignon, France, 1972 08/26 Herve Quiroz born in Aix-en-Provence, France, 1977 08/27 Andrey Chernov born in Moscow, USSR, 1966 08/27 Tony Finch born in London, United Kingdom, 1974 08/27 Michael Johnson born in Morganton, North Carolina, United States, 1980 08/28 Norikatsu Shigemura born in Fujisawa, Kanagawa, Japan, 1974 08/29 Thomas Gellekum born in Moenchengladbach, Nordrhein-Westfalen, Germany, 1967 08/29 Max Laier born in Karlsruhe, Germany, 1981 09/01 Pyun YongHyeon born in Kimcheon, Korea, 1968 09/03 Max Khon born in Novosibirsk, USSR, 1976 09/03 Cheng-Lung Sung born in Taipei, Taiwan, Republic of China, 1977 09/05 Mark Robert Vaughan Murray born in Harare, Mashonaland, Zimbabwe, 1961 09/05 Adrian Harold Chadd born in Perth, Western Australia, Australia, 1979 09/07 Tim Bishop born in Cornwall, United Kingdom, 1978 09/08 Boris Samorodov born in Krasnodar, Russian Federation, 1963 09/09 Yoshio Mita born in Hiroshima, Japan, 1972 09/10 Wesley R. Peters born in Hartford, Alabama, United States, 1961 09/12 Weongyo Jeong born in Haman, Korea, 1980 09/12 William C. Fumerola II born in Detroit, Michigan, United States, 1981 09/12 Benedict Christopher Reuschling born in Darmstadt, Germany, 1981 09/15 Dima Panov born in Khabarovsk, Russian Federation, 1978 09/17 Maxim Bolotin born in Rostov-on-Don, Russian Federation, 1976 +09/18 Matthew Fleming born in Cleveland, Ohio, United States, 1975 09/20 Kevin Lo born in Taipei, Taiwan, Republic of China, 1972 09/27 Neil Blakey-Milner born in Port Elizabeth, South Africa, 1978 09/27 Renato Botelho born in Araras, Sao Paulo, Brazil, 1979 09/28 Greg Lehey born in Melbourne, Victoria, Australia, 1948 09/28 Alex Dupre born in Milano, Italy, 1980 09/29 Matthew Hunt born in Johnstown, Pennsylvania, United States, 1976 09/30 Hiten M. Pandya born in Dar-es-Salaam, Tanzania, East Africa, 1986 10/02 Beat Gaetzi born in Zurich, Switzerland, 1980 10/05 Hiroki Sato born in Yamagata, Japan, 1977 10/05 Chris Costello born in Houston, Texas, United States, 1985 10/09 Stefan Walter born in Werne, Nordrhein-Westfalen, 1978 10/12 Pawel Jakub Dawidek born in Radzyn Podlaski, Poland, 1980 10/15 Maxim Konovalov born in Khabarovsk, USSR, 1973 10/16 Remko Lodder born in Rotterdam, the Netherlands, 1983 10/17 Maho NAKATA born in Osaka, Japan, 1974 10/18 Sheldon Hearn born in Cape Town, Western Cape, South Africa, 1974 10/19 Nicholas Souchu born in Suresnes, Hauts-de-Seine, France, 1972 10/19 Nick Barkas born in Longview, Washington, United States, 1981 10/20 Joel Dahl born in Lidkoping, Sweden, 1983 10/20 Dmitry Marakasov born in Moscow, Russian Federation, 1984 10/21 Dan Moschuk born in Halifax, Nova Scotia, Canada, 1980 10/21 Ben Smithurst born in Sheffield, South Yorkshire, United Kingdom, 1981 10/22 Jean-Sebastien Pedron born in Redon, Ille-et-Vilaine, France, 1980 10/23 Mario Sergio Fujikawa Ferreira born in Brasilia, Distrito Federal, Brazil, 1976 10/25 Eric Melville born in Los Gatos, California, United States, 1980 10/26 Philip M. Gollucci born in Silver Spring, Maryland, United States, 1979 10/27 Takanori Watanabe born in Numazu, Shizuoka, Japan, 1972 11/05 M. Warner Losh born in Kansas City, Kansas, United States, 1966 11/09 Coleman Kane born in Cincinnati, OH, United States, 1980 11/09 Antoine Brodin born in Bagnolet, France, 1981 11/10 Gregory Neil Shapiro born in Providence, Rhode Island, United States, 1970 11/13 John Baldwin born in Stuart, Virginia, United States, 1977 11/15 Lars Engels born in Hilden, Nordrhein-Westfalen, Germany, 1980 +11/15 Tijl Coosemans born in Duffel, Belgium, 1983 11/16 Jose Maria Alcaide Salinas born in Madrid, Spain, 1962 11/17 Ralf S. Engelschall born in Dachau, Bavaria, Germany, 1972 11/18 Thomas Quinot born in Paris, France, 1977 11/19 Konstantin Belousov born in Kiev, USSR, 1972 11/20 Dmitry Morozovsky born in Moscow, USSR, 1968 11/20 Gavin Atkinson born in Middlesbrough, United Kingdom, 1979 11/23 Josef Lawrence Karthauser born in Pembury, Kent, United Kingdom, 1972 11/24 Andrey Zakhvatov born in Chelyabinsk, Russian Federation, 1974 11/24 Daniel Gerzo born in Bratislava, Slovakia, 1986 11/28 Nik Clayton born in Peterborough, United Kingdom, 1973 11/28 Stanislav Sedov born in Chelyabinsk, USSR, 1985 12/01 Hajimu Umemoto born in Nara, Japan, 1961 12/01 Alexey Dokuchaev born in Magadan, USSR, 1980 12/02 Ermal LuГi born in Tirane, Albania, 1980 12/03 Diane Bruce born in Ottawa, Ontario, Canada, 1952 12/05 Ivan Voras born in Slavonski Brod, Croatia, 1981 12/06 Stefan Farfeleder born in Wien, Austria, 1980 12/15 James FitzGibbon born in Amersham, Buckinghamshire, United Kingdom, 1974 12/15 Timur I. Bakeyev born in Kazan, Republic of Tatarstan, USSR, 1974 12/18 Chris Timmons born in Ellensburg, Washington, United States, 1964 12/18 Dag-Erling Smorgrav born in Brussels, Belgium, 1977 12/18 Semen Ustimenko born in Novosibirsk, Russian Federation, 1979 12/21 Rong-En Fan born in Taipei, Taiwan, Republic of China, 1982 12/22 Maxim Sobolev born in Dnepropetrovsk, Ukraine, 1976 12/23 Sean Chittenden born in Seattle, Washington, United States, 1979 12/23 Alejandro Pulver born in Buenos Aires, Argentina, 1989 12/28 Soren Schmidt born in Maribo, Denmark, 1960 12/28 Ade Lovett born in London, England, 1969 12/28 Marius Strobl born in Cham, Bavaria, Germany, 1978 12/31 Edwin Groothuis born in Geldrop, the Netherlands, 1970 #endif /* !_calendar_freebsd_ */ Index: stable/8/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common =================================================================== --- stable/8/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common (revision 211722) +++ stable/8/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common (revision 211723) @@ -1,90 +1,105 @@ /* * Российские праздники * * $FreeBSD$ */ #ifndef _ru_RU_KOI8_R_common_ #define _ru_RU_KOI8_R_common_ LANG=ru_RU.KOI8-R 12 янв День работника прокуратуры 13 янв День российской печати 14 янв Старый Новый год 21 янв День инженерных войск 25 янв Татьянин день. Студенческий праздник 8 фев День российской науки 10 фев День дипломатического работника 1 мар Всемирный день гражданской обороны 03/SunSecond День работников геодезии и картографии +11 мар День работника органов наркоконтроля 18 мар День налоговой полиции 03/SunThird День работников торговли, бытового обслуживания населения и жилищно-коммунального хозяйства 27 мар Международный день театра 27 мар День внутренних войск 1 апр День смеха 2 апр День единения народов 04/SunFirst День геолога 12 апр День космонавтики 04/SunSecond День войск противовоздушной обороны 26 апр День памяти погибших в радиационных авариях и катастрофах 30 апр День пожарной охраны 7 май День радио 17 май Международный день телекоммуникаций 18 май Международный день музеев 24 май День славянской письменности и культуры +26 май День российского предпринимательства 27 май Общероссийский день библиотек 28 май День пограничника +30 май День пожарной охраны +31 май День Российской Адвокатуры 05/SunLast День химика 1 июн День защиты детей + 5 июн День эколога 6 июн Пушкинский день 8 июн День социального работника 06/SunSecond День работников легкой промышленности 06/SunThird День медицинского работника 22 июн День памяти и скорби (Начало Великой Отечественной Войны, 1941 год) 27 июн День молодежи +29 июн День партизан и подпольщиков 06/SatLast День изобретателя и рационализатора 07/SunFirst День работников морского и речного флота 07/SunSecond День рыбака 07/SunSecond День российской почты 07/SunThird День металлурга 07/SunLast День Военно-Морского Флота +28 июл День крещения Руси 6 авг День железнодорожных войск 08/SunFirst День железнодорожника 12 авг День военно-воздушных сил 08/SunSecond День строителя 08/SunThird День Воздушного Флота 22 авг День государственного флага 27 авг День кино 08/SunLast День шахтера 1 сен День знаний 2 сен День российской гвардии + 3 сен День солидарности в борьбе с терроризмом + 4 сен День специалиста по ядерному обеспечению 09/SunFirst День работников нефтяной и газовой промышленности 09/SunSecond День танкиста 09/SunThird День работников леса +28 сен День работника атомной промышленности 09/SunLast День машиностроителя 1 окт День пожилых людей - 4 окт День военно-космических сил + 1 окт День сухопутных войск + 4 окт День космических войск 5 окт День учителя 14 окт Международный день стандартизации 10/SunSecond День работников сельского хозяйства и перерабатывающей промышленности 10/SunThird День работников дорожного хозяйства 24 окт Международный день ООН 25 окт День таможенника 30 окт День памяти жертв политических репрессий 10/SunLast День работников автомобильного транспорта + 7 ноя День октябрьской революции 1917 года 9 ноя Всемирный день качества 10 ноя День милиции 16 ноя День морской пехоты 17 ноя Международный день студентов -11/SunThird День ракетных войск и артиллерии +19 ноя День ракетных войск и артиллерии 21 ноя День работников налоговых органов 26 ноя Всемирный день информации 11/SunLast День матери 1 дек Всемирный день борьбы со СПИДом + 3 дек День юриста + 9 дек День Героев Отечества +12 дек День Конституции 17 дек День ракетных войск стратегического назначения 20 дек День работника органов безопасности 22 дек День энергетика 27 дек День спасателя #endif /* !_ru_RU_KOI8_R_common_ */ Property changes on: stable/8/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common ___________________________________________________________________ Added: fbsd:notbinary ## -0,0 +1 ## +yes \ No newline at end of property Index: stable/8/usr.bin/calendar/day.c =================================================================== --- stable/8/usr.bin/calendar/day.c (revision 211722) +++ stable/8/usr.bin/calendar/day.c (revision 211723) @@ -1,486 +1,117 @@ -/* +/*- * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * 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. */ #include __FBSDID("$FreeBSD$"); -#include -#include -#include #include #include #include #include #include #include -#include "pathnames.h" #include "calendar.h" -struct tm *tp; -static const struct tm tm0; -int *cumdays, yrdays; -char dayname[10]; +time_t time1, time2; +const struct tm tm0; +char dayname[100]; +int year1, year2; -/* 1-based month, 0-based days, cumulative */ -int daytab[][14] = { - {0, -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364}, - {0, -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, -}; - -static char const *days[] = { - "sun", "mon", "tue", "wed", "thu", "fri", "sat", NULL, -}; - -static const char *months[] = { - "jan", "feb", "mar", "apr", "may", "jun", - "jul", "aug", "sep", "oct", "nov", "dec", NULL, -}; - -static struct fixs fndays[8]; /* full national days names */ -static struct fixs ndays[8]; /* short national days names */ - -static struct fixs fnmonths[13]; /* full national months names */ -static struct fixs nmonths[13]; /* short national month names */ - - void -setnnames(void) +settimes(time_t now, int before, int after, int friday, struct tm *tp1, struct tm *tp2) { - char buf[80]; - int i, l; - struct tm tm; + char *oldl, *lbufp; + struct tm tp; - for (i = 0; i < 7; i++) { - tm.tm_wday = i; - strftime(buf, sizeof(buf), "%a", &tm); - for (l = strlen(buf); - l > 0 && isspace((unsigned char)buf[l - 1]); - l--) - ; - buf[l] = '\0'; - if (ndays[i].name != NULL) - free(ndays[i].name); - if ((ndays[i].name = strdup(buf)) == NULL) - errx(1, "cannot allocate memory"); - ndays[i].len = strlen(buf); + localtime_r(&now, &tp); - strftime(buf, sizeof(buf), "%A", &tm); - for (l = strlen(buf); - l > 0 && isspace((unsigned char)buf[l - 1]); - l--) - ; - buf[l] = '\0'; - if (fndays[i].name != NULL) - free(fndays[i].name); - if ((fndays[i].name = strdup(buf)) == NULL) - errx(1, "cannot allocate memory"); - fndays[i].len = strlen(buf); - } + /* Friday displays Monday's events */ + if (after == 0 && before == 0 && friday != -1) + after = tp.tm_wday == friday ? 3 : 1; - for (i = 0; i < 12; i++) { - tm.tm_mon = i; - strftime(buf, sizeof(buf), "%b", &tm); - for (l = strlen(buf); - l > 0 && isspace((unsigned char)buf[l - 1]); - l--) - ; - buf[l] = '\0'; - if (nmonths[i].name != NULL) - free(nmonths[i].name); - if ((nmonths[i].name = strdup(buf)) == NULL) - errx(1, "cannot allocate memory"); - nmonths[i].len = strlen(buf); + time1 = now - SECSPERDAY * before; + localtime_r(&time1, tp1); + year1 = 1900 + tp1->tm_year; + time2 = now + SECSPERDAY * after; + localtime_r(&time2, tp2); + year2 = 1900 + tp2->tm_year; - strftime(buf, sizeof(buf), "%B", &tm); - for (l = strlen(buf); - l > 0 && isspace((unsigned char)buf[l - 1]); - l--) - ; - buf[l] = '\0'; - if (fnmonths[i].name != NULL) - free(fnmonths[i].name); - if ((fnmonths[i].name = strdup(buf)) == NULL) - errx(1, "cannot allocate memory"); - fnmonths[i].len = strlen(buf); - } -} + strftime(dayname, sizeof(dayname) - 1, "%A, %d %B %Y", tp1); -void -settime(time_t now) -{ - char *oldl, *lbufp; - - tp = localtime(&now); - if (isleap(tp->tm_year + 1900)) { - yrdays = 366; - cumdays = daytab[1]; - } else { - yrdays = 365; - cumdays = daytab[0]; - } - /* Friday displays Monday's events */ - if (f_dayAfter == 0 && f_dayBefore == 0 && Friday != -1) - f_dayAfter = tp->tm_wday == Friday ? 3 : 1; - header[5].iov_base = dayname; - oldl = NULL; lbufp = setlocale(LC_TIME, NULL); if (lbufp != NULL && (oldl = strdup(lbufp)) == NULL) errx(1, "cannot allocate memory"); (void)setlocale(LC_TIME, "C"); - header[5].iov_len = strftime(dayname, sizeof(dayname), "%A", tp); (void)setlocale(LC_TIME, (oldl != NULL ? oldl : "")); if (oldl != NULL) free(oldl); setnnames(); } /* convert Day[/Month][/Year] into unix time (since 1970) * Day: two digits, Month: two digits, Year: digits */ time_t Mktime(char *dp) { time_t t; int d, m, y; - struct tm tm; + struct tm tm, tp; (void)time(&t); - tp = localtime(&t); + localtime_r(&t, &tp); tm = tm0; - tm.tm_mday = tp->tm_mday; - tm.tm_mon = tp->tm_mon; - tm.tm_year = tp->tm_year; + tm.tm_mday = tp.tm_mday; + tm.tm_mon = tp.tm_mon; + tm.tm_year = tp.tm_year; switch (sscanf(dp, "%d.%d.%d", &d, &m, &y)) { case 3: if (y > 1900) y -= 1900; tm.tm_year = y; /* FALLTHROUGH */ case 2: tm.tm_mon = m - 1; /* FALLTHROUGH */ case 1: tm.tm_mday = d; } #ifdef DEBUG fprintf(stderr, "Mktime: %d %d %s\n", (int)mktime(&tm), (int)t, asctime(&tm)); #endif return (mktime(&tm)); -} - -/* - * Possible date formats include any combination of: - * 3-charmonth (January, Jan, Jan) - * 3-charweekday (Friday, Monday, mon.) - * numeric month or day (1, 2, 04) - * - * Any character may separate them, or they may not be separated. Any line, - * following a line that is matched, that starts with "whitespace", is shown - * along with the matched line. - */ -int -isnow(char *endp, int *monthp, int *dayp, int *varp) -{ - int day, flags, month = 0, v1, v2; - - /* - * CONVENTION - * - * Month: 1-12 - * Monthname: Jan .. Dec - * Day: 1-31 - * Weekday: Mon-Sun - * - */ - - flags = 0; - - /* read first field */ - /* didn't recognize anything, skip it */ - if (!(v1 = getfield(endp, &endp, &flags))) - return (0); - - /* Easter or Easter depending days */ - if (flags & F_EASTER) - day = v1 - 1; /* days since January 1 [0-365] */ - - /* - * 1. {Weekday,Day} XYZ ... - * - * where Day is > 12 - */ - else if (flags & F_ISDAY || v1 > 12) { - - /* found a day; day: 1-31 or weekday: 1-7 */ - day = v1; - - /* {Day,Weekday} {Month,Monthname} ... */ - /* if no recognizable month, assume just a day alone - * in other words, find month or use current month */ - if (!(month = getfield(endp, &endp, &flags))) - month = tp->tm_mon + 1; - } - - /* 2. {Monthname} XYZ ... */ - else if (flags & F_ISMONTH) { - month = v1; - - /* Monthname {day,weekday} */ - /* if no recognizable day, assume the first day in month */ - if (!(day = getfield(endp, &endp, &flags))) - day = 1; - } - - /* Hm ... */ - else { - v2 = getfield(endp, &endp, &flags); - - /* - * {Day} {Monthname} ... - * where Day <= 12 - */ - if (flags & F_ISMONTH) { - day = v1; - month = v2; - *varp = 0; - } - - /* {Month} {Weekday,Day} ... */ - else { - /* F_ISDAY set, v2 > 12, or no way to tell */ - month = v1; - /* if no recognizable day, assume the first */ - day = v2 ? v2 : 1; - *varp = 0; - } - } - - /* convert Weekday into *next* Day, - * e.g.: 'Sunday' -> 22 - * 'SundayLast' -> ?? - */ - if (flags & F_ISDAY) { -#ifdef DEBUG - fprintf(stderr, "\nday: %d %s month %d\n", day, endp, month); -#endif - - *varp = 1; - /* variable weekday, SundayLast, MondayFirst ... */ - if (day < 0 || day >= 10) { - - /* negative offset; last, -4 .. -1 */ - if (day < 0) { - v1 = day / 10 - 1; /* offset -4 ... -1 */ - day = 10 + (day % 10); /* day 1 ... 7 */ - - /* day, eg '22nd' */ - v2 = tp->tm_mday + - (((day - 1) - tp->tm_wday + 7) % 7); - - /* (month length - day) / 7 + 1 */ - if (cumdays[month + 1] - cumdays[month] >= v2 - && ((int)((cumdays[month + 1] - - cumdays[month] - v2) / 7) + 1) == -v1) - day = v2; /* bingo ! */ - - /* set to yesterday */ - else { - day = tp->tm_mday - 1; - if (day == 0) - return (0); - } - } - - /* first, second ... +1 ... +5 */ - else { - /* offset: +1 (first Sunday) ... */ - v1 = day / 10; - day = day % 10; - - /* day, eg '22th' */ - v2 = tp->tm_mday + - (((day - 1) - tp->tm_wday + 7) % 7); - - /* Hurrah! matched */ - if (((v2 - 1 + 7) / 7) == v1 ) - day = v2; - - else { - /* set to yesterday */ - day = tp->tm_mday - 1; - if (day == 0) - return (0); - } - } - } else { - /* wired */ - day = tp->tm_mday + (((day - 1) - tp->tm_wday + 7) % 7); - *varp = 1; - } - } - - if (!(flags & F_EASTER)) { - if (day + cumdays[month] > cumdays[month + 1]) { - /* off end of month, adjust */ - day -= (cumdays[month + 1] - cumdays[month]); - /* next year */ - if (++month > 12) - month = 1; - } - *monthp = month; - *dayp = day; - day = cumdays[month] + day; - } else { - for (v1 = 0; day > cumdays[v1]; v1++) - ; - *monthp = v1 - 1; - *dayp = day - cumdays[v1 - 1]; - *varp = 1; - } - -#ifdef DEBUG - fprintf(stderr, "day2: day %d(%d-%d) yday %d\n", - *dayp, day, cumdays[month], tp->tm_yday); -#endif - - /* When days before or days after is specified */ - /* no year rollover */ - if (day >= tp->tm_yday - f_dayBefore && - day <= tp->tm_yday + f_dayAfter) - return (1); - - /* next year */ - if (tp->tm_yday + f_dayAfter >= yrdays) { - int end = tp->tm_yday + f_dayAfter - yrdays; - if (day <= end) - return (1); - } - - /* previous year */ - if (tp->tm_yday - f_dayBefore < 0) { - int before = yrdays + (tp->tm_yday - f_dayBefore); - if (day >= before) - return (1); - } - - return (0); -} - - -int -getmonth(char *s) -{ - const char **p; - struct fixs *n; - - for (n = fnmonths; n->name; ++n) - if (!strncasecmp(s, n->name, n->len)) - return ((n - fnmonths) + 1); - for (n = nmonths; n->name; ++n) - if (!strncasecmp(s, n->name, n->len)) - return ((n - nmonths) + 1); - for (p = months; *p; ++p) - if (!strncasecmp(s, *p, 3)) - return ((p - months) + 1); - return (0); -} - - -int -getday(char *s) -{ - const char **p; - struct fixs *n; - - for (n = fndays; n->name; ++n) - if (!strncasecmp(s, n->name, n->len)) - return ((n - fndays) + 1); - for (n = ndays; n->name; ++n) - if (!strncasecmp(s, n->name, n->len)) - return ((n - ndays) + 1); - for (p = days; *p; ++p) - if (!strncasecmp(s, *p, 3)) - return ((p - days) + 1); - return (0); -} - -/* return offset for variable weekdays - * -1 -> last weekday in month - * +1 -> first weekday in month - * ... etc ... - */ -int -getdayvar(char *s) -{ - int offs; - - offs = strlen(s); - - /* Sun+1 or Wednesday-2 - * ^ ^ */ - - /* fprintf(stderr, "x: %s %s %d\n", s, s + offs - 2, offs); */ - switch (*(s + offs - 2)) { - case '-': - return (-(atoi(s + offs - 1))); - case '+': - return (atoi(s + offs - 1)); - } - - /* - * some aliases: last, first, second, third, fourth - */ - - /* last */ - if (offs > 4 && !strcasecmp(s + offs - 4, "last")) - return (-1); - else if (offs > 5 && !strcasecmp(s + offs - 5, "first")) - return (+1); - else if (offs > 6 && !strcasecmp(s + offs - 6, "second")) - return (+2); - else if (offs > 5 && !strcasecmp(s + offs - 5, "third")) - return (+3); - else if (offs > 6 && !strcasecmp(s + offs - 6, "fourth")) - return (+4); - - /* no offset detected */ - return (0); } Index: stable/8/usr.bin/calendar/io.c =================================================================== --- stable/8/usr.bin/calendar/io.c (revision 211722) +++ stable/8/usr.bin/calendar/io.c (revision 211723) @@ -1,517 +1,359 @@ -/* +/*- * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * 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. */ #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif #if 0 #ifndef lint static char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; #endif #endif #include __FBSDID("$FreeBSD$"); -#include #include #include -#include -#include #include #include #include #include #include #include #include #include #include #include #include #include "pathnames.h" #include "calendar.h" -/* - * 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 - */ -static struct event *event_add(struct event *, int, int, char *, int, char *); -static void event_continue(struct event *events, char *txt); -static void event_print_all(FILE *fp, struct event *events); -struct event { - int month; - int day; - int var; - char *date; - char *text; - struct event *next; -}; - const char *calendarFile = "calendar"; /* default calendar file */ const char *calendarHomes[] = {".calendar", _PATH_INCLUDE}; /* HOME */ const char *calendarNoMail = "nomail"; /* don't sent mail if this file exist */ char path[MAXPATHLEN]; -struct fixs neaster, npaskha; +struct fixs neaster, npaskha, ncny, nfullmoon, nnewmoon; +struct fixs nmarequinox, nsepequinox, njunsolstice, ndecsolstice; -struct iovec header[] = { - {"From: ", 6}, - {NULL, 0}, - {" (Reminder Service)\nTo: ", 24}, - {NULL, 0}, - {"\nSubject: ", 10}, - {NULL, 0}, - {"'s Calendar\nPrecedence: bulk\n\n", 30}, -}; - +#define REPLACE(string, slen, struct_) \ + if (strncasecmp(buf, (string), (slen)) == 0 && buf[(slen)]) { \ + if (struct_.name != NULL) \ + free(struct_.name); \ + if ((struct_.name = strdup(buf + (slen))) == NULL) \ + errx(1, "cannot allocate memory"); \ + struct_.len = strlen(buf + (slen)); \ + continue; \ + } void cal(void) { - int printing; - char *p; + char *pp, p; FILE *fp; int ch, l; - int month; - int day; - int var; + int count, i; + int month[MAXCOUNT]; + int day[MAXCOUNT]; + int year[MAXCOUNT]; + char **extradata; /* strings of 20 length */ + int flags; static int d_first = -1; char buf[2048 + 1]; - struct event *events = NULL; + struct event *events[MAXCOUNT]; + struct tm tm; + char dbuf[80]; - if ((fp = opencal()) == NULL) + extradata = (char **)calloc(MAXCOUNT, sizeof(char *)); + for (i = 0; i < MAXCOUNT; i++) { + extradata[i] = (char *)calloc(1, 20); + } + + /* Unused */ + tm.tm_sec = 0; + tm.tm_min = 0; + tm.tm_hour = 0; + tm.tm_wday = 0; + + count = 0; + if ((fp = opencal()) == NULL) { + free(extradata); return; - for (printing = 0; fgets(buf, sizeof(buf), stdin) != NULL;) { - if ((p = strchr(buf, '\n')) != NULL) - *p = '\0'; + } + while (fgets(buf, sizeof(buf), stdin) != NULL) { + if ((pp = strchr(buf, '\n')) != NULL) + *pp = '\0'; else + /* Flush this line */ while ((ch = getchar()) != '\n' && ch != EOF); for (l = strlen(buf); l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; if (buf[0] == '\0') continue; + + /* Parse special definitions: LANG, Easter, Paskha etc */ if (strncmp(buf, "LANG=", 5) == 0) { (void)setlocale(LC_ALL, buf + 5); d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); setnnames(); continue; } - if (strncasecmp(buf, "Easter=", 7) == 0 && buf[7]) { - if (neaster.name != NULL) - free(neaster.name); - if ((neaster.name = strdup(buf + 7)) == NULL) - errx(1, "cannot allocate memory"); - neaster.len = strlen(buf + 7); + REPLACE("Easter=", 7, neaster); + REPLACE("Paskha=", 7, npaskha); + REPLACE("ChineseNewYear=", 15, ncny); + REPLACE("NewMoon=", 8, nnewmoon); + REPLACE("FullMoon=", 9, nfullmoon); + REPLACE("MarEquinox=", 11, nmarequinox); + REPLACE("SepEquinox=", 11, nsepequinox); + REPLACE("JunSolstice=", 12, njunsolstice); + REPLACE("DecSolstice=", 12, ndecsolstice); + if (strncmp(buf, "SEQUENCE=", 9) == 0) { + setnsequences(buf + 9); continue; } - if (strncasecmp(buf, "Paskha=", 7) == 0 && buf[7]) { - if (npaskha.name != NULL) - free(npaskha.name); - if ((npaskha.name = strdup(buf + 7)) == NULL) - errx(1, "cannot allocate memory"); - npaskha.len = strlen(buf + 7); - continue; - } - if (buf[0] != '\t') { - printing = isnow(buf, &month, &day, &var) ? 1 : 0; - if ((p = strchr(buf, '\t')) == NULL) - continue; - if (p > buf && p[-1] == '*') - var = 1; - if (printing) { - struct tm tm; - char dbuf[80]; - if (d_first < 0) - d_first = - (*nl_langinfo(D_MD_ORDER) == 'd'); - tm.tm_sec = 0; /* unused */ - tm.tm_min = 0; /* unused */ - tm.tm_hour = 0; /* unused */ - tm.tm_wday = 0; /* unused */ - tm.tm_mon = month - 1; - tm.tm_mday = day; - tm.tm_year = tp->tm_year; /* unused */ - (void)strftime(dbuf, sizeof(dbuf), - d_first ? "%e %b" : "%b %e", &tm); - events = event_add(events, month, day, dbuf, - var, p); - } - } else { - if (printing) - event_continue(events, buf); - } - } - - event_print_all(fp, events); - closecal(fp); -} - -static struct event * -event_add(struct event *events, int month, int day, - char *date, int var, char *txt) -{ - struct event *e; - - /* - * Creating a new event: - * - Create a new event - * - Copy the machine readable day and month - * - Copy the human readable and language specific date - * - Copy the text of the event - */ - e = (struct event *)calloc(1, sizeof(struct event)); - if (e == NULL) - errx(1, "event_add: cannot allocate memory"); - e->month = month; - e->day = day; - e->var = var; - e->date = strdup(date); - if (e->date == NULL) - errx(1, "event_add: cannot allocate memory"); - e->text = strdup(txt); - if (e->text == NULL) - errx(1, "event_add: cannot allocate memory"); - e->next = events; - - return e; -} - -static void -event_continue(struct event *e, char *txt) -{ - char *text; - - /* - * Adding text to the event: - * - Save a copy of the old text (unknown length, so strdup()) - * - Allocate enough space for old text + \n + new text + 0 - * - Store the old text + \n + new text - * - Destroy the saved copy. - */ - text = strdup(e->text); - if (text == NULL) - errx(1, "event_continue: cannot allocate memory"); - - free(e->text); - e->text = (char *)malloc(strlen(text) + strlen(txt) + 3); - if (e->text == NULL) - errx(1, "event_continue: cannot allocate memory"); - strcpy(e->text, text); - strcat(e->text, "\n"); - strcat(e->text, txt); - free(text); - - return; -} - -static void -event_print_all(FILE *fp, struct event *events) -{ - struct event *e, *e_next; - int daycounter; - int day, month; - - /* - * Print all events: - * - We know the number of days to be counted (f_dayAfter + f_dayBefore) - * - We know the current day of the year ("now" - f_dayBefore + counter) - * - We know the number of days in the year (yrdays, set in settime()) - * - So we know the date on which the current daycounter is on the - * calendar in days and months. - * - Go through the list of events, and print all matching dates - */ - for (daycounter = 0; daycounter <= f_dayAfter + f_dayBefore; - daycounter++) { - day = tp->tm_yday - f_dayBefore + daycounter; - if (day < 0) - day += yrdays; - if (day >= yrdays) - day -= yrdays; - /* - * When we know the day of the year, we can determine the day - * of the month and the month. + * If the line starts with a tab, the data has to be + * added to the previous line */ - month = 1; - while (month <= 12) { - if (day <= cumdays[month]) - break; - month++; + if (buf[0] == '\t') { + for (i = 0; i < count; i++) + event_continue(events[i], buf); + continue; } - month--; - day -= cumdays[month]; -#ifdef DEBUG - fprintf(stderr, "event_print_allmonth: %d, day: %d\n", - month, day); -#endif + /* Get rid of leading spaces (non-standard) */ + while (isspace((unsigned char)buf[0])) + memcpy(buf, buf + 1, strlen(buf)); - /* - * Go through all events and print the text of the matching - * dates - */ - for (e = events; e != NULL; e = e_next) { - e_next = e->next; + /* No tab in the line, then not a valid line */ + if ((pp = strchr(buf, '\t')) == NULL) + continue; - if (month != e->month || day != e->day) - continue; + /* Trim spaces in front of the tab */ + while (isspace((unsigned char)pp[-1])) + pp--; - (void)fprintf(fp, "%s%c%s\n", e->date, - e->var ? '*' : ' ', e->text); + p = *pp; + *pp = '\0'; + if ((count = parsedaymonth(buf, year, month, day, &flags, + extradata)) == 0) + continue; + *pp = p; + if (count < 0) { + /* Show error status based on return value */ + fprintf(stderr, "Ignored: %s\n", buf); + if (count == -1) + continue; + count = -count + 1; } - } -} -int -getfield(char *p, char **endp, int *flags) -{ - int val, var; - char *start, savech; + /* Find the last tab */ + while (pp[1] == '\t') + pp++; - for (; !isdigit((unsigned char)*p) && !isalpha((unsigned char)*p) - && *p != '*'; ++p) - ; - if (*p == '*') { /* `*' is current month */ - *flags |= F_ISMONTH; - *endp = p + 1; - return (tp->tm_mon + 1); - } - if (isdigit((unsigned char)*p)) { - val = strtol(p, &p, 10); /* if 0, it's failure */ - for (; !isdigit((unsigned char)*p) - && !isalpha((unsigned char)*p) && *p != '*'; ++p); - *endp = p; - return (val); - } - for (start = p; isalpha((unsigned char)*++p);); + if (d_first < 0) + d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); - /* Sunday-1 */ - if (*p == '+' || *p == '-') - for(; isdigit((unsigned char)*++p);) - ; - - savech = *p; - *p = '\0'; - - /* Month */ - if ((val = getmonth(start)) != 0) - *flags |= F_ISMONTH; - - /* Day */ - else if ((val = getday(start)) != 0) { - *flags |= F_ISDAY; - - /* variable weekday */ - if ((var = getdayvar(start)) != 0) { - if (var <= 5 && var >= -4) - val += var * 10; -#ifdef DEBUG - printf("var: %d\n", var); -#endif + for (i = 0; i < count; i++) { + tm.tm_mon = month[i] - 1; + tm.tm_mday = day[i]; + tm.tm_year = year[i] - 1900; + (void)strftime(dbuf, sizeof(dbuf), + d_first ? "%e %b" : "%b %e", &tm); + if (debug) + fprintf(stderr, "got %s\n", pp); + events[i] = event_add(year[i], month[i], day[i], dbuf, + ((flags &= F_VARIABLE) != 0) ? 1 : 0, pp, + extradata[i]); } } - /* Easter */ - else if ((val = geteaster(start, tp->tm_year + 1900)) != 0) - *flags |= F_EASTER; - - /* Paskha */ - else if ((val = getpaskha(start, tp->tm_year + 1900)) != 0) - *flags |= F_EASTER; - - /* undefined rest */ - else { - *p = savech; - return (0); - } - for (*p = savech; !isdigit((unsigned char)*p) - && !isalpha((unsigned char)*p) && *p != '*'; ++p) - ; - *endp = p; - return (val); + event_print_all(fp); + closecal(fp); + free(extradata); } FILE * opencal(void) { uid_t uid; size_t i; int fd, found, pdes[2]; struct stat sbuf; /* open up calendar file as stdin */ if (!freopen(calendarFile, "r", stdin)) { if (doall) { if (chdir(calendarHomes[0]) != 0) return (NULL); if (stat(calendarNoMail, &sbuf) == 0) return (NULL); if (!freopen(calendarFile, "r", stdin)) return (NULL); } else { char *home = getenv("HOME"); if (home == NULL || *home == '\0') errx(1, "cannot get home directory"); - chdir(home); + if (chdir(home) != 0) + errx(1, "cannot enter home directory"); for (found = i = 0; i < sizeof(calendarHomes) / sizeof(calendarHomes[0]); i++) if (chdir(calendarHomes[i]) == 0 && freopen(calendarFile, "r", stdin)) { found = 1; break; } if (!found) errx(1, "can't open calendar file \"%s\": %s (%d)", calendarFile, strerror(errno), errno); } } if (pipe(pdes) < 0) return (NULL); switch (fork()) { case -1: /* error */ (void)close(pdes[0]); (void)close(pdes[1]); return (NULL); case 0: /* child -- stdin already setup, set stdout to pipe input */ if (pdes[1] != STDOUT_FILENO) { (void)dup2(pdes[1], STDOUT_FILENO); (void)close(pdes[1]); } (void)close(pdes[0]); uid = geteuid(); if (setuid(getuid()) < 0) { warnx("first setuid failed"); _exit(1); }; if (setgid(getegid()) < 0) { warnx("setgid failed"); _exit(1); } if (setuid(uid) < 0) { warnx("setuid failed"); _exit(1); } execl(_PATH_CPP, "cpp", "-P", "-traditional", "-nostdinc", /* GCC specific opts */ "-I.", "-I", _PATH_INCLUDE, (char *)NULL); warn(_PATH_CPP); _exit(1); } /* parent -- set stdin to pipe output */ (void)dup2(pdes[0], STDIN_FILENO); (void)close(pdes[0]); (void)close(pdes[1]); /* not reading all calendar files, just set output to stdout */ if (!doall) return (stdout); /* set output to a temporary file, so if no output don't send mail */ (void)snprintf(path, sizeof(path), "%s/_calXXXXXX", _PATH_TMP); if ((fd = mkstemp(path)) < 0) return (NULL); return (fdopen(fd, "w+")); } void closecal(FILE *fp) { uid_t uid; struct stat sbuf; int nread, pdes[2], status; char buf[1024]; if (!doall) return; - (void)rewind(fp); + rewind(fp); if (fstat(fileno(fp), &sbuf) || !sbuf.st_size) goto done; if (pipe(pdes) < 0) goto done; switch (fork()) { case -1: /* error */ (void)close(pdes[0]); (void)close(pdes[1]); goto done; case 0: /* child -- set stdin to pipe output */ if (pdes[0] != STDIN_FILENO) { (void)dup2(pdes[0], STDIN_FILENO); (void)close(pdes[0]); } (void)close(pdes[1]); uid = geteuid(); if (setuid(getuid()) < 0) { warnx("setuid failed"); _exit(1); }; if (setgid(getegid()) < 0) { warnx("setgid failed"); _exit(1); } if (setuid(uid) < 0) { warnx("setuid failed"); _exit(1); } execl(_PATH_SENDMAIL, "sendmail", "-i", "-t", "-F", "\"Reminder Service\"", (char *)NULL); warn(_PATH_SENDMAIL); _exit(1); } /* parent -- write to pipe input */ (void)close(pdes[0]); - header[1].iov_base = header[3].iov_base = pw->pw_name; - header[1].iov_len = header[3].iov_len = strlen(pw->pw_name); - writev(pdes[1], header, 7); + write(pdes[1], "From: \"Reminder Service\" <", 26); + write(pdes[1], pw->pw_name, strlen(pw->pw_name)); + write(pdes[1], ">\nTo: <", 7); + write(pdes[1], pw->pw_name, strlen(pw->pw_name)); + write(pdes[1], ">\nSubject: ", 12); + write(pdes[1], dayname, strlen(dayname)); + write(pdes[1], "'s Calendar\nPrecedence: bulk\n\n", 30); + while ((nread = read(fileno(fp), buf, sizeof(buf))) > 0) (void)write(pdes[1], buf, nread); (void)close(pdes[1]); done: (void)fclose(fp); (void)unlink(path); while (wait(&status) >= 0); } Index: stable/8/usr.bin/calendar/ostern.c =================================================================== --- stable/8/usr.bin/calendar/ostern.c (revision 211722) +++ stable/8/usr.bin/calendar/ostern.c (revision 211723) @@ -1,110 +1,67 @@ -/* +/*- * Copyright (c) 1996 Wolfram Schneider . Berlin. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. */ #include __FBSDID("$FreeBSD$"); #include #include #include -#include #include "calendar.h" /* return year day for Easter */ /* * This code is based on the Calendar FAQ's code for how to calculate * easter is. This is the Gregorian calendar version. They refer to * the Algorithm of Oudin in the "Explanatory Supplement to the * Astronomical Almanac". */ int easter(int year) /* 0 ... abcd, NOT since 1900 */ { int G, /* Golden number - 1 */ C, /* Century */ H, /* 23 - epact % 30 */ I, /* days from 21 March to Paschal full moon */ J, /* weekday of full moon */ L; /* days from 21 March to Sunday on of before full moon */ G = year % 19; C = year / 100; H = (C - C / 4 - (8 * C + 13) / 25 + 19 * G + 15) % 30; I = H - (H / 28) * (1 - (H / 28) * (29 / (H + 1)) * ((21 - G) / 11)); J = (year + year / 4 + I + 2 - C + C / 4) % 7; L = I - J; - if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) + if (isleap(year)) return 31 + 29 + 21 + L + 7; else return 31 + 28 + 21 + L + 7; -} - -/* return year day for Easter or easter depending days - * Match: Easter([+-][0-9]+)? - * e.g: Easter-2 is Good Friday (2 days before Easter) - */ - -int -geteaster(char *s, int year) -{ - int offset = 0; - -#define EASTER "easter" -#define EASTERNAMELEN (sizeof(EASTER) - 1) - - if (strncasecmp(s, EASTER, EASTERNAMELEN) == 0) - s += EASTERNAMELEN; - else if (neaster.name != NULL - && strncasecmp(s, neaster.name, neaster.len) == 0) - s += neaster.len; - else - return (0); - -#if DEBUG - printf("%s %d %d\n", s, year, EASTERNAMELEN); -#endif - - /* Easter+1 or Easter-2 - * ^ ^ */ - - switch (*s) { - - case '-': - case '+': - offset = atoi(s); - break; - - default: - offset = 0; - } - - return (easter(year) + offset); } Index: stable/8/usr.bin/calendar/paskha.c =================================================================== --- stable/8/usr.bin/calendar/paskha.c (revision 211722) +++ stable/8/usr.bin/calendar/paskha.c (revision 211723) @@ -1,91 +1,57 @@ -/* +/*- * Copyright (C) 1993-1996 by Andrey A. Chernov, Moscow, Russia. * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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. */ #include __FBSDID("$FreeBSD$"); #include #include #include -#include #include "calendar.h" #define PASKHA "paskha" #define PASKHALEN (sizeof(PASKHA) - 1) -static int paskha(int); - /* return year day for Orthodox Easter using Gauss formula */ /* (old style result) */ -static int +int paskha(int R) /*year*/ { int a, b, c, d, e; static int x = 15; static int y = 6; + int *cumday; a = R % 19; b = R % 4; c = R % 7; d = (19 * a + x) % 30; e = (2 * b + 4 * c + 6 * d + y) % 7; - return (((cumdays[3] + 1) + 22) + (d + e)); -} - -/* return year day for Orthodox Easter depending days */ - -int -getpaskha(char *s, int year) -{ - int offset; - - if (strncasecmp(s, PASKHA, PASKHALEN) == 0) - s += PASKHALEN; - else if (npaskha.name != NULL - && strncasecmp(s, npaskha.name, npaskha.len) == 0) - s += npaskha.len; - else - return 0; - - /* Paskha+1 or Paskha-2 - * ^ ^ */ - - switch (*s) { - - case '-': - case '+': - offset = atoi(s); - break; - - default: - offset = 0; - break; - } - - return (paskha(year) + offset + 13 /* new style */); + cumday = cumdaytab[isleap(R)]; + return (((cumday[3] + 1) + 22) + (d + e)); } Index: stable/8/usr.bin/calendar/pathnames.h =================================================================== --- stable/8/usr.bin/calendar/pathnames.h (revision 211722) +++ stable/8/usr.bin/calendar/pathnames.h (revision 211723) @@ -1,40 +1,36 @@ -/* +/*- * Copyright (c) 1989, 1993 * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * 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. * * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 * $FreeBSD$ */ #include #define _PATH_CPP "/usr/bin/cpp" #define _PATH_INCLUDE "/usr/share/calendar" Index: stable/8/usr.bin/calendar =================================================================== --- stable/8/usr.bin/calendar (revision 211722) +++ stable/8/usr.bin/calendar (revision 211723) Property changes on: stable/8/usr.bin/calendar ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/usr.bin/calendar:r196045-196247,196249-196878,196880-197787,197789-198019,198021-198479,198481-198482,198484-198896,198898-199746,199748-199798,199800-199820,199823-200170,200172-200181,200183-200274,200276-200294,200296-200317,200319-200358,200360-200623,200625-200649,200651-203039,203041-203044,203046-203047,203049-203375,203377-203383,203385-204194,204196-205852,205855-205991,205993-207841,207843,207845-208088,208090-208319,208321-211516