Ejemplo n.º 1
0
int
main ()
{
  char *p;

  next_element (getenv ("PATH"));
  while (p = next_element (NULL))
    puts (p);
  exit (0);
}
Ejemplo n.º 2
0
int user_create_ray (double *delta_t, double *energy,
		     double *cosx, double *cosy, double *cosz)
{
   if (Num_Rays == 0)
     {
	if (-1 == SLexecute_function (Create_Ray))
	  {
	     SLang_verror (0, "Encountered an error processing %s\n", "user_create_ray");
	     return -1;
	  }
	
	if (SLang_peek_at_stack () == SLANG_NULL_TYPE)
	  return -1;		       /* done */

	if ((-1 == pop_array (&CosZ_Array))
	    || (-1 == pop_array (&CosY_Array))
	    || (-1 == pop_array (&CosX_Array))
	    || (-1 == pop_array (&Energy_Array))
	    || (-1 == pop_array (&dT_Array)))
	  {
	     SLang_verror (0, "Encountered an error processing %s\n", "user_create_ray");
	     return -1;
	  }
	
	if (Num_Rays == 0)
	  return -1;
	
	if (CosX_Array.num_elements < Num_Rays)
	  CosX_Array.di = 0;
	if (CosY_Array.num_elements < Num_Rays)
	  CosY_Array.di = 0;
	if (CosZ_Array.num_elements < Num_Rays)
	  CosZ_Array.di = 0;
	if (dT_Array.num_elements < Num_Rays)
	  dT_Array.di = 0;
	if (Energy_Array.num_elements < Num_Rays)
	  Energy_Array.di = 0;
     }

   *cosx = next_element (&CosX_Array);
   *cosy = next_element (&CosY_Array);
   *cosz = next_element (&CosZ_Array);
   *delta_t = next_element (&dT_Array);
   *energy = next_element (&Energy_Array);
   
   Num_Rays--;
   return 0;
}
Ejemplo n.º 3
0
/* parse_resources()
	Processes the services/resources that are part of a request. This method walks
	through each element from a request and attempts to match each one with the
	available services on the Arduino. Based on these matches this method also 
	updates the services_xxx_requested and services_set_updated arrays, which identify what 
	services were requested or updated by the current request.
	Accepts: n/a
	Returns: n/a
 */
void RestServer::parse_resources() {                              
	int next_start_pos = 0;
	boolean processing_request = true;

    while(processing_request == true) {

		// re-initializing the start and end position of current element 
		int cur_start_pos = next_start_pos;
		next_start_pos = next_element(cur_start_pos);

		// if next_start_pos returns a NO_MATCH then we have reached end of resource request 
		if (next_start_pos == NO_MATCH) {
			next_start_pos = request.length - 1;
			processing_request = false;
		}

		// loop through each resource/service name to look for a match
		for (int i = 0; i < int(resources_count); i++) {
			int match_index = service_match(i, cur_start_pos);
			if (match_index != NO_MATCH) { 
				next_start_pos = match_index; 
				if (next_start_pos >= request.length) break;
			}
		}
    }    
}
Ejemplo n.º 4
0
Archivo: list.c Proyecto: Henauxg/minix
/**
 * @brief Parse a list of the following format:
 *   ( *LWS element *( *LWS "," *LWS element ))
 * @param lp pointer to list_t type for returned list.  Cannot be NULL.
 * @param p string to parse
 * @return 0 on success, -1 on error (no memory).
 *
 * Note: the list is allocated.  Use saslc__list_free() to free it.
 */
