/* * Version string boilerplate for slide puzzle game. * Copyright © 2022-2023 Nick Bowler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include "version.h" const char *init_copysign(char **alloc) { *alloc = NULL; if (ENABLE_NLS) { char *buf = str_iconv("\xc2\xa9", "UTF-8", locale_charset()); if (buf) return *alloc = buf; } return "(C)"; } #define VERSION_HEAD_FMT "%s (RRace) %s\nCopyright %s 2023 Nick Bowler" #define VERSION_HEAD_ARGS progname, PACKAGE_VERSION, copysign void version_print_head(const char *progname, FILE *f) { const char *copysign; char *copybuf; copysign = init_copysign(©buf); printf(VERSION_HEAD_FMT, VERSION_HEAD_ARGS); putc('\n', f); free(copybuf); } char *version_format_head(const char *progname) { const char *copysign; char *copybuf, *ret; copysign = init_copysign(©buf); ret = malloc(sizeof VERSION_HEAD_FMT + 100); if (ret) sprintf(ret, VERSION_HEAD_FMT, VERSION_HEAD_ARGS); free(copybuf); return ret; }