aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Gladkov <gladkov.alexey@gmail.com>2022-01-27 18:39:30 +0100
committerAlexey Gladkov <gladkov.alexey@gmail.com>2022-03-20 14:17:48 +0100
commit1f567a60e346d1af6bebf0a2d167298cdba46b90 (patch)
treef88ffb4553f2e81d6a19da979a369add328cf346
parentef3b76e0a9fb094632f1d7414363ec342e88b0ac (diff)
downloadkbd-1f567a60e346d1af6bebf0a2d167298cdba46b90.tar.gz
kfont: Тake the verbose parameter into account when logging messages
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
-rw-r--r--src/libkfont/context.c10
-rw-r--r--src/libkfont/loadunimap.c14
-rw-r--r--src/libkfont/mapscrn.c21
-rw-r--r--src/libkfont/setfont.c42
4 files changed, 42 insertions, 45 deletions
diff --git a/src/libkfont/context.c b/src/libkfont/context.c
index 11bf61b6..93efbe73 100644
--- a/src/libkfont/context.c
+++ b/src/libkfont/context.c
@@ -101,6 +101,16 @@ logger(struct kfont_context *ctx, int priority, const char *file,
va_list args;
if (ctx->log_fn == NULL)
return;
+ switch(ctx->verbose) {
+ case 0:
+ if (priority > LOG_ERR)
+ return;
+ break;
+ case 1:
+ if (priority > LOG_INFO)
+ return;
+ break;
+ }
va_start(args, fmt);
ctx->log_fn(ctx, priority, file, line, fn, fmt, args);
va_end(args);
diff --git a/src/libkfont/loadunimap.c b/src/libkfont/loadunimap.c
index bb60c898..a9505adf 100644
--- a/src/libkfont/loadunimap.c
+++ b/src/libkfont/loadunimap.c
@@ -263,8 +263,7 @@ kfont_load_unicodemap(struct kfont_context *ctx, int fd, const char *tblname)
goto err;
}
- if (ctx->verbose)
- KFONT_INFO(ctx, _("Loading unicode map from file %s"), kbdfile_get_pathname(fp));
+ KFONT_INFO(ctx, _("Loading unicode map from file %s"), kbdfile_get_pathname(fp));
while (fgets(buffer, sizeof(buffer), kbdfile_get_file(fp)) != NULL) {
if ((p = strchr(buffer, '\n')) != NULL)
@@ -300,9 +299,8 @@ getunicodemap(struct kfont_context *ctx, int fd, struct unimapdesc *unimap_descr
if (kfont_get_unicodemap(ctx, fd, unimap_descr))
return -1;
- if (ctx->verbose)
- KFONT_INFO(ctx, P_("# %d entry", "# %d entries", unimap_descr->entry_ct),
- unimap_descr->entry_ct);
+ KFONT_INFO(ctx, P_("# %d entry", "# %d entries", unimap_descr->entry_ct),
+ unimap_descr->entry_ct);
return 0;
}
@@ -328,8 +326,7 @@ kfont_save_unicodemap(struct kfont_context *ctx, int consolefd,
for (i = 0; i < unimap_descr.entry_ct; i++)
fprintf(fpo, "0x%02x\tU+%04x\n", unilist[i].fontpos, unilist[i].unicode);
- if (ctx->verbose)
- KFONT_INFO(ctx, _("Saved unicode map on `%s'"), filename);
+ KFONT_INFO(ctx, _("Saved unicode map on `%s'"), filename);
end:
fclose(fpo);
return ret;
@@ -378,8 +375,7 @@ appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp,
if (ctx->verbose > 1)
printf("\n");
- if (ctx->verbose)
- KFONT_INFO(ctx, _("Appended Unicode map"));
+ KFONT_INFO(ctx, _("Appended Unicode map"));
return 0;
}
diff --git a/src/libkfont/mapscrn.c b/src/libkfont/mapscrn.c
index 682691af..7f0ae885 100644
--- a/src/libkfont/mapscrn.c
+++ b/src/libkfont/mapscrn.c
@@ -105,10 +105,9 @@ readnewmapfromfile(struct kfont_context *ctx, const char *mfil,
}
if (stbuf.st_size == E_TABSZ) {
- if (ctx->verbose)
- KFONT_INFO(ctx,
- _("Loading binary direct-to-font screen map from file %s"),
- kbdfile_get_pathname(fp));
+ KFONT_INFO(ctx,
+ _("Loading binary direct-to-font screen map from file %s"),
+ kbdfile_get_pathname(fp));
if (fread(buf, E_TABSZ, 1, kbdfile_get_file(fp)) != 1) {
KFONT_ERR(ctx, _("Error reading map from file `%s'"),
@@ -117,10 +116,9 @@ readnewmapfromfile(struct kfont_context *ctx, const char *mfil,
goto end;
}
} else if (stbuf.st_size == 2 * E_TABSZ) {
- if (ctx->verbose)
- KFONT_INFO(ctx,
- _("Loading binary unicode screen map from file %s"),
- kbdfile_get_pathname(fp));
+ KFONT_INFO(ctx,
+ _("Loading binary unicode screen map from file %s"),
+ kbdfile_get_pathname(fp));
if (fread(ubuf, 2 * E_TABSZ, 1, kbdfile_get_file(fp)) != 1) {
KFONT_ERR(ctx,
@@ -131,9 +129,8 @@ readnewmapfromfile(struct kfont_context *ctx, const char *mfil,
}
ret = 1;
} else {
- if (ctx->verbose)
- KFONT_INFO(ctx, _("Loading symbolic screen map from file %s"),
- kbdfile_get_pathname(fp));
+ KFONT_INFO(ctx, _("Loading symbolic screen map from file %s"),
+ kbdfile_get_pathname(fp));
if (parsemap(kbdfile_get_file(fp), buf, ubuf, &ret, &lineno)) {
KFONT_ERR(ctx,
@@ -267,7 +264,7 @@ kfont_save_consolemap(struct kfont_context *ctx, int fd, const char *omfil)
ret = -1;
}
- if (!ret && ctx->verbose)
+ if (!ret)
KFONT_INFO(ctx, _("Saved screen map in `%s'"), omfil);
fclose(fp);
diff --git a/src/libkfont/setfont.c b/src/libkfont/setfont.c
index d48f37f6..9a0bb72c 100644
--- a/src/libkfont/setfont.c
+++ b/src/libkfont/setfont.c
@@ -156,20 +156,18 @@ do_loadfont(struct kfont_context *ctx, int fd, const unsigned char *inbuf,
}
}
- if (ctx->verbose) {
- if (height == hwunit && filename)
- KFONT_INFO(ctx, _("Loading %d-char %dx%d font from file %s"),
- fontsize, width, height, filename);
- else if (height == hwunit)
- KFONT_INFO(ctx, _("Loading %d-char %dx%d font"),
- fontsize, width, height);
- else if (filename)
- KFONT_INFO(ctx, _("Loading %d-char %dx%d (%d) font from file %s"),
- fontsize, width, height, hwunit, filename);
- else
- KFONT_INFO(ctx, _("Loading %d-char %dx%d (%d) font"),
- fontsize, width, height, hwunit);
- }
+ if (height == hwunit && filename)
+ KFONT_INFO(ctx, _("Loading %d-char %dx%d font from file %s"),
+ fontsize, width, height, filename);
+ else if (height == hwunit)
+ KFONT_INFO(ctx, _("Loading %d-char %dx%d font"),
+ fontsize, width, height);
+ else if (filename)
+ KFONT_INFO(ctx, _("Loading %d-char %dx%d (%d) font from file %s"),
+ fontsize, width, height, hwunit, filename);
+ else
+ KFONT_INFO(ctx, _("Loading %d-char %dx%d (%d) font"),
+ fontsize, width, height, hwunit);
if (kfont_put_font(ctx, fd, buf, fontsize, width, hwunit) < 0) {
ret = -EX_OSERR;
@@ -244,8 +242,7 @@ do_loadtable(struct kfont_context *ctx, int fd, struct unicode_list *uclistheads
goto err;
}
- if (ctx->verbose)
- KFONT_INFO(ctx, _("Loading Unicode mapping table..."));
+ KFONT_INFO(ctx, _("Loading Unicode mapping table..."));
ud.entry_ct = ct;
ud.entries = up;
@@ -319,9 +316,8 @@ kfont_load_fonts(struct kfont_context *ctx,
bytewidth = (width + 7) / 8;
height = fontbuflth / (bytewidth * fontsize);
- if (ctx->verbose)
- KFONT_INFO(ctx, _("Read %d-char %dx%d font from file %s"),
- fontsize, width, height, kbdfile_get_pathname(fp));
+ KFONT_INFO(ctx, _("Read %d-char %dx%d font from file %s"),
+ fontsize, width, height, kbdfile_get_pathname(fp));
kbdfile_free(fp); // avoid zombies, jw@suse.de (#88501)
fp = NULL;
@@ -632,11 +628,9 @@ save_font(struct kfont_context *ctx, int consolefd, const char *filename,
return -EX_IOERR;
}
}
- if (ctx->verbose) {
- KFONT_INFO(ctx,
- _("Saved %d-char %dx%d font file on %s"),
- ct, width, height, filename);
- }
+ KFONT_INFO(ctx,
+ _("Saved %d-char %dx%d font file on %s"),
+ ct, width, height, filename);
}
if (count)