functions used by multiple boot loader plugins
More...
#include <stdio.h>
#include "../lickdir.h"
Go to the source code of this file.
|
|
#define | LOADER_DESC "LICK Boot Loader" |
| |
|
#define | START_LOADER_DESC "Start LICK Boot Loader" |
| |
|
#define | ID_LEN 37 |
| |
|
#define | COMMAND_BUFFER_LEN 1024 |
| |
|
| char * | advance_to_newline (char *s) |
| | returns a pointer to the next newline in a string More...
|
| |
| int | find_section (const char *haystack, const char *needle, char **start, char **end) |
| | find the extents of an INI section More...
|
| |
| char * | after_last_entry (char *sec, char *sec_end, const char *needle) |
| | find the line after the last needle in an INI section More...
|
| |
| char * | check_timeout (char *f, char *key, char *sep) |
| | check the timeout value of an INI file More...
|
| |
| int | backup_file (const char *f) |
| | create a backup of a file More...
|
| |
| int | get_id_from_command_range (const char *c, char *out, char *start, char *end) |
| | get an ID from a command, between two strings More...
|
| |
| int | get_id_from_command (const char *c, char *out) |
| | get an ID from a command More...
|
| |
| char * | get_bcdedit () |
| | get the path to bcdedit.exe More...
|
| |
| int | apply_fn_to_file (const char *file, char *(*fn)(char *, lickdir_t *), int backup, lickdir_t *lick) |
| | applies a function to a file More...
|
| |
| char * | find_drive_with_file (const char *suggested_drive, const char *file) |
| | find a drive which contains a file More...
|
| |
| char * | boot_drive (const char *boot_file) |
| | find the boot drive More...
|
| |
functions used by multiple boot loader plugins
| char* advance_to_newline |
( |
char * |
s | ) |
|
returns a pointer to the next newline in a string
- Parameters
-
| s | the beginning of the string to search in |
- Returns
- a pointer to the first newline, or to the string terminator
| char* after_last_entry |
( |
char * |
sec, |
|
|
char * |
sec_end, |
|
|
const char * |
needle |
|
) |
| |
find the line after the last needle in an INI section
sec and sec_end can be start and end from find_section
- Parameters
-
| sec | the beginning of the section |
| sec_end | the beginning of the next section |
| needle | a needle to determine if something is an entry |
| int apply_fn_to_file |
( |
const char * |
file, |
|
|
char *(*)(char *, lickdir_t *) |
fn, |
|
|
int |
backup, |
|
|
lickdir_t * |
lick |
|
) |
| |
applies a function to a file
Reads a file and applies the function to the contents. If the return value is a string, optionally backs up the file, then saves the return value in the file. This also ensures the file is saved with the same attributes.
- Parameters
-
| file | the file to apply the function on |
| fn | the function to apply |
| backup | to backup the file or not before saving |
| lick | the lick environment |
- Returns
- 1 on success
| int backup_file |
( |
const char * |
f | ) |
|
create a backup of a file
- Parameters
-
- Returns
- 1 on success
| char* boot_drive |
( |
const char * |
boot_file | ) |
|
find the boot drive
Finds the boot drive of the computer. To help in the search, a path of a file that is expected to be found on the root of the drive should be given.
- Parameters
-
| boot_file | a path to a file that is expected to be on the boot partition |
- Returns
- a path that must be freed using free on success, NULL on failure
| char* check_timeout |
( |
char * |
f, |
|
|
char * |
key, |
|
|
char * |
sep |
|
) |
| |
check the timeout value of an INI file
f must be allocated using malloc, and should contain the contents of an INI file. f will be freed in this function
- Parameters
-
| f | the file |
| key | the key of the timeout |
| sep | the string before the start of the timeout |
- Returns
- the INI file. Must be freed using free
| char* find_drive_with_file |
( |
const char * |
suggested_drive, |
|
|
const char * |
file |
|
) |
| |
find a drive which contains a file
Given a file, such as 'path/to/boot.ini', finds a drive where the file exists. If suggested_drive is given, that drive is checked first.
- Parameters
-
| suggested_drive | the drive to first look at. Can be NULL |
| file | the file to find |
- Returns
- a path that must be freed using free on success, NULL on failure
| int find_section |
( |
const char * |
haystack, |
|
|
const char * |
needle, |
|
|
char ** |
start, |
|
|
char ** |
end |
|
) |
| |
find the extents of an INI section
- Parameters
-
| [in] | haystack | the file |
| [in] | needle | the section header, including brackets |
| [out] | start | points to first character of section |
| [out] | end | points to first character of the next section, or '\0' |
- Returns
- 1 if the section is found, otherwise 0
get the path to bcdedit.exe
- Returns
- path to bcdedit.exe. Must be freed using free
| int get_id_from_command |
( |
const char * |
c, |
|
|
char * |
out |
|
) |
| |
get an ID from a command
- Parameters
-
| c | the command |
| out | the buffer to put the ID. Must be at least ID_LEN + 1 long |
- Returns
- 1 on success, otherwise 0
| int get_id_from_command_range |
( |
const char * |
c, |
|
|
char * |
out, |
|
|
char * |
start, |
|
|
char * |
end |
|
) |
| |
get an ID from a command, between two strings
Looks for end in the output, then looks backwards to find the start, then looks for the ID between these two points.
- Parameters
-
| c | the command |
| out | the buffer to put the ID. Must be at least ID_LEN + 1 long |
| start | the string to look after |
| end | the string to look before |
- Returns
- 1 on success, otherwise 0