diff options
author | Alexey Gladkov <gladkov.alexey@gmail.com> | 2020-04-17 18:34:54 +0200 |
---|---|---|
committer | Alexey Gladkov <gladkov.alexey@gmail.com> | 2020-04-17 18:34:54 +0200 |
commit | ff85ca04a563229be40bc2f0874f3a8fe8c557eb (patch) | |
tree | 269fa75f4eb0c8b411e488cc41301b0b2fec5f00 | |
parent | ea2ac448f3d5ff30ac55ff70e0cc8f0db3006a8f (diff) | |
download | kbd-ff85ca04a563229be40bc2f0874f3a8fe8c557eb.tar.gz |
Replace kfont_saveoldfont and kfont_saveoldfontplusunicodemap by kfont_save_font
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
-rw-r--r-- | src/libkfont/kfont.h | 7 | ||||
-rw-r--r-- | src/libkfont/libkfont.map | 3 | ||||
-rw-r--r-- | src/libkfont/setfont.c | 39 | ||||
-rw-r--r-- | src/setfont.c | 4 |
4 files changed, 19 insertions, 34 deletions
diff --git a/src/libkfont/kfont.h b/src/libkfont/kfont.h index 911e4de8..46a76857 100644 --- a/src/libkfont/kfont.h +++ b/src/libkfont/kfont.h @@ -208,11 +208,10 @@ int kfont_loadunimap(struct kfont_context *ctx, int fd, struct unimapinit *ui, __attribute__((nonnull(1))); /* setfont.c */ -int kfont_saveoldfontplusunicodemap(struct kfont_context *ctx, int fd, const char *Ofil) - __attribute__((nonnull(1))); -int kfont_saveoldfont(struct kfont_context *ctx, int fd, const char *ofil) - __attribute__((nonnull(1))); +int kfont_save_font(struct kfont_context *ctx, int consolefd, + const char *filename, int with_unicodemap) + __attribute__((nonnull(1,3))); int kfont_loadnewfont(struct kfont_context *ctx, int fd, const char *ifil, diff --git a/src/libkfont/libkfont.map b/src/libkfont/libkfont.map index c9ed8af7..310b48d0 100644 --- a/src/libkfont/libkfont.map +++ b/src/libkfont/libkfont.map @@ -19,8 +19,7 @@ KFONT_1.0 { kfont_loaduniscrnmap; kfont_readpsffont; kfont_restorefont; - kfont_saveoldfont; - kfont_saveoldfontplusunicodemap; + kfont_save_font; kfont_saveoldmap; kfont_saveunicodemap; kfont_set_option; diff --git a/src/libkfont/setfont.c b/src/libkfont/setfont.c index 562ff3da..2e3fad3a 100644 --- a/src/libkfont/setfont.c +++ b/src/libkfont/setfont.c @@ -582,8 +582,8 @@ position_codepage(unsigned int iunit) } static int -do_saveoldfont(struct kfont_context *ctx, - int fd, const char *ofil, FILE *fpo, int unimap_follows, +save_font(struct kfont_context *ctx, int consolefd, const char *filename, + FILE *fpo, int unimap_follows, unsigned int *count, int *utf8) { /* this is the max font size the kernel is willing to handle */ @@ -594,7 +594,7 @@ do_saveoldfont(struct kfont_context *ctx, ct = sizeof(buf) / (32 * 32 / 8); /* max size 32x32, 8 bits/byte */ - if (kfont_getfont(ctx, fd, buf, &ct, &width, &height) < 0) + if (kfont_getfont(ctx, consolefd, buf, &ct, &width, &height) < 0) return -EX_OSERR; /* save as efficiently as possible */ @@ -635,7 +635,7 @@ do_saveoldfont(struct kfont_context *ctx, if (ctx->verbose) { KFONT_INFO(ctx, _("Saved %d-char %dx%d font file on %s"), - ct, width, height, ofil); + ct, width, height, filename); } } @@ -646,38 +646,25 @@ do_saveoldfont(struct kfont_context *ctx, } int -kfont_saveoldfont(struct kfont_context *ctx, int fd, const char *ofil) -{ - int ret; - FILE *fpo = fopen(ofil, "w"); - - if (!fpo) { - KFONT_ERR(ctx, "Unable to open: %s: %m", ofil); - return -EX_CANTCREAT; - } - - ret = do_saveoldfont(ctx, fd, ofil, fpo, 0, NULL, NULL); - - fclose(fpo); - return ret; -} - -int -kfont_saveoldfontplusunicodemap(struct kfont_context *ctx, int fd, const char *Ofil) +kfont_save_font(struct kfont_context *ctx, int consolefd, const char *filename, + int with_unicodemap) { int ret = 0; - FILE *fpo = fopen(Ofil, "w"); + FILE *fpo = fopen(filename, "w"); if (!fpo) { - KFONT_ERR(ctx, "unable to open: %s: %m", Ofil); + KFONT_ERR(ctx, "unable to open: %s: %m", filename); return -EX_CANTCREAT; } int utf8 = 0; unsigned int ct = 0; - if (!(ret = do_saveoldfont(ctx, fd, Ofil, fpo, 1, &ct, &utf8))) - ret = appendunicodemap(ctx, fd, fpo, ct, utf8); + ret = save_font(ctx, consolefd, filename, fpo, with_unicodemap, + &ct, &utf8); + + if (!ret && with_unicodemap) + ret = appendunicodemap(ctx, consolefd, fpo, ct, utf8); fclose(fpo); return ret; diff --git a/src/setfont.c b/src/setfont.c index d7462ee6..319dd25c 100644 --- a/src/setfont.c +++ b/src/setfont.c @@ -168,10 +168,10 @@ int main(int argc, char *argv[]) /* reset to some default */ ifiles[ifilct++] = ""; - if (Ofil && (ret = kfont_saveoldfontplusunicodemap(kfont, fd, Ofil)) < 0) + if (Ofil && (ret = kfont_save_font(kfont, fd, Ofil, 1)) < 0) return -ret; - if (ofil && (ret = kfont_saveoldfont(kfont, fd, ofil)) < 0) + if (ofil && (ret = kfont_save_font(kfont, fd, ofil, 0)) < 0) return -ret; if (omfil && (ret = kfont_saveoldmap(kfont, fd, omfil)) < 0) |