aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Gladkov <gladkov.alexey@gmail.com>2020-04-13 01:35:28 +0200
committerAlexey Gladkov <gladkov.alexey@gmail.com>2020-04-13 01:35:28 +0200
commitb568f18911efb1d2eb7b734ba5a3731d112a90af (patch)
treef8d4422d71fbc21d569b0db92da5a18a2a920054
parent46d0ebd9346497d391c8e594b9deb1682a7db0ff (diff)
downloadkbd-b568f18911efb1d2eb7b734ba5a3731d112a90af.tar.gz
Add verbose field into kfont_context
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
-rw-r--r--src/clrunimap.c1
-rw-r--r--src/context.h1
-rw-r--r--src/getunimap.c1
-rw-r--r--src/loadunimap.c15
-rw-r--r--src/mapscrn.c24
-rw-r--r--src/paths.h3
-rw-r--r--src/psffontop.c2
-rw-r--r--src/psfxtable.c1
-rw-r--r--src/readpsfheader.c4
-rw-r--r--src/setfont.c37
-rw-r--r--src/showconsolefont.c19
11 files changed, 52 insertions, 56 deletions
diff --git a/src/clrunimap.c b/src/clrunimap.c
index a05479de..2f4b1843 100644
--- a/src/clrunimap.c
+++ b/src/clrunimap.c
@@ -30,6 +30,7 @@ int main(int argc, char *argv[])
struct kfont_context ctx = {
.progname = get_progname(),
+ .verbose = 0,
.log_fn = kfont_log_stderr,
};
diff --git a/src/context.h b/src/context.h
index be03c85c..f1c02307 100644
--- a/src/context.h
+++ b/src/context.h
@@ -15,6 +15,7 @@ typedef void (*kfont_logger_t)(struct kfont_context *, int, const char *, int,
struct kfont_context {
const char *progname;
+ int verbose;
kfont_logger_t log_fn;
};
diff --git a/src/getunimap.c b/src/getunimap.c
index a814873b..1eaeef94 100644
--- a/src/getunimap.c
+++ b/src/getunimap.c
@@ -71,6 +71,7 @@ int main(int argc, char **argv)
struct kfont_context ctx = {
.progname = get_progname(),
+ .verbose = 0,
.log_fn = kfont_log_stderr,
};
diff --git a/src/loadunimap.c b/src/loadunimap.c
index 8341dd52..a95c3c6c 100644
--- a/src/loadunimap.c
+++ b/src/loadunimap.c
@@ -42,9 +42,7 @@ static const char *const unisuffixes[] = {
};
#ifdef MAIN
-int verbose = 0;
int force = 0;
-int debug = 0;
static void __attribute__((noreturn))
usage(void)
@@ -89,6 +87,7 @@ int main(int argc, char *argv[])
struct kfont_context ctx = {
.progname = get_progname(),
+ .verbose = 0,
.log_fn = kfont_log_stderr,
};
@@ -312,7 +311,7 @@ loadunicodemap(struct kfont_context *ctx, int fd, const char *tblname)
goto err;
}
- if (verbose)
+ if (ctx->verbose)
KFONT_INFO(ctx, _("Loading unicode map from file %s"), kbdfile_get_pathname(fp));
while (fgets(buffer, sizeof(buffer), kbdfile_get_file(fp)) != NULL) {
@@ -377,7 +376,7 @@ saveunicodemap(struct kfont_context *ctx, int fd, char *oufil)
fprintf(fpo, "0x%02x\tU+%04x\n", unilist[i].fontpos, unilist[i].unicode);
fclose(fpo);
- if (verbose)
+ if (ctx->verbose)
KFONT_INFO(ctx, _("Saved unicode map on `%s'"), oufil);
return 0;
@@ -407,12 +406,12 @@ appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp,
if (no > 1)
appendseparator(fp, 1, utf8);
#endif
- if (debug)
+ if (ctx->verbose > 1)
printf("\nchar %03x: ", i);
for (j = 0; j < unimap_descr.entry_ct; j++) {
if (unilist[j].fontpos == i) {
- if (debug)
+ if (ctx->verbose > 1)
printf("%04x ", unilist[j].unicode);
if ((ret = appendunicode(ctx,fp, unilist[j].unicode, utf8)) < 0)
return ret;
@@ -423,10 +422,10 @@ appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp,
return ret;
}
- if (debug)
+ if (ctx->verbose > 1)
printf("\n");
- if (verbose)
+ if (ctx->verbose)
KFONT_INFO(ctx, _("Appended Unicode map"));
return 0;
diff --git a/src/mapscrn.c b/src/mapscrn.c
index 27a6dc3d..d9973b7e 100644
--- a/src/mapscrn.c
+++ b/src/mapscrn.c
@@ -39,13 +39,16 @@ static const char *const mapsuffixes[] = {
};
#ifdef MAIN
-int verbose = 0;
-int debug = 0;
-
int main(int argc, char *argv[])
{
int fd, ret;
+ struct kfont_context ctx = {
+ .progname = get_progname(),
+ .verbose = 0,
+ .log_fn = kfont_log_stderr,
+ };
+
set_progname(argv[0]);
setuplocale();
@@ -53,7 +56,7 @@ int main(int argc, char *argv[])
print_version_and_exit();
if (argc > 1 && !strcmp(argv[1], "-v")) {
- verbose = 1;
+ ctx.verbose++;
argc--;
argv++;
}
@@ -61,11 +64,6 @@ int main(int argc, char *argv[])
if ((fd = getfd(NULL)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
- struct kfont_context ctx = {
- .progname = get_progname(),
- .log_fn = kfont_log_stderr,
- };
-
if (argc >= 3 && !strcmp(argv[1], "-o")) {
ret = saveoldmap(&ctx, fd, argv[2]);
if (ret < 0)
@@ -164,7 +162,7 @@ readnewmapfromfile(struct kfont_context *ctx, const char *mfil,
}
if (stbuf.st_size == E_TABSZ) {
- if (verbose)
+ if (ctx->verbose)
KFONT_INFO(ctx,
_("Loading binary direct-to-font screen map from file %s"),
kbdfile_get_pathname(fp));
@@ -175,7 +173,7 @@ readnewmapfromfile(struct kfont_context *ctx, const char *mfil,
return -EX_IOERR;
}
} else if (stbuf.st_size == 2 * E_TABSZ) {
- if (verbose)
+ if (ctx->verbose)
KFONT_INFO(ctx,
_("Loading binary unicode screen map from file %s"),
kbdfile_get_pathname(fp));
@@ -188,7 +186,7 @@ readnewmapfromfile(struct kfont_context *ctx, const char *mfil,
}
u = 1;
} else {
- if (verbose)
+ if (ctx->verbose)
KFONT_INFO(ctx, _("Loading symbolic screen map from file %s"),
kbdfile_get_pathname(fp));
@@ -323,7 +321,7 @@ saveoldmap(struct kfont_context *ctx, int fd, const char *omfil)
fclose(fp);
- if (verbose)
+ if (ctx->verbose)
KFONT_INFO(ctx, _("Saved screen map in `%s'"), omfil);
return 0;
diff --git a/src/paths.h b/src/paths.h
index 51093939..66830e24 100644
--- a/src/paths.h
+++ b/src/paths.h
@@ -25,7 +25,4 @@
#define KERNDIR "/usr/src/linux/drivers/tty/vt"
#endif
-extern int verbose;
-extern int debug;
-
#endif /* _PATHS_H */
diff --git a/src/psffontop.c b/src/psffontop.c
index be2e3a51..d5248990 100644
--- a/src/psffontop.c
+++ b/src/psffontop.c
@@ -356,7 +356,7 @@ appendunicode(struct kfont_context *ctx, FILE *fp, int u, int utf8)
KFONT_ERR(ctx, "appendunimap: %m");
return -EX_IOERR;
}
- if (debug) {
+ if (ctx->verbose > 0) {
printf("(");
if (!utf8)
printf("U+");
diff --git a/src/psfxtable.c b/src/psfxtable.c
index 141a6c45..b46241e1 100644
--- a/src/psfxtable.c
+++ b/src/psfxtable.c
@@ -246,6 +246,7 @@ int main(int argc, char **argv)
struct kfont_context ctx = {
.progname = get_progname(),
+ .verbose = 0,
.log_fn = kfont_log_stderr,
};
diff --git a/src/readpsfheader.c b/src/readpsfheader.c
index aa6de398..858d5085 100644
--- a/src/readpsfheader.c
+++ b/src/readpsfheader.c
@@ -6,9 +6,6 @@
#include "libcommon.h"
#include "kfont.h"
-int verbose = 0;
-int debug = 0;
-
static void __attribute__((noreturn))
usage(void)
{
@@ -38,6 +35,7 @@ int main(int argc, char **argv)
struct kfont_context ctx = {
.progname = get_progname(),
+ .verbose = 0,
.log_fn = kfont_log_stderr,
};
diff --git a/src/setfont.c b/src/setfont.c
index 3b29fa7c..55c95468 100644
--- a/src/setfont.c
+++ b/src/setfont.c
@@ -45,9 +45,7 @@ static int loadnewfonts(struct kfont_context *ctx,
static void activatemap(int fd);
static void disactivatemap(int fd);
-int verbose = 0;
int force = 0;
-int debug = 0;
int double_size = 0;
/* search for the font in these directories (with trailing /) */
@@ -133,6 +131,12 @@ int main(int argc, char *argv[])
set_progname(argv[0]);
setuplocale();
+ struct kfont_context ctx = {
+ .progname = get_progname(),
+ .verbose = 0,
+ .log_fn = kfont_log_stderr,
+ };
+
ifiles[0] = mfil = ufil = Ofil = ofil = omfil = oufil = NULL;
iunit = hwunit = 0;
no_m = no_u = 0;
@@ -145,7 +149,7 @@ int main(int argc, char *argv[])
if (!strcmp(argv[i], "-V")) {
print_version_and_exit();
} else if (!strcmp(argv[i], "-v")) {
- verbose++;
+ ctx.verbose++;
} else if (!strcmp(argv[i], "-R")) {
restore = 1;
} else if (!strcmp(argv[i], "-C")) {
@@ -220,17 +224,12 @@ int main(int argc, char *argv[])
* PIO_FONT will fail on a console which is in foreground and in KD_GRAPHICS mode.
* 2005-03-03, jw@suse.de.
*/
- if (verbose)
+ if (ctx.verbose)
printf("setfont: graphics console %s skipped\n", console ? console : "");
close(fd);
return 0;
}
- struct kfont_context ctx = {
- .progname = get_progname(),
- .log_fn = kfont_log_stderr,
- };
-
if (!ifilct && !mfil && !ufil &&
!Ofil && !ofil && !omfil && !oufil && !restore)
/* reset to some default */
@@ -386,7 +385,7 @@ do_loadfont(struct kfont_context *ctx, int fd, const unsigned char *inbuf,
}
}
- if (verbose) {
+ if (ctx->verbose) {
if (height == hwunit && filename)
KFONT_INFO(ctx, _("Loading %d-char %dx%d font from file %s"),
fontsize, width, height, filename);
@@ -442,7 +441,7 @@ do_loadtable(struct kfont_context *ctx, int fd, struct unicode_list *uclistheads
for (i = 0; i < fontsize; i++) {
ul = uclistheads[i].next;
- if (debug)
+ if (ctx->verbose > 1)
printf("char %03x:", i);
while (ul) {
us = ul->seq;
@@ -450,9 +449,9 @@ do_loadtable(struct kfont_context *ctx, int fd, struct unicode_list *uclistheads
up[ct].unicode = us->uc;
up[ct].fontpos = i;
ct++;
- if (debug)
+ if (ctx->verbose > 1)
printf(" %04x", us->uc);
- } else if (debug) {
+ } else if (ctx->verbose > 1) {
printf(" seq: <");
while (us) {
printf(" %04x", us->uc);
@@ -461,10 +460,10 @@ do_loadtable(struct kfont_context *ctx, int fd, struct unicode_list *uclistheads
printf(" >");
}
ul = ul->next;
- if (debug)
+ if (ctx->verbose > 1)
printf(",");
}
- if (debug)
+ if (ctx->verbose > 1)
printf("\n");
}
@@ -474,7 +473,7 @@ do_loadtable(struct kfont_context *ctx, int fd, struct unicode_list *uclistheads
goto err;
}
- if (verbose)
+ if (ctx->verbose)
KFONT_INFO(ctx, _("Loading Unicode mapping table..."));
ud.entry_ct = ct;
@@ -549,7 +548,7 @@ loadnewfonts(struct kfont_context *ctx,
bytewidth = (width + 7) / 8;
height = fontbuflth / (bytewidth * fontsize);
- if (verbose)
+ if (ctx->verbose)
KFONT_INFO(ctx, _("Read %d-char %dx%d font from file %s"),
fontsize, width, height, kbdfile_get_pathname(fp));
@@ -654,7 +653,7 @@ loadnewfont(struct kfont_context *ctx, int fd, const char *ifil,
}
}
- if (verbose > 1)
+ if (ctx->verbose > 1)
KFONT_INFO(ctx, _("Reading font file %s"), ifil);
inbuf = fontbuf = NULL;
@@ -863,7 +862,7 @@ do_saveoldfont(struct kfont_context *ctx,
return -EX_IOERR;
}
}
- if (verbose) {
+ if (ctx->verbose) {
KFONT_INFO(ctx,
_("Saved %d-char %dx%d font file on %s"),
ct, width, height, ofil);
diff --git a/src/showconsolefont.c b/src/showconsolefont.c
index 104f9b1b..a56fd18a 100644
--- a/src/showconsolefont.c
+++ b/src/showconsolefont.c
@@ -123,11 +123,17 @@ int main(int argc, char **argv)
int mode;
const char *space, *sep;
char *console = NULL;
- int list[64], lth, info = 0, verbose = 0;
+ int list[64], lth, info = 0;
set_progname(argv[0]);
setuplocale();
+ struct kfont_context ctx = {
+ .progname = get_progname(),
+ .verbose = 0,
+ .log_fn = kfont_log_stderr,
+ };
+
if (argc == 2 &&
(!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")))
print_version_and_exit();
@@ -138,7 +144,7 @@ int main(int argc, char **argv)
info = 1;
break;
case 'v':
- verbose = 1;
+ ctx.verbose++;
break;
case 'C':
console = optarg;
@@ -151,11 +157,6 @@ int main(int argc, char **argv)
if (optind != argc)
usage();
- struct kfont_context ctx = {
- .progname = get_progname(),
- .log_fn = kfont_log_stderr,
- };
-
if ((fd = getfd(console)) < 0)
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
@@ -175,7 +176,7 @@ int main(int argc, char **argv)
if (n != 0)
leave(&ctx, EXIT_FAILURE);
- if (verbose) {
+ if (ctx.verbose) {
printf(_("Character count: %u\n"), nr);
printf(_("Font width : %u\n"), rows);
printf(_("Font height : %u\n"), cols);
@@ -188,7 +189,7 @@ int main(int argc, char **argv)
getoldunicodemap(&ctx);
n = getfontsize(&ctx, fd);
- if (verbose)
+ if (ctx.verbose)
printf(_("Showing %d-char font\n\n"), n);
cols = ((n > 256) ? 32 : 16);
nr = 64 / cols;