/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * COPYING NOTES * * parser.h -- Function to parserize a text file structure like MS'.ini * * Copyright (C) 2003 Roberto A. Foglietta <robang@libero.it> * Copyright (C) 2003 GEA-Automotive <fogliettar@gea-automotive.com> * * 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; either 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. */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * REVISION NOTES: * * released 22-05-2003 by Roberto A. Foglietta * static 27-06-2003 by Roberto A. Foglietta * */ #ifndef PARSER_H #define PARSER_H #ifndef PARSER_DYNAMIC_VERSION /* RAF 2003-06-27: Static version of parser with fixed * number of maximum parameters. This * number could be changed by users * only by recompiling the source code. */ #ifndef MAX_NUM_PARSER_PARAM /* The numbers of parameters really useable will * be one less than the number here defined. */ #define MAX_NUM_PARSER_PARAM 16 #endif #endif union alltypes { int d; float f; unsigned u; char *s; long ld; double lf; unsigned long lu; }; char *grab_section_from_text(const char *pt, const char *name); /* * pointer = grab_section_from_text(text, "section name or NULL"); * * find and return the starting point of the section which has the * name passed as 2nd parameter or the first section encountered * if the 2nd parameter is a NULL pointer. */ char *dup_n_separate_section(const char *p); /* * buffer = dup_n_separate_section(start_text); * * get and alloc a copy of the first section contained in the text * pointend by the parameter *p. Someday you will free this buffer! */ union alltypes back_cast_param_from_test(char *str, const char *cast); /* * value = back_cast_param_from_test(string, cast_type); * * this function keep the text passed as first parameter and trasform it * in a value backcasting it in the type passed ad 2nd parameter. * followings are the only cast usable (actually): * %u, %d, %x, %f, %s, %lu, %ld, %lx, %lf */ union alltypes *get_mult_param_value_from_text (const char *pt, const char *pname, const char **cast); /* * value_vector = get_mult_param_value_from_text (string, param_name, cast_vector); * * this function keep the text passed as first parameter and trasform it * in a vector of values backcasting it as cast_vector indicate. * ATTENTION: cast_vector[N+1] = { "type1", "type2", ..., "typeN", NULL}; * ATTENTION: cast_vector has to end with a NULL pointer! * followings are the only cast usable (actually): * %u, %d, %x, %f, %s, %lu, %ld, %lx, %lf */ #endif /* PARSER_H */