char *VC2Decoder::FindNextParseInfo(char *_idata, int ilength) {
	VC2DecoderParseSegment pi;

	char *idata = _idata;
	int offset = 0;

	while (offset < ilength) {
		try {
			pi = parse_info(&idata[offset]);
		}
		catch (VC2DecoderResult &r) {
			if (r == VC2DECODER_NOTPARSEINFO) {
				offset++;
				continue;
			}
			else
				throw;
		}
		break;
	}

	if (offset >= ilength) {
		return NULL;
	}

	return idata + offset;
}
blargg_err_t Sap_Emu::load_mem_( byte const in [], int size )
{
	file_end = in + size;
	
	info_.warning    = NULL;
	info_.type       = 'B';
	info_.stereo     = false;
	info_.init_addr  = -1;
	info_.play_addr  = -1;
	info_.music_addr = -1;
	info_.fastplay   = 312;
	RETURN_ERR( parse_info( in, size, &info_ ) );
	
	set_warning( info_.warning );
	set_track_count( info_.track_count );
	set_voice_count( Sap_Apu::osc_count << info_.stereo );
	core.apu_impl().volume( gain() );
	
	static const char* const names [Sap_Apu::osc_count * 2] = {
		"Wave 1", "Wave 2", "Wave 3", "Wave 4",
		"Wave 5", "Wave 6", "Wave 7", "Wave 8",
	};
	set_voice_names( names );
	
	static int const types [Sap_Apu::osc_count * 2] = {
		wave_type+1, wave_type+2, wave_type+3, wave_type+0,
		wave_type+5, wave_type+6, wave_type+7, wave_type+4,
	};
	set_voice_types( types );
	
	return setup_buffer( 1773447 );
}
Exemple #3
0
imputed_data
parse_imputed_data(const std::string &prefix, float call_rate)
{
    imputed_data data;

    data.info = parse_info( prefix + "_info" );
    data.samples = parse_sample( prefix + "_samples" );
    data.genotypes = parse_genotypes( prefix, call_rate, data.samples );
        
    return data;
}
VC2DecoderSequenceResult VC2Decoder::sequenceSynchronise(char **_idata, int ilength, bool skip_aux) {
	VC2DecoderParseSegment pi;

	char *idata = *_idata;
	int offset = 0;

	while (offset < ilength) {
		try {
			pi = parse_info(&idata[offset]);
		}
		catch (VC2DecoderResult &r) {
			if (r == VC2DECODER_NOTPARSEINFO) {
				offset++;
				continue;
			}
			else
				throw;
		}
		switch (pi.parse_code) {
		case VC2DECODER_PARSE_CODE_SEQUENCE_HEADER:
			break;

		case VC2DECODER_PARSE_CODE_AUXILIARY_DATA:
			if (!skip_aux) {
				*_idata = &idata[offset];
				return VC2DECODER_AUXILIARY;
			}
		default:
			if (pi.next_header == NULL) {
				offset += 13;
			}
			else {
				offset = pi.next_header - idata;
			}
			continue;
		}
		break;
	}

	if (offset >= ilength) {
		return VC2DECODER_EOS;
	}

	parseSeqHeader(pi.data);

	*_idata = pi.next_header;

	return VC2DECODER_RECONFIGURED;
}
Exemple #5
0
blargg_err_t Sap_Emu::load_mem_( byte const* in, long size )
{
	file_end = in + size;
	
	info.warning    = 0;
	info.type       = 'B';
	info.stereo     = false;
	info.init_addr  = -1;
	info.play_addr  = -1;
	info.music_addr = -1;
	info.fastplay   = 312;
	RETURN_ERR( parse_info( in, size, &info ) );
	
	set_warning( info.warning );
	set_track_count( info.track_count );
	set_voice_count( Sap_Apu::osc_count << info.stereo );
	apu_impl.volume( gain() );
	
	return setup_buffer( 1773447 );
}
Exemple #6
0
GA::info GA::evaluate(const Chromosome& chromosome) const {
  string chromosome_str = to_string(chromosome);
  auto it = cache.find(chromosome_str);
  if (it != cache.end()) {
    return it->second;
  }

  create_factor_file(chromosome);
  sys(flm_conf.make_fngram_command(chromosome_str, ga_conf.ga_path));

  info chromosome_info = parse_info(
    ga_conf.ga_path + chromosome_str + ".EvalLog",
    ga_conf.ga_path + chromosome_str + ".complexity"
  );
  
  chromosome_info.fitness = ga_conf.fitness_function->evaluate(
    chromosome_info.logprob, chromosome_info.perplexity, chromosome_info.complexity);
  
  return cache[chromosome_str] = chromosome_info;
}
int VC2Decoder::sequenceExtractAux(char **_idata, int ilength, uint8_t **odata) {
	VC2DecoderParseSegment pi;
	char *idata = *_idata;

	if (ilength < 13)
		throw VC2DECODER_CODEROVERRUN;

	pi = parse_info(idata);

	if (pi.parse_code != VC2DECODER_PARSE_CODE_AUXILIARY_DATA) {
		throw VC2DECODER_NOTPARSEINFO;
	}

	if (pi.next_header >= (*_idata) + ilength)
		throw VC2DECODER_CODEROVERRUN;

	*odata = (uint8_t *)pi.data;
	*_idata = pi.next_header;

	return pi.next_header - pi.data;
}
Exemple #8
0
int 
main(int argc, char **argv) {

  char *info;
  int n_failed;
  struct swift_context *c;
  swift_error e;

  info = (char *)malloc(strlen(INTEGRATION) + 1);
  strcpy(info, INTEGRATION);

  if (!parse_info(info, &username, &password, &url)) {
    exit(EXIT_FAILURE);
  }
  printf("Testing with user %s against server: %s\n", username, url);

  swift_init();
  e = swift_context_create(&c, url, username, password);
  if (e) {
    printf("Error creating context!\n");
    exit(EXIT_FAILURE);
  }
  e = swift_can_connect(c);
  if (e) {
    printf("Can't connect to test server! Are you sure it was specified?\n");
    exit(EXIT_FAILURE);
  }

  swift_context_delete(&c);


  Suite *s = swift_integration();
  SRunner *sr = srunner_create(s);
  srunner_run_all(sr, CK_VERBOSE);
  n_failed = srunner_ntests_failed(sr);
  srunner_free(sr);
  return (n_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;

}
static void parse_message(char *msg)
{
    ServiceContext *context = get_service_context();
    char *data = NULL;
    char *idx = strchr(msg, ':');

    if(idx)
        asprintf(&data, "%s", idx + 1);
    else
        asprintf(&data, "%s", "");

    if (strstr(msg, MSG_BACKGROUND_DATA_SETTING)) {
        LOGD("Background data allowed: %s", data);
        if (strstr(data, "true")) {
            context->background_data_allowed = 1;
            gpsctrl_set_background_data_allowed(1);
        } else {
            context->background_data_allowed = 0;
            gpsctrl_set_background_data_allowed(0);
        }
    } else if (strstr(msg, MSG_MOBILE_DATA_ALLOWED)) {
        LOGD("Data enabled: %s", data);
        if (strstr(data, "true")) {
            context->data_enabled = 1;
            gpsctrl_set_data_enabled(1);
        } else {
            context->data_enabled = 0;
            gpsctrl_set_data_enabled(0);
        }
    } else if (strstr(msg, MSG_ROAMING_ALLOWED)) {
        LOGD("Roaming data allowed: %s", data);
        if (strstr(data, "true")) {
            context->roaming_data_allowed = 1;
            gpsctrl_set_data_roaming_allowed(1);
        } else {
            context->roaming_data_allowed = 0;
            gpsctrl_set_data_roaming_allowed(0);
        }
    } else if (strstr(msg, MSG_APN_INFO)) {
        char apn[MAX_APN_LENGTH];
        char username[MAX_USERNAME_LENGTH];
        char password[MAX_PASSWORD_LENGTH];
        char auth[MAX_AUTHTYPE_LENGTH];

        LOGD("%s: %s", MSG_APN_INFO, data);

        if (0 != parse_info(apn, data, "apn=", MAX_APN_LENGTH))
            return;
        if (0 != parse_info(username, data, "user="******"pass="******"authtype=", MAX_AUTHTYPE_LENGTH))
            return;

        gpsctrl_set_apn_info(apn, username, password, auth);
    } else if (strstr(msg, MSG_PGPS_DATA)) {
        char path[MAX_PATH_LENGTH];
        char s_id[10];
        int id;

        LOGD("%s: %s", MSG_PGPS_DATA, data);

        if (strstr(data, "failed"))
            onPgpsDataFailed();
        else {
            if (0 != parse_info(s_id, data, "id=", MAX_PATH_LENGTH)) {
                LOGD("FAILED TO PARSE ID");
                onPgpsDataFailed();
                return;
            }
            if (0 != parse_info(path, data, "path=", MAX_PATH_LENGTH)) {
                LOGD("FAILED TO PARSE PATH");
                onPgpsDataFailed();
                return;
            }

            id = atoi(s_id);
            pgps_read_data(id, path);
        }
    } else {
        LOGD("Unknown message from mbm service received: %s", data);
    }
}
Exemple #10
0
	blargg_err_t load_mem_( byte const* begin, long size )
	{
		RETURN_ERR( parse_info( begin, size, &info ) );
		set_track_count( info.track_count );
		return 0;
	}
Exemple #11
0
int uci_parse(uci_t * uci, const char string[]) {

   int event;
   parse_t parse[1];
   char command[StringSize];
   char argument[StringSize];

   ASSERT(uci_is_ok(uci));
   ASSERT(string!=NULL);

   // init

   event = EVENT_NONE;

   // parse

   parse_open(parse,string);

   if (parse_get_word(parse,command,StringSize)) {

      parse_get_string(parse,argument,StringSize);
      if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" ARGUMENT \"%s\"\n",command,argument);

      if (false) {

      } else if (my_string_equal(command,"bestmove")) {

         // search end

         ASSERT(uci->pending_nb>0);

         if (uci->searching && uci->pending_nb == 1) {

            // current search

            uci->searching = false;
            uci->pending_nb--;

            event = parse_bestmove(uci,argument); // updates uci->best_move and uci->ponder_move

         } else {

            // obsolete search

            if (uci->pending_nb > 0) {
               uci->pending_nb--;
               if (uci->pending_nb == 0) event = EVENT_STOP;
            }
         }

      } else if (my_string_equal(command,"id")) {

         parse_id(uci,argument);

      } else if (my_string_equal(command,"info")) {

         // search information

         if (uci->searching && uci->pending_nb == 1) { // current search
            event = parse_info(uci,argument);
         }

      } else if (my_string_equal(command,"option")) {

         parse_option(uci,argument);

      } else if (my_string_equal(command,"readyok")) {

         // engine is ready

         ASSERT(uci->ready_nb>0);

         if (uci->ready_nb > 0) {
            uci->ready_nb--;
            if (uci->ready_nb == 0) event = EVENT_READY;
         }

      } else if (my_string_equal(command,"uciok")) {

         event = EVENT_UCI;

      } else {

         if (UseDebug) my_log("POLYGLOT unknown command \"%s\"\n",command);
      }
   }

   parse_close(parse);

   return event;
}
VC2DecoderSequenceResult VC2Decoder::sequenceDecodeOnePicture(char **_idata, int ilength, uint16_t **odata, int *ostride, bool skip_aux) {
	VC2DecoderParseSegment pi;
	char *idata = *_idata;
	char *iend = *_idata + ilength;

	try {
		while (idata < *(_idata)+ilength) {
			pi = parse_info(idata);
			if ((uint64_t)idata >(uint64_t)iend) {
				writelog(LOG_ERROR, "%s:%d:  Data Unit is off end of input data\n", __FILE__, __LINE__);
				throw VC2DECODER_CODEROVERRUN;
			}
			switch (pi.parse_code) {
			case VC2DECODER_PARSE_CODE_SEQUENCE_HEADER:
				if (parseSeqHeader(pi.data)) {
					*_idata = pi.next_header;
					return VC2DECODER_RECONFIGURED;
				}
				break;

			case VC2DECODER_PARSE_CODE_END_OF_SEQUENCE:
				*_idata = idata + 13;
				return VC2DECODER_EOS;

			case VC2DECODER_PARSE_CODE_AUXILIARY_DATA:
				if (!skip_aux) {
					*_idata = idata;
					return VC2DECODER_AUXILIARY;
				}
			case VC2DECODER_PARSE_CODE_PADDING_DATA:
				break;

			case VC2DECODER_PARSE_CODE_CORE_PICTURE_AC:
			case VC2DECODER_PARSE_CODE_CORE_PICTURE_VLC:
			case VC2DECODER_PARSE_CODE_LD_PICTURE:
				*_idata = pi.next_header;
				return VC2DECODER_INVALID_PICTURE;

			case VC2DECODER_PARSE_CODE_HQ_PICTURE:
			{
				uint64_t length = decodeFrame(pi.data, iend - pi.data, odata, ostride);
				if (pi.next_header != NULL) {
					*_idata = pi.next_header;
				}
				else {
					*_idata = FindNextParseInfo(idata + length, iend - (idata + length));
				}
			}
			return VC2DECODER_PICTURE;

			default:
				writelog(LOG_WARN, "%s:%d:  Unknown parse code 0x%02x\n", __FILE__, __LINE__, pi.parse_code);
				break;
			}

			if (pi.next_header == NULL) {
				*_idata = idata + 13;
				return VC2DECODER_EOS;
			}

			idata = pi.next_header;
		}
	}
	catch (VC2DecoderResult &r) {
		if (r == VC2DECODER_NOTPARSEINFO) {
			writelog(LOG_ERROR, "%s:%d:  No Parse Info Header Where One was Expected\n", __FILE__, __LINE__);
			throw VC2DECODER_BADSTREAM;
		}
		throw;
	}

	writelog(LOG_WARN, "%s:%d: Premature end of stream\n", __FILE__, __LINE__);
	*_idata += ilength;
	return VC2DECODER_EOS;
}
Exemple #13
0
	blargg_err_t load_mem_( byte const begin [], int size )
	{
		RETURN_ERR( parse_info( begin, size, &info ) );
		set_track_count( info.track_count );
		return blargg_ok;
	}