[BACK]Return to calendar.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / calendar

Annotation of src/usr.bin/calendar/calendar.h, Revision 1.14

1.14    ! millert     1: /*     $OpenBSD: calendar.h,v 1.13 2010/04/28 18:20:15 jsg Exp $       */
1.1       millert     2:
                      3: /*
                      4:  * Copyright (c) 1989, 1993, 1994
                      5:  *     The Regents of the University of California.  All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
1.9       millert    15:  * 3. Neither the name of the University nor the names of its contributors
1.1       millert    16:  *    may be used to endorse or promote products derived from this software
                     17:  *    without specific prior written permission.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     20:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     21:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     22:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     23:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     24:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     25:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     26:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     27:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     28:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     29:  * SUCH DAMAGE.
                     30:  */
                     31:
                     32:
                     33: extern struct passwd *pw;
                     34: extern int doall;
1.6       mickey     35: extern int bodun_always;
1.4       pjanzen    36: extern time_t f_time;
1.1       millert    37: extern struct tm *tp;
                     38: extern char *calendarFile;
1.5       pjanzen    39: extern char *calendarHome;
1.1       millert    40: extern char *optarg;
                     41:
1.3       pjanzen    42: struct fixs {
                     43:        char *name;
                     44:        int len;
                     45: };
                     46:
                     47: struct event {
                     48:        time_t  when;
                     49:        char    print_date[31];
1.4       pjanzen    50:        char    **desc;
                     51:        char    *ldesc;
1.3       pjanzen    52:        struct event    *next;
                     53: };
                     54:
                     55: struct match {
1.4       pjanzen    56:        time_t  when;
                     57:        char    print_date[30];
1.7       mickey     58:        int     bodun;
1.4       pjanzen    59:        int     var;
                     60:        struct match    *next;
                     61: };
                     62:
                     63: struct specialev {
                     64:        char *name;
                     65:        int nlen;
                     66:        char *uname;
                     67:        int ulen;
1.8       millert    68:        int (*getev)(int);
1.3       pjanzen    69: };
                     70:
1.8       millert    71: void    cal(void);
                     72: void    closecal(FILE *);
                     73: int     getday(char *);
                     74: int     getdayvar(char *);
                     75: int     getfield(char *, char **, int *);
                     76: int     getmonth(char *);
1.11      mickey     77: int     pesach(int);
1.8       millert    78: int     easter(int);
                     79: int     paskha(int);
                     80: void    insert(struct event **, struct event *);
                     81: struct match   *isnow(char *, int);
                     82: FILE   *opencal(void);
                     83: void    settime(time_t *);
                     84: time_t  Mktime(char *);
                     85: void    usage(void);
                     86: int     foy(int);
                     87: void    variable_weekday(int *, int, int);
                     88: void    setnnames(void);
1.1       millert    89:
                     90: /* some flags */
                     91: #define        F_ISMONTH       0x01 /* month (Januar ...) */
                     92: #define        F_ISDAY         0x02 /* day of week (Sun, Mon, ...) */
1.4       pjanzen    93: /*#define      F_ISDAYVAR      0x04  variables day of week, like SundayLast */
                     94: #define        F_SPECIAL       0x08 /* Events that occur once a year but don't track
                     95:                              * calendar time--e.g.  Easter or easter depending
                     96:                              * days */
1.14    ! millert    97:
        !            98: #define        SECSPERDAY      (24 * 60 * 60)
        !            99: #define        isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
1.1       millert   100:
1.2       deraadt   101: extern int f_dayAfter; /* days after current date */
                    102: extern int f_dayBefore;        /* days before current date */
1.12      mickey    103: extern int f_SetdayAfter; /* calendar invoked with -A */
1.4       pjanzen   104:
                    105: /* Special events; see also setnnames() in day.c */
                    106: /* '=' is not a valid character in a special event name */
1.11      mickey    107: #define PESACH "pesach"
                    108: #define PESACHLEN (sizeof(PESACH) - 1)
1.4       pjanzen   109: #define EASTER "easter"
                    110: #define EASTERNAMELEN (sizeof(EASTER) - 1)
                    111: #define PASKHA "paskha"
                    112: #define PASKHALEN (sizeof(PASKHA) - 1)
1.10      mickey    113:
                    114: /* calendars */
                    115: extern enum calendars { GREGORIAN = 0, JULIAN, LUNAR } calendar;
                    116: extern u_long julian;
1.4       pjanzen   117:
1.11      mickey    118: #define NUMEV 3        /* Total number of such special events */
1.4       pjanzen   119: extern struct specialev spev[NUMEV];
1.5       pjanzen   120:
                    121: /* For calendar -a, specify a maximum time (in seconds) to spend parsing
                    122:  * each user's calendar files.  This prevents them from hanging calendar
                    123:  * (e.g. by using named pipes)
                    124:  */
                    125: #define USERTIMEOUT 20