summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicolas.dufresne <nicolas.dufresne@c587cffe-e639-0410-9787-d7902ae8ed56>2010-05-18 14:22:56 +0000
committernicolas.dufresne <nicolas.dufresne@c587cffe-e639-0410-9787-d7902ae8ed56>2010-05-18 14:22:56 +0000
commitf25371797c814cfc4b06c55fe7f4c1a1eccb3b18 (patch)
tree068d4ecad27a80aae7f668e66f86b325e5a18698
parent631f23c5f1508eadedfd7099ae3e228f7bc83997 (diff)
downloadlibproxy-git-libproxy-0.4.0.tar.gz
Tag for LibProxy 0.4.0libproxy-0.4.0
-rw-r--r--AUTHORS1
-rw-r--r--CMakeLists.txt25
-rw-r--r--INSTALL30
-rw-r--r--NEWS5
-rw-r--r--bindings/CMakeLists.txt32
-rw-r--r--bindings/libproxy.py4
-rw-r--r--bindings/perl/CMakeLists.txt23
-rw-r--r--bindings/perl/lib/CMakeLists.txt2
-rw-r--r--bindings/perl/lib/Libproxy.pm75
-rw-r--r--bindings/perl/src/CMakeLists.txt25
-rw-r--r--bindings/perl/src/Libproxy.xs62
-rw-r--r--bindings/perl/src/doxsubpp.pl23
-rw-r--r--bindings/perl/src/typemap2
-rw-r--r--bindings/perl/t/CMakeLists.txt1
-rw-r--r--bindings/perl/t/Libproxy.t15
-rw-r--r--bindings/vala/libproxy-1.0.vapi10
-rw-r--r--libmodman/CMakeLists.txt2
-rw-r--r--libmodman/module_manager.cpp2
-rw-r--r--libmodman/module_manager.hpp10
-rw-r--r--libproxy.spec.in318
-rw-r--r--libproxy/CMakeLists.txt127
-rw-r--r--libproxy/Findlibproxy.cmake.in20
-rw-r--r--libproxy/extension_network.hpp3
-rw-r--r--libproxy/libproxy-1.0.pc.in4
-rw-r--r--libproxy/modules/config_gnome.cpp210
-rw-r--r--libproxy/modules/config_kde4.cpp3
-rw-r--r--libproxy/modules/config_macosx.cpp6
-rw-r--r--libproxy/modules/network_networkmanager.cpp2
-rw-r--r--libproxy/modules/pacrunner_webkit.cpp6
-rw-r--r--libproxy/modules/pxgconf.cpp13
-rw-r--r--libproxy/modules/xhasclient.cpp87
-rw-r--r--libproxy/proxy.cpp67
-rw-r--r--libproxy/proxy.h17
-rw-r--r--libproxy/url.cpp53
-rw-r--r--samples/perl/sample.pl7
-rw-r--r--samples/vala/sample.vala9
36 files changed, 480 insertions, 821 deletions
diff --git a/AUTHORS b/AUTHORS
index 50c4e27..b8464bc 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,4 +1,3 @@
Nathaniel McCallum <nathaniel@natemccallum.com>
Alex Panait <kippled@gmail.com>
Dominique Leuenberger <dominique-libproxy@leuenberger.net>
-Gonéri Le Bouder <goneri@rulezlan.org> - Perl bindings
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e6a406c..093e628 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
### Required
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 2.8)
project(libproxy)
### Enable packaging
@@ -30,36 +30,33 @@ enable_testing()
# Setup our relative paths
if(${WIN32})
- set(rlibdir .)
+ set(rlibdir .)
set(rmoduledir modules/)
set(rlibexecdir .)
set(rbindir .)
set(rincludedir include/)
- set(rdatadir .)
else()
- set(rlibdir lib${LIB_SUFFIX}/)
- set(rmoduledir ${rlibdir}${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_VERSION}/modules/)
+ set(rlibdir lib${LIB_SUFFIX}/)
+ set(rmoduledir ${rlibdir}/${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_VERSION}/modules/)
set(rlibexecdir libexec/)
set(rbindir bin/)
set(rincludedir include/)
- set(rdatadir share/)
endif()
# Setup our full paths
-set(prefix ${CMAKE_INSTALL_PREFIX} CACHE PATH "prefix")
-set(libdir ${prefix}/${rlibdir} CACHE PATH "libdir")
-set(moduledir ${prefix}/${rmoduledir} CACHE PATH "moduledir")
-set(libexecdir ${prefix}/${rlibexecdir} CACHE PATH "libexecdir")
-set(bindir ${prefix}/${rbindir} CACHE PATH "bindir")
-set(includedir ${prefix}/${rincludedir} CACHE PATH "includedir")
-set(datadir ${prefix}/${rdatadir} CACHE PATH "datadir")
+set(prefix ${CMAKE_INSTALL_PREFIX})
+set(libdir ${prefix}/${rlibdir})
+set(moduledir ${prefix}/${rmoduledir})
+set(libexecdir ${prefix}/${rlibexecdir})
+set(bindir ${prefix}/${rbindir})
+set(includedir ${prefix}/${rincludedir})
# Add a global compilation stuff
if (WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
else()
add_definitions(-D_POSIX_C_SOURCE=1)
- set(CMAKE_CXX_FLAGS "-g -Wall -Werror -fvisibility=hidden -Os ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS "-g -Wall -Werror -fvisibility=hidden ${CMAKE_CXX_FLAGS}")
endif()
### Subdirectories
diff --git a/INSTALL b/INSTALL
index a12fcc3..ec976b6 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,35 +1,5 @@
-
-Quick Start
-###########
-
1. cmake ./
2. make
3. make install
Or something like that...
-
-
-More advanced installation options:
-###################################
-1. Run cmake with optional arguments (any combination of, some might not make much sense though):
-
- -DCMAKE_INSTALL_PREFIX=/usr/local
- -Dlibdir=/usr/local/lib
- -Dlibexecdir=/usr/local/libexec
- -Ddatadir=/usr/local/share
- -Dmoduledir=/usr/local/lib/libproxy/0.4.0/modules
- -DWITH_VALA=yes
- -DPERL_VENDORINSTALL=yes
-
-Most of the arguments are selfexplanatory.
--DWITH_VALA=yes can be specified if the Vala bindings shall be installed too
--DPERL_VENDORINSTALL=yes specifies that the perl bindings should be installed in the vendor-lib folders and not in site-lib (as it would by default).
-
-2. Build the binaries using make
-
-Of course you can use parallel build using "make -j2" (limited testing is done on this. We try to have this functional)
-
-3. Installation
-
-make install [DESTDIR=/any/prefix/to/prepend]
-
diff --git a/NEWS b/NEWS
index d219482..324e2c0 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,3 @@
-New in version 0.4.1
-===============================
-* Perl bindings have been integrated into the CMake Build System
-* Vala bindings are installed if -DWITH_VALA=yes is passed to cmake
-
New in version 0.4.0
===============================
* C++ rewrite
diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt
index f1ce1d2..0d9f749 100644
--- a/bindings/CMakeLists.txt
+++ b/bindings/CMakeLists.txt
@@ -1,27 +1,13 @@
-option(WITH_PYTHON "Enables Python bindings" ON)
-if (WITH_PYTHON)
- find_package(PythonInterp)
-
- if(PYTHONINTERP_FOUND)
- execute_process(COMMAND
- ${PYTHON_EXECUTABLE}
- -c "import distutils.sysconfig ; print distutils.sysconfig.get_python_lib(plat_specific=0)"
- OUTPUT_VARIABLE pysitepkgdir
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- install(FILES libproxy.py DESTINATION ${pysitepkgdir})
- endif()
+find_package(PythonInterp)
+
+if(PYTHONINTERP_FOUND)
+ execute_process(COMMAND
+ ${PYTHON_EXECUTABLE}
+ -c "import distutils.sysconfig ; print distutils.sysconfig.get_python_lib(plat_specific=1)"
+ OUTPUT_VARIABLE pysitepkgdir
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ install(FILES libproxy.py DESTINATION ${pysitepkgdir})
endif()
#TODO c-sharp bindings
-#perl bindings live in their own subdir.
-option(WITH_PERL "Enables Perl bindings" ON)
-if (WITH_PERL)
- add_subdirectory(perl)
-endif()
-
-# Install Vala bindings / Install only when -DWITH_VALA is passed to cmake.
-option(WITH_VALA "Enables Vala bindings" OFF)
-if(WITH_VALA)
- install(FILES vala/libproxy-1.0.vapi DESTINATION ${datadir}/vala/vapi)
-endif()
diff --git a/bindings/libproxy.py b/bindings/libproxy.py
index 307372d..5d9b43f 100644
--- a/bindings/libproxy.py
+++ b/bindings/libproxy.py
@@ -32,7 +32,7 @@ _libproxy.px_proxy_factory_get_proxies.restype = ctypes.POINTER(ctypes.c_void_p)
class ProxyFactory(object):
"""A ProxyFactory object is used to provide potential proxies to use
- in order to reach a given URL (via 'getProxies(url)').
+ in order to reach a given URL (via 'getProxy(url)').
This instance should be kept around as long as possible as it contains
cached data to increase performance. Memory usage should be minimal (cache
@@ -41,7 +41,7 @@ class ProxyFactory(object):
Usage is pretty simple:
pf = libproxy.ProxyFactory()
for url in urls:
- proxies = pf.getProxies(url)
+ proxies = pf.getProxy(url)
for proxy in proxies:
if proxy == "direct://":
# Fetch URL without using a proxy
diff --git a/bindings/perl/CMakeLists.txt b/bindings/perl/CMakeLists.txt
deleted file mode 100644
index 29495bc..0000000
--- a/bindings/perl/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-find_package(Perl)
-include (FindPerlLibs)
-
-if(PERL_FOUND AND PERLLIBS_FOUND)
-
- # Some distributions install perl packages in vendor when shipped with the distro.
- # Let's make their lifes easier by offering an install flag for this usecase.
- if(PERL_VENDORINSTALL)
- set (PX_PERL_ARCH ${PERL_VENDORARCH})
- set (PX_PERL_LIB ${PERL_VENDORLIB})
- else()
- # PERL_SITEARCH is actually not defined in latest FindPerlLibs.cmake macros, thus
- # we have to find the correct path on our own.
- EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -MConfig -e "print \$Config{sitearch}"
- OUTPUT_VARIABLE PX_PERL_ARCH)
- set (PX_PERL_LIB ${PERL_SITELIB})
- endif()
-
- add_subdirectory(lib)
- add_subdirectory(src)
- add_subdirectory(t)
-endif()
-
diff --git a/bindings/perl/lib/CMakeLists.txt b/bindings/perl/lib/CMakeLists.txt
deleted file mode 100644
index 9856627..0000000
--- a/bindings/perl/lib/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_custom_target(PMlibproxy ALL ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Libproxy.pm ${CMAKE_BINARY_DIR}/perl/blib/lib/Libproxy.pm)
-install( FILES Libproxy.pm DESTINATION ${PX_PERL_ARCH}/Net )
diff --git a/bindings/perl/lib/Libproxy.pm b/bindings/perl/lib/Libproxy.pm
deleted file mode 100644
index 67670fe..0000000
--- a/bindings/perl/lib/Libproxy.pm
+++ /dev/null
@@ -1,75 +0,0 @@
-package Net::Libproxy;
-use 5.008000;
-use warnings;
-our $VERSION = '0.04';
-
-require Exporter;
-require DynaLoader;
-@ISA = qw(Exporter DynaLoader);
-@EXPORT = qw(proxy_factory_new proxy_factory_get_proxies);
-
-bootstrap Net::Libproxy;
-
-sub new {
- my $self;
-
- $self->{pf} = Net::Libproxy::proxy_factory_new();
-
- bless $self;
-}
-
-sub getProxies {
- my ($self, $url) = @_;
-
- return Net::Libproxy::proxy_factory_get_proxies($self->{pf}, $url);
-}
-
-1;
-
-
-=head1 NAME
-
-Net::Libproxy - Perl binding for libproxy ( http://code.google.com/p/libproxy/ )
-
-=head1 SYNOPSIS
-
- use Net::Libproxy;
-
- $p = new Net::Libproxy;
- $proxies = $p->getProxies('http://code.google.com/p/libproxy/');
-
- foreach my $proxy (@$proxies) {
- print $proxy."\n";
- }
-
-=head1 DESCRIPTION
-
-libproxy is a lightweight library which makes it easy to develop
-applications proxy-aware with a simple and stable API.
-
-=head2 EXPORT
-
-These two functions are also exported.
-proxy_factory_new()
-proxy_factory_get_proxies()
-
-=head1 SEE ALSO
-
-Libproxy homepage: http://code.google.com/p/libproxy/
-Net::Libproxy on Gitorious: http://gitorious.org/net-libproxy
-You can also read proxy.h and Net/Libproxy.pm
-
-=head1 AUTHOR
-
-Goneri Le Bouder, E<lt>goneri@rulezlan.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2009 by Goneri Le Bouder
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself, either Perl version 5.10.0 or,
-at your option, any later version of Perl 5 you may have available.
-
-
-=cut
diff --git a/bindings/perl/src/CMakeLists.txt b/bindings/perl/src/CMakeLists.txt
deleted file mode 100644
index 920aa09..0000000
--- a/bindings/perl/src/CMakeLists.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-
-include_directories( ${PERL_INCLUDE_PATH} ${CMAKE_SOURCE_DIR}/libproxy )
-
-# Run doxsubpp.pl to run xsubpp on Libproxy.xs
-add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Libproxy.c
- COMMAND ${PERL_EXECUTABLE} ARGS ${CMAKE_CURRENT_SOURCE_DIR}/doxsubpp.pl ${PERL_EXECUTABLE} Libproxy.xs Libproxy.c
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Libproxy.xs libproxy
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
-set(Libproxy_LIB_SRCS
- Libproxy.c
-)
-
-set(CMAKE_C_COMPILER ${CMAKE_CXX_COMPILER})
-set(CMAKE_C_FLAGS ${PERL_CXX_FLAGS} )
-
-set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/perl/blib/arch/auto/Net)
-add_library(PLlibproxy SHARED ${Libproxy_LIB_SRCS})
-
-target_link_libraries(PLlibproxy libproxy)
-set_target_properties(PLlibproxy PROPERTIES OUTPUT_NAME "Libproxy")
-set_target_properties(PLlibproxy PROPERTIES PREFIX "")
-
-install( TARGETS PLlibproxy DESTINATION ${PX_PERL_ARCH}/auto/Net/Libproxy )
diff --git a/bindings/perl/src/Libproxy.xs b/bindings/perl/src/Libproxy.xs
deleted file mode 100644
index cacdfd9..0000000
--- a/bindings/perl/src/Libproxy.xs
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-
-#include <proxy.h>
-
-
-void XS_pack_charPtrPtr( SV * arg, char ** array, int count) {
- int i;
- AV * avref;
- avref = (AV*)sv_2mortal((SV*)newAV());
- for (i=0; i<count; i++) {
- av_push(avref, newSVpv(array[i], strlen(array[i])));
- }
- SvSetSV( arg, newRV((SV*)avref));
-}
-
-
-MODULE = Net::Libproxy PACKAGE = Net::Libproxy
-
-PROTOTYPES: DISABLE
-
-pxProxyFactory *
-proxy_factory_new()
- PREINIT:
- pxProxyFactory *pf;
- CODE:
- pf = px_proxy_factory_new();
- RETVAL = pf;
- OUTPUT:
- RETVAL
-
-char **
-proxy_factory_get_proxies(pf, url)
- pxProxyFactory * pf
- char * url
- PREINIT:
- char ** array;
- int count_charPtrPtr;
- int i;
- CODE:
- array = px_proxy_factory_get_proxies(pf, url);
- RETVAL = array;
- i = 0;
- while( array[i] != NULL ) {
- i++;
- }
- count_charPtrPtr = i;
- OUTPUT:
- RETVAL
-
-
-MODULE = Net::Libproxy PACKAGE = Net::Libproxy::ProxyFactoryPtr
-
-void
-DESTROY(pf)
- pxProxyFactory * pf
- CODE:
- printf("Net::Libproxy::DESTROY\n");
- px_proxy_factory_free(pf);
-
-
diff --git a/bindings/perl/src/doxsubpp.pl b/bindings/perl/src/doxsubpp.pl
deleted file mode 100644
index 57ab4dd..0000000
--- a/bindings/perl/src/doxsubpp.pl
+++ /dev/null
@@ -1,23 +0,0 @@
-use strict;
-use warnings;
-use ExtUtils::MakeMaker;
-
-my $perl = $ARGV[0];
-my $in = $ARGV[1];
-my $out = $ARGV[2];
-
-my $mm = ExtUtils::MakeMaker->new( {
- NAME => 'Libproxy',
- NEEDS_LINKING => 1,
-} );
-
-my $perl_include_path = $mm->{PERL_INC};
-my @xsubinfo = split "\n", $mm->tool_xsubpp();
-
-my $xsubppdir = (map{ my $foo = $_; $foo =~ s/XSUBPPDIR = //; $foo } grep{ m/^XSUBPPDIR =/ } @xsubinfo)[0];
-my $xsubpp = "$xsubppdir/xsubpp";
-
-my $xsubppargs = (map{ my $foo = $_; $foo =~ s/XSUBPPARGS = //; $foo } grep{ m/^XSUBPPARGS =/ } @xsubinfo)[0];
-
-my $cmd = "$perl $xsubpp $xsubppargs -typemap typemap $in > $out";
-system $cmd;
diff --git a/bindings/perl/src/typemap b/bindings/perl/src/typemap
deleted file mode 100644
index 62be990..0000000
--- a/bindings/perl/src/typemap
+++ /dev/null
@@ -1,2 +0,0 @@
-TYPEMAP
-pxProxyFactory * T_PTROBJ
diff --git a/bindings/perl/t/CMakeLists.txt b/bindings/perl/t/CMakeLists.txt
deleted file mode 100644
index 8007124..0000000
--- a/bindings/perl/t/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_custom_target(test prove -b ${CMAKE_CURRENT_SOURCE_DIR})
diff --git a/bindings/perl/t/Libproxy.t b/bindings/perl/t/Libproxy.t
deleted file mode 100644
index 5c4fe61..0000000
--- a/bindings/perl/t/Libproxy.t
+++ /dev/null
@@ -1,15 +0,0 @@
-# Before `make install' is performed this script should be runnable with
-# `make test'. After `make install' it should work as `perl Foo.t'
-
-#########################
-
-# change 'tests => 1' to 'tests => last_test_to_print';
-
-use Test::More tests => 1;
-BEGIN { use_ok('Net::Libproxy') };
-
-#########################
-
-# Insert your test code below, the Test::More module is use()ed here so read
-# its man page ( perldoc Test::More ) for help writing this test script.
-
diff --git a/bindings/vala/libproxy-1.0.vapi b/bindings/vala/libproxy-1.0.vapi
deleted file mode 100644
index bec22d0..0000000
--- a/bindings/vala/libproxy-1.0.vapi
+++ /dev/null
@@ -1,10 +0,0 @@
-[CCode (cprefix = "px", lower_case_cprefix = "px_", cheader_filename = "proxy.h")]
-namespace Libproxy {
- [Compact]
- [CCode (free_function = "px_proxy_factory_free")]
- public class ProxyFactory {
- public ProxyFactory ();
- [CCode (array_length = false, array_null_terminated = true)]
- public string[] get_proxies (string url);
- }
-}
diff --git a/libmodman/CMakeLists.txt b/libmodman/CMakeLists.txt
index c5e0857..8f519fc 100644
--- a/libmodman/CMakeLists.txt
+++ b/libmodman/CMakeLists.txt
@@ -4,7 +4,7 @@ if(NOT WIN32)
target_link_libraries(libmodman dl)
endif()
set_target_properties(libmodman PROPERTIES PREFIX "" VERSION 0 SOVERSION 0.0.0)
-install(TARGETS libmodman DESTINATION ${libdir})
+install(TARGETS libmodman DESTINATION ${rlibdir})
### Tests
# Functions
diff --git a/libmodman/module_manager.cpp b/libmodman/module_manager.cpp
index a7a971d..91da917 100644
--- a/libmodman/module_manager.cpp
+++ b/libmodman/module_manager.cpp
@@ -223,7 +223,7 @@ static int load(map<string, vector<base_extension*> >& extensions,
<< prep_type_name(exts[i]->get_base_type()) << ")" << endl;
extensions[exts[i]->get_base_type()].push_back(exts[i]);
}
- delete[] exts;
+ delete exts;
return _LOAD_SUCC;
}
diff --git a/libmodman/module_manager.hpp b/libmodman/module_manager.hpp
index d67a2d9..3340dc8 100644
--- a/libmodman/module_manager.hpp
+++ b/libmodman/module_manager.hpp
@@ -25,7 +25,6 @@
#include <set>
#include <string>
#include <vector>
-#include <cassert>
#include "module.hpp"
@@ -50,13 +49,8 @@ public:
if (it != this->extensions.end()) {
vector<base_extension*> extlist = it->second;
- for (size_t i=0 ; i < extlist.size() ; i++) {
- T* obj = dynamic_cast<T*>(extlist[i]);
- if (obj)
- retlist.push_back(obj);
- else
- assert (obj != NULL);
- }
+ for (size_t i=0 ; i < extlist.size() ; i++)
+ retlist.push_back(dynamic_cast<T*>(extlist[i]));
sort(retlist.begin(), retlist.end(), &pcmp::cmp);
}
diff --git a/libproxy.spec.in b/libproxy.spec.in
index 550a855..dcfff27 100644
--- a/libproxy.spec.in
+++ b/libproxy.spec.in
@@ -1,7 +1,7 @@
#
-# spec file for package libproxy (Version 0.4.0)
+# spec file for package libproxy (Version 0.3.0)
#
-# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,9 +18,6 @@
# norootforbuild
%define build_core_not_modules 1
-%if 0%{suse_version} > 1120
-%define xulrunner_ver 192
-%else
%if 0%{suse_version} > 1110
%define xulrunner_ver 191
%else
@@ -30,7 +27,6 @@
%define xulrunner_ver 181
%endif
%endif
-%endif
Url: http://code.google.com/p/libproxy/
%define _name libproxy
@@ -38,30 +34,23 @@ Name: libproxy
Group: System/Libraries
Summary: Libproxy provides consistent proxy configuration to applications
Version: @VERSION@
-Release: 4
+Release: 1
Source: http://libproxy.googlecode.com/files/%{_name}-%{version}.tar.bz2
-Source99: baselibs.conf
-License: LGPLv2.1+
+License: LGPL v2.1 or later
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-BuildRequires: cmake
-BuildRequires: gcc-c++
BuildRequires: pkg-config
-BuildRequires: zlib-devel
+BuildRequires: python-devel
%if !%build_core_not_modules
BuildRequires: dbus-1-devel
BuildRequires: gconf2-devel
# For directory ownership, but also because we want to rebuild the modules if
# the library changed
-BuildRequires: libproxy1
+BuildRequires: libproxy0
BuildRequires: libwebkit-devel
BuildRequires: mozilla-xulrunner%{xulrunner_ver}-devel
BuildRequires: NetworkManager-devel
-BuildRequires: libkde4-devel
-BuildRequires: libqt4-devel
-%else
-BuildRequires: python-devel
+BuildRequires: xorg-x11-libXmu-devel
%endif
-
%if %suse_version <= 1110
%define python_sitelib %{py_sitedir}
%endif
@@ -83,10 +72,10 @@ libproxy offers the following features: * extremely small core
%if %build_core_not_modules
%package tools
-License: GPLv2+ ; LGPLv2.1+
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: A simple application using libproxy
Group: System/Libraries
-Requires: libproxy1 = %{version}
+Requires: libproxy0 = %{version}
%description tools
A simple application that will use libproxy to give the results you can
@@ -94,11 +83,11 @@ expect from other applications. It can be used to debug what would
happen in various cases.
-%package devel
-License: GPLv2+ ; LGPLv2.1+
+%package devel
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: Libproxy provides consistent proxy configuration to applications - Development Files
Group: Development/Libraries/C and C++
-Requires: libproxy1 = %{version}
+Requires: libproxy0 = %{version}
%description devel
libproxy offers the following features: * extremely small core
@@ -114,12 +103,12 @@ libproxy offers the following features: * extremely small core
* a standard way of dealing with proxy settings across all scenarios
-%package -n libproxy1
-License: GPLv2+ ; LGPLv2.1+
+%package -n libproxy0
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: Libproxy provides consistent proxy configuration to applications
Group: System/Libraries
-%description -n libproxy1
+%description -n libproxy0
libproxy offers the following features: * extremely small core
footprint (< 35K)
@@ -132,23 +121,12 @@ libproxy offers the following features: * extremely small core
* a standard way of dealing with proxy settings across all scenarios
-%package -n libmodman0_0_0
-License: GPLv2+ ; LGPLv2.1+
-Summary: Libproxy's Module Management Library
-Group: System/Libraries
-
-%description -n libmodman0_0_0
-A module management library taking care of loading / unload modules
-including heuristics in detecting which bindings might already
-be used by an application and favouring this one.
-
%package -n python-libproxy
-License: GPLv2+ ; LGPLv2.1+
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: Python bindings for libproxy
Group: System/Libraries
-BuildArch: noarch
-Requires: libproxy1 = %{version}
+Requires: libproxy0 = %{version}
%py_requires
%description -n python-libproxy
@@ -165,32 +143,11 @@ libproxy offers the following features: * extremely small core
* a standard way of dealing with proxy settings across all scenarios
-%package -n perl-Net-Libproxy
-License: GPLv2+ ; LGPLv2.1+
-Summary: Perl bindings for libproxy
-Group: Development/Libraries/Perl
-Requires: libproxy1 = %{version}
-Requires: perl = %{perl_version}%py_requires
-
-%description -n perl-Net-Libproxy
-libproxy offers the following features: * extremely small core
- footprint (< 35K)
-
-* no external dependencies within libproxy core (libproxy modules
- may have dependencies)
-
-* only 3 functions in the stable external API
-
-* dynamic adjustment to changing network topology
-
-* a standard way of dealing with proxy settings across all scenarios
-
-
%package -n libproxy-sharp
-License: GPLv2+ ; LGPLv2.1+
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: .Net bindings for libproxy
Group: Development/Languages/Mono
-Requires: libproxy1 = %{version}
+Requires: libproxy0 = %{version}
%description -n libproxy-sharp
libproxy offers the following features: * extremely small core
@@ -208,189 +165,228 @@ libproxy offers the following features: * extremely small core
%else
-%package -n libproxy1-config-gnome
-License: GPLv2+ ; LGPLv2.1+
+%package -n libproxy0-config-gnome
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: Libproxy module for GNOME configuration
Group: System/Libraries
-Requires: libproxy1 = %{version}
-Recommends: libproxy1-pacrunner = %{version}
-Recommends: libproxy1-wpad-dns = %{version}
-Supplements: packageand(libproxy1:gconf2)
+Requires: libproxy0 = %{version}
+Recommends: libproxy0-pacrunner = %{version}
+Recommends: libproxy0-wpad-dns = %{version}
+Supplements: packageand(libproxy0:gconf2)
Provides: libproxy-gnome = %{version}
Obsoletes: libproxy-gnome < %{version}
+Provides: libproxy0-gnome = %{version}
+Obsoletes: libproxy0-gnome < %{version}
+
-%description -n libproxy1-config-gnome
+%description -n libproxy0-config-gnome
A module to extend libproxy with capabilities to query GNOME about
proxy settings.
-%package -n libproxy1-config-kde4
-License: GPLv2+ ; LGPLv2.1+
+%package -n libproxy0-config-kde
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: Libproxy module for KDE configuration
Group: System/Libraries
-Requires: libproxy1 = %{version}
-Recommends: libproxy1-pacrunner = %{version}
-Recommends: libproxy1-wpad-dns = %{version}
-Supplements: packageand(libproxy1:libkde4)
+Requires: libproxy0 = %{version}
+Recommends: libproxy0-pacrunner = %{version}
+Recommends: libproxy0-wpad-dns = %{version}
+Supplements: packageand(libproxy0:libkde4)
Provides: libproxy-kde = %{version}
Obsoletes: libproxy-kde < %{version}
+Provides: libproxy0-kde = %{version}
+Obsoletes: libproxy0-kde < %{version}
-%description -n libproxy1-config-kde4
-A module to extend libproxy with capabilities to query KDE4 about proxy
+%description -n libproxy0-config-kde
+A module to extend libproxy with capabilities to query KDE about proxy
settings.
-%package -n libproxy1-pacrunner-mozjs
-License: GPLv2+ ; LGPLv2.1+
+%package -n libproxy0-pacrunner-mozjs
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: Libproxy module to support wpad/pac parsing via Mozilla JavaScript Engine
Group: System/Libraries
-Requires: libproxy1 = %{version}
-Supplements: packageand(libproxy1:mozilla-xulrunner%{xulrunner_ver})
+Requires: libproxy0 = %{version}
+Supplements: packageand(libproxy0:mozilla-xulrunner%{xulrunner_ver})
# A virtual symbol to identify that this is a pacrunner.
-Provides: libproxy1-pacrunner = %{version}
+Provides: libproxy0-pacrunner = %{version}
+Provides: libproxy-mozjs = %{version}
+Obsoletes: libproxy-mozjs < %{version}
+Provides: libproxy0-mozjs = %{version}
+Obsoletes: libproxy0-mozjs < %{version}
-%description -n libproxy1-pacrunner-mozjs
+%description -n libproxy0-pacrunner-mozjs
A module to extend libproxy with capabilities to pass addresses to a
WPAD/PAC script and have it find the correct proxy.
-%package -n libproxy1-pacrunner-webkit
-License: GPLv2+ ; LGPLv2.1+
+%package -n libproxy0-pacrunner-webkit
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: Libproxy module to support WPAD/PAC parsing via WebKit JavaScript Engine
Group: System/Libraries
-Requires: libproxy1 = %{version}
-Supplements: packageand(libproxy1:libwebkit-1)
-# A virtual symbol to identify that this is a pacrunner.
-Provides: libproxy1-pacrunner = %{version}
-
-%description -n libproxy1-pacrunner-webkit
+Requires: libproxy0 = %{version}
+Supplements: packageand(libproxy0:libwebkit-1)
+Provides: libproxy0-pacrunner = %{version}
+Provides: libproxy-webkit = %{version}
+Obsoletes: libproxy-webkit < %{version}
+Provides: libproxy0-webkit = %{version}
+Obsoletes: libproxy0-webkit < %{version}
+
+%description -n libproxy0-pacrunner-webkit
A module to extend libproxy with capabilities to pass addresses to a
WPAD/PAC script and have it find the correct proxy.
-%package -n libproxy1-networkmanager
-License: GPLv2+ ; LGPLv2.1+
+%package -n libproxy0-networkmanager
+License: GPL v2 or later ; LGPL v2.1 or later
Summary: Libproxy module for NetworkManager configuration
Group: System/Libraries
-Requires: libproxy1 = %{version}
-Supplements: packageand(libproxy1:NetworkManager)
+Requires: libproxy0 = %{version}
+Supplements: packageand(libproxy0:NetworkManager)
+Provides: libproxy-networkmanager = %{version}
+Obsoletes: libproxy-networkmanager < %{version}
-%description -n libproxy1-networkmanager
+%description -n libproxy0-networkmanager
A module to extend libproxy with capabilities to query NetworkManager
about network configuration changes.
+
+%package -n libproxy0-config-wpad
+License: GPL v2 or later ; LGPL v2.1 or later
+Summary: Libproxy module for WPAD autofallback
+Group: System/Libraries
+Requires: libproxy0 = %{version}
+Requires: libproxy0-wpad-dns = %{version}
+
+%description -n libproxy0-config-wpad
+A module to extend libproxy with capabilities to query wpad://
+in case no other module returns valid configuration.
+
+This might not be wanted in tight security environments.
+
+
+%package -n libproxy0-wpad-dns
+License: GPL v2 or later ; LGPL v2.1 or later
+Summary: Libproxy module for WPAD Autofallback
+Group: System/Libraries
+Requires: libproxy0 = %{version}
+Requires: libproxy0-pacrunner = %{version}
+Recommends: libproxy-wpad-dns-devolution = %{version}
+
+%description -n libproxy0-wpad-dns
+This modules performs the DNS queries needed to find
+the wpad:// configuration.
+
+The module is needed to exist whenever automatic proxy
+configuration is used.
+
+
+%package -n libproxy0-wpad-dns-devolution
+License: GPL v2 or later ; LGPL v2.1 or later
+Summary: Libproxy module for WPAD Autofallback
+Group: System/Libraries
+Requires: libproxy0 = %{version}
+Requires: libproxy0-pacrunner = %{version}
+Requires: libproxy0-wpad-dns = %{version}
+
+%description -n libproxy0-wpad-dns-devolution
+A module to extend wpad:// capabilities of libproxy with DNS
+devolution. The module is written with care and it will never
+fall back to the .TLD domains.
+
+
%endif
%prep
%setup -q -n %{_name}-%{version}
-mkdir build
%build
-cd build
-cmake \
- -DCMAKE_INSTALL_PREFIX=%{_prefix} \
- -Dlibdir=%{_libdir} \
- -Dlibexecdir=%{_libexecdir}/libproxy \
- -Ddatadir=%{_datadir} \
- -Dmoduledir=%{_libdir}/libproxy/%{version}/modules \
- -DWITH_VALA=yes \
- -DPERL_VENDORINSTALL=yes \
-..
-%{__make} %{?jobs:-j%jobs} VERBOSE=1
+%configure \
+%if %build_core_not_modules
+ --without-wpad \
+%endif
+ --with-python \
+ --disable-static
+%{__make} %{?jobs:-j%jobs}
%install
-cd build
-%makeinstall
%if %build_core_not_modules
-# Build the basic directory structure for the modules so we can
-# own the directories in the main library package
-install -d %{buildroot}%{_libexecdir}/libproxy
-install -d %{buildroot}%{_libdir}/%{name}/%{version}/modules
+%makeinstall
+rm %{buildroot}%{_libdir}/*.la
%else
+cd src/lib
+%makeinstall
+cd ../modules
+%makeinstall
# remove files that are part of the core
rm %{buildroot}%{_includedir}/*.h
-# Delete all files that exist in the base libproxy package
-rm %{buildroot}%{_bindir}/proxy
-rm %{buildroot}%{_libdir}/libproxy.so*
-rm %{buildroot}%{_libdir}/libmodman.so*
-rm %{buildroot}%{python_sitelib}/*.py
-rm %{buildroot}%{_libdir}/pkgconfig/libproxy-1.0.pc
-rm %{buildroot}%{_datadir}/cmake/Modules/Findlibproxy.cmake
-rm %{buildroot}%{_datadir}/vala/vapi/libproxy-1.0.vapi
-rm %{buildroot}%{perl_vendorarch}/Net/Libproxy.pm
-rm %{buildroot}%{perl_vendorarch}/auto/Net/Libproxy/Libproxy.so
+rm %{buildroot}%{_libdir}/libproxy.*
+rm %{buildroot}%{_libdir}/libproxy/%{version}/modules/config_envvar.so
+rm %{buildroot}%{_libdir}/libproxy/%{version}/modules/config_file.so
+rm %{buildroot}%{_libdir}/libproxy/%{version}/modules/config_direct.so
+rm %{buildroot}%{_libdir}/libproxy/%{version}/modules/ignore_*.so
%endif
%if %build_core_not_modules
-%post -n libproxy1 -p /sbin/ldconfig
-
-%post -n libmodman0_0_0 -p /sbin/ldconfig
+%post -n libproxy0 -p /sbin/ldconfig
-%postun -n libproxy1 -p /sbin/ldconfig
-
-%postun -n libmodman0_0_0 -p /sbin/ldconfig
+%postun -n libproxy0 -p /sbin/ldconfig
%files tools
%defattr(-, root, root)
%{_bindir}/proxy
-%files -n libproxy1
+%files -n libproxy0
%defattr(-, root, root)
-%{_libdir}/libproxy.so.*
-%dir %{_libexecdir}/libproxy
+%{_libdir}/*.so.*
%dir %{_libdir}/libproxy
%dir %{_libdir}/libproxy/%{version}
%dir %{_libdir}/libproxy/%{version}/modules
-#%{_libdir}/libproxy/%{version}/modules/config_envvar.so
-#%{_libdir}/libproxy/%{version}/modules/config_file.so
-#%{_libdir}/libproxy/%{version}/modules/config_direct.so
-#%{_libdir}/libproxy/%{version}/modules/ignore_*.so
-
-%files -n libmodman0_0_0
-%defattr(-, root, root)
-%{_libdir}/libmodman.so.*
+%{_libdir}/libproxy/%{version}/modules/config_envvar.so
+%{_libdir}/libproxy/%{version}/modules/config_file.so
+%{_libdir}/libproxy/%{version}/modules/config_direct.so
+%{_libdir}/libproxy/%{version}/modules/ignore_*.so
%files devel
%defattr(-, root, root)
%{_includedir}/*.h
%{_libdir}/*.so
-%{_libdir}/pkgconfig/libproxy-1.0.pc
-%{_datadir}/cmake/Modules/Findlibproxy.cmake
-%dir %{_datadir}/vala
-%dir %{_datadir}/vala/vapi
-%{_datadir}/vala/vapi/libproxy-1.0.vapi
+%{_libdir}/pkgconfig/*.pc
%files -n python-libproxy
%defattr(-, root, root)
%{python_sitelib}/*.py
-
-%files -n perl-Net-Libproxy
-%defattr(-,root,root)
-%dir %{perl_vendorarch}/Net
-%dir %{perl_vendorarch}/auto/Net
-%dir %{perl_vendorarch}/auto/Net/Libproxy
-%{perl_vendorarch}/Net/Libproxy.pm
-%{perl_vendorarch}/auto/Net/Libproxy/Libproxy.so
%else
-%files -n libproxy1-config-kde4
+%files -n libproxy0-config-kde
%defattr(-, root, root)
-%{_libdir}/libproxy/%{version}/modules/config_kde4.so
+%{_libdir}/libproxy/%{version}/modules/config_kde.so
-%files -n libproxy1-config-gnome
+%files -n libproxy0-config-gnome
%defattr(-, root, root)
%{_libdir}/libproxy/%{version}/modules/config_gnome.so
-%{_libexecdir}/libproxy/pxgconf
-%files -n libproxy1-networkmanager
+%files -n libproxy0-config-wpad
+%defattr(-, root, root)
+%{_libdir}/libproxy/%{version}/modules/config_wpad.so
+
+%files -n libproxy0-wpad-dns
+%defattr(-, root, root)
+%{_libdir}/libproxy/%{version}/modules/wpad_dns.so
+
+%files -n libproxy0-wpad-dns-devolution
+%defattr(-, root, root)
+%{_libdir}/libproxy/%{version}/modules/wpad_dnsdevolution.so
+
+%files -n libproxy0-networkmanager
%defattr(-, root, root)
%{_libdir}/libproxy/%{version}/modules/network_networkmanager.so
-%files -n libproxy1-pacrunner-webkit
+%files -n libproxy0-pacrunner-webkit
%defattr(-, root, root)
%{_libdir}/libproxy/%{version}/modules/pacrunner_webkit.so
-%files -n libproxy1-pacrunner-mozjs
+%files -n libproxy0-pacrunner-mozjs
%defattr(-, root, root)
%{_libdir}/libproxy/%{version}/modules/pacrunner_mozjs.so
%endif
diff --git a/libproxy/CMakeLists.txt b/libproxy/CMakeLists.txt
index 6c2a0d8..6439b2f 100644
--- a/libproxy/CMakeLists.txt
+++ b/libproxy/CMakeLists.txt
@@ -15,7 +15,7 @@ function(px_module name build builtin)
add_library(${name} MODULE modules/${name}.cpp)
target_link_libraries(${name} libproxy)
set_target_properties(${name} PROPERTIES PREFIX "")
- install(TARGETS ${name} LIBRARY DESTINATION ${moduledir})
+ install(TARGETS ${name} LIBRARY DESTINATION ${rmoduledir})
if(${ARGC} GREATER 3)
target_link_libraries(${name} ${ARGN})
endif()
@@ -28,10 +28,59 @@ endfunction(px_module)
## Dependency detection
#
+find_package(PkgConfig)
+if("${PKG_CONFIG_FOUND}")
+ # Define our magical px_check_modules function
+ function(px_check_modules name)
+ pkg_check_modules(${name} ${ARGN})
+ if(${${name}_FOUND})
+ include_directories(${${name}_INCLUDE_DIRS})
+ link_directories(${${name}_LIBRARY_DIRS})
+ else()
+ set(${name}_FOUND 0 PARENT_SCOPE)
+ endif()
+ endfunction(px_check_modules)
+
+ px_check_modules(X11 x11 xmu)
+ px_check_modules(NM NetworkManager dbus-1)
+ px_check_modules(WEBKIT webkit-1.0)
+ px_check_modules(MOZJS xulrunner-js)
+ if(NOT MOZJS_FOUND)
+ unset(MOZJS_FOUND)
+ px_check_modules(MOZJS firefox-js)
+ if(NOT MOZJS_FOUND)
+ unset(MOZJS_FOUND)
+ px_check_modules(MOZJS mozilla-js)
+ if(NOT MOZJS_FOUND)
+ unset(MOZJS_FOUND)
+ px_check_modules(MOZJS seamonkey-js)
+ endif()
+ endif()
+ endif()
+ if(X11_FOUND)
+ px_check_modules(GNOME gconf-2.0)
+ find_package(KDE4)
+ find_package(Qt4)
+ if(KDE4_FOUND AND QT4_FOUND)
+ set(KDE4_FOUND 1)
+ set(KDE4_LIBRARIES ${KDE4_KDECORE_LIBS} ${QT_LIBRARIES})
+ include_directories(${KDE4_INCLUDE_DIR} ${QT_INCLUDES})
+ link_directories(${KDE4_LIB_DIR})
+ string(REGEX REPLACE " *-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+ else()
+ set(KDE4_FOUND 0)
+ endif()
+ endif()
+endif()
+
+if(UNIX AND NOT APPLE)
+ set(ENVVAR_FOUND 1)
+endif()
+
if(WIN32)
# Make the relevant variables show up in the UI
- set(MOZJS_INCLUDE_DIR "MOZJS_INCLUDE_DIR-NOTFOUND" CACHE PATH "Path to the MOZJS include directory")
- set(WEBKIT_INCLUDE_DIR "WEBKIT_INCLUDE_DIR-NOTFOUND" CACHE PATH "Path to the WEBKIT include directory")
+ set(MOZJS_INCLUDE_DIR "MOZJS_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Path to the MOZJS include files")
+ set(WEBKIT_INCLUDE_DIR "WEBKIT_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Path to the WEBKIT include files")
set(MOZJS_LIBRARIES "MOZJS_LIBRARIES-NOTFOUND" CACHE FILEPATH "Path to the MOZJS .lib file")
set(WEBKIT_LIBRARIES "WEBKIT_LIBRARIES-NOTFOUND" CACHE FILEPATH "Path to the WEBKIT .lib file")
@@ -45,8 +94,9 @@ if(WIN32)
link_directories(WEBKIT_LIBRARIES)
include_directories("${WEBKIT_INCLUDE_DIR}")
endif()
+endif()
-elseif(APPLE)
+if(APPLE)
find_library(WEBKIT_LIBRARIES JavaScriptCore)
find_library(SC_LIBRARIES SystemConfiguration)
find_library(CF_LIBRARIES CoreFoundation)
@@ -59,57 +109,6 @@ elseif(APPLE)
if(CF_LIBRARIES)
set(CF_FOUND 1)
endif()
-
-else()
- set(ENVVAR_FOUND 1)
-
- find_package(PkgConfig)
- if(PKG_CONFIG_FOUND)
- # Define our magical px_check_modules function
- function(px_check_modules name)
- option(WITH_${name} "Search for ${name} package" ON)
- if (WITH_${name})
- pkg_check_modules(${name} ${ARGN})
- if(${${name}_FOUND})
- include_directories(${${name}_INCLUDE_DIRS})
- link_directories(${${name}_LIBRARY_DIRS})
- else()
- set(${name}_FOUND 0 PARENT_SCOPE)
- endif()
- else()
- set(${name}_FOUND 0 PARENT_SCOPE)
- endif()
- endfunction(px_check_modules)
-
- px_check_modules(NM NetworkManager dbus-1)
- px_check_modules(WEBKIT webkit-1.0)
-
- set(MOZJS_SEARCH_ORDER "xulrunner-js;firefox-js;mozilla-js;seamonkey-js" CACHE STRING "MozJS search order")
- foreach(mozjspc ${MOZJS_SEARCH_ORDER})
- px_check_modules(MOZJS ${mozjspc})
- if(MOZJS_FOUND)
- break()
- endif()
- unset(MOZJS_FOUND)
- endforeach()
-
- px_check_modules(GNOME gconf-2.0 gobject-2.0)
-
- option(WITH_KDE4 "Search for KDE4 package" ON)
- if (WITH_KDE4)
- find_package(KDE4)
- find_package(Qt4)
- if(KDE4_FOUND AND QT4_FOUND)
- set(KDE4_FOUND 1)
- set(KDE4_LIBRARIES ${KDE4_KDECORE_LIBS} ${QT_LIBRARIES})
- include_directories(${KDE4_INCLUDE_DIR} ${QT_INCLUDES})
- link_directories(${KDE4_LIB_DIR})
- string(REGEX REPLACE " *-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
- else()
- set(KDE4_FOUND 0)
- endif()
- endif()
- endif()
endif()
# Build the pacrunner into libproxy unless we are building for multiple engines
@@ -138,22 +137,16 @@ message("")
### Misc files
# PkgConfig file
-if(NOT WIN32 AND NOT APPLE)
- configure_file(${CMAKE_SOURCE_DIR}/libproxy/libproxy-1.0.pc.in ${CMAKE_BINARY_DIR}/libproxy-1.0.pc @ONLY)
- install(FILES ${CMAKE_BINARY_DIR}/libproxy-1.0.pc DESTINATION ${libdir}/pkgconfig)
-endif()
-
-# CMake Find helper
-if (NOT WIN32 AND NOT APPLE)
- configure_file(${CMAKE_SOURCE_DIR}/libproxy/Findlibproxy.cmake.in ${CMAKE_BINARY_DIR}/Findlibproxy.cmake @ONLY)
- install(FILES ${CMAKE_BINARY_DIR}/Findlibproxy.cmake DESTINATION ${datadir}/cmake/Modules)
+if(NOT ${WIN32})
+ configure_file(libproxy-1.0.pc.in libproxy-1.0.pc @ONLY)
+ install(FILES libproxy-1.0.pc DESTINATION ${libdir}/pkgconfig)
endif()
# GNOME (gconf) helper
if(${GNOME_FOUND})
add_executable(pxgconf modules/pxgconf.cpp)
target_link_libraries(pxgconf ${GNOME_LIBRARIES})
- install(TARGETS pxgconf RUNTIME DESTINATION ${libexecdir})
+ install(TARGETS pxgconf RUNTIME DESTINATION ${rlibexecdir})
endif()
### Main library
@@ -171,5 +164,5 @@ endif()
set_property(SOURCE proxy.cpp PROPERTY COMPILE_DEFINITIONS MODULEDIR="${moduledir}";BUILTIN_MODULES=${BUILTIN_MODULES})
set_target_properties(libproxy PROPERTIES PREFIX "" VERSION 1.0.0 SOVERSION 1)
-install(TARGETS libproxy DESTINATION ${libdir})
-install(FILES proxy.h DESTINATION ${includedir})
+install(TARGETS libproxy DESTINATION ${rlibdir})
+install(FILES proxy.h DESTINATION ${rincludedir})
diff --git a/libproxy/Findlibproxy.cmake.in b/libproxy/Findlibproxy.cmake.in
deleted file mode 100644
index 4f13e4d..0000000
--- a/libproxy/Findlibproxy.cmake.in
+++ /dev/null
@@ -1,20 +0,0 @@
-# - Try to find libproxy
-# Once done this will define
-#
-# LIBPROXY_FOUND - system has libproxy
-# LIBPROXY_INCLUDE_DIR - the libproxy include directory
-# LIBPROXY_LIBRARIES - libproxy library
-#
-# Copyright (c) 2010, Dominique Leuenberger
-#
-# Redistribution and use is allowed according the license terms
-# of libproxy, which this file is integrated part of.
-
-# Find proxy.h and the corresponding library (libproxy.so)
-FIND_PATH(LIBPROXY_INCLUDE_DIR proxy.h )
-FIND_LIBRARY(LIBPROXY_LIBRARIES NAMES proxy )
-
-# Give output, should this be wished (this handles also QUIET and REQUIRED
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(libproxy DEFAULT_MSG LIBPROXY_LIBRARIES LIBPROXY_INCLUDE_DIR)
-
diff --git a/libproxy/extension_network.hpp b/libproxy/extension_network.hpp
index 1a8fc46..e2f1e73 100644
--- a/libproxy/extension_network.hpp
+++ b/libproxy/extension_network.hpp
@@ -21,13 +21,12 @@
#define EXTENSION_NETWORK_HPP_
#include <libmodman/module.hpp>
-#include "config.hpp"
namespace libproxy {
using namespace libmodman;
// Network module
-class DLL_PUBLIC network_extension : public extension<network_extension> {
+class network_extension : public extension<network_extension> {
public:
virtual bool changed()=0;
};
diff --git a/libproxy/libproxy-1.0.pc.in b/libproxy/libproxy-1.0.pc.in
index a1924fa..8772712 100644
--- a/libproxy/libproxy-1.0.pc.in
+++ b/libproxy/libproxy-1.0.pc.in
@@ -2,8 +2,8 @@ prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
-Name: libproxy-1.0
+Name: libproxy
Description: Proxy Configuration Library
-Version: @CMAKE_PROJECT_VERSION@
+Version: @VERSION@
Libs: -L${libdir} -lproxy
Cflags: -I${includedir}
diff --git a/libproxy/modules/config_gnome.cpp b/libproxy/modules/config_gnome.cpp
index f31aa8b..7490e92 100644
--- a/libproxy/modules/config_gnome.cpp
+++ b/libproxy/modules/config_gnome.cpp
@@ -23,44 +23,23 @@
#include <errno.h> // For errno stuff
#include <unistd.h> // For pipe(), close(), vfork(), dup(), execl(), _exit()
#include <signal.h> // For kill()
+#include "xhasclient.cpp" // For xhasclient()
#include "../extension_config.hpp"
using namespace libproxy;
#define BUFFERSIZE 10240
-#define PROXY_MODE "/system/proxy/mode"
-#define PROXY_USE_AUTHENTICATION "/system/http_proxy/use_authentication"
-#define PROXY_AUTH_PASSWORD "/system/http_proxy/authentication_password"
-#define PROXY_AUTH_USER "/system/http_proxy/authentication_user"
-#define PROXY_AUTOCONFIG_URL "/system/proxy/autoconfig_url"
-#define PROXY_IGNORE_HOSTS "/system/http_proxy/ignore_hosts"
-#define PROXY_HTTP_HOST "/system/http_proxy/host"
-#define PROXY_HTTP_PORT "/system/http_proxy/port"
-#define PROXY_FTP_HOST "/system/proxy/ftp_host"
-#define PROXY_FTP_PORT "/system/proxy/ftp_port"
-#define PROXY_SECURE_HOST "/system/proxy/secure_host"
-#define PROXY_SECURE_PORT "/system/proxy/secure_port"
-#define PROXY_SOCKS_HOST "/system/proxy/socks_host"
-#define PROXY_SOCKS_PORT "/system/proxy/socks_port"
-#define PROXY_SAME_FOR_ALL "/system/http_proxy/use_same_proxy"
-
static const char *all_keys[] = {
- PROXY_MODE,
- PROXY_USE_AUTHENTICATION,
- PROXY_AUTH_PASSWORD,
- PROXY_AUTH_USER,
- PROXY_AUTOCONFIG_URL,
- PROXY_IGNORE_HOSTS,
- PROXY_HTTP_HOST,
- PROXY_HTTP_PORT,
- PROXY_FTP_HOST,
- PROXY_FTP_PORT,
- PROXY_SECURE_HOST,
- PROXY_SECURE_PORT,
- PROXY_SOCKS_HOST,
- PROXY_SOCKS_PORT,
- PROXY_SAME_FOR_ALL,
+ "/system/proxy/mode", "/system/proxy/autoconfig_url",
+ "/system/http_proxy/host", "/system/http_proxy/port",
+ "/system/proxy/secure_host", "/system/proxy/secure_port",
+ "/system/proxy/ftp_host", "/system/proxy/ftp_port",
+ "/system/proxy/socks_host", "/system/proxy/socks_port",
+ "/system/http_proxy/ignore_hosts",
+ "/system/http_proxy/use_authentication",
+ "/system/http_proxy/authentication_user",
+ "/system/http_proxy/authentication_password",
NULL
};
@@ -94,10 +73,8 @@ static int popen2(const char *program, FILE** read, FILE** write, pid_t* pid) {
close(STDIN_FILENO); // Close stdin
close(STDOUT_FILENO); // Close stdout
- // Dup the read end of the write pipe to stdin
- // Dup the write end of the read pipe to stdout
- if (dup2(wpipe[0], STDIN_FILENO) != STDIN_FILENO) _exit(1);
- if (dup2(rpipe[1], STDOUT_FILENO) != STDOUT_FILENO) _exit(2);
+ dup(wpipe[0]); // Dup the read end of the write pipe to stdin
+ dup(rpipe[1]); // Dup the write end of the read pipe to stdout
// Close unneeded fds
close(rpipe[0]);
@@ -123,48 +100,29 @@ static int popen2(const char *program, FILE** read, FILE** write, pid_t* pid) {
}
}
-static inline uint16_t get_port(string &port)
-{
- uint16_t retval;
-
- if (sscanf(port.c_str(), "%hu", &retval) != 1)
- retval = 0;
-
- return retval;
-}
-
class gnome_config_extension : public config_extension {
public:
gnome_config_extension() {
// Build the command
int count;
- struct stat st;
- string cmd = LIBEXECDIR "/pxgconf";
- const char *pxgconf = getenv("PX_GCONF");
-
- if (pxgconf)
- cmd = string (pxgconf);
-
- if (stat(cmd.c_str(), &st))
- throw runtime_error ("Unable to open gconf helper!");
-
+ string cmd = LIBEXECDIR "pxgconf";
for (count=0 ; all_keys[count] ; count++)
cmd += string(" ", 1) + all_keys[count];
// Get our pipes
if (popen2(cmd.c_str(), &this->read, &this->write, &this->pid) != 0)
- throw runtime_error("Unable to run gconf helper!");
-
- // Read in our initial data
- this->read_data(count);
+ throw runtime_error("Unable to open gconf helper!");
// Set the read pipe to non-blocking
- if (fcntl(fileno(this->read), F_SETFL, O_NONBLOCK) == -1) {
+ if (fcntl(fileno(this->read), F_SETFL, FNONBLOCK) == -1) {
fclose(this->read);
fclose(this->write);
kill(this->pid, SIGTERM);
throw runtime_error("Unable to set pipe to non-blocking!");
}
+
+ // Read in the first print-out of all our keys
+ this->update_data(count);
}
~gnome_config_extension() {
@@ -175,69 +133,50 @@ public:
url get_config(url dest) throw (runtime_error) {
// Check for changes in the config
- fd_set rfds;
- struct timeval timeout = { 0, 0 };
- FD_ZERO(&rfds);
- FD_SET(fileno(this->read), &rfds);
- if (select(fileno(this->read)+1, &rfds, NULL, NULL, &timeout) > 0)
- this->read_data();
+ this->update_data();
// Mode is wpad:// or pac+http://...
- if (this->data[PROXY_MODE] == "auto") {
- string pac = this->data[PROXY_AUTOCONFIG_URL];
+ if (this->data["/system/proxy/mode"] == "auto") {
+ string pac = this->data["/system/proxy/autoconfig_url"];
return url::is_valid(pac) ? url(string("pac+") + pac) : url("wpad://");
}
// Mode is http://... or socks://...
- else if (this->data[PROXY_MODE] == "manual") {
- string type, host, port;
- bool auth = this->data[PROXY_USE_AUTHENTICATION] == "true";
- string username = this->data[PROXY_AUTH_USER];
- string password = this->data[PROXY_AUTH_PASSWORD];
- bool same_proxy = this->data[PROXY_SAME_FOR_ALL] == "true";
-
- // If socks is set use it (except when same_proxy is set)
- if (!same_proxy) {
- type = "socks";
- host = this->data[PROXY_SOCKS_HOST];
- port = this->data[PROXY_SOCKS_PORT];
+ else if (this->data["/system/proxy/mode"] == "manual") {
+ string type = "http", host, port;
+ bool auth = this->data["/system/http_proxy/use_authentication"] == "true";
+ string username = this->data["/system/http_proxy/authentication_user"];
+ string password = this->data["/system/http_proxy/authentication_password"];
+ uint16_t p = 0;
+
+ // Get the per-scheme proxy settings
+ if (dest.get_scheme() == "https") {
+ host = this->data["/system/proxy/secure_host"];
+ port = this->data["/system/proxy/secure_port"];
+ if (sscanf(port.c_str(), "%hu", &p) != 1) p = 0;
}
-
- if (host == "" || get_port(port) == 0) {
- // Get the per-scheme proxy settings
- if (dest.get_scheme() == "http") {
- type = "http";
- host = this->data[PROXY_HTTP_HOST];
- port = this->data[PROXY_HTTP_PORT];
- }
- else if (dest.get_scheme() == "https") {
- // It is expected that the configured server is an
- // HTTP server that support CONNECT method.
- type = "http";
- host = this->data[PROXY_SECURE_HOST];
- port = this->data[PROXY_SECURE_PORT];
- }
- else if (dest.get_scheme() == "ftp") {
- // It is expected that the configured server is an
- // HTTP server that handles proxying FTP URLs
- // (e.g. request with header "Host: ftp://ftp.host.org")
- type = "http";
- host = this->data[PROXY_FTP_HOST];
- port = this->data[PROXY_FTP_PORT];
- }
-
- // If no proxy is set and we have the same_proxy option
- // enabled try socks at the end only.
- if (same_proxy && (host == "" || get_port(port) == 0)) {
- type = "socks";
- host = this->data[PROXY_SOCKS_HOST];
- port = this->data[PROXY_SOCKS_PORT];
- }
+ else if (dest.get_scheme() == "ftp") {
+ host = this->data["/system/proxy/ftp_host"];
+ port = this->data["/system/proxy/ftp_port"];
+ if (sscanf(port.c_str(), "%hu", &p) != 1) p = 0;
+ }
+ if (host == "" || p == 0)
+ {
+ host = this->data["/system/http_proxy/host"];
+ port = this->data["/system/http_proxy/port"];
+ if (sscanf(port.c_str(), "%hu", &p) != 1) p = 0;
}
+ // If http(s)/ftp proxy is not set, try socks
+ if (host == "" || p == 0)
+ {
+ host = this->data["/system/proxy/socks_host"];
+ port = this->data["/system/proxy/socks_port"];
+ if (sscanf(port.c_str(), "%hu", &p) != 1) p = 0;
+ }
// If host and port were found, build config url
- if (host != "" && get_port(port) != 0) {
+ if (host != "" && p != 0) {
string tmp = type + "://";
if (auth)
tmp += username + ":" + password + "@";
@@ -251,13 +190,13 @@ public:
}
string get_ignore(url) {
- return this->data[PROXY_IGNORE_HOSTS];
+ return this->data["/system/http_proxy/ignore_hosts"];
}
bool set_creds(url /*proxy*/, string username, string password) {
- string auth = PROXY_USE_AUTHENTICATION "\ttrue\n";
- string user = string(PROXY_AUTH_USER "\t") + username + "\n";
- string pass = string(PROXY_AUTH_PASSWORD "\t") + password + "\n";
+ string auth = "/system/http_proxy/use_authentication\ttrue\n";
+ string user = string("/system/http_proxy/authentication_user\t") + username + "\n";
+ string pass = string("/system/http_proxy/authentication_password\t") + password + "\n";
return (fwrite(auth.c_str(), 1, auth.size(), this->write) == auth.size() &&
fwrite(user.c_str(), 1, user.size(), this->write) == user.size() &&
@@ -270,20 +209,40 @@ private:
pid_t pid;
map<string, string> data;
- bool read_data(int num=-1) {
- if (num == 0) return true;
- if (!this->read) return false; // We need the pipe to be open
+ // This method attempts to update data
+ // If called with no arguments, it will check for new data (sleeping for <=10
+ // useconds) and returning true or false depending on if at least one line of
+ // data was found.
+ // However, if req > 0, we will keep checking for new lines (at 10 usec ivals)
+ // until enough lines are found. This allows us to wait for *all* the initial
+ // values to be read in before we start processing gconf requests.
+ bool update_data(int req=0, int found=0) {
+ // If we have collected the correct number of lines, return true
+ if (req > 0 && found >= req)
+ return true;
+
+ // We need the pipe to be open
+ if (!this->read) return false;
+
+ fd_set rfds;
+ struct timeval timeout = { 0, 10 }; // select() for 1/1000th of a second
+ FD_ZERO(&rfds);
+ FD_SET(fileno(this->read), &rfds);
+ if (select(fileno(this->read)+1, &rfds, NULL, NULL, &timeout) < 1)
+ return req > 0 ? this->update_data(req, found) : false; // If we still haven't met
+ // our req quota, try again
- for (char l[BUFFERSIZE] ; num != 0 && fgets(l, BUFFERSIZE, this->read) != NULL ; ) {
+ bool retval = false;
+ for (char l[BUFFERSIZE] ; fgets(l, BUFFERSIZE, this->read) != NULL ; ) {
string line = l;
line = line.substr(0, line.rfind('\n'));
string key = line.substr(0, line.find("\t"));
string val = line.substr(line.find("\t")+1);
this->data[key] = val;
- if (num > 0) num--;
+ retval = ++found >= req;
}
- return (num <= 0);
+ return (this->update_data(req, found) || retval);
}
};
@@ -301,9 +260,4 @@ static base_extension** gnome_config_extension_init() {
}
MM_MODULE_INIT(gnome_config_extension, gnome_config_extension_init);
-MM_MODULE_TEST_EZ(gnome_config_extension,
- (
- getenv("GNOME_DESKTOP_SESSION_ID") ||
- (getenv("DESKTOP_SESSION") && string(getenv("DESKTOP_SESSION")) == "gnome")
- )
- );
+MM_MODULE_TEST_EZ(gnome_config_extension, xhasclient("gnome-session", "gnome-settings-daemon", "gnome-panel", NULL));
diff --git a/libproxy/modules/config_kde4.cpp b/libproxy/modules/config_kde4.cpp
index 94fda99..91325a0 100644
--- a/libproxy/modules/config_kde4.cpp
+++ b/libproxy/modules/config_kde4.cpp
@@ -20,6 +20,7 @@
#include <KDE/KConfig>
#include <KDE/KConfigGroup>
#include <KDE/KGlobal>
+#include "xhasclient.cpp" // For xhasclient(...)
#include "../extension_config.hpp"
using namespace libproxy;
@@ -99,4 +100,4 @@ private:
};
MM_MODULE_INIT_EZ(kde_config_extension);
-MM_MODULE_TEST_EZ(kde_config_extension, getenv("KDE_FULL_SESSION"));
+MM_MODULE_TEST_EZ(kde_config_extension, xhasclient("kicker", "klipper", "kwin", "plasma-desktop", NULL));
diff --git a/libproxy/modules/config_macosx.cpp b/libproxy/modules/config_macosx.cpp
index c8cec85..4a837ed 100644
--- a/libproxy/modules/config_macosx.cpp
+++ b/libproxy/modules/config_macosx.cpp
@@ -84,10 +84,12 @@ static bool protocol_url(CFDictionaryRef settings, string protocol, string& conf
return false;
stringstream ss;
- if (protocol == "HTTP" || protocol == "HTTPS" || protocol == "FTP" || protocol == "Gopher")
+ if (protocol == "HTTP" || protocol == "HTTPS" || protocol == "FTP")
ss << "http://";
+ else if (protocol == "Gopher")
+ return false; //ss << "gopher://"; // Is this correct?
else if (protocol == "RTSP")
- ss << "rtsp://";
+ return false; //ss << "rtsp://"; // Is this correct?
else if (protocol == "SOCKS")
ss << "socks://";
else
diff --git a/libproxy/modules/network_networkmanager.cpp b/libproxy/modules/network_networkmanager.cpp
index 7f621f4..4304ae2 100644
--- a/libproxy/modules/network_networkmanager.cpp
+++ b/libproxy/modules/network_networkmanager.cpp
@@ -46,7 +46,7 @@ public:
{
dbus_connection_close(conn);
dbus_connection_read_write(conn, 0);
- for (DBusMessage *msg=NULL ; (msg = dbus_connection_pop_message(conn)) ; dbus_message_unref(msg)) {};
+ for (DBusMessage *msg=NULL ; (msg = dbus_connection_pop_message(conn)) ; dbus_message_unref(msg));
}
// Create a new connections
diff --git a/libproxy/modules/pacrunner_webkit.cpp b/libproxy/modules/pacrunner_webkit.cpp
index cc7e2c8..171295f 100644
--- a/libproxy/modules/pacrunner_webkit.cpp
+++ b/libproxy/modules/pacrunner_webkit.cpp
@@ -20,13 +20,7 @@
#include "../extension_pacrunner.hpp"
using namespace libproxy;
-#ifdef __APPLE__
-// JavaScriptCore.h requires CoreFoundation
-// This is only found on Mac OS X
-#include <JavaScriptCore/JavaScriptCore.h>
-#else
#include <JavaScriptCore/JavaScript.h>
-#endif
#include "pacutils.h"
#ifndef INET_ADDRSTRLEN
diff --git a/libproxy/modules/pxgconf.cpp b/libproxy/modules/pxgconf.cpp
index 4a1e17c..a252fe6 100644
--- a/libproxy/modules/pxgconf.cpp
+++ b/libproxy/modules/pxgconf.cpp
@@ -100,7 +100,7 @@ static gboolean in(GIOChannel *source, GIOCondition condition, gpointer data) {
// Remove the trailing '\n'
for (int i=0 ; key && key[i] ; i++)
if (key[i] == '\n')
- key[i] = '\0';
+ key[i] = NULL;
// If we were successful
if (key && st == G_IO_STATUS_NORMAL) {
@@ -108,7 +108,7 @@ static gboolean in(GIOChannel *source, GIOCondition condition, gpointer data) {
goto exit;
val = g_strrstr(key, "\t") + 1;
- *(val-1) = '\0';
+ *(val-1) = NULL;
if (!set_key(key, val))
goto exit;
@@ -168,16 +168,9 @@ int main(int argc, char **argv) {
// Add server notifications for all keys
for (int i=1 ; i < argc ; i++) {
- GConfValue *value;
gconf_client_add_dir(client, argv[i], GCONF_CLIENT_PRELOAD_NONE, NULL);
gconf_client_notify_add(client, argv[i], on_value_change, NULL, NULL, NULL);
- value = gconf_client_get(client, argv[i], NULL);
- if (value) {
- gconf_value_free (value);
- gconf_client_notify(client, argv[i]);
- } else {
- printf("%s\n", argv[i]);
- }
+ gconf_client_notify(client, argv[i]);
}
g_main_loop_run(loop);
diff --git a/libproxy/modules/xhasclient.cpp b/libproxy/modules/xhasclient.cpp
new file mode 100644
index 0000000..5c22d83
--- /dev/null
+++ b/libproxy/modules/xhasclient.cpp
@@ -0,0 +1,87 @@
+/*
+ *
+ *
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ * *
+ * Author: Jim Fulton, MIT X Consortium
+ */
+
+/*
+ * Concept and some basic code shamelessly stolen from xlsclients... :)
+ * Reworked by Nathaniel McCallum, 2007
+ */
+
+#include <stdarg.h>
+#include <string.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xmu/WinUtil.h>
+
+bool xhasclient(const char *prog, ...) {
+ va_list ap;
+
+ // Open display
+ Display *display = XOpenDisplay(NULL);
+ if (!display)
+ return false;
+
+ // For each screen...
+ for (int i=0; i < ScreenCount(display); i++) {
+ Window dummy, *children = NULL;
+ unsigned int nchildren = 0;
+
+ // Get the root window's children
+ if (!XQueryTree(display, RootWindow(display, i), &dummy, &dummy, &children, &nchildren))
+ continue;
+
+ // For each child on the screen...
+ for (size_t j=0; j < nchildren; j++) {
+ // If we can get their client info...
+ Window client;
+ if ((client = XmuClientWindow(display, children[j])) != None) {
+ int argc;
+ char **argv;
+
+ // ... and if we can find out their command ...
+ if (!XGetCommand (display, client, &argv, &argc) || argc == 0)
+ continue;
+
+ // ... check the commands against our list
+ va_start(ap, prog);
+ for (const char *s = prog ; s ; s = va_arg(ap, char *)) {
+ // We've found a match, return...
+ if (!strcmp(argv[0], s)) {
+ va_end(ap);
+ XCloseDisplay(display);
+ return true;
+ }
+ }
+ va_end(ap);
+ }
+ }
+ }
+
+ // Close the display
+ XCloseDisplay(display);
+ return false;
+}
diff --git a/libproxy/proxy.cpp b/libproxy/proxy.cpp
index 617c69d..5f34e98 100644
--- a/libproxy/proxy.cpp
+++ b/libproxy/proxy.cpp
@@ -31,6 +31,7 @@
#include "extension_wpad.hpp"
#ifdef WIN32
+#define setenv(name, value, overwrite) SetEnvironmentVariable(name, value)
#define strdup _strdup
#endif
@@ -83,8 +84,7 @@ format_pac_response(string response)
}
// Strip whitespace
- if (response.size() > 0)
- response = response.substr(response.find_first_not_of(" \t\n"), response.find_last_not_of(" \t\n")+1);
+ response = response.substr(response.find_first_not_of(" \t"), response.find_last_not_of(" \t")+1);
// Get the method and the server
string method = "";
@@ -101,10 +101,6 @@ format_pac_response(string response)
retval.insert(retval.begin(), string("http://") + server);
else if (istringcmp(method, "socks") && url::is_valid("http://" + server))
retval.insert(retval.begin(), string("socks://") + server);
- else if (istringcmp(method, "socks4") && url::is_valid("http://" + server))
- retval.insert(retval.begin(), string("socks4://") + server);
- else if (istringcmp(method, "socks5") && url::is_valid("http://" + server))
- retval.insert(retval.begin(), string("socks5://") + server);
else if (istringcmp(method, "direct"))
retval.insert(retval.begin(), string("direct://"));
@@ -112,8 +108,6 @@ format_pac_response(string response)
}
proxy_factory::proxy_factory() {
- const char *module_dir;
-
#ifdef WIN32
this->mutex = CreateMutex(NULL, false, NULL);
WaitForSingleObject(this->mutex, INFINITE);
@@ -140,11 +134,8 @@ proxy_factory::proxy_factory() {
this->mm.load_builtin(builtin_modules[i], "libproxy");
// Load all modules
- module_dir = getenv("PX_MODULE_PATH");
- if (!module_dir)
- module_dir = MODULEDIR;
- this->mm.load_dir(module_dir);
- this->mm.load_dir(module_dir, false);
+ this->mm.load_dir(MODULEDIR);
+ this->mm.load_dir(MODULEDIR, false);
#ifdef WIN32
ReleaseMutex(this->mutex);
@@ -214,18 +205,26 @@ vector<string> proxy_factory::get_proxies(string url_) {
config = *i;
// Try to get the confurl
- try {
- confurl = config->get_config(*realurl);
- confign = config->get_ignore(*realurl);
- config->set_valid(true);
- break;
- }
- catch (runtime_error e) {
+ try { confurl = (config)->get_config(*realurl); }
+ catch (runtime_error e) { goto invalid_config; }
+
+ // Validate the input
+ if (!(confurl.get_scheme() == "http" ||
+ confurl.get_scheme() == "socks" ||
+ confurl.get_scheme().substr(0, 4) == "pac+" ||
+ confurl.get_scheme() == "wpad" ||
+ confurl.get_scheme() == "direct"))
+ goto invalid_config;
+
+ config->set_valid(true);
+ confign = config->get_ignore(*realurl);
+ break;
+
+ invalid_config:
confurl = "direct://";
confign = "";
- config->set_valid(false);
+ (config)->set_valid(false);
config = NULL;
- }
}
if (debug) {
if (config)
@@ -239,15 +238,12 @@ vector<string> proxy_factory::get_proxies(string url_) {
ignores = this->mm.get_extensions<ignore_extension>();
invign = confign[0] == '-';
if (invign) confign = confign.substr(1);
- for (size_t i=0 ; i < confign.size() && !ignored;) {
- size_t next = confign.find(',', i);
- if (next == string::npos) next = confign.length();
- if (next > (i+1)) {
- string ignorestr = confign.substr (i, next - i);
- for (vector<ignore_extension*>::iterator it=ignores.begin() ; it != ignores.end() && !ignored ; it++)
- ignored = ((*it)->ignore(*realurl, ignorestr));
- }
- i = next+1;
+ for (size_t i=0 ; i < confign.size() && i != string::npos && !ignored; i=confign.substr(i).find(',')) {
+ while (i < confign.size() && confign[i] == ',') i++;
+
+ for (vector<ignore_extension*>::iterator it=ignores.begin() ; it != ignores.end() && !ignored ; it++)
+ if ((*it)->ignore(*realurl, confign.substr(i, confign.find(','))))
+ ignored = true;
}
if (!ignored && invign) goto do_return;
if (ignored && !invign) goto do_return;
@@ -351,8 +347,8 @@ vector<string> proxy_factory::get_proxies(string url_) {
response = format_pac_response(pacresp);
}
- /* If we have a manual config (http://..., socks://..., etc.) */
- else
+ /* If we have a manual config (http://..., socks://...) */
+ else if (confurl.get_scheme() == "http" || confurl.get_scheme() == "socks")
{
this->wpad = false;
if (this->pac) { delete this->pac; this->pac = NULL; }
@@ -392,8 +388,7 @@ extern "C" DLL_PUBLIC char** px_proxy_factory_get_proxies(struct pxProxyFactory_
// Call the main method
try {
proxies = self->pf.get_proxies(url);
- retval = (char**) malloc(sizeof(char*) * (proxies.size() + 1));
- if (!retval) return NULL;
+ retval = new char*[proxies.size()+1];
} catch (std::exception&) {
// Return NULL on any exception
return NULL;
@@ -407,7 +402,7 @@ extern "C" DLL_PUBLIC char** px_proxy_factory_get_proxies(struct pxProxyFactory_
if (retval[i] == NULL) {
for (int j=i-1 ; j >= 0 ; j--)
free(retval[j]);
- free(retval);
+ delete retval;
return NULL;
}
}
diff --git a/libproxy/proxy.h b/libproxy/proxy.h
index fb8275b..5bd299f 100644
--- a/libproxy/proxy.h
+++ b/libproxy/proxy.h
@@ -66,29 +66,14 @@ pxProxyFactory *px_proxy_factory_new(void);
* The format of the returned proxy strings are as follows:
* - http://[username:password@]proxy:port
* - socks://[username:password@]proxy:port
- * - socks5://[username:password@]proxy:port
- * - socks4://[username:password@]proxy:port
- * - <procotol>://[username:password@]proxy:port
* - direct://
* Please note that the username and password in the above URLs are optional
* and should be use to authenticate the connection if present.
*
- * For SOCKS proxies, when the protocol version is specified (socks4:// or
- * sock5://), it is expected that only this version is used. When only
- * socks:// is set, the client MUST try SOCKS version 5 protocol and, on
- * connection failure, fallback to SOCKS version 4.
- *
- * Other proxying protocols may exist. It is expected that the returned
- * configuration scheme shall match the network service name of the
- * proxy protocol or the service name of the protocol being proxied if the
- * previous does not exist. As an example, on Mac OS X you can configure a
- * RTSP streaming proxy. The expected returned configuration would be:
- * - rtsp://[username:password@]proxy:port
- *
* @url The URL we are trying to reach
* @return A NULL-terminated array of proxy strings to use
*/
-char **px_proxy_factory_get_proxies(pxProxyFactory *self, const char *url);
+char **px_proxy_factory_get_proxies(pxProxyFactory *self, char *url);
/**
* Frees the pxProxyFactory instance when no longer used.
diff --git a/libproxy/url.cpp b/libproxy/url.cpp
index 4db2e2f..b63006a 100644
--- a/libproxy/url.cpp
+++ b/libproxy/url.cpp
@@ -90,43 +90,39 @@ url::url(const string url) throw(parse_error, logic_error) {
char *host = new char[url.size()];
char *path = new char[url.size()];
bool port_specified = false;
- bool auth_specified = false;
- bool pass_specified = false;
this->ips = NULL;
// Break apart our url into 4 sections: scheme, auth (user/pass), host and path
// We'll do further parsing of auth and host a bit later
// NOTE: reset the unused variable after each scan or we get bleed-through
- if (sscanf(url.c_str(), "%[^:]://%[^@]@%[^/]/%s", schm, auth, host, path) != 4 && !((*path = '\0')) && // URL with auth, host and path
- sscanf(url.c_str(), "%[^:]://%[^@]@%[^/]", schm, auth, host) != 3 && !((*auth = '\0')) && // URL with auth, host
- sscanf(url.c_str(), "%[^:]://%[^/]/%s", schm, host, path) != 3 && !((*path = '\0')) && // URL with host, path
- sscanf(url.c_str(), "%[^:]://%[^/]", schm, host) != 2 && !((*host = '\0')) && // URL with host
- !(sscanf(url.c_str(), "%[^:]://%s", schm, path) == 2 && string("file") == schm) && !((*path = '\0')) && // URL with path (ex: file:///foo)
+ if (sscanf(url.c_str(), "%[^:]://%[^@]@%[^/]/%s", schm, auth, host, path) != 4 && !((*path = NULL)) && // URL with auth, host and path
+ sscanf(url.c_str(), "%[^:]://%[^@]@%[^/]", schm, auth, host) != 3 && !((*auth = NULL)) && // URL with auth, host
+ sscanf(url.c_str(), "%[^:]://%[^/]/%s", schm, host, path) != 3 && !((*path = NULL)) && // URL with host, path
+ sscanf(url.c_str(), "%[^:]://%[^/]", schm, host) != 2 && !((*host = NULL)) && // URL with host
+ !(sscanf(url.c_str(), "%[^:]://%s", schm, path) == 2 && string("file") == schm) && !((*path = NULL)) && // URL with path (ex: file:///foo)
!(sscanf(url.c_str(), "%[^:]://", schm) == 1 && (string("direct") == schm || string("wpad") == schm))) // URL with scheme-only (ex: wpad://, direct://)
{
- delete[] schm;
- delete[] auth;
- delete[] host;
- delete[] path;
+ delete schm;
+ delete auth;
+ delete host;
+ delete path;
throw parse_error("Invalid URL: " + url);
}
// Set scheme and path
this->scheme = schm;
this->path = *path ? string("/") + path : "";
- *schm = '\0';
- *path = '\0';
+ *schm = NULL;
+ *path = NULL;
// Parse auth further
if (*auth) {
- auth_specified = true;
this->user = auth;
if (string(auth).find(":") != string:: npos) {
- pass_specified = true;
this->pass = this->user.substr(this->user.find(":")+1);
this->user = this->user.substr(0, this->user.find(":"));
}
- *auth = '\0';
+ *auth = NULL;
}
// Parse host further. Basically, we're looking for a port.
@@ -146,21 +142,18 @@ url::url(const string url) throw(parse_error, logic_error) {
}
this->host = host;
- *host = '\0';
+ *host = NULL;
}
// Cleanup
- delete[] schm;
- delete[] auth;
- delete[] host;
- delete[] path;
+ delete schm;
+ delete auth;
+ delete host;
+ delete path;
// Verify by re-assembly
- if (auth_specified)
- if (pass_specified)
- this->orig = this->scheme + "://" + this->user + ":" + this->pass + "@" + this->host;
- else
- this->orig = this->scheme + "://" + this->user + "@" + this->host;
+ if (this->user != "" && this->pass != "")
+ this->orig = this->scheme + "://" + this->user + ":" + this->pass + "@" + this->host;
else
this->orig = this->scheme + "://" + this->host;
if (port_specified)
@@ -213,7 +206,7 @@ url& url::operator=(const url& url) {
if (url.ips) {
// Copy the new ip cache
- for (i=0 ; url.ips[i] ; i++) {};
+ for (i=0 ; url.ips[i] ; i++);
this->ips = new sockaddr*[i];
for (i=0 ; url.ips[i] ; i++)
this->ips[i] = copyaddr(*url.ips[i]);
@@ -242,7 +235,7 @@ sockaddr const* const* url::get_ips(bool usedns) {
// Check DNS for IPs
struct addrinfo* info;
struct addrinfo flags;
- memset(&flags, '\0', sizeof(addrinfo));
+ memset(&flags, NULL, sizeof(addrinfo));
flags.ai_family = AF_UNSPEC;
flags.ai_socktype = 0;
flags.ai_protocol = 0;
@@ -261,7 +254,7 @@ sockaddr const* const* url::get_ips(bool usedns) {
// Create our array since we actually have a result
this->ips = new sockaddr*[++i];
- memset(this->ips, '\0', sizeof(sockaddr*)*i);
+ memset(this->ips, NULL, sizeof(sockaddr*)*i);
// Copy the sockaddr's into this->ips
for (i = 0, info = first ; info ; info = info->ai_next) {
@@ -321,7 +314,7 @@ char* url::get_pac() {
string request;
// In case of a file:// url we open the file and read it
- if (this->scheme == "file" || this->scheme == "pac+file") {
+ if (this->scheme == "file") {
struct stat st;
if ((sock = ::open(this->path.c_str(), O_RDONLY)) < 0)
return NULL;
diff --git a/samples/perl/sample.pl b/samples/perl/sample.pl
deleted file mode 100644
index e8850fc..0000000
--- a/samples/perl/sample.pl
+++ /dev/null
@@ -1,7 +0,0 @@
-use Net::Libproxy;
-
-$p = new Net::Libproxy;
-$proxies = $p->getProxies('http://www.google.com');
-foreach my $proxy (@$proxies) {
- print $proxy."\n";
-}
diff --git a/samples/vala/sample.vala b/samples/vala/sample.vala
deleted file mode 100644
index aad265e..0000000
--- a/samples/vala/sample.vala
+++ /dev/null
@@ -1,9 +0,0 @@
-using Libproxy;
-
-void main () {
- var proxy_factory = new ProxyFactory ();
- string[] proxies = proxy_factory.get_proxies ("");
- foreach (string proxy in proxies) {
- stdout.printf ("%s\n", proxy);
- }
-}