1 #ifndef __COMMON_H
2 # define __COMMON_H
3 /*!
4 *  \file common.h
5 *  \brief Basic program specific statements, macros and typedefs...
6 */
7 /*
8 *  Copyright (c) 1994, 95, 96, 1997, 2000, 2011, 2012 Thomas Esken
9 *  Copyright (c) 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
10 *
11 *  This software doesn't claim completeness, correctness or usability.
12 *  On principle I will not be liable for ANY damages or losses (implicit
13 *  or explicit), which result from using or handling my software.
14 *  If you use this software, you agree without any exception to this
15 *  agreement, which binds you LEGALLY !!
16 *
17 *  This program is free software; you can redistribute it and/or modify
18 *  it under the terms of the `GNU General Public License' as published by
19 *  the `Free Software Foundation'; either version 3, or (at your option)
20 *  any later version.
21 *
22 *  You should have received a copy of the `GNU General Public License'
23 *  along with this program; if not, write to the:
24 *
25 */
26 
27 
28 
29 /*
30 *  $Id: common.h 3.01 2000/06/14 03:00:01 tom Exp $
31 */
32 
33 
34 
35 /*
36 *  Include (sub)header files   ;<
37 */
38 # if USE_UNICODE
39 #  include "unistdio.h"
40 #  include "unistr.h"
41 #  undef sprintf
42 #  define sprintf u8_sprintf
43 #  undef strlen
44 #  define strlen u8_strlen
45 # endif
46 # if HAVE_STDIO_H || STDC_HEADERS
47 #  include <stdio.h>
48 # endif
49 # if HAVE_STDLIB_H || STDC_HEADERS
50 #  include <stdlib.h>
51 # endif
52 # if HAVE_STRING_H || STDC_HEADERS
53 #  include <string.h>
54 # else /* !HAVE_STRING_H && !STDC_HEADERS */
55 #  include <strings.h>
56 #  if !HAVE_STRCHR
57 #   ifndef strchr
58 #    define strchr       index
59 extern char *strchr __P_ ((const char *s, int c));
60 #   endif
61 #  endif /* !HAVE_STRCHR */
62 #  if !HAVE_STRRCHR
63 #   ifndef strrchr
64 #    define strrchr      rindex
65 extern char *strrchr __P_ ((const char *s, int c));
66 #   endif
67 #  endif /* !HAVE_STRRCHR */
68 # endif	/* !HAVE_STRING_H && !STDC_HEADERS */
69 
70 # if HAVE_SIGNAL_H && HAVE_SIGNAL
71 #  if HAVE_SYS_TYPES_H
72 #   include <sys/types.h>
73 #  endif
74 #  include <signal.h>
75 # endif
76 # if defined(AMIGA) && !defined(__GNUC__)
77 extern long atol __P_ ((const char *string));
78 # endif
79 # ifdef __50SERIES
80 extern char *getenv __P_ ((const char *env_var));
81 #  if HAVE_SIGNAL && defined(SIGTERM)
82 /* We don't want a signal handler for SIGTERM */
83 #   undef  SIGTERM
84 #  endif
85 # endif
86 
87 
88 
89 /*
90 *  Basic preprocessor statements and macros.
91 */
92 # ifdef SPECIAL_VALUE
93 #  undef  SPECIAL_VALUE
94 # endif
95 /*
96 *  !!! DO NOT TOUCH THIS SPECIAL_VALUE, OTHERWISE YOU DESTROY THE PROGRAM !!!
97 */
98 # define SPECIAL_VALUE    (-1)
99 # ifndef TRUE
100 #  define TRUE            (0==0)
101 # endif
102 # ifndef FALSE
103 #  define FALSE           (!TRUE)
104 # endif
105 # ifndef __LINE__
106 #  define __LINE__         0L
107 # endif
108 # ifndef __FILE__
109 #  define __FILE__         "???"
110 # endif
111 # ifndef __DATE__
112 #  define __DATE__         "DD-MMM-YYYY"
113 # endif
114 # ifndef __TIME__
115 #  define __TIME__         "HH:MM:SS"
116 # endif
117 # define LOOP              for(;;)
118 # if HAVE_VOID
119 #  define VOID_PTR        void *
120 # else /* !HAVE_VOID */
121 #  define VOID_PTR        char *
122 #  define void            int
123 # endif	/* !HAVE_VOID */
124 # ifndef RETSIGTYPE
125 #  define RETSIGTYPE      void
126 # endif
127 # if !HAVE_STRSTR
128 #  ifndef strstr
129 #   define strstr          my_strstr
130 #  endif
131 # endif
132 # if !HAVE_STRCSPN
133 #  ifndef strcspn
134 #   define strcspn          my_strcspn
135 #  endif
136 # endif
137 # if !HAVE_STRCASECMP
138 #  ifndef strcasecmp
139 #   define strcasecmp      my_strcasecmp
140 #  endif
141 # endif
142 # if !HAVE_STRNCASECMP
143 #  ifndef strncasecmp
144 #   define strncasecmp     my_strncasecmp
145 #  endif
146 # endif
147 # if HAVE_TIME_T
148 #  define MY_TIME_T       time_t
149 # else /* !HAVE_TIME_T */
150 #  define MY_TIME_T       long
151 # endif	/* !HAVE_TIME_T */
152 # if !HAVE_UPPER_LOWER
153 #  ifndef islower
154 #   define islower(gc_c) (((gc_c) >= 'a') && ((gc_c) <= 'z'))
155 #  endif
156 #  ifndef isupper
157 #   define isupper(gc_c) (((gc_c) >= 'A') && ((gc_c) <= 'Z'))
158 #  endif
159 #  ifndef tolower
160 #   define tolower(gc_c) ((isupper(gc_c)) ? (gc_c) - 'A' + 'a' : (gc_c))
161 #  endif
162 #  ifndef toupper
163 #   define toupper(gc_c) ((islower(gc_c)) ? (gc_c) - 'a' + 'A' : (gc_c))
164 #  endif
165 # endif
166 # if !HAVE_ISDIGIT
167 #  ifndef isdigit
168 #   define isdigit(gc_c) (((gc_c) >= '0') && ((gc_c) <= '9'))
169 #  endif
170 # endif
171 # if !HAVE_ISALPHA
172 #  ifndef isalpha
173 #   define isalpha(gc_c) (isupper(gc_c) || islower(gc_c))
174 #  endif
175 # endif
176 # if !HAVE_ISALNUM
177 #  ifndef isalnum
178 #   define isalnum(gc_c) (isalpha(gc_c) || isdigit(gc_c))
179 #  endif
180 # endif
181 # if !HAVE_ISSPACE
182 #  ifndef isspace
183 #   define isspace(gc_c) (   (gc_c) == ' '  || (gc_c) == '\f' || (gc_c) == '\n' \
184                               || (gc_c) == '\r' || (gc_c) == '\t' || (gc_c) == '\v')
185 #  endif
186 # endif
187 /*
188 *  Preprocessor macros used to activate some self-written mathematical
189 *    functions if no mathematical library is available.
190 */
191 # if !HAVE_LIBM
192 #  ifdef floor
193 #   undef  floor
194 #  endif
195 #  define floor  my_floor
196 #  ifdef ceil
197 #   undef  ceil
198 #  endif
199 #  define ceil   my_ceil
200 #  ifdef sqrt
201 #   undef  sqrt
202 #  endif
203 #  define sqrt   my_sqrt
204 #  ifdef log
205 #   undef  log
206 #  endif
207 #  define log    my_log
208 #  ifdef log10
209 #   undef  log10
210 #  endif
211 #  define log10  my_log10
212 #  ifdef sin
213 #   undef  sin
214 #  endif
215 #  define sin    my_sin
216 #  ifdef cos
217 #   undef  cos
218 #  endif
219 #  define cos    my_cos
220 #  ifdef tan
221 #   undef  tan
222 #  endif
223 #  define tan    my_tan
224 #  ifdef asin
225 #   undef  asin
226 #  endif
227 #  define asin   my_asin
228 #  ifdef acos
229 #   undef  acos
230 #  endif
231 #  define acos   my_acos
232 #  ifdef atan
233 #   undef  atan
234 #  endif
235 #  define atan   my_atan
236 # endif	/* !HAVE_LIBM */
237 
238 
239 
240 /*!
241 *  Preprocessor statements for the exit codes.
242 */
243 # define ERR_NONE                      0
244 /*
245 *  Common values.
246 */
247 # define ERR_TERMINATION_BY_SIGNAL     3
248 # define ERR_INVALID_DATE_FORMAT       106
249 # define ERR_INTERNAL_TABLE_CRASH      107
250 # define ERR_ILLEGAL_CHAR_IN_FILE      108
251 # define ERR_READ_FILE                 109
252 # define ERR_WRITE_FILE                115
253 # define ERR_NO_MEMORY_AVAILABLE       124
254 # define ERR_INVALID_EASTER_DATE       125
255 # define ERR_INVALID_OPTION            126
256 # define ERR_EXIT_INFO_TEXTS_NON_ZERO  127
257 /*
258 *  System/configuration dependent values.
259 */
260 # ifdef GCAL_EMAIL
261 #  define ERR_EMAIL_SEND_FAILURE        111
262 # endif
263 # if defined(GCAL_EPAGER) || defined(GCAL_EMAIL) || USE_RC
264 #  define ERR_INTERNAL_C_FUNC_FAILURE   110
265 # endif
266 /*
267 *  Force the use of THESE values!
268 */
269 # ifndef EXIT_FATAL
270 #  define EXIT_FATAL                    2
271 # endif
272 
273 
274 
275 /*
276 *  Program specific preprocessor statements.
277 */
278 /*! Maximum length of a file block buffer. */
279 # ifndef BUF_LEN
280 #  define BUF_LEN           16384
281 # endif
282 
283 /*! Default length of a "string" text buffer. */
284 # ifndef MAXLEN_MAX
285 #  define MAXLEN_MAX       1024
286 # endif
287 
288 /*! Default number of command line arguments in `my_argv[]' table. */
289 # ifndef MY_ARGC_MAX
290 #  define MY_ARGC_MAX      64
291 # endif
292 
293 /*! Gcal's exit status on: help, version, license. */
294 # ifndef EXIT_STAT_HELP
295 #  define EXIT_STAT_HELP   EXIT_SUCCESS
296 # endif
297 
298 /*! Default length of a displayed (native language translated) text line. */
299 # ifndef LEN_SINGLE_LINE
300 #  define LEN_SINGLE_LINE  200
301 # endif
302 
303 /*! Maximum amount of debug/warning levels. */
304 # define WARN_LVL_MAX     4
305 
306 
307 
308 /*!
309 *  Preprocessor statements for long options `Lopt_struct' field `symbolic_name'.
310 */
311 # define SYM_NIL                         0
312 /*
313 *  Common values.
314 */
315 # define SYM_BLOCKS                      1
316 # define SYM_CALENDAR_DATES              2
317 # define SYM_CALENDAR_WITH_WEEK_NUMBER   3
318 # define SYM_DATE_FORMAT                 4
319 # define SYM_DEBUG                       5
320 # define SYM_DESC_HOLIDAY_LIST           6
321 # define SYM_DISABLE_HIGHLIGHTING        7
322 # define SYM_EXCLUDE_HD_TITLE            8
323 # define SYM_EXIT_STAT_HELP_NON_ZERO     9
324 # define SYM_FORCE_HIGHLIGHTING          10
325 # define SYM_GREG_REFORM                 11
326 # define SYM_HELP                        12
327 # define SYM_HIGHLIGHTING                13
328 # define SYM_HOLIDAY_DATES               14
329 # define SYM_HOLIDAY_LIST                15
330 # define SYM_ISO_WEEK_NUMBER             16
331 # define SYM_LICENSE1                    17
332 # define SYM_LICENSE2                    18
333 # define SYM_LICENSE3                    19
334 # define SYM_LONG_HELP1                  20
335 # define SYM_LONG_HELP2                  21
336 # define SYM_ORTHODOX_CALENDAR           22
337 # define SYM_RESPONSE_FILE               23
338 # define SYM_STARTING_DAY                24
339 # define SYM_SUPPRESS_CALENDAR           25
340 # define SYM_SUPPRESS_HDLIST_SEP         26
341 # define SYM_TIME_OFFSET                 27
342 # define SYM_TRANSFORM_YEAR              28
343 # define SYM_TRANSLATE_STRING            29
344 # define SYM_TYPE_OF_CALENDAR            30
345 # define SYM_VERSION                     31
346 /*
347 *  Common holiday list values.
348 */
349 # define SYM_ASTRONOMICAL_HDY            50
350 # define SYM_MULTICULTURAL_NEW_YEAR_HDY  51
351 # define SYM_ZODIACAL_MARKER_HDY         52
352 # define SYM_CC_HDY                      53
353 /*
354 *  Calendar specific holiday list values.
355 */
356 # define SYM_BAHAI_HDY                   60
357 # define SYM_CELTIC_HDY                  61
358 # define SYM_CHINESE_FLEXIBLE_HDY        62
359 # define SYM_CHINESE_HDY                 63
360 # define SYM_CHRISTIAN_HDY               64
361 # define SYM_HEBREW_HDY                  65
362 # define SYM_ISLAMIC_HDY                 66
363 # define SYM_JAPANESE_FLEXIBLE_HDY       67
364 # define SYM_JAPANESE_HDY                68
365 # define SYM_ORTHODOX_NEW_HDY            69
366 # define SYM_ORTHODOX_OLD_HDY            70
367 # define SYM_PERSIAN_HDY                 71
368 /*
369 *  Calendar specific month list values.
370 */
371 # define SYM_BAHAI_MTH                   80
372 # define SYM_CHINESE_FLEXIBLE_MTH        81
373 # define SYM_CHINESE_MTH                 82
374 # define SYM_COPTIC_MTH                  83
375 # define SYM_ETHIOPIC_MTH                84
376 # define SYM_FRENCH_REVOLUTIONARY_MTH    85
377 # define SYM_HEBREW_MTH                  86
378 # define SYM_INDIAN_CIVIL_MTH            87
379 # define SYM_ISLAMIC_MTH                 88
380 # define SYM_JAPANESE_FLEXIBLE_MTH       89
381 # define SYM_JAPANESE_MTH                90
382 # define SYM_OLD_ARMENIC_MTH             91
383 # define SYM_OLD_EGYPTIC_MTH             92
384 # define SYM_PERSIAN_MTH                 93
385 /*
386 *  System dependent values.
387 */
388 # ifdef GCAL_SHELL
389 #  define SYM_SCRIPT_FILE                 100
390 # endif
391 # ifdef GCAL_EMAIL
392 #  define SYM_MAIL                        101
393 # endif
394 /*!
395 *  Configuration dependent values.
396 */
397 # if USE_PAGER
398 #  define SYM_PAGER                       150
399 # endif
400 
401 
402 
403 /*
404 *  Preprocessor statements for long options `Lopt_struct' field `larg_mode'.
405 */
406 /*! `--foo'. */
407 # define LARG_NO          0
408 
409 /*! `--foo' or `--foo=BAR'. */
410 # define LARG_NO_OR_ONE   1
411 
412 /*! `--foo=BAR'. */
413 # define LARG_ONE         2
414 
415 /*! `--foo=BAR' or `--foo=ARG'. */
416 # define LARG_ONE_OR_ARG  3
417 
418 /*
419 *  Further preprocessor statements used for long-style options.
420 */
421 /*! Maximum number of arguments a long option may have. */
422 # define LARG_MAX        6
423 
424 /*! Argument separator of a long option, e.g. `--foo=BAR'. */
425 # define LARG_SEP        "="
426 
427 
428 
429 /*
430 *  Some other common environment variable names.
431 */
432 /*! Name of the timezone environment variable. */
433 # define ENV_VAR_TZ    "TZ"
434 
435 # if USE_PAGER
436 /*! Name of number of terminal rows environment variable. */
437 #  define ENV_VAR_LI    "GCAL_LINES"
438 
439 /*! Name of number of terminal columns environment variable. */
440 #  define ENV_VAR_CO    "GCAL_COLUMNS"
441 
442 /*! Name of number of terminal rows environment variable. */
443 #  define ENV_VAR_LI2   "LINES"
444 
445 /* Name of number of terminal columns environment variable. */
446 #  define ENV_VAR_CO2   "COLUMNS"
447 # endif
448 
449 
450 
451 /*
452 *  Further preprocessor symbols.
453 */
454 /*! Comment character of a resource/response file line. */
455 # define REM_CHAR          ';'
456 
457 /*! Marker character of a response file (@FILE). */
458 # define RSP_CHAR          '@'
459 
460 /*! Character used to quote a newline character etc. */
461 # define QUOTE_CHAR        '\\'
462 
463 /*! Character used to replace a QUOTE_CHAR. */
464 # define PSEUDO_QUOTE      '\001'
465 
466 /*! Used to insert a blank (' ') in places the OS normally forbits its use. */
467 # define PSEUDO_BLANK      '_'
468 
469 /*! Separator of user defined sequences: `-HSEQ:SEQ...' `-vARG:ARG...' `-rARG:ARG...'. */
470 # define SEP               ":"
471 
472 /*! Separator used for splitting lists, e.g. `-P e[DATE][,e[DATE],...]. */
473 # define SPLIT_SEP         ","
474 
475 /*! Separator used for connecting lists, e.g. `--cc-holidays=CC[+CC+...]'. */
476 # define CONNECT_SEP       "+"
477 
478 /*! Default switch char, which defines an command line option. */
479 # define SWITCH            "-"
480 
481 /*! First additional switch char. */
482 # define SWITCH2           "/"
483 
484 /*! Separator of a list of months (MM,MM). */
485 # define MLIST_SEP         ","
486 
487 /*! Separator of a range of months (MM-MM). */
488 # define MRANGE_SEP        "-"
489 
490 /*! Separator of a list of years (YYYY;YYYY). */
491 # define YLIST_SEP         ";"
492 
493 /*! Separator of a range of years (YYYY+YYYY). */
494 # define YRANGE_SEP        "+"
495 
496 /*! Separator of a standard year (MM/YYYY). */
497 # define YEAR_SEP          "/"
498 
499 /*! Separator of a fiscal year (MM:YYYY). */
500 # define FYEAR_SEP         ":"
501 
502 /*! Command for enabling 3-month mode (.|..|.+|.-). */
503 # define MONTH3_LIT        "."
504 
505 /*! Prefix to disable highlighting of a holiday. */
506 # define DIS_HLS_PREF      "-"
507 
508 /*! Prefix to disable highlighting of a holiday. */
509 # define DIS_HLS_PREF2     "*"
510 
511 /*! Modifier for moving ascending/forwards in date/PLUS sign. */
512 # define ASC_LIT           "+"
513 
514 /*! Modifier for moving descending/backwards in date/MINUS sign. */
515 # define DES_LIT           "-"
516 
517 /*! Identifier for actual local time based time offsets used in the `--time_offset=ARG' option. */
518 # if !USE_RC
519 #  define staticTIME_CHAR    't'
520 # endif	/* USE_RC */
521 
522 /*! Default time separator for scanning HH:MM time expressions. */
523 # define DEFAULT_TIME_SEP  ":"
524 
525 /*! Mininum length of a day "cell" used in calendar sheets. */
526 # define FORMAT_LEN_MIN    3
527 
528 /*! Minimum length of a textual day name. */
529 # define TXTLEN_DAY        2
530 
531 /*! Minimum length of a textual month name. */
532 # define TXTLEN_MONTH      3
533 
534 /*! Number of standard calsheet format default rows standard date. */
535 # define S_OUT_ROWS        3
536 
537 /*! Number of standard calsheet format default columns standard date. */
538 # define S_OUT_COLS        4
539 
540 /*! Number of standard calsheet format default rows special date. */
541 # define J_OUT_ROWS        4
542 
543 /*! Number of standard calsheet format default columns special date. */
544 # define J_OUT_COLS        3
545 
546 /*! Number of standard calsheet format default rows both dates. */
547 # define B_OUT_ROWS        12
548 
549 /*! Number of standard calsheet format default columns both dates. */
550 # define B_OUT_COLS        1
551 
552 /*! Number of special calsheet format default rows standard date. */
553 # define SI_OUT_ROWS       4
554 
555 /*! Number of special calsheet format default columns standard date. */
556 # define SI_OUT_COLS       3
557 
558 /*! Number of special calsheet format default rows special date. */
559 # define JI_OUT_ROWS       6
560 
561 /*! Number of special calsheet format default columns special date. */
562 # define JI_OUT_COLS       2
563 
564 /*! Number of special calsheet format default rows both dates. */
565 # define BI_OUT_ROWS       B_OUT_ROWS
566 
567 /*! Number of special calsheet format default columns both dates. */
568 # define BI_OUT_COLS       B_OUT_COLS
569 
570 /*! No of standard calsheet format default 3-month mode rows standard date. */
571 # define S3_OUT_ROWS       1
572 
573 /*! No of standard calsheet format default 3-month mode columns standard date. */
574 # define S3_OUT_COLS       3
575 
576 /*! No of standard calsheet format default 3-month mode rows special date. */
577 # define J3_OUT_ROWS       S3_OUT_ROWS
578 
579 /*! No of standard calsheet format default 3-month mode columns special date. */
580 # define J3_OUT_COLS       S3_OUT_COLS
581 
582 /*! No of standard calsheet format default 3-month mode rows both dates. */
583 # define B3_OUT_ROWS       3
584 
585 /*! No of standard calsheet format default 3-month mode columns both dates. */
586 # define B3_OUT_COLS       1
587 
588 /*! No of special calsheet format default 3-month mode rows standard date. */
589 # define SI3_OUT_ROWS      S3_OUT_ROWS
590 
591 /*! No of special calsheet format default 3-month mode columns standard date. */
592 # define SI3_OUT_COLS      S3_OUT_COLS
593 
594 /*! No of special calsheet format default 3-month mode rows special date. */
595 # define JI3_OUT_ROWS      B3_OUT_ROWS
596 
597 /*! No of special calsheet format default 3-month mode columns special date. */
598 # define JI3_OUT_COLS      B3_OUT_COLS
599 
600 /*! No of special calsheet format default 3-month mode rows both dates. */
601 # define BI3_OUT_ROWS      B3_OUT_ROWS
602 
603 /*! No of special calsheet format default 3-month mode columns both dates. */
604 # define BI3_OUT_COLS      B3_OUT_COLS
605 
606 
607 
608 /*
609 *  Characters used for ordering a displayed date.
610 */
611 /*! Identifier leading the character used for ordering a displayed date. */
612 # define DFORMAT_CHAR    '%'
613 
614 /*! %weekday name. */
615 # define WDNAME_CHAR     'K'
616 
617 /*! %day number. */
618 # define DAYNR_CHAR      'D'
619 
620 /*! %month name. */
621 # define MONTHNAME_CHAR  'U'
622 
623 /*! %month number. */
624 # define MONTHNR_CHAR    'M'
625 
626 /*! %year number. */
627 # define YEARNR_CHAR     'Y'
628 
629 /*! %highlighting sequence 1 enable. */
630 # define HLS1S_CHAR      '1'
631 
632 /*! %highlighting sequence 1 disable. */
633 # define HLS1E_CHAR      '2'
634 
635 
636 
637 /*
638 *  The elements used within the optional %... text format field,
639 *    which template is:  ALIGNMENT [SIGN] [LZERO] WIDTH [STYLE] [SUFFIX] FORMAT
640 */
641 /* Identification values for the different field styles. */
642 # define FSTYLE_NONE   SPECIAL_VALUE
643 # define FSTYLE_UPPER  1
644 # define FSTYLE_LOWER  2
645 # define FSTYLE_WORD   4
646 
647 /*! Minimum width of a field. */
648 # define FWIDTH_MIN    1
649 
650 /*! Maximum width of a field. */
651 # define FWIDTH_MAX    256
652 
653 /*! Field contents is aligned left. */
654 # define FLEFT_CHAR    '<'
655 
656 /*! Field contents is centered. */
657 # define FCENTER_CHAR  ':'
658 
659 /*! Field contents is aligned right. */
660 # define FRIGHT_CHAR   '>'
661 
662 /*! Provides numerical field contents with leading sign. */
663 # define FSIGN_CHAR    '+'
664 
665 /*! Provides numerical field contents with leading zero(es) */
666 # define FLZERO_CHAR   '0'
667 
668 /*! Field contents is converted to upper-case letters. */
669 # define FUPPER_CHAR   'u'
670 
671 /*! Field contents is converted to lower-case letters. */
672 # define FLOWER_CHAR   'l'
673 
674 /*! Field contents is converted to capitalized words. */
675 # define FWORD_CHAR    'w'
676 
677 /*! Appends ordinal number suffix to numerical field contents. */
678 # define FSUFFIX_CHAR  '&'
679 
680 /*! Variable length field format. */
681 # define FVAR_CHAR     '*'
682 
683 /*! Fixed length field format. */
684 # define FFIX_CHAR     '#'
685 
686 /*
687 *  Important preprocessor symbols for the internal ranges.
688 */
689 /*! Minimum day of week/month/year. */
690 # define DAY_MIN     1
691 
692 /*! Maximum day/amount of days of week. */
693 # define DAY_MAX     7
694 
695 /*! Last day in a NON leap year. */
696 # define DAY_LAST    365
697 
698 /*! Maximum week number of year. */
699 # define WEEK_MAX    52
700 
701 /*! Minimum month of year. */
702 # define MONTH_MIN   1
703 
704 /*! Maximum month of year. */
705 # define MONTH_MAX   12
706 
707 /*! Highest day number in a month. */
708 # define MONTH_LAST  31
709 
710 /*! Minimum year able to compute. */
711 # define YEAR_MIN    1
712 
713 /*! Maximum year able to compute. */
714 # define YEAR_MAX    9999
715 
716 /*! Operating system standard starting century, DON'T change! */
717 # define CENTURY     1900
718 
719 /*! Minimum year for computing Easter Sunday (29+1). */
720 # define EASTER_MIN  30
721 
722 /*! Maximum year for computing Easter Sunday. */
723 # define EASTER_MAX  YEAR_MAX
724 
725 /*! Maximum number of columns of a month. */
726 # define MONTH_COLS  6
727 
728 /*! Maximum number of elements per month (DAY_MAX*MONTH_COLS). */
729 # define VEC_BLOCK   42
730 
731 /*! Maximum number of elements per year (VEC_BLOCK*MONTH_MAX). */
732 # define VEC_ELEMS   504
733 
734 
735 
736 /*
737 *  Additional usage texts.
738 */
739 # if !USE_RC
740 #  define USAGE_RC1  ""
741 #  define USAGE_RC2  ""
742 #  define USAGE_RC3  ""
743 #  define USAGE_RC4  ""
744 # endif	/* !USE_RC */
745 
746 # if USE_PAGER
747 /* Quits the internal pager. */
748 #  define PAGER_QUIT   "q"
749 /* Additional usage text. */
750 #  define USAGE_PAGER  "p"
751 # else /* !USE_PAGER */
752 #  define USAGE_PAGER  ""
753 # endif	/* !USE_PAGER */
754 
755 # ifdef GCAL_SHELL
756 /* Additional usage text. */
757 #  define USAGE_SHELL   "S"
758 # else /* !GCAL_SHELL */
759 #  define USAGE_SHELL   ""
760 # endif	/* !GCAL_SHELL */
761 
762 
763 
764 /*
765 *  And last but not least...
766 */
767 # define COPYRIGHT_TXT    "Copyright (c) 1994, 95, 96, 1997, 2000 Thomas Esken\n" \
768 "Copyright (c) 2010, 2011, 2012, 2014 Free Software Foundation, Inc."
769 # define BUG_REPORT_ADR1  "bug-gcal@gnu.org"
770 
771 # define HOMEPAGE "http://www.gnu.org/software/gcal"
772 # define HOMEPAGE_GNU_SOFTWARE "http://www.gnu.org/gethelp/"
773 
774 
775 
776 /*!
777 *  Number of days between 1.5-Jan-4713 BCE and 1.5-Jan-0001 CE.
778 */
779 # define MIN_BCE_TO_1_CE   1721424L
780 
781 
782 
783 /*
784 *  Some important mathematical constants.
785 */
786 # define MY_PI             3.14159265358979323846
787 # define MY_TWO_PI         6.28318530717958647692
788 # define MY_HALF_PI        1.57079632679489661923
789 
790 
791 
792 /*
793 *  Common preprocessor macros.
794 */
795 # ifdef S_NEWLINE
796 #  undef  S_NEWLINE
797 # endif
798 # define S_NEWLINE(gc_fp)    fputc('\n', (gc_fp))
799 # ifdef MIN
800 #  undef  MIN
801 # endif
802 # define MIN(gc_x1, gc_x2)   (((gc_x1) < (gc_x2)) ? (gc_x1) : (gc_x2))
803 # ifdef MAX
804 #  undef  MAX
805 # endif
806 # define MAX(gc_x1, gc_x2)   (((gc_x1) > (gc_x2)) ? (gc_x1) : (gc_x2))
807 # ifdef SYEAR
808 #  undef  SYEAR
809 # endif
810 # define SYEAR(gc_d, gc_s)   (  ((gc_d)-(gc_s)+1) < DAY_MIN) \
811                                 ? ((gc_d)-(gc_s)+(DAY_MAX+1)) \
812                                 : ((gc_d)-(gc_s)+1)
813 # ifdef SMONTH
814 #  undef  SMONTH
815 # endif
816 # define SMONTH(gc_d, gc_s)  (  ((gc_d)+(gc_s)-1) > MONTH_MAX) \
817                                 ? ((gc_d)+(gc_s)-(MONTH_MAX+1)) \
818                                 : ((gc_d)+(gc_s)-1)
819 # ifdef SDAY
820 #  undef  SDAY
821 # endif
822 # define SDAY(gc_d, gc_s)    (  ((gc_d)+(gc_s)-1) > DAY_MAX) \
823                                 ? ((gc_d)+(gc_s)-(DAY_MAX+1)) \
824                                 : ((gc_d)+(gc_s)-1)
825 
826 
827 
828 /*
829 *  Some useful mathematical functions.
830 */
831 /*!
832 *  Reduce a degree value to a value within circle range.
833 */
834 # ifdef FIXANGLE
835 #  undef FIXANGLE
836 # endif
837 # define FIXANGLE(a)  ((a) - 360.0 * (floor((a) / 360.0)))
838 /*!
839 *  Degrees to Radians := degree_value * Pi / 180.
840 */
841 # ifdef TORAD
842 #  undef TORAD
843 # endif
844 # define TORAD(r)  ((r)*0.017453292519943295769)
845 /*!
846 *  Radians to Degrees := radian_value * 180 / Pi.
847 */
848 # ifdef TODEG
849 #  undef TODEG
850 # endif
851 # define TODEG(d)  ((d)*57.295779513082320877)
852 /*!
853 *  Absolute value of a number := |x|.
854 */
855 # ifdef abs
856 #  undef  abs
857 # endif
858 # define abs(x)       (((x) < 0) ? (-(x)) : (x))
859 /*!
860 *  Sign of a number.
861 */
862 # ifdef SGN
863 #  undef  SGN
864 # endif
865 # define SGN(x)       (((x) < 0) ? -1 : (((x) > 0) ? 1 : 0))
866 /*!
867 *  Round-up factor.
868 */
869 # ifdef ROUND
870 #  undef  ROUND
871 # endif
872 # define ROUND(x)     ((abs(x)+0.5)*SGN(x))
873 
874 
875 /*
876 *  Some time values.
877 */
878 # define HOURS_PER_DAY       24
879 # define HOURS_PER_HALF_DAY  12
880 # define MINS_PER_DAY        1440
881 # define MINS_PER_HOUR       60
882 # define SECS_PER_MIN        MINS_PER_HOUR
883 # define SECS_PER_HOUR       3600
884 # define SECS_PER_DAY        86400L
885 
886 
887 
888 /*
889 *  Some degree values.
890 */
891 # define DEGS_PER_HOUR        15.0	/* 2 Pi in degrees / 24.0 hours. */
892 # define DEGS_PER_06_HOURS    90.0	/* Pi / 2 in degrees. */
893 # define DEGS_PER_12_HOURS   180.0	/* Pi in degrees. */
894 # define DEGS_PER_24_HOURS   360.0	/* 2 Pi in degrees. */
895 
896 
897 /*
898 *  Some degree to time and vice-versa conversion functions.
899 */
900 /*!
901 *  Degrees to Days := degree_value / 360.0 (15 degrees * 24 hours [2 Pi]).
902 */
903 # define DEG2DAY(d)      ((d) / DEGS_PER_24_HOURS)
904 /*!
905 *  Degrees to Hours := degree_value / 15.0 (360 degrees / 24 hours).
906 */
907 # define DEG2HH(d)       ((d) / DEGS_PER_HOUR)
908 /*!
909 *  Degrees to Minutes := degree_value * 60.0.
910 */
911 # define DEG2MM(d)       ((d) * (double)MINS_PER_HOUR)
912 /*!
913 *  Degrees to Seconds := degree_value * 3600.0 (60 minutes * 60 seconds).
914 */
915 # define DEG2SS(d)       ((d) * (double)SECS_PER_HOUR)
916 /*!
917 *  Days to Degrees := day_value * 360.0 (15 degrees * 24 hours [2 Pi]).
918 */
919 # define DAY2DEG(x)      ((x) * DEGS_PER_24_HOURS)
920 /*!
921 *  Hours to Degrees := hour_value * 15.0 (360 degrees / 24 hours).
922 */
923 # define HH2DEG(h)       ((h) * DEGS_PER_HOUR)
924 /*!
925 *  Minutes to Degrees := minute_value / 60.0.
926 */
927 # define MM2DEG(m)       ((m) / (double)MINS_PER_HOUR)
928 /*!
929 *  Seconds to Degrees := second_value / 3600.0 (60 minutes * 60 seconds).
930 */
931 # define SS2DEG(s)       ((s) / (double)SECS_PER_HOUR)
932 /*!
933 *  Hours to Days := hour_value / 24.0.
934 */
935 # define HH2DAY(h)       ((h) / (double)HOURS_PER_DAY)
936 /*!
937 *  Minutes to Days := minute_value / 1440.0 (24 hours * 60 minutes).
938 */
939 # define MM2DAY(m)       ((m) / (double)MINS_PER_DAY)
940 /*!
941 *  Seconds to Days := second_value / 86400.0 (24 hours * 3600 seconds).
942 */
943 # define SS2DAY(s)       ((s) / (double)SECS_PER_DAY)
944 /*!
945 *  Days to Hours := day_value * 24.0.
946 */
947 # define DAY2HH(x)       ((x) * (double)HOURS_PER_DAY)
948 /*!
949 *  Days to Minutes := day_value * 1440.0 (24 hours * 60 minutes).
950 */
951 # define DAY2MM(x)       ((x) * (double)MINS_PER_DAY)
952 /*!
953 *  Days to Seconds := day_value * 86400.0 (24 hours * 3600 seconds).
954 */
955 # define DAY2SS(x)       ((x) * (double)SECS_PER_DAY)
956 /*!
957 *  Hours and Minutes to Days := (hour_value * 60 + min_value) / 1440.0.
958 */
959 # define HHMM2DAY(h, m)  (((h) * MINS_PER_HOUR + (m)) / (double)MINS_PER_DAY)
960 /*!
961 *  Hours and Minutes to Hours := hour_value + min_value / 60.0.
962 */
963 # define HHMM2HH(h, m)   ((h) + (m) / (double)MINS_PER_HOUR)
964 /*!
965 *  Hours and Minutes to Minutes := hour_value * 60 + min_value.
966 */
967 # define HHMM2MM(h, m)   ((h) * MINS_PER_HOUR + (m))
968 /*!
969 *  Hours and Minutes to Seconds := hour_value * 3600 + min_value * 60.
970 */
971 # define HHMM2SS(h, m)   ((h) * SECS_PER_HOUR + (m) * SECS_PER_MIN)
972 /*!
973 *  Hours to Minutes.
974 */
975 # define HH2MM(x)        DEG2MM(x)
976 /*!
977 *  Hours to Seconds.
978 */
979 # define HH2SS(x)        DEG2SS(x)
980 /*!
981 *  Minutes to Hours.
982 */
983 # define MM2HH(x)        MM2DEG(x)
984 /*!
985 *  Minutes to Seconds.
986 */
987 # define MM2SS(x)        DEG2MM(x)
988 /*!
989 *  Seconds to Hours.
990 */
991 # define SS2HH(x)        SS2DEG(x)
992 /*!
993 *  Seconds to Minutes.
994 */
995 # define SS2MM(x)        MM2DEG(x)
996 
997 
998 
999 # ifdef CUT_LONGNAMES
1000 /*
1001 *  Cut resp., replace some long variable or function names to 6 significant
1002 *    places so ANY linker should be able to bind an executable file.
1003 */
1004 #  define bahai_hdy                           F_bhd
1005 #  define bahai_mth                           F_bmt
1006 #  define chinese_hdy                         F_chd
1007 #  define chinese_mth                         F_cmt
1008 #  define compare_d_m_name                    F_cdm
1009 #  define comparemode                         V_cm
1010 #  if !USE_RC
1011 #   define days_of_feb                         V_dof
1012 #  endif
1013 #  define decode_date_format                  F_ddf
1014 #  define decode_eclipse                      F_de
1015 #  define decode_format                       F_df
1016 #  define days_of_february                    F_dof
1017 #  if USE_HLS || USE_PAGER
1018 #   define get_termcap_hls                     F_ghl
1019 #   define get_termcap_scr_attrib              F_gsc
1020 #  endif
1021 #  define get_tty_hls                         F_gth
1022 #  if USE_PAGER
1023 #   define get_tty_scr_size                    F_gts
1024 #  endif
1025 #  define hd_title_flag                       V_htf
1026 #  define hd_title_shown                      V_hts
1027 #  define hebrew_hdy                          F_hhd
1028 #  define hebrew_mth                          F_hmt
1029 #  define hdy_chinese                         V_hc
1030 #  define hdy_chinese_flexible                V_hcf
1031 #  define hdy_christian                       V_hcr
1032 #  define hdy_japanese                        V_hj
1033 #  define hdy_japanese_flexible               V_hjf
1034 #  define hdy_orthodox_new                    V_hon
1035 #  define hdy_orthodox_old                    V_hoo
1036 #  define holiday                             V_hd
1037 #  define holiday_flag                        V_hf
1038 #  define holiday_name                        V_hn
1039 #  define holiday_prefix                      V_hp
1040 #  define is_3month_mode                      V_3m
1041 #  define is_3month_mode2                     V_3m2
1042 #  define is_ext_list                         V_iel
1043 #  define is_ext_range                        V_ier
1044 #  define is_ext_year                         V_iey
1045 #  define is_tty                              V_it
1046 #  define is_tty1                             V_it1
1047 #  define is_tty2                             V_it2
1048 #  define islamic_hdy                         F_ihd
1049 #  define islamic_mth                         F_imt
1050 #  define longopt                             V_lo
1051 #  define longopt_symbolic                    V_los
1052 #  define module_line                         V_mdl
1053 #  define module_name                         V_mdn
1054 #  define month_list                          V_ml
1055 #  define month_list_max                      V_mlm
1056 #  define month_name                          F_mn
1057 #  define month_set                           V_ms
1058 #  define moon_corrected_anomaly              V_mca
1059 #  define moon_corrected_longitude            V_mcl
1060 #  define moon_correction_equation_of_center  V_mce
1061 #  define moon_correction_term1               V_mc1
1062 #  define moon_correction_term2               V_mc2
1063 #  define moon_mean_anomaly                   V_mma
1064 #  define moon_mean_longitude                 V_mml
1065 #  define moon_present_age                    V_mpa
1066 #  define moon_present_longitude              V_mpl
1067 #  define moon_present_phase                  V_mpp
1068 #  define mth_chinese                         V_mtc
1069 #  define mth_chinese_flexible                V_mcf
1070 #  define mth_japanese                        V_mtj
1071 #  define mth_japanese_flexible               V_mjf
1072 #  define mth_old_armenian                    V_moa
1073 #  define mth_old_egyptian                    V_moe
1074 #  define my_argc                             V_mac
1075 #  define my_argc_max                         V_max
1076 #  define my_argv                             V_mav
1077 #  if !HAVE_LIBM
1078 #   define my_atan                             V_ma1
1079 #   define my_atan2                            V_ma2
1080 #  endif
1081 #  define my_help_head_text                   F_mhh
1082 #  define my_help_tail_text                   F_mht
1083 #  if !HAVE_LIBM
1084 #   define my_log                              V_mle
1085 #   define my_log10                            V_ml1
1086 #  endif
1087 #  define my_strstr                           F_mss
1088 #  define my_strcspn                          F_msp
1089 #  define my_strcasecmp                       F_msc
1090 #  define my_strncasecmp                      F_msn
1091 #  define orthodox_calendar                   V_oc
1092 #  define orthodox_easter                     F_oe
1093 #  define orthodox_hdy                        F_oh
1094 #  define persian_hdy                         F_phy
1095 #  define persian_mth                         F_pmt
1096 #  define print_all_holidays                  F_pah
1097 #  define print_calendar                      F_pc
1098 #  define print_highlighted_date              F_phd
1099 #  if USE_HLS
1100 #   define print_hls                           V_phl
1101 #  endif
1102 #  define print_text                          F_ptx
1103 #  define print_unhighlighted_date            F_pud
1104 #  define ptr_cc                              V_pcc
1105 #  define ptr_cc_holidays                     V_pcd
1106 #  define ptr_cc_id                           V_pid
1107 #  define ptr_info_date_format                V_pdf
1108 #  define short_day_name                      F_sdn
1109 #  define short_month_name                    F_smn
1110 #  define special_flag                        V_sf
1111 #  define special_vector                      V_sv
1112 #  define users_date_format                   V_ud
1113 #  define users_greg                          V_ug
1114 #  define use_day_suffix                      V_uds
1115 #  define use_day_zeroleaded                  V_udz
1116 # endif	/* CUT_LONGNAMES */
1117 
1118 
1119 
1120 /*
1121 *  Type definitions.
1122 */
1123 typedef unsigned char Uchar;
1124 
1125 typedef unsigned int Uint;
1126 
1127 # ifdef DJG
1128 typedef
1129 #  if defined(__STDC__) && __STDC__
1130   unsigned short int
1131 #  else				/* !__STDC__ */
1132   unsigned short
1133 #  endif			/* !__STDC__ */
1134   Usint;
1135 # endif	/* DJG */
1136 
1137 typedef
1138 # if defined(__STDC__) && __STDC__
1139   signed long int
1140 # else				/* !__STDC__ */
1141   long
1142 # endif				/* !__STDC__ */
1143   Slint;
1144 
1145 typedef
1146 # if defined(__STDC__) && __STDC__
1147   unsigned long int
1148 # else				/* !__STDC__ */
1149   unsigned long
1150 # endif				/* !__STDC__ */
1151   Ulint;
1152 
1153 typedef int Bool;
1154 
1155 /*!
1156 *  The quicksort (`qsort()') compare function type.
1157 */
1158 typedef int (*Cmp_func) __P_ ((const VOID_PTR, const VOID_PTR));
1159 
1160 # if HAVE_SIGNAL && (defined(SIGINT) || defined(SIGTERM) || defined(SIGHUP))
1161 /*!
1162 *  The signal (`signal()') handler function return type.
1163 */
1164 typedef RETSIGTYPE (*Sig_type) __P_ ((int));
1165 # endif
1166 
1167 /*!
1168 *  The long option record, see file `gcal.c' for a detailed description of it!
1169 */
1170 typedef struct long_option_type
1171 {
1172   int symbolic_name;
1173   char *long_name;
1174   char *short_name[LARG_MAX];
1175   int larg_mode;
1176   char *largs[LARG_MAX];
1177 }
1178 Lopt_struct;
1179 
1180 /*!
1181 *  The highlighting sequence record.
1182 */
1183 typedef struct hls_type
1184 {
1185   const char *seq;
1186   int len;
1187 }
1188 Hls_struct;
1189 
1190 /*!
1191 *  The list/range of months/years record.
1192 */
1193 typedef struct ml_type
1194 {
1195   int ml_month;
1196   int ml_year;
1197 }
1198 Ml_struct;
1199 
1200 /*!
1201 *  The supported date format record.
1202 */
1203 typedef struct date_format_type
1204 {
1205   /* Identifying text of the format. */
1206   char *df_id;
1207 
1208   /* Description text of the format. */
1209   char *df_info;
1210 
1211   /* The format text itself. */
1212   char *df_format;
1213 }
1214 Df_struct;
1215 
1216 
1217 /*!
1218 *  The Gregorian Reformation date record.
1219 */
1220 typedef struct greg_type
1221 {
1222   /* Year of Gregorian Reformation. */
1223   int year;
1224 
1225   /* Month of Gregorian Reformation. */
1226   int month;
1227 
1228   /* First missing day of Reformation period. */
1229   int first_day;
1230 
1231   /* Last missing day of Reformation period. */
1232   int last_day;
1233 }
1234 Greg_struct;
1235 
1236 /*!
1237 *  General purpose enumerations.
1238 */
1239 typedef enum compare_mode
1240 {
1241   DAy = 1,
1242 # if USE_RC
1243   DVar,
1244   TVar,
1245   EAster,
1246   TOday,
1247   WEek,
1248 # endif
1249   MOnth
1250 }
1251 Cmode_enum;
1252 
1253 typedef enum file_mode
1254 {
1255   REsponse = 1,
1256 # if USE_RC
1257   USr_include,
1258   SYs_include,
1259   REsource,
1260   HEre,
1261 # endif
1262 # ifdef GCAL_SHELL
1263   SCript,
1264 # endif
1265   COmmon
1266 }
1267 Fmode_enum;
1268 #endif /* __COMMON_H */
1269