print: Specifier for printing URIs
This commit is contained in:
parent
a1bcf3c09b
commit
71eb143611
|
@ -192,6 +192,25 @@ void vprint(const char *fmt, va_list args) {
|
||||||
char c = (char)va_arg(args, int);
|
char c = (char)va_arg(args, int);
|
||||||
prn_char(print_buf, &print_buf_i, c); }
|
prn_char(print_buf, &print_buf_i, c); }
|
||||||
break;
|
break;
|
||||||
|
case '#': {
|
||||||
|
bool printed = false;
|
||||||
|
char *str = (char *)va_arg(args, const char *);
|
||||||
|
for (int i = (int)strlen(str) - 1; i >= 0; i--) {
|
||||||
|
if (str[i] != '#') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
prn_nstr(print_buf, &print_buf_i, str, i);
|
||||||
|
printed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!printed) {
|
||||||
|
prn_str(print_buf, &print_buf_i, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
prn_char(print_buf, &print_buf_i, '?');
|
prn_char(print_buf, &print_buf_i, '?');
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -194,7 +194,7 @@ struct file_handle *uri_open(char *uri) {
|
||||||
uri_resolve(uri, &resource, &root, &path);
|
uri_resolve(uri, &resource, &root, &path);
|
||||||
|
|
||||||
if (resource == NULL) {
|
if (resource == NULL) {
|
||||||
panic(true, "No resource specified for URI `%s`.", uri);
|
panic(true, "No resource specified for URI `%#`.", uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compressed = false;
|
bool compressed = false;
|
||||||
|
|
|
@ -281,11 +281,11 @@ noreturn void limine_load(char *config, char *cmdline) {
|
||||||
if (kernel_path == NULL)
|
if (kernel_path == NULL)
|
||||||
panic(true, "limine: KERNEL_PATH not specified");
|
panic(true, "limine: KERNEL_PATH not specified");
|
||||||
|
|
||||||
print("limine: Loading kernel `%s`...\n", kernel_path);
|
print("limine: Loading kernel `%#`...\n", kernel_path);
|
||||||
|
|
||||||
struct file_handle *kernel_file;
|
struct file_handle *kernel_file;
|
||||||
if ((kernel_file = uri_open(kernel_path)) == NULL)
|
if ((kernel_file = uri_open(kernel_path)) == NULL)
|
||||||
panic(true, "limine: Failed to open kernel with path `%s`. Is the path correct?", kernel_path);
|
panic(true, "limine: Failed to open kernel with path `%#`. Is the path correct?", kernel_path);
|
||||||
|
|
||||||
uint8_t *kernel = freadall(kernel_file, MEMMAP_BOOTLOADER_RECLAIMABLE);
|
uint8_t *kernel = freadall(kernel_file, MEMMAP_BOOTLOADER_RECLAIMABLE);
|
||||||
|
|
||||||
|
@ -632,11 +632,11 @@ FEAT_START
|
||||||
module_cmdline = "";
|
module_cmdline = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
print("limine: Loading module `%s`...\n", module_path);
|
print("limine: Loading module `%#`...\n", module_path);
|
||||||
|
|
||||||
struct file_handle *f;
|
struct file_handle *f;
|
||||||
if ((f = uri_open(module_path)) == NULL)
|
if ((f = uri_open(module_path)) == NULL)
|
||||||
panic(true, "limine: Failed to open module with path `%s`. Is the path correct?", module_path);
|
panic(true, "limine: Failed to open module with path `%#`. Is the path correct?", module_path);
|
||||||
|
|
||||||
struct limine_file *l = &modules[i];
|
struct limine_file *l = &modules[i];
|
||||||
*l = get_file(f, module_cmdline);
|
*l = get_file(f, module_cmdline);
|
||||||
|
|
|
@ -357,10 +357,10 @@ noreturn void linux_load(char *config, char *cmdline) {
|
||||||
if (kernel_path == NULL)
|
if (kernel_path == NULL)
|
||||||
panic(true, "linux: KERNEL_PATH not specified");
|
panic(true, "linux: KERNEL_PATH not specified");
|
||||||
|
|
||||||
print("linux: Loading kernel `%s`...\n", kernel_path);
|
print("linux: Loading kernel `%#`...\n", kernel_path);
|
||||||
|
|
||||||
if ((kernel_file = uri_open(kernel_path)) == NULL)
|
if ((kernel_file = uri_open(kernel_path)) == NULL)
|
||||||
panic(true, "linux: Failed to open kernel with path `%s`. Is the path correct?", kernel_path);
|
panic(true, "linux: Failed to open kernel with path `%#`. Is the path correct?", kernel_path);
|
||||||
|
|
||||||
uint32_t signature;
|
uint32_t signature;
|
||||||
fread(kernel_file, &signature, 0x202, sizeof(uint32_t));
|
fread(kernel_file, &signature, 0x202, sizeof(uint32_t));
|
||||||
|
@ -475,11 +475,11 @@ noreturn void linux_load(char *config, char *cmdline) {
|
||||||
if (module_path == NULL)
|
if (module_path == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
print("linux: Loading module `%s`...\n", module_path);
|
print("linux: Loading module `%#`...\n", module_path);
|
||||||
|
|
||||||
struct file_handle *module;
|
struct file_handle *module;
|
||||||
if ((module = uri_open(module_path)) == NULL)
|
if ((module = uri_open(module_path)) == NULL)
|
||||||
panic(true, "linux: Could not open `%s`", module_path);
|
panic(true, "linux: Could not open `%#`", module_path);
|
||||||
|
|
||||||
fread(module, (void *)_modules_mem_base, 0, module->size);
|
fread(module, (void *)_modules_mem_base, 0, module->size);
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,10 @@ noreturn void multiboot1_load(char *config, char *cmdline) {
|
||||||
if (kernel_path == NULL)
|
if (kernel_path == NULL)
|
||||||
panic(true, "multiboot1: KERNEL_PATH not specified");
|
panic(true, "multiboot1: KERNEL_PATH not specified");
|
||||||
|
|
||||||
print("multiboot1: Loading kernel `%s`...\n", kernel_path);
|
print("multiboot1: Loading kernel `%#`...\n", kernel_path);
|
||||||
|
|
||||||
if ((kernel_file = uri_open(kernel_path)) == NULL)
|
if ((kernel_file = uri_open(kernel_path)) == NULL)
|
||||||
panic(true, "multiboot1: Failed to open kernel with path `%s`. Is the path correct?", kernel_path);
|
panic(true, "multiboot1: Failed to open kernel with path `%#`. Is the path correct?", kernel_path);
|
||||||
|
|
||||||
uint8_t *kernel = freadall(kernel_file, MEMMAP_KERNEL_AND_MODULES);
|
uint8_t *kernel = freadall(kernel_file, MEMMAP_KERNEL_AND_MODULES);
|
||||||
|
|
||||||
|
@ -248,11 +248,11 @@ noreturn void multiboot1_load(char *config, char *cmdline) {
|
||||||
if (module_path == NULL)
|
if (module_path == NULL)
|
||||||
panic(true, "multiboot1: Module disappeared unexpectedly");
|
panic(true, "multiboot1: Module disappeared unexpectedly");
|
||||||
|
|
||||||
print("multiboot1: Loading module `%s`...\n", module_path);
|
print("multiboot1: Loading module `%#`...\n", module_path);
|
||||||
|
|
||||||
struct file_handle *f;
|
struct file_handle *f;
|
||||||
if ((f = uri_open(module_path)) == NULL)
|
if ((f = uri_open(module_path)) == NULL)
|
||||||
panic(true, "multiboot1: Failed to open module with path `%s`. Is the path correct?", module_path);
|
panic(true, "multiboot1: Failed to open module with path `%#`. Is the path correct?", module_path);
|
||||||
|
|
||||||
char *module_cmdline = conf_tuple.value2;
|
char *module_cmdline = conf_tuple.value2;
|
||||||
if (module_cmdline == NULL) {
|
if (module_cmdline == NULL) {
|
||||||
|
|
|
@ -70,10 +70,10 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
|
||||||
if (kernel_path == NULL)
|
if (kernel_path == NULL)
|
||||||
panic(true, "multiboot2: KERNEL_PATH not specified");
|
panic(true, "multiboot2: KERNEL_PATH not specified");
|
||||||
|
|
||||||
print("multiboot2: Loading kernel `%s`...\n", kernel_path);
|
print("multiboot2: Loading kernel `%#`...\n", kernel_path);
|
||||||
|
|
||||||
if ((kernel_file = uri_open(kernel_path)) == NULL)
|
if ((kernel_file = uri_open(kernel_path)) == NULL)
|
||||||
panic(true, "multiboot2: Failed to open kernel with path `%s`. Is the path correct?", kernel_path);
|
panic(true, "multiboot2: Failed to open kernel with path `%#`. Is the path correct?", kernel_path);
|
||||||
|
|
||||||
uint8_t *kernel = freadall(kernel_file, MEMMAP_KERNEL_AND_MODULES);
|
uint8_t *kernel = freadall(kernel_file, MEMMAP_KERNEL_AND_MODULES);
|
||||||
|
|
||||||
|
@ -397,11 +397,11 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
|
||||||
char *module_path = conf_tuple.value1;
|
char *module_path = conf_tuple.value1;
|
||||||
if (!module_path) panic(true, "multiboot2: Module disappeared unexpectedly");
|
if (!module_path) panic(true, "multiboot2: Module disappeared unexpectedly");
|
||||||
|
|
||||||
print("multiboot2: Loading module `%s`...\n", module_path);
|
print("multiboot2: Loading module `%#`...\n", module_path);
|
||||||
|
|
||||||
struct file_handle *f;
|
struct file_handle *f;
|
||||||
if ((f = uri_open(module_path)) == NULL)
|
if ((f = uri_open(module_path)) == NULL)
|
||||||
panic(true, "multiboot2: Failed to open module with path `%s`. Is the path correct?", module_path);
|
panic(true, "multiboot2: Failed to open module with path `%#`. Is the path correct?", module_path);
|
||||||
|
|
||||||
// Module commandline can be null, so we guard against that and make the
|
// Module commandline can be null, so we guard against that and make the
|
||||||
// string "".
|
// string "".
|
||||||
|
|
Loading…
Reference in New Issue