Smrender
 All Data Structures Files Functions Variables Macros
Functions
smrparse.c File Reference
#include <string.h>
#include <errno.h>
#include <dlfcn.h>
#include <ctype.h>
#include <inttypes.h>
#include "smrender_dev.h"
#include "colors.c"
Include dependency graph for smrparse.c:

Functions

int parse_matchtag (struct otag *ot, struct stag *st)
 
short ppos (const char *s)
 
int get_color (int n)
 
int set_color (const char *s, int col)
 
int parse_color (const char *s)
 
int parse_double_option (const char *s, double *v, char **endptr)
 
int parse_style (const char *s)
 
int get_structor (void *lhandle, void **stor, const char *sym, const char *trail)
 
void check_way_type (smrule_t *r)
 
int init_rule (osm_obj_t *o, smrule_t **r)
 
int init_rules (osm_obj_t *o, void *p)
 
void free_fparam (fparam_t **fp)
 
fparam_t ** parse_fparam (char *parm)
 
int parse_alignment_str (const char *s)
 
int parse_alignment (const action_t *act)
 
unit_t parse_unit (const char *uptr)
 
int parse_length (const char *s, value_t *v)
 
int parse_length_def (const char *s, value_t *v, unit_t u)
 
int parse_length_mm_array (const char *s, double *val, int len)
 

Detailed Description

This file contains the code of the rule parser and main loop of the render as well as the code for traversing the object (nodes/ways) tree.

Author
Bernhard R. Fischer

Function Documentation

int init_rule ( osm_obj_t o,
smrule_t **  r 
)

This function parses a rule defined within the object o into a smrule_t structure r. The memory is reserved by a call to alloc_rule() and must be freed again with free(). If the action tag was parsed properly, it is removed from that object's list of tags.

Parameters
oPointer to object.
rPointer to rule pointer. It will receive the pointer to the newly allocated memory or NULL in case of error.
Returns
0 if everything is ok. In case of a fatal error a negative value is returned and *r is set to NULL. In case of a minor error a positive number is returned and *r is set to a valid memory.
int parse_double_option ( const char *  s,
double *  v,
char **  endptr 
)

This function parses strings with decimal numbers prepended by a colon into a double variable.

Parameters
sPointer to string. May be preceded by spaces.
vPointer to double variable for the result.
endptrPointer to receive address of string behind decimal number. This is directly passed to strtod().
Returns
-1 if s == NULL, -2 if s does not contain any data ('\0'), -3 if there is no expected colon, and -4 if no conversion took place.
fparam_t** parse_fparam ( char *  parm)

This function parses a string of the format "key1=val1;key2=val2;..." into a fparam_t* list. The string within the list (keyX, valX) may be additionally delimited by '\'' or '"'. Special characters such as one of those both delimiters may be escaped with a backslash.

Parameters
parmA pointer to the original string. Please note that the string is tokenized similar to strtok_r(), thus '\0' characters are inserted. If the original string is needed for something else it should be strdup()'ed before.
Returns
A pointer to a fparam_t* list or NULL in case of error. The fparam_t* list always contains one additional element which points to NULL.
int parse_length_mm_array ( const char *  s,
double *  val,
int  len 
)

Parses a string of the form "<ddd.ddd>[<unit>]:<eee.eee>[<unit>]:..." into an array. If no unit exists, mm is used by default.

Parameters
sPointer to the string.
valPointer to the array which will receive the values.
lenNumber of elements of the array.
Returns
Returns the number of elements found in the array or a negative value according to parse_length_def() in case of error.
int parse_matchtag ( struct otag ot,
struct stag st 
)

This function parses the match tags in ot and fills the special tag structure st accordingly. The bstrings in ot are modified. This function actually calls parse_matchtype().

Parameters
otPointer to a struct otag.
stPointer to a struct stag.
Returns
On success, the function returns 0. On failure a negative value is returned (see parse_matchtype()).