mirror of
https://github.com/vivier/EMILE.git
synced 2024-09-08 19:54:38 +00:00
use emile_second_set_param() and emile_second_get_param()
This commit is contained in:
parent
aa95b99d93
commit
5d238a87d0
@ -39,9 +39,6 @@ int set_cmdline(char* image, char* cmdline)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
int drive, second, size;
|
|
||||||
char *configuration;
|
|
||||||
off_t offset;
|
|
||||||
|
|
||||||
fd = open(image, O_RDWR);
|
fd = open(image, O_RDWR);
|
||||||
|
|
||||||
@ -51,38 +48,7 @@ int set_cmdline(char* image, char* cmdline)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* can work on an image or directly on second level file */
|
ret = emile_second_set_param(fd, NULL, cmdline, NULL);
|
||||||
|
|
||||||
ret = emile_first_get_param(fd, &drive, &second, &size);
|
|
||||||
if (ret == EEMILE_UNKNOWN_FIRST)
|
|
||||||
{
|
|
||||||
/* should be a second level file */
|
|
||||||
|
|
||||||
ret = lseek(fd, 0, SEEK_SET);
|
|
||||||
if (ret == -1)
|
|
||||||
{
|
|
||||||
perror("Cannot go to buffer offset");
|
|
||||||
close(fd);
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
offset = lseek(fd, 0, SEEK_CUR);
|
|
||||||
|
|
||||||
configuration = emile_second_get_configuration(fd);
|
|
||||||
if (configuration == NULL)
|
|
||||||
return 4;
|
|
||||||
|
|
||||||
emile_second_set_property(configuration, "parameters", cmdline);
|
|
||||||
|
|
||||||
ret = lseek(fd, offset, SEEK_SET);
|
|
||||||
if (ret == -1)
|
|
||||||
return 5;
|
|
||||||
|
|
||||||
ret = emile_second_set_configuration(fd, configuration);
|
|
||||||
if (ret != 0)
|
|
||||||
return 6;
|
|
||||||
|
|
||||||
free(configuration);
|
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@ -94,8 +60,6 @@ int get_cmdline(char* image)
|
|||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
char cmdline[255];
|
char cmdline[255];
|
||||||
char *configuration;
|
|
||||||
int drive, second, size;
|
|
||||||
|
|
||||||
fd = open(image, O_RDONLY);
|
fd = open(image, O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
@ -104,34 +68,12 @@ int get_cmdline(char* image)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* can work on an image or directly on second level file */
|
ret = emile_second_get_param(fd, NULL, cmdline, NULL);
|
||||||
|
|
||||||
ret = emile_first_get_param(fd, &drive, &second, &size);
|
if (cmdline[0])
|
||||||
if (ret == EEMILE_UNKNOWN_FIRST)
|
|
||||||
{
|
|
||||||
/* should be a second level file */
|
|
||||||
|
|
||||||
ret = lseek(fd, 0, SEEK_SET);
|
|
||||||
if (ret == -1)
|
|
||||||
{
|
|
||||||
perror("Cannot go to buffer offset");
|
|
||||||
close(fd);
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configuration = emile_second_get_configuration(fd);
|
|
||||||
if (configuration == NULL)
|
|
||||||
return 4;
|
|
||||||
|
|
||||||
ret = emile_second_get_property(configuration, "parameters", cmdline);
|
|
||||||
|
|
||||||
if (ret != 0)
|
|
||||||
fprintf(stderr, "No command line found\n");
|
|
||||||
else
|
|
||||||
printf("Current command line: \"%s\"\n", cmdline);
|
printf("Current command line: \"%s\"\n", cmdline);
|
||||||
|
else
|
||||||
free(configuration);
|
fprintf(stderr, "No command line found\n");
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user