ALPS_DECL params make_parameters_from_xml(boost::filesystem::path const & arg) {
        Parameters par;
        boost::filesystem::ifstream infile(arg.string());

        // read outermost tag (e.g. <SIMULATION>)
        XMLTag tag = parse_tag(infile, true);
        std::string closingtag = "/" + tag.name;

        // scan for <PARAMETERS> and read them
        tag = parse_tag(infile, true);
        while (tag.name != "PARAMETERS" && tag.name != closingtag) {
            std::cerr << "skipping tag with name " << tag.name << "\n";
            skip_element(infile, tag);
            tag = parse_tag(infile, true);
        }

        par.read_xml(tag, infile, true);
        if (!par.defined("SEED"))
            par["SEED"] = 0;
        
        params res;
        for (Parameters::const_iterator it = par.begin(); it != par.end(); ++it)
            res[it->key()] = it->value();
        return res;
    }
Esempio n. 2
0
static int replace_name(struct commit_name *e,
			       int prio,
			       const unsigned char *sha1,
			       struct tag **tag)
{
	if (!e || e->prio < prio)
		return 1;

	if (e->prio == 2 && prio == 2) {
		/* Multiple annotated tags point to the same commit.
		 * Select one to keep based upon their tagger date.
		 */
		struct tag *t;

		if (!e->tag) {
			t = lookup_tag(e->sha1);
			if (!t || parse_tag(t))
				return 1;
			e->tag = t;
		}

		t = lookup_tag(sha1);
		if (!t || parse_tag(t))
			return 0;
		*tag = t;

		if (e->tag->date < t->date)
			return 1;
	}

	return 0;
}
Esempio n. 3
0
static gboolean
xmms_html_browse (xmms_xform_t *xform, const gchar *url,
                  xmms_error_t *error)
{
	gchar buffer[XMMS_XFORM_MAX_LINE_SIZE];
	const gchar *plsurl;
	gchar *tagbeg, *aurl, *full;

	xmms_error_reset (error);
	plsurl = xmms_xform_get_url (xform);

	while (xmms_xform_read_line (xform, buffer, error)) {
		tagbeg = buffer;
		while ((tagbeg = strchr (tagbeg, '<'))) {
			if ((aurl = parse_tag (++tagbeg, plsurl))) {
				full = xmms_build_playlist_url (plsurl,
				                                aurl);
				xmms_xform_browse_add_symlink (xform,
				                               NULL, full);
				g_free (full);
				g_free (aurl);
			}
		}
	}

	return TRUE;
}
Esempio n. 4
0
Section* Parser::parse_section(){
	if(!maybe_char(OPEN_SECTION)){
		return NULL;
	}

	SafePointer<Section> section(new Section());

	//These aren't safe pointers because the moment they have a value,
	//they're immediately handed to another owner.
	Text* text;
	Tag* tag;
	do{
		if(text=parse_section_text()){
			section->add(text);
		}
		if(tag=parse_tag()){
			section->add(tag);
		}
	}while(text or tag);

	if(!maybe_char(CLOSE_SECTION)){
		if(it==end){
			throw ParseError(SECTION_EOF,line,col);
		}
		throw ParseError(EXPECTED_CLOSE_SECTION,line,col);
	}

	return section.yield();
}
Esempio n. 5
0
bool class_source_parser::parse_tag(){
	while (!f_.eof()){
		std::string line;
		if (! getline(line) ) { return false; }
		if (check_valid(line)) {
			if (check_tag_begin(line)){
				parse_tag();
			}
			if (check_tag_end(line)){
				return true;
			}
			if (check_keys_begin(line)){
				parse_keys();
			}
			if (check_allow_link(line)){
				continue;
			}
			if (check_allow_global(line)){
				continue;
			}
			if (check_remove_key(line)){
			}
		}else{
			if (!current_.empty()){
				// adding error messages for each unclosed entity
				add_open_tag_error();
				close_opened_tags();
			}
			return true;
		}
	}
	return true;
}
Esempio n. 6
0
bool class_source_parser::parse_block(){
	while (!f_.eof()){
		std::string line;
		if (! getline(line) ) { return false; }
		if ( check_valid(line)) {
			if (check_allow_type(line)) continue;
			if (check_remove_type(line)) continue;
			if (check_parent_begin(line)) continue;

			if (check_tag_begin(line)){
				parse_tag();
				continue;
			}
			check_parent_end(line);
		}
		else{
			// wiki-block is closed. checking stack of opened tags
			if (!current_.empty()){
				add_open_tag_error();
				close_opened_tags();
				// continue working
			}
			// block is closed and all tags are closed.
			return true;

		}
	}// end while
	return false;
}
Esempio n. 7
0
xml::Tag read_tag(std::istream& stream) {
  std::string line;
  std::getline(stream, line);
  xml::Tag st;
  CHECK(parse_tag(line, &st));
  return st;
}
Esempio n. 8
0
struct object *parse_object(unsigned char *sha1)
{
	unsigned long mapsize;
	void *map = map_sha1_file(sha1, &mapsize);
	if (map) {
		char type[100];
		unsigned long size;
		void *buffer = unpack_sha1_file(map, mapsize, type, &size);
		if (!buffer)
			return NULL;
		if (check_sha1_signature(sha1, buffer, size, type) < 0)
			printf("sha1 mismatch %s\n", sha1_to_hex(sha1));
		munmap(map, mapsize);
		if (!strcmp(type, "blob")) {
			struct blob *ret = lookup_blob(sha1);
			parse_blob(ret);
			return &ret->object;
		} else if (!strcmp(type, "tree")) {
			struct tree *ret = lookup_tree(sha1);
			parse_tree(ret);
			return &ret->object;
		} else if (!strcmp(type, "commit")) {
			struct commit *ret = lookup_commit(sha1);
			parse_commit(ret);
			return &ret->object;
		} else if (!strcmp(type, "tag")) {
			struct tag *ret = lookup_tag(sha1);
			parse_tag(ret);
			return &ret->object;
		} else {
			return NULL;
		}
	}
	return NULL;
}
Esempio n. 9
0
/*
 * Parse all tags in the list, checking both the global and architecture
 * specific tag tables.
 */
