|
From: <gu...@us...> - 2007-08-20 21:17:18
|
Revision: 396
http://viking.svn.sourceforge.net/viking/?rev=396&view=rev
Author: guyou
Date: 2007-08-20 14:17:21 -0700 (Mon, 20 Aug 2007)
Log Message:
-----------
libcurl is a requirement
It is no more a optional feature, but an "hard" requirement.
The main reason is that it is time consuming to maintain code
to work with and without libcurl. Furthermore, libcurl is available
in a lot of distributions now.
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.ac
trunk/src/Makefile.am
trunk/src/curl_download.c
trunk/src/download.c
trunk/src/download.h
trunk/src/expedia.c
trunk/src/google.c
trunk/src/googlemaps.c
trunk/src/googlesearch.c
trunk/src/khmaps.c
trunk/src/main.c
trunk/src/osm.c
trunk/src/terraserver.c
Removed Paths:
-------------
trunk/src/http.c
trunk/src/http.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/ChangeLog 2007-08-20 21:17:21 UTC (rev 396)
@@ -1,4 +1,8 @@
2007-08-20
+Guilhem Bonnefille <gui...@gm...>:
+ * libcurl is a requirement
+
+2007-08-20
Quy Tonthat <qto...@gm...>:
* Fix bugs that cause crashes on layers copy/paste/delete.
* Fix bug in Google search that caused viking jump to wrong location
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/configure.ac 2007-08-20 21:17:21 UTC (rev 396)
@@ -28,7 +28,7 @@
AM_WITH_EXPAT
# Curl
-LIBCURL_CHECK_CONFIG([yes],[],[AM_CONDITIONAL([LIBCURL],[true])],[AM_CONDITIONAL([LIBCURL],[false])])
+LIBCURL_CHECK_CONFIG([yes],[],[],[AC_MSG_ERROR([libcurl is needed but not found])])
AC_CHECK_PROG([GDK_PIXBUF_CSOURCE],gdk-pixbuf-csource,[yes])
if test $GDK_PIXBUF_CSOURCE != "yes"
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/Makefile.am 2007-08-20 21:17:21 UTC (rev 396)
@@ -15,6 +15,7 @@
viking_SOURCES = main.c \
modules.h modules.c \
+ curl_download.c curl_download.h \
menu.xml.h \
degrees_converters.c degrees_converters.h \
viking.h globals.h mapcoord.h config.h \
@@ -64,14 +65,6 @@
vikfilelist.c vikfilelist.h \
dems.c dems.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 \
Modified: trunk/src/curl_download.c
===================================================================
--- trunk/src/curl_download.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/curl_download.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -27,7 +27,6 @@
#include <gtk/gtk.h>
-#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#include "file.h"
@@ -112,4 +111,3 @@
return (ret ? -2 : 0); /* -2 HTTP error */
}
-#endif /* HAVE_LIB_CURL */
Modified: trunk/src/download.c
===================================================================
--- trunk/src/download.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/download.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -34,11 +34,7 @@
#include "download.h"
-#ifdef HAVE_LIBCURL
#include "curl_download.h"
-#else
-#include "http.h"
-#endif
#ifdef WINDOWS
@@ -141,11 +137,7 @@
}
/* Call the backend function */
-#ifdef HAVE_LIBCURL
ret = curl_download_get_url ( hostname, uri, f, options );
-#else
- ret = http_download_get_url ( hostname, uri, f, 0, options );
-#endif
if (ret == -1 || ret == 1 || ret == -2 || check_map_file(f))
{
Modified: trunk/src/download.h
===================================================================
--- trunk/src/download.h 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/download.h 2007-08-20 21:17:21 UTC (rev 396)
@@ -24,11 +24,6 @@
typedef struct {
/**
- * Indicates if we should send hostname on the GET request.
- * (see http.c)
- */
- int sendhostname;
- /**
* The REFERER string to use.
* Could be NULL.
*/
Modified: trunk/src/expedia.c
===================================================================
--- trunk/src/expedia.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/expedia.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -37,7 +37,7 @@
static void expedia_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest );
static int expedia_download ( MapCoord *src, const gchar *dest_fn );
-static DownloadOptions expedia_options = { 0, NULL };
+static DownloadOptions expedia_options = { NULL };
void expedia_init() {
VikMapsLayer_MapType map_type = { 5, 0, 0, VIK_VIEWPORT_DRAWMODE_EXPEDIA, expedia_coord_to_mapcoord, expedia_mapcoord_to_center_coord, expedia_download };
Modified: trunk/src/google.c
===================================================================
--- trunk/src/google.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/google.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -40,7 +40,7 @@
static void google_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest );
static gboolean google_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
-static DownloadOptions google_options = { 1, "http://maps.google.com/" };
+static DownloadOptions google_options = { "http://maps.google.com/" };
void google_init () {
VikMapsLayer_MapType google_1 = { 7, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, google_coord_to_mapcoord, google_mapcoord_to_center_coord, google_download };
Modified: trunk/src/googlemaps.c
===================================================================
--- trunk/src/googlemaps.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/googlemaps.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -30,7 +30,7 @@
#include "googlemaps.h"
-static DownloadOptions googlemaps_options = { 1, "http://maps.google.com/" };
+static DownloadOptions googlemaps_options = { "http://maps.google.com/" };
/* initialisation */
void googlemaps_init () {
Modified: trunk/src/googlesearch.c
===================================================================
--- trunk/src/googlesearch.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/googlesearch.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -35,7 +35,7 @@
static VikCoord *last_coord = NULL;
static gchar *last_successful_search_str = NULL;
-static DownloadOptions googlesearch_options = { 0, "http://maps.google.com/" };
+static DownloadOptions googlesearch_options = { "http://maps.google.com/" };
gchar * a_googlesearch_get_search_string_for_this_place(VikWindow *vw)
{
Deleted: trunk/src/http.c
===================================================================
--- trunk/src/http.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/http.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -1,199 +0,0 @@
-/*
- * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
- *
- * Copyright (C) 2003-2005, Evan Battaglia <gt...@gm...>
- *
- * 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
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <gtk/gtk.h>
-#include <string.h>
-
-#ifdef WINDOWS
-#include <winsock.h>
-#else
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#endif
-
-#include "http.h"
-
-int http_connect(const char *hostname, int port)
-{
- int sock;
- struct sockaddr_in server;
- struct hostent *host_addr;
-
- /* create a socket of type AF_INET, and SOCK_STREAM (TCP) */
- sock = socket(AF_INET, SOCK_STREAM, 0);
-
- /* get an IP from a domain name -- essential */
- host_addr = gethostbyname(hostname);
- if (host_addr == NULL)
- return(-1);
-
- server.sin_family = AF_INET;
- /* 110 is the standard POP port. Host TO Network order. */
- server.sin_port = htons(port);
- /* get the IP address. */
- server.sin_addr = *((struct in_addr *) host_addr->h_addr);
- /* padding unused in sockaddr_in */
-#ifndef WINDOWS
- bzero(&(server.sin_zero), 8);
-#endif
-
- if ((connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr))) == -1)
- return(-2);
-
- return(sock);
-}
-
-int http_get_line(int sock, char *buf, int len)
-{
- static char lilbuf;
- int size, count;
-
- count = 1;
- size = 1;
- lilbuf = 'a';
- while (size != 0 && lilbuf != '\n' && count < len)
- {
- size = recv(sock, &lilbuf, 1, 0);
- if (size == 0 && count == 1 )
- return 0;
-
- if (size > 0)
- *buf++ = lilbuf;
- count++;
- }
- *buf = '\0';
-
- return 1;
-}
-
-int http_download_get_url ( const char *hostname, const char *uri, FILE *f, int already_redirected, DownloadOptions *options )
-{
- static char input_buffer[1024];
- int sock;
- int len;
- FILE *tmp_f;
- /* int hnlen = strlen ( hostname ); */
-
-#ifdef WINDOWS
- WSADATA usadata;
- WSAStartup ( MAKEWORD(2,2), &usadata );
-#endif
-
- sock = http_connect ( hostname, 80 );
- if (sock < 0)
- {
- return -1;
- }
-
-
- if ( options != NULL && options->sendhostname ) {
- send ( sock, "GET http://", 11, 0);
- send ( sock, hostname, strlen(hostname), 0 );
- send ( sock, uri, strlen ( uri ), 0 );
- send ( sock, " HTTP/1.0\r\n\r\n", 13, 0 );
- } else {
- send ( sock, "GET ", 4, 0 );
- send ( sock, uri, strlen ( uri ), 0 );
- send ( sock, "\r\n\r\n", 4, 0 );
- }
-
- /* next, skip through all headers EXCEPT content length.,
- that is, if it begins with "Content-Length: " (strncasecmp),
- atoi that line from +16 (+17 ?), read that many bytes directly
- into file (IF we can open it, else return error) and we're done.
- */
-
- /* "HTTP/1.x 200 OK" check */
- if ( recv ( sock, input_buffer, 12, 0 ) < 12 || input_buffer[9] != '2' || input_buffer[10] != '0' || input_buffer[11] != '0' )
- {
- /* maybe it's a redirect */
- if ( ! already_redirected )
- do
- {
- if ( http_get_line ( sock, input_buffer, 1024 ) == 0 )
- break;
-
- /* Location: http://abc.def/bla */
- if ( strncmp(input_buffer, "Location: ", 10) == 0 && strlen(input_buffer) > 17 )
- {
- char *uri_start;
-
- int rv;
- uri_start = strchr(input_buffer+17,'/');
-
- if ( uri_start )
- {
- char *newhost = g_strndup ( input_buffer + 17, uri_start - input_buffer - 17 );
- char *newuri = strdup ( uri_start );
- close ( sock );
-
- if ( options != NULL )
- rv = http_download_get_url ( newhost, newuri, f, 1, options->sendhostname );
- else
- rv = http_download_get_url ( newhost, newuri, f, 1, 0 );
-
- free ( newhost );
- free ( newuri );
- return rv;
- }
- }
- } while (input_buffer[0] != '\r' );
-
- /* Something went wrong */
- return 1;
- }
-
- do
- {
- if ( http_get_line ( sock, input_buffer, 1024 ) == 0 )
- {
- close ( sock );
- return -2;
- }
- } while (input_buffer[0] != '\r' );
-
- tmp_f = tmpfile();
-
- do {
- len = recv ( sock, input_buffer, 1024, 0 );
- if ( len > 0 )
- fwrite ( input_buffer, 1, len, tmp_f );
- } while ( len > 0 );
-
- rewind(tmp_f);
-
- while ( ! feof(tmp_f) )
- {
- len = fread ( input_buffer, 1, 1024, tmp_f );
- fwrite ( input_buffer, 1, len, f);
- }
- fclose ( tmp_f );
-
- close ( sock );
-#ifdef WINDOWS
- WSACleanup(); /* they sure make winsock programming easy. */
-#endif
- return 0;
-}
Deleted: trunk/src/http.h
===================================================================
--- trunk/src/http.h 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/http.h 2007-08-20 21:17:21 UTC (rev 396)
@@ -1,31 +0,0 @@
-/*
- * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
- *
- * Copyright (C) 2003-2005, Evan Battaglia <gt...@gm...>
- *
- * 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_HTTP_H
-#define _VIKING_HTTP_H
-
-#include <stdio.h>
-
-#include "download.h"
-
-int http_download_get_url ( const char *hostname, const char *uri, FILE *f, int already_redirected, DownloadOptions *options );
-
-#endif
Modified: trunk/src/khmaps.c
===================================================================
--- trunk/src/khmaps.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/khmaps.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -31,7 +31,7 @@
#include "khmaps.h"
-static DownloadOptions khmaps_options = { 1, NULL };
+static DownloadOptions khmaps_options = { NULL };
void khmaps_init () {
VikMapsLayer_MapType map_type = { 8, 256, 256, VIK_VIEWPORT_DRAWMODE_KH, khmaps_coord_to_mapcoord, khmaps_mapcoord_to_center_coord, khmaps_download };
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/main.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -92,9 +92,7 @@
gtk_init (&argc, &argv);
-#ifdef HAVE_LIBCURL
curl_download_init();
-#endif
/* Init modules/plugins */
modules_init();
Modified: trunk/src/osm.c
===================================================================
--- trunk/src/osm.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/osm.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -25,7 +25,6 @@
#include "coords.h"
#include "vikcoord.h"
#include "mapcoord.h"
-#include "http.h"
#include "vikmapslayer.h"
#include "osm.h"
@@ -38,7 +37,7 @@
static int osm_mapnik_download ( MapCoord *src, const gchar *dest_fn );
static int osm_osmarender_download ( MapCoord *src, const gchar *dest_fn );
-static DownloadOptions osm_options = { 1, NULL };
+static DownloadOptions osm_options = { NULL };
/* initialisation */
void osm_init () {
Modified: trunk/src/terraserver.c
===================================================================
--- trunk/src/terraserver.c 2007-08-20 08:40:27 UTC (rev 395)
+++ trunk/src/terraserver.c 2007-08-20 21:17:21 UTC (rev 396)
@@ -41,7 +41,7 @@
static void terraserver_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest );
-static DownloadOptions terraserver_options = { 0, NULL };
+static DownloadOptions terraserver_options = { NULL };
void terraserver_init () {
VikMapsLayer_MapType map_type_1 = { 2, 200, 200, VIK_VIEWPORT_DRAWMODE_UTM, terraserver_topo_coord_to_mapcoord, terraserver_mapcoord_to_center_coord, terraserver_topo_download };
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|