mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-26 06:33:43 +02:00
add "-c" option to direct run command.
This commit is contained in:
parent
f7998e35b8
commit
37327ca07f
@ -161,10 +161,13 @@ int command_handle(char *buf)
|
|||||||
{
|
{
|
||||||
int cmd = command_interpret(buf);
|
int cmd = command_interpret(buf);
|
||||||
|
|
||||||
if (!cmd) return -1;
|
if (!cmd)
|
||||||
|
return -1;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 11:
|
case 11:
|
||||||
return nprog();
|
nprog();
|
||||||
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
handle_help();
|
handle_help();
|
||||||
break;
|
break;
|
||||||
@ -173,12 +176,14 @@ int command_handle(char *buf)
|
|||||||
break;
|
break;
|
||||||
case 16: /* exit */
|
case 16: /* exit */
|
||||||
printf("\n exiting inflash software\n");
|
printf("\n exiting inflash software\n");
|
||||||
exit(EXIT_SUCCESS);
|
return -1; /* return -1 to break the main.c while
|
||||||
|
* then run usb_ingenic_cleanup*/
|
||||||
case 20:
|
case 20:
|
||||||
return boot(STAGE1_FILE_PATH, STAGE2_FILE_PATH);
|
boot(STAGE1_FILE_PATH, STAGE2_FILE_PATH);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
printf("\n Command not support!");
|
printf("\n Command not support!");
|
||||||
return -1;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -41,6 +41,7 @@ static void help(void)
|
|||||||
printf("Usage: inflash [options] ...(must run as root)\n"
|
printf("Usage: inflash [options] ...(must run as root)\n"
|
||||||
" -h --help\t\t\tPrint this help message\n"
|
" -h --help\t\t\tPrint this help message\n"
|
||||||
" -v --version\t\t\tPrint the version number\n"
|
" -v --version\t\t\tPrint the version number\n"
|
||||||
|
" -c --command\t\t\tDirect run the command\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ static void print_version(void)
|
|||||||
static struct option opts[] = {
|
static struct option opts[] = {
|
||||||
{ "help", 0, 0, 'h' },
|
{ "help", 0, 0, 'h' },
|
||||||
{ "version", 0, 0, 'v' },
|
{ "version", 0, 0, 'v' },
|
||||||
|
{ "command", 1, 0, 'c' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,9 +62,13 @@ int main(int argc, char **argv)
|
|||||||
printf("inflash - (C) 2009\n"
|
printf("inflash - (C) 2009\n"
|
||||||
"This program is Free Software and has ABSOLUTELY NO WARRANTY\n\n");
|
"This program is Free Software and has ABSOLUTELY NO WARRANTY\n\n");
|
||||||
|
|
||||||
|
int command = 0;
|
||||||
|
char com_buf[256];
|
||||||
|
memset(com_buf, '\n', 256);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int c, option_index = 0;
|
int c, option_index = 0;
|
||||||
c = getopt_long(argc, argv, "hv", opts,
|
c = getopt_long(argc, argv, "hvc:", opts,
|
||||||
&option_index);
|
&option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
@ -74,12 +80,19 @@ int main(int argc, char **argv)
|
|||||||
case 'v':
|
case 'v':
|
||||||
print_version();
|
print_version();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
case 'c':
|
||||||
|
command = 1;
|
||||||
|
strcpy(com_buf, optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
help();
|
help();
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("\n Welcome!"
|
||||||
|
"\n Ingenic Tools Software!");
|
||||||
|
|
||||||
if ((getuid()) || (getgid())) {
|
if ((getuid()) || (getgid())) {
|
||||||
fprintf(stderr, "Error - you must be root to run '%s'\n", argv[0]);
|
fprintf(stderr, "Error - you must be root to run '%s'\n", argv[0]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -91,17 +104,21 @@ int main(int argc, char **argv)
|
|||||||
if (parse_configure(&hand, CONFIG_FILE_PATH) < 1)
|
if (parse_configure(&hand, CONFIG_FILE_PATH) < 1)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
char com_buf[256];
|
if (command) {
|
||||||
printf("\n Welcome!");
|
command_handle(com_buf);
|
||||||
printf("\n Ingenic Tools Software!");
|
printf("\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
printf("\n inflash :> ");
|
printf("\n inflash :> ");
|
||||||
if (!command_input(com_buf))
|
if (!command_input(com_buf))
|
||||||
continue;
|
continue;
|
||||||
command_handle(com_buf);
|
if (command_handle(com_buf) == -1 )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
usb_ingenic_cleanup(&ingenic_dev);
|
usb_ingenic_cleanup(&ingenic_dev);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user