diff options
author | Stefan Wildemann <metalstrolch@users.noreply.github.com> | 2019-08-20 21:31:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-20 21:31:50 +0200 |
commit | 69acac0a6c36e7c11cc39612bea3f9f992f4d155 (patch) | |
tree | 93d080f9ea431619abf56ffc54a276bc2dee3fe0 /navit/attr.c | |
parent | 352b84220834ea937f4bd8b64ab69ed6d1639bda (diff) | |
parent | cbb32d188bd46eac9927f28b86dc765e7159e5e4 (diff) | |
download | navit-69acac0a6c36e7c11cc39612bea3f9f992f4d155.tar.gz |
Merge branch 'trunk' into multipolygon
Diffstat (limited to 'navit/attr.c')
-rw-r--r-- | navit/attr.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/navit/attr.c b/navit/attr.c index cf81c0ae9..78e2a683c 100644 --- a/navit/attr.c +++ b/navit/attr.c @@ -912,6 +912,29 @@ attr_list_dup(struct attr **attrs) { return ret; } +/** + * @brief Retrieves an attribute from a line in textfile format. + * + * If `name` is NULL, this function returns the first attribute found; otherwise it looks for an attribute + * named `name`. + * + * If `pos` is specified, it acts as an offset pointer: Any data in `line` before `*pos` will be skipped. + * When the function returns, the value pointed to by `pos` will be incremented by the number of characters + * parsed. This can be used to iteratively retrieve all attributes: declare a local variable, set it to zero, + * then iteratively call this function with a pointer to the same variable until it returns false. + * + * `val_ret` must be allocated (and later freed) by the caller, and have sufficient capacity to hold the + * parsed value including the terminating NULL character. The minimum safe size is + * `strlen(line) - strlen(name) - *pos` (assuming zero for NULL pointers). + * + * @param line The line to parse + * @param name The name of the attribute to retrieve; if NULL, + * @param pos Offset pointer, see description + * @param val_ret Points to a buffer which will receive the value as text + * @param name_ret Points to a buffer which will receive the name of the attribute parsed, can be NULL + * + * @return true if successful, false in case of failure + */ int attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret) { int len=0,quoted; char *p,*e,*n; |