📄 gmo2msg.c
字号:
/*gmo2msg.c - create X/Open message source file for libelf.Copyright (C) 1996 - 2002 Michael Riepe <michael@stud.uni-hannover.de>This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Library General PublicLicense as published by the Free Software Foundation; eitherversion 2 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULibrary General Public License for more details.You should have received a copy of the GNU Library General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/#ifndef lintstatic const char rcsid[] = "@(#) $Id: gmo2msg.c,v 1.6 2002/12/14 17:43:13 michael Exp $";#endif /* lint */#include <stdlib.h>#include <string.h>#include <unistd.h>#include <stdio.h>#include <libintl.h>#define DOMAIN "libelf"static const char *msgs[] = {#define __err__(a,b) b,#include <errors.h>#undef __err__};intmain(int argc, char **argv) { char buf[1024], *lang, *progname, *s; unsigned i; if (*argv && (progname = strrchr(argv[0], '/'))) { progname++; } else if (!(progname = *argv)) { progname = "gmo2msg"; } if (!(lang = getenv("LANGUAGE")) && !(lang = getenv("LC_ALL")) && !(lang = getenv("LC_MESSAGES")) && !(lang = getenv("LANG"))) { fprintf(stderr, "LANG variable not set.\n"); exit(1); } /* * Fool gettext... */ getcwd(buf, sizeof(buf)); bindtextdomain(DOMAIN, buf); sprintf(buf, "%s.gmo", lang); unlink(DOMAIN ".mo"); symlink(buf, DOMAIN ".mo"); unlink("LC_MESSAGES"); symlink(".", "LC_MESSAGES"); unlink(lang); symlink(".", lang); printf("$set 1 Automatically created from %s by %s\n", buf, progname); /* * Get translated messages. * Assume that messages contain printable ASCII characters ONLY. * That means no tabs, linefeeds etc. */ textdomain(DOMAIN); if ((s = gettext("")) && (s = strdup(s))) { s = strtok(s, "\n"); while (s) { printf("$ %s\n", s); s = strtok(NULL, "\n"); } } for (i = 0; i < sizeof(msgs)/sizeof(*msgs); i++) { s = gettext(msgs[i]); if (s != msgs[i] && strcmp(s, msgs[i])) { printf("$ \n$ Original message: %s\n", msgs[i]); printf("%u %s\n", i + 1, s); } } /* * Cleanup. */ unlink(DOMAIN ".mo"); unlink("LC_MESSAGES"); unlink(lang); exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -