From a26f5f6415a990b77d61ebfd4f1b51af26c2d6fb Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Wed, 30 Nov 2011 11:19:37 +0200 Subject: [PATCH] Add examples/parse.c --- examples/Makefile.am | 7 ++++++- examples/parse.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 examples/parse.c diff --git a/examples/Makefile.am b/examples/Makefile.am index 2cb4422..5a7b397 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,5 +1,5 @@ if WITH_EXAMPLES -noinst_PROGRAMS= simple version +noinst_PROGRAMS= simple version parse simple_SOURCES= simple.c common.c common.h simple_CPPFLAGS= -I$(top_srcdir)/src/libquvi $(AM_CPPFLAGS) @@ -11,6 +11,11 @@ version_CPPFLAGS= -I$(top_srcdir)/src/libquvi $(AM_CPPFLAGS) version_CFLAGS= $(AM_CFLAGS) version_LDFLAGS= $(top_builddir)/src/libquvi/libquvi.la $(AM_LDFLAGS) +parse_SOURCES= parse.c +parse_CPPFLAGS= -I$(top_srcdir)/src/libquvi $(AM_CPPFLAGS) +parse_CFLAGS= $(AM_CFLAGS) +parse_LDFLAGS= $(top_builddir)/src/libquvi/libquvi.la $(AM_LDFLAGS) + if WITH_SOUP noinst_PROGRAMS+= callback_libsoup diff --git a/examples/parse.c b/examples/parse.c new file mode 100644 index 0000000..1794ee4 --- /dev/null +++ b/examples/parse.c @@ -0,0 +1,54 @@ +/* libquvi + * Copyright (C) 2011 Toni Gundogdu + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#include +#include + +int main(int argc, char **argv) +{ + quvi_media_t m; + QUVIcode rc; + quvi_t q; + + rc = quvi_init(&q); + if (rc != QUVI_OK) + { + puts(quvi_strerror(q, rc)); + quvi_close(&q); /* Must be closed. */ + return (rc); + } + + quvi_setopt(q, QUVIOPT_NORESOLVE, 1L); /*!*/ + + rc = quvi_parse(q, "http://dai.ly/cityofscars", &m); + if (rc != QUVI_OK) + puts(quvi_strerror(q, rc)); + else + { + char *s; + quvi_getprop(m, QUVIPROP_PAGETITLE, &s); + puts(s); + } + quvi_parse_close(&m); + quvi_close(&q); + + return (0); +} + +/* vim: set ts=2 sw=2 tw=72 expandtab: */ -- 2.11.4.GIT