More Solaris build fixes from Steve Christensen <steve AT
[cave.git] / src / common.h
blob65945b074525a3d0a41860520c1b6b7993d0daa3
1 /*
2 Copyright (C) 2001-2002 Ben Kibbey <bjk@luxsci.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #ifdef HAVE_REGEX_H
19 #include <sys/types.h>
20 #include <regex.h>
21 #endif
23 #ifdef HAVE_LIMITS_H
24 #include <limits.h>
25 #endif
27 #ifndef HAVE_CURSES_H
28 #ifdef HAVE_NCURSES_H
29 #include <ncurses.h>
30 #endif
31 #else
32 #include <curses.h>
33 #endif
35 #ifdef HAVE_PANEL_H
36 #include <panel.h>
37 #endif
39 #ifndef LINE_MAX
40 #ifdef _POSIX2_LINE_MAX
41 #define LINE_MAX _POSIX2_LINE_MAX
42 #elif defined(_POSIX_LINE_MAX)
43 #define LINE_MAX _POSIX_LINE_MAX
44 #else
45 #define LINE_MAX 2048
46 #endif
47 #endif
49 #define ESCAPE '\033'
50 #define BACKSPACE '\010'
52 #define COPYRIGHT "Copyright (C) 2001-2002 " PACKAGE_BUGREPORT "\nDistributed under the terms of the GNU General Public License version 2."
54 #define LOADING "Loading %s, please wait..."
55 #define DETECT "could not detect file type for %s"
56 #define NOTAFILE "%s is not a regular file"
57 #define VINFO ("[ " PACKAGE_STRING " ]")
58 #define ERROR "[ ERROR ]"
59 #define NOTICE "[ NOTICE ]"
60 #define INFO "[ FRAME INFORMATION ]"
61 #define HELP "[ HELP ]"
62 #define STEP "STEP"
63 #define PLAY "PLAY"
64 #define GOTO "Goto frame: "
65 #define CHGSSTIMEOUT "Seconds: "
66 #define SSTIMEOUT "Seconds: "
67 #define LOOP "LOOP"
68 #define ANYKEY "[ press any key to continue ]"
69 #define HELPTEXT "Press 'h' for help"
70 #define FATAL (message("[ FATAL ]", ANYKEY, "%s(%i): %s", __FILE__, \
71 __LINE__ - 1, strerror(errno)))
73 #define ARRCNT(x) (sizeof(x) / sizeof(x[0]))
74 #define CALCWIDTH(str) (strlen(str) + 4) /*
75 * 2 for box, 2 for padding
77 #define CALCHEIGHT() (4) /*
78 * 2 box, 2 padding, 1 prompt
80 #define CALCPOSY(y) ((y > LINES - 1) ? 0 : LINES / 2 - y / 2)
81 #define CALCPOSX(x) (COLS / 2 - x / 2)
82 #define CENTERX(x, str) (x / 2 - strlen(str) / 2)
84 typedef struct frames {
85 char *line;
86 struct frames *next;
87 } FRAME;
89 typedef struct scenes {
90 unsigned long frameid;
91 unsigned long delay;
92 unsigned long timepos;
93 unsigned rows;
94 FRAME *frame;
95 struct scenes *next;
96 struct scenes *prev;
97 } SCENE;
99 int message(const char *, const char *, const char *, ...);
100 void *Malloc(size_t);
101 void *Calloc(size_t num, size_t size);
102 char *sepfile(char *);
104 unsigned regexdelay, maxx, maxy;
105 unsigned long frames, delaylen;
106 regex_t regex;
107 WINDOW *statusw;
108 PANEL *statusp;
110 #ifdef WITH_DMALLOC
111 #include <dmalloc.h>
112 #endif