--- /dev/null
+configure
+Makefile.in
+Makefile
+config.log
+config.guess
+config.sub
+config.h
+config.status
+config.h.in
+autom4te.cache
+missing
+aclocal.m4
+install-sh
+stamp-h1
+depcomp
+ltmain.sh
+libtool
+a.out*
+
--- /dev/null
+@(#) $Id$
+
+Copyright (c) 2005, 2008 Mo McRoberts.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The names of the author(s) of this software may not be used to endorse
+ or promote products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null
+## @(#) $Id$
+
+## Copyright (c) 2008 Mo McRoberts.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions
+## are met:
+## 1. Redistributions of source code must retain the above copyright
+## notice, this list of conditions and the following disclaimer.
+## 2. Redistributions in binary form must reproduce the above copyright
+## notice, this list of conditions and the following disclaimer in the
+## documentation and/or other materials provided with the distribution.
+## 3. The names of the author(s) of this software may not be used to endorse
+## or promote products derived from this software without specific prior
+## written permission.
+##
+## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+## AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+## AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+## TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+## LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+## NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+## SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+SUBDIRS = iri-config include libiri tests
+
+EXTRA_DIST = LICENSE
--- /dev/null
+#! /bin/sh
+
+# @(#) $Id$
+
+AUTOHEADER26=${AUTOHEADER26-autoheader26}
+LIBTOOLIZE15=${LIBTOOLIZE15-libtoolize15}
+ACLOCAL110=${ACLOCAL110-aclocal110}
+AUTOMAKE110=${AUTOMAKE110-automake110}
+AUTOCONF26=${AUTOCONF26-autoconf26}
+
+set -x
+
+${AUTOHEADER26}
+${LIBTOOLIZE15} --force --copy --automake
+${ACLOCAL110}
+${AUTOMAKE110} --add-missing --copy
+${AUTOCONF26}
+
--- /dev/null
+dnl @(#) $Id$
+
+dnl Copyright (c) 2005, 2008 Mo McRoberts.
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are permitted provided that the following conditions
+dnl are met:
+dnl 1. Redistributions of source code must retain the above copyright
+dnl notice, this list of conditions and the following disclaimer.
+dnl 2. Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl 3. The names of the author(s) of this software may not be used to endorse
+dnl or promote products derived from this software without specific prior
+dnl written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+dnl AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+dnl AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+dnl TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+AC_INIT(libiri, 2.0)
+AC_CONFIG_SRCDIR([include/iri.h])
+AM_INIT_AUTOMAKE([foreign])
+AM_MAINTAINER_MODE
+
+CPPFLAGS="$CPPFLAGS -W -Wall -D_REENTRANT -I\${top_srcdir}/include"
+export CPPFLAGS
+
+CFLAGS="$CFLAGS -g -O0"
+export CFLAGS
+
+AC_PROG_CC
+AC_PROG_LIBTOOL
+
+spfx="${prefix}"
+sepfx="${exec_prefix}"
+test x"${prefix}" = x"NONE" && prefix="${ac_default_prefix}"
+test x"${exec_prefix}" = x"NONE" && exec_prefix="${prefix}"
+
+IRI_VERSION="${VERSION}"
+AC_SUBST([IRI_VERSION])
+
+IRI_CFLAGS="-I`eval echo $includedir`"
+AC_SUBST([IRI_CFLAGS])
+
+IRI_INCLUDES="-I`eval echo $includedir`"
+AC_SUBST([IRI_INCLUDES])
+
+IRI_LIBS="-L`eval echo $libdir` -liri"
+AC_SUBST([IRI_LIBS])
+
+prefix="${spfx}"
+exec_prefix="${sepfx}"
+
+AC_CONFIG_HEADER([config.h])
+
+AC_CONFIG_FILES([Makefile
+include/Makefile
+libiri/Makefile
+iri-config/iri-config.c
+iri-config/Makefile
+tests/Makefile
+])
+
+AC_OUTPUT
+
--- /dev/null
+.deps
+.libs
+Makefile
+Makefile.in
+*.la
+*.lo
+*.so
+*.a
+*.dll
+*.exe
+*.o
--- /dev/null
+## @(#) $Id$
+
+## Copyright (c) 2008 Mo McRoberts.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions
+## are met:
+## 1. Redistributions of source code must retain the above copyright
+## notice, this list of conditions and the following disclaimer.
+## 2. Redistributions in binary form must reproduce the above copyright
+## notice, this list of conditions and the following disclaimer in the
+## documentation and/or other materials provided with the distribution.
+## 3. The names of the author(s) of this software may not be used to endorse
+## or promote products derived from this software without specific prior
+## written permission.
+##
+## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+## AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+## AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+## TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+## LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+## NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+## SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include_HEADERS = iri.h
--- /dev/null
+/*
+ * Copyright (c) 2005, 2008 Mo McRoberts.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the author(s) of this software may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IRI_H_
+# define IRI_H_ 1
+
+typedef struct iri_struct iri_t;
+
+struct iri_struct
+{
+ void *_private;
+ const char *scheme;
+ const char *user;
+ const char *auth;
+ const char *host;
+ int port;
+ const char *path;
+ const char *query;
+ const char *anchor;
+ const char **params;
+};
+
+# undef EXTERNC_
+# if defined(__cplusplus)
+# define EXTERNC_ extern "C"
+# else
+# define EXTERNC_ extern
+# endif
+
+EXTERNC_ iri_t *iri_parse(const char *src);
+EXTERNC_ void iri_destroy(iri_t *iri);
+
+#endif /* !IRI_H_ */
--- /dev/null
+.deps
+.libs
+Makefile
+Makefile.in
+*.la
+*.lo
+*.so
+*.a
+*.dll
+*.exe
+*.o
+iri-config
+iri-config.c
+
--- /dev/null
+
+EXTRA_DIST = iri-config.c.in
+
+bin_PROGRAMS = iri-config
+
+iri_config_SOURCES = iri-config.c
--- /dev/null
+/*
+ * Copyright (c) 2005, 2008 Mo McRoberts.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the author(s) of this software may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+static struct
+{
+ const char *key;
+ const char *value;
+} pairs[] =
+{
+ { "cflags", "@IRI_CFLAGS@" },
+ { "include", "@IRI_INCLUDES@" },
+ { "libs", "@IRI_LIBS@" },
+ { "version", "@IRI_VERSION@" },
+ { NULL, NULL }
+};
+
+static void
+usage(int status)
+{
+ int d;
+
+ puts("Usage: @bindir@/iri-config [OPTIONS]");
+ puts("Options:");
+ for(d = 0; NULL != pairs[d].key; d++)
+ {
+ printf("\t--%-14s [%s]\n", pairs[d].key, pairs[d].value);
+ }
+ exit(status);
+}
+
+int
+main(int argc, char **argv)
+{
+ int c, d;
+
+ if(argc < 2)
+ {
+ usage(EXIT_SUCCESS);
+ }
+ for(c = 1 ; c < argc; c++)
+ {
+ if(argv[c][0] == '-' && argv[c][1] == '-')
+ {
+ for(d = 0; NULL != pairs[d].key; d++)
+ {
+ if(0 == strcmp(&(argv[c][2]), pairs[d].key))
+ {
+ break;
+ }
+ }
+ if(NULL == pairs[d].key)
+ {
+ usage(EXIT_FAILURE);
+ }
+ }
+ else
+ {
+ usage(EXIT_FAILURE);
+ }
+ }
+ for(c = 1 ; c < argc; c++)
+ {
+ for(d = 0; NULL != pairs[d].key; d++)
+ {
+ if(0 == strcmp(&(argv[c][2]), pairs[d].key))
+ {
+ printf("%s\n", pairs[d].value);
+ break;
+ }
+ }
+ }
+ return 0;
+}
--- /dev/null
+.deps
+.libs
+Makefile
+Makefile.in
+*.la
+*.lo
+*.so
+*.a
+*.dll
+*.exe
+*.o
--- /dev/null
+## @(#) $Id$
+
+## Copyright (c) 2008 Mo McRoberts.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions
+## are met:
+## 1. Redistributions of source code must retain the above copyright
+## notice, this list of conditions and the following disclaimer.
+## 2. Redistributions in binary form must reproduce the above copyright
+## notice, this list of conditions and the following disclaimer in the
+## documentation and/or other materials provided with the distribution.
+## 3. The names of the author(s) of this software may not be used to endorse
+## or promote products derived from this software without specific prior
+## written permission.
+##
+## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+## AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+## AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+## TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+## LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+## NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+## SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+lib_LTLIBRARIES = libiri.la
+
+libiri_la_LDFLAGS = -avoid-version
+
+libiri_la_SOURCES = \
+ p_libiri.h \
+ parse.c destroy.c
+
--- /dev/null
+/*
+ * Copyright (c) 2005, 2008 Mo McRoberts.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the author(s) of this software may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "p_libiri.h"
+
+void
+iri_destroy(iri_t *iri)
+{
+ if(NULL != iri)
+ {
+ free(iri->_private);
+ free(iri);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2005, 2008 Mo McRoberts.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the author(s) of this software may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef P_LIBIRI_H_
+# define P_LIBIRI_H_ 1
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "iri.h"
+
+#endif /* !P_LIBIRI_H_ */
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2005, 2008 Mo McRoberts.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the author(s) of this software may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "p_libiri.h"
+
+static inline const char *
+iri__copychar_decode(char **dest, const char *src)
+{
+ **dest = *src;
+ src++;
+ (*dest)++;
+ return src;
+}
+
+static inline char *
+iri__allocbuf(const char *src)
+{
+ /* Calculate the size of the buffer required to hold a decoded version of
+ * src, including enough breathing space for null bytes.
+ */
+ /* XXX: This is way too much; we need to actually count it */
+ return (char *) calloc(1, (strlen(src) * 4) + 16);
+}
+
+iri_t *
+iri_parse(const char *src)
+{
+ iri_t *p;
+ char *bufstart, *endp, *bufp;
+ const char *at, *colon, *slash;
+
+ if(NULL == (p = (iri_t *) calloc(1, sizeof(iri_t))))
+ {
+ return NULL;
+ }
+ if(NULL == (bufstart = iri__allocbuf(src)))
+ {
+ free(p);
+ return NULL;
+ }
+ p->_private = bufp = bufstart;
+ at = strchr(src, '@');
+ slash = strchr(src, '/');
+ colon = strchr(src, ':');
+ if(slash && colon && slash < colon)
+ {
+ /* We can disregard the colon if a slash appears before it */
+ colon = NULL;
+ }
+ if(colon && !at)
+ {
+ /* Definitely a scheme */
+ p->scheme = bufp;
+ while(*src && *src != ':')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ src++;
+ /* src[0-1] SHOULD == '/' */
+ for(; *src == '/'; src++);
+ }
+ else if(colon && at && colon < at)
+ {
+ /* This could be scheme://user[:auth]@host or [scheme:]user[:auth]@host (urgh) */
+ if(colon[1] == '/')
+ {
+ p->scheme = bufp;
+ while(*src && *src != ':')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ src++;
+ /* src[0-1] SHOULD == '/' */
+ for(; *src == '/'; src++);
+ p->user = bufp;
+ }
+ else
+ {
+ p->scheme = bufp;
+ }
+ while(*src && *src != ':' && *src != '@')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ if(*src == ':')
+ {
+ /* Following auth data */
+ src++;
+ p->auth = bufp;
+ while(*src && *src != ':' && *src != '@')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ if(*src == ':')
+ {
+ src++;
+ /* It was actually scheme:user:auth@host */
+ p->user = p->auth;
+ p->auth = bufp;
+ while(*src && *src != '@')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ }
+ }
+ if(!*src)
+ {
+ /* No host part */
+ return p;
+ }
+ if(*src == '@')
+ {
+ src++;
+ }
+ }
+ else if(at)
+ {
+ /* user@host[/path...] */
+ p->user = bufp;
+ while(*src != '@')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ src++;
+ }
+ p->host = bufp;
+ while(*src && *src != ':' && *src != '/' && *src != '?' && *src != '#')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ if(*src == ':')
+ {
+ /* Port part */
+ src++;
+ endp = (char *) src;
+ p->port = strtol(src, &endp, 10);
+ src = endp;
+ }
+ if(*src == '/')
+ {
+ p->path = bufp;
+ while(*src && *src != '?' && *src != '#')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ }
+ if(*src == '?')
+ {
+ p->query = bufp;
+ src++;
+ while(*src && *src != '#')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ }
+ if(*src == '#')
+ {
+ p->anchor = bufp;
+ while(*src)
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ }
+ if(*src)
+ {
+ /* Still stuff left? It must be a path... of sorts */
+ p->path = bufp;
+ while(*src && *src != '?' && *src != '#')
+ {
+ src = iri__copychar_decode(&bufp, src);
+ }
+ *bufp = 0;
+ bufp++;
+ }
+ return p;
+}
--- /dev/null
+.deps
+.libs
+Makefile
+Makefile.in
+*.la
+*.lo
+*.so
+*.a
+*.dll
+*.exe
+*.o
+iridump
+
--- /dev/null
+## @(#) $Id$
+
+## Copyright (c) 2008 Mo McRoberts.
+##
+## Redistribution and use in source and binary forms, with or without
+## modification, are permitted provided that the following conditions
+## are met:
+## 1. Redistributions of source code must retain the above copyright
+## notice, this list of conditions and the following disclaimer.
+## 2. Redistributions in binary form must reproduce the above copyright
+## notice, this list of conditions and the following disclaimer in the
+## documentation and/or other materials provided with the distribution.
+## 3. The names of the author(s) of this software may not be used to endorse
+## or promote products derived from this software without specific prior
+## written permission.
+##
+## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+## INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+## AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+## AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+## TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+## LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+## NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+## SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+noinst_PROGRAMS = iridump
+
+iridump_SOURCES = iridump.c
+iridump_LDADD = ../libiri/libiri.la
--- /dev/null
+/*
+ * Copyright (c) 2005, 2008 Mo McRoberts.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The names of the author(s) of this software may not be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * AUTHORS OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "iri.h"
+
+int
+main(int argc, char **argv)
+{
+ iri_t *iri;
+
+ if(argc != 2)
+ {
+ fprintf(stderr, "Usage: %s IRI\n", argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ iri = iri_parse(argv[1]);
+ printf("scheme: %s\n", iri->scheme);
+ printf(" user: %s\n", iri->user);
+ printf(" auth: %s\n", iri->auth);
+ printf(" host: %s\n", iri->host);
+ printf(" port: %d\n", iri->port);
+ printf(" path: %s\n", iri->path);
+ printf(" query: %s\n", iri->query);
+ printf("anchor: %s\n", iri->anchor);
+ return 0;
+}