Exemple #1
0
int main( int argc, char **argv )
{
	int a;
	struct params params;

	params_init( &params );
	for ( a = 1; a < argc; a++ )
		params_execute( &params, argv[a], strlen(argv[a])+1 );
	if ( params_finish( &params ) != 1 )
		fprintf( stderr, "params: error processing arguments\n" );

	return 0;
}
Exemple #2
0
int dgreed_main(int argc, const char** argv) {
    params_init(argc, argv);

    dgreed_preinit();
    dgreed_init(argc, argv);
    while(true) {
        if(!dgreed_update())
            break;
        if(!dgreed_render())
            break;
    }
    dgreed_close();

    return 0;
}
Exemple #3
0
/* Just unit test */
int main(void){

	int exit_code;
	char* key;

	if((exit_code=params_init())){
		return exit_code;
	}

	/*
	 * use here...
	 */
	key = "prop1";
	printf("value for key %s: %s", key, params_get(key));

	return 0;
}
Exemple #4
0
int dgreed_main(int argc, const char** argv) {
	params_init(argc, argv);
	rand_init(time(NULL));
	layouts_init();
	layouts_set("dvorak");

	bool fullscreen = true;
	if(params_find("-windowed") != ~0)
		fullscreen = false;

	video_init_ex(SCREEN_WIDTH, SCREEN_HEIGHT, 
		SCREEN_WIDTH, SCREEN_HEIGHT, "KeyMingler", fullscreen);
	font = font_load(FONT_FILE);	
	float text_width = font_width(font, LOADING_TEXT);
	float text_height = font_height(font);
	Vector2 pos = vec2((SCREEN_WIDTH - text_width) / 2.0f,
		(SCREEN_HEIGHT - text_height) / 2.0f);
	font_draw(font, LOADING_TEXT, 0, &pos, COLOR_WHITE);	
	video_present();
	system_update();

	game_init();
	sounds_init();
	music = sound_load_stream(MUSIC_FILE);
	sound_play(music);

	while(system_update()) {
		game_update();
		game_render();
		video_present();
		sound_update();

		if(key_up(KEY_QUIT))
			break;
	}
	
	font_free(font);
	sound_free(music);
	sounds_close();
	game_close();
	video_close();
	layouts_close();

	return 0;
}
Exemple #5
0
bool dgreed_init(int argc, const char** argv) {
#ifndef _WIN32
    params_init(argc, argv);
#else
    params_init(1, NULL);
#endif

    rand_init(432);

    const char* sprsheet = ASSETS_PRE "sprsheet_768p.mml";
    const char* particles = "particles.mml";
    uint width = 1024;
    uint height = 768;
    uint v_width = 1024;
    uint v_height = 768;

    uint n_width, n_height;
    video_get_native_resolution(&n_width, &n_height);

    LOG_INFO("Native resolution %u %u", n_width, n_height);

    // Select screen size
    scr_size = SCR_IPAD;
    if(params_find("-iphone5") != ~0 || (n_width == 1136 && n_height == 640)) {
        LOG_INFO("iphone5");
        sprsheet = ASSETS_PRE "sprsheet_640p.mml";
        particles = "particles_small.mml";
        scr_size = SCR_IPHONE;
        v_width = 568;
        v_height = 320;
        width = v_width * 2;
        height = v_height * 2;
        retina = true;
    }
    else if(params_find("-retinaipad") != ~0 || (n_width == 2048 && n_height == 1536)) {
        LOG_INFO("retina ipad");
        sprsheet = ASSETS_PRE "sprsheet_1536p.mml";
        width = 2048;
        height = 1536;
        retina = true;
    }
    else if(params_find("-iphone") != ~0 || (n_width < 960 || n_height < 640)) {
        LOG_INFO("iphone");
        sprsheet = ASSETS_PRE "sprsheet_320p.mml";
        particles = "particles_small.mml";
        scr_size = SCR_IPHONE;
        v_width = width = 480;
        v_height = height = 320;
    }
    else if(params_find("-retina") != ~0 || (n_width < 1024 || n_height < 768)) {
        LOG_INFO("retina iphone");
        sprsheet = ASSETS_PRE "sprsheet_640p.mml";
        particles = "particles_small.mml";
        scr_size = SCR_IPHONE;
        v_width = 480;
        v_height = 320;
        width = v_width * 2;
        height = v_height * 2;
        retina = true;
    }

    video_init_ex(width, height, v_width, v_height, "nulis", false);
    sound_init();

    keyval_init("nulis2_progress.db");
    keyval_set_bool("unlocked", true);

    particles_init_ex(ASSETS_PRE, particles, 4);
    mfx_init(ASSETS_PRE "effects.mml");

    malka_init();
    malka_params(argc, argv);
    malka_register(bind_open_nulis2);

    sprsheet_init(sprsheet);

    malka_states_init(SCRIPTS_PRE "main.lua");
    malka_states_start();

    return true;
}
// ----------------------------------------------------------------------------
// tmain
// ----------------------------------------------------------------------------
int tmain(int argc, TCHAR *argv[])
{
  int ii, ac, opt;
  TCHAR *s, *av[MAXC], *errtxt;
  TCHAR geoid[MAXS+1];
  int value, tr, rev, warn;
  TCHAR inpname[MAXS+1], outname[MAXS+1], prjname[MAXS+1];
  static GEOGRA ifl, ofl; static GEOUTM ixy, oxy;
  struct timespec start, stop;
  double tdif;
  SHPHandle iSHP, oSHP;
  DBFHandle iDBF, oDBF;
  int nShapeType, nEntities; //, nVertices, nParts;
  int nEntity, nVertex, nPart;
  double adfMinBound[4], adfMaxBound[4];
  SHPObject *psShape;
  TCHAR *pszPartType, *pszPlus;
  TCHAR *iTuple, *oTuple;
  FILE *out; TCHAR *proj;
  int nPercentBefore, nPercent;

  // Get program name
  if ((prog = strrchr(argv[0], DIRSEP)) == NULL) prog = argv[0];
  else prog++;
  if ((s = strstr(prog, T(".exe"))) != NULL) *s = T('\0');
  if ((s = strstr(prog, T(".EXE"))) != NULL) *s = T('\0');

  // Default global flags
  debug = 0;   // no debug
  tr = 1;      // default transformation: xy (d96tm) --> fila (etrs89)
  rev = 0;     // don't reverse xy/fila
  geoid[0] = T('\0');
  gid_wgs = 1; // slo2000
  hsel = -1;   // no default height processing (use internal recommendations)

  // Parse command line
  ac = 0; opt = 1;
  for (ii = 1; ii < argc && ac < MAXC; ii++) {
    if (opt && *argv[ii] == T('-')) {
      if (strcasecmp(argv[ii], T("-g")) == 0) { // geoid
        ii++; if (ii >= argc) goto usage;
        xstrncpy(geoid, argv[ii], MAXS);
        if (strlen(geoid) == 0) goto usage;
        if (strncasecmp(geoid, T("slo"), 1) == 0) gid_wgs = 1;      // slo2000
        else if (strncasecmp(geoid, T("egm"), 1) == 0) gid_wgs = 2; // egm2008
        else goto usage;
        continue;
      }
      else if (strcasecmp(argv[ii], T("-t")) == 0) { // transformation
        ii++; if (ii >= argc) goto usage;
        if (strlen(argv[ii]) == 0) goto usage;
        errno = 0; value = strtol(argv[ii], &s, 10);
        if (errno || *s) goto usage;
        if (value < 1 || value > 10) goto usage;
        tr = value;
        continue;
      }
      else if (strcasecmp(argv[ii], T("-ht")) == 0) { // transformed height
        hsel = 0;
        continue;
      }
      else if (strcasecmp(argv[ii], T("-hc")) == 0) { // copy height
        hsel = 1;
        continue;
      }
      else if (strcasecmp(argv[ii], T("-hg")) == 0) { // geoid height
        hsel = 2;
        continue;
      }
      else if (strcasecmp(argv[ii], T("--")) == 0) { // end of options
        opt = 0;
        continue;
      }
      s = argv[ii];
      while (*++s) {
        switch (*s) {
          case T('d'): // debug
            debug++;
            break;
          case T('r'): // reverse xy/fila
            rev = 1;
            break;
          case T('v'): // version
            usage(prog, 1); // show version only
            exit(0);
            break;
          default: // usage
usage:      usage(prog, 0);
            exit(1);
        }
      }
      continue;
    } // if opt
    av[ac] = (TCHAR *)malloc(MAXS+1);
    if (av[ac] == NULL) {
      errtxt = xstrerror();
      if (errtxt != NULL) {
        fprintf(stderr, T("malloc(av): %s\n"), errtxt); free(errtxt);
      } else
        fprintf(stderr, T("malloc(av): Unknown error\n"));
      exit(3);
    }
    xstrncpy(av[ac++], argv[ii], MAXS);
  } // for each argc
  av[ac] = NULL;

  ellipsoid_init();
  params_init();

  if (ac < 2) goto usage;

  if ((s = strrchr(av[0], T('.'))) != NULL) *s = T('\0'); // clear current extension
  xstrncat(av[0], T(".shp"), MAXS); // look for <name>.shp

  convert_shp_file(av[0], av[1], NULL);

  return 0;
} /* main */
Exemple #7
0
int main( int argc, char** argv )
{
  CCP4program prog( "cecalc", "0.1", "$Date: 2004/07/01" );

  // defaults
  clipper::String ipfile = "NONE";
  clipper::String ipcolfo = "NONE";
  clipper::String opfile = "ecalc.mtz";
  clipper::String opcol = "ecalc";
  const int nprm = 12;

  // command input
  CommandInput args( argc, argv, true );
  int arg = 0;
  while ( ++arg < args.size() ) {
    if ( args[arg] == "-mtzin" ) {
      if ( ++arg < args.size() ) ipfile = args[arg];
    } else if ( args[arg] == "-mtzout" ) {
      if ( ++arg < args.size() ) opfile = args[arg];
    } else if ( args[arg] == "-colin-fo" ) {
      if ( ++arg < args.size() ) ipcolfo = args[arg];
    } else if ( args[arg] == "-colout" ) {
      if ( ++arg < args.size() ) opcol = args[arg];
    } else {
      std::cout << "Unrecognized:\t" << args[arg] << "\n";
      args.clear();
    }
  }
  if ( args.size() <= 1 ) {
    std::cout << "Usage: cecalc\n\t-mtzin <filename>\n\t-mtzout <filename>\n\t-colin-fo <colpath>\n\t-colout <colpath>\nCalculate E's from F's\n";
    exit(1);
  }

  // make data objects
  clipper::CCP4MTZfile mtzin, mtzout;
  clipper::HKL_info hkls;
  typedef clipper::HKL_data_base::HKL_reference_index HRI;

  // open file
  mtzin.open_read( ipfile );
  mtzin.import_hkl_info( hkls );
  clipper::HKL_data<clipper::data32::F_sigF> fsig( hkls );
  mtzin.import_hkl_data( fsig, ipcolfo );
  if ( opcol[0] != '/' ) opcol = mtzin.assigned_paths()[0].notail()+"/"+opcol;
  mtzin.close_read();

  // create initial E
  clipper::HKL_data<clipper::data32::E_sigE> esig( hkls );
  esig.compute( fsig, clipper::data32::Compute_EsigE_from_FsigF() );

  // calc E-scaling
  std::vector<double> params_init( nprm, 1.0 );
  clipper::BasisFn_spline basis_fo( esig, nprm, 2.0 );
  clipper::TargetFn_scaleEsq<clipper::data32::E_sigE> target_fo( esig );
  clipper::ResolutionFn escale( hkls, basis_fo, target_fo, params_init );

  // apply E-scaling
  for ( HRI ih = esig.first(); !ih.last(); ih.next() )
    if ( !esig[ih].missing() ) esig[ih].scale( sqrt( escale.f(ih) ) );

  // output data
  mtzout.open_append( ipfile, opfile );
  mtzout.export_hkl_data( esig, opcol );
  mtzout.close_append();
}
Exemple #8
0
static
atf_error_t
process_params(int argc, char **argv, struct params *p)
{
    atf_error_t err;
    int ch;
    int old_opterr;

    err = params_init(p, argv[0]);
    if (atf_is_error(err))
        goto out;

    old_opterr = opterr;
    opterr = 0;
    while (!atf_is_error(err) &&
           (ch = getopt(argc, argv, GETOPT_POSIX ":lr:s:v:")) != -1) {
        switch (ch) {
        case 'l':
            p->m_do_list = true;
            break;

        case 'r':
            err = replace_path_param(&p->m_resfile, optarg);
            break;

        case 's':
            err = replace_path_param(&p->m_srcdir, optarg);
            break;

        case 'v':
            err = parse_vflag(optarg, &p->m_config);
            break;

        case ':':
            err = usage_error("Option -%c requires an argument.", optopt);
            break;

        case '?':
        default:
            err = usage_error("Unknown option -%c.", optopt);
        }
    }
    argc -= optind;
    argv += optind;

    /* Clear getopt state just in case the test wants to use it. */
    opterr = old_opterr;
    optind = 1;
#if defined(HAVE_OPTRESET)
    optreset = 1;
#endif

    if (!atf_is_error(err)) {
        if (p->m_do_list) {
            if (argc > 0)
                err = usage_error("Cannot provide test case names with -l");
        } else {
            if (argc == 0)
                err = usage_error("Must provide a test case name");
            else if (argc == 1)
                err = handle_tcarg(argv[0], &p->m_tcname, &p->m_tcpart);
            else if (argc > 1) {
                err = usage_error("Cannot provide more than one test case "
                                  "name");
            }
        }
    }

    if (atf_is_error(err))
        params_fini(p);

out:
    return err;
}