int
saslc__list_parse(list_t **lp, const char *p)
{
	const char *e, *n;
	list_t *l, *t, **tp;

	l = NULL;
	tp = NULL;
	n = p;
	for (;;) {
		p = n;
		p = skip_LWS(p);
		if (*p == '\0')
			break;
		n = next_element(p);
		e = n > p && n[-1] == ',' ? n - 1 : n;
		e = strip_LWS(e - 1, p);
		if (e <= p)
			continue;
		t = alloc_list(p, (size_t)(e - p));
		if (t == NULL) {
			saslc__list_free(l);
			return -1;
		}
		if (tp != NULL)
			*tp = t;
		else
			l = t;
		tp = &t->next;
	}
	*lp = l;
	return 0;
}
Ejemplo n.º 5
0
void update_config(vector<string> *&lines, string var_name, string var_value){
    int next2 = 0;
    if(next_element(var_name,lines,next2)){ //jeœli ju¿ jest ten element
        //nadpisanie linii danych
        lines->at(next2) = var_value;
    }else{
        //utworzenie nowych linii
        lines->push_back(var_name);
        lines->push_back(var_value);
    }
}
Ejemplo n.º 6
0
/* check_for_state_msg(int)
	Checks if element at current location is a state message. Currently, only positive integers
	state messages are supported.
	Accepts: index where to start searching for state message. 
	Returns: integer that reflects state, if one is found; otherwise, NO_MATCH is returned.
 */
int RestServer::check_for_state_msg(int _start) {
	// check that current start location is not a div character
	_start = check_start(_start);
	if (_start == NO_MATCH || _start > request.length-1) return NO_MATCH;
    
	// search for end position of current element and adjust as required
	int end_index = next_element(_start);
    if (end_index == NO_MATCH) end_index = request.length - 1;
    else end_index -= 1; 	// move end index to location before the division character
   
	// try to convert current element into a number by calling request.to_i method
	int new_num = request.to_i(_start, end_index);
	
    return new_num;
}
Ejemplo n.º 7
0
diagram hydrator::read_diagram() {
    next_element(dia_diagram);
    BOOST_LOG_SEV(lg, debug) << "Reading diagram.";

    diagram diagram;
    diagram.diagram_data(read_diagram_data());
    std::vector<layer> layers;

    do {
        layers.push_back(read_layer());
    } while (!is_end_element(dia_diagram));

    diagram.layers(layers);
    BOOST_LOG_SEV(lg, debug) << "Read diagram.";
    return diagram;
}
Ejemplo n.º 8
0
/* state_match(int, int, int)
	Checks the element at the current location in the request message to determine if
	it is a state message. If state message is found it reads the message into the
	service_set_state array.
	Accepts: an integer that identifies whether the service type being checked is 
		a get service (0), or a set service (1); the position of the specific service 
		to be checked within the get or set services arrays; and, the position of the 
		current element within the request char array.
	Returns: returns location of the next element within the request, if a state message 
		is found; otherwise, returns NO_MATCH  
 */
