1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: kstddef.h,v 1.6 2000/05/03 19:51:41 kevin Exp $
7 ** Revision 1.6 2000/05/03 19:51:41 kevin
8 ** function renaming for phantoms and phantom elements
10 ** Revision 1.5 2000/05/02 20:00:25 kevin
11 ** *** empty log message ***
13 ** Revision 1.4 2000/04/28 18:00:55 kevin
14 ** remove unused files
16 ** Revision 1.3 2000/04/28 17:38:16 kevin
17 ** Removed unused files
19 ** Revision 1.2 2000/04/28 14:14:16 kevin
20 ** *** empty log message ***
23 ** This program is free software; you can redistribute it and/or modify
24 ** it under the terms of the GNU General Public License (version 2) as
25 ** published by the Free Software Foundation.
27 ** This program is distributed in the hope that it will be useful,
28 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
29 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 ** GNU General Public License for more details.
32 ** You should have received a copy of the GNU General Public License
33 ** along with this program; if not, write to the Free Software
34 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 ******************************************************************************/
36 /******************************************************************************
41 * Author: Kevin Rosenberg
42 * Purpose: Header file containing KRL standard C definitions
43 * Date Started: Dec. 83
46 * Header file contains KRL standard C definitions
50 *****************************************************************************/
62 #define STR_MAX_LEN 255
63 #define STR_SIZE STR_MAX_LEN+1
66 typedef signed int bool; /* Boolean variable type */
69 typedef unsigned char string[STR_SIZE];
71 #define UNSIGNLONG unsigned long int
72 #define UNSIGNCHAR unsigned char
83 /*----------------------------------------------------------------------*/
85 #define SHOW(var, fmt) fprintf (stderr, "var = fmt\n", var)
87 /*----------------------------------------------------------------------*/
89 #define INTERNAL_FUNC static
90 #define INTERNAL_VAR static
92 /*----------------------------------------------------------------------*/
98 #define ETX 26 /* end of text signal for PC-DOS */
100 /*----------------------------------------------------------------------*/
102 #define MAXPATHNAME 65 /* max length of pathname + 1 */
103 #define MAXFILENAME 13 /* rootname(8) + '.'(1) + extension(3) + EOS */
104 #define MAXROOTNAME 8
106 #define MAXFULLNAME MAXPATHNAME + MAXFILENAME
108 /*----------------------------------------------------------------------*/
110 #define ABS(x) ((x) < 0 ? -(x) : (x))
111 #define SQR(x) ((x) * (x))
114 #define MAX(a,b) ((a) > (b) ? (a) : (b))
117 #define MIN(a,b) ((a) <= (b) ? (a) : (b))
119 #define ISWAP(a,b) {int i; i = a; a = b; b = i;}
121 #define CLIP(n,lb,ub) if (n < lb) n = lb; else if (n > ub) n = ub
122 #define FOREVER for (;;)
123 #define STR_EQUAL(s1,s2) (strcmp (s1, s2) == 0)
125 /*----------------------------------------------------------------------*/
128 int hour, minute, second, hs;
132 int year, month, date, dow;
140 typedef struct time_st TIME;
141 typedef struct date_st DATE;
142 typedef struct timedate_st TIMEDATE;
144 /*----------------------------------------------------------------------*/
146 #define ERR_WARNING 0
150 /*----------------------------------------------------------------------*/
152 /* codes for open command */
155 #define OPEN_RDONLY 0x8000 /* Lattice codes for binary i/o */
156 #define OPEN_WRONLY 0x8001
157 #define OPEN_RDWR 0x8002
159 #define OPEN_RDONLY O_RDONLY /* other system use standard codes */
160 #define OPEN_WRONLY O_WRONLY /* for binary */
161 #define OPEN_RDWR O_RDWR
163 #define OPEN_RDONLY 0 /* other system use standard codes */
164 #define OPEN_WRONLY 1 /* for binary */
168 /*----------------------------------------------------------------------*/
170 /* codes for input (inp_*) routines */
175 #define INP_NEITHER 'b'
176 #define INP_RETURN 'r'
177 #define INP_BREAK 0x8000
184 #define S_IWRITE S_IWUSR
188 float *alloc_float(int n);
189 double *alloc_double(int n);
190 int *alloc_int(int n);
192 int file_exists(const char *fname);
194 char *kbasename(const char *filename);
196 int iclip(int n, int lb, int ub);
198 char *str_skip_head(const char *str, const char *charlist);
200 char *str_lower(char *s);
202 char *str_wrm_tail(char *str);
203 char *str_rm_tail(char *str, const char *charlist);
205 char *str_save(const char *s);
207 char *str_upper(char *str);
209 void *sys_alloc(const int nbytes, const char *name);
211 void sys_error(int severity, const char *msg, ...);
212 void sys_verror(int severity, const char *msg, va_list arg);
213 void sys_error_level(int severity);
215 FILE *sys_fopen(const char *filename, const char *mode, const char *progname);
217 void sys_free(void *ptr, const char *name);
219 DATE *td_get_date(DATE *d);
220 TIME *td_get_time(TIME *t);
221 double td_current_sec(void);
222 double td_time_to_sec(TIME *t);
223 TIME *td_time_sub(const TIME *t1, const TIME *t2, TIME *tdiff);
224 TIME *td_time_add(const TIME *t1, const TIME *t2, TIME *tsum);
225 TIME *td_time_copy(TIME *to, const TIME *from);
226 TIME *td_time_norm(TIME *t);
227 void td_get_tmdt(TIMEDATE *td);
228 const char *td_str_tmdt(const TIMEDATE *td);
229 const char *td_str_time(const TIME *t);
230 const char *td_str_stime(const TIME *t);
231 const char *td_str_date(const DATE *d);
232 char *td_str_cdate(DATE *d);
233 char *td_month_name(int n);
234 char *td_day_name(int n);