Diff for /np2/x11/main.c between versions 1.28 and 1.36

version 1.28, 2008/03/13 16:27:39 version 1.36, 2011/01/15 18:43:13
Line 27 Line 27
   
 #include <sys/stat.h>  #include <sys/stat.h>
 #include <getopt.h>  #include <getopt.h>
   #include <locale.h>
 #include <signal.h>  #include <signal.h>
   
   #if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER)
   #include <SDL.h>
   #endif
   
 #include "np2.h"  #include "np2.h"
 #include "diskdrv.h"  #include "diskdrv.h"
 #include "dosio.h"  #include "dosio.h"
Line 80  static void Line 85  static void
 sighandler(int signo)  sighandler(int signo)
 {  {
   
         UNUSED(signo);  
   
         toolkit_widget_quit();          toolkit_widget_quit();
 }  }
   
Line 102  static void Line 105  static void
 usage(void)  usage(void)
 {  {
   
         printf("Usage: %s [options] [[FD1 image] [[FD2 image] [[FD3 image] [FD4 image]]]]\n\n", progname);          g_printerr("Usage: %s [options] [[FD1 image] [[FD2 image] [[FD3 image] [FD4 image]]]]\n\n", progname);
         printf("options:\n");          g_printerr("options:\n");
         printf("\t--help            [-h]        : print this message\n");          g_printerr("\t--help            [-h]        : print this message\n");
         printf("\t--config          [-c] <file> : specify config file\n");          g_printerr("\t--config          [-c] <file> : specify config file\n");
         printf("\t--timidity-config [-C] <file> : specify timidity config file\n");          g_printerr("\t--timidity-config [-C] <file> : specify timidity config file\n");
         exit(1);          exit(1);
 }  }
   
Line 125  main(int argc, char *argv[]) Line 128  main(int argc, char *argv[])
   
         progname = argv[0];          progname = argv[0];
   
           setlocale(LC_ALL, "");
           bindtextdomain(np2appname, NP2LOCALEDIR);
           bind_textdomain_codeset(np2appname, "UTF-8");
           textdomain(np2appname);
   
         toolkit_initialize();          toolkit_initialize();
         toolkit_arginit(&argc, &argv);          toolkit_arginit(&argc, &argv);
   
Line 132  main(int argc, char *argv[]) Line 140  main(int argc, char *argv[])
                 switch (ch) {                  switch (ch) {
                 case 'c':                  case 'c':
                         if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) {                          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);                                  exit(1);
                         }                          }
                         milstr_ncpy(modulefile, optarg, sizeof(modulefile));                          milstr_ncpy(modulefile, optarg, sizeof(modulefile));
   
                         /* resume/statsave dir */  
                         file_cpyname(statpath, modulefile, sizeof(statpath));  
                         file_cutname(statpath);  
                         break;                          break;
   
                 case 'C':                  case 'C':
                         if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) {                          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);                                  exit(1);
                         }                          }
                         milstr_ncpy(timidity_cfgfile_path, optarg,                          milstr_ncpy(timidity_cfgfile_path, optarg,
                             sizeof(timidity_cfgfile_path));                              sizeof(timidity_cfgfile_path));
                         break;                          break;
   
                 case 't':  
                         if (stat(optarg, &sb) < 0 || !S_ISREG(sb.st_mode)) {  
                                 fprintf(stderr, "Can't access %s.\n", optarg);  
                                 exit(1);  
                         }  
                         milstr_ncpy(fontfilename, optarg, sizeof(fontfilename));  
                         break;  
   
                 case 'v':                  case 'v':
                         verbose = 1;                          verbose = 1;
                         break;                          break;
