1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* $Id$
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
extern int errno;
extern int yyparse();
#include "config.h"
#include "memedit_parser.h"
int debug = 0;
int readback = 1;
int mmaped_access = 0;
FILE *rl_instream;
int fd = -1;
void *mem = NULL;
int main (int argc, char *argv[])
{
struct arg_t arg;
struct arg_t *kom_arg = &arg;
/*
* genparse has changed it's api in v0.6.5.
* Version schema used here:
* xxxyyyzzz, maior/minor/micro, without leading zeros
*/
#if ((GENPARSE_VERS_MAGIC) <= (6005))
kom_arg = Cmdline(argc, argv);
#else
Cmdline (kom_arg, argc, argv);
#endif
printf("\nmemedit - quick change of memory content; version %s\n", PACKAGE_VERSION);
printf("Copyright (C) 2004-2011 by Pengutronix (kernel@pengutronix.de)\n\n");
if (kom_arg->v)
return EXIT_FAILURE;
printf("Please enter 'help' for a list of commands. \n\n");
debug = kom_arg->V;
readback = !kom_arg->r;
if (kom_arg->s)
{
rl_instream = fopen(kom_arg->s,"r");
if(rl_instream) {
printf("parsing %s\n",kom_arg->s);
yyparse ();
} else {
printf ("opening \"%s\" failed\n%s\n",
kom_arg->s, strerror(errno));
}
}
if (kom_arg->optind)
{
if(fd > 0) {
printf("file already opened - ignoring command line\n");
} else {
fd = open(argv[kom_arg->optind], O_RDWR | O_SYNC);
if (fd<0)
printf ("opening \"%s\" failed\n%s\n",
argv[kom_arg->optind], strerror(errno));
}
}
rl_instream = stdin;
yyparse ();
return EXIT_SUCCESS;
}
void yyerror (const char *s) /* Called by yyparse on error */
{
printf ("%s\n", s);
}
|