links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: c8829818690bb9ca9c59a17e7e164c779c1f14ff
Parent: 3ae103d2de295de287a6c2327f073f6dfd265fd0
Author: opask
Date:   Tue, 21 Aug 2018 22:50:40 -0600

simplification: drivers.c

Diffstat:
Mdrivers.c | 46++++++++++++++++++++--------------------------
Mkbd.c | 3---
Mlinks.h | 7-------
Mmenu.c | 17++---------------
Mos_dep.c | 3---
Mx.c | 7+------
6 files changed, 23 insertions(+), 60 deletions(-)

diff --git a/drivers.c b/drivers.c @@ -28,13 +28,14 @@ static unsigned char *init_graphics_driver(struct graphics_driver *gd, unsigned unsigned char *r; unsigned char *p = param; struct driver_param *dp = get_driver_param(gd->name); - if (!param || !*param) p = dp->param; + if (!param || !*param) + p = dp->param; gd->kbd_codepage = dp->kbd_codepage; gd->shell = mem_calloc(MAX_STR_LEN); - if (dp->shell) safe_strncpy(gd->shell, dp->shell, MAX_STR_LEN); + if (dp->shell) + safe_strncpy(gd->shell, dp->shell, MAX_STR_LEN); drv = gd; - r = gd->init_driver(p,display); - if (r) { + if ((r = gd->init_driver(p, display))) { free(gd->shell); gd->shell = NULL; drv = NULL; @@ -46,35 +47,28 @@ static unsigned char *init_graphics_driver(struct graphics_driver *gd, unsigned void add_graphics_drivers(unsigned char **s, int *l) { - struct graphics_driver **gd; - for (gd = graphics_drivers; *gd; gd++) { - if (gd != graphics_drivers) add_to_str(s, l, cast_uchar ", "); - add_to_str(s, l, (*gd)->name); - } + add_to_str(s, l, graphics_drivers[0]->name); } unsigned char *init_graphics(unsigned char *driver, unsigned char *param, unsigned char *display) { unsigned char *s = init_str(); int l = 0; - struct graphics_driver **gd; - for (gd = graphics_drivers; *gd; gd++) { - if (!driver || !*driver || !casestrcmp((*gd)->name, driver)) { - unsigned char *r; - if ((!driver || !*driver) && (*gd)->flags & GD_NOAUTO) continue; - if (!(r = init_graphics_driver(*gd, param, display))) { - free(s); - return NULL; - } - if (!l) { - if (!driver || !*driver) add_to_str(&s, &l, cast_uchar "Could not initialize any graphics driver. Tried the following drivers:\n"); - else add_to_str(&s, &l, cast_uchar "Could not initialize graphics driver "); - } - add_to_str(&s, &l, (*gd)->name); - add_to_str(&s, &l, cast_uchar ":\n"); - add_to_str(&s, &l, r); - free(r); + struct graphics_driver **gd = graphics_drivers; + if (!driver || !*driver || !casestrcmp((*gd)->name, driver)) { + unsigned char *r; + if (!(r = init_graphics_driver(*gd, param, display))) { + free(s); + return NULL; } + if (!driver || !*driver) + add_to_str(&s, &l, cast_uchar "Could not initialize any graphics driver. Tried the following drivers:\n"); + else + add_to_str(&s, &l, cast_uchar "Could not initialize graphics driver "); + add_to_str(&s, &l, (*gd)->name); + add_to_str(&s, &l, cast_uchar ":\n"); + add_to_str(&s, &l, r); + free(r); } if (!l) { add_to_str(&s, &l, cast_uchar "Unknown graphics driver "); diff --git a/kbd.c b/kbd.c @@ -396,9 +396,6 @@ static void free_trm(struct itrm *itrm) void fatal_tty_exit(void) { if (ditrm) setcooked(ditrm->ctl_in); -#ifdef G - if (drv && drv->emergency_shutdown) drv->emergency_shutdown(); -#endif } static void resize_terminal_x(unsigned char *text) diff --git a/links.h b/links.h @@ -1099,16 +1099,9 @@ struct graphics_driver { void (*shutdown_driver)(void); - void (*emergency_shutdown)(void); - - void (*after_fork)(void); - unsigned char *(*get_driver_param)(void); /* returns allocated string with parameter given to init_driver function */ unsigned char *(*get_af_unix_name)(void); - void (*get_margin)(int *left, int *right, int *top, int *bottom); - int (*set_margin)(int left, int right, int top, int bottom); - /* dest must have x and y filled in when get_empty_bitmap is called */ int (*get_empty_bitmap)(struct bitmap *dest); diff --git a/menu.c b/menu.c @@ -646,11 +646,6 @@ static void margins_ok(void *xxx) ts->top_margin = top; ts->bottom_margin = bottom; cls_redraw_all_terminals(); -#ifdef G - } else { - if (drv->set_margin(left, right, top, bottom)) - goto error; -#endif } return; @@ -680,16 +675,12 @@ static void screen_margins(struct terminal *term, void *xxx, void *ses_) struct term_spec *ts = term->spec; int string_len = !F ? 4 : 5; int max_value = !F ? 999 : 9999; - int l, r, t, b; + int l = 0, r = 0, t = 0, b = 0; if (!F) { l = ts->left_margin; r = ts->right_margin; t = ts->top_margin; b = ts->bottom_margin; -#ifdef G - } else { - drv->get_margin(&l, &r, &t, &b); -#endif } snprint(left_margin_str, string_len, l); snprint(right_margin_str, string_len, r); @@ -3010,11 +3001,7 @@ static void do_setup_menu(struct terminal *term, void *xxx, void *ses_) e += sizeof(setup_menu_3) / sizeof(struct menu_item); #endif } - if (!F -#ifdef G - || (drv->get_margin && drv->set_margin) -#endif - ) { + if (!F) { memcpy(e, setup_menu_4, sizeof(setup_menu_4)); e += sizeof(setup_menu_4) / sizeof(struct menu_item); } diff --git a/os_dep.c b/os_dep.c @@ -294,9 +294,6 @@ void close_fork_tty(void) EINTRLOOP(rs, close(signal_pipe[0])); EINTRLOOP(rs, close(signal_pipe[1])); #endif -#ifdef G - if (drv && drv->after_fork) drv->after_fork(); -#endif if (terminal_pipe[1] != -1) EINTRLOOP(rs, close(terminal_pipe[1])); foreach(struct terminal, t, lt, terminals) { if (t->fdin > 0) diff --git a/x.c b/x.c @@ -510,8 +510,7 @@ static void x_free_hash_table(void) for (a = 0; a < X_HASH_TABLE_SIZE; a++) { for (b = 0; b < x_hash_table[a].count; b++) free(x_hash_table[a].pointer[b]); - if (x_hash_table[a].pointer) - free(x_hash_table[a].pointer); + free(x_hash_table[a].pointer); } x_clear_clipboard(); @@ -2124,12 +2123,8 @@ struct graphics_driver x_driver = { x_init_device, x_shutdown_device, x_shutdown_driver, - NULL, - NULL, x_get_driver_param, x_get_af_unix_name, - NULL, - NULL, x_get_empty_bitmap, x_register_bitmap, x_prepare_strip,