static void __init parse_tags(const struct tag *t)
{
	for (; t->hdr.size; t = tag_next(t))
		if (!parse_tag(t))
			pr_warn("Ignoring unrecognised tag 0x%08x\n",
				t->hdr.tag);
}
Esempio n. 10
0
/*
** parse_hsc
**
** parse input chars with full hsc support
**
** params: inpf...input file
**
** result: TRUE, if no error
*/
BOOL parse_hsc( INFILE *inpf )
{
    if ( !fatal_error ) {
        char *nxtwd;

        nxtwd = infgetw( inpf );

        if ( nxtwd ) {

            if ( !strcmp(nxtwd, "<") )                     /* parse tag */
                parse_tag( inpf );
            else if ( !strcmp(nxtwd, "&") )                /* parse entity */
                parse_amp( inpf );

            else {                                         /* handle text */

                if ( !strcmp(nxtwd, ">") ) {               /* unmatched ">"? */

                    message( ERROR_UNMA_GT, inpf );        /* Y->error message */
                    errstr( "unmatched \">\"\n" );

                }

                outstr( infgetcws( inpf ) );               /* output word */
                if (!infeof(inpf))
                    outstr( infgetcw( inpf ) );


            }
        }
    }

    return (BOOL)( !fatal_error );
}
Esempio n. 11
0
static int	parse_format(const char *format, va_list *args)
{
	int		count;
	char	c;
	char	*ptr;
	int		tag_length;

	ptr = (char *)format;
	count = 0;
	while (*ptr)
	{
		c = *ptr++;
		if (c == '%')
		{
			if ((tag_length = parse_tag(&ptr, args)) == -1)
				return (-1);
			count += tag_length;
		}
		else
		{
			count++;
			ft_putchar(c);
		}
	}
	return (count);
}
Esempio n. 12
0
/*
 * Parse a single line of data, and return a newly allocated dev struct.
 * Add the new device to the cache struct, if one was read.
 *
 * Lines are of the form <device [TAG="value" ...]>/dev/foo</device>
 *
 * Returns -ve value on error.
 * Returns 0 otherwise.
 * If a valid device was read, *dev_p is non-NULL, otherwise it is NULL
 * (e.g. comment lines, unknown XML content, etc).
 */