int RestServer::state_match(int _r_index, int _start_pos) {
	// check if for a state message (a number following an UPDATE-capable service)
	int new_number = check_for_state_msg(_start_pos);

	// if match exists, then (1) set updated array to true, (2) update state array 
	if (new_number != NO_MATCH) {
		resources[_r_index].post = true;
		resources[_r_index].service->setValue( constrain(new_number,
											  resources[_r_index].service->getMinValue(),
											  resources[_r_index].service->getMaxValue()) );

		// check the position of the next element
		_start_pos = next_element(_start_pos);
		if (_start_pos == NO_MATCH) _start_pos = request.length;
	}  
	return _start_pos;
}
Ejemplo n.º 9
0
diagram_data hydrator::read_diagram_data() {
    next_element(dia_diagramdata);
    diagram_data diagram_data;
    BOOST_LOG_SEV(lg, debug) << "Reading diagram data.";

    if (!reader_.read()) {
        BOOST_LOG_SEV(lg, error) << unexpected_eod;
        BOOST_THROW_EXCEPTION(hydration_error(unexpected_eod));
    }

    std::vector<attribute> attributes;
    do {
        attributes.push_back(read_attribute());
    } while (!is_end_element(dia_diagramdata));

    reader_.read();

    diagram_data.attributes(attributes);
    BOOST_LOG_SEV(lg, debug) << "Read diagram data.";
    return diagram_data;
}
Ejemplo n.º 10
0
void FeedParser::parse(XmlReader& xml, KPrintFun log)
{
    if (xml.name() != "project" || xml.namespace_uri() != project_ns)
    {
        throw std::runtime_error("not a project feed");
    }
    std::string id = xml.attribute("href", project_ns);
    if (id != spec.id)
    {
        spec.id = id;
        queue.current_id(id);
    }
    name = xml.attribute("name", project_ns);
    std::string tag = next_element(xml, log);
    if (tag == "meta")
    {
        xml.skip();
        tag = next_element(xml, log);
    }
    if (tag == "variants")
    {
        parse_variants(xml);
        xml.skip();
        tag = next_element(xml, log);
    }
    if (tag == "releases")
    {
        parse_releases(xml);
        xml.skip();
        tag = next_element(xml, log);
    }
    if (tag == "build")
    {
        std::string vcs = xml.attribute("vcs", project_ns);
        std::string href = xml.attribute("href", project_ns);
        parse_build(xml, vcs, href);
        xml.skip();
        tag = next_element(xml, log);
    }
    if (tag == "runtime")
    {
        parse_runtime(xml);
        xml.skip();
        tag = next_element(xml, log);
    }
    else if (tag == "components")
    {
        parse_components(xml);
        xml.skip();
        tag = next_element(xml, log);
    }
    if (tag == "packages")
    {
        Package group;
        parse_packages(xml, group);
        xml.skip();
        tag = next_element(xml, log);
    }
    if (!tag.empty())
    {
        Log(log, "element '%1%' not expected!!") % tag;
    }
}
Ejemplo n.º 11
0
void App::load_config(){
	log("Wczytywanie ustawieñ...");
    //domyœlne wartoœci
    config->midi_instrument = 25;
    config->midi_volume = 100;
    config->midi_basetone = 60;
    config->midi_pause = 500;
    config->ustawienia_type = TYP_INTERWAL_RM;
    for(int i=0; i<12; i++)
        config->ustawienia_interwaly[i]=false;
    config->ustawienia_interwaly[0] = true;
    config->ustawienia_interwaly[1] = true;
    config->ustawienia_interwaly[2] = true;
    for(int i=0; i<7; i++)
        config->ustawienia_oktawy[i]=false;
    config->ustawienia_oktawy[2] = true;
    config->ustawienia_oktawy[3] = true;
    //wczytanie pliku
    vector<string> *lines = get_all_lines("config.txt");
    if(lines==NULL){
        echo("B³¹d: Brak pliku konfiguracyjnego");
        return;
    }
    int next2 = 0;
    if(next_element("instrument=",lines,next2)){
        config->midi_instrument = atoi(lines->at(next2).c_str());
    }
    if(next_element("volume=",lines,next2)){
        config->midi_volume = atoi(lines->at(next2).c_str());
    }
    if(next_element("basetone=",lines,next2)){
        config->midi_basetone = atoi(lines->at(next2).c_str());
    }
    if(next_element("pause=",lines,next2)){
        config->midi_pause = atoi(lines->at(next2).c_str());
    }
    if(next_element("interval_type=",lines,next2)){
        config->ustawienia_type = atoi(lines->at(next2).c_str());
        if(config->ustawienia_type<0) config->ustawienia_type = 0;
        if(config->ustawienia_type>6) config->ustawienia_type = 6;
    }
    if(next_element("interwaly=",lines,next2)){
        string interwaly = lines->at(next2);
        if(interwaly.length()>=12){
            for(int i=0; i<12; i++){
                if(interwaly[i]=='1'){
                    config->ustawienia_interwaly[i] = true;
                }else{
                    config->ustawienia_interwaly[i] = false;
                }
            }
        }
    }
    if(next_element("oktawy=",lines,next2)){
        string oktawy = lines->at(next2);
        if(oktawy.length()>=7){
            for(int i=0; i<7; i++){
                if(oktawy[i]=='1'){
                    config->ustawienia_oktawy[i] = true;
                }else{
                    config->ustawienia_oktawy[i] = false;
                }
            }
        }
    }
    lines->clear();
    delete lines;
}
Ejemplo n.º 12
0
/* Returns next keyvalue pair. If there is no item left, p points to the byte after the current element */
element nextitem(element p)
{
  BYTE type = *(p++);
  while (*(p++));
  return next_element(p, type);
}