diff --git a/shell.c b/shell.c index 7537685..427bc52 100644 --- a/shell.c +++ b/shell.c @@ -114,12 +114,13 @@ convert_f70_file_attr(uint32_t attr, char s[KF_ATTR_CNT+1]) { } static void -print_f70_status(struct shell_ctx *ctx, f7080ret_t *r, int use_ebx) { - fprintf(ctx->fout, "status = %d %s", r->status, get_f70_status_name(r->status)); - if (use_ebx && - (r->status == ERROR_SUCCESS || r->status == ERROR_END_OF_FILE)) - fprintf(ctx->fout, ", count = %d", r->count); - fputc('\n', ctx->fout); +print_f70_status(f7080ret_t *r, int use_ebx) { + printf("status = %d %s", r->status, get_f70_status_name(r->status)); + if (use_ebx + && (r->status == ERROR_SUCCESS || r->status == ERROR_END_OF_FILE)) { + printf(", count = %d", r->count); + } + putchar('\n'); } static bool @@ -131,25 +132,25 @@ parse_uintmax(const char *str, uintmax_t *res) { } static bool -parse_uint32(struct shell_ctx *ctx, const char *str, uint32_t *res) { +parse_uint32(const char *str, uint32_t *res) { uintmax_t x; if (parse_uintmax(str, &x) && x <= UINT32_MAX) { *res = (uint32_t)x; return true; } else { - fprintf(ctx->fout, "invalid number: %s\n", str); + printf("invalid number: %s\n", str); return false; } } static bool -parse_uint64(struct shell_ctx *ctx, const char *str, uint64_t *res) { +parse_uint64(const char *str, uint64_t *res) { uintmax_t x; if (parse_uintmax(str, &x) && x <= UINT64_MAX) { *res = x; return true; } else { - fprintf(ctx->fout, "invalid number: %s\n", str); + printf("invalid number: %s\n", str); return false; } } @@ -283,24 +284,24 @@ shell_var_add_ptr(struct shell_ctx *ctx, void *value) { } static void -print_bytes(struct shell_ctx *ctx, uint8_t *x, size_t len) { +print_bytes(uint8_t *x, size_t len) { for (size_t i = 0; i < len; i++) { if (i % PRINT_BYTES_PER_LINE == 0 && i != 0) { - fputc('\n', ctx->fout); + putchar('\n'); } - fprintf(ctx->fout, "%2.2x", x[i]); + printf("%2.2x", x[i]); } - fputc('\n', ctx->fout); + putchar('\n'); } static void -print_hash(struct shell_ctx *ctx, uint8_t *x, size_t len) { +print_hash(uint8_t *x, size_t len) { hash_context hash; hash_oneshot(&hash, x, len); for (size_t i = 0; i < HASH_SIZE; i++) { - fprintf(ctx->fout, "%2.2x", hash.hash[i]); + printf("%2.2x", hash.hash[i]); } - fputc('\n', ctx->fout); + putchar('\n'); } void *host_load_file(const char *fname) { @@ -329,7 +330,7 @@ get_last_dir(const char *path) { } static void -prompt(struct shell_ctx *ctx) { +prompt() { if (cur_dir_changed) { if (umka_initialized) { COVERAGE_ON(); @@ -339,8 +340,8 @@ prompt(struct shell_ctx *ctx) { last_dir = get_last_dir(cur_dir); cur_dir_changed = false; } - fprintf(ctx->fout, "%s> ", last_dir); - fflush(ctx->fout); + printf("%s> ", last_dir); + fflush(stdout); } static void @@ -354,8 +355,8 @@ completion(const char *buf, bestlineCompletions *lc) { static char * hints(const char *buf, const char **ansi1, const char **ansi2) { if (!strcmp(buf,"hello")) { - *ansi1 = "\033[35m"; - *ansi2 = "\033[39m"; + *ansi1 = "\033[35m"; /* magenta foreground */ + *ansi2 = "\033[39m"; /* reset foreground */ return " World"; } return NULL; @@ -370,26 +371,28 @@ split_args(char *s, char **argv) { static void cmd_var(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: var <$name>\n" - " $name variable name, must start with $ sign\n"; + " $name variable name, must start with $ sign"; if (argc != 2) { - fputs(usage, ctx->fout); + puts(usage); return; } bool status = shell_var_name(ctx, argv[1]); if (!status) { - fprintf(ctx->fout, "fail\n"); + printf("fail\n"); } } static void cmd_send_scancode(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: send_scancode ...\n" - " code dec or hex number\n"; + " code dec or hex number"; if (argc < 2) { - fputs(usage, ctx->fout); + puts(usage); return; } argc -= 1; @@ -403,8 +406,8 @@ cmd_send_scancode(struct shell_ctx *ctx, int argc, char **argv) { argc--; argv++; } else { - fprintf(ctx->fout, "not an integer: %s\n", argv[0]); - fputs(usage, ctx->fout); + printf("not an integer: %s\n", argv[0]); + puts(usage); return; } } @@ -412,11 +415,12 @@ cmd_send_scancode(struct shell_ctx *ctx, int argc, char **argv) { static void cmd_umka_init(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ - "usage: umka_init\n"; + "usage: umka_init"; (void)argv; - if (argc < 0) { - fputs(usage, ctx->fout); + if (argc != 1) { + puts(usage); return; } COVERAGE_ON(); @@ -426,11 +430,11 @@ cmd_umka_init(struct shell_ctx *ctx, int argc, char **argv) { static void cmd_umka_set_boot_params(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: umka_set_boot_params [--x_res ] [--y_res ]\n" " --x_res screen width\n" - " --y_res screen height\n"; - + " --y_res screen height"; argc -= 1; argv += 1; @@ -447,21 +451,21 @@ cmd_umka_set_boot_params(struct shell_ctx *ctx, int argc, char **argv) { argv += 2; continue; } else { - fprintf(ctx->fout, "bad option: %s\n", argv[0]); - fputs(usage, ctx->fout); + printf("bad option: %s\n", argv[0]); + puts(usage); return; } } - } static void cmd_i40(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: i40 [ebx [ecx [edx [esi [edi [ebp]]]]]]...\n" - " see '/kernel/docs/sysfuncs.txt' for details\n"; + " see '/kernel/docs/sysfuncs.txt' for details"; if (argc < 2 || argc > 8) { - fputs(usage, ctx->fout); + puts(usage); return; } pushad_t regs = {0, 0, 0, 0, 0, 0, 0, 0}; @@ -475,52 +479,52 @@ cmd_i40(struct shell_ctx *ctx, int argc, char **argv) { COVERAGE_ON(); umka_i40(®s); COVERAGE_OFF(); - fprintf(ctx->fout, "eax = %8.8x %" PRIu32 " %" PRIi32 "\n" + printf("eax = %8.8x %" PRIu32 " %" PRIi32 "\n" "ebx = %8.8x %" PRIu32 " %" PRIi32 "\n", regs.eax, regs.eax, (int32_t)regs.eax, regs.ebx, regs.ebx, (int32_t)regs.ebx); } static void -disk_list_partitions(struct shell_ctx *ctx, disk_t *d) { +disk_list_partitions(disk_t *d) { for (size_t i = 0; i < d->num_partitions; i++) { - fprintf(ctx->fout, "/%s/%d: ", d->name, i+1); + printf("/%s/%d: ", d->name, i+1); if (d->partitions[i]->fs_user_functions == xfs_user_functions) { - fputs("xfs\n", ctx->fout); + puts("xfs"); } else if (d->partitions[i]->fs_user_functions == ext_user_functions) { - fputs("ext\n", ctx->fout); + puts("ext"); } else if (d->partitions[i]->fs_user_functions == fat_user_functions) { - fputs("fat\n", ctx->fout); + puts("fat"); } else if (d->partitions[i]->fs_user_functions == exfat_user_functions) { - fputs("exfat\n", ctx->fout); + puts("exfat"); } else if (d->partitions[i]->fs_user_functions == ntfs_user_functions) { - fputs("ntfs\n", ctx->fout); + puts("ntfs"); } else { - fputs("???\n", ctx->fout); + puts("???"); } } } static void cmd_ramdisk_init(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: ramdisk_init \n" - " absolute or relative path\n"; + " absolute or relative path"; if (argc != 2) { - fputs(usage, ctx->fout); + puts(usage); return; } const char *fname = argv[1]; FILE *f = fopen(fname, "rb"); if (!f) { - fprintf(ctx->fout, "[!] can't open file '%s': %s\n", fname, strerror(errno)); + printf("[!] can't open file '%s': %s\n", fname, strerror(errno)); return; } fseek(f, 0, SEEK_END); size_t fsize = ftell(f); if (fsize > 2880*512) { - fprintf(ctx->fout, "[!] file '%s' is too big, max size is 1474560 bytes\n", - fname); + printf("[!] file '%s' is too big, max size is 1474560 bytes\n", fname); return; } rewind(f); @@ -529,18 +533,19 @@ cmd_ramdisk_init(struct shell_ctx *ctx, int argc, char **argv) { COVERAGE_ON(); void *ramdisk = kos_ramdisk_init(); COVERAGE_OFF(); - disk_list_partitions(ctx, ramdisk); + disk_list_partitions(ramdisk); } static void cmd_disk_add(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: disk_add [option]...\n" " absolute or relative path\n" " disk name, e.g. hd0 or rd\n" - " -c cache size size of disk cache in bytes\n"; + " -c cache size size of disk cache in bytes"; if (argc < 3) { - fputs(usage, ctx->fout); + puts(usage); return; } size_t cache_size = 0; @@ -556,7 +561,7 @@ cmd_disk_add(struct shell_ctx *ctx, int argc, char **argv) { adjust_cache_size = 1; break; default: - fputs(usage, ctx->fout); + puts(usage); return; } } @@ -570,17 +575,16 @@ cmd_disk_add(struct shell_ctx *ctx, int argc, char **argv) { COVERAGE_ON(); disk_media_changed(vdisk, 1); COVERAGE_OFF(); - disk_list_partitions(ctx, vdisk); + disk_list_partitions(vdisk); return; } } - fprintf(ctx->fout, "umka: can't add file '%s' as disk '%s'\n", file_name, - disk_name); + printf("umka: can't add file '%s' as disk '%s'\n", file_name, disk_name); return; } static void -disk_del_by_name(struct shell_ctx *ctx, const char *name) { +disk_del_by_name(const char *name) { for(disk_t *d = disk_list.next; d != &disk_list; d = d->next) { if (!strcmp(d->name, name)) { COVERAGE_ON(); @@ -589,29 +593,31 @@ disk_del_by_name(struct shell_ctx *ctx, const char *name) { return; } } - fprintf(ctx->fout, "umka: can't find disk '%s'\n", name); + printf("umka: can't find disk '%s'\n", name); } static void cmd_disk_del(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: disk_del \n" - " name disk name, i.e. rd or hd0\n"; + " name disk name, i.e. rd or hd0"; if (argc != 2) { - fputs(usage, ctx->fout); + puts(usage); return; } const char *name = argv[1]; - disk_del_by_name(ctx, name); + disk_del_by_name(name); return; } static void cmd_pwd(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ - "usage: pwd\n"; + "usage: pwd"; if (argc != 1) { - fputs(usage, ctx->fout); + puts(usage); return; } (void)argv; @@ -620,19 +626,20 @@ cmd_pwd(struct shell_ctx *ctx, int argc, char **argv) { COVERAGE_ON(); umka_sys_get_cwd(cur_dir, PATH_MAX); COVERAGE_OFF(); - fprintf(ctx->fout, "%s%s%s\n", quote, cur_dir, quote); + printf("%s%s%s\n", quote, cur_dir, quote); } static void cmd_set_pixel(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: set_pixel [-i]\n" " x x window coordinate\n" " y y window coordinate\n" " color argb in hex\n" - " -i inverted color\n"; + " -i inverted color"; if (argc < 4) { - fputs(usage, ctx->fout); + puts(usage); return; } size_t x = strtoul(argv[1], NULL, 0); @@ -646,6 +653,7 @@ cmd_set_pixel(struct shell_ctx *ctx, int argc, char **argv) { static void cmd_write_text(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: write_text " " " @@ -659,9 +667,9 @@ cmd_write_text(struct shell_ctx *ctx, int argc, char **argv) { " font_and_enc font size and string encoding\n" " draw_to_buf draw to the buffer pointed to by the next param\n" " length length of the string if it is non-asciiz\n" - " bg_color_or_buf argb or pointer\n"; + " bg_color_or_buf argb or pointer"; if (argc != 12) { - fputs(usage, ctx->fout); + puts(usage); return; } size_t x = strtoul(argv[1], NULL, 0); @@ -684,23 +692,25 @@ cmd_write_text(struct shell_ctx *ctx, int argc, char **argv) { static void cmd_get_key(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; (void)argv; const char *usage = \ - "usage: get_key\n"; + "usage: get_key"; if (argc > 1) { - fputs(usage, ctx->fout); + puts(usage); return; } - fprintf(ctx->fout, "0x%8.8" PRIx32 "\n", umka_get_key()); + printf("0x%8.8" PRIx32 "\n", umka_get_key()); } static void cmd_dump_key_buff(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: dump_key_buff [count]\n" - " count how many items to dump (all by default)\n"; + " count how many items to dump (all by default)"; if (argc > 2) { - fputs(usage, ctx->fout); + puts(usage); return; } int count = INT_MAX; @@ -708,18 +718,19 @@ cmd_dump_key_buff(struct shell_ctx *ctx, int argc, char **argv) { count = strtol(argv[1], NULL, 0); } for (int i = 0; i < count && i < kos_key_count; i++) { - fprintf(ctx->fout, "%3i 0x%2.2x 0x%2.2x\n", i, kos_key_buff[i], - kos_key_buff[120+2+i]); + printf("%3i 0x%2.2x 0x%2.2x\n", i, kos_key_buff[i], + kos_key_buff[120+2+i]); } } static void cmd_dump_win_stack(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: dump_win_stack [count]\n" - " count how many items to dump\n"; + " count how many items to dump"; if (argc > 2) { - fputs(usage, ctx->fout); + puts(usage); return; } int depth = 5; @@ -727,17 +738,18 @@ cmd_dump_win_stack(struct shell_ctx *ctx, int argc, char **argv) { depth = strtol(argv[1], NULL, 0); } for (int i = 0; i < depth; i++) { - fprintf(ctx->fout, "%3i: %3u\n", i, kos_win_stack[i]); + printf("%3i: %3u\n", i, kos_win_stack[i]); } } static void cmd_dump_win_pos(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: dump_win_pos [count]\n" - " count how many items to dump\n"; + " count how many items to dump"; if (argc < 1) { - fputs(usage, ctx->fout); + puts(usage); return; } int depth = 5; @@ -745,36 +757,38 @@ cmd_dump_win_pos(struct shell_ctx *ctx, int argc, char **argv) { depth = strtol(argv[1], NULL, 0); } for (int i = 0; i < depth; i++) { - fprintf(ctx->fout, "%3i: %3u\n", i, kos_win_pos[i]); + printf("%3i: %3u\n", i, kos_win_pos[i]); } } static void cmd_dump_win_map(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; + (void)argv; // TODO: area const char *usage = \ - "usage: dump_win_map\n"; - (void)argv; + "usage: dump_win_map"; if (argc < 0) { - fputs(usage, ctx->fout); + puts(usage); return; } for (size_t y = 0; y < kos_display.height; y++) { for (size_t x = 0; x < kos_display.width; x++) { - fputc(kos_display.win_map[y * kos_display.width + x] + '0', ctx->fout); + putchar(kos_display.win_map[y * kos_display.width + x] + '0'); } - fputc('\n', ctx->fout); + putchar('\n'); } } static void cmd_dump_appdata(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: dump_appdata [-p]\n" " index index into appdata array to dump\n" - " -p print fields that are pointers\n"; + " -p print fields that are pointers"; if (argc < 2) { - fputs(usage, ctx->fout); + puts(usage); return; } int show_pointers = 0; @@ -783,60 +797,59 @@ cmd_dump_appdata(struct shell_ctx *ctx, int argc, char **argv) { show_pointers = 1; } appdata_t *a = kos_slot_base + idx; - fprintf(ctx->fout, "app_name: %s\n", a->app_name); + printf("app_name: %s\n", a->app_name); if (show_pointers) { - fprintf(ctx->fout, "process: %p\n", (void*)a->process); - fprintf(ctx->fout, "fpu_state: %p\n", (void*)a->fpu_state); - fprintf(ctx->fout, "exc_handler: %p\n", (void*)a->exc_handler); + printf("process: %p\n", (void*)a->process); + printf("fpu_state: %p\n", (void*)a->fpu_state); + printf("exc_handler: %p\n", (void*)a->exc_handler); } - fprintf(ctx->fout, "except_mask: %" PRIx32 "\n", a->except_mask); + printf("except_mask: %" PRIx32 "\n", a->except_mask); if (show_pointers) { - fprintf(ctx->fout, "pl0_stack: %p\n", (void*)a->pl0_stack); - fprintf(ctx->fout, "cursor: %p\n", (void*)a->cursor); - fprintf(ctx->fout, "fd_ev: %p\n", (void*)a->fd_ev); - fprintf(ctx->fout, "bk_ev: %p\n", (void*)a->bk_ev); - fprintf(ctx->fout, "fd_obj: %p\n", (void*)a->fd_obj); - fprintf(ctx->fout, "bk_obj: %p\n", (void*)a->bk_obj); - fprintf(ctx->fout, "saved_esp: %p\n", (void*)a->saved_esp); + printf("pl0_stack: %p\n", (void*)a->pl0_stack); + printf("cursor: %p\n", (void*)a->cursor); + printf("fd_ev: %p\n", (void*)a->fd_ev); + printf("bk_ev: %p\n", (void*)a->bk_ev); + printf("fd_obj: %p\n", (void*)a->fd_obj); + printf("bk_obj: %p\n", (void*)a->bk_obj); + printf("saved_esp: %p\n", (void*)a->saved_esp); } - fprintf(ctx->fout, "dbg_state: %u\n", a->dbg_state); - fprintf(ctx->fout, "cur_dir: %s\n", a->cur_dir); - fprintf(ctx->fout, "draw_bgr_x: %u\n", a->draw_bgr_x); - fprintf(ctx->fout, "draw_bgr_y: %u\n", a->draw_bgr_y); - fprintf(ctx->fout, "event_mask: %" PRIx32 "\n", a->event_mask); - fprintf(ctx->fout, "tid: %" PRId32 "\n", a->tid); - fprintf(ctx->fout, "state: 0x%" PRIx8 "\n", a->state); - fprintf(ctx->fout, "wnd_number: %" PRIu8 "\n", a->wnd_number); - fprintf(ctx->fout, "terminate_protection: %u\n", a->terminate_protection); - fprintf(ctx->fout, "keyboard_mode: %u\n", a->keyboard_mode); - fprintf(ctx->fout, "captionEncoding: %u\n", a->captionEncoding); - fprintf(ctx->fout, "exec_params: %s\n", a->exec_params); - fprintf(ctx->fout, "wnd_caption: %s\n", a->wnd_caption); - fprintf(ctx->fout, "wnd_clientbox (ltwh): %u %u %u %u\n", a->wnd_clientbox.left, - a->wnd_clientbox.top, a->wnd_clientbox.width, - a->wnd_clientbox.height); - fprintf(ctx->fout, "priority: %u\n", a->priority); + printf("dbg_state: %u\n", a->dbg_state); + printf("cur_dir: %s\n", a->cur_dir); + printf("draw_bgr_x: %u\n", a->draw_bgr_x); + printf("draw_bgr_y: %u\n", a->draw_bgr_y); + printf("event_mask: %" PRIx32 "\n", a->event_mask); + printf("tid: %" PRId32 "\n", a->tid); + printf("state: 0x%" PRIx8 "\n", a->state); + printf("wnd_number: %" PRIu8 "\n", a->wnd_number); + printf("terminate_protection: %u\n", a->terminate_protection); + printf("keyboard_mode: %u\n", a->keyboard_mode); + printf("captionEncoding: %u\n", a->captionEncoding); + printf("exec_params: %s\n", a->exec_params); + printf("wnd_caption: %s\n", a->wnd_caption); + printf("wnd_clientbox (ltwh): %u %u %u %u\n", a->wnd_clientbox.left, + a->wnd_clientbox.top, a->wnd_clientbox.width, + a->wnd_clientbox.height); + printf("priority: %u\n", a->priority); - fprintf(ctx->fout, "in_schedule: prev"); + printf("in_schedule: prev"); if (show_pointers) { - fprintf(ctx->fout, " %p", (void*)a->in_schedule.prev); + printf(" %p", (void*)a->in_schedule.prev); } - fprintf(ctx->fout, " (%u), next", - (appdata_t*)a->in_schedule.prev - kos_slot_base); + printf(" (%u), next", (appdata_t*)a->in_schedule.prev - kos_slot_base); if (show_pointers) { - fprintf(ctx->fout, " %p", (void*)a->in_schedule.next); + printf(" %p", (void*)a->in_schedule.next); } - fprintf(ctx->fout, " (%u)\n", - (appdata_t*)a->in_schedule.next - kos_slot_base); + printf(" (%u)\n", (appdata_t*)a->in_schedule.next - kos_slot_base); } static void cmd_switch_to_thread(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: switch_to_thread \n" - " thread id to switch to\n"; + " thread id to switch to"; if (argc != 2) { - fputs(usage, ctx->fout); + puts(usage); return; } uint8_t tid = strtoul(argv[1], NULL, 0); @@ -846,39 +859,41 @@ cmd_switch_to_thread(struct shell_ctx *ctx, int argc, char **argv) { static void cmd_get(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: get \n" - " variable to get\n"; + " variable to get"; if (argc != 2) { - fputs(usage, ctx->fout); + puts(usage); return; } const char *var = argv[1]; if (!strcmp(var, "redraw_background")) { - fprintf(ctx->fout, "%i\n", kos_redraw_background); + printf("%i\n", kos_redraw_background); } else if (!strcmp(var, "key_count")) { - fprintf(ctx->fout, "%i\n", kos_key_count); + printf("%i\n", kos_key_count); } else if (!strcmp(var, "syslang")) { - fprintf(ctx->fout, "%i\n", kos_syslang); + printf("%i\n", kos_syslang); } else if (!strcmp(var, "keyboard")) { - fprintf(ctx->fout, "%i\n", kos_keyboard); + printf("%i\n", kos_keyboard); } else if (!strcmp(var, "keyboard_mode")) { - fprintf(ctx->fout, "%i\n", kos_keyboard_mode); + printf("%i\n", kos_keyboard_mode); } else { - fprintf(ctx->fout, "no such variable: %s\n", var); - fputs(usage, ctx->fout); + printf("no such variable: %s\n", var); + puts(usage); return; } } static void cmd_set(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: set \n" " variable to set\n" - " decimal or hex value\n"; + " decimal or hex value"; if (argc != 3) { - fputs(usage, ctx->fout); + puts(usage); return; } const char *var = argv[1]; @@ -886,7 +901,7 @@ cmd_set(struct shell_ctx *ctx, int argc, char **argv) { char *endptr; ssize_t value = strtol(val_str, &endptr, 0); if (*endptr != '\0') { - fprintf(ctx->fout, "integer required: %s\n", val_str); + printf("integer required: %s\n", val_str); return; } if (!strcmp(var, "redraw_background")) { @@ -898,28 +913,30 @@ cmd_set(struct shell_ctx *ctx, int argc, char **argv) { } else if (!strcmp(var, "keyboard_mode")) { kos_keyboard_mode = value; } else { - fprintf(ctx->fout, "bad option: %s\n", argv[1]); - fputs(usage, ctx->fout); + printf("bad option: %s\n", argv[1]); + puts(usage); return; } } static void cmd_new_sys_thread(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; + (void)argv; // FIXME const char *usage = \ - "usage: new_sys_thread\n"; + "usage: new_sys_thread"; if (!argc) { - fputs(usage, ctx->fout); + puts(usage); return; } - (void)argv; size_t tid = umka_new_sys_threads(0, NULL, NULL); - fprintf(ctx->fout, "tid: %u\n", tid); + printf("tid: %u\n", tid); } static void cmd_mouse_move(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: mouse_move [-l] [-m] [-r] [-x {+|-|=}]" "[-y {+|-|=}] [-h {+|-}] [-v {+|-}]\n" @@ -929,9 +946,9 @@ cmd_mouse_move(struct shell_ctx *ctx, int argc, char **argv) { " -x increase, decrease or set x coordinate\n" " -y increase, decrease or set y coordinate\n" " -h scroll horizontally\n" - " -v scroll vertically\n"; + " -v scroll vertically"; if (!argc) { - fputs(usage, ctx->fout); + puts(usage); return; } int lbheld = 0, mbheld = 0, rbheld = 0, xabs = 0, yabs = 0; @@ -961,7 +978,7 @@ cmd_mouse_move(struct shell_ctx *ctx, int argc, char **argv) { xmoving = -strtol(optarg, NULL, 0); break; default: - fputs(usage, ctx->fout); + puts(usage); return; } break; @@ -977,26 +994,26 @@ cmd_mouse_move(struct shell_ctx *ctx, int argc, char **argv) { ymoving = -strtol(optarg, NULL, 0); break; default: - fputs(usage, ctx->fout); + puts(usage); return; } break; case 'h': if ((optarg[0] != '+') && (optarg[0] != '-')) { - fputs(usage, ctx->fout); + puts(usage); return; } hscroll = strtol(optarg, NULL, 0); break; case 'v': if ((optarg[0] != '+') && (optarg[0] != '-')) { - fputs(usage, ctx->fout); + puts(usage); return; } vscroll = strtol(optarg, NULL, 0); break; default: - fputs(usage, ctx->fout); + puts(usage); return; } } @@ -1010,9 +1027,9 @@ static void cmd_process_info(struct shell_ctx *ctx, int argc, char **argv) { const char *usage = \ "usage: process_info \n" - " pid process id to dump, -1 for self\n"; + " pid process id to dump, -1 for self"; if (argc != 2) { - fputs(usage, ctx->fout); + puts(usage); return; } process_information_t info; @@ -1021,24 +1038,25 @@ cmd_process_info(struct shell_ctx *ctx, int argc, char **argv) { COVERAGE_ON(); umka_sys_process_info(pid, &info); COVERAGE_OFF(); - fprintf(ctx->fout, "cpu_usage: %u\n", info.cpu_usage); - fprintf(ctx->fout, "window_stack_position: %u\n", info.window_stack_position); - fprintf(ctx->fout, "window_stack_value: %u\n", info.window_stack_value); - fprintf(ctx->fout, "process_name: %s\n", info.process_name); - fprintf(ctx->fout, "memory_start: 0x%.8" PRIx32 "\n", info.memory_start); - fprintf(ctx->fout, "used_memory: %u (0x%x)\n", info.used_memory, - info.used_memory); - fprintf(ctx->fout, "pid: %u\n", info.pid); - fprintf(ctx->fout, "box: %u %u %u %u\n", info.box.left, info.box.top, - info.box.width, info.box.height); - fprintf(ctx->fout, "slot_state: %u\n", info.slot_state); - fprintf(ctx->fout, "client_box: %u %u %u %u\n", info.client_box.left, - info.client_box.top, info.client_box.width, info.client_box.height); - fprintf(ctx->fout, "wnd_state: 0x%.2" PRIx8 "\n", info.wnd_state); + printf("cpu_usage: %u\n", info.cpu_usage); + printf("window_stack_position: %u\n", info.window_stack_position); + printf("window_stack_value: %u\n", info.window_stack_value); + printf("process_name: %s\n", info.process_name); + printf("memory_start: 0x%.8" PRIx32 "\n", info.memory_start); + printf("used_memory: %u (0x%x)\n", info.used_memory, + info.used_memory); + printf("pid: %u\n", info.pid); + printf("box: %u %u %u %u\n", info.box.left, info.box.top, + info.box.width, info.box.height); + printf("slot_state: %u\n", info.slot_state); + printf("client_box: %u %u %u %u\n", info.client_box.left, + info.client_box.top, info.client_box.width, info.client_box.height); + printf("wnd_state: 0x%.2" PRIx8 "\n", info.wnd_state); } static void cmd_display_number(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: display_number " " " @@ -1056,9 +1074,9 @@ cmd_display_number(struct shell_ctx *ctx, int argc, char **argv) { " font 0 = 6x9, 1 = 8x16\n" " draw_to_buf 0/1\n" " scale_factor 0 = x1, ..., 7 = x8\n" - " bg_color_or_buf depending on flags fill_bg and draw_to_buf\n"; + " bg_color_or_buf depending on flags fill_bg and draw_to_buf"; if (argc != 15) { - fputs(usage, ctx->fout); + puts(usage); return; } int is_pointer = strtoul(argv[1], NULL, 0); @@ -1089,13 +1107,14 @@ cmd_display_number(struct shell_ctx *ctx, int argc, char **argv) { static void cmd_set_window_colors(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: set_window_colors " " " " \n" - " * all colors are in hex\n"; + " * all colors are in hex"; if (argc != (1 + sizeof(system_colors_t)/4)) { - fputs(usage, ctx->fout); + puts(usage); return; } system_colors_t colors; @@ -1116,75 +1135,79 @@ cmd_set_window_colors(struct shell_ctx *ctx, int argc, char **argv) { static void cmd_get_window_colors(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; + (void)argv; const char *usage = \ - "usage: get_window_colors\n"; + "usage: get_window_colors"; if (argc != 1) { - fputs(usage, ctx->fout); + puts(usage); return; } - (void)argv; system_colors_t colors; memset(&colors, 0xaa, sizeof(colors)); COVERAGE_ON(); umka_sys_get_window_colors(&colors); COVERAGE_OFF(); - fprintf(ctx->fout, "0x%.8" PRIx32 " frame\n", colors.frame); - fprintf(ctx->fout, "0x%.8" PRIx32 " grab\n", colors.grab); - fprintf(ctx->fout, "0x%.8" PRIx32 " work_3d_dark\n", colors.work_3d_dark); - fprintf(ctx->fout, "0x%.8" PRIx32 " work_3d_light\n", colors.work_3d_light); - fprintf(ctx->fout, "0x%.8" PRIx32 " grab_text\n", colors.grab_text); - fprintf(ctx->fout, "0x%.8" PRIx32 " work\n", colors.work); - fprintf(ctx->fout, "0x%.8" PRIx32 " work_button\n", colors.work_button); - fprintf(ctx->fout, "0x%.8" PRIx32 " work_button_text\n", - colors.work_button_text); - fprintf(ctx->fout, "0x%.8" PRIx32 " work_text\n", colors.work_text); - fprintf(ctx->fout, "0x%.8" PRIx32 " work_graph\n", colors.work_graph); + printf("0x%.8" PRIx32 " frame\n", colors.frame); + printf("0x%.8" PRIx32 " grab\n", colors.grab); + printf("0x%.8" PRIx32 " work_3d_dark\n", colors.work_3d_dark); + printf("0x%.8" PRIx32 " work_3d_light\n", colors.work_3d_light); + printf("0x%.8" PRIx32 " grab_text\n", colors.grab_text); + printf("0x%.8" PRIx32 " work\n", colors.work); + printf("0x%.8" PRIx32 " work_button\n", colors.work_button); + printf("0x%.8" PRIx32 " work_button_text\n", + colors.work_button_text); + printf("0x%.8" PRIx32 " work_text\n", colors.work_text); + printf("0x%.8" PRIx32 " work_graph\n", colors.work_graph); } static void cmd_get_skin_height(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; + (void)argv; const char *usage = \ - "usage: get_skin_height\n"; + "usage: get_skin_height"; if (argc != 1) { - fputs(usage, ctx->fout); + puts(usage); return; } - (void)argv; COVERAGE_ON(); uint32_t skin_height = umka_sys_get_skin_height(); COVERAGE_OFF(); - fprintf(ctx->fout, "%" PRIu32 "\n", skin_height); + printf("%" PRIu32 "\n", skin_height); } static void cmd_get_screen_area(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; + (void)argv; const char *usage = \ - "usage: get_screen_area\n"; + "usage: get_screen_area"; if (argc != 1) { - fputs(usage, ctx->fout); + puts(usage); return; } - (void)argv; rect_t wa; COVERAGE_ON(); umka_sys_get_screen_area(&wa); COVERAGE_OFF(); - fprintf(ctx->fout, "%" PRIu32 " left\n", wa.left); - fprintf(ctx->fout, "%" PRIu32 " top\n", wa.top); - fprintf(ctx->fout, "%" PRIu32 " right\n", wa.right); - fprintf(ctx->fout, "%" PRIu32 " bottom\n", wa.bottom); + printf("%" PRIu32 " left\n", wa.left); + printf("%" PRIu32 " top\n", wa.top); + printf("%" PRIu32 " right\n", wa.right); + printf("%" PRIu32 " bottom\n", wa.bottom); } static void cmd_set_screen_area(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: set_screen_area \n" " left left x coord\n" " top top y coord\n" " right right x coord (not length!)\n" - " bottom bottom y coord\n"; + " bottom bottom y coord"; if (argc != 5) { - fputs(usage, ctx->fout); + puts(usage); return; } rect_t wa; @@ -1199,30 +1222,32 @@ cmd_set_screen_area(struct shell_ctx *ctx, int argc, char **argv) { static void cmd_get_skin_margins(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; + (void)argv; const char *usage = \ - "usage: get_skin_margins\n"; + "usage: get_skin_margins"; if (argc != 1) { - fputs(usage, ctx->fout); + puts(usage); return; } - (void)argv; rect_t wa; COVERAGE_ON(); umka_sys_get_skin_margins(&wa); COVERAGE_OFF(); - fprintf(ctx->fout, "%" PRIu32 " left\n", wa.left); - fprintf(ctx->fout, "%" PRIu32 " top\n", wa.top); - fprintf(ctx->fout, "%" PRIu32 " right\n", wa.right); - fprintf(ctx->fout, "%" PRIu32 " bottom\n", wa.bottom); + printf("%" PRIu32 " left\n", wa.left); + printf("%" PRIu32 " top\n", wa.top); + printf("%" PRIu32 " right\n", wa.right); + printf("%" PRIu32 " bottom\n", wa.bottom); } static void cmd_set_button_style(struct shell_ctx *ctx, int argc, char **argv) { + (void)ctx; const char *usage = \ "usage: set_button_style