(debug): New.
(main): Set it on -d. (oops, CANT_HAPPEN): New.
This commit is contained in:
parent
f1edf905e9
commit
47c8a32ae3
4 changed files with 29 additions and 1 deletions
|
@ -123,6 +123,15 @@ typedef short coord;
|
||||||
#define hours(x) (60*60*(x))
|
#define hours(x) (60*60*(x))
|
||||||
#define days(x) (60*60*24*(x))
|
#define days(x) (60*60*24*(x))
|
||||||
|
|
||||||
|
extern int debug;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If EXPR is true, an internal error occured.
|
||||||
|
* Return EXPR != 0.
|
||||||
|
* Usage: if (CANT_HAPPEN(...)) recovery_code();
|
||||||
|
*/
|
||||||
|
#define CANT_HAPPEN(expr) ((expr) ? oops(#expr, __FILE__, __LINE__) : 0)
|
||||||
|
|
||||||
typedef int (*qsort_func_t) (const void *, const void *);
|
typedef int (*qsort_func_t) (const void *, const void *);
|
||||||
|
|
||||||
/* return codes from command routines */
|
/* return codes from command routines */
|
||||||
|
|
|
@ -128,6 +128,7 @@ extern int has_helpful_engineer(coord x, coord y, natid cn);
|
||||||
/* log.c */
|
/* log.c */
|
||||||
extern void loginit(s_char *);
|
extern void loginit(s_char *);
|
||||||
extern void logerror(s_char *, ...) ATTRIBUTE((format (printf, 1, 2)));
|
extern void logerror(s_char *, ...) ATTRIBUTE((format (printf, 1, 2)));
|
||||||
|
extern int oops(char *, char *, int);
|
||||||
/* maps.c */
|
/* maps.c */
|
||||||
extern int draw_map(int, s_char, int, struct nstr_sect *, int);
|
extern int draw_map(int, s_char, int, struct nstr_sect *, int);
|
||||||
extern int unit_map(int, int, struct nstr_sect *, s_char *);
|
extern int unit_map(int, int, struct nstr_sect *, s_char *);
|
||||||
|
|
|
@ -99,3 +99,15 @@ logerror(s_char *format, ...)
|
||||||
#endif
|
#endif
|
||||||
va_end(list);
|
va_end(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Log internal error MSG occured in FILE:LINE.
|
||||||
|
* If debugging, call abort(), else return 1.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
oops(char *msg, char *file, int line)
|
||||||
|
{
|
||||||
|
logerror("Oops: %s in %s:%d\n", msg, file, line);
|
||||||
|
if (debug) abort();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
|
@ -80,13 +80,19 @@ static void loc_NTTerm(void);
|
||||||
static int mainpid = 0;
|
static int mainpid = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Debugging?
|
||||||
|
* If yes, don't fork into background, don't catch certain signals,
|
||||||
|
* call abort() on internal error.
|
||||||
|
*/
|
||||||
|
int debug = 0;
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
int hour[2];
|
int hour[2];
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
int debug = 0;
|
|
||||||
int op;
|
int op;
|
||||||
char *config_file = NULL;
|
char *config_file = NULL;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue