X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Fparser.c;h=bcae82e1a4ab89e62948c998a6d7d088bf88c22f;hb=9f2d599db2cff6ee2a1733e43966eb5aeebdd35e;hp=492f766724f9aaa38c5eb3be12194af3d6bbcb95;hpb=1b44b0b5729fbc82eab287323dc14d12c028dd44;p=lttv.git diff --git a/ltt/branches/poly/ltt/parser.c b/ltt/branches/poly/ltt/parser.c index 492f7667..bcae82e1 100644 --- a/ltt/branches/poly/ltt/parser.c +++ b/ltt/branches/poly/ltt/parser.c @@ -1,25 +1,24 @@ /* - * parser.c: Generate helper declarations and functions to trace events - * from an event description file. - * - * Copyright (C) 2005, Mathieu Desnoyers - * Copyright (C) 2002, Xianxiu Yang - * Copyright (C) 2002, Michel Dagenais - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License Version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ + +parser.c: Generate helper declarations and functions to trace events + from an event description file. + + Copyright (C) 2005, Mathieu Desnoyers + Copyright (C) 2002, Xianxiu Yang + Copyright (C) 2002, Michel Dagenais + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ /* This program reads the ".xml" event definitions input files and constructs structure for each event. @@ -98,11 +97,26 @@ int getSizeindex(unsigned int value) unsigned long long int getSize(parse_file_t *in) { char *token; + int has_quotes = 0; + unsigned long long int ret; token = getToken(in); + if(token[0] == '"') { + has_quotes = 1; + token = getToken(in); + } if(in->type == NUMBER) { - return strtoull(token, NULL, 0); - } + ret = strtoull(token, NULL, 0); + } else { + goto error; + } + if(has_quotes) { + token = getToken(in); + if(token[0] != '"') goto error; + } + + return ret; +error: in->error(in,"incorrect size specification"); return -1; } @@ -184,6 +198,7 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t, t->fmt = NULL; t->size = 0; t->custom_write = 0; + t->network = 0; while(1) { token = getToken(in); @@ -206,7 +221,9 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t, t->size = getSize(in); } else if(!strcmp("custom_write", token)) { t->custom_write = 1; - } + } else if(!strcmp("network", token)) { + t->network = 1; + } } } @@ -328,7 +345,7 @@ void getFieldAttributes(parse_file_t *in, field_t *f) else if(car == '\"') f->name = allocAndCopy(getQuotedString(in)); else f->name = allocAndCopy(getName(in)); } - } + } } char *getNameAttribute(parse_file_t *in) @@ -339,42 +356,59 @@ char *getNameAttribute(parse_file_t *in) while(1) { token = getToken(in); - if(strcmp("/",token) == 0 || strcmp(">",token) == 0){ - ungetToken(in); - break; - } - if(!strcmp("name",token)) { getEqual(in); car = seekNextChar(in); if(car == EOF) in->error(in,"name was expected"); else if(car == '\"') name = allocAndCopy(getQuotedString(in)); else name = allocAndCopy(getName(in)); + } else { + ungetToken(in); + break; } + } if(name == NULL) in->error(in, "Name was expected"); return name; - } //for