/* * $Id$ * */ #include #include #include #include #include #include #include #include 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); }