From 78f771c881f9ef27ca4a35b3fc9efc407edba665 Mon Sep 17 00:00:00 2001 From: Pierre-Alexandre Meyer Date: Sat, 31 Oct 2009 22:32:26 -0700 Subject: [PATCH] hdt: change remaining printf to more_printf (CLI) A lot of places still had printf() instead of more_printf(). This patch does a bulk update and add missing reset_more_printf(), used to reset the pager counter between each command call. This also changes the more_printf() routine to delete the "--More--" line while scrolling. Signed-off-by: Pierre-Alexandre Meyer --- com32/hdt/hdt-cli-disk.c | 16 ++-- com32/hdt/hdt-cli-dmi.c | 223 ++++++++++++++++++++++--------------------- com32/hdt/hdt-cli-hdt.c | 49 +++++----- com32/hdt/hdt-cli-kernel.c | 8 +- com32/hdt/hdt-cli-memory.c | 2 +- com32/hdt/hdt-cli-pci.c | 55 +++++------ com32/hdt/hdt-cli-pxe.c | 17 ++-- com32/hdt/hdt-cli-syslinux.c | 13 +-- com32/hdt/hdt-cli-vesa.c | 29 +++--- com32/hdt/hdt-cli-vpd.c | 4 +- com32/hdt/hdt-common.h | 11 ++- 11 files changed, 226 insertions(+), 201 deletions(-) diff --git a/com32/hdt/hdt-cli-disk.c b/com32/hdt/hdt-cli-disk.c index 48f1901..7f6b00d 100644 --- a/com32/hdt/hdt-cli-disk.c +++ b/com32/hdt/hdt-cli-disk.c @@ -62,6 +62,8 @@ static void show_partition_information(struct driveinfo *drive_info, int i = nb_partitions_seen; + reset_more_printf(); + start = partition_offset; end = start + ptab->length - 1; @@ -114,6 +116,8 @@ void main_show_disk(int argc, char **argv, char mbr_name[50]; detect_disks(hardware); + reset_more_printf(); + if (!hardware->disk_info[i].cbios) return; /* Invalid geometry */ @@ -157,14 +161,14 @@ void main_show_disks(int argc __unused, char **argv __unused, reset_more_printf(); detect_disks(hardware); - int first_one = 0; + int first_one = 0; for (int drive = 0x80; drive < 0xff; drive++) { if (hardware->disk_info[drive - 0x80].cbios) { - if (!first_one) { - first_one = 1; - } else { - pause_printf(); - } + if (!first_one) { + first_one = 1; + } else { + pause_printf(); + } char buf[5] = ""; sprintf(buf, "0x%x", drive); char *argv[1] = { buf }; diff --git a/com32/hdt/hdt-cli-dmi.c b/com32/hdt/hdt-cli-dmi.c index f40f600..194cded 100644 --- a/com32/hdt/hdt-cli-dmi.c +++ b/com32/hdt/hdt-cli-dmi.c @@ -38,48 +38,49 @@ static void show_dmi_modules(int argc __unused, char** argv __unused, struct s_hardware *hardware) { char available_dmi_commands[1024]; + reset_more_printf(); memset(available_dmi_commands, 0, sizeof(available_dmi_commands)); - printf("Available DMI modules on your system:\n"); + more_printf("Available DMI modules on your system:\n"); if (hardware->dmi.base_board.filled == true) - printf("\t%s\n", CLI_DMI_BASE_BOARD); + more_printf("\t%s\n", CLI_DMI_BASE_BOARD); if (hardware->dmi.battery.filled == true) - printf("\t%s\n", CLI_DMI_BATTERY); + more_printf("\t%s\n", CLI_DMI_BATTERY); if (hardware->dmi.bios.filled == true) - printf("\t%s\n", CLI_DMI_BIOS); + more_printf("\t%s\n", CLI_DMI_BIOS); if (hardware->dmi.chassis.filled == true) - printf("\t%s\n", CLI_DMI_CHASSIS); + more_printf("\t%s\n", CLI_DMI_CHASSIS); for (int i = 0; i < hardware->dmi.memory_count; i++) { if (hardware->dmi.memory[i].filled == true) { - printf("\tbank \n"); + more_printf("\tbank \n"); break; } } for (int i = 0; i < hardware->dmi.memory_module_count; i++) { if (hardware->dmi.memory_module[i].filled == true) { - printf("\tmodule \n"); + more_printf("\tmodule \n"); break; } } if (hardware->dmi.processor.filled == true) - printf("\t%s\n", CLI_DMI_PROCESSOR); + more_printf("\t%s\n", CLI_DMI_PROCESSOR); if (hardware->dmi.system.filled == true) - printf("\t%s\n", CLI_DMI_SYSTEM); + more_printf("\t%s\n", CLI_DMI_SYSTEM); if (hardware->dmi.ipmi.filled == true) - printf("\t%s\n", CLI_DMI_IPMI); + more_printf("\t%s\n", CLI_DMI_IPMI); if (hardware->dmi.cache_count) - printf("\t%s\n", CLI_DMI_CACHE); + more_printf("\t%s\n", CLI_DMI_CACHE); if (strlen(hardware->dmi.oem_strings)) more_printf("\t%s\n", CLI_DMI_OEM); if (hardware->dmi.hardware_security.filled) - printf("\t%s\n", CLI_DMI_SECURITY); + more_printf("\t%s\n", CLI_DMI_SECURITY); } static void show_dmi_base_board(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.base_board.filled == false) { - printf("base_board information not found on your system, see " + more_printf("base_board information not found on your system, see " "`show list' to see which module is available.\n"); return; } @@ -114,54 +115,55 @@ static void show_dmi_system(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.system.filled == false) { - printf("system information not found on your system, see " + more_printf("system information not found on your system, see " "`show list' to see which module is available.\n"); return; } - printf("System\n"); - printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer); - printf(" Product Name : %s\n", hardware->dmi.system.product_name); - printf(" Version : %s\n", hardware->dmi.system.version); - printf(" Serial : %s\n", hardware->dmi.system.serial); - printf(" UUID : %s\n", hardware->dmi.system.uuid); - printf(" Wakeup Type : %s\n", hardware->dmi.system.wakeup_type); - printf(" SKU Number : %s\n", hardware->dmi.system.sku_number); - printf(" Family : %s\n", hardware->dmi.system.family); + reset_more_printf(); + more_printf("System\n"); + more_printf(" Manufacturer : %s\n", hardware->dmi.system.manufacturer); + more_printf(" Product Name : %s\n", hardware->dmi.system.product_name); + more_printf(" Version : %s\n", hardware->dmi.system.version); + more_printf(" Serial : %s\n", hardware->dmi.system.serial); + more_printf(" UUID : %s\n", hardware->dmi.system.uuid); + more_printf(" Wakeup Type : %s\n", hardware->dmi.system.wakeup_type); + more_printf(" SKU Number : %s\n", hardware->dmi.system.sku_number); + more_printf(" Family : %s\n", hardware->dmi.system.family); if (strlen(hardware->dmi.system.configuration_options)) { - printf("System Configuration Options\n"); - printf("%s\n", hardware->dmi.system.configuration_options); + more_printf("System Configuration Options\n"); + more_printf("%s\n", hardware->dmi.system.configuration_options); } if (hardware->dmi.system.system_reset.filled) { - printf("System Reset\n"); - printf(" Status : %s\n", + more_printf("System Reset\n"); + more_printf(" Status : %s\n", (hardware->dmi.system.system_reset.status ? "Enabled" : "Disabled")); - printf(" Watchdog Timer : %s\n", + more_printf(" Watchdog Timer : %s\n", (hardware->dmi.system.system_reset.watchdog ? "Present" : "Not Present")); if (strlen(hardware->dmi.system.system_reset.boot_option)) - printf(" Boot Option : %s\n", hardware->dmi.system.system_reset.boot_option); + more_printf(" Boot Option : %s\n", hardware->dmi.system.system_reset.boot_option); if (strlen(hardware->dmi.system.system_reset.boot_option_on_limit)) - printf(" Boot Option On Limit : %s\n", hardware->dmi.system.system_reset.boot_option_on_limit); + more_printf(" Boot Option On Limit : %s\n", hardware->dmi.system.system_reset.boot_option_on_limit); if (strlen(hardware->dmi.system.system_reset.reset_count)) - printf(" Reset Count : %s\n", hardware->dmi.system.system_reset.reset_count); + more_printf(" Reset Count : %s\n", hardware->dmi.system.system_reset.reset_count); if (strlen(hardware->dmi.system.system_reset.reset_limit)) - printf(" Reset Limit : %s\n", hardware->dmi.system.system_reset.reset_limit); + more_printf(" Reset Limit : %s\n", hardware->dmi.system.system_reset.reset_limit); if (strlen(hardware->dmi.system.system_reset.timer_interval)) - printf(" Timer Interval : %s\n", hardware->dmi.system.system_reset.timer_interval); + more_printf(" Timer Interval : %s\n", hardware->dmi.system.system_reset.timer_interval); if (strlen(hardware->dmi.system.system_reset.timeout)) - printf(" Timeout : %s\n", hardware->dmi.system.system_reset.timeout); + more_printf(" Timeout : %s\n", hardware->dmi.system.system_reset.timeout); } - printf("System Boot Information\n"); - printf(" Status : %s\n", hardware->dmi.system.system_boot_status); + more_printf("System Boot Information\n"); + more_printf(" Status : %s\n", hardware->dmi.system.system_boot_status); } static void show_dmi_bios(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.bios.filled == false) { - printf("bios information not found on your system, see " + more_printf("bios information not found on your system, see " "`show list' to see which module is available.\n"); return; } @@ -213,28 +215,29 @@ static void show_dmi_chassis(int argc __unused, char** argv __unused, "`show list' to see which module is available.\n"); return; } - printf("Chassis\n"); - printf(" Manufacturer : %s\n", + reset_more_printf(); + more_printf("Chassis\n"); + more_printf(" Manufacturer : %s\n", hardware->dmi.chassis.manufacturer); - printf(" Type : %s\n", hardware->dmi.chassis.type); - printf(" Lock : %s\n", hardware->dmi.chassis.lock); - printf(" Version : %s\n", + more_printf(" Type : %s\n", hardware->dmi.chassis.type); + more_printf(" Lock : %s\n", hardware->dmi.chassis.lock); + more_printf(" Version : %s\n", hardware->dmi.chassis.version); - printf(" Serial : %s\n", hardware->dmi.chassis.serial); - printf(" Asset Tag : %s\n", + more_printf(" Serial : %s\n", hardware->dmi.chassis.serial); + more_printf(" Asset Tag : %s\n", del_multi_spaces(hardware->dmi.chassis.asset_tag)); - printf(" Boot up state : %s\n", + more_printf(" Boot up state : %s\n", hardware->dmi.chassis.boot_up_state); - printf(" Power supply state : %s\n", + more_printf(" Power supply state : %s\n", hardware->dmi.chassis.power_supply_state); - printf(" Thermal state : %s\n", + more_printf(" Thermal state : %s\n", hardware->dmi.chassis.thermal_state); - printf(" Security Status : %s\n", + more_printf(" Security Status : %s\n", hardware->dmi.chassis.security_status); - printf(" OEM Information : %s\n", + more_printf(" OEM Information : %s\n", hardware->dmi.chassis.oem_information); - printf(" Height : %u\n", hardware->dmi.chassis.height); - printf(" NB Power Cords : %u\n", + more_printf(" Height : %u\n", hardware->dmi.chassis.height); + more_printf(" NB Power Cords : %u\n", hardware->dmi.chassis.nb_power_cords); } @@ -245,21 +248,22 @@ static void show_dmi_ipmi(int argc __unused, char **argv __unused, more_printf("IPMI module not available\n"); return; } - printf("IPMI\n"); - printf(" Interface Type : %s\n", + reset_more_printf(); + more_printf("IPMI\n"); + more_printf(" Interface Type : %s\n", hardware->dmi.ipmi.interface_type); - printf(" Specification Ver. : %u.%u\n", + more_printf(" Specification Ver. : %u.%u\n", hardware->dmi.ipmi.major_specification_version, hardware->dmi.ipmi.minor_specification_version); - printf(" I2C Slave Address : 0x%02x\n", + more_printf(" I2C Slave Address : 0x%02x\n", hardware->dmi.ipmi.I2C_slave_address); - printf(" Nv Storage Address : %u\n", + more_printf(" Nv Storage Address : %u\n", hardware->dmi.ipmi.nv_address); uint32_t high = hardware->dmi.ipmi.base_address >> 32; uint32_t low = hardware->dmi.ipmi.base_address & 0xFFFF; - printf(" Base Address : %08X%08X\n", + more_printf(" Base Address : %08X%08X\n", high,(low & ~1)); - printf(" IRQ : %d\n", + more_printf(" IRQ : %d\n", hardware->dmi.ipmi.irq); } @@ -267,31 +271,32 @@ static void show_dmi_battery(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.battery.filled == false) { - printf("battery information not found on your system, see " + more_printf("battery information not found on your system, see " "`show list' to see which module is available.\n"); return; } - printf("Battery \n"); - printf(" Vendor : %s\n", + reset_more_printf(); + more_printf("Battery \n"); + more_printf(" Vendor : %s\n", hardware->dmi.battery.manufacturer); - printf(" Manufacture Date : %s\n", + more_printf(" Manufacture Date : %s\n", hardware->dmi.battery.manufacture_date); - printf(" Serial : %s\n", hardware->dmi.battery.serial); - printf(" Name : %s\n", hardware->dmi.battery.name); - printf(" Chemistry : %s\n", + more_printf(" Serial : %s\n", hardware->dmi.battery.serial); + more_printf(" Name : %s\n", hardware->dmi.battery.name); + more_printf(" Chemistry : %s\n", hardware->dmi.battery.chemistry); - printf(" Design Capacity : %s\n", + more_printf(" Design Capacity : %s\n", hardware->dmi.battery.design_capacity); - printf(" Design Voltage : %s\n", + more_printf(" Design Voltage : %s\n", hardware->dmi.battery.design_voltage); - printf(" SBDS : %s\n", hardware->dmi.battery.sbds); - printf(" SBDS Manuf. Date : %s\n", + more_printf(" SBDS : %s\n", hardware->dmi.battery.sbds); + more_printf(" SBDS Manuf. Date : %s\n", hardware->dmi.battery.sbds_manufacture_date); - printf(" SBDS Chemistry : %s\n", + more_printf(" SBDS Chemistry : %s\n", hardware->dmi.battery.sbds_chemistry); - printf(" Maximum Error : %s\n", + more_printf(" Maximum Error : %s\n", hardware->dmi.battery.maximum_error); - printf(" OEM Info : %s\n", + more_printf(" OEM Info : %s\n", hardware->dmi.battery.oem_info); } @@ -299,7 +304,7 @@ static void show_dmi_cpu(int argc __unused, char** argv __unused, struct s_hardware *hardware) { if (hardware->dmi.processor.filled == false) { - printf("processor information not found on your system, see " + more_printf("processor information not found on your system, see " "`show list' to see which module is available.\n"); return; } @@ -363,44 +368,45 @@ void show_dmi_memory_bank(int argc, char** argv, bank = strtol(argv[0], (char **)NULL, 10); if (errno == ERANGE || bank < 0) { - printf("This bank number is incorrect\n"); + more_printf("This bank number is incorrect\n"); return; } if ((bank >= hardware->dmi.memory_count) || (bank < 0)) { - printf("Bank %d number doesn't exist\n", bank); + more_printf("Bank %d number doesn't exist\n", bank); return; } if (hardware->dmi.memory[bank].filled == false) { - printf("Bank %d doesn't contain any information\n", bank); + more_printf("Bank %d doesn't contain any information\n", bank); return; } - printf("Memory Bank %d\n", bank); - printf(" Form Factor : %s\n", + reset_more_printf(); + more_printf("Memory Bank %d\n", bank); + more_printf(" Form Factor : %s\n", hardware->dmi.memory[bank].form_factor); - printf(" Type : %s\n", hardware->dmi.memory[bank].type); - printf(" Type Detail : %s\n", + more_printf(" Type : %s\n", hardware->dmi.memory[bank].type); + more_printf(" Type Detail : %s\n", hardware->dmi.memory[bank].type_detail); - printf(" Speed : %s\n", hardware->dmi.memory[bank].speed); - printf(" Size : %s\n", hardware->dmi.memory[bank].size); - printf(" Device Set : %s\n", + more_printf(" Speed : %s\n", hardware->dmi.memory[bank].speed); + more_printf(" Size : %s\n", hardware->dmi.memory[bank].size); + more_printf(" Device Set : %s\n", hardware->dmi.memory[bank].device_set); - printf(" Device Loc. : %s\n", + more_printf(" Device Loc. : %s\n", hardware->dmi.memory[bank].device_locator); - printf(" Bank Locator : %s\n", + more_printf(" Bank Locator : %s\n", hardware->dmi.memory[bank].bank_locator); - printf(" Total Width : %s\n", + more_printf(" Total Width : %s\n", hardware->dmi.memory[bank].total_width); - printf(" Data Width : %s\n", + more_printf(" Data Width : %s\n", hardware->dmi.memory[bank].data_width); - printf(" Error : %s\n", hardware->dmi.memory[bank].error); - printf(" Vendor : %s\n", + more_printf(" Error : %s\n", hardware->dmi.memory[bank].error); + more_printf(" Vendor : %s\n", hardware->dmi.memory[bank].manufacturer); - printf(" Serial : %s\n", hardware->dmi.memory[bank].serial); - printf(" Asset Tag : %s\n", + more_printf(" Serial : %s\n", hardware->dmi.memory[bank].serial); + more_printf(" Asset Tag : %s\n", hardware->dmi.memory[bank].asset_tag); - printf(" Part Number : %s\n", + more_printf(" Part Number : %s\n", hardware->dmi.memory[bank].part_number); } @@ -408,7 +414,7 @@ static void show_dmi_cache(int argc, char** argv, struct s_hardware *hardware) { if (!hardware->dmi.cache_count) { - printf("cache information not found on your system, see " + more_printf("cache information not found on your system, see " "`show list' to see which module is available.\n"); return; } @@ -416,7 +422,7 @@ static void show_dmi_cache(int argc, char** argv, int cache = strtol(argv[0], NULL, 10); if (argc != 1 || cache > hardware->dmi.cache_count) { - printf("show cache [0-%d]\n", hardware->dmi.cache_count-1); + more_printf("show cache [0-%d]\n", hardware->dmi.cache_count-1); return; } @@ -464,34 +470,35 @@ void show_dmi_memory_module(int argc, char** argv, module = strtol(argv[0], (char **)NULL, 10); if (errno == ERANGE || module < 0) { - printf("This module number is incorrect\n"); + more_printf("This module number is incorrect\n"); return; } if ((module >= hardware->dmi.memory_module_count) || (module < 0)) { - printf("Module number %d doesn't exist\n", module); + more_printf("Module number %d doesn't exist\n", module); return; } if (hardware->dmi.memory_module[module].filled == false) { - printf("Module %d doesn't contain any information\n", module); + more_printf("Module %d doesn't contain any information\n", module); return; } - printf("Memory Module %d\n", module); - printf(" Socket Designation : %s\n", + reset_more_printf(); + more_printf("Memory Module %d\n", module); + more_printf(" Socket Designation : %s\n", hardware->dmi.memory_module[module].socket_designation); - printf(" Bank Connections : %s\n", + more_printf(" Bank Connections : %s\n", hardware->dmi.memory_module[module].bank_connections); - printf(" Current Speed : %s\n", + more_printf(" Current Speed : %s\n", hardware->dmi.memory_module[module].speed); - printf(" Type : %s\n", + more_printf(" Type : %s\n", hardware->dmi.memory_module[module].type); - printf(" Installed Size : %s\n", + more_printf(" Installed Size : %s\n", hardware->dmi.memory_module[module].installed_size); - printf(" Enabled Size : %s\n", + more_printf(" Enabled Size : %s\n", hardware->dmi.memory_module[module].enabled_size); - printf(" Error Status : %s\n", + more_printf(" Error Status : %s\n", hardware->dmi.memory_module[module].error_status); } @@ -502,10 +509,11 @@ void main_show_dmi(int argc __unused, char **argv __unused, detect_dmi(hardware); if (hardware->is_dmi_valid == false) { - printf("No valid DMI table found, exiting.\n"); + more_printf("No valid DMI table found, exiting.\n"); return; } - printf("DMI Table version %u.%u found\n", + reset_more_printf(); + more_printf("DMI Table version %u.%u found\n", hardware->dmi.dmitable.major_version, hardware->dmi.dmitable.minor_version); @@ -536,6 +544,7 @@ void show_dmi_memory_modules(int argc __unused, char** argv __unused, return; } + reset_more_printf(); more_printf("Memory Banks\n"); for (int i = 0; i < hardware->dmi.memory_count; i++) { if (hardware->dmi.memory[i].filled == true) { diff --git a/com32/hdt/hdt-cli-hdt.c b/com32/hdt/hdt-cli-hdt.c index b5cd535..5034725 100644 --- a/com32/hdt/hdt-cli-hdt.c +++ b/com32/hdt/hdt-cli-hdt.c @@ -52,12 +52,13 @@ static void main_show_modes(int argc __unused, char** argv __unused, { int i = 0; - printf("Available modes:\n"); + reset_more_printf(); + more_printf("Available modes:\n"); while (list_modes[i]) { - printf("%s ", list_modes[i]->name); + more_printf("%s ", list_modes[i]->name); i++; } - printf("\n"); + more_printf("\n"); } /** @@ -70,8 +71,9 @@ static void cli_set_mode(int argc, char **argv, { cli_mode_t new_mode; + reset_more_printf(); if (argc <= 0) { - printf("Which mode?\n"); + more_printf("Which mode?\n"); return; } @@ -117,43 +119,44 @@ static void show_cli_help(int argc __unused, char** argv __unused, find_cli_mode_descr(hdt_cli.mode, ¤t_mode); - printf("Available commands are:\n"); + reset_more_printf(); + more_printf("Available commands are:\n"); /* List first default modules of the mode */ if (current_mode->default_modules && current_mode->default_modules->modules) { while (current_mode->default_modules->modules[j].name) { - printf("%s ", + more_printf("%s ", current_mode->default_modules->modules[j].name); j++; } - printf("\n"); + more_printf("\n"); } /* List secondly the show modules of the mode */ if (current_mode->show_modules && current_mode->show_modules->modules) { - printf("\nshow commands:\n"); + more_printf("\nshow commands:\n"); j = 0; while (current_mode->show_modules->modules[j].name) { - printf("%s ", + more_printf("%s ", current_mode->show_modules->modules[j].name); j++; } - printf("\n"); + more_printf("\n"); } /* List thirdly the set modules of the mode */ if (current_mode->set_modules && current_mode->set_modules->modules) { - printf("\nset commands:\n"); + more_printf("\nset commands:\n"); j = 0; while (current_mode->set_modules->modules[j].name) { - printf("%s ", + more_printf("%s ", current_mode->set_modules->modules[j].name); j++; } - printf("\n"); + more_printf("\n"); } /* List finally the default modules of the hdt mode */ @@ -173,14 +176,14 @@ static void show_cli_help(int argc __unused, char** argv __unused, current_mode->default_modules, &associated_module); if (associated_module == NULL) - printf("%s ", + more_printf("%s ", hdt_mode.default_modules->modules[j].name); j++; } - printf("\n"); + more_printf("\n"); } - printf("\n"); + more_printf("\n"); main_show_modes(argc, argv, hardware); } @@ -206,6 +209,7 @@ void main_show_summary(int argc __unused, char **argv __unused, detect_pci(hardware); /* pxe is detected in the pci */ detect_dmi(hardware); cpu_detect(hardware); + reset_more_printf(); clear_screen(); main_show_cpu(argc, argv, hardware); if (hardware->is_dmi_valid) { @@ -236,14 +240,15 @@ void main_show_summary(int argc __unused, char **argv __unused, void main_show_hdt(int argc __unused, char **argv __unused, struct s_hardware *hardware __unused) { - printf("HDT\n"); - printf(" Product : %s\n", PRODUCT_NAME); - printf(" Version : %s\n", VERSION); - printf(" Author : %s\n", AUTHOR); - printf(" Contact : %s\n", CONTACT); + reset_more_printf(); + more_printf("HDT\n"); + more_printf(" Product : %s\n", PRODUCT_NAME); + more_printf(" Version : %s\n", VERSION); + more_printf(" Author : %s\n", AUTHOR); + more_printf(" Contact : %s\n", CONTACT); char *contributors[NB_CONTRIBUTORS] = CONTRIBUTORS; for (int c = 0; c < NB_CONTRIBUTORS; c++) { - printf(" Contributor : %s\n", contributors[c]); + more_printf(" Contributor : %s\n", contributors[c]); } } diff --git a/com32/hdt/hdt-cli-kernel.c b/com32/hdt/hdt-cli-kernel.c index 41c80be..d33cdd8 100644 --- a/com32/hdt/hdt-cli-kernel.c +++ b/com32/hdt/hdt-cli-kernel.c @@ -46,6 +46,7 @@ void main_show_kernel(int argc __unused, char **argv __unused, memset(buffer, 0, sizeof(buffer)); detect_pci(hardware); + reset_more_printf(); more_printf("Kernel modules\n"); // more_printf(" PCI device no: %d \n", p->pci_device_pos); @@ -105,17 +106,18 @@ static void show_kernel_modules(int argc __unused, char **argv __unused, if (hardware->pci_ids_return_code == -ENOPCIIDS) { nopciids = true; - printf(" Missing pci.ids, we can't compute the list\n"); + more_printf(" Missing pci.ids, we can't compute the list\n"); return; } if (hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) { nomodulespcimap = true; - printf + more_printf (" Missing modules.pcimap, we can't compute the list\n"); return; } + reset_more_printf(); for_each_pci_func(pci_device, hardware->pci_domain) { memset(kernel_modules, 0, sizeof kernel_modules); @@ -140,7 +142,7 @@ static void show_kernel_modules(int argc __unused, char **argv __unused, /* Print the found items */ for (int i = 0; i < MAX_PCI_CLASSES; i++) { if (strlen(category_name[i]) > 1) { - printf("%s : %s\n", category_name[i], modules[i]); + more_printf("%s : %s\n", category_name[i], modules[i]); } } } diff --git a/com32/hdt/hdt-cli-memory.c b/com32/hdt/hdt-cli-memory.c index 89f871e..3f8ed75 100644 --- a/com32/hdt/hdt-cli-memory.c +++ b/com32/hdt/hdt-cli-memory.c @@ -41,8 +41,8 @@ static void show_memory_e820(int argc __unused, char **argv __unused, char type[14]; detect_memory_e820(map, E820MAX, &count); - printf("BIOS-provided physical RAM e820 map:\n"); reset_more_printf(); + more_printf("BIOS-provided physical RAM e820 map:\n"); for (int i = 0; i < count; i++) { get_type(map[i].type, type, 14); more_printf("%016llx - %016llx %016llx (%s)\n", diff --git a/com32/hdt/hdt-cli-pci.c b/com32/hdt/hdt-cli-pci.c index 448f47b..1557b87 100644 --- a/com32/hdt/hdt-cli-pci.c +++ b/com32/hdt/hdt-cli-pci.c @@ -37,7 +37,7 @@ void main_show_pci(int argc __unused, char **argv __unused, struct s_hardware *hardware) { cli_detect_pci(hardware); - + reset_more_printf(); more_printf("PCI\n"); more_printf(" NB Devices : %d\n", hardware->nb_pci_devices); } @@ -56,19 +56,20 @@ static void show_pci_device(int argc, char **argv, MAX_KERNEL_MODULES_PER_PCI_DEVICE]; int bus = 0, slot = 0, func = 0; + reset_more_printf(); /* Sanitize arguments */ if (argc <= 0) { - printf("show device \n"); + more_printf("show device \n"); return; } else pcidev = strtol(argv[0], (char **)NULL, 10); if (errno == ERANGE) { - printf("This PCI device number is incorrect\n"); + more_printf("This PCI device number is incorrect\n"); return; } if ((pcidev > hardware->nb_pci_devices) || (pcidev <= 0)) { - printf("PCI device %d doesn't exist\n", pcidev); + more_printf("PCI device %d doesn't exist\n", pcidev); return; } if (hardware->pci_ids_return_code == -ENOPCIIDS) { @@ -92,7 +93,7 @@ static void show_pci_device(int argc, char **argv, } if (pci_device == NULL) { - printf("We were enabled to find PCI device %d\n", pcidev); + more_printf("We were enabled to find PCI device %d\n", pcidev); return; } @@ -109,41 +110,41 @@ static void show_pci_device(int argc, char **argv, if (pci_device->dev_info->linux_kernel_module_count == 0) strlcpy(kernel_modules, "unknown", 7); - printf("PCI Device %d\n", pcidev); + more_printf("PCI Device %d\n", pcidev); if (nopciids == false) { - printf("Vendor Name : %s\n", + more_printf("Vendor Name : %s\n", pci_device->dev_info->vendor_name); - printf("Product Name : %s\n", + more_printf("Product Name : %s\n", pci_device->dev_info->product_name); - printf("Class Name : %s\n", + more_printf("Class Name : %s\n", pci_device->dev_info->class_name); } if (nomodulesfiles == false) { - printf("Kernel module : %s\n", kernel_modules); + more_printf("Kernel module : %s\n", kernel_modules); } - printf("Vendor ID : %04x\n", pci_device->vendor); - printf("Product ID : %04x\n", pci_device->product); - printf("SubVendor ID : %04x\n", pci_device->sub_vendor); - printf("SubProduct ID : %04x\n", pci_device->sub_product); - printf("Class ID : %02x.%02x.%02x\n", pci_device->class[2], + more_printf("Vendor ID : %04x\n", pci_device->vendor); + more_printf("Product ID : %04x\n", pci_device->product); + more_printf("SubVendor ID : %04x\n", pci_device->sub_vendor); + more_printf("SubProduct ID : %04x\n", pci_device->sub_product); + more_printf("Class ID : %02x.%02x.%02x\n", pci_device->class[2], pci_device->class[1], pci_device->class[0]); - printf("Revision : %02x\n", pci_device->revision); + more_printf("Revision : %02x\n", pci_device->revision); if ((pci_device->dev_info->irq > 0) && (pci_device->dev_info->irq < 255)) more_printf("IRQ : %0d\n", pci_device->dev_info->irq); - printf("Latency : %0d\n", pci_device->dev_info->latency); - printf("PCI Bus : %02d\n", bus); - printf("PCI Slot : %02d\n", slot); - printf("PCI Func : %02d\n", func); + more_printf("Latency : %0d\n", pci_device->dev_info->latency); + more_printf("PCI Bus : %02d\n", bus); + more_printf("PCI Slot : %02d\n", slot); + more_printf("PCI Func : %02d\n", func); if (hardware->is_pxe_valid == true) { if ((hardware->pxe.pci_device != NULL) && (hardware->pxe.pci_device == pci_device)) { - printf("Mac Address : %s\n", hardware->pxe.mac_addr); - printf("PXE : Current boot device\n"); + more_printf("Mac Address : %s\n", hardware->pxe.mac_addr); + more_printf("PXE : Current boot device\n"); } } } @@ -305,21 +306,21 @@ void cli_detect_pci(struct s_hardware *hardware) if (hardware->pci_detection == false) { detect_pci(hardware); if (hardware->pci_ids_return_code == -ENOPCIIDS) { - printf + more_printf ("The pci.ids file is missing, device names can't be computed.\n"); - printf("Please put one in same dir as hdt\n"); + more_printf("Please put one in same dir as hdt\n"); error = true; } if ((hardware->modules_pcimap_return_code == -ENOMODULESPCIMAP) && (hardware->modules_alias_return_code == -ENOMODULESALIAS)) { - printf + more_printf ("The modules.pcimap or modules.alias files are missing, device names can't be computed.\n"); - printf("Please put one of them in same dir as hdt\n"); + more_printf("Please put one of them in same dir as hdt\n"); error = true; } if (error == true) { char tempbuf[10]; - printf("Press enter to continue\n"); + more_printf("Press enter to continue\n"); fgets(tempbuf, sizeof(tempbuf), stdin); } } diff --git a/com32/hdt/hdt-cli-pxe.c b/com32/hdt/hdt-cli-pxe.c index 1d00cae..a281d15 100644 --- a/com32/hdt/hdt-cli-pxe.c +++ b/com32/hdt/hdt-cli-pxe.c @@ -41,20 +41,21 @@ void main_show_pxe(int argc __unused, char **argv __unused, { char buffer[81]; memset(buffer, 0, sizeof(81)); + reset_more_printf(); if (hardware->sv->filesystem != SYSLINUX_FS_PXELINUX) { - printf("You are not currently using PXELINUX\n"); + more_printf("You are not currently using PXELINUX\n"); return; } detect_pxe(hardware); - printf("PXE\n"); + more_printf("PXE\n"); if (hardware->is_pxe_valid == false) { - printf(" No valid PXE ROM found\n"); + more_printf(" No valid PXE ROM found\n"); return; } struct s_pxe *p = &hardware->pxe; - printf(" PCI device no: %d \n", p->pci_device_pos); + more_printf(" PCI device no: %d \n", p->pci_device_pos); if (hardware->pci_ids_return_code == -ENOPCIIDS || (p->pci_device == NULL)) { @@ -65,16 +66,16 @@ void main_show_pxe(int argc __unused, char **argv __unused, snprintf(buffer, sizeof(buffer), " PCI Bus pos. : %02x:%02x.%02x\n", p->pci_bus, p->pci_dev, p->pci_func); - printf(buffer); + more_printf(buffer); } else { snprintf(buffer, sizeof(buffer), " Manufacturer : %s \n", p->pci_device->dev_info->vendor_name); - printf(buffer); + more_printf(buffer); snprintf(buffer, sizeof(buffer), " Product : %s \n", p->pci_device->dev_info->product_name); - printf(buffer); + more_printf(buffer); } - printf(" Addresses : %d.%d.%d.%d @ %s\n", p->ip_addr[0], + more_printf(" Addresses : %d.%d.%d.%d @ %s\n", p->ip_addr[0], p->ip_addr[1], p->ip_addr[2], p->ip_addr[3], p->mac_addr); } diff --git a/com32/hdt/hdt-cli-syslinux.c b/com32/hdt/hdt-cli-syslinux.c index 0d78bc6..160e33c 100644 --- a/com32/hdt/hdt-cli-syslinux.c +++ b/com32/hdt/hdt-cli-syslinux.c @@ -39,12 +39,13 @@ void main_show_syslinux(int argc __unused, char **argv __unused, struct s_hardware *hardware) { - printf("SYSLINUX\n"); - printf(" Bootloader : %s\n", hardware->syslinux_fs); - printf(" Version : %s\n", hardware->sv->version_string + 2); - printf(" Version : %u\n", hardware->sv->version); - printf(" Max API : %u\n", hardware->sv->max_api); - printf(" Copyright : %s\n", hardware->sv->copyright_string + 1); + reset_more_printf(); + more_printf("SYSLINUX\n"); + more_printf(" Bootloader : %s\n", hardware->syslinux_fs); + more_printf(" Version : %s\n", hardware->sv->version_string + 2); + more_printf(" Version : %u\n", hardware->sv->version); + more_printf(" Max API : %u\n", hardware->sv->max_api); + more_printf(" Copyright : %s\n", hardware->sv->copyright_string + 1); } struct cli_module_descr syslinux_show_modules = { diff --git a/com32/hdt/hdt-cli-vesa.c b/com32/hdt/hdt-cli-vesa.c index 70d1dc6..c6eea07 100644 --- a/com32/hdt/hdt-cli-vesa.c +++ b/com32/hdt/hdt-cli-vesa.c @@ -36,33 +36,34 @@ void main_show_vesa(int argc __unused, char **argv __unused, struct s_hardware *hardware) { + reset_more_printf(); detect_vesa(hardware); if (hardware->is_vesa_valid == false) { - printf("No VESA BIOS detected\n"); + more_printf("No VESA BIOS detected\n"); return; } - printf("VESA\n"); - printf(" Vesa version : %d.%d\n", hardware->vesa.major_version, + more_printf("VESA\n"); + more_printf(" Vesa version : %d.%d\n", hardware->vesa.major_version, hardware->vesa.minor_version); - printf(" Vendor : %s\n", hardware->vesa.vendor); - printf(" Product : %s\n", hardware->vesa.product); - printf(" Product rev. : %s\n", hardware->vesa.product_revision); - printf(" Software rev.: %d\n", hardware->vesa.software_rev); - printf(" Memory (KB) : %d\n", hardware->vesa.total_memory * 64); - printf(" Modes : %d\n", hardware->vesa.vmi_count); + more_printf(" Vendor : %s\n", hardware->vesa.vendor); + more_printf(" Product : %s\n", hardware->vesa.product); + more_printf(" Product rev. : %s\n", hardware->vesa.product_revision); + more_printf(" Software rev.: %d\n", hardware->vesa.software_rev); + more_printf(" Memory (KB) : %d\n", hardware->vesa.total_memory * 64); + more_printf(" Modes : %d\n", hardware->vesa.vmi_count); } static void show_vesa_modes(int argc __unused, char **argv __unused, struct s_hardware *hardware) { detect_vesa(hardware); + reset_more_printf(); if (hardware->is_vesa_valid == false) { - printf("No VESA BIOS detected\n"); + more_printf("No VESA BIOS detected\n"); return; } - reset_more_printf(); - printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n"); - printf("----------------------------------------\n"); + more_printf(" ResH. x ResV x Bits : vga= : Vesa Mode\n"); + more_printf("----------------------------------------\n"); for (int i = 0; i < hardware->vesa.vmi_count; i++) { struct vesa_mode_info *mi = &hardware->vesa.vmi[i].mi; @@ -71,7 +72,7 @@ static void show_vesa_modes(int argc __unused, char **argv __unused, * We don't need to display that ones. */ if ((mi->h_res == 0) || (mi->v_res == 0)) continue; - printf("%5u %5u %3u %3d 0x%04x\n", + more_printf("%5u %5u %3u %3d 0x%04x\n", mi->h_res, mi->v_res, mi->bpp, hardware->vesa.vmi[i].mode + 0x200, hardware->vesa.vmi[i].mode); diff --git a/com32/hdt/hdt-cli-vpd.c b/com32/hdt/hdt-cli-vpd.c index 03614d3..a445d83 100644 --- a/com32/hdt/hdt-cli-vpd.c +++ b/com32/hdt/hdt-cli-vpd.c @@ -39,11 +39,11 @@ void main_show_vpd(int argc __unused, char **argv __unused, detect_vpd(hardware); if (!hardware->is_vpd_valid) { - printf("No VPD structure detected.\n"); + more_printf("No VPD structure detected.\n"); return; } - printf("VPD present at address : 0x%s\n", hardware->vpd.base_address); + more_printf("VPD present at address : 0x%s\n", hardware->vpd.base_address); if (strlen(hardware->vpd.bios_build_id) > 0) more_printf("Bios Build ID : %s\n", hardware->vpd.bios_build_id); if (strlen(hardware->vpd.bios_release_date) > 0) diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h index 8ef24e7..dddcb55 100644 --- a/com32/hdt/hdt-common.h +++ b/com32/hdt/hdt-common.h @@ -60,18 +60,19 @@ extern int display_line_nb; #define pause_printf() do {\ - printf("--More--");\ - get_key(stdin, 0);\ - printf("\n");\ + printf("--More--");\ + get_key(stdin, 0);\ + printf("\033[2K\033[1G\033[1F\n");\ } while (0); #define more_printf(...) do {\ if (display_line_nb == 20) {\ - printf("\nPress any key to continue");\ + printf("\n--More--");\ display_line_nb=0;\ get_key(stdin, 0);\ + printf("\033[2K\033[1G\033[1F");\ }\ - printf ( __VA_ARGS__);\ + printf(__VA_ARGS__);\ display_line_nb++; \ } while (0); -- 2.7.4