25 |
|
#include <signal.h> |
26 |
|
#include <ctype.h> |
27 |
|
|
28 |
< |
#ifdef HAVE_READLINE_READLINE_H |
28 |
> |
#if defined(HAVE_READLINE_H) |
29 |
> |
extern "C" { |
30 |
> |
#include <readline.h> |
31 |
> |
} |
32 |
> |
#elif defined(HAVE_READLINE_READLINE_H) |
33 |
|
extern "C" { |
34 |
|
#include <readline/readline.h> |
35 |
|
} |
36 |
|
#endif |
37 |
|
|
38 |
< |
#ifdef HAVE_READLINE_HISTORY_H |
38 |
> |
#if defined(HAVE_HISTORY_H) |
39 |
> |
extern "C" { |
40 |
> |
#include <history.h> |
41 |
> |
} |
42 |
> |
#elif defined(HAVE_READLINE_HISTORY_H) |
43 |
|
extern "C" { |
44 |
|
#include <readline/history.h> |
45 |
|
} |
48 |
|
#include "mon.h" |
49 |
|
#include "mon_cmd.h" |
50 |
|
|
51 |
+ |
#ifndef VERSION |
52 |
+ |
#define VERSION "2" |
53 |
+ |
#endif |
54 |
+ |
|
55 |
|
|
56 |
|
// Buffer we're operating on |
57 |
|
bool mon_use_real_mem = false; |
1133 |
|
monout = stdout; |
1134 |
|
monerr = stdout; |
1135 |
|
|
1136 |
< |
if (argc) { |
1137 |
< |
// Access real memory if mon was started as "rmon" |
1138 |
< |
char *prgname = argv[0]; |
1139 |
< |
char *lastslash; |
1140 |
< |
if ((lastslash = strrchr(prgname, '/')) != NULL) |
1141 |
< |
prgname = lastslash + 1; |
1142 |
< |
if (strcmp(prgname, "rmon") == 0) |
1136 |
> |
// Make argc/argv point to the actual arguments |
1137 |
> |
if (argc) |
1138 |
> |
argc--; argv++; |
1139 |
> |
|
1140 |
> |
// Parse arguments |
1141 |
> |
mon_macos_mode = false; |
1142 |
> |
mon_use_real_mem = false; |
1143 |
> |
while (argc > 0) { |
1144 |
> |
if (strcmp(argv[0], "-m") == 0) |
1145 |
> |
mon_macos_mode = true; |
1146 |
> |
else if (strcmp(argv[0], "-r") == 0) |
1147 |
|
mon_use_real_mem = true; |
1148 |
< |
|
1149 |
< |
// Make argc/argv point to the actual arguments |
1150 |
< |
argc--; |
1135 |
< |
argv++; |
1136 |
< |
interactive = (argc == 0); |
1148 |
> |
else |
1149 |
> |
break; |
1150 |
> |
argc--; argv++; |
1151 |
|
} |
1152 |
+ |
interactive = (argc == 0); |
1153 |
|
|
1154 |
|
// Set up memory access functions if not supplied by the user |
1155 |
|
if (mon_read_byte == NULL) { |
1173 |
|
// Print banner |
1174 |
|
if (interactive) |
1175 |
|
fprintf(monerr, "\n *** mon V" VERSION " by Christian Bauer and Marc Hellwig ***\n" |
1176 |
< |
" *** Press 'h' for help ***\n\n"); |
1176 |
> |
" *** Press 'h' for help ***\n\n"); |
1177 |
|
} |
1178 |
|
|
1179 |
|
init_abort(); |