summaryrefslogtreecommitdiffstats
path: root/memedit.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2005-05-27 12:41:56 +0000
committerSascha Hauer <s.hauer@pengutronix.de>2005-05-27 12:41:56 +0000
commit990a6430b13f62a1971faf8db78d98a26703a36f (patch)
tree626c00a7bb74f7964cd84a4727088ef529c57725 /memedit.c
parent88228fb6a886abd17b6845e07060c93f359b62af (diff)
downloadmemedit-990a6430b13f62a1971faf8db78d98a26703a36f.tar.gz
memedit-990a6430b13f62a1971faf8db78d98a26703a36f.tar.xz
- use mmap instead of read/write
- add env command - add parsing of startup file
Diffstat (limited to 'memedit.c')
-rw-r--r--memedit.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/memedit.c b/memedit.c
index 5165f7d..ed797b4 100644
--- a/memedit.c
+++ b/memedit.c
@@ -8,6 +8,9 @@
#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();
@@ -17,7 +20,9 @@ extern int yyparse();
int debug = 0;
FILE *rl_instream;
-FILE *fhan = NULL;
+int fd = -1;
+
+void *mem = NULL;
int main (int argc, char *argv[])
{
@@ -26,7 +31,7 @@ int main (int argc, char *argv[])
kom_arg = Cmdline (argc, argv);
printf("\nmemedit - quick change of memory content\n");
- printf("Copyright (C) 2004 by Pengutronix\n");
+ printf("Copyright (C) 2004, 2005 by Pengutronix\n");
printf("Please enter 'help' for a list of commands. \n\n");
if (kom_arg->v)
@@ -36,12 +41,29 @@ int main (int argc, char *argv[])
}
debug = kom_arg->V;
-
+
+ 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)
{
- fhan = fopen(argv[kom_arg->optind], "r+");
- if (!fhan) printf ("opening \"%s\" failed\n%s\n",
- argv[kom_arg->optind], strerror(errno));
+ 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;