static int blkid_parse_line(blkid_cache cache, blkid_dev *dev_p, char *cp)
{
	blkid_dev dev;
	int ret;

	if (!cache || !dev_p)
		return -BLKID_ERR_PARAM;

	*dev_p = NULL;

	DBG(READ, ul_debug("line: %s", cp));

	if ((ret = parse_dev(cache, dev_p, &cp)) <= 0)
		return ret;

	dev = *dev_p;

	while ((ret = parse_tag(cache, dev, &cp)) > 0) {
		;
	}

	if (dev->bid_type == NULL) {
		DBG(READ, ul_debug("blkid: device %s has no TYPE",dev->bid_name));
		blkid_free_dev(dev);
		goto done;
	}

done:
	return ret;
}
Esempio n. 13
0
int
map_collect_data_osm(FILE *in, struct maptool_osm *osm)
{
	int size=BUFFER_SIZE;
	char buffer[BUFFER_SIZE];
	char *p;
	sig_alrm(0);
	if (!fgets(buffer, size, in) || !xml_declaration_in_line(buffer)){
		fprintf(stderr,"FATAL: First line does not start with XML declaration;\n"
			       "this does not look like a valid OSM file.\n");
		exit(EXIT_FAILURE);
	}
	while (fgets(buffer, size, in)) {
		p=strchr(buffer,'<');
		if (! p) {
			fprintf(stderr,"FATAL: wrong line in input data (does not start with '<'): %s\n", buffer);
			fprintf(stderr,"This does not look like a valid OSM file.\n"
		                "Note that maptool can only process OSM files without wrapped or empty lines.\n");
			exit(EXIT_FAILURE);
		}
		if (!strncmp(p, "<osm ",5)) {
		} else if (!strncmp(p, "<bound ",7)) {
		} else if (!strncmp(p, "<node ",6)) {
			if (!parse_node(p))
				fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
			processed_nodes++;
		} else if (!strncmp(p, "<tag ",5)) {
			if (!parse_tag(p))
				fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
		} else if (!strncmp(p, "<way ",5)) {
			if (!parse_way(p))
				fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
			processed_ways++;
		} else if (!strncmp(p, "<nd ",4)) {
			if (!parse_nd(p))
				fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
		} else if (!strncmp(p, "<relation ",10)) {
			if (!parse_relation(p))
				fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
			processed_relations++;
		} else if (!strncmp(p, "<member ",8)) {
			if (!parse_member(p))
				fprintf(stderr,"WARNING: failed to parse %s\n", buffer);
		} else if (!strncmp(p, "</node>",7)) {
			osm_end_node(osm);
		} else if (!strncmp(p, "</way>",6)) {
			osm_end_way(osm);
		} else if (!strncmp(p, "</relation>",11)) {
			osm_end_relation(osm);
		} else if (!strncmp(p, "</osm>",6)) {
		} else {
			fprintf(stderr,"WARNING: unknown tag in %s\n", buffer);
		}
	}
	sig_alrm(0);
	sig_alrm_end();
	return 1;
}
Esempio n. 14
0
enum html_tag
html_parse_tag(const struct array *tag)
{
	if (tag && tag->data) {
		return parse_tag(*tag);
	} else {
		return HTML_TAG_UNKNOWN;
	}
}
Esempio n. 15
0
static const char *parse_field(struct buffer *self, int tag)
{
	if (parse_tag(self) != tag) {
		next_tag(self);
		return NULL;
	}

	return parse_value(self);
}
Esempio n. 16
0
File: fsck.c Progetto: PEPE-coin/git
static int fsck_walk_tag(struct tag *tag, void *data, struct fsck_options *options)
{
	char *name = get_object_name(options, &tag->object);

	if (parse_tag(tag))
		return -1;
	if (name)
		put_object_name(options, tag->tagged, "%s", name);
	return options->walk(tag->tagged, OBJ_ANY, data, options);
}
Esempio n. 17
0
static void
html_render_tag(struct render_context *ctx, const struct array tag)
{
	if (tag.size > 0) {
		ctx->closing = html_tag_is_closing(&tag);
		html_output_tag(ctx->output, tag);
		if (HTML_TAG_PRE == parse_tag(tag)) {
			ctx->preformatted = !ctx->closing;
		}
	}
}
Esempio n. 18
0
static const char *parse_field_promisc(struct buffer *self, int *tag)
{
	*tag = parse_tag(self);

	if (!(*tag)) {
		next_tag(self);
		return NULL;
	}

	return parse_value(self);
}
Esempio n. 19
0
/* astreich, 06/17 */
Parameters Task::parse_ext_task_file(std::string infilename)
{
  Parameters res;
  boost::filesystem::ifstream infile(infilename);

  // read outermost tag (e.g. <SIMULATION>)
  XMLTag tag=parse_tag(infile,true);
  std::string closingtag = "/"+tag.name;

  // scan for <PARAMETERS> and read them
  tag=parse_tag(infile,true);
  while (tag.name!="PARAMETERS" && tag.name != closingtag) {
    std::cerr << "skipping tag with name " << tag.name << "\n";
    skip_element(infile,tag);
    tag=parse_tag(infile,true);
  }
  res.read_xml(tag,infile,true);
  if (!res.defined("SEED"))
    res["SEED"]=0;
  return res;
}
Esempio n. 20
0
Flake* Parser::parse_value(){
	Flake* f;
	if(f=parse_text()){
		return f;
	}

	if(f=parse_tag()){
		return f;
	}

	if(f=parse_section()){
		return f;
	}

	//Error checking

	/*
	Snow errors are very predictable, so check for common
	mistakes. By this point, we know the next character is
	one of the quote characters, ], }, whitespace, a control
	character, or EOF (if not, something is HORRIBLY wrong)
	*/

	if(it==end){
		throw ParseError(TAG_EOF,line,col);
	}

	char c=*it;

	if(c==CLOSE_SECTION){
		throw ParseError(UNEXPECTED_CLOSE_SECTION,line,col-1);
	}

	if(c==CLOSE_TAG){
		throw ParseError(UNNAMED_ATTR,colonline,coloncol);
	}

	if(c==NAMED_ATTR){
		throw ParseError(ILLEGAL_NAMED,line,col-1);
	}

	if(isspace(c)){
		//This should NEVER happen. Guarantees a problem with the parser.
		throw ParseError(UNEXPECTED_SPACE,line,col);
	}

	//Reserved for cosmic ray errors
	throw ParseError(COSMIC_RAY_ERR,line,col);
}
Esempio n. 21
0
static void display_name(struct commit_name *n)
{
	if (n->prio == 2 && !n->tag) {
		n->tag = lookup_tag(n->sha1);
		if (!n->tag || parse_tag(n->tag) || !n->tag->tag)
			die("annotated tag %s not available", n->path);
		if (strcmp(n->tag->tag, n->path))
			warning("tag '%s' is really '%s' here", n->tag->tag, n->path);
	}

	if (n->tag)
		printf("%s", n->tag->tag);
	else
		printf("%s", n->path);
}
Esempio n. 22
0
static int parse_field_promisc(struct buffer *self, int *tag, const char **value)
{
	int ret;

	ret = parse_tag(self, tag);

	if (ret)
		goto fail;

	return parse_value(self, value);

fail:
	next_tag(self);
	return ret;
}
Esempio n. 23
0
void cgit_print_tag(char *revname)
{
    unsigned char sha1[20];
    struct object *obj;
    struct tag *tag;
    struct taginfo *info;

    if (get_sha1(revname, sha1)) {
        cgit_print_error(fmt("Bad tag reference: %s", revname));
        return;
    }
    obj = parse_object(sha1);
    if (!obj) {
        cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1)));
        return;
    }
    if (obj->type == OBJ_TAG) {
        tag = lookup_tag(sha1);
        if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) {
            cgit_print_error(fmt("Bad tag object: %s", revname));
            return;
        }
        html("<table class='commit-info'>\n");
        htmlf("<tr><td>Tag name</td><td>%s (%s)</td></tr>\n",
              revname, sha1_to_hex(sha1));
        if (info->tagger_date > 0) {
            html("<tr><td>Tag date</td><td>");
            cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time);
            html("</td></tr>\n");
        }
        if (info->tagger) {
            html("<tr><td>Tagged by</td><td>");
            html_txt(info->tagger);
            if (info->tagger_email) {
                html(" ");
                html_txt(info->tagger_email);
            }
            html("</td></tr>\n");
        }
        html("<tr><td>Tagged object</td><td>");
        cgit_object_link(tag->tagged);
        html("</td></tr>\n");
        html("</table>\n");
        print_tag_content(info->msg);
    }
    return;
}
Esempio n. 24
0
void ff_id3v1_read(AVFormatContext *s)
{
    int ret, filesize;
    uint8_t buf[ID3v1_TAG_SIZE];

    if (!url_is_streamed(s->pb)) {
        /* XXX: change that */
        filesize = url_fsize(s->pb);
        if (filesize > 128) {
            avio_seek(s->pb, filesize - 128, SEEK_SET);
            ret = avio_read(s->pb, buf, ID3v1_TAG_SIZE);
            if (ret == ID3v1_TAG_SIZE) {
                parse_tag(s, buf);
            }
            avio_seek(s->pb, 0, SEEK_SET);
        }
    }
}
Esempio n. 25
0
void ff_id3v1_read(AVFormatContext *s)
{
    int ret;
    uint8_t buf[ID3v1_TAG_SIZE];
    int64_t filesize, position = avio_tell(s->pb);

    if (s->pb->seekable) {
        /* XXX: change that */
        filesize = avio_size(s->pb);
        if (filesize > 128) {
            avio_seek(s->pb, filesize - 128, SEEK_SET);
            ret = avio_read(s->pb, buf, ID3v1_TAG_SIZE);
            if (ret == ID3v1_TAG_SIZE) {
                parse_tag(s, buf);
            }
            avio_seek(s->pb, position, SEEK_SET);
        }
    }
}
Esempio n. 26
0
static int parse_field(struct buffer *self, int tag, const char **value)
{
	int ptag, ret;

	ret = parse_tag(self, &ptag);

	if (ret)
		goto fail;
	else if (ptag != tag) {
		ret = FIX_MSG_STATE_GARBLED;
		goto fail;
	}

	return parse_value(self, value);

fail:
	next_tag(self);
	return ret;
}
Esempio n. 27
0
static void display_name(struct commit_name *n)
{
	if (n->prio == 2 && !n->tag) {
		n->tag = lookup_tag(n->sha1);
		if (!n->tag || parse_tag(n->tag))
			die(_("annotated tag %s not available"), n->path);
	}
	if (n->tag && !n->name_checked) {
		if (!n->tag->tag)
			die(_("annotated tag %s has no embedded name"), n->path);
		if (strcmp(n->tag->tag, all ? n->path + 5 : n->path))
			warning(_("tag '%s' is really '%s' here"), n->tag->tag, n->path);
		n->name_checked = 1;
	}

	if (n->tag)
		printf("%s", n->tag->tag);
	else
		printf("%s", n->path);
}
Esempio n. 28
0
static GHashTable *
parse_tags (const xmlNode *tag_child)
{
  GHashTable *tags;
  const xmlNode *cur_node;
  
  tags = g_hash_table_new (g_str_hash, g_str_equal);

  for (cur_node = tag_child; cur_node; cur_node = cur_node->next)
    {
      /* skip non-element nodes */
      if (cur_node->type != XML_ELEMENT_NODE)
        continue;

      if (g_str_equal (cur_node->name, "tag"))
        parse_tag (cur_node->properties, tags);
    }

  return tags;
}
Esempio n. 29
0
// Parse an item description (name, tags, child items, ...)
golem_item *parse_item(golem_tokenizer *tokenizer) {
  log("> parse item [%d]\n", tokenizer->token);
  golem_item *item = new_item(NULL), *child, *children;
  golem_tag *tag;
  int token;
  for (;;) {
    token = tokenizer->token;
    switch (token) {
      case token_name:
        append_to_item_name(item, get_token_string(tokenizer));
        break;
      case '+':
      case '-':
        tag = parse_tag(tokenizer);
        tag_item(item, tag);
        break;
      case '[':
        token = get_token(tokenizer);
        children = parse_item_children(tokenizer, item);
        for (child = item->first_child; child && child->next_sibling;
            child = child->next_sibling);
        if (child) {
          child->next_sibling = children;
        } else {
          item->first_child = children;
        }
        break;
      case ',':
      case ';':
      case ':':
      case '.':
      case ']':
        log("< parsed item “%s” [%d]\n", item->name, tokenizer->token);
        return item;
      default:
        die("parse item: expected name, tag, children or rule separator.");
    }
    token = get_token(tokenizer);
  }
  die("parse item: unfinished item");
}
Esempio n. 30
0
/*----------------------------------------------------------------------------*/
static int
task_is_add(tres_res_t *task, const char *str)
{
  tres_is_t *is;

  is = memb_alloc(&is_mem);
  if(is == NULL) {
    return ERR_IS_NONE_FREE;
  }
  str = parse_url(str, is->addr, is->path, TRES_PATH_LEN_MAX);
  if(str == NULL) {
    memb_free(&is_mem, is);
    return ERR_IS_INVALID_URL;
  }
  str = parse_tag(is->tag, str, TRES_TAG_MAX_LEN);
  if(str == NULL) {
    memb_free(&is_mem, is);
    return ERR_IS_INVALID_TAG;
  }
  PRINTF("TAG: %s\n", is->tag);
  list_add(task->is_list, is);
  return ERR_NONE;
}