예제 #1
0
파일: matfuncs.c 프로젝트: aylusltd/gretl
int main (int argc, char **argv)
{
    sectlist slist;
    int err = 0;

    if (argc != 2) {
	fprintf(stderr, "Please supply one argument: the name of a "
		"file to process\n");
	exit(EXIT_FAILURE);
    }

    nls_init();

    strcpy(reffile, argv[1]);

    sectlist_init(&slist);

    err = parse_ref_file(&slist);
    if (err) {
	fprintf(stderr, "Error parsing %s\n", reffile);
	exit(EXIT_FAILURE);
    }

    fprintf(stderr, "Found %d sections in '%s'\n", slist.nsects, reffile);

    print_topic_lists(&slist);

    free_sectlist(&slist);

    return err;
}
예제 #2
0
int main()
{
	int res;
	Volume *v;
	nls_init();
	res = fat_mount("../img/floppy.img", &v);
	printf("Mount: %i (%s)\n", res, strerror(-res));
	//for (res = 0; res < 100000; res++)
	//unlink_test(v, "\\grub\\menu.lst");
	//rmdir_test(v, "\\faccio un provolone");
	rename_test(v, "\\grub\\rentest", "\\puppo");
		//read_test(v, "\\grub\\menu.lst");
		//lfnfind_test(v, "\\grub", "*.*");
		//create_test(v, "\\faccio una prova.txt");
		//mkdir_test(v, "\\faccio un provolone");
		//dosfind_test(v, "\\autoexec.bat\\*.*");
	res = fat_unmount(v);
	printf("Unmount: %i (%s)\n", res, strerror(-res));
	#if 0
	//res = fat_open(v, "\\autoexec.bat", NULL, O_RDWR, 0, &c);
	res = fat_open(v, "\\faccio una prova.txt", NULL, O_RDWR | O_CREAT | O_EXCL, 0, &c);
	printf("Open: %i (%s)\n", res, strerror(-res));
	#if 1 /* write */
	res = fat_lseek(c, 0, SEEK_SET);
	printf("Seek: %i (%s)\n", res, strerror(-res));
	for (k = 0; k < sizeof(buf); k++) buf[k] = (k % 10) + '0';
	res = fat_write(c, buf, sizeof(buf));
	printf("Write: %i (%s)\n", res, strerror(-res));
	#elif 0 /* read */
	res = fat_read(c, buf, sizeof(buf));
	printf("Read: %i (%s)\n", res, strerror(-res));
	for (k = 0; k < res; k++) fputc(buf[k], stdout);
	#elif 0 /* truncate */
	res = fat_ftruncate(c, 65432);
	printf("Truncate: %i (%s)\n", res, strerror(-res));
	#endif
	res = fat_close(c);
	printf("Close: %i (%s)\n", res, strerror(-res));
	res = fat_unmount(v);
	printf("Unmount: %i (%s)\n", res, strerror(-res));
	#endif
	return 0;
}
예제 #3
0
파일: main.c 프로젝트: erlgo/ms-sys
int main(int argc, char **argv)
{
   FILE *fp;
   int iBr = NO_WRITING;
   int bForce = 0;
   int bPrintVersion = 0;
   int bKeepLabel = 1;
   int bWritePartitionInfo = 0;
   int iHeads = -1;
   int iRet = 0;

   nls_init();
   if(parse_switches(argc, argv, &iBr, &bForce, &bPrintVersion,
		     &bKeepLabel, &bWritePartitionInfo, &iHeads))
   {
      print_help(argv[0]);
      return 0;
   }
   if(bPrintVersion)
   {
      print_version();
      if(argc < 3)
	 return 0;
   }
   fp=fopen(argv[argc-1], (iBr || bWritePartitionInfo) ? "r+b" : "rb");
   if(!fp)
   {
      printf(_("Unable to open %s, %s\n"), argv[argc-1], strerror(errno));
      return 1;
   }
   if(iBr == AUTO_BR)
   {
      iBr = smart_select(fp);
      if(!iBr)
	 printf(_("Unable to automaticly select boot record for %s\n"),
		argv[argc-1]);
   }
   if(iBr && !bForce)
   {
      if(!sanity_check(fp, argv[argc-1], iBr, 1))
      {
	 fclose(fp);
	 return 1;
      }
   }
   if(bWritePartitionInfo)
   {
      if(!iBr && !bForce)
      {
	 if(!sanity_check(fp, argv[argc-1], FAT32_BR, 1))
	 {
	    fclose(fp);
	    return 1;
	 }
      }
      if(write_partition_start_sector_number(fp))
      {
	 printf(_("Start sector %ld (nr of hidden sectors) successfully written to %s\n"),
		partition_start_sector(fp),
		argv[argc-1]);
	 if( write_partition_physical_disk_drive_id(fp) )
	 {
	    printf(_("Physical disk drive id 0x80 (C:) successfully written to %s\n"),
		   argv[argc-1]);
	    if( write_partition_number_of_heads(fp, iHeads))
	    {
	       printf(_("Number of heads (%d) successfully written to %s\n"),
		      iHeads != -1 ? iHeads : partition_number_of_heads(fp),
		      argv[argc-1]);
	    }
	    else
	    {
	       printf(_("Failed writing number of heads to %s\n"),
		      argv[argc-1]);
	    }
	 }
	 else
	 {
	    printf(_("Failed writing physical disk drive id to %s\n"),
		   argv[argc-1]);
	 }
      }
      else
      {
	 printf(_("Failed writing start sector to %s, this is only possible to do with\n"),
		argv[argc-1]);
	 printf(_("real partitions!\n"));
	 iRet = 1;
      }
   }
   switch(iBr)
   {
      case NO_WRITING:
      {
	 if( ! bWritePartitionInfo )
	 {
	    diagnose(fp, argv[argc-1]);
	 }
	 break;
      }
      case MBR_WIN7FAT:
      {
         if(write_win7_fat_mbr(fp))
             printf(_("Windows 7 FAT master boot record successfully written to %s\n"),
                    argv[argc-1]);
         else
         {
             printf(_("Failed writing Windows 7 FAT master boot record to %s\n"),
                    argv[argc-1]);
             iRet = 1;
         }
      }
      case MBR_WIN7:
      {
         if(write_win7_mbr(fp))
            printf(_("Windows 7 master boot record successfully written to %s\n"),
                   argv[argc-1]);
         else
         {
            printf(_("Failed writing Windows 7 master boot record to %s\n"),
                   argv[argc-1]);
            iRet = 1;
         }
      }
      break;
      case MBR_VISTA:
      {
         if(write_vista_mbr(fp))
            printf(_("Windows Vista master boot record successfully written to %s\n"),
                   argv[argc-1]);
         else
         {
            printf(_("Failed writing Windows Vista master boot record to %s\n"),
                   argv[argc-1]);
            iRet = 1;
         }
      }
      break;
      case MBR_2000:
      {
	 if(write_2000_mbr(fp))
	    printf(_("Windows 2000/XP/2003 master boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing Windows 2000/XP/2003 master boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case MBR_95B:
      {
	 if(write_95b_mbr(fp))
	    printf(_("Windows 95B/98/98SE/ME master boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing Windows 95B/98/98SE/ME master boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case MBR_DOS:
      {
	 if(write_dos_mbr(fp))
	    printf(_("DOS/Windows NT master boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing DOS/Windows NT master boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case MBR_SYSLINUX:
      {
	 if(write_syslinux_mbr(fp))
	    printf(_("Syslinux master boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing syslinux master boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case MBR_GPT_SYSLINUX:
      {
	 if(write_syslinux_gpt_mbr(fp))
	    printf(_("Syslinux GPT master boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing syslinux GPT master boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case MBR_ZERO:
      {
	 if(write_zero_mbr(fp))
	    printf(_("Empty (zeroed) master boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing empty (zeroed) master boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case FAT12W7_BR:
      {
     if(write_fat_12_w7_br(fp, bKeepLabel))
        printf(_("FAT12 Win 7 boot record successfully written to %s\n"),
           argv[argc-1]);
     else
     {
        printf(_("Failed writing FAT12 Win 7 boot record to %s\n"),
           argv[argc-1]);
        iRet = 1;
     }
      }
      break;
      case FAT12_BR:
      {
	 if(write_fat_12_br(fp, bKeepLabel))
	    printf(_("FAT12 boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing FAT12 boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case FAT16_BR:
      {
	 if(write_fat_16_br(fp, bKeepLabel))
	    printf(_("FAT16 boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing FAT16 boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case FAT16FD_BR:
      {
	 if(write_fat_16_fd_br(fp, bKeepLabel))
	    printf(_("FAT16 FreeDOS boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing FAT16 FreeDOS boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case FAT32NT_BR:
      {
	 if(write_fat_32_nt_br(fp, bKeepLabel))
	    printf(_("FAT32 NT boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing FAT32 NT boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case FAT32PE_BR:
      {
	 if(write_fat_32_pe_br(fp, bKeepLabel))
	    printf(_("FAT32 PE boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing FAT32 PE boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case FAT32FD_BR:
      {
	 if(write_fat_32_fd_br(fp, bKeepLabel))
	    printf(_("FAT32 FreeDOS boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing FAT32 FreeDOS boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case FAT32W7_BR:
      {
     if(write_fat_32_w7_br(fp, bKeepLabel))
        printf(_("FAT32 Win 7 boot record successfully written to %s\n"),
           argv[argc-1]);
     else
     {
        printf(_("Failed writing FAT32 Win 7 boot record to %s\n"),
           argv[argc-1]);
        iRet = 1;
     }
      }
      break;
      case FAT32_BR:
      {
	 if(write_fat_32_br(fp, bKeepLabel))
	    printf(_("FAT32 DOS boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing FAT32 DOS boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      case NTFS_BR:
      {
	 if(write_ntfs_br(fp))
	    printf(_("NTFS Windows 7 boot record successfully written to %s\n"),
		   argv[argc-1]);
	 else
	 {
	    printf(_("Failed writing NTFS Windows 7 boot record to %s\n"),
		   argv[argc-1]);
	    iRet = 1;
	 }	    
      }
      break;
      default:
      {
	 printf(_("Whoops, internal error, unknown boot record\n"));
      }
      break;
   }
   fclose(fp);
   return iRet;
} /* main */
예제 #4
0
int
main(int argc,char **argv)
{
  int option ;
  const char *unzipper = NULL ;
  const char *infile = NULL ;

  setlocale(LC_ALL,"");
  progname = argv[0] ;
  nls_init();

  if( argc <= 1 ) gpl_blurb() ;
  
  init_flatspec(&flatspec) ;
  while( (option=getopt_long(argc,argv,"-"OPTSTRING,longopts,NULL)) >= 0 )
    switch(option) {
      #define OPTION(char,long,desc,man) case char:
      #include "options.i"
    case 1:
      if( infile ) 
        add_layer_request(&flatspec,optarg);
      else
        infile = optarg ;
      break ;
    case '?':
      usage(stderr);
    default:
      FatalUnexpected("Getopt(_long) unexpectedly returned '%c'",option);
    }
  if( infile == NULL ) {
    usage(stderr);
  }
  
  read_or_mmap_xcf(infile,unzipper);
  getBasicXcfInfo() ;
  initColormap();
 
  complete_flatspec(&flatspec,guessIndexed);
  if( flatspec.process_in_memory ) {
    rgba **allPixels = flattenAll(&flatspec);
     
    analyse_colormode(&flatspec,allPixels,guessIndexed);

    /* See if we can do alpha compaction.
     */
    if( flatspec.partial_transparency_mode != ALLOW_PARTIAL_TRANSPARENCY &&
        !FULLALPHA(flatspec.default_pixel) &&
        flatspec.out_color_mode != COLOR_INDEXED ) {
      rgba unused = findUnusedColor(allPixels,
                                    flatspec.dim.width,
                                    flatspec.dim.height);
      if( unused && (flatspec.out_color_mode == COLOR_RGB ||
                     degrayPixel(unused) >= 0) ) {
        unsigned x,y ;
        unused = NEWALPHA(unused,0) ;
        for( y=0; y<flatspec.dim.height; y++)
          for( x=0; x<flatspec.dim.width; x++)
            if( allPixels[y][x] == 0 )
              allPixels[y][x] = unused ;
        flatspec.default_pixel = unused ;
      }
    }
    shipoutWithCallback(&flatspec,allPixels,selectCallback());
  } else {
    flattenIncrementally(&flatspec,selectCallback());
  }
  if( libpng ) {
    png_write_end(libpng,libpng2);
    png_destroy_write_struct(&libpng,&libpng2);
  }
  if( outfile ) {
    closeout(outfile,flatspec.output_filename);
  }
  return 0 ;
}
예제 #5
0
void
i18n_init(void)
{
  prop_t *s = settings_add_dir(NULL, _p("Languages"), NULL, NULL,
			       _p("Preferred languages"));
  setting_t *x;
  int i;

  htsmsg_t *store = htsmsg_store_load("i18n");
  if(store == NULL)
    store = htsmsg_create_map();

  nls_init(s, store);


  settings_create_info(s, 
		       NULL,
		       _p("Language codes should be configured as three character ISO codes, example (eng, swe, fra)"));

  settings_create_string(s, "audio1", _p("Primary audio language code"), NULL, 
			 store, set_lang, &lang_audio[0],
			 SETTINGS_INITIAL_UPDATE,  NULL,
			 settings_generic_save_settings, 
			 (void *)"i18n");

  settings_create_string(s, "audio2", _p("Secondary audio language code"),
			 NULL, 
			 store, set_lang, &lang_audio[1],
			 SETTINGS_INITIAL_UPDATE,  NULL,
			 settings_generic_save_settings, 
			 (void *)"i18n");

  settings_create_string(s, "audio3", _p("Tertiary audio language code"), NULL, 
			 store, set_lang, &lang_audio[2],
			 SETTINGS_INITIAL_UPDATE,  NULL,
			 settings_generic_save_settings, 
			 (void *)"i18n");
  

  settings_create_string(s, "subtitle1", _p("Primary subtitle language code"),
			 NULL, store, set_lang, &lang_subtitle[0],
			 SETTINGS_INITIAL_UPDATE,  NULL,
			 settings_generic_save_settings, 
			 (void *)"i18n");

  settings_create_string(s, "subtitle2", _p("Secondary subtitle language code"),
			 NULL, store, set_lang, &lang_subtitle[1],
			 SETTINGS_INITIAL_UPDATE,  NULL,
			 settings_generic_save_settings, 
			 (void *)"i18n");

  settings_create_string(s, "subtitle3", _p("Tertiary subtitle language code"),
			 NULL, store, set_lang, &lang_subtitle[2],
			 SETTINGS_INITIAL_UPDATE,  NULL,
			 settings_generic_save_settings, 
			 (void *)"i18n");

  x = settings_create_multiopt(s, "srt_charset", _p("SRT character set"));
			       

  const charset_t *cs;
  for(i = 0; (cs = charset_get_idx(i)) != NULL; i++)
    settings_multiopt_add_opt_cstr(x, cs->id, cs->title, i == 0);

  settings_multiopt_initiate(x,
			     set_srt_charset, NULL, NULL,
			     store, settings_generic_save_settings, 
			     (void *)"i18n");
}
예제 #6
0
파일: gretlcli.c 프로젝트: aylusltd/gretl
int main (int argc, char *argv[])
{
#ifdef WIN32
    char *callname = argv[0];
#endif
    char linecopy[MAXLINE];
    DATASET *dset = NULL;
    MODEL *model = NULL;
    ExecState state;
    char *line = NULL;
    int quiet = 0;
    int makepkg = 0;
    int load_datafile = 1;
    char filearg[MAXLEN];
    char runfile[MAXLEN];
    double scriptval = NADBL;
    CMD cmd;
    PRN *prn = NULL;
    PRN *cmdprn = NULL;
    int err = 0;

#ifdef G_OS_WIN32
    win32_set_gretldir(callname);
#endif

    nls_init();

#ifdef HAVE_READLINE
    rl_bind_key(0x18, ctrl_x);
#endif

    dset = datainfo_new();
    if (dset == NULL) {
	noalloc();
    }

    if (argc < 2) {
	load_datafile = 0;
    } else {
	gretlopt opt = 0;

	err = parse_options(&argc, &argv, &opt, &scriptval, filearg);

	if (!err && (opt & (OPT_DBOPEN | OPT_WEBDB))) {
	    /* catch GUI-only options */
	    err = E_BADOPT;
	}

	if (err) {
	    /* bad option */
	    usage(1);
	} else if (opt & (OPT_HELP | OPT_VERSION)) {
	    /* we'll exit in these cases */
	    if (opt & OPT_HELP) {
		usage(0);
	    } else {
		logo(0);
		exit(EXIT_SUCCESS);
	    }
	}
	    
	if (opt & (OPT_BATCH | OPT_RUNIT | OPT_MAKEPKG)) {
	    if (*filearg == '\0') {
		/* we're missing a filename argument */
		usage(1);
	    } else {
		/* record argument (not a datafile) */
		strcpy(runfile, filearg);
		load_datafile = 0;
		if (opt & OPT_BATCH) {
		    batch = 1;
		} else if (opt & OPT_MAKEPKG) {
		    batch = 1;
		    makepkg = 1;
		} else {
		    runit = 1;
		}
	    }
	} else if (*filearg == '\0') {
	    load_datafile = 0;
	}

	if (opt & OPT_QUIET) {
	    quiet = 1;
	}

	if (opt & OPT_ENGLISH) {
	    force_language(LANG_C);
	}
    }

    libgretl_init();

    logo(quiet);
    if (!quiet) {
	session_time(NULL);
    }

    prn = gretl_print_new(GRETL_PRINT_STDOUT, &err);
    if (err) {
	noalloc();
    }

    line = malloc(MAXLINE);
    if (line == NULL) {
	noalloc();
    }

#ifdef WIN32
    win32_cli_read_rc(callname);
#else
    cli_read_rc();
#endif /* WIN32 */

    if (!batch) {
	strcpy(cmdfile, gretl_workdir());
	strcat(cmdfile, "session.inp");
	cmdprn = gretl_print_new_with_filename(cmdfile, &err);
	if (err) {
	    errmsg(err, prn);
	    return EXIT_FAILURE;
	}
    }

    if (load_datafile) {
	handle_datafile(filearg, runfile, dset, prn, cmdprn);
    }

    /* allocate memory for model */
    model = allocate_working_model();
    if (model == NULL) {
	noalloc(); 
    }

    gretl_cmd_init(&cmd);
    gretl_exec_state_init(&state, 0, line, &cmd, model, prn);
    set_debug_read_func(get_interactive_line);

    /* print list of variables */
    if (data_status) {
	varlist(dset, prn);
    }

    if (!na(scriptval)) {
	/* define "scriptopt" */
	gretl_scalar_add("scriptopt", scriptval);
    }

    /* misc. interactive-mode setup */
    if (!batch) {
	check_help_file();
	fb = stdin;
	push_input_file(fb);
	if (!runit && !data_status) {
	    fputs(_("Type \"open filename\" to open a data set\n"), stdout);
	}
    }

#ifdef HAVE_READLINE
    initialize_readline();
#endif
    
    if (batch || runit) {
	/* re-initialize: will be incremented by "run" cmd */
	runit = 0;
	if (makepkg) {
	    set_gretl_echo(0);
	}
	if (strchr(runfile, ' ')) {
	    sprintf(line, "run \"%s\"", runfile);
	} else {
	    sprintf(line, "run %s", runfile);
	}
	err = cli_exec_line(&state, dset, cmdprn);
	if (err && fb == NULL) {
	    exit(EXIT_FAILURE);
	}
    }

    *linecopy = '\0';

    /* main command loop */
    while (cmd.ci != QUIT && fb != NULL && !xout) {
	if (err && gretl_error_is_fatal()) {
	    gretl_abort(linecopy);
	}

	if (gretl_execute_loop()) { 
	    if (gretl_loop_exec(&state, dset, NULL)) {
		return 1;
	    }
	} else {
	    err = cli_get_input_line(&state);
	    if (err) {
		errmsg(err, prn);
		break;
	    }
	}

	if (!state.in_comment) {
	    if (cmd.context == FOREIGN || cmd.context == MPI ||
		gretl_compiling_python(line)) {
		tailstrip(line);
	    } else {
		err = maybe_get_input_line_continuation(line); 
		if (err) {
		    errmsg(err, prn);
		    break;
		}
	    }
	} 

	strcpy(linecopy, line);
	tailstrip(linecopy);
	err = cli_exec_line(&state, dset, cmdprn);
    } /* end of get commands loop */

    if (!err) {
	err = gretl_if_state_check(0);
	if (err) {
	    errmsg(err, prn);
	}
    }

    if (makepkg && !err) {
	switch_ext(filearg, runfile, "gfn");
	sprintf(line, "makepkg %s\n", filearg);
	cli_exec_line(&state, dset, cmdprn);
    }

    /* leak check -- try explicitly freeing all memory allocated */

    destroy_working_model(model);
    destroy_dataset(dset);

    if (fb != stdin && fb != NULL) {
	fclose(fb);
    }

    free(line);

    gretl_print_destroy(prn);
    gretl_cmd_free(&cmd);
    libgretl_cleanup();

    return 0;
}
예제 #7
0
파일: i18n.c 프로젝트: bguerreiro/movian
void
i18n_init(void)
{
  prop_t *s = settings_add_dir(NULL, _p("Languages"), "i18n", NULL,
			       _p("Preferred languages"),
			       "settings:i18n");
  int i;

  nls_init(s);

#ifdef STOS
  setting_create(SETTING_STRING, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Timezone")),
                 SETTING_CALLBACK(set_timezone, NULL),
                 SETTING_STORE("i18n", "timezone"),
                 NULL);

#endif

  setting_create(SETTING_MULTIOPT, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Time format")),
                 SETTING_STORE("i18n", "timeformat"),
                 SETTING_WRITE_INT(&gconf.time_format),
                 SETTING_OPTION(gconf.time_format_system ? "0" : NULL,
                                _p("System default")),
                 SETTING_OPTION("1", _p("24 Hour")),
                 SETTING_OPTION("2", _p("12 Hour")),
                 NULL);


  settings_create_info(s,
		       NULL,
		       _p("Language codes should be configured as three character ISO codes, example (eng, swe, fra)"));

  setting_create(SETTING_STRING, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Primary audio language code")),
                 SETTING_CALLBACK(set_lang, &lang_audio[0]),
                 SETTING_STORE("i18n", "audio1"),
                 NULL);

  setting_create(SETTING_STRING, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Secondary audio language code")),
                 SETTING_CALLBACK(set_lang, &lang_audio[1]),
                 SETTING_STORE("i18n", "audio2"),
                 NULL);

  setting_create(SETTING_STRING, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Tertiary audio language code")),
                 SETTING_CALLBACK(set_lang, &lang_audio[2]),
                 SETTING_STORE("i18n", "audio3"),
                 NULL);


  setting_create(SETTING_STRING, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Primary subtitle language code")),
                 SETTING_CALLBACK(&set_lang, &lang_subtitle[0]),
                 SETTING_STORE("i18n", "subtitle1"),
                 NULL);

  setting_create(SETTING_STRING, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Secondary subtitle language code")),
                 SETTING_CALLBACK(&set_lang, &lang_subtitle[1]),
                 SETTING_STORE("i18n", "subtitle2"),
                 NULL);

  setting_create(SETTING_STRING, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Tertiary subtitle language code")),
                 SETTING_CALLBACK(&set_lang, &lang_subtitle[2]),
                 SETTING_STORE("i18n", "subtitle3"),
                 NULL);

  const char **optlist = NULL;
  const charset_t *cs;
  for(i = 0; (cs = charset_get_idx(i)) != NULL; i++) {}

  optlist = alloca((i * 2 + 3) * sizeof(const char *));

  optlist[0] = "auto";
  optlist[1] = "Auto";

  for(i = 0; (cs = charset_get_idx(i)) != NULL; i++) {
    optlist[i * 2 + 2] = cs->id;
    optlist[i * 2 + 3] = cs->title;
  }
  optlist[i * 2 + 2] = NULL;

  setting_create(SETTING_MULTIOPT, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Default character set")),
                 SETTING_STORE("i18n", "default_charset"),
                 SETTING_CALLBACK(set_default_charset, NULL),
                 SETTING_OPTION_LIST(optlist),
                 NULL);

  setting_create(SETTING_BOOL, s, SETTINGS_INITIAL_UPDATE,
                 SETTING_TITLE(_p("Ignore 'The' at beginning of words when sorting")),
                 SETTING_STORE("i18n", "skipthe"),
                 SETTING_WRITE_BOOL(&gconf.ignore_the_prefix),
                 NULL);
}
예제 #8
0
void initialize (int *argc, char **argv[], char ***envp)
{
    char    buf[512], *p;
    char    inifile[MAX_PATH], ifile[MAX_PATH];
    time_t     t1;
    struct tm  tm1;
#ifdef __MINGW32__
    WSADATA wsa;
#endif

    //putenv ("TZ=GMT0");
    //tzset ();

    // first we need to initialize FLY variables
    fly_initialize ();
    fl_opt.appname = "nftp";

    if (fl_opt.has_console)
        fprintf (stderr, "\nNFTP - Version%sof %s, %s"
                 "\nCopyright (C) Sergey Ayukov 1994--2000.\n\n",
                 NFTP_VERSION, __DATE__, __TIME__);

    fly_process_args (argc, argv, envp);

    // checking command-line arguments
    check_args (*argc, *argv);

    // find where our config files are
    determine_paths ((*argv)[0]);

    // delete old temporary files
    clear_tmp ();

    // loading configuration files
    init_config ();

    // initilialize debug subsystem if specified
    if (options.debug)
    {
        sprintf (buf, /*sizeof(buf),*/ "%s/debug", paths.user_libpath);
        mkdir1 (buf, 0700);
        sprintf (buf, /*sizeof(buf),*/ "%s/debug/nftp.dbg.%u", paths.user_libpath, (int)getpid ());
        dbfile = fopen (buf, "w");
        tools_debug = dbfile;
    }

    if (options.log_cc)
    {
        sprintf (buf, /*sizeof(buf),*/ "%s/CC", paths.user_libpath);
        mkdir1 (buf, 0700);
        t1 = time (NULL);
        tm1 = *localtime (&t1);
        sprintf (buf, "CC/%04d-%02d-%02d.%02d:%02d:%02d.log",
                 tm1.tm_year+1900, tm1.tm_mon, tm1.tm_mday,
                 tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
        p = str_sjoin (paths.user_libpath, buf);
        cc_log = fopen (p, "w");
        if (cc_log == NULL) options.log_cc = FALSE;
        free (p);
    }

    // load language-specific things
    nls_init (paths.system_libpath, paths.user_libpath);
    load_menu ();

    // check for correct NFTP.INI version
    strcpy (buf, NFTP_VERSION);
    str_strip2 (buf, " ");
    //if (str_numchars (buf, '.') > 1)  *(strrchr (buf, '.')) = '\0';
    if (strcmp (options.version, buf) != 0)
    {
        // looking for nftp.i file in user dir, then in system dir
        strcpy (ifile, paths.user_libpath);
        str_cats (ifile, "nftp.i");
        if (access (ifile, R_OK) != 0)
        {
            strcpy (ifile, paths.system_libpath);
            str_cats (ifile, "nftp.i");
            if (access (ifile, R_OK) != 0)
                fly_error (MSG(M_INI_CANT_FIND_NFTP_I),
                        paths.user_libpath, paths.system_libpath);
        }
        strcpy (inifile, paths.user_libpath);
        str_cats (inifile, "nftp.ini");
        update_inifile (inifile, ifile);
        GetProfileOptions (inifile);
    }

    config_fly ();

#ifdef __MINGW32__
    WSAStartup (MAKEWORD(1,1), &wsa);
#endif
}
예제 #9
0
int
main(int argc,char **argv)
{
  int i ;
  int option ;
  const char *unzipper = NULL ;
  const char *infile = NULL ;
  const char *pathSeparator = "|";

  setlocale(LC_ALL,"");
  progname = argv[0] ;
  nls_init();

  if( argc <= 1 ) gpl_blurb() ;

  while( (option=getopt_long(argc,argv,"-"OPTSTRING,longopts,NULL)) >= 0 )
    switch(option) {
      #define OPTION(char,long,desc,man) case char:
      #include "options.i"
    case 1:
      if( infile ) {
        FatalGeneric
          (20,_("Only one XCF file per command line, please"));
      } else {
        infile = optarg ;
        break ;
      }
    case '?':
      usage(stderr);
    default:
      FatalUnexpected("Getopt(_long) unexpectedly returned '%c'",option);
    }
  if( infile == NULL ) {
    usage(stderr);
  }

  read_or_mmap_xcf(infile,unzipper);
  getBasicXcfInfo() ;
  printf(_("Version %d, %dx%d %s, %d layers, compressed %s\n"),
         XCF.version,XCF.width,XCF.height,
         _(showGimpImageBaseType(XCF.type)),
         XCF.numLayers,
         _(showXcfCompressionType(XCF.compression)));
  for( i = XCF.numLayers ; i-- ; ) {
    printf("%c %dx%d%+d%+d %s %s",
           XCF.layers[i].isVisible ? '+' : '-',
           XCF.layers[i].dim.width, XCF.layers[i].dim.height,
           XCF.layers[i].dim.c.l, XCF.layers[i].dim.c.t,
           _(showGimpImageType(XCF.layers[i].type)),
           _(showGimpLayerModeEffects(XCF.layers[i].mode)));
    if( XCF.layers[i].opacity < 255 )
      printf("/%02d%%",XCF.layers[i].opacity * 100 / 255);
    if( XCF.layers[i].hasMask )
      printf(_("/mask"));
    if( XCF.layers[i].isGroup )
      printf(_("/group"));

    printf( " " );

    if ( XCF.version > 2 ) {
      printLayerPath( i, pathSeparator );
      printf( "%s", pathSeparator );
    }

    printf("%s\n",XCF.layers[i].name);
  }
      
  return 0 ;
}
예제 #10
0
static void bios_init(void)
{
    KDEBUG(("bios_init()\n"));

    /* initialize Native Features, if available
     * do it as soon as possible so that kprintf can make use of them
     */
#if DETECT_NATIVE_FEATURES
    KDEBUG(("natfeat_init()\n"));
    natfeat_init();
#endif
#if STONX_NATIVE_PRINT
    KDEBUG(("stonx_kprintf_init()\n"));
    stonx_kprintf_init();
#endif
#if CONF_WITH_UAE
    KDEBUG(("amiga_uaelib_init()\n"));
    amiga_uaelib_init();
#endif

    /* Initialize the processor */
    KDEBUG(("processor_init()\n"));
    processor_init();   /* Set CPU type, longframe and FPU type */
    KDEBUG(("vecs_init()\n"));
    vecs_init();        /* setup all exception vectors (above) */
    KDEBUG(("init_delay()\n"));
    init_delay();       /* set 'reasonable' default values for delay */

    /* Detect optional hardware (video, sound, etc.) */
    KDEBUG(("machine_detect()\n"));
    machine_detect();   /* detect hardware */
    KDEBUG(("machine_init()\n"));
    machine_init();     /* initialise machine-specific stuff */

    /* Initialize the screen */
    KDEBUG(("screen_init()\n"));
    screen_init();      /* detect monitor type, ... */

    /* Initialize the BIOS memory management */
    KDEBUG(("bmem_init()\n"));
    bmem_init();        /* this must be done after screen_init() */

    KDEBUG(("cookie_init()\n"));
    cookie_init();      /* sets a cookie jar */
    KDEBUG(("fill_cookie_jar()\n"));
    fill_cookie_jar();  /* detect hardware features and fill the cookie jar */

    /* Set up the BIOS console output */
    KDEBUG(("linea_init()\n"));
    linea_init();       /* initialize screen related line-a variables */
    font_init();        /* initialize font ring (requires cookie_akp) */
    font_set_default(-1);/* set default font */
    vt52_init();        /* initialize the vt52 console */

    /* Now kcprintf() will also send debug info to the screen */
    KDEBUG(("after vt52_init()\n"));

    /* misc. variables */
    dumpflg = -1;
    sysbase = (LONG) os_entry;
    savptr = (LONG) trap_save_area;
    etv_timer = (void(*)(int)) just_rts;
    etv_critic = default_etv_critic;
    etv_term = just_rts;

    /* setup VBL queue */
    nvbls = 8;
    vblqueue = vbl_list;
    {
        int i;
        for(i = 0 ; i < 8 ; i++) {
            vbl_list[i] = 0;
        }
    }

#if CONF_WITH_MFP
    KDEBUG(("mfp_init()\n"));
    mfp_init();
#endif

#if CONF_WITH_TT_MFP
    if (has_tt_mfp)
    {
        KDEBUG(("tt_mfp_init()\n"));
        tt_mfp_init();
    }
#endif

    /* Initialize the system 200 Hz timer */
    KDEBUG(("init_system_timer()\n"));
    init_system_timer();

    /* Initialize the RS-232 port(s) */
    KDEBUG(("chardev_init()\n"));
    chardev_init();     /* Initialize low-memory bios vectors */
    boot_status |= CHARDEV_AVAILABLE;   /* track progress */
    KDEBUG(("init_serport()\n"));
    init_serport();
    boot_status |= RS232_AVAILABLE;     /* track progress */
#if CONF_WITH_SCC
    if (has_scc)
        boot_status |= SCC_AVAILABLE;   /* track progress */
#endif

    /* The sound init must be done before allowing MFC interrupts,
     * because of dosound stuff in the timer C interrupt routine.
     */
#if CONF_WITH_DMASOUND
    KDEBUG(("dmasound_init()\n"));
    dmasound_init();
#endif
    KDEBUG(("snd_init()\n"));
    snd_init();         /* Reset Soundchip, deselect floppies */

    /* Init the two ACIA devices (MIDI and KBD). The three actions below can
     * be done in any order provided they happen before allowing MFP
     * interrupts.
     */
    KDEBUG(("kbd_init()\n"));
    kbd_init();         /* init keyboard, disable mouse and joystick */
    KDEBUG(("midi_init()\n"));
    midi_init();        /* init MIDI acia so that kbd acia irq works */
    KDEBUG(("init_acia_vecs()\n"));
    init_acia_vecs();   /* Init the ACIA interrupt vector and related stuff */
    KDEBUG(("after init_acia_vecs()\n"));
    boot_status |= MIDI_AVAILABLE;  /* track progress */

    /* Now we can enable the interrupts.
     * We need a timer for DMA timeouts in floppy and harddisk initialisation.
     * The VBL processing will be enabled later with the vblsem semaphore.
     */
#if CONF_WITH_ATARI_VIDEO
    /* Keep the HBL disabled */
    set_sr(0x2300);
#else
    set_sr(0x2000);
#endif

    KDEBUG(("calibrate_delay()\n"));
    calibrate_delay();  /* determine values for delay() function */
                        /*  - requires interrupts to be enabled  */
    KDEBUG(("blkdev_init()\n"));
    blkdev_init();      /* floppy and harddisk initialisation */
    KDEBUG(("after blkdev_init()\n"));

    /* initialize BIOS components */

    KDEBUG(("parport_init()\n"));
    parport_init();     /* parallel port */
    //mouse_init();     /* init mouse driver */
    KDEBUG(("clock_init()\n"));
    clock_init();       /* init clock */
    KDEBUG(("after clock_init()\n"));

#if CONF_WITH_NLS
    KDEBUG(("nls_init()\n"));
    nls_init();         /* init native language support */
    nls_set_lang(get_lang_name());
#endif

    /* set start of user interface */
#if WITH_AES
    exec_os = ui_start;
#elif WITH_CLI
    exec_os = coma_start;
#else
    exec_os = NULL;
#endif

    KDEBUG(("osinit()\n"));
    osinit();                   /* initialize BDOS */
    KDEBUG(("after osinit()\n"));
    boot_status |= DOS_AVAILABLE;   /* track progress */

    /* Enable VBL processing */
    vblsem = 1;

#if CONF_WITH_CARTRIDGE
    {
        WORD save_hz = v_hz_rez, save_vt = v_vt_rez, save_pl = v_planes;

        /* Run all boot applications from the application cartridge.
         * Beware: Hatari features a special cartridge which is used
         * for GEMDOS drive emulation. It will hack drvbits and hook Pexec().
         * It will also hack Line A variables to enable extended VDI video modes.
         */
        KDEBUG(("run_cartridge_applications(3)\n"));
        run_cartridge_applications(3); /* Type "Execute prior to bootdisk" */
        KDEBUG(("after run_cartridge_applications()\n"));

        if ((v_hz_rez != save_hz) || (v_vt_rez != save_vt) || (v_planes != save_pl))
        {
            set_rez_hacked();
            font_set_default(-1);   /* set default font */
            vt52_init();            /* initialize the vt52 console */
        }
    }
#endif

#if CONF_WITH_ALT_RAM

#if CONF_WITH_FASTRAM
    /* add TT-RAM that was detected in memory.S */
    if (ramtop != NULL)
    {
        KDEBUG(("xmaddalt()\n"));
        xmaddalt(FASTRAM_START, ramtop - FASTRAM_START);
    }
#endif

#if CONF_WITH_MONSTER
    /* Add MonSTer alt-RAM detected in machine.c */
    if (has_monster)
    {
        /* Dummy read from MonSTer register to initiate write sequence. */
        unsigned short monster_reg = *(volatile unsigned short *)MONSTER_REG;

        /* Only enable 6Mb when on a Mega STE due to address conflict with
           VME bus. Todo: This should be made configurable. */
        if (has_vme)
            monster_reg = 6;
        else
            monster_reg = 8;

        /* Register write sequence: read - write - write */
        *(volatile unsigned short *)MONSTER_REG = monster_reg;
        *(volatile unsigned short *)MONSTER_REG = monster_reg;
        KDEBUG(("xmaddalt()\n"));
        xmaddalt((UBYTE *)0x400000L, monster_reg*0x100000L);
    }
#endif

#ifdef MACHINE_AMIGA
    KDEBUG(("amiga_add_alt_ram()\n"));
    amiga_add_alt_ram();
#endif

#endif /* CONF_WITH_ALT_RAM */

    KDEBUG(("bios_init() end\n"));
}
예제 #11
0
int
main(int argc,char **argv)
{
  int option ;
  const char *unzipper = NULL ;
  const char *infile = NULL ;

  setlocale(LC_ALL,"");
  progname = argv[0] ;
  nls_init();

  if( argc <= 1 ) gpl_blurb() ;
  
  init_flatspec(&flatspec) ;
  flatspec.out_color_mode = COLOR_BY_FILENAME ;
  while( (option=getopt_long(argc,argv,"-@#"OPTSTRING,longopts,NULL)) >= 0 )
    switch(option) {
      #define OPTION(char,long,desc,man) case char:
      #include "options.i"
    case 1:
      if( infile ) 
        add_layer_request(&flatspec,optarg);
      else
        infile = optarg ;
      break ;
    case '?':
      usage(stderr);
    case '@':
      /* Non-documented option for build-time test */
      suppress_byline = 1 ;
      break ;
    case '#':
      /* Non-documented option for xcfview */
      flatspec.default_pixel = CHECKERED_BACKGROUND ;
      break ;
    default:
      FatalUnexpected("Getopt(_long) unexpectedly returned '%c'",option);
    }
  if( infile == NULL ) {
    usage(stderr);
  }

  if( flatspec.out_color_mode == COLOR_BY_FILENAME &&
      strlen(flatspec.output_filename) > 4 &&
      flatspec.output_filename[strlen(flatspec.output_filename)-4] == '.' )
    flatspec.out_color_mode = guess_color_mode(flatspec.output_filename);

  /* If the output filename was not enough cue, see if we're running
   * through a symlink/hardlink that gives the required output format
   */
  if( flatspec.out_color_mode == COLOR_BY_FILENAME &&
      strlen(progname) > 3 )
    flatspec.out_color_mode = guess_color_mode(progname);
  
  if( flatspec.out_color_mode == COLOR_BY_FILENAME )
    flatspec.out_color_mode = COLOR_BY_CONTENTS ;
  
  read_or_mmap_xcf(infile,unzipper);
  getBasicXcfInfo() ;
  initColormap();
 
  complete_flatspec(&flatspec,NULL);
  if( flatspec.process_in_memory ) {
    rgba **allPixels = flattenAll(&flatspec);
    analyse_colormode(&flatspec,allPixels,NULL);
    shipoutWithCallback(&flatspec,allPixels,selectCallback());
  } else {
    flattenIncrementally(&flatspec,selectCallback());
  }
  closeout(outfile,flatspec.output_filename) ;
  closeout(transfile,flatspec.transmap_filename) ;
  return 0 ;
}