# Expat
AM_WITH_EXPAT
+# Curl
+LIBCURL_CHECK_CONFIG([yes],[],[AM_CONDITIONAL([LIBCURL],[true])],[AM_CONDITIONAL([LIBCURL],[false])])
+
AC_CHECK_PROG([GDK_PIXBUF_CSOURCE],gdk-pixbuf-csource,[yes])
if test $GDK_PIXBUF_CSOURCE != "yes"
then
file.c file.h \
authors.h \
dialog.c dialog.h \
- http.c http.h \
download.c download.h \
viktreeview.c viktreeview.h \
viktrwlayer.c viktrwlayer.h viktrwlayer_pixmap.h \
datasource_gc.c \
datasources.h
+if LIBCURL
+viking_SOURCES += \
+ curl_download.c curl_download.h
+else
+viking_SOURCES += \
+ http.c http.h
+endif
+
if GOOGLE
viking_SOURCES += \
khmaps.c khmaps.h \
expedia.c expedia.h
endif
-INCLUDES = @GTK_CFLAGS@ @EXPAT_CFLAGS@
-LDADD = @GTK_LIBS@ @EXPAT_LIBS@
+INCLUDES = @GTK_CFLAGS@ @EXPAT_CFLAGS@ @LIBCURL_CPPFLAGS@
+LDADD = @GTK_LIBS@ @EXPAT_LIBS@ @LIBCURL@
AM_CFLAGS = -Wall -g
--- /dev/null
+/*
+ * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
+ *
+ * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gtk/gtk.h>
+
+#ifdef HAVE_LIBCURL
+#include <curl/curl.h>
+#endif
+
+#include "curl_download.h"
+
+int curl_download_uri ( const char *uri, FILE *f )
+{
+#ifdef HAVE_LIBCURL
+ CURL *curl;
+ CURLcode res;
+
+ curl = curl_easy_init ();
+ if ( curl )
+ {
+ curl_easy_setopt ( curl, CURLOPT_URL, uri );
+ curl_easy_setopt ( curl, CURLOPT_FILE, f );
+ res = curl_easy_perform ( curl );
+ curl_easy_cleanup ( curl );
+ }
+#endif
+}
+
+int curl_download_get_url ( const char *hostname, const char *uri, FILE *f )
+{
+ int ret;
+ gchar *full = NULL;
+
+ /* Compose the full url */
+ full = g_strdup_printf ( "http://%s%s", hostname, uri );
+ ret = curl_download_uri ( full, f );
+ g_free ( full );
+ full = NULL;
+
+ return ret;
+}
--- /dev/null
+/*
+ * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
+ *
+ * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _VIKING_CURL_DOWNLOAD_H
+#define _VIKING_CURL_DOWNLOAD_H
+
+#include <stdio.h>
+
+int curl_download_get_url ( const char *hostname, const char *uri, FILE *f );
+
+#endif
*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <errno.h>
#include <gtk/gtk.h>
#include <sys/types.h>
#include "download.h"
+
+#ifdef HAVE_LIBCURL
+#include "curl_download.h"
+#else
#include "http.h"
+#endif
#ifdef WINDOWS
}
/* Call the backend function */
+#ifdef HAVE_LIBCURL
+ ret = curl_download_get_url ( hostname, uri, f );
+#else
ret = http_download_get_url ( hostname, uri, f, 0, sendhostname );
+#endif
if (ret == -1 || ret == 1 || ret == -2)
{
return 1;
}
-/* makes directory if neccessary */
int http_download_get_url ( const char *hostname, const char *uri, FILE *f, int already_redirected, int sendhostname )
{
static char input_buffer[1024];