diff options
author | David Robillard <d@drobilla.net> | 2011-01-24 21:11:53 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-01-24 21:11:53 +0000 |
commit | 6903e56e2443a1a5b023d688cb7fd54e3580316d (patch) | |
tree | 291d35f268ed8de8ed1a671800d3481003abc4dc /src/uri.c | |
parent | cffc0e7bb7a52153673d3eba2e31d6b2930a6248 (diff) | |
download | serd-6903e56e2443a1a5b023d688cb7fd54e3580316d.tar.gz serd-6903e56e2443a1a5b023d688cb7fd54e3580316d.tar.bz2 serd-6903e56e2443a1a5b023d688cb7fd54e3580316d.zip |
Remove SerdString from public API in favour of more expressive (and not necessarily inline with data payload) SerdNode.
git-svn-id: http://svn.drobilla.net/serd/trunk@53 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/uri.c')
-rw-r--r-- | src/uri.c | 56 |
1 files changed, 2 insertions, 54 deletions
@@ -8,11 +8,11 @@ * * Serd 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 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for details. * * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> @@ -338,55 +338,3 @@ serd_uri_serialise(const SerdURI* uri, SerdSink sink, void* stream) } return write_size; } - - -static size_t -serd_uri_string_length(const SerdURI* uri) -{ - size_t len = uri->path_base.len; - -#define ADD_LEN(field, n_delims) \ - if ((field).len) { len += (field).len + (n_delims); } - - ADD_LEN(uri->path, 1); // + possible leading `/' - ADD_LEN(uri->scheme, 1); // + trailing `:' - ADD_LEN(uri->authority, 2); // + leading `//' - ADD_LEN(uri->query, 1); // + leading `?' - ADD_LEN(uri->fragment, 1); // + leading `#' - - return len; -} - -static size_t -string_sink(const void* buf, size_t len, void* stream) -{ - uint8_t** ptr = (uint8_t**)stream; - memcpy(*ptr, buf, len); - *ptr += len; - return len; -} - -SERD_API -SerdString* -serd_string_new_from_uri(const SerdURI* uri, SerdURI* out) -{ - const size_t len = serd_uri_string_length(uri); - SerdString* str = malloc(sizeof(SerdString) + len + 1); - str->n_bytes = len + 1; - str->n_chars = len; // FIXME: UTF-8 - - uint8_t* ptr = str->buf; - const size_t actual_len = serd_uri_serialise(uri, string_sink, &ptr); - - str->buf[actual_len] = '\0'; - str->n_bytes = actual_len + 1; - str->n_chars = str->n_bytes - 1; // FIXME: UTF-8 - - #ifdef URI_DEBUG - fwrite("URI: `'", 1, 6, stderr); - fwrite(str->buf, 1, str->n_bytes - 1, stderr); - fwrite("'\n", 1, 2, stderr); - #endif - - return str; -} |