/*----------------------------------------------------------------------
  Parameters:

  Description:
  ----------------------------------------------------------------------*/
static int
get_option(int argc, char *argv[])
{
  int  nargs = 0 ;
  char *option ;

  option = argv[1] + 1 ;            /* past '-' */
  if (!stricmp(option, "-help"))
    print_help() ;
  else if (!stricmp(option, "-version"))
    print_version() ;
  else if (!stricmp(option, "src_type"))
  {
    srctypestring = argv[2];
    srctype = string_to_type(srctypestring);
    nargs = 1 ;
  }
  else if (!stricmp(option, "trg_type"))
  {
    trgtypestring = argv[2];
    trgtype = string_to_type(srctypestring);
    nargs = 1 ;
  }
  else if (!stricmp(option, "abspath"))
  {
    pathflag = 1;
  }
  else if (!stricmp(option, "neg"))
  {
    negflag = 1 ;
  }
  else if (!stricmp(option, "debug"))
  {
    debugflag = 1;
    debugvtx = atoi(argv[2]);
    nargs = 1;
  }
  else
  {
    fprintf(stderr, "unknown option %s\n", argv[1]) ;
    print_help() ;
    exit(1) ;
  }

  return(nargs) ;
}
void
OSOReaderQuery::hint (const char *hintstring)
{
    if (m_reading_param && ! strncmp (hintstring, "%meta{", 6)) {
        hintstring += 6;
        // std::cerr << "  Metadata '" << hintstring << "'\n";
        std::string type = readuntil (&hintstring, ',', '}');
        std::string name = readuntil (&hintstring, ',', '}');
        // std::cerr << "    " << name << " : " << type << "\n";
        OSLQuery::Parameter p;
        p.name = name;
        p.type = string_to_type (type.c_str());
        if (p.type.basetype == TypeDesc::STRING) {
            while (*hintstring == ' ')
                ++hintstring;
            while (hintstring[0] == '\"') {
                ++hintstring;
                p.sdefault.push_back (readuntil (&hintstring, '\"'));
            }
        } else if (p.type.basetype == TypeDesc::INT) {
            while (*hintstring == ' ')
                ++hintstring;
            while (*hintstring && *hintstring != '}') {
                p.idefault.push_back (atoi (hintstring));
                readuntil (&hintstring, ',', '}');
            }
        } else if (p.type.basetype == TypeDesc::FLOAT) {
            while (*hintstring == ' ')
                ++hintstring;
            while (*hintstring && *hintstring != '}') {
                p.fdefault.push_back (atof (hintstring));
                readuntil (&hintstring, ',', '}');
            }
        }
        m_query.m_params[m_query.nparams()-1].metadata.push_back (p);
        return;
    }
    if (m_reading_param && ! strncmp (hintstring, "%structfields{", 14)) {
        hintstring += 14;
        OSLQuery::Parameter &param (m_query.m_params[m_query.nparams()-1]);
        while (*hintstring) {
            std::string afield = readuntil (&hintstring, ',', '}');
            param.fields.push_back (afield);
        }
        return;
    }
    if (m_reading_param && ! strncmp (hintstring, "%struct{", 8)) {
        hintstring += 8;
        if (*hintstring == '\"')  // skip quote
            ++hintstring;
        OSLQuery::Parameter &param (m_query.m_params[m_query.nparams()-1]);
        param.structname = readuntil (&hintstring, '\"', '}');
        return;
    }
    // std::cerr << "Hint '" << hintstring << "'\n";
}
int CustomTypeParser::parse(std::string &data, std::string &type) {
	MyCustomType my_type;
	int result_code = string_to_type(data, my_type);
	if (result_code != 0) {
		std::cerr << data << " format is wrong ! type = " << type << std::endl;
		return -1;
	}
	std::string custom_str = type_to_string(my_type);
	std::cout << " custom type " << custom_str << std::endl;
	return 0;
}
Exemple #4
0
/*------------------------------------------------------------*/
static int checkfmt(char *fmt) {
  int fmtid;

  if (fmt == NULL) return(MRI_VOLUME_TYPE_UNKNOWN);
  fmtid = string_to_type(fmt);
  if (fmtid == MRI_VOLUME_TYPE_UNKNOWN) {
    printf("ERROR: format string %s unrecognized\n",fmt);
    exit(1);
  }
  return(fmtid);
}
void SuperFamicomCartridge::read_hash(const netnode & node)
{
  char buf[MAXSTR];
  ssize_t len;

  rom_size = node.hashval_long("rom_size");
  ram_size = node.hashval_long("ram_size");
  firmware_appended = node.hashval_long("firmware_appended") != 0;

  header_offset = node.hashval_long("header_offset");

  len = node.hashstr("type", buf, sizeof(buf));
  if(len >= 0) type = string_to_type(buf);
  len = node.hashstr("region", buf, sizeof(buf));
  if(len >= 0) region = string_to_region(buf);
  len = node.hashstr("mapper", buf, sizeof(buf));
  if(len >= 0) mapper = string_to_mapper(buf);
  len = node.hashstr("dsp1_mapper", buf, sizeof(buf));
  if(len >= 0) dsp1_mapper = string_to_dsp1_mapper(buf);

  has_bsx_slot = node.hashval_long("has_bsx_slot") != 0;
  has_superfx = node.hashval_long("has_superfx") != 0;
  has_sa1 = node.hashval_long("has_sa1") != 0;
  has_sharprtc = node.hashval_long("has_sharprtc") != 0;
  has_epsonrtc = node.hashval_long("has_epsonrtc") != 0;
  has_sdd1 = node.hashval_long("has_sdd1") != 0;
  has_spc7110 = node.hashval_long("has_spc7110") != 0;
  has_cx4 = node.hashval_long("has_cx4") != 0;
  has_dsp1 = node.hashval_long("has_dsp1") != 0;
  has_dsp2 = node.hashval_long("has_dsp2") != 0;
  has_dsp3 = node.hashval_long("has_dsp3") != 0;
  has_dsp4 = node.hashval_long("has_dsp4") != 0;
  has_obc1 = node.hashval_long("has_obc1") != 0;
  has_st010 = node.hashval_long("has_st010") != 0;
  has_st011 = node.hashval_long("has_st011") != 0;
  has_st018 = node.hashval_long("has_st018") != 0;
}
Exemple #6
0
enum datafile_type string_to_datafile_type(const char *datafile_type)
{
  return (enum datafile_type)string_to_type(datafile_type_table, datafile_type);
}