--- np2/x11/main.c 2008/03/18 15:33:14 1.29 +++ np2/x11/main.c 2011/01/15 18:43:13 1.36 @@ -1,5 +1,3 @@ -/* $Id: main.c,v 1.29 2008/03/18 15:33:14 monaka Exp $ */ - /* * Copyright (c) 2003 NONAKA Kimihiro * All rights reserved. @@ -29,8 +27,13 @@ #include #include +#include #include +#if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) +#include +#endif + #include "np2.h" #include "diskdrv.h" #include "dosio.h" @@ -82,8 +85,6 @@ static void sighandler(int signo) { - UNUSED(signo); - toolkit_widget_quit(); } @@ -104,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); } @@ -127,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); @@ -134,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)); @@ -142,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, @@ -167,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) { @@ -175,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); } @@ -184,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)); @@ -204,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); } @@ -232,6 +242,10 @@ main(int argc, char *argv[]) TRACEINIT(); +#if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) + SDL_Init(0); +#endif + if (fontmng_init() != SUCCESS) goto fontmng_failure; @@ -355,6 +369,10 @@ fontmng_failure: skbdwin_deinitialize(); +#if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER) + SDL_Quit(); +#endif + TRACETERM(); dosio_term();