--- np2/x11/main.c 2008/04/02 13:03:35 1.30 +++ np2/x11/main.c 2011/01/15 18:43:13 1.36 @@ -1,5 +1,3 @@ -/* $Id: main.c,v 1.30 2008/04/02 13:03:35 monaka Exp $ */ - /* * Copyright (c) 2003 NONAKA Kimihiro * All rights reserved. @@ -29,6 +27,7 @@ #include #include +#include #include #if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) @@ -86,8 +85,6 @@ static void sighandler(int signo) { - UNUSED(signo); - toolkit_widget_quit(); } @@ -108,11 +105,11 @@ static void usage(void) { - printf("Usage: %s [options] [[FD1 image] [[FD2 image] [[FD3 image] [FD4 image]]]]\n\n", progname); - printf("options:\n"); - printf("\t--help [-h] : print this message\n"); - printf("\t--config [-c] : specify config file\n"); - printf("\t--timidity-config [-C] : specify timidity config file\n"); + g_printerr("Usage: %s [options] [[FD1 image] [[FD2 image] [[FD3 image] [FD4 image]]]]\n\n", progname); + g_printerr("options:\n"); + g_printerr("\t--help [-h] : print this message\n"); + g_printerr("\t--config [-c] : specify config file\n"); + g_printerr("\t--timidity-config [-C] : specify timidity config file\n"); exit(1); } @@ -131,6 +128,11 @@ main(int argc, char *argv[]) progname = argv[0]; + setlocale(LC_ALL, ""); + bindtextdomain(np2appname, NP2LOCALEDIR); + bind_textdomain_codeset(np2appname, "UTF-8"); + textdomain(np2appname); + toolkit_initialize(); toolkit_arginit(&argc, &argv); @@ -138,7 +140,7 @@ main(int argc, char *argv[]) switch (ch) { case 'c': if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) { - fprintf(stderr, "Can't access %s.\n", optarg); + g_printerr("Can't access %s.\n", optarg); exit(1); } milstr_ncpy(modulefile, optarg, sizeof(modulefile)); @@ -146,7 +148,7 @@ main(int argc, char *argv[]) case 'C': if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) { - fprintf(stderr, "Can't access %s.\n", optarg); + g_printerr("Can't access %s.\n", optarg); exit(1); } milstr_ncpy(timidity_cfgfile_path, optarg, @@ -171,7 +173,7 @@ main(int argc, char *argv[]) char *env = getenv("HOME"); if (env) { /* base dir */ - snprintf(modulefile, sizeof(modulefile), + g_snprintf(modulefile, sizeof(modulefile), "%s/.%s", env, np2appname); if (stat(modulefile, &sb) < 0) { if (mkdir(modulefile, 0700) < 0) { @@ -179,7 +181,7 @@ main(int argc, char *argv[]) exit(1); } } else if (!S_ISDIR(sb.st_mode)) { - fprintf(stderr, "%s isn't directory.\n", + g_printerr("%s isn't directory.\n", modulefile); exit(1); } @@ -188,15 +190,19 @@ main(int argc, char *argv[]) milstr_ncat(modulefile, "/np2rc", sizeof(modulefile)); if ((stat(modulefile, &sb) >= 0) && !S_ISREG(sb.st_mode)) { - fprintf(stderr, "%s isn't regular file.\n", + g_printerr("%s isn't regular file.\n", modulefile); } } } if (modulefile[0] != '\0') { /* font file */ - snprintf(np2cfg.fontfile, sizeof(np2cfg.fontfile), - "%s/font.bmp", modulefile); + file_cpyname(np2cfg.fontfile, modulefile, + sizeof(np2cfg.fontfile)); + file_cutname(np2cfg.fontfile); + file_setseparator(np2cfg.fontfile, sizeof(np2cfg.fontfile)); + file_catname(np2cfg.fontfile, "font.bmp", + sizeof(np2cfg.fontfile)); /* resume/statsave dir */ file_cpyname(statpath, modulefile, sizeof(statpath)); @@ -208,7 +214,7 @@ main(int argc, char *argv[]) exit(1); } } else if (!S_ISDIR(sb.st_mode)) { - fprintf(stderr, "%s isn't directory.\n", + g_printerr("%s isn't directory.\n", statpath); exit(1); }