Line 177  main(int argc, char *argv[]) Line 173  main(int argc, char *argv[])
                 char *env = getenv("HOME");                  char *env = getenv("HOME");
                 if (env) {                  if (env) {
                         /* base dir */                          /* base dir */
                         snprintf(modulefile, sizeof(modulefile),                          g_snprintf(modulefile, sizeof(modulefile),
                             "%s/.np2", env);                              "%s/.%s", env, np2appname);
                         if (stat(modulefile, &sb) < 0) {                          if (stat(modulefile, &sb) < 0) {
                                 if (mkdir(modulefile, 0700) < 0) {                                  if (mkdir(modulefile, 0700) < 0) {
                                         perror(modulefile);                                          perror(modulefile);
                                         exit(1);                                          exit(1);
                                 }                                  }
                         } else if (!S_ISDIR(sb.st_mode)) {                          } else if (!S_ISDIR(sb.st_mode)) {
                                 fprintf(stderr, "%s isn't directory.\n",                                  g_printerr("%s isn't directory.\n",
                                     modulefile);                                      modulefile);
                                 exit(1);                                  exit(1);
                         }                          }
   
                         /* font file */  
                         snprintf(np2cfg.fontfile, sizeof(np2cfg.fontfile),  
                             "%s/font.bmp", modulefile);  
   
                         /* resume/statsave dir */  
                         file_cpyname(statpath, modulefile, sizeof(statpath));  
                         file_catname(statpath, "/sav/", sizeof(statpath));  
                         if (stat(statpath, &sb) < 0) {  
                                 if (mkdir(statpath, 0700) < 0) {  
                                         perror(statpath);  
                                         exit(1);  
                                 }  
                         } else if (!S_ISDIR(sb.st_mode)) {  
                                 fprintf(stderr, "%s isn't directory.\n",  
                                     statpath);  
                                 exit(1);  
                         }  
   
                         /* config file */                          /* config file */
                         milstr_ncat(modulefile, "/np2rc", sizeof(modulefile));                          milstr_ncat(modulefile, "/np2rc", sizeof(modulefile));
                         if ((stat(modulefile, &sb) >= 0)                          if ((stat(modulefile, &sb) >= 0)
                          && !S_ISREG(sb.st_mode)) {                           && !S_ISREG(sb.st_mode)) {
                                 fprintf(stderr, "%s isn't regular file.\n",                                  g_printerr("%s isn't regular file.\n",
                                     modulefile);                                      modulefile);
                         }                          }
                 }                  }
         }          }
           if (modulefile[0] != '\0') {
                   /* font file */
                   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));
                   file_cutname(statpath);
                   file_catname(statpath, "/sav/", sizeof(statpath));
                   if (stat(statpath, &sb) < 0) {
                           if (mkdir(statpath, 0700) < 0) {
                                   perror(statpath);
                                   exit(1);
                           }
                   } else if (!S_ISDIR(sb.st_mode)) {
                           g_printerr("%s isn't directory.\n",
                               statpath);
                           exit(1);
                   }
                   file_catname(statpath, np2appname, sizeof(statpath));
           }
         if (timidity_cfgfile_path[0] == '\0') {          if (timidity_cfgfile_path[0] == '\0') {
                 file_cpyname(timidity_cfgfile_path, modulefile,                  file_cpyname(timidity_cfgfile_path, modulefile,
                     sizeof(timidity_cfgfile_path));                      sizeof(timidity_cfgfile_path));
Line 239  main(int argc, char *argv[]) Line 242  main(int argc, char *argv[])
   
         TRACEINIT();          TRACEINIT();
   
   #if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER)
           SDL_Init(0);
   #endif
   
         if (fontmng_init() != SUCCESS)          if (fontmng_init() != SUCCESS)
                 goto fontmng_failure;                  goto fontmng_failure;
   
Line 352  scrnmng_failure: Line 359  scrnmng_failure:
         fontmng_terminate();          fontmng_terminate();
   
 fontmng_failure:  fontmng_failure:
         if (sys_updates & (SYS_UPDATECFG|SYS_UPDATEOSCFG)) {          if (!np2oscfg.cfgreadonly
            && (sys_updates & (SYS_UPDATECFG|SYS_UPDATEOSCFG))) {
                 initsave();                  initsave();
                 toolwin_writeini();                  toolwin_writeini();
                 kdispwin_writeini();                  kdispwin_writeini();
Line 361  fontmng_failure: Line 369  fontmng_failure:
   
         skbdwin_deinitialize();          skbdwin_deinitialize();
   
   #if defined(USE_SDLAUDIO) || defined(USE_SDLMIXER)
           SDL_Quit();
   #endif
   
         TRACETERM();          TRACETERM();
         dosio_term();          dosio_term();
   

Removed from v.1.28  
changed lines
  Added in v.1.36


RetroPC.NET-CVS <cvs@retropc.net>