Skip to content

Commit

Permalink
add buffer_clone and ows_layer_no_prefix functions. somehow related to
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Courtin committed Nov 5, 2012
1 parent bd3b90c commit 22c0907
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/ows/ows_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,26 @@ list *ows_layer_list_ns_prefix(ows_layer_list * ll, list * layer_name)
}


/*
* Retrieve the layer name without prefix
*/
buffer *ows_layer_no_prefix(ows_layer_list * ll, buffer * layer_name)
{
ows_layer_node *ln;

assert(ll);
assert(layer_name);

for (ln = ll->first; ln ; ln = ln->next)
if (buffer_cmp(ln->layer->name, layer_name->buf)) {
buffer_shift(layer_name, ln->layer->ns_prefix->use + 1); /* +1 for ':' separator */
return layer_name;
}

return (buffer *) NULL;
}


/*
* Retrieve the prefix linked to the specified layer
*/
Expand Down
2 changes: 2 additions & 0 deletions src/ows_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bool buffer_cmp (const buffer * buf, const char *str);
bool buffer_ncmp(const buffer * buf, const char *str, size_t n);
bool buffer_case_cmp (const buffer * buf, const char *str);
void buffer_copy (buffer * dest, const buffer * src);
buffer *buffer_clone(buffer * buf);
void buffer_empty (buffer * buf);
void buffer_flush (buffer * buf, FILE * output);
void buffer_free (buffer * buf);
Expand Down Expand Up @@ -149,6 +150,7 @@ void ows_layer_list_free (ows_layer_list * ll);
bool ows_layer_list_in_list (const ows_layer_list * ll, const list * l);
ows_layer_list *ows_layer_list_init ();
array *ows_layer_list_namespaces (ows_layer_list * ll);
buffer *ows_layer_no_prefix(ows_layer_list * ll, buffer * layer_name);
list *ows_layer_list_ns_prefix (ows_layer_list * ll, list * layer_name);
bool ows_layer_list_retrievable (const ows_layer_list * ll);
bool ows_layer_list_writable (const ows_layer_list * ll);
Expand Down
17 changes: 17 additions & 0 deletions src/struct/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@ void buffer_copy(buffer * dest, const buffer * src)
}


/*
* Copy the whole buffer struct to an another struct
*/
buffer *buffer_clone(buffer * buf)
{
buffer *b;

assert(buf);
assert(buf->buf);

b = buffer_init();
buffer_copy(b, buf);

return b;
}


/*
* Delete last N chars from a buffer
*/
Expand Down

0 comments on commit 22c0907

Please sign in to comment.