[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] r4538: Tag the 0.2.11 release (in vidalia/tags: . vidalia-0.2.11 vidalia-0.2.11/pkg/rpm vidalia-0.2.11/src/common vidalia-0.2.11/src/miniupnpc)



Author: chiiph
Date: 2011-03-20 15:40:12 +0000 (Sun, 20 Mar 2011)
New Revision: 4538

Added:
   vidalia/tags/vidalia-0.2.11/
   vidalia/tags/vidalia-0.2.11/CMakeLists.txt
   vidalia/tags/vidalia-0.2.11/INSTALL
   vidalia/tags/vidalia-0.2.11/config.h.in
   vidalia/tags/vidalia-0.2.11/pkg/rpm/vidalia.spec.in
   vidalia/tags/vidalia-0.2.11/src/common/CMakeLists.txt
   vidalia/tags/vidalia-0.2.11/src/miniupnpc/connecthostport.c
   vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniupnpc.c
   vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniwget.c
Removed:
   vidalia/tags/vidalia-0.2.11/CMakeLists.txt
   vidalia/tags/vidalia-0.2.11/INSTALL
   vidalia/tags/vidalia-0.2.11/config.h.in
   vidalia/tags/vidalia-0.2.11/pkg/rpm/vidalia.spec.in
   vidalia/tags/vidalia-0.2.11/src/common/CMakeLists.txt
   vidalia/tags/vidalia-0.2.11/src/common/TorSslSocket.cpp
   vidalia/tags/vidalia-0.2.11/src/common/TorSslSocket.h
   vidalia/tags/vidalia-0.2.11/src/miniupnpc/connecthostport.c
   vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniupnpc.c
   vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniwget.c
Log:
Tag the 0.2.11 release

Deleted: vidalia/tags/vidalia-0.2.11/CMakeLists.txt
===================================================================
--- vidalia/trunk/CMakeLists.txt	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/CMakeLists.txt	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,144 +0,0 @@
-##
-##  $Id$
-## 
-##  This file is part of Vidalia, and is subject to the license terms in the
-##  LICENSE file, found in the top level directory of this distribution. If 
-##  you did not receive the LICENSE file with this file, you may obtain it
-##  from the Vidalia source package distributed by the Vidalia Project at
-##  http://www.vidalia-project.net/. No part of Vidalia, including this file,
-##  may be copied, modified, propagated, or distributed except according to
-##  the terms described in the LICENSE file.
-##
-
-
-set(VER_MAJOR   "0")
-set(VER_MINOR   "2")
-set(VER_PATCH   "11")
-set(VERSION     "${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}-svn")
-message(STATUS  "Configuring Vidalia ${VERSION}")
-project(Vidalia)
-
-## Specify the minimim required CMake version
-cmake_minimum_required(VERSION 2.4.7)
-if (COMMAND cmake_policy)
-  # Force CMake 2.4 compatibility for handling linker search paths
-  cmake_policy(SET CMP0003 OLD)
-endif(COMMAND cmake_policy)
-
-## We declare this option here, because it determines the minimum
-## required Qt version
-option(USE_MARBLE "Enable the KDE Marble-based map widget." OFF)
-
-## Specify the minimum version of Qt required
-set(QT_MIN_VERSION    "4.3.0")
-
-## Specify the Qt libraries used
-include(FindQt4)
-find_package(Qt4 REQUIRED)
-set(QT_USE_QTNETWORK  true)
-set(QT_USE_QTXML      true)
-if (USE_MARBLE)
-  set(QT_USE_QTSVG    true)
-  set(QT_USE_QTWEBKIT true)
-  set(QT_USE_QTSCRIPT true)
-  set(QT_USE_QTDBUS   true)
-endif(USE_MARBLE)
-include(${QT_USE_FILE})
-include(${CMAKE_SOURCE_DIR}/cmake/VidaliaMacros.cmake)
-include(CheckIncludeFile)
-include(CheckIncludeFileCXX)
-include(CheckTypeSize)
-include(CheckFunctionExists)
-if (WIN32)
-  include(${CMAKE_SOURCE_DIR}/cmake/FindWiX.cmake)
-endif(WIN32)
-if (MSVC OR UNIX)
-  include(${CMAKE_SOURCE_DIR}/cmake/FindOpenSSL.cmake)
-endif(MSVC OR UNIX)
-
-if(MSVC_IDE)
-    set(CMAKE_SUPPRESS_REGENERATION TRUE)
-    set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
-    set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
-endif(MSVC_IDE)
-  
-## Define Vidalia-specific CMake options
-if (APPLE)
-  option(OSX_TIGER_COMPAT "Build an OS X 10.4 Compatible Vidalia." OFF)
-  if (OSX_TIGER_COMPAT)
-    set(CMAKE_EXE_LINKER_FLAGS "-mmacosx-version-min=10.4"
-      CACHE STRING "Flags used by the linker." FORCE)
-    set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk"
-      CACHE STRING "isysroot used for universal binary support" FORCE)
-  endif(OSX_TIGER_COMPAT)
-
-  option(OSX_FAT_BINARY "Build Vidalia as a Universal binary." OFF)
-  if (OSX_FAT_BINARY)
-    set(CMAKE_OSX_ARCHITECTURES "ppc;i386" 
-        CACHE STRING "OS X build architectures" FORCE)
-    set(CMAKE_EXE_LINKER_FLAGS "-mmacosx-version-min=10.4"
-        CACHE STRING "Flags used by the linker." FORCE)
-    set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk"
-        CACHE STRING "isysroot used for universal binary support" FORCE)
-  endif(OSX_FAT_BINARY)
-
-  option(OSX_FORCE_32BIT "Force a 32-bit build for compatibility." OFF)
-  if (OSX_FORCE_32BIT)
-    add_definitions(-m32)
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" 
-        CACHE STRING "Flags used by the linker." FORCE)
-  endif(OSX_FORCE_32BIT)
-endif(APPLE)
-
-## UPnP support is currently optional (enabled by default)
-option(USE_MINIUPNPC "Enable UPnP support using the MiniUPnPc library." ON)
-
-## Crash reporting via Google Breakpad is optional (disabled by default)
-option(USE_BREAKPAD "Enable Google Breakpad crash reporting." OFF)
-if (USE_BREAKPAD)
-  include(${CMAKE_SOURCE_DIR}/cmake/FindBreakpad.cmake)
-endif(USE_BREAKPAD)
-
-## Automatic software update is optional (disabled by default)
-if (WIN32)
-  option(USE_AUTOUPDATE "Enable automatic software update support." OFF)
-endif(WIN32)
-
-## Find the KDE Marble library
-if (USE_MARBLE)
-  include(${CMAKE_SOURCE_DIR}/cmake/FindMarble.cmake)
-endif(USE_MARBLE)
-
-## Find the MaxMind GeoIP library
-option(USE_GEOIP "Enable GeoIP lookups via a local MaxMind database" OFF)
-if (USE_GEOIP)
-  include(${CMAKE_SOURCE_DIR}/cmake/FindGeoIP.cmake)
-endif(USE_GEOIP)
-
-## Check for system header files
-check_include_file("limits.h" HAVE_LIMITS_H)
-check_include_file("sys/limits.h" HAVE_SYS_LIMITS_H)
-check_include_file("signal.h" HAVE_SIGNAL_H)
-
-## Check for the sizes of various data types
-check_type_size(int SIZEOF_INT)
-
-## Check for the existence of some platform-specific functions
-if (HAVE_SIGNAL_H)
-  set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "signal.h")
-  check_function_exists(sigaction HAVE_SIGACTION)
-  check_function_exists(signal HAVE_SIGNAL)
-endif(HAVE_SIGNAL_H)
-
-## Write out a configuration file
-configure_file(
-  ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
-  ${CMAKE_CURRENT_BINARY_DIR}/config.h
-)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-## Add the actual source directories
-add_subdirectory(src)
-add_subdirectory(doc)
-add_subdirectory(pkg)
-

Copied: vidalia/tags/vidalia-0.2.11/CMakeLists.txt (from rev 4537, vidalia/trunk/CMakeLists.txt)
===================================================================
--- vidalia/tags/vidalia-0.2.11/CMakeLists.txt	                        (rev 0)
+++ vidalia/tags/vidalia-0.2.11/CMakeLists.txt	2011-03-20 15:40:12 UTC (rev 4538)
@@ -0,0 +1,147 @@
+##
+##  $Id$
+## 
+##  This file is part of Vidalia, and is subject to the license terms in the
+##  LICENSE file, found in the top level directory of this distribution. If 
+##  you did not receive the LICENSE file with this file, you may obtain it
+##  from the Vidalia source package distributed by the Vidalia Project at
+##  http://www.vidalia-project.net/. No part of Vidalia, including this file,
+##  may be copied, modified, propagated, or distributed except according to
+##  the terms described in the LICENSE file.
+##
+
+
+set(VER_MAJOR   "0")
+set(VER_MINOR   "2")
+set(VER_PATCH   "11")
+set(VERSION     "${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}")
+message(STATUS  "Configuring Vidalia ${VERSION}")
+project(Vidalia)
+
+## Specify the minimim required CMake version
+cmake_minimum_required(VERSION 2.4.7)
+if (COMMAND cmake_policy)
+  # Force CMake 2.4 compatibility for handling linker search paths
+  cmake_policy(SET CMP0003 OLD)
+endif(COMMAND cmake_policy)
+
+## We declare this option here, because it determines the minimum
+## required Qt version
+option(USE_MARBLE "Enable the KDE Marble-based map widget." OFF)
+
+## Specify the minimum version of Qt required
+set(QT_MIN_VERSION    "4.3.0")
+
+## Specify the Qt libraries used
+include(FindQt4)
+find_package(Qt4 REQUIRED)
+set(QT_USE_QTNETWORK  true)
+set(QT_USE_QTXML      true)
+if (USE_MARBLE)
+  set(QT_USE_QTSVG    true)
+  set(QT_USE_QTWEBKIT true)
+  set(QT_USE_QTSCRIPT true)
+  set(QT_USE_QTDBUS   true)
+endif(USE_MARBLE)
+include(${QT_USE_FILE})
+include(${CMAKE_SOURCE_DIR}/cmake/VidaliaMacros.cmake)
+include(CheckIncludeFile)
+include(CheckIncludeFileCXX)
+include(CheckTypeSize)
+include(CheckFunctionExists)
+if (WIN32)
+  include(${CMAKE_SOURCE_DIR}/cmake/FindWiX.cmake)
+endif(WIN32)
+if (MSVC)
+  include(${CMAKE_SOURCE_DIR}/cmake/FindOpenSSL.cmake)
+endif(MSVC)
+
+if(MSVC_IDE)
+    set(CMAKE_SUPPRESS_REGENERATION TRUE)
+    set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
+    set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
+endif(MSVC_IDE)
+  
+## Define Vidalia-specific CMake options
+if (APPLE)
+  option(OSX_TIGER_COMPAT "Build an OS X 10.4 Compatible Vidalia." OFF)
+  if (OSX_TIGER_COMPAT)
+    set(CMAKE_EXE_LINKER_FLAGS "-mmacosx-version-min=10.4"
+      CACHE STRING "Flags used by the linker." FORCE)
+    set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk"
+      CACHE STRING "isysroot used for universal binary support" FORCE)
+  endif(OSX_TIGER_COMPAT)
+
+  option(OSX_FAT_BINARY "Build Vidalia as a Universal binary." OFF)
+  if (OSX_FAT_BINARY)
+    set(CMAKE_OSX_ARCHITECTURES "ppc;i386" 
+        CACHE STRING "OS X build architectures" FORCE)
+    set(CMAKE_EXE_LINKER_FLAGS "-mmacosx-version-min=10.4"
+        CACHE STRING "Flags used by the linker." FORCE)
+    set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk"
+        CACHE STRING "isysroot used for universal binary support" FORCE)
+  endif(OSX_FAT_BINARY)
+
+  option(OSX_FORCE_32BIT "Force a 32-bit build for compatibility." OFF)
+  if (OSX_FORCE_32BIT)
+    add_definitions(-m32)
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" 
+        CACHE STRING "Flags used by the linker." FORCE)
+  endif(OSX_FORCE_32BIT)
+endif(APPLE)
+
+## Define if compiled with Windows 2k support
+option(WIN2K "Enable Windows 2k support." OFF)
+
+## UPnP support is currently optional (enabled by default)
+option(USE_MINIUPNPC "Enable UPnP support using the MiniUPnPc library." ON)
+
+## Crash reporting via Google Breakpad is optional (disabled by default)
+option(USE_BREAKPAD "Enable Google Breakpad crash reporting." OFF)
+if (USE_BREAKPAD)
+  include(${CMAKE_SOURCE_DIR}/cmake/FindBreakpad.cmake)
+endif(USE_BREAKPAD)
+
+## Automatic software update is optional (disabled by default)
+if (WIN32)
+  option(USE_AUTOUPDATE "Enable automatic software update support." OFF)
+endif(WIN32)
+
+## Find the KDE Marble library
+if (USE_MARBLE)
+  include(${CMAKE_SOURCE_DIR}/cmake/FindMarble.cmake)
+endif(USE_MARBLE)
+
+## Find the MaxMind GeoIP library
+option(USE_GEOIP "Enable GeoIP lookups via a local MaxMind database" OFF)
+if (USE_GEOIP)
+  include(${CMAKE_SOURCE_DIR}/cmake/FindGeoIP.cmake)
+endif(USE_GEOIP)
+
+## Check for system header files
+check_include_file("limits.h" HAVE_LIMITS_H)
+check_include_file("sys/limits.h" HAVE_SYS_LIMITS_H)
+check_include_file("signal.h" HAVE_SIGNAL_H)
+
+## Check for the sizes of various data types
+check_type_size(int SIZEOF_INT)
+
+## Check for the existence of some platform-specific functions
+if (HAVE_SIGNAL_H)
+  set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "signal.h")
+  check_function_exists(sigaction HAVE_SIGACTION)
+  check_function_exists(signal HAVE_SIGNAL)
+endif(HAVE_SIGNAL_H)
+
+## Write out a configuration file
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+  ${CMAKE_CURRENT_BINARY_DIR}/config.h
+)
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+## Add the actual source directories
+add_subdirectory(src)
+add_subdirectory(doc)
+add_subdirectory(pkg)
+

Deleted: vidalia/tags/vidalia-0.2.11/INSTALL
===================================================================
--- vidalia/trunk/INSTALL	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/INSTALL	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,269 +0,0 @@
-
-         Instructions for Building and Installing Vidalia from Source
-
-
-Before building and running Vidalia, you will need to have the following
-packages installed:
-
-  * Qt >= 4.3           http://qt.nokia.com/downloads
-  * Tor >= 0.2.0.34     https://www.torproject.org/download.html
-  * CMake >= 2.4.0      http://www.cmake.org/HTML/Download.html
-
-
-Linux/BSD/Unix
---------------
-  1. To configure and compile Vidalia, you can run the following sequence of
-     commands:
-
-       mkdir build && cd build
-       cmake ..
-       make
-
-  2. When the previous command finishes, Vidalia's binary will be
-     placed in the build/src/vidalia/ directory.
-  
-  3. Optionally, you can run `make install` to install Vidalia into
-     your /usr/local/bin/ directory. 
-
-
-Mac OS X
---------
-CMake on Mac OS X gives you the option of compiling Vidalia from the command
-line using standard Unix Makefiles, or generating an Xcode project if you
-prefer building from an IDE.
-
-  1. To build Vidalia from the command line, you can run:
-
-        mkdir build && cd build
-        cmake ..
-        make
-
-     Alternatively, you can have CMake generate an Xcode project for Vidalia
-     by running:
-
-        mkdir xcode && cd xcode
-        cmake -G Xcode ..
-
-  2. If you built from the command line, Vidalia's binary will be in an
-     application bundle located at build/src/vidalia/Vidalia.app. You can copy
-     Vidalia.app to your Applications folder, if you prefer.
-
-     If you're building from a CMake-generated Xcode project, you can simply
-     click "Build & Go" in Xcode to build and run Vidalia. Or, you can run
-     'xcodebuild' if you prefer building from the command line.
-
-
-Windows with MinGW
--------------------
-  1. Make sure the following directories are in your PATH environment
-  variable:
-      
-        * CMake (e.g., "C:\Program Files\CMake 2.4\bin")
-        * MinGW (e.g., "C:\MinGW\bin")
-        * Qt    (e.g., "C:\Qt\4.3.2\bin")
-
-  2. Configure Vidalia and generate Makefiles by running: 
-
-        mkdir build && cd build
-        cmake -G "MinGW Makefiles" ..
-
-     There should be no spaces in the path to your build directory. Otherwise,
-     Vidalia will fail to build.
-
-  3. Compile Vidalia by running: 
-                          
-        mingw32-make
-
-
-If CMake fails to find your Qt installation, you can explicitly tell CMake
-where to find Qt as in the following example:
-
-        cmake -DQT_QMAKE_EXECUTABLE="C:\Qt\4.3.2\bin\qmake.exe" ..
-
-You would replace "C:\Qt\4.3.2\bin" in the previous command with the actual
-path to your Qt installation's qmake.exe binary.
-
-
-Windows with Visual Studio
---------------------------
-Starting with Qt 4.3.2, the open source editions of Qt/Win include support for
-Visual Studio. Previously, Visual Studio support was limited to commercial 
-editions of Qt unless you patched Qt's source.
-
-To build Vidalia under Visual Studio, you will first need to obtain Qt's 
-source code and compile it with Visual Studio support. The following
-directions show how to compile Qt with Visual Studio 2005 support, but a
-similar process can be followed for other versions of VS. 
-
-  1. Download and install Visual C++ 2005 Express
- 
-       http://www.microsoft.com/express/2005/download/default.aspx
-
-  2. Download and install the Windows Platform SDK and configure Visual C++ with
-     the location of the Platform SDK's executable, include, and library
-     directories.
-
-       http://msdn2.microsoft.com/en-us/express/aa700755.aspx
-
-     It is important to also install the "Microsoft Web Workshop (IE) SDK", even
-     though that seems irrelevant.
-
-  3. Download the Qt/Windows open source edition source code and extract it to a
-     directory with no spaces (e.g., C:\Qt\4.3.3).
-
-       http://qt.nokia.com/downloads/windows-cpp
-
-  4. Edit the Visual Studio  2005 command prompt environment variables to
-     include the platform SDK files, by opening
-
-       C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
-
-     and adding
-
-       C:\Program Files\Microsoft Platform SDK for Windows Servers 2003 R2\Include
-
-     to the INCLUDE variable and
-
-       C:\Program Files\Microsoft Platform SDK for Windows Servers 2003 R2\Lib
-
-     to the LIB variable. Modify the path to the platform SDK files as
-     appropriate, depending on where you installed Visual Studio and the
-     Platform SDK in Steps 1 and 2.
-
-  5. Open the Visual Studio 2005 Command Prompt and 'cd' to the location of 
-     your extracted Qt source code (e.g., C:\Qt\4.3.3).
-
-  6. Configure Qt with support for your version of Visual Studio. For example,
-     to configure Qt with support for Visual Studio 2005, you would run:
-
-      configure.exe -debug-and-release -static -fast -platform win32-msvc2005
-
-     See Qt's README file for more available platform options.
-
-  7. Compile Qt by running:  
-     
-        nmake.exe
-  
-     (NOTE: This step will take several hours and lots of hard drive space.)
- 
-Once you have Qt compiled with Visual Studio support, you can use CMake to
-generate a Visual Studio project file by running
-
-        mkdir build && cd build
-        cmake -G "Visual Studio 8 2005" ..
-
-or whatever your particular version of Visual Studio happens to be.
-'cmake --help' lists other available generators.
-
-
-Windows with NMake
--------------------
-To compile Vidalia from the command line using NMake, you will first need to
-follow the steps under the 'Windows with Visual Studio' section for compiling
-Qt with Visual Studio support.
-
-If you want to build Vidalia from the command line, you can have CMake 
-generate NMake makefiles by running:
-
-        mkdir build && cd build
-        cmake -G "NMake Makefiles" ..
-
-You can then compile Vidalia from the command line by simply running:
-
-        nmake
-
-
-Available Configuration Options
--------------------------------
-You can customize your Vidalia build by supplying arguments and values to the
-`cmake` commands above. Each of the configuration options can be specified on
-the command line and follows the format "-D <var>:<type>=<value>
-
-  -DUSE_QSSLSOCKET=0 
-  
-      Disable building Vidalia with SSL support.
-
-  -DUSE_MINIUPNPC=0
-    
-    Disable UPnP support in Vidalia.
-
-  -DOSX_FAT_BINARY=1 
-    
-    Build Vidalia as a Universal binary.
-
-  -DOSX_TIGER_COMPAT=1
-  
-    Build Vidalia compatible with OS X Tiger (10.4).
-
-  -DOSX_FORCE_32BIT=1
-
-    Forces a 32-bit build. This is useful on platforms that default to 64-bit
-    (e.g. Snow Leopard), but only have 32-bit versions of the Qt libraries
-    available.
-
-  -DQT_QMAKE_EXECUTABLE=/path/to/qmake
-  
-    Specifies the location of Qt's 'qmake' binary.
-
-  -DOPENSSL_LIBRARY_DIR=/path/to/openssl
-  
-    Specifies the location of OpenSSL's libraries.
-
-  -DCMAKE_INSTALL_PREFIX=/usr/local
-  
-    Specifies the install prefix used for `make install`.
-
-  -DCMAKE_BUILD_TYPE=<buildtype>
-  
-    Available build types include: "release", "debug", "minsizerel"
-
-  -DUSE_MARBLE=1
-  
-    Replace the flat map with a 3-D sphere using the Marble libraries.
-
-  -DWIX_BINARY_DIR=C:\Path\To\WiX\
-  
-    Specifies the location of your WiX executables, such as candle.exe and
-    light.exe (optional, Windows-only).
-
-
-For example, to configure CMake to look for Qt in "/usr/local/Qt-4.3.2/bin",
-you would run:
-
-      cmake -DQT_QMAKE_EXECUTABLE=/usr/local/Qt-4.3.2/bin/qmake ..
-
-Don't forget the dot(s) at the end!
-
-CMake also supports other generators besides Makefiles on certain platforms. 
-See  'cmake --help' or 'man cmake' (on non-Windows platforms) for more 
-information about supported generators and configuration options.
-
-
-Additional Build Targets
--------------------------
-Vidalia contains a number of additional CMake build targets to assist in
-building code documentation and platform-specific packages. The targets are:
-
-  'dist'                    Creates a Vidalia source code tarball.
-
-  'dist-osx'                Creates a Vidalia-only Mac OS X .dmg.
-
-  'dist-osx-bundle'         Creates a Vidalia bundle .dmg. See
-                            pkg/osx/build-bundle.txt for additional
-                            information on the CMake options necessary to create
-                            a proper OS X bundle.
-
-  'dist-osx-split-bundle'   Creates a "split" Mac OS X bundle. See 
-                            pkg/osx/build-bundle.txt for additional
-                            information on the CMake options necessary to create
-                            a proper OS X bundle.
-
-  'dist-win32'              Creates a Windows .msi package. You will also
-                            need to define -DWIX_BINARY_DIR=<path-to-WiX>
-                            in order to use this build target.
-
-  'doxygen'                 Creates the Doxygen-generated code
-                            documentation for Vidalia's source. You must
-                            have Doxygen installed for this target to
-                            function.
-

Copied: vidalia/tags/vidalia-0.2.11/INSTALL (from rev 4536, vidalia/trunk/INSTALL)
===================================================================
--- vidalia/tags/vidalia-0.2.11/INSTALL	                        (rev 0)
+++ vidalia/tags/vidalia-0.2.11/INSTALL	2011-03-20 15:40:12 UTC (rev 4538)
@@ -0,0 +1,280 @@
+
+         Instructions for Building and Installing Vidalia from Source
+
+
+Before building and running Vidalia, you will need to have the following
+packages installed:
+
+  * Qt >= 4.3           http://qt.nokia.com/downloads
+  * Tor >= 0.2.0.34     https://www.torproject.org/download.html
+  * CMake >= 2.4.0      http://www.cmake.org/HTML/Download.html
+
+
+Linux/BSD/Unix
+--------------
+  1. To configure and compile Vidalia, you can run the following sequence of
+     commands:
+
+       mkdir build && cd build
+       cmake ..
+       make
+
+  2. When the previous command finishes, Vidalia's binary will be
+     placed in the build/src/vidalia/ directory.
+  
+  3. Optionally, you can run `make install` to install Vidalia into
+     your /usr/local/bin/ directory. 
+
+
+Mac OS X
+--------
+CMake on Mac OS X gives you the option of compiling Vidalia from the command
+line using standard Unix Makefiles, or generating an Xcode project if you
+prefer building from an IDE.
+
+  1. To build Vidalia from the command line, you can run:
+
+        mkdir build && cd build
+        cmake ..
+        make
+
+     Alternatively, you can have CMake generate an Xcode project for Vidalia
+     by running:
+
+        mkdir xcode && cd xcode
+        cmake -G Xcode ..
+
+  2. If you built from the command line, Vidalia's binary will be in an
+     application bundle located at build/src/vidalia/Vidalia.app. You can copy
+     Vidalia.app to your Applications folder, if you prefer.
+
+     If you're building from a CMake-generated Xcode project, you can simply
+     click "Build & Go" in Xcode to build and run Vidalia. Or, you can run
+     'xcodebuild' if you prefer building from the command line.
+
+
+Windows with MinGW
+-------------------
+  1. Make sure the following directories are in your PATH environment
+  variable:
+      
+        * CMake (e.g., "C:\Program Files\CMake 2.4\bin")
+        * MinGW (e.g., "C:\MinGW\bin")
+        * Qt    (e.g., "C:\Qt\4.3.2\bin")
+
+  2. Configure Vidalia and generate Makefiles by running: 
+
+        mkdir build && cd build
+        cmake -G "MinGW Makefiles" ..
+
+     There should be no spaces in the path to your build directory. Otherwise,
+     Vidalia will fail to build.
+
+  3. Compile Vidalia by running: 
+                          
+        mingw32-make
+
+
+If CMake fails to find your Qt installation, you can explicitly tell CMake
+where to find Qt as in the following example:
+
+        cmake -DQT_QMAKE_EXECUTABLE="C:\Qt\4.3.2\bin\qmake.exe" ..
+
+You would replace "C:\Qt\4.3.2\bin" in the previous command with the actual
+path to your Qt installation's qmake.exe binary.
+
+If you are trying to build Vidalia for Windows 2000 and earlier, you should
+download Windows SDK, copy wspiapi.h header to MinGW include directory and
+build vidalia running:
+
+        cmake -DWIN2K ..
+
+Note: the header as it is in the SDK needs a "_inline" to be replaced to 
+"__inline" for it to build properly.
+
+
+Windows with Visual Studio
+--------------------------
+Starting with Qt 4.3.2, the open source editions of Qt/Win include support for
+Visual Studio. Previously, Visual Studio support was limited to commercial 
+editions of Qt unless you patched Qt's source.
+
+To build Vidalia under Visual Studio, you will first need to obtain Qt's 
+source code and compile it with Visual Studio support. The following
+directions show how to compile Qt with Visual Studio 2005 support, but a
+similar process can be followed for other versions of VS. 
+
+  1. Download and install Visual C++ 2005 Express
+ 
+       http://www.microsoft.com/express/2005/download/default.aspx
+
+  2. Download and install the Windows Platform SDK and configure Visual C++ with
+     the location of the Platform SDK's executable, include, and library
+     directories.
+
+       http://msdn2.microsoft.com/en-us/express/aa700755.aspx
+
+     It is important to also install the "Microsoft Web Workshop (IE) SDK", even
+     though that seems irrelevant.
+
+  3. Download the Qt/Windows open source edition source code and extract it to a
+     directory with no spaces (e.g., C:\Qt\4.3.3).
+
+       http://qt.nokia.com/downloads/windows-cpp
+
+  4. Edit the Visual Studio  2005 command prompt environment variables to
+     include the platform SDK files, by opening
+
+       C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
+
+     and adding
+
+       C:\Program Files\Microsoft Platform SDK for Windows Servers 2003 R2\Include
+
+     to the INCLUDE variable and
+
+       C:\Program Files\Microsoft Platform SDK for Windows Servers 2003 R2\Lib
+
+     to the LIB variable. Modify the path to the platform SDK files as
+     appropriate, depending on where you installed Visual Studio and the
+     Platform SDK in Steps 1 and 2.
+
+  5. Open the Visual Studio 2005 Command Prompt and 'cd' to the location of 
+     your extracted Qt source code (e.g., C:\Qt\4.3.3).
+
+  6. Configure Qt with support for your version of Visual Studio. For example,
+     to configure Qt with support for Visual Studio 2005, you would run:
+
+      configure.exe -debug-and-release -static -fast -platform win32-msvc2005
+
+     See Qt's README file for more available platform options.
+
+  7. Compile Qt by running:  
+     
+        nmake.exe
+  
+     (NOTE: This step will take several hours and lots of hard drive space.)
+ 
+Once you have Qt compiled with Visual Studio support, you can use CMake to
+generate a Visual Studio project file by running
+
+        mkdir build && cd build
+        cmake -G "Visual Studio 8 2005" ..
+
+or whatever your particular version of Visual Studio happens to be.
+'cmake --help' lists other available generators.
+
+
+Windows with NMake
+-------------------
+To compile Vidalia from the command line using NMake, you will first need to
+follow the steps under the 'Windows with Visual Studio' section for compiling
+Qt with Visual Studio support.
+
+If you want to build Vidalia from the command line, you can have CMake 
+generate NMake makefiles by running:
+
+        mkdir build && cd build
+        cmake -G "NMake Makefiles" ..
+
+You can then compile Vidalia from the command line by simply running:
+
+        nmake
+
+
+Available Configuration Options
+-------------------------------
+You can customize your Vidalia build by supplying arguments and values to the
+`cmake` commands above. Each of the configuration options can be specified on
+the command line and follows the format "-D <var>:<type>=<value>
+
+  -DUSE_MINIUPNPC=0
+    
+    Disable UPnP support in Vidalia.
+
+  -DOSX_FAT_BINARY=1 
+    
+    Build Vidalia as a Universal binary.
+
+  -DOSX_TIGER_COMPAT=1
+  
+    Build Vidalia compatible with OS X Tiger (10.4).
+
+  -DOSX_FORCE_32BIT=1
+
+    Forces a 32-bit build. This is useful on platforms that default to 64-bit
+    (e.g. Snow Leopard), but only have 32-bit versions of the Qt libraries
+    available.
+
+  -DQT_QMAKE_EXECUTABLE=/path/to/qmake
+  
+    Specifies the location of Qt's 'qmake' binary.
+
+  -DOPENSSL_LIBRARY_DIR=/path/to/openssl
+  
+    Specifies the location of OpenSSL's libraries for building installer on 
+    Windows.
+
+  -DCMAKE_INSTALL_PREFIX=/usr/local
+  
+    Specifies the install prefix used for `make install`.
+
+  -DCMAKE_BUILD_TYPE=<buildtype>
+  
+    Available build types include: "release", "debug", "minsizerel"
+
+  -DUSE_MARBLE=1
+  
+    Replace the flat map with a 3-D sphere using the Marble libraries.
+
+  -DWIX_BINARY_DIR=C:\Path\To\WiX\
+  
+    Specifies the location of your WiX executables, such as candle.exe and
+    light.exe (optional, Windows-only).
+
+  -DWIN2K
+
+    Builds Vidalia using the inlines defined in wspiapi.h header for Windows
+    2000 and earlier support.
+
+
+For example, to configure CMake to look for Qt in "/usr/local/Qt-4.3.2/bin",
+you would run:
+
+      cmake -DQT_QMAKE_EXECUTABLE=/usr/local/Qt-4.3.2/bin/qmake ..
+
+Don't forget the dot(s) at the end!
+
+CMake also supports other generators besides Makefiles on certain platforms. 
+See  'cmake --help' or 'man cmake' (on non-Windows platforms) for more 
+information about supported generators and configuration options.
+
+
+Additional Build Targets
+-------------------------
+Vidalia contains a number of additional CMake build targets to assist in
+building code documentation and platform-specific packages. The targets are:
+
+  'dist'                    Creates a Vidalia source code tarball.
+
+  'dist-osx'                Creates a Vidalia-only Mac OS X .dmg.
+
+  'dist-osx-bundle'         Creates a Vidalia bundle .dmg. See
+                            pkg/osx/build-bundle.txt for additional
+                            information on the CMake options necessary to create
+                            a proper OS X bundle.
+
+  'dist-osx-split-bundle'   Creates a "split" Mac OS X bundle. See 
+                            pkg/osx/build-bundle.txt for additional
+                            information on the CMake options necessary to create
+                            a proper OS X bundle.
+
+  'dist-win32'              Creates a Windows .msi package. You will also
+                            need to define -DWIX_BINARY_DIR=<path-to-WiX>
+                            in order to use this build target.
+
+  'doxygen'                 Creates the Doxygen-generated code
+                            documentation for Vidalia's source. You must
+                            have Doxygen installed for this target to
+                            function.
+

Deleted: vidalia/tags/vidalia-0.2.11/config.h.in
===================================================================
--- vidalia/trunk/config.h.in	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/config.h.in	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,46 +0,0 @@
-/*
-**  $Id$
-** 
-**  This file is part of Vidalia, and is subject to the license terms in the 
-**  LICENSE file, found in the top level directory of this distribution. If  
-**  you did not receive the LICENSE file with this file, you may obtain it
-**  from the Vidalia source package distributed by the Vidalia Project at
-**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
-**  may be copied, modified, propagated, or distributed except according to
-**  the terms described in the LICENSE file.
-**
-*/
-
-#ifndef _CONFIG_H
-#define _CONFIG_H
-
-#define VIDALIA_VERSION    "@VERSION@"
-
-#cmakedefine HAVE_LIMITS_H
-
-#cmakedefine HAVE_SYS_LIMITS_H
-
-#cmakedefine HAVE_SIGNAL_H
-
-#cmakedefine HAVE_SIGACTION
-
-#cmakedefine HAVE_SIGNAL
-
-#cmakedefine HAVE_GEOIP_H
-
-#cmakedefine HAVE_GEOIPCITY_H
-
-#cmakedefine SIZEOF_INT @SIZEOF_INT@
-
-#cmakedefine USE_MINIUPNPC
-
-#cmakedefine USE_AUTOUPDATE
-
-#cmakedefine USE_MARBLE
-
-#cmakedefine USE_BREAKPAD
-
-#cmakedefine USE_GEOIP
-
-#endif
-

Copied: vidalia/tags/vidalia-0.2.11/config.h.in (from rev 4535, vidalia/trunk/config.h.in)
===================================================================
--- vidalia/tags/vidalia-0.2.11/config.h.in	                        (rev 0)
+++ vidalia/tags/vidalia-0.2.11/config.h.in	2011-03-20 15:40:12 UTC (rev 4538)
@@ -0,0 +1,48 @@
+/*
+**  $Id$
+** 
+**  This file is part of Vidalia, and is subject to the license terms in the 
+**  LICENSE file, found in the top level directory of this distribution. If  
+**  you did not receive the LICENSE file with this file, you may obtain it
+**  from the Vidalia source package distributed by the Vidalia Project at
+**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
+**  may be copied, modified, propagated, or distributed except according to
+**  the terms described in the LICENSE file.
+**
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+
+#define VIDALIA_VERSION    "@VERSION@"
+
+#cmakedefine HAVE_LIMITS_H
+
+#cmakedefine HAVE_SYS_LIMITS_H
+
+#cmakedefine HAVE_SIGNAL_H
+
+#cmakedefine HAVE_SIGACTION
+
+#cmakedefine HAVE_SIGNAL
+
+#cmakedefine HAVE_GEOIP_H
+
+#cmakedefine HAVE_GEOIPCITY_H
+
+#cmakedefine SIZEOF_INT @SIZEOF_INT@
+
+#cmakedefine USE_MINIUPNPC
+
+#cmakedefine USE_AUTOUPDATE
+
+#cmakedefine USE_MARBLE
+
+#cmakedefine USE_BREAKPAD
+
+#cmakedefine USE_GEOIP
+
+#cmakedefine WIN2K
+
+#endif
+

Deleted: vidalia/tags/vidalia-0.2.11/pkg/rpm/vidalia.spec.in
===================================================================
--- vidalia/trunk/pkg/rpm/vidalia.spec.in	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/pkg/rpm/vidalia.spec.in	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,141 +0,0 @@
-Name:             vidalia
-Version:          @VERSION@
-Release:          1%{?dist}
-Summary:          GUI controller for the Tor Onion Routing Network
-
-Group:            Applications/Internet
-License:          GPLv2+
-URL:              https://www.torproject.org/vidalia/
-Source0:          https://www.torproject.org/%{name}/dist/%{name}-%{version}.tar.gz
-BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 
-
-BuildRequires:    desktop-file-utils
-BuildRequires:    openssl-devel
-BuildRequires:    qt4-devel
-BuildRequires:    cmake
-
-Requires:         tor
-Requires:         privoxy
-Requires:         hicolor-icon-theme
-
-
-%description
-Vidalia is a cross-platform controller GUI for Tor, built using the Qt 
-framework. Vidalia allows you to start and stop Tor, view the status of Tor at 
-a glance, and monitor Tor's bandwidth usage. Vidalia also makes it easy to 
-contribute to the Tor network by helping you setup a Tor server, if you wish.
-
-
-%package doc
-Summary:        Documentation for %{name}
-Group:          Documentation
-BuildRequires:  doxygen
-Requires:       %{name} = %{version}-%{release}
-
-
-%description doc
-Doxygen generated documentations for %{name}.
-
-
-%prep
-%setup -q
-
-
-%build
-%if 0%{?_qt4_bindir:1}
-PATH=%{_qt4_bindir}:$PATH; export PATH
-%else
-PATH=%{_libdir}/qt4/bin:$PATH; export PATH
-%endif
-
-%cmake .
-
-make %{?_smp_mflags}
-
-cd doc
-doxygen Doxyfile.in
-
-
-%install
-rm -rf %{buildroot}
-
-make install \
-     INSTALL="install -p" \
-     DESTDIR=%{buildroot}
-
-install -Dpm0644 doc/%{name}.1 \
-        %{buildroot}%{_mandir}/man1/%{name}.1
-
-
-mkdir -p %{buildroot}%{_docdir}/%{name}-%{version}-doxygen/
-
-cp -r src/%{name}/help/ \
-	%{buildroot}%{_docdir}/%{name}-%{version}-doxygen/
-
-
-
-%post
-touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
-
-
-%postun
-if [ $1 -eq 0 ] ; then
-    touch --no-create %{_datadir}/icons/hicolor &>/dev/null
-    gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-fi
-
-
-%posttrans
-gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
-
-
-%clean
-rm -rf %{buildroot}
-
-
-%files
-%defattr(-,root,root,-)
-%doc CHANGELOG CREDITS HACKING LICENSE LICENSE-GPLV2 LICENSE-GPLV3 LICENSE-OPENSSL README
-%{_bindir}/%{name}
-%{_mandir}/man1/%{name}*
-%{_datadir}/applications/%{name}.desktop
-%{_datadir}/icons/hicolor/*/apps/%{name}.png
-
-
-%files doc
-%defattr(-,root,root,-)
-%{_docdir}/%{name}-%{version}-doxygen/
-
-
-%changelog
-* Fri Jan 29 2010 Erinn Clark <erinn@xxxxxxxxxxxxxx> - 0.2.7-1
-- New upstream release
-- Updated documentation installation process
-
-* Sat Jun 13 2009 Matt Edman <edmanm@xxxxxxxxxxxxxxxxxxx> - 0.2.1-1
-- Added to Vidalia Subversion repository
-
-* Mon Jun 01 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.13-2
-- Merge builds for fedora and epel
-
-* Mon Jun 01 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.13-1
-- Update to 0.1.13
-- Adjust to fedora and epel
-
-* Sun Apr 06 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.12-1
-- New upstream release
-- Correct typo in URL
-- Add R: hicolor for new handling of icons
-- Add update-icon-cache sniplet
-- Use summary of upstream for Desktopfile and in spec file
-- Create doxygen-documentations
-
-* Sun Feb 15 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.10-2
-- Correct Qt in Summary
-- Correct Qt in desktop-file-source
-- Add a german Translation in the desktop-file-source
-- Using CMAKE-macro instead of cmake
-- Add more files to more documentation
-
-* Tue Feb 10 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.10-1
-- Initial Package build

Copied: vidalia/tags/vidalia-0.2.11/pkg/rpm/vidalia.spec.in (from rev 4533, vidalia/trunk/pkg/rpm/vidalia.spec.in)
===================================================================
--- vidalia/tags/vidalia-0.2.11/pkg/rpm/vidalia.spec.in	                        (rev 0)
+++ vidalia/tags/vidalia-0.2.11/pkg/rpm/vidalia.spec.in	2011-03-20 15:40:12 UTC (rev 4538)
@@ -0,0 +1,140 @@
+Name:             vidalia
+Version:          @VERSION@
+Release:          1%{?dist}
+Summary:          GUI controller for the Tor Onion Routing Network
+
+Group:            Applications/Internet
+License:          GPLv2+
+URL:              https://www.torproject.org/vidalia/
+Source0:          https://www.torproject.org/%{name}/dist/%{name}-%{version}.tar.gz
+BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 
+
+BuildRequires:    desktop-file-utils
+BuildRequires:    qt4-devel
+BuildRequires:    cmake
+
+Requires:         tor
+Requires:         privoxy
+Requires:         hicolor-icon-theme
+
+
+%description
+Vidalia is a cross-platform controller GUI for Tor, built using the Qt 
+framework. Vidalia allows you to start and stop Tor, view the status of Tor at 
+a glance, and monitor Tor's bandwidth usage. Vidalia also makes it easy to 
+contribute to the Tor network by helping you setup a Tor server, if you wish.
+
+
+%package doc
+Summary:        Documentation for %{name}
+Group:          Documentation
+BuildRequires:  doxygen
+Requires:       %{name} = %{version}-%{release}
+
+
+%description doc
+Doxygen generated documentations for %{name}.
+
+
+%prep
+%setup -q
+
+
+%build
+%if 0%{?_qt4_bindir:1}
+PATH=%{_qt4_bindir}:$PATH; export PATH
+%else
+PATH=%{_libdir}/qt4/bin:$PATH; export PATH
+%endif
+
+%cmake .
+
+make %{?_smp_mflags}
+
+cd doc
+doxygen Doxyfile.in
+
+
+%install
+rm -rf %{buildroot}
+
+make install \
+     INSTALL="install -p" \
+     DESTDIR=%{buildroot}
+
+install -Dpm0644 doc/%{name}.1 \
+        %{buildroot}%{_mandir}/man1/%{name}.1
+
+
+mkdir -p %{buildroot}%{_docdir}/%{name}-%{version}-doxygen/
+
+cp -r src/%{name}/help/ \
+	%{buildroot}%{_docdir}/%{name}-%{version}-doxygen/
+
+
+
+%post
+touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
+
+
+%postun
+if [ $1 -eq 0 ] ; then
+    touch --no-create %{_datadir}/icons/hicolor &>/dev/null
+    gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+fi
+
+
+%posttrans
+gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
+
+
+%clean
+rm -rf %{buildroot}
+
+
+%files
+%defattr(-,root,root,-)
+%doc CHANGELOG CREDITS HACKING LICENSE LICENSE-GPLV2 LICENSE-GPLV3 README
+%{_bindir}/%{name}
+%{_mandir}/man1/%{name}*
+%{_datadir}/applications/%{name}.desktop
+%{_datadir}/icons/hicolor/*/apps/%{name}.png
+
+
+%files doc
+%defattr(-,root,root,-)
+%{_docdir}/%{name}-%{version}-doxygen/
+
+
+%changelog
+* Fri Jan 29 2010 Erinn Clark <erinn@xxxxxxxxxxxxxx> - 0.2.7-1
+- New upstream release
+- Updated documentation installation process
+
+* Sat Jun 13 2009 Matt Edman <edmanm@xxxxxxxxxxxxxxxxxxx> - 0.2.1-1
+- Added to Vidalia Subversion repository
+
+* Mon Jun 01 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.13-2
+- Merge builds for fedora and epel
+
+* Mon Jun 01 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.13-1
+- Update to 0.1.13
+- Adjust to fedora and epel
+
+* Sun Apr 06 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.12-1
+- New upstream release
+- Correct typo in URL
+- Add R: hicolor for new handling of icons
+- Add update-icon-cache sniplet
+- Use summary of upstream for Desktopfile and in spec file
+- Create doxygen-documentations
+
+* Sun Feb 15 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.10-2
+- Correct Qt in Summary
+- Correct Qt in desktop-file-source
+- Add a german Translation in the desktop-file-source
+- Using CMAKE-macro instead of cmake
+- Add more files to more documentation
+
+* Tue Feb 10 2009 Simon Wesp <cassmodiah@xxxxxxxxxxxxxxxxx> - 0.1.10-1
+- Initial Package build

Deleted: vidalia/tags/vidalia-0.2.11/src/common/CMakeLists.txt
===================================================================
--- vidalia/trunk/src/common/CMakeLists.txt	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/src/common/CMakeLists.txt	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,46 +0,0 @@
-##
-##  $Id$
-## 
-##  This file is part of Vidalia, and is subject to the license terms in the
-##  LICENSE file, found in the top level directory of this distribution. If 
-##  you did not receive the LICENSE file with this file, you may obtain it
-##  from the Vidalia source package distributed by the Vidalia Project at
-##  http://www.vidalia-project.net/. No part of Vidalia, including this file,
-##  may be copied, modified, propagated, or distributed except according to
-##  the terms described in the LICENSE file.
-##
-
-
-set(common_SRCS
-  crypto.cpp
-  file.cpp
-  html.cpp
-  Log.cpp
-  net.cpp
-  procutil.cpp
-  stringutil.cpp
-  TorSocket.cpp
-  TorSslSocket.cpp
-)
-qt4_wrap_cpp(common_SRCS 
-  TorSocket.h
-  TorSslSocket.h
-)
-
-if(WIN32)
-  set(common_SRCS ${common_SRCS}
-    win32.cpp
-  )
-endif(WIN32)
-
-
-add_library(common STATIC ${common_SRCS})
-target_link_libraries(common
-  ${QT_QTCORE_LIBRARY}
-  ${QT_QTNETWORK_LIBRARY}
-)
-
-if(OPENSSL_LIBRARIES)
-  target_link_libraries(common ${OPENSSL_LIBRARIES})
-endif(OPENSSL_LIBRARIES)
-

Copied: vidalia/tags/vidalia-0.2.11/src/common/CMakeLists.txt (from rev 4533, vidalia/trunk/src/common/CMakeLists.txt)
===================================================================
--- vidalia/tags/vidalia-0.2.11/src/common/CMakeLists.txt	                        (rev 0)
+++ vidalia/tags/vidalia-0.2.11/src/common/CMakeLists.txt	2011-03-20 15:40:12 UTC (rev 4538)
@@ -0,0 +1,40 @@
+##
+##  $Id$
+## 
+##  This file is part of Vidalia, and is subject to the license terms in the
+##  LICENSE file, found in the top level directory of this distribution. If 
+##  you did not receive the LICENSE file with this file, you may obtain it
+##  from the Vidalia source package distributed by the Vidalia Project at
+##  http://www.vidalia-project.net/. No part of Vidalia, including this file,
+##  may be copied, modified, propagated, or distributed except according to
+##  the terms described in the LICENSE file.
+##
+
+
+set(common_SRCS
+  crypto.cpp
+  file.cpp
+  html.cpp
+  Log.cpp
+  net.cpp
+  procutil.cpp
+  stringutil.cpp
+  TorSocket.cpp
+)
+qt4_wrap_cpp(common_SRCS 
+  TorSocket.h
+)
+
+if(WIN32)
+  set(common_SRCS ${common_SRCS}
+    win32.cpp
+  )
+endif(WIN32)
+
+
+add_library(common STATIC ${common_SRCS})
+target_link_libraries(common
+  ${QT_QTCORE_LIBRARY}
+  ${QT_QTNETWORK_LIBRARY}
+)
+

Deleted: vidalia/tags/vidalia-0.2.11/src/common/TorSslSocket.cpp
===================================================================
--- vidalia/trunk/src/common/TorSslSocket.cpp	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/src/common/TorSslSocket.cpp	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,160 +0,0 @@
-/*
-**  This file is part of Vidalia, and is subject to the license terms in the
-**  LICENSE file, found in the top level directory of this distribution. If you
-**  did not receive the LICENSE file with this file, you may obtain it from the
-**  Vidalia source package distributed by the Vidalia Project at
-**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
-**  may be copied, modified, propagated, or distributed except according to the
-**  terms described in the LICENSE file.
-*/
-
-/*
-** \file TorSslSocket.cpp
-** \version $Id: /local/vidalia/trunk/src/util/torsocket.cpp 1564 2006-12-26T06:06:04.965088Z edmanm  $
-** \brief A QSslSocket that makes encrypted requests over Tor
-*/
-
-#include "TorSslSocket.h"
-
-#include <QDataStream>
-#include <QStringList>
-
-#define SOCKS_VERSION             0x04 /**< SOCKS version. */
-#define SOCKS_CONNECT             0x01 /**< SOCKS connect command ID. */
-#define SOCKS_FAKE_IP             0x00000001 /**< Bogus IP. */
-#define SOCKS_RESPONSE_LEN        0x08 /**< SOCKS server response length. */
-#define SOCKS_RESPONSE_VERSION    0x00 /**< SOCKS server response version. */
-#define SOCKS_CONNECT_STATUS_OK   0x5A /**< SOCKS server response status. */
-
-
-/** Constructor. */
-TorSslSocket::TorSslSocket(const QHostAddress &socksAddr,
-                           quint16 socksPort, QObject *parent)
-: QSslSocket(parent),
-  _socksAddr(socksAddr),
-  _socksPort(socksPort)
-{
-  QObject::connect(this, SIGNAL(sslErrors(QList<QSslError>)),
-                   this, SLOT(onSslErrors(QList<QSslError>)));
-  QObject::connect(this, SIGNAL(error(QAbstractSocket::SocketError)),
-                   this, SLOT(onError(QAbstractSocket::SocketError)));
-  QObject::connect(this, SIGNAL(readyRead()),
-                   this, SLOT(onHandshakeResponse()));
-  QObject::connect(this, SIGNAL(connected()),
-                   this, SLOT(connectedToProxy()));
-  QObject::connect(this, SIGNAL(encrypted()),
-                   this, SLOT(onEncrypted()));
-}
-
-/** Connects to the specified hostname and port via Tor. */
-void
-TorSslSocket::connectToRemoteHost(const QString &remoteHost, quint16 remotePort,
-                                  bool encrypted)
-{
-  _remoteHost = remoteHost;
-  _remotePort = remotePort;
-  _encrypted  = encrypted;
-  QTcpSocket::connectToHost(_socksAddr, _socksPort);
-}
-
-/** Called when a connection error has occurred. */
-void
-TorSslSocket::onError(QAbstractSocket::SocketError error)
-{
-  Q_UNUSED(error);
-  emit socketError(errorString());
-}
-
-/** Called when one or more SSL errors occur on the socket. */
-void
-TorSslSocket::onSslErrors(const QList<QSslError> &errors)
-{
-  QStringList errorStrings;
-  foreach (QSslError error, errors) {
-    errorStrings << "\"" + error.errorString() + "\"";
-  }
-  emit socketError(errorStrings.join(","));
-}
-
-/** Called when a connection has been established to the proxy host and starts
- * a Socks4a handshake. */
-void
-TorSslSocket::connectedToProxy()
-{
-  sendSocksHandshake(_remoteHost, _remotePort);
-}
-
-/** Called when an encrypted connection has been established to the remote
- * host. */
-void
-TorSslSocket::onEncrypted()
-{
-  emit connectedToRemoteHost();
-}
-
-/** Sends the first part of a Socks4a handshake, using the remote hostname and
- * port specified in the previous call to connectToHost(). The message should
- * be formatted as follows:
- *
- *   0x04                 (socks version)
- *   0x01                 (connect)
- *   PORT                 (two bytes, most significant byte first)
- *   0x00 0x00 0x00 0x01  (fake IP address: tells proxy to use SOCKS4a)
- *   0x00                 (empty username field)
- *   HOSTNAME             (target hostname)
- *   0x00                 (marks the end of the hostname field)
- */
-void
-TorSslSocket::sendSocksHandshake(const QString &remoteHost, quint16 remotePort)
-{
-  QDataStream sock(this);
-  sock << (quint8)SOCKS_VERSION;
-  sock << (quint8)SOCKS_CONNECT;
-  sock << (quint16)remotePort;
-  sock << (quint32)SOCKS_FAKE_IP;
-  sock << (quint8)0;
-  sock.writeRawData(qPrintable(remoteHost), remoteHost.length());
-  sock << (quint8)0;
-}
-
-/** Handles the second half of the handshake, received from the SOCKS 
- * proxy server. The response should be formatted as follows: 
- * 
- *    0x00                 (response version)
- *    STATUS               (0x5A means success; other values mean failure)
- *    PORT                 (not set)
- *    ADDRESS              (not set)
- */
-void
-TorSslSocket::onHandshakeResponse()
-{
-  QByteArray response;
-  if (bytesAvailable() >= SOCKS_RESPONSE_LEN) {
-    /* We've received our response, so stop waiting for it. */
-    QObject::disconnect(this, SIGNAL(readyRead()),
-                        this, SLOT(onHandshakeResponse()));
-    
-    /* Read the 8-byte response off the socket. */
-    response = read(SOCKS_RESPONSE_LEN);
-    
-    /* Check to make sure we got a good response from the proxy. */
-    if ((uchar)response[0] == (uchar)SOCKS_RESPONSE_VERSION &&
-        (uchar)response[1] == (uchar)SOCKS_CONNECT_STATUS_OK) {
-      if (_encrypted) {
-        /* Connection status was okay, so start client encryption. */
-        /* We first need to set the peer name to the intended remote host,
-         * otherwise Qt will use the proxy (e.g., 127.0.0.1) as the peer name
-         * when validating the server certificate. */
-        setPeerName(_remoteHost);
-        startClientEncryption();
-      } else {
-        /* Caller wanted an unencrypted, unauthenticated, uncool conn. */
-        emit connectedToRemoteHost();
-      }
-    } else {
-      /* Remote connection failed, so close the connection to the proxy. */
-      disconnectFromHost();
-    }
-  }
-}
-

Deleted: vidalia/tags/vidalia-0.2.11/src/common/TorSslSocket.h
===================================================================
--- vidalia/trunk/src/common/TorSslSocket.h	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/src/common/TorSslSocket.h	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,71 +0,0 @@
-/*
-**  This file is part of Vidalia, and is subject to the license terms in the
-**  LICENSE file, found in the top level directory of this distribution. If you
-**  did not receive the LICENSE file with this file, you may obtain it from the
-**  Vidalia source package distributed by the Vidalia Project at
-**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
-**  may be copied, modified, propagated, or distributed except according to the
-**  terms described in the LICENSE file.
-*/
-
-/*
-** \file TorSslSocket.h
-** \version $Id: /local/vidalia/trunk/src/util/torsocket.h 1564 2006-12-26T06:06:04.965088Z edmanm  $
-** \brief A QSslSocket that makes encrypted requests over Tor
-*/
-
-#ifndef _TORSSLSOCKET_H
-#define _TORSSLSOCKET_H
-
-#include <QSslSocket>
-#include <QHostAddress>
-
-
-class TorSslSocket : public QSslSocket
-{
-  Q_OBJECT
-  
-public:
-  /** Constructor. */
-  TorSslSocket(const QHostAddress &socksAddr,
-               quint16 socksPort, QObject *parent = 0);
-
-  /** Connects to the specified hostname and port via Tor. */
-  void connectToRemoteHost(const QString &remoteHost, quint16 remotePort,
-                           bool encrypted);
-
-signals:
-  /** Emitted when a connection has been established through Tor to the remote
-   * host specified in a prior call to connectToHost(). */
-  void connectedToRemoteHost();
-  /** Emitted when a connection error has occurred. */
-  void socketError(QString errmsg);
-    
-private slots:
-  /** Called when the socket is connected to the proxy and sends our
-   * half of a Socks4a handshake. */
-  void connectedToProxy();
-  /** Called when an encrypted connection has been established to the remote
-   * host. */
-  void onEncrypted();
-  /** Handles the server's response part of a Socks4a handshake. */
-  void onHandshakeResponse();
-  /** Called when a connection error has occurred. */
-  void onError(QAbstractSocket::SocketError error);
-  /** Called when one or more SSL errors occur on the socket. */
-  void onSslErrors(const QList<QSslError> &errors);
-  
-private:
-  /** Sends the client part of a Socks4a handshake with a proxy server. */
-  void sendSocksHandshake(const QString &remoteHost, quint16 remotePort);
-  
-  QHostAddress _socksAddr; /**< Address of Tor's SOCKS listener. */
-  QString _remoteHost;     /**< Remote hostname. */
-  quint16 _socksPort;      /**< Port of Tor's SOCKS listener. */
-  quint16 _remotePort;     /**< Remote host port. */
-  bool    _encrypted;      /**< Set to true if the connection to the remote
-                                host should be encrypted. */
-};
-
-#endif
-

Deleted: vidalia/tags/vidalia-0.2.11/src/miniupnpc/connecthostport.c
===================================================================
--- vidalia/trunk/src/miniupnpc/connecthostport.c	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/src/miniupnpc/connecthostport.c	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,221 +0,0 @@
-/* $Id: connecthostport.c,v 1.2 2010/04/05 00:08:15 nanard Exp $ */
-/* Project : miniupnp
- * Author : Thomas Bernard
- * Copyright (c) 2010 Thomas Bernard
- * This software is subject to the conditions detailed in the
- * LICENCE file provided in this distribution. */
-
-/* use getaddrinfo() or gethostbyname()
- * uncomment the following line in order to use gethostbyname() */
-/* #define USE_GETHOSTBYNAME */
-
-#include <string.h>
-#include <stdio.h>
-#ifdef WIN32
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#include <io.h>
-#define snprintf _snprintf
-#define herror
-#define socklen_t int
-#else /* #ifdef WIN32 */
-#include <unistd.h>
-#include <errno.h>
-#define closesocket close
-#include <netdb.h>
-/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions
- * during the connect() call */
-#define MINIUPNPC_IGNORE_EINTR
-#ifndef USE_GETHOSTBYNAME
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* #ifndef USE_GETHOSTBYNAME */
-#endif /* #else WIN32 */
-
-/* definition of PRINT_SOCKET_ERROR */
-#ifdef WIN32
-#define PRINT_SOCKET_ERROR(x)    printf("Socket error: %s, %d\n", x, WSAGetLastError());
-#else
-#define PRINT_SOCKET_ERROR(x) perror(x)
-#endif
-
-#if defined(__amigaos__) || defined(__amigaos4__)
-#define herror(A) printf("%s\n", A)
-#endif
-
-#include "connecthostport.h"
-
-/* connecthostport()
- * return a socket connected (TCP) to the host and port
- * or -1 in case of error */
-int connecthostport(const char * host, unsigned short port)
-{
-	int s, n;
-#ifdef USE_GETHOSTBYNAME
-	struct sockaddr_in dest;
-	struct hostent *hp;
-#else /* #ifdef USE_GETHOSTBYNAME */
-	char port_str[8];
-	struct addrinfo *ai, *p;
-	struct addrinfo hints;
-#endif /* #ifdef USE_GETHOSTBYNAME */
-#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
-	struct timeval timeout;
-#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
-	
-#ifdef USE_GETHOSTBYNAME
-	hp = gethostbyname(host);
-	if(hp == NULL)
-	{
-		herror(host);
-		return -1;
-	}
-	memcpy(&dest.sin_addr, hp->h_addr, sizeof(dest.sin_addr));
-	memset(dest.sin_zero, 0, sizeof(dest.sin_zero));
-	s = socket(PF_INET, SOCK_STREAM, 0);
-	if(s < 0)
-	{
-		PRINT_SOCKET_ERROR("socket");
-		return -1;
-	}
-#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
-	/* setting a 3 seconds timeout for the connect() call */
-	timeout.tv_sec = 3;
-	timeout.tv_usec = 0;
-	if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0)
-	{
-		PRINT_SOCKET_ERROR("setsockopt");
-	}
-	timeout.tv_sec = 3;
-	timeout.tv_usec = 0;
-	if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
-	{
-		PRINT_SOCKET_ERROR("setsockopt");
-	}
-#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
-	dest.sin_family = AF_INET;
-	dest.sin_port = htons(port);
-	n = connect(s, (struct sockaddr *)&dest, sizeof(struct sockaddr_in));
-#ifdef MINIUPNPC_IGNORE_EINTR
-	while(n < 0 && errno == EINTR)
-	{
-		socklen_t len;
-		fd_set wset;
-		int err;
-		FD_ZERO(&wset);
-		FD_SET(s, &wset);
-		if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR)
-			continue;
-		/*len = 0;*/
-		/*n = getpeername(s, NULL, &len);*/
-		len = sizeof(err);
-		if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
-			PRINT_SOCKET_ERROR("getsockopt");
-			closesocket(s);
-			return -1;
-		}
-		if(err != 0) {
-			errno = err;
-			n = -1;
-		}
-	}
-#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */
-	if(n<0)
-	{
-		PRINT_SOCKET_ERROR("connect");
-		closesocket(s);
-		return -1;
-	}
-#else /* #ifdef USE_GETHOSTBYNAME */
-	/* use getaddrinfo() instead of gethostbyname() */
-	memset(&hints, 0, sizeof(hints));
-	/* hints.ai_flags = AI_ADDRCONFIG; */
-#ifdef AI_NUMERICSERV
-	hints.ai_flags = AI_NUMERICSERV;
-#endif
-	hints.ai_socktype = SOCK_STREAM;
-	hints.ai_family = AF_UNSPEC; /* AF_INET, AF_INET6 or AF_UNSPEC */
-	/* hints.ai_protocol = IPPROTO_TCP; */
-	snprintf(port_str, sizeof(port_str), "%hu", port);
-	n = getaddrinfo(host, port_str, &hints, &ai);
-	if(n != 0)
-	{
-#ifdef WIN32
-		fprintf(stderr, "getaddrinfo() error : %d\n", n);
-#else
-		fprintf(stderr, "getaddrinfo() error : %s\n", gai_strerror(n));
-#endif
-		return -1;
-	}
-	s = -1;
-	for(p = ai; p; p = p->ai_next)
-	{
-		s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
-		if(s < 0)
-			continue;
-#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
-		/* setting a 3 seconds timeout for the connect() call */
-		timeout.tv_sec = 3;
-		timeout.tv_usec = 0;
-		if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0)
-		{
-			PRINT_SOCKET_ERROR("setsockopt");
-		}
-		timeout.tv_sec = 3;
-		timeout.tv_usec = 0;
-		if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
-		{
-			PRINT_SOCKET_ERROR("setsockopt");
-		}
-#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
-		n = connect(s, p->ai_addr, p->ai_addrlen);
-#ifdef MINIUPNPC_IGNORE_EINTR
-		while(n < 0 && errno == EINTR)
-		{
-			socklen_t len;
-			fd_set wset;
-			int err;
-			FD_ZERO(&wset);
-			FD_SET(s, &wset);
-			if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR)
-				continue;
-			/*len = 0;*/
-			/*n = getpeername(s, NULL, &len);*/
-			len = sizeof(err);
-			if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
-				PRINT_SOCKET_ERROR("getsockopt");
-				closesocket(s);
-				freeaddrinfo(ai);
-				return -1;
-			}
-			if(err != 0) {
-				errno = err;
-				n = -1;
-			}
-		}
-#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */
-		if(n < 0)
-		{
-			closesocket(s);
-			continue;
-		}
-		else
-		{
-			break;
-		}
-	}
-	freeaddrinfo(ai);
-	if(s < 0)
-	{
-		PRINT_SOCKET_ERROR("socket");
-		return -1;
-	}
-	if(n < 0)
-	{
-		PRINT_SOCKET_ERROR("connect");
-		return -1;
-	}
-#endif /* #ifdef USE_GETHOSTBYNAME */
-	return s;
-}
-

Copied: vidalia/tags/vidalia-0.2.11/src/miniupnpc/connecthostport.c (from rev 4535, vidalia/trunk/src/miniupnpc/connecthostport.c)
===================================================================
--- vidalia/tags/vidalia-0.2.11/src/miniupnpc/connecthostport.c	                        (rev 0)
+++ vidalia/tags/vidalia-0.2.11/src/miniupnpc/connecthostport.c	2011-03-20 15:40:12 UTC (rev 4538)
@@ -0,0 +1,225 @@
+/* $Id: connecthostport.c,v 1.2 2010/04/05 00:08:15 nanard Exp $ */
+/* Project : miniupnp
+ * Author : Thomas Bernard
+ * Copyright (c) 2010 Thomas Bernard
+ * This software is subject to the conditions detailed in the
+ * LICENCE file provided in this distribution. */
+
+/* use getaddrinfo() or gethostbyname()
+ * uncomment the following line in order to use gethostbyname() */
+/* #define USE_GETHOSTBYNAME */
+
+#include <string.h>
+#include <stdio.h>
+#ifdef WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#ifdef WIN2K
+#  define __inline static inline
+#  include <wspiapi.h>
+#endif
+#include <io.h>
+#define snprintf _snprintf
+#define herror
+#define socklen_t int
+#else /* #ifdef WIN32 */
+#include <unistd.h>
+#include <errno.h>
+#define closesocket close
+#include <netdb.h>
+/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions
+ * during the connect() call */
+#define MINIUPNPC_IGNORE_EINTR
+#ifndef USE_GETHOSTBYNAME
+#include <sys/types.h>
+#include <sys/socket.h>
+#endif /* #ifndef USE_GETHOSTBYNAME */
+#endif /* #else WIN32 */
+
+/* definition of PRINT_SOCKET_ERROR */
+#ifdef WIN32
+#define PRINT_SOCKET_ERROR(x)    printf("Socket error: %s, %d\n", x, WSAGetLastError());
+#else
+#define PRINT_SOCKET_ERROR(x) perror(x)
+#endif
+
+#if defined(__amigaos__) || defined(__amigaos4__)
+#define herror(A) printf("%s\n", A)
+#endif
+
+#include "connecthostport.h"
+
+/* connecthostport()
+ * return a socket connected (TCP) to the host and port
+ * or -1 in case of error */
+int connecthostport(const char * host, unsigned short port)
+{
+	int s, n;
+#ifdef USE_GETHOSTBYNAME
+	struct sockaddr_in dest;
+	struct hostent *hp;
+#else /* #ifdef USE_GETHOSTBYNAME */
+	char port_str[8];
+	struct addrinfo *ai, *p;
+	struct addrinfo hints;
+#endif /* #ifdef USE_GETHOSTBYNAME */
+#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
+	struct timeval timeout;
+#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
+	
+#ifdef USE_GETHOSTBYNAME
+	hp = gethostbyname(host);
+	if(hp == NULL)
+	{
+		herror(host);
+		return -1;
+	}
+	memcpy(&dest.sin_addr, hp->h_addr, sizeof(dest.sin_addr));
+	memset(dest.sin_zero, 0, sizeof(dest.sin_zero));
+	s = socket(PF_INET, SOCK_STREAM, 0);
+	if(s < 0)
+	{
+		PRINT_SOCKET_ERROR("socket");
+		return -1;
+	}
+#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
+	/* setting a 3 seconds timeout for the connect() call */
+	timeout.tv_sec = 3;
+	timeout.tv_usec = 0;
+	if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0)
+	{
+		PRINT_SOCKET_ERROR("setsockopt");
+	}
+	timeout.tv_sec = 3;
+	timeout.tv_usec = 0;
+	if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
+	{
+		PRINT_SOCKET_ERROR("setsockopt");
+	}
+#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
+	dest.sin_family = AF_INET;
+	dest.sin_port = htons(port);
+	n = connect(s, (struct sockaddr *)&dest, sizeof(struct sockaddr_in));
+#ifdef MINIUPNPC_IGNORE_EINTR
+	while(n < 0 && errno == EINTR)
+	{
+		socklen_t len;
+		fd_set wset;
+		int err;
+		FD_ZERO(&wset);
+		FD_SET(s, &wset);
+		if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR)
+			continue;
+		/*len = 0;*/
+		/*n = getpeername(s, NULL, &len);*/
+		len = sizeof(err);
+		if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
+			PRINT_SOCKET_ERROR("getsockopt");
+			closesocket(s);
+			return -1;
+		}
+		if(err != 0) {
+			errno = err;
+			n = -1;
+		}
+	}
+#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */
+	if(n<0)
+	{
+		PRINT_SOCKET_ERROR("connect");
+		closesocket(s);
+		return -1;
+	}
+#else /* #ifdef USE_GETHOSTBYNAME */
+	/* use getaddrinfo() instead of gethostbyname() */
+	memset(&hints, 0, sizeof(hints));
+	/* hints.ai_flags = AI_ADDRCONFIG; */
+#ifdef AI_NUMERICSERV
+	hints.ai_flags = AI_NUMERICSERV;
+#endif
+	hints.ai_socktype = SOCK_STREAM;
+	hints.ai_family = AF_UNSPEC; /* AF_INET, AF_INET6 or AF_UNSPEC */
+	/* hints.ai_protocol = IPPROTO_TCP; */
+	snprintf(port_str, sizeof(port_str), "%hu", port);
+	n = getaddrinfo(host, port_str, &hints, &ai);
+	if(n != 0)
+	{
+#ifdef WIN32
+		fprintf(stderr, "getaddrinfo() error : %d\n", n);
+#else
+		fprintf(stderr, "getaddrinfo() error : %s\n", gai_strerror(n));
+#endif
+		return -1;
+	}
+	s = -1;
+	for(p = ai; p; p = p->ai_next)
+	{
+		s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
+		if(s < 0)
+			continue;
+#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
+		/* setting a 3 seconds timeout for the connect() call */
+		timeout.tv_sec = 3;
+		timeout.tv_usec = 0;
+		if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0)
+		{
+			PRINT_SOCKET_ERROR("setsockopt");
+		}
+		timeout.tv_sec = 3;
+		timeout.tv_usec = 0;
+		if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0)
+		{
+			PRINT_SOCKET_ERROR("setsockopt");
+		}
+#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */
+		n = connect(s, p->ai_addr, p->ai_addrlen);
+#ifdef MINIUPNPC_IGNORE_EINTR
+		while(n < 0 && errno == EINTR)
+		{
+			socklen_t len;
+			fd_set wset;
+			int err;
+			FD_ZERO(&wset);
+			FD_SET(s, &wset);
+			if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR)
+				continue;
+			/*len = 0;*/
+			/*n = getpeername(s, NULL, &len);*/
+			len = sizeof(err);
+			if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
+				PRINT_SOCKET_ERROR("getsockopt");
+				closesocket(s);
+				freeaddrinfo(ai);
+				return -1;
+			}
+			if(err != 0) {
+				errno = err;
+				n = -1;
+			}
+		}
+#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */
+		if(n < 0)
+		{
+			closesocket(s);
+			continue;
+		}
+		else
+		{
+			break;
+		}
+	}
+	freeaddrinfo(ai);
+	if(s < 0)
+	{
+		PRINT_SOCKET_ERROR("socket");
+		return -1;
+	}
+	if(n < 0)
+	{
+		PRINT_SOCKET_ERROR("connect");
+		return -1;
+	}
+#endif /* #ifdef USE_GETHOSTBYNAME */
+	return s;
+}
+

Deleted: vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniupnpc.c
===================================================================
--- vidalia/trunk/src/miniupnpc/miniupnpc.c	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniupnpc.c	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,892 +0,0 @@
-/* $Id: miniupnpc.c,v 1.78 2010/04/05 20:36:59 nanard Exp $ */
-/* Project : miniupnp
- * Author : Thomas BERNARD
- * copyright (c) 2005-2010 Thomas Bernard
- * This software is subjet to the conditions detailed in the
- * provided LICENSE file. */
-#define __EXTENSIONS__ 1
-#if !defined(MACOSX) && !defined(__sun)
-#if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__)
-#ifndef __cplusplus
-#define _XOPEN_SOURCE 600
-#endif
-#endif
-#ifndef __BSD_VISIBLE
-#define __BSD_VISIBLE 1
-#endif
-#endif
-
-#ifdef __APPLE__
-#define _DARWIN_C_SOURCE
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef WIN32
-/* Win32 Specific includes and defines */
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#include <io.h>
-/*#include <IPHlpApi.h>*/
-#define snprintf _snprintf
-#if defined(_MSC_VER) && (_MSC_VER >= 1400)
-#define strncasecmp _memicmp
-#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
-#define strncasecmp memicmp
-#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
-#define MAXHOSTNAMELEN 64
-#else /* #ifdef WIN32 */
-/* Standard POSIX includes */
-#include <unistd.h>
-#if defined(__amigaos__) && !defined(__amigaos4__)
-/* Amiga OS 3 specific stuff */
-#define socklen_t int
-#else
-#include <sys/select.h>
-#endif
-#if defined(__APPLE__)
-#undef _POSIX_C_SOURCE
-#endif
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#if !defined(__amigaos__) && !defined(__amigaos4__)
-#include <poll.h>
-#endif
-#include <strings.h>
-#include <errno.h>
-#define closesocket close
-#define MINIUPNPC_IGNORE_EINTR
-#endif /* #else WIN32 */
-#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
-#include <sys/time.h>
-#endif
-#if defined(__amigaos__) || defined(__amigaos4__)
-/* Amiga OS specific stuff */
-#define TIMEVAL struct timeval
-#endif
-
-#include "miniupnpc.h"
-#include "minissdpc.h"
-#include "miniwget.h"
-#include "minisoap.h"
-#include "minixml.h"
-#include "upnpcommands.h"
-#include "connecthostport.h"
-
-#ifdef WIN32
-#define PRINT_SOCKET_ERROR(x)    printf("Socket error: %s, %d\n", x, WSAGetLastError());
-#else
-#define PRINT_SOCKET_ERROR(x) perror(x)
-#endif
-
-#define SOAPPREFIX "s"
-#define SERVICEPREFIX "u"
-#define SERVICEPREFIX2 'u'
-
-/* root description parsing */
-LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data)
-{
-	struct xmlparser parser;
-	/* xmlparser object */
-	parser.xmlstart = buffer;
-	parser.xmlsize = bufsize;
-	parser.data = data;
-	parser.starteltfunc = IGDstartelt;
-	parser.endeltfunc = IGDendelt;
-	parser.datafunc = IGDdata;
-	parser.attfunc = 0;
-	parsexml(&parser);
-#ifdef DEBUG
-	printIGD(data);
-#endif
-}
-
-/* getcontentlenfromline() : parse the Content-Length HTTP header line.
- * Content-length: nnn */
-static int getcontentlenfromline(const char * p, int n)
-{
-	static const char contlenstr[] = "content-length";
-	const char * p2 = contlenstr;
-	int a = 0;
-	while(*p2)
-	{
-		if(n==0)
-			return -1;
-		if(*p2 != *p && *p2 != (*p + 32))
-			return -1;
-		p++; p2++; n--;
-	}
-	if(n==0)
-		return -1;
-	if(*p != ':')
-		return -1;
-	p++; n--;
-	while(*p == ' ')
-	{
-		if(n==0)
-			return -1;
-		p++; n--;
-	}
-	while(*p >= '0' && *p <= '9')
-	{
-		if(n==0)
-			return -1;
-		a = (a * 10) + (*p - '0');
-		p++; n--;
-	}
-	return a;
-}
-
-/* getContentLengthAndHeaderLength()
- * retrieve header length and content length from an HTTP response
- * TODO : retrieve Transfer-Encoding: header value, in order to support
- *        HTTP/1.1, chunked transfer encoding must be supported. */
-static void
-getContentLengthAndHeaderLength(char * p, int n,
-                                int * contentlen, int * headerlen)
-{
-	char * line;
-	int linelen;
-	int r;
-	line = p;
-	while(line < p + n)
-	{
-		linelen = 0;
-		while(line[linelen] != '\r' && line[linelen] != '\r')
-		{
-			if(line+linelen >= p+n)
-				return;
-			linelen++;
-		}
-		r = getcontentlenfromline(line, linelen);
-		if(r>0)
-			*contentlen = r;
-		line = line + linelen + 2;
-		if(line[0] == '\r' && line[1] == '\n')
-		{
-			*headerlen = (line - p) + 2;
-			return;
-		}
-	}
-}
-
-/* simpleUPnPcommand :
- * not so simple !
- * return values :
- *   0 - OK
- *  -1 - error */
-int simpleUPnPcommand(int s, const char * url, const char * service,
-                      const char * action, struct UPNParg * args,
-                      char * buffer, int * bufsize)
-{
-	char hostname[MAXHOSTNAMELEN+1];
-	unsigned short port = 0;
-	char * path;
-	char soapact[128];
-	char soapbody[2048];
-	char * buf;
-	int buffree;
-    int n;
-	int contentlen, headerlen;	/* for the response */
-
-	snprintf(soapact, sizeof(soapact), "%s#%s", service, action);
-	if(args==NULL)
-	{
-		/*soapbodylen = */snprintf(soapbody, sizeof(soapbody),
-						"<?xml version=\"1.0\"?>\r\n"
-	    	              "<" SOAPPREFIX ":Envelope "
-						  "xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\"; "
-						  SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\";>"
-						  "<" SOAPPREFIX ":Body>"
-						  "<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">"
-						  "</" SERVICEPREFIX ":%s>"
-						  "</" SOAPPREFIX ":Body></" SOAPPREFIX ":Envelope>"
-					 	  "\r\n", action, service, action);
-	}
-	else
-	{
-		char * p;
-		const char * pe, * pv;
-		int soapbodylen;
-		soapbodylen = snprintf(soapbody, sizeof(soapbody),
-						"<?xml version=\"1.0\"?>\r\n"
-	    	            "<" SOAPPREFIX ":Envelope "
-						"xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\"; "
-						SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\";>"
-						"<" SOAPPREFIX ":Body>"
-						"<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">",
-						action, service);
-		p = soapbody + soapbodylen;
-		while(args->elt)
-		{
-			/* check that we are never overflowing the string... */
-			if(soapbody + sizeof(soapbody) <= p + 100)
-			{
-				/* we keep a margin of at least 100 bytes */
-				*bufsize = 0;
-				return -1;
-			}
-			*(p++) = '<';
-			pe = args->elt;
-			while(*pe)
-				*(p++) = *(pe++);
-			*(p++) = '>';
-			if((pv = args->val))
-			{
-				while(*pv)
-					*(p++) = *(pv++);
-			}
-			*(p++) = '<';
-			*(p++) = '/';
-			pe = args->elt;
-			while(*pe)
-				*(p++) = *(pe++);
-			*(p++) = '>';
-			args++;
-		}
-		*(p++) = '<';
-		*(p++) = '/';
-		*(p++) = SERVICEPREFIX2;
-		*(p++) = ':';
-		pe = action;
-		while(*pe)
-			*(p++) = *(pe++);
-		strncpy(p, "></" SOAPPREFIX ":Body></" SOAPPREFIX ":Envelope>\r\n",
-		        soapbody + sizeof(soapbody) - p);
-	}
-	if(!parseURL(url, hostname, &port, &path)) return -1;
-	if(s<0)
-	{
-		s = connecthostport(hostname, port);
-		if(s < 0)
-		{
-			*bufsize = 0;
-			return -1;
-		}
-	}
-
-	n = soapPostSubmit(s, path, hostname, port, soapact, soapbody);
-	if(n<=0) {
-#ifdef DEBUG
-		printf("Error sending SOAP request\n");
-#endif
-		closesocket(s);
-		return -1;
-	}
-
-	contentlen = -1;
-	headerlen = -1;
-	buf = buffer;
-	buffree = *bufsize;
-	*bufsize = 0;
-	while ((n = ReceiveData(s, buf, buffree, 5000)) > 0) {
-		buffree -= n;
-		buf += n;
-		*bufsize += n;
-		getContentLengthAndHeaderLength(buffer, *bufsize,
-		                                &contentlen, &headerlen);
-#ifdef DEBUG
-		printf("received n=%dbytes bufsize=%d ContLen=%d HeadLen=%d\n",
-		       n, *bufsize, contentlen, headerlen);
-#endif
-		/* break if we received everything */
-		if(contentlen > 0 && headerlen > 0 && *bufsize >= contentlen+headerlen)
-			break;
-	}
-	
-	closesocket(s);
-	return 0;
-}
-
-/* parseMSEARCHReply()
- * the last 4 arguments are filled during the parsing :
- *    - location/locationsize : "location:" field of the SSDP reply packet
- *    - st/stsize : "st:" field of the SSDP reply packet.
- * The strings are NOT null terminated */
-static void
-parseMSEARCHReply(const char * reply, int size,
-                  const char * * location, int * locationsize,
-			      const char * * st, int * stsize)
-{
-	int a, b, i;
-	i = 0;
-	a = i;	/* start of the line */
-	b = 0;
-	while(i<size)
-	{
-		switch(reply[i])
-		{
-		case ':':
-				if(b==0)
-				{
-					b = i; /* end of the "header" */
-					/*for(j=a; j<b; j++)
-					{
-						putchar(reply[j]);
-					}
-					*/
-				}
-				break;
-		case '\x0a':
-		case '\x0d':
-				if(b!=0)
-				{
-					/*for(j=b+1; j<i; j++)
-					{
-						putchar(reply[j]);
-					}
-					putchar('\n');*/
-					do { b++; } while(reply[b]==' ');
-					if(0==strncasecmp(reply+a, "location", 8))
-					{
-						*location = reply+b;
-						*locationsize = i-b;
-					}
-					else if(0==strncasecmp(reply+a, "st", 2))
-					{
-						*st = reply+b;
-						*stsize = i-b;
-					}
-					b = 0;
-				}
-				a = i+1;
-				break;
-		default:
-				break;
-		}
-		i++;
-	}
-}
-
-/* port upnp discover : SSDP protocol */
-#define PORT 1900
-#define XSTR(s) STR(s)
-#define STR(s) #s
-#define UPNP_MCAST_ADDR "239.255.255.250"
-
-/* upnpDiscover() :
- * return a chained list of all devices found or NULL if
- * no devices was found.
- * It is up to the caller to free the chained list
- * delay is in millisecond (poll) */
-LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
-                              const char * minissdpdsock, int sameport)
-{
-	struct UPNPDev * tmp;
-	struct UPNPDev * devlist = 0;
-	int opt = 1;
-	static const char MSearchMsgFmt[] = 
-	"M-SEARCH * HTTP/1.1\r\n"
-	"HOST: " UPNP_MCAST_ADDR ":" XSTR(PORT) "\r\n"
-	"ST: %s\r\n"
-	"MAN: \"ssdp:discover\"\r\n"
-	"MX: %u\r\n"
-	"\r\n";
-	static const char * const deviceList[] = {
-		"urn:schemas-upnp-org:device:InternetGatewayDevice:1",
-		"urn:schemas-upnp-org:service:WANIPConnection:1",
-		"urn:schemas-upnp-org:service:WANPPPConnection:1",
-		"upnp:rootdevice",
-		0
-	};
-	int deviceIndex = 0;
-	char bufr[1536];	/* reception and emission buffer */
-	int sudp;
-	int n;
-	struct sockaddr sockudp_r;
-	unsigned int mx;
-	int rv;
-	struct addrinfo hints, *servinfo, *p;
-#ifdef WIN32
-	/*MIB_IPFORWARDROW ip_forward;*/
-#endif
-
-#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
-	/* first try to get infos from minissdpd ! */
-	if(!minissdpdsock)
-		minissdpdsock = "/var/run/minissdpd.sock";
-	while(!devlist && deviceList[deviceIndex]) {
-		devlist = getDevicesFromMiniSSDPD(deviceList[deviceIndex],
-		                                  minissdpdsock);
-		/* We return what we have found if it was not only a rootdevice */
-		if(devlist && !strstr(deviceList[deviceIndex], "rootdevice"))
-			return devlist;
-		deviceIndex++;
-	}
-	deviceIndex = 0;
-#endif
-	/* fallback to direct discovery */
-#ifdef WIN32
-	sudp = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
-#else
-	sudp = socket(PF_INET, SOCK_DGRAM, 0);
-#endif
-	if(sudp < 0)
-	{
-		PRINT_SOCKET_ERROR("socket");
-		return NULL;
-	}
-	/* reception */
-	memset(&sockudp_r, 0, sizeof(struct sockaddr));
-	if(0/*ipv6*/) {
-		struct sockaddr_in6 * p = (struct sockaddr_in6 *)&sockudp_r;
-		p->sin6_family = AF_INET6;
-		if(sameport)
-			p->sin6_port = htons(PORT);
-		p->sin6_addr = in6addr_any;//IN6ADDR_ANY_INIT;/*INADDR_ANY;*/
-	} else {
-		struct sockaddr_in * p = (struct sockaddr_in *)&sockudp_r;
-		p->sin_family = AF_INET;
-		if(sameport)
-			p->sin_port = htons(PORT);
-		p->sin_addr.s_addr = INADDR_ANY;
-	}
-#if 0
-	/* emission */
-	memset(&sockudp_w, 0, sizeof(struct sockaddr_in));
-	sockudp_w.sin_family = AF_INET;
-	sockudp_w.sin_port = htons(PORT);
-	sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);
-#endif
-#ifdef WIN32
-/* This code could help us to use the right Network interface for 
- * SSDP multicast traffic */
-/* TODO : Get IP associated with the index given in the ip_forward struct
- * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */
- /*
-	if(GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) == NO_ERROR) {
-		DWORD dwRetVal = 0;
-		PMIB_IPADDRTABLE pIPAddrTable;
-    DWORD dwSize = 0;
-    IN_ADDR IPAddr;
-    int i;
-    printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop);
-    pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE));
-    if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
-	    free(pIPAddrTable);
-      pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize);
-    }
-    if(pIPAddrTable) {
-    	dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 );
-    	printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries);
-    	for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) {
-        printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex);
-        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr;
-        printf("\tIP Address[%d]:     \t%s\n", i, inet_ntoa(IPAddr) );
-        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask;
-        printf("\tSubnet Mask[%d]:    \t%s\n", i, inet_ntoa(IPAddr) );
-        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr;
-        printf("\tBroadCast[%d]:      \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr);
-        printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize);
-        printf("\tType and State[%d]:", i);
-        printf("\n");
-    	}
-			free(pIPAddrTable);
-    	pIPAddrTable = NULL;
-    }
-	}
-*/
-#endif
-
-#ifdef WIN32
-	if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof (opt)) < 0)
-#else
-	if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt)) < 0)
-#endif
-	{
-		PRINT_SOCKET_ERROR("setsockopt");
-		return NULL;
-	}
-
-	if(multicastif)
-	{
-		struct in_addr mc_if;
-		mc_if.s_addr = inet_addr(multicastif);
-		if(0/*ipv6*/) {
-		} else {
-			((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr;
-		}
-		if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0)
-		{
-			PRINT_SOCKET_ERROR("setsockopt");
-		}
-	}
-
-	/* Avant d'envoyer le paquet on bind pour recevoir la reponse */
-    if (bind(sudp, &sockudp_r, 0/*ipv6*/?sizeof(struct sockaddr_in6):sizeof(struct sockaddr_in)) != 0)
-	{
-        PRINT_SOCKET_ERROR("bind");
-		closesocket(sudp);
-		return NULL;
-    }
-
-	/* Calculating maximum response time in seconds */
-	mx = ((unsigned int)delay) / 1000u;
-	/* receiving SSDP response packet */
-	for(n = 0;;)
-	{
-	if(n == 0)
-	{
-		/* sending the SSDP M-SEARCH packet */
-		n = snprintf(bufr, sizeof(bufr),
-		             MSearchMsgFmt, deviceList[deviceIndex++], mx);
-		/*printf("Sending %s", bufr);*/
-#if 0
-		n = sendto(sudp, bufr, n, 0,
-		           (struct sockaddr *)&sockudp_w, sizeof(struct sockaddr_in));
-		if (n < 0) {
-			PRINT_SOCKET_ERROR("sendto");
-			closesocket(sudp);
-			return devlist;
-		}
-#endif
-		memset(&hints, 0, sizeof(hints));
-		hints.ai_family = AF_UNSPEC; // AF_INET6 or AF_INET
-		hints.ai_socktype = SOCK_DGRAM;
-		/*hints.ai_flags = */
-		if ((rv = getaddrinfo(UPNP_MCAST_ADDR, XSTR(PORT), &hints, &servinfo)) != 0) {
-#ifdef WIN32
-		    fprintf(stderr, "getaddrinfo() failed: %d\n", rv);
-#else
-		    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
-#endif
-		    return devlist;
-		}
-		for(p = servinfo; p; p = p->ai_next) {
-			n = sendto(sudp, bufr, n, 0, p->ai_addr, p->ai_addrlen);
-			if (n < 0) {
-				PRINT_SOCKET_ERROR("sendto");
-				continue;
-			}
-		}
-		freeaddrinfo(servinfo);
-		if(n < 0) {
-			closesocket(sudp);
-			return devlist;
-		}
-	}
-	/* Waiting for SSDP REPLY packet to M-SEARCH */
-	n = ReceiveData(sudp, bufr, sizeof(bufr), delay);
-	if (n < 0) {
-		/* error */
-		closesocket(sudp);
-		return devlist;
-	} else if (n == 0) {
-		/* no data or Time Out */
-		if (devlist || (deviceList[deviceIndex] == 0)) {
-			/* no more device type to look for... */
-			closesocket(sudp);
-			return devlist;
-		}
-	} else {
-		const char * descURL=NULL;
-		int urlsize=0;
-		const char * st=NULL;
-		int stsize=0;
-        /*printf("%d byte(s) :\n%s\n", n, bufr);*/ /* affichage du message */
-		parseMSEARCHReply(bufr, n, &descURL, &urlsize, &st, &stsize);
-		if(st&&descURL)
-		{
-			/*printf("M-SEARCH Reply:\nST: %.*s\nLocation: %.*s\n",
-			       stsize, st, urlsize, descURL); */
-			tmp = (struct UPNPDev *)malloc(sizeof(struct UPNPDev)+urlsize+stsize);
-			tmp->pNext = devlist;
-			tmp->descURL = tmp->buffer;
-			tmp->st = tmp->buffer + 1 + urlsize;
-			memcpy(tmp->buffer, descURL, urlsize);
-			tmp->buffer[urlsize] = '\0';
-			memcpy(tmp->buffer + urlsize + 1, st, stsize);
-			tmp->buffer[urlsize+1+stsize] = '\0';
-			devlist = tmp;
-		}
-	}
-	}
-}
-
-/* freeUPNPDevlist() should be used to
- * free the chained list returned by upnpDiscover() */
-LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist)
-{
-	struct UPNPDev * next;
-	while(devlist)
-	{
-		next = devlist->pNext;
-		free(devlist);
-		devlist = next;
-	}
-}
-
-static void
-url_cpy_or_cat(char * dst, const char * src, int n)
-{
-	if(  (src[0] == 'h')
-	   &&(src[1] == 't')
-	   &&(src[2] == 't')
-	   &&(src[3] == 'p')
-	   &&(src[4] == ':')
-	   &&(src[5] == '/')
-	   &&(src[6] == '/'))
-	{
-		strncpy(dst, src, n);
-	}
-	else
-	{
-		int l = strlen(dst);
-		if(src[0] != '/')
-			dst[l++] = '/';
-		if(l<=n)
-			strncpy(dst + l, src, n - l);
-	}
-}
-
-/* Prepare the Urls for usage...
- */
-LIBSPEC void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
-                 const char * descURL)
-{
-	char * p;
-	int n1, n2, n3;
-	n1 = strlen(data->urlbase);
-	if(n1==0)
-		n1 = strlen(descURL);
-	n1 += 2;	/* 1 byte more for Null terminator, 1 byte for '/' if needed */
-	n2 = n1; n3 = n1;
-	n1 += strlen(data->first.scpdurl);
-	n2 += strlen(data->first.controlurl);
-	n3 += strlen(data->CIF.controlurl);
-
-	urls->ipcondescURL = (char *)malloc(n1);
-	urls->controlURL = (char *)malloc(n2);
-	urls->controlURL_CIF = (char *)malloc(n3);
-	/* maintenant on chope la desc du WANIPConnection */
-	if(data->urlbase[0] != '\0')
-		strncpy(urls->ipcondescURL, data->urlbase, n1);
-	else
-		strncpy(urls->ipcondescURL, descURL, n1);
-	p = strchr(urls->ipcondescURL+7, '/');
-	if(p) p[0] = '\0';
-	strncpy(urls->controlURL, urls->ipcondescURL, n2);
-	strncpy(urls->controlURL_CIF, urls->ipcondescURL, n3);
-	
-	url_cpy_or_cat(urls->ipcondescURL, data->first.scpdurl, n1);
-
-	url_cpy_or_cat(urls->controlURL, data->first.controlurl, n2);
-
-	url_cpy_or_cat(urls->controlURL_CIF, data->CIF.controlurl, n3);
-
-#ifdef DEBUG
-	printf("urls->ipcondescURL='%s' %u n1=%d\n", urls->ipcondescURL,
-	       (unsigned)strlen(urls->ipcondescURL), n1);
-	printf("urls->controlURL='%s' %u n2=%d\n", urls->controlURL,
-	       (unsigned)strlen(urls->controlURL), n2);
-	printf("urls->controlURL_CIF='%s' %u n3=%d\n", urls->controlURL_CIF,
-	       (unsigned)strlen(urls->controlURL_CIF), n3);
-#endif
-}
-
-LIBSPEC void
-FreeUPNPUrls(struct UPNPUrls * urls)
-{
-	if(!urls)
-		return;
-	free(urls->controlURL);
-	urls->controlURL = 0;
-	free(urls->ipcondescURL);
-	urls->ipcondescURL = 0;
-	free(urls->controlURL_CIF);
-	urls->controlURL_CIF = 0;
-}
-
-
-int ReceiveData(int socket, char * data, int length, int timeout)
-{
-    int n;
-#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
-    struct pollfd fds[1]; /* for the poll */
-#ifdef MINIUPNPC_IGNORE_EINTR
-    do {
-#endif
-        fds[0].fd = socket;
-        fds[0].events = POLLIN;
-        n = poll(fds, 1, timeout);
-#ifdef MINIUPNPC_IGNORE_EINTR
-    } while(n < 0 && errno == EINTR);
-#endif
-    if(n < 0)
-    {
-        PRINT_SOCKET_ERROR("poll");
-        return -1;
-    }
-    else if(n == 0)
-    {
-        return 0;
-    }
-#else
-    fd_set socketSet;
-    TIMEVAL timeval;
-    FD_ZERO(&socketSet);
-    FD_SET(socket, &socketSet);
-    timeval.tv_sec = timeout / 1000;
-    timeval.tv_usec = (timeout % 1000) * 1000;
-    n = select(FD_SETSIZE, &socketSet, NULL, NULL, &timeval);
-    if(n < 0)
-    {
-        PRINT_SOCKET_ERROR("select");
-        return -1;
-    }
-    else if(n == 0)
-    {
-        return 0;
-    }    
-#endif
-	n = recv(socket, data, length, 0);
-	if(n<0)
-	{
-		PRINT_SOCKET_ERROR("recv");
-	}
-	return n;
-}
-
-int
-UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data)
-{
-	char status[64];
-	unsigned int uptime;
-	status[0] = '\0';
-	UPNP_GetStatusInfo(urls->controlURL, data->first.servicetype,
-	                   status, &uptime, NULL);
-	if(0 == strcmp("Connected", status))
-	{
-		return 1;
-	}
-	else
-		return 0;
-}
-
-
-/* UPNP_GetValidIGD() :
- * return values :
- *     0 = NO IGD found
- *     1 = A valid connected IGD has been found
- *     2 = A valid IGD has been found but it reported as
- *         not connected
- *     3 = an UPnP device has been found but was not recognized as an IGD
- *
- * In any non zero return case, the urls and data structures
- * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
- * free allocated memory.
- */
-LIBSPEC int
-UPNP_GetValidIGD(struct UPNPDev * devlist,
-                 struct UPNPUrls * urls,
-				 struct IGDdatas * data,
-				 char * lanaddr, int lanaddrlen)
-{
-	char * descXML;
-	int descXMLsize = 0;
-	struct UPNPDev * dev;
-	int ndev = 0;
-	int state; /* state 1 : IGD connected. State 2 : IGD. State 3 : anything */
-	if(!devlist)
-	{
-#ifdef DEBUG
-		printf("Empty devlist\n");
-#endif
-		return 0;
-	}
-	for(state = 1; state <= 3; state++)
-	{
-		for(dev = devlist; dev; dev = dev->pNext)
-		{
-			/* we should choose an internet gateway device.
-		 	* with st == urn:schemas-upnp-org:device:InternetGatewayDevice:1 */
-			descXML = miniwget_getaddr(dev->descURL, &descXMLsize,
-			   	                        lanaddr, lanaddrlen);
-			if(descXML)
-			{
-				ndev++;
-				memset(data, 0, sizeof(struct IGDdatas));
-				memset(urls, 0, sizeof(struct UPNPUrls));
-				parserootdesc(descXML, descXMLsize, data);
-				free(descXML);
-				descXML = NULL;
-				if(0==strcmp(data->CIF.servicetype,
-				   "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")
-				   || state >= 3 )
-				{
-				  GetUPNPUrls(urls, data, dev->descURL);
-
-#ifdef DEBUG
-				  printf("UPNPIGD_IsConnected(%s) = %d\n",
-				     urls->controlURL,
-			         UPNPIGD_IsConnected(urls, data));
-#endif
-				  if((state >= 2) || UPNPIGD_IsConnected(urls, data))
-					return state;
-				  FreeUPNPUrls(urls);
-				  if(data->second.servicetype[0] != '\0') {
-#ifdef DEBUG
-				    printf("We tried %s, now we try %s !\n",
-				           data->first.servicetype, data->second.servicetype);
-#endif
-				    /* swaping WANPPPConnection and WANIPConnection ! */
-				    memcpy(&data->tmp, &data->first, sizeof(struct IGDdatas_service));
-				    memcpy(&data->first, &data->second, sizeof(struct IGDdatas_service));
-				    memcpy(&data->second, &data->tmp, sizeof(struct IGDdatas_service));
-				    GetUPNPUrls(urls, data, dev->descURL);
-#ifdef DEBUG
-				    printf("UPNPIGD_IsConnected(%s) = %d\n",
-				       urls->controlURL,
-			           UPNPIGD_IsConnected(urls, data));
-#endif
-				    if((state >= 2) || UPNPIGD_IsConnected(urls, data))
-					  return state;
-				    FreeUPNPUrls(urls);
-				  }
-				}
-				memset(data, 0, sizeof(struct IGDdatas));
-			}
-#ifdef DEBUG
-			else
-			{
-				printf("error getting XML description %s\n", dev->descURL);
-			}
-#endif
-		}
-	}
-	return 0;
-}
-
-/* UPNP_GetIGDFromUrl()
- * Used when skipping the discovery process.
- * return value :
- *   0 - Not ok
- *   1 - OK */
-int
-UPNP_GetIGDFromUrl(const char * rootdescurl,
-                   struct UPNPUrls * urls,
-                   struct IGDdatas * data,
-                   char * lanaddr, int lanaddrlen)
-{
-	char * descXML;
-	int descXMLsize = 0;
-	descXML = miniwget_getaddr(rootdescurl, &descXMLsize,
-	   	                       lanaddr, lanaddrlen);
-	if(descXML) {
-		memset(data, 0, sizeof(struct IGDdatas));
-		memset(urls, 0, sizeof(struct UPNPUrls));
-		parserootdesc(descXML, descXMLsize, data);
-		free(descXML);
-		descXML = NULL;
-		GetUPNPUrls(urls, data, rootdescurl);
-		return 1;
-	} else {
-		return 0;
-	}
-}
-

Copied: vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniupnpc.c (from rev 4535, vidalia/trunk/src/miniupnpc/miniupnpc.c)
===================================================================
--- vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniupnpc.c	                        (rev 0)
+++ vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniupnpc.c	2011-03-20 15:40:12 UTC (rev 4538)
@@ -0,0 +1,896 @@
+/* $Id: miniupnpc.c,v 1.78 2010/04/05 20:36:59 nanard Exp $ */
+/* Project : miniupnp
+ * Author : Thomas BERNARD
+ * copyright (c) 2005-2010 Thomas Bernard
+ * This software is subjet to the conditions detailed in the
+ * provided LICENSE file. */
+#define __EXTENSIONS__ 1
+#if !defined(MACOSX) && !defined(__sun)
+#if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__)
+#ifndef __cplusplus
+#define _XOPEN_SOURCE 600
+#endif
+#endif
+#ifndef __BSD_VISIBLE
+#define __BSD_VISIBLE 1
+#endif
+#endif
+
+#ifdef __APPLE__
+#define _DARWIN_C_SOURCE
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef WIN32
+/* Win32 Specific includes and defines */
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#ifdef WIN2K
+#  define __inline static inline
+#  include <wspiapi.h>
+#endif
+#include <io.h>
+/*#include <IPHlpApi.h>*/
+#define snprintf _snprintf
+#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+#define strncasecmp _memicmp
+#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
+#define strncasecmp memicmp
+#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
+#define MAXHOSTNAMELEN 64
+#else /* #ifdef WIN32 */
+/* Standard POSIX includes */
+#include <unistd.h>
+#if defined(__amigaos__) && !defined(__amigaos4__)
+/* Amiga OS 3 specific stuff */
+#define socklen_t int
+#else
+#include <sys/select.h>
+#endif
+#if defined(__APPLE__)
+#undef _POSIX_C_SOURCE
+#endif
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#if !defined(__amigaos__) && !defined(__amigaos4__)
+#include <poll.h>
+#endif
+#include <strings.h>
+#include <errno.h>
+#define closesocket close
+#define MINIUPNPC_IGNORE_EINTR
+#endif /* #else WIN32 */
+#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT
+#include <sys/time.h>
+#endif
+#if defined(__amigaos__) || defined(__amigaos4__)
+/* Amiga OS specific stuff */
+#define TIMEVAL struct timeval
+#endif
+
+#include "miniupnpc.h"
+#include "minissdpc.h"
+#include "miniwget.h"
+#include "minisoap.h"
+#include "minixml.h"
+#include "upnpcommands.h"
+#include "connecthostport.h"
+
+#ifdef WIN32
+#define PRINT_SOCKET_ERROR(x)    printf("Socket error: %s, %d\n", x, WSAGetLastError());
+#else
+#define PRINT_SOCKET_ERROR(x) perror(x)
+#endif
+
+#define SOAPPREFIX "s"
+#define SERVICEPREFIX "u"
+#define SERVICEPREFIX2 'u'
+
+/* root description parsing */
+LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data)
+{
+	struct xmlparser parser;
+	/* xmlparser object */
+	parser.xmlstart = buffer;
+	parser.xmlsize = bufsize;
+	parser.data = data;
+	parser.starteltfunc = IGDstartelt;
+	parser.endeltfunc = IGDendelt;
+	parser.datafunc = IGDdata;
+	parser.attfunc = 0;
+	parsexml(&parser);
+#ifdef DEBUG
+	printIGD(data);
+#endif
+}
+
+/* getcontentlenfromline() : parse the Content-Length HTTP header line.
+ * Content-length: nnn */
+static int getcontentlenfromline(const char * p, int n)
+{
+	static const char contlenstr[] = "content-length";
+	const char * p2 = contlenstr;
+	int a = 0;
+	while(*p2)
+	{
+		if(n==0)
+			return -1;
+		if(*p2 != *p && *p2 != (*p + 32))
+			return -1;
+		p++; p2++; n--;
+	}
+	if(n==0)
+		return -1;
+	if(*p != ':')
+		return -1;
+	p++; n--;
+	while(*p == ' ')
+	{
+		if(n==0)
+			return -1;
+		p++; n--;
+	}
+	while(*p >= '0' && *p <= '9')
+	{
+		if(n==0)
+			return -1;
+		a = (a * 10) + (*p - '0');
+		p++; n--;
+	}
+	return a;
+}
+
+/* getContentLengthAndHeaderLength()
+ * retrieve header length and content length from an HTTP response
+ * TODO : retrieve Transfer-Encoding: header value, in order to support
+ *        HTTP/1.1, chunked transfer encoding must be supported. */
+static void
+getContentLengthAndHeaderLength(char * p, int n,
+                                int * contentlen, int * headerlen)
+{
+	char * line;
+	int linelen;
+	int r;
+	line = p;
+	while(line < p + n)
+	{
+		linelen = 0;
+		while(line[linelen] != '\r' && line[linelen] != '\r')
+		{
+			if(line+linelen >= p+n)
+				return;
+			linelen++;
+		}
+		r = getcontentlenfromline(line, linelen);
+		if(r>0)
+			*contentlen = r;
+		line = line + linelen + 2;
+		if(line[0] == '\r' && line[1] == '\n')
+		{
+			*headerlen = (line - p) + 2;
+			return;
+		}
+	}
+}
+
+/* simpleUPnPcommand :
+ * not so simple !
+ * return values :
+ *   0 - OK
+ *  -1 - error */
+int simpleUPnPcommand(int s, const char * url, const char * service,
+                      const char * action, struct UPNParg * args,
+                      char * buffer, int * bufsize)
+{
+	char hostname[MAXHOSTNAMELEN+1];
+	unsigned short port = 0;
+	char * path;
+	char soapact[128];
+	char soapbody[2048];
+	char * buf;
+	int buffree;
+    int n;
+	int contentlen, headerlen;	/* for the response */
+
+	snprintf(soapact, sizeof(soapact), "%s#%s", service, action);
+	if(args==NULL)
+	{
+		/*soapbodylen = */snprintf(soapbody, sizeof(soapbody),
+						"<?xml version=\"1.0\"?>\r\n"
+	    	              "<" SOAPPREFIX ":Envelope "
+						  "xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\"; "
+						  SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\";>"
+						  "<" SOAPPREFIX ":Body>"
+						  "<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">"
+						  "</" SERVICEPREFIX ":%s>"
+						  "</" SOAPPREFIX ":Body></" SOAPPREFIX ":Envelope>"
+					 	  "\r\n", action, service, action);
+	}
+	else
+	{
+		char * p;
+		const char * pe, * pv;
+		int soapbodylen;
+		soapbodylen = snprintf(soapbody, sizeof(soapbody),
+						"<?xml version=\"1.0\"?>\r\n"
+	    	            "<" SOAPPREFIX ":Envelope "
+						"xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\"; "
+						SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\";>"
+						"<" SOAPPREFIX ":Body>"
+						"<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">",
+						action, service);
+		p = soapbody + soapbodylen;
+		while(args->elt)
+		{
+			/* check that we are never overflowing the string... */
+			if(soapbody + sizeof(soapbody) <= p + 100)
+			{
+				/* we keep a margin of at least 100 bytes */
+				*bufsize = 0;
+				return -1;
+			}
+			*(p++) = '<';
+			pe = args->elt;
+			while(*pe)
+				*(p++) = *(pe++);
+			*(p++) = '>';
+			if((pv = args->val))
+			{
+				while(*pv)
+					*(p++) = *(pv++);
+			}
+			*(p++) = '<';
+			*(p++) = '/';
+			pe = args->elt;
+			while(*pe)
+				*(p++) = *(pe++);
+			*(p++) = '>';
+			args++;
+		}
+		*(p++) = '<';
+		*(p++) = '/';
+		*(p++) = SERVICEPREFIX2;
+		*(p++) = ':';
+		pe = action;
+		while(*pe)
+			*(p++) = *(pe++);
+		strncpy(p, "></" SOAPPREFIX ":Body></" SOAPPREFIX ":Envelope>\r\n",
+		        soapbody + sizeof(soapbody) - p);
+	}
+	if(!parseURL(url, hostname, &port, &path)) return -1;
+	if(s<0)
+	{
+		s = connecthostport(hostname, port);
+		if(s < 0)
+		{
+			*bufsize = 0;
+			return -1;
+		}
+	}
+
+	n = soapPostSubmit(s, path, hostname, port, soapact, soapbody);
+	if(n<=0) {
+#ifdef DEBUG
+		printf("Error sending SOAP request\n");
+#endif
+		closesocket(s);
+		return -1;
+	}
+
+	contentlen = -1;
+	headerlen = -1;
+	buf = buffer;
+	buffree = *bufsize;
+	*bufsize = 0;
+	while ((n = ReceiveData(s, buf, buffree, 5000)) > 0) {
+		buffree -= n;
+		buf += n;
+		*bufsize += n;
+		getContentLengthAndHeaderLength(buffer, *bufsize,
+		                                &contentlen, &headerlen);
+#ifdef DEBUG
+		printf("received n=%dbytes bufsize=%d ContLen=%d HeadLen=%d\n",
+		       n, *bufsize, contentlen, headerlen);
+#endif
+		/* break if we received everything */
+		if(contentlen > 0 && headerlen > 0 && *bufsize >= contentlen+headerlen)
+			break;
+	}
+	
+	closesocket(s);
+	return 0;
+}
+
+/* parseMSEARCHReply()
+ * the last 4 arguments are filled during the parsing :
+ *    - location/locationsize : "location:" field of the SSDP reply packet
+ *    - st/stsize : "st:" field of the SSDP reply packet.
+ * The strings are NOT null terminated */
+static void
+parseMSEARCHReply(const char * reply, int size,
+                  const char * * location, int * locationsize,
+			      const char * * st, int * stsize)
+{
+	int a, b, i;
+	i = 0;
+	a = i;	/* start of the line */
+	b = 0;
+	while(i<size)
+	{
+		switch(reply[i])
+		{
+		case ':':
+				if(b==0)
+				{
+					b = i; /* end of the "header" */
+					/*for(j=a; j<b; j++)
+					{
+						putchar(reply[j]);
+					}
+					*/
+				}
+				break;
+		case '\x0a':
+		case '\x0d':
+				if(b!=0)
+				{
+					/*for(j=b+1; j<i; j++)
+					{
+						putchar(reply[j]);
+					}
+					putchar('\n');*/
+					do { b++; } while(reply[b]==' ');
+					if(0==strncasecmp(reply+a, "location", 8))
+					{
+						*location = reply+b;
+						*locationsize = i-b;
+					}
+					else if(0==strncasecmp(reply+a, "st", 2))
+					{
+						*st = reply+b;
+						*stsize = i-b;
+					}
+					b = 0;
+				}
+				a = i+1;
+				break;
+		default:
+				break;
+		}
+		i++;
+	}
+}
+
+/* port upnp discover : SSDP protocol */
+#define PORT 1900
+#define XSTR(s) STR(s)
+#define STR(s) #s
+#define UPNP_MCAST_ADDR "239.255.255.250"
+
+/* upnpDiscover() :
+ * return a chained list of all devices found or NULL if
+ * no devices was found.
+ * It is up to the caller to free the chained list
+ * delay is in millisecond (poll) */
+LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
+                              const char * minissdpdsock, int sameport)
+{
+	struct UPNPDev * tmp;
+	struct UPNPDev * devlist = 0;
+	int opt = 1;
+	static const char MSearchMsgFmt[] = 
+	"M-SEARCH * HTTP/1.1\r\n"
+	"HOST: " UPNP_MCAST_ADDR ":" XSTR(PORT) "\r\n"
+	"ST: %s\r\n"
+	"MAN: \"ssdp:discover\"\r\n"
+	"MX: %u\r\n"
+	"\r\n";
+	static const char * const deviceList[] = {
+		"urn:schemas-upnp-org:device:InternetGatewayDevice:1",
+		"urn:schemas-upnp-org:service:WANIPConnection:1",
+		"urn:schemas-upnp-org:service:WANPPPConnection:1",
+		"upnp:rootdevice",
+		0
+	};
+	int deviceIndex = 0;
+	char bufr[1536];	/* reception and emission buffer */
+	int sudp;
+	int n;
+	struct sockaddr sockudp_r;
+	unsigned int mx;
+	int rv;
+	struct addrinfo hints, *servinfo, *p;
+#ifdef WIN32
+	/*MIB_IPFORWARDROW ip_forward;*/
+#endif
+
+#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
+	/* first try to get infos from minissdpd ! */
+	if(!minissdpdsock)
+		minissdpdsock = "/var/run/minissdpd.sock";
+	while(!devlist && deviceList[deviceIndex]) {
+		devlist = getDevicesFromMiniSSDPD(deviceList[deviceIndex],
+		                                  minissdpdsock);
+		/* We return what we have found if it was not only a rootdevice */
+		if(devlist && !strstr(deviceList[deviceIndex], "rootdevice"))
+			return devlist;
+		deviceIndex++;
+	}
+	deviceIndex = 0;
+#endif
+	/* fallback to direct discovery */
+#ifdef WIN32
+	sudp = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+#else
+	sudp = socket(PF_INET, SOCK_DGRAM, 0);
+#endif
+	if(sudp < 0)
+	{
+		PRINT_SOCKET_ERROR("socket");
+		return NULL;
+	}
+	/* reception */
+	memset(&sockudp_r, 0, sizeof(struct sockaddr));
+	if(0/*ipv6*/) {
+		struct sockaddr_in6 * p = (struct sockaddr_in6 *)&sockudp_r;
+		p->sin6_family = AF_INET6;
+		if(sameport)
+			p->sin6_port = htons(PORT);
+		p->sin6_addr = in6addr_any;//IN6ADDR_ANY_INIT;/*INADDR_ANY;*/
+	} else {
+		struct sockaddr_in * p = (struct sockaddr_in *)&sockudp_r;
+		p->sin_family = AF_INET;
+		if(sameport)
+			p->sin_port = htons(PORT);
+		p->sin_addr.s_addr = INADDR_ANY;
+	}
+#if 0
+	/* emission */
+	memset(&sockudp_w, 0, sizeof(struct sockaddr_in));
+	sockudp_w.sin_family = AF_INET;
+	sockudp_w.sin_port = htons(PORT);
+	sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR);
+#endif
+#ifdef WIN32
+/* This code could help us to use the right Network interface for 
+ * SSDP multicast traffic */
+/* TODO : Get IP associated with the index given in the ip_forward struct
+ * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */
+ /*
+	if(GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) == NO_ERROR) {
+		DWORD dwRetVal = 0;
+		PMIB_IPADDRTABLE pIPAddrTable;
+    DWORD dwSize = 0;
+    IN_ADDR IPAddr;
+    int i;
+    printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop);
+    pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE));
+    if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) {
+	    free(pIPAddrTable);
+      pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize);
+    }
+    if(pIPAddrTable) {
+    	dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 );
+    	printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries);
+    	for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) {
+        printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex);
+        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr;
+        printf("\tIP Address[%d]:     \t%s\n", i, inet_ntoa(IPAddr) );
+        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask;
+        printf("\tSubnet Mask[%d]:    \t%s\n", i, inet_ntoa(IPAddr) );
+        IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr;
+        printf("\tBroadCast[%d]:      \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr);
+        printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize);
+        printf("\tType and State[%d]:", i);
+        printf("\n");
+    	}
+			free(pIPAddrTable);
+    	pIPAddrTable = NULL;
+    }
+	}
+*/
+#endif
+
+#ifdef WIN32
+	if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof (opt)) < 0)
+#else
+	if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt)) < 0)
+#endif
+	{
+		PRINT_SOCKET_ERROR("setsockopt");
+		return NULL;
+	}
+
+	if(multicastif)
+	{
+		struct in_addr mc_if;
+		mc_if.s_addr = inet_addr(multicastif);
+		if(0/*ipv6*/) {
+		} else {
+			((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr;
+		}
+		if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0)
+		{
+			PRINT_SOCKET_ERROR("setsockopt");
+		}
+	}
+
+	/* Avant d'envoyer le paquet on bind pour recevoir la reponse */
+    if (bind(sudp, &sockudp_r, 0/*ipv6*/?sizeof(struct sockaddr_in6):sizeof(struct sockaddr_in)) != 0)
+	{
+        PRINT_SOCKET_ERROR("bind");
+		closesocket(sudp);
+		return NULL;
+    }
+
+	/* Calculating maximum response time in seconds */
+	mx = ((unsigned int)delay) / 1000u;
+	/* receiving SSDP response packet */
+	for(n = 0;;)
+	{
+	if(n == 0)
+	{
+		/* sending the SSDP M-SEARCH packet */
+		n = snprintf(bufr, sizeof(bufr),
+		             MSearchMsgFmt, deviceList[deviceIndex++], mx);
+		/*printf("Sending %s", bufr);*/
+#if 0
+		n = sendto(sudp, bufr, n, 0,
+		           (struct sockaddr *)&sockudp_w, sizeof(struct sockaddr_in));
+		if (n < 0) {
+			PRINT_SOCKET_ERROR("sendto");
+			closesocket(sudp);
+			return devlist;
+		}
+#endif
+		memset(&hints, 0, sizeof(hints));
+		hints.ai_family = AF_UNSPEC; // AF_INET6 or AF_INET
+		hints.ai_socktype = SOCK_DGRAM;
+		/*hints.ai_flags = */
+		if ((rv = getaddrinfo(UPNP_MCAST_ADDR, XSTR(PORT), &hints, &servinfo)) != 0) {
+#ifdef WIN32
+		    fprintf(stderr, "getaddrinfo() failed: %d\n", rv);
+#else
+		    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
+#endif
+		    return devlist;
+		}
+		for(p = servinfo; p; p = p->ai_next) {
+			n = sendto(sudp, bufr, n, 0, p->ai_addr, p->ai_addrlen);
+			if (n < 0) {
+				PRINT_SOCKET_ERROR("sendto");
+				continue;
+			}
+		}
+		freeaddrinfo(servinfo);
+		if(n < 0) {
+			closesocket(sudp);
+			return devlist;
+		}
+	}
+	/* Waiting for SSDP REPLY packet to M-SEARCH */
+	n = ReceiveData(sudp, bufr, sizeof(bufr), delay);
+	if (n < 0) {
+		/* error */
+		closesocket(sudp);
+		return devlist;
+	} else if (n == 0) {
+		/* no data or Time Out */
+		if (devlist || (deviceList[deviceIndex] == 0)) {
+			/* no more device type to look for... */
+			closesocket(sudp);
+			return devlist;
+		}
+	} else {
+		const char * descURL=NULL;
+		int urlsize=0;
+		const char * st=NULL;
+		int stsize=0;
+        /*printf("%d byte(s) :\n%s\n", n, bufr);*/ /* affichage du message */
+		parseMSEARCHReply(bufr, n, &descURL, &urlsize, &st, &stsize);
+		if(st&&descURL)
+		{
+			/*printf("M-SEARCH Reply:\nST: %.*s\nLocation: %.*s\n",
+			       stsize, st, urlsize, descURL); */
+			tmp = (struct UPNPDev *)malloc(sizeof(struct UPNPDev)+urlsize+stsize);
+			tmp->pNext = devlist;
+			tmp->descURL = tmp->buffer;
+			tmp->st = tmp->buffer + 1 + urlsize;
+			memcpy(tmp->buffer, descURL, urlsize);
+			tmp->buffer[urlsize] = '\0';
+			memcpy(tmp->buffer + urlsize + 1, st, stsize);
+			tmp->buffer[urlsize+1+stsize] = '\0';
+			devlist = tmp;
+		}
+	}
+	}
+}
+
+/* freeUPNPDevlist() should be used to
+ * free the chained list returned by upnpDiscover() */
+LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist)
+{
+	struct UPNPDev * next;
+	while(devlist)
+	{
+		next = devlist->pNext;
+		free(devlist);
+		devlist = next;
+	}
+}
+
+static void
+url_cpy_or_cat(char * dst, const char * src, int n)
+{
+	if(  (src[0] == 'h')
+	   &&(src[1] == 't')
+	   &&(src[2] == 't')
+	   &&(src[3] == 'p')
+	   &&(src[4] == ':')
+	   &&(src[5] == '/')
+	   &&(src[6] == '/'))
+	{
+		strncpy(dst, src, n);
+	}
+	else
+	{
+		int l = strlen(dst);
+		if(src[0] != '/')
+			dst[l++] = '/';
+		if(l<=n)
+			strncpy(dst + l, src, n - l);
+	}
+}
+
+/* Prepare the Urls for usage...
+ */
+LIBSPEC void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data,
+                 const char * descURL)
+{
+	char * p;
+	int n1, n2, n3;
+	n1 = strlen(data->urlbase);
+	if(n1==0)
+		n1 = strlen(descURL);
+	n1 += 2;	/* 1 byte more for Null terminator, 1 byte for '/' if needed */
+	n2 = n1; n3 = n1;
+	n1 += strlen(data->first.scpdurl);
+	n2 += strlen(data->first.controlurl);
+	n3 += strlen(data->CIF.controlurl);
+
+	urls->ipcondescURL = (char *)malloc(n1);
+	urls->controlURL = (char *)malloc(n2);
+	urls->controlURL_CIF = (char *)malloc(n3);
+	/* maintenant on chope la desc du WANIPConnection */
+	if(data->urlbase[0] != '\0')
+		strncpy(urls->ipcondescURL, data->urlbase, n1);
+	else
+		strncpy(urls->ipcondescURL, descURL, n1);
+	p = strchr(urls->ipcondescURL+7, '/');
+	if(p) p[0] = '\0';
+	strncpy(urls->controlURL, urls->ipcondescURL, n2);
+	strncpy(urls->controlURL_CIF, urls->ipcondescURL, n3);
+	
+	url_cpy_or_cat(urls->ipcondescURL, data->first.scpdurl, n1);
+
+	url_cpy_or_cat(urls->controlURL, data->first.controlurl, n2);
+
+	url_cpy_or_cat(urls->controlURL_CIF, data->CIF.controlurl, n3);
+
+#ifdef DEBUG
+	printf("urls->ipcondescURL='%s' %u n1=%d\n", urls->ipcondescURL,
+	       (unsigned)strlen(urls->ipcondescURL), n1);
+	printf("urls->controlURL='%s' %u n2=%d\n", urls->controlURL,
+	       (unsigned)strlen(urls->controlURL), n2);
+	printf("urls->controlURL_CIF='%s' %u n3=%d\n", urls->controlURL_CIF,
+	       (unsigned)strlen(urls->controlURL_CIF), n3);
+#endif
+}
+
+LIBSPEC void
+FreeUPNPUrls(struct UPNPUrls * urls)
+{
+	if(!urls)
+		return;
+	free(urls->controlURL);
+	urls->controlURL = 0;
+	free(urls->ipcondescURL);
+	urls->ipcondescURL = 0;
+	free(urls->controlURL_CIF);
+	urls->controlURL_CIF = 0;
+}
+
+
+int ReceiveData(int socket, char * data, int length, int timeout)
+{
+    int n;
+#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__)
+    struct pollfd fds[1]; /* for the poll */
+#ifdef MINIUPNPC_IGNORE_EINTR
+    do {
+#endif
+        fds[0].fd = socket;
+        fds[0].events = POLLIN;
+        n = poll(fds, 1, timeout);
+#ifdef MINIUPNPC_IGNORE_EINTR
+    } while(n < 0 && errno == EINTR);
+#endif
+    if(n < 0)
+    {
+        PRINT_SOCKET_ERROR("poll");
+        return -1;
+    }
+    else if(n == 0)
+    {
+        return 0;
+    }
+#else
+    fd_set socketSet;
+    TIMEVAL timeval;
+    FD_ZERO(&socketSet);
+    FD_SET(socket, &socketSet);
+    timeval.tv_sec = timeout / 1000;
+    timeval.tv_usec = (timeout % 1000) * 1000;
+    n = select(FD_SETSIZE, &socketSet, NULL, NULL, &timeval);
+    if(n < 0)
+    {
+        PRINT_SOCKET_ERROR("select");
+        return -1;
+    }
+    else if(n == 0)
+    {
+        return 0;
+    }    
+#endif
+	n = recv(socket, data, length, 0);
+	if(n<0)
+	{
+		PRINT_SOCKET_ERROR("recv");
+	}
+	return n;
+}
+
+int
+UPNPIGD_IsConnected(struct UPNPUrls * urls, struct IGDdatas * data)
+{
+	char status[64];
+	unsigned int uptime;
+	status[0] = '\0';
+	UPNP_GetStatusInfo(urls->controlURL, data->first.servicetype,
+	                   status, &uptime, NULL);
+	if(0 == strcmp("Connected", status))
+	{
+		return 1;
+	}
+	else
+		return 0;
+}
+
+
+/* UPNP_GetValidIGD() :
+ * return values :
+ *     0 = NO IGD found
+ *     1 = A valid connected IGD has been found
+ *     2 = A valid IGD has been found but it reported as
+ *         not connected
+ *     3 = an UPnP device has been found but was not recognized as an IGD
+ *
+ * In any non zero return case, the urls and data structures
+ * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
+ * free allocated memory.
+ */
+LIBSPEC int
+UPNP_GetValidIGD(struct UPNPDev * devlist,
+                 struct UPNPUrls * urls,
+				 struct IGDdatas * data,
+				 char * lanaddr, int lanaddrlen)
+{
+	char * descXML;
+	int descXMLsize = 0;
+	struct UPNPDev * dev;
+	int ndev = 0;
+	int state; /* state 1 : IGD connected. State 2 : IGD. State 3 : anything */
+	if(!devlist)
+	{
+#ifdef DEBUG
+		printf("Empty devlist\n");
+#endif
+		return 0;
+	}
+	for(state = 1; state <= 3; state++)
+	{
+		for(dev = devlist; dev; dev = dev->pNext)
+		{
+			/* we should choose an internet gateway device.
+		 	* with st == urn:schemas-upnp-org:device:InternetGatewayDevice:1 */
+			descXML = miniwget_getaddr(dev->descURL, &descXMLsize,
+			   	                        lanaddr, lanaddrlen);
+			if(descXML)
+			{
+				ndev++;
+				memset(data, 0, sizeof(struct IGDdatas));
+				memset(urls, 0, sizeof(struct UPNPUrls));
+				parserootdesc(descXML, descXMLsize, data);
+				free(descXML);
+				descXML = NULL;
+				if(0==strcmp(data->CIF.servicetype,
+				   "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")
+				   || state >= 3 )
+				{
+				  GetUPNPUrls(urls, data, dev->descURL);
+
+#ifdef DEBUG
+				  printf("UPNPIGD_IsConnected(%s) = %d\n",
+				     urls->controlURL,
+			         UPNPIGD_IsConnected(urls, data));
+#endif
+				  if((state >= 2) || UPNPIGD_IsConnected(urls, data))
+					return state;
+				  FreeUPNPUrls(urls);
+				  if(data->second.servicetype[0] != '\0') {
+#ifdef DEBUG
+				    printf("We tried %s, now we try %s !\n",
+				           data->first.servicetype, data->second.servicetype);
+#endif
+				    /* swaping WANPPPConnection and WANIPConnection ! */
+				    memcpy(&data->tmp, &data->first, sizeof(struct IGDdatas_service));
+				    memcpy(&data->first, &data->second, sizeof(struct IGDdatas_service));
+				    memcpy(&data->second, &data->tmp, sizeof(struct IGDdatas_service));
+				    GetUPNPUrls(urls, data, dev->descURL);
+#ifdef DEBUG
+				    printf("UPNPIGD_IsConnected(%s) = %d\n",
+				       urls->controlURL,
+			           UPNPIGD_IsConnected(urls, data));
+#endif
+				    if((state >= 2) || UPNPIGD_IsConnected(urls, data))
+					  return state;
+				    FreeUPNPUrls(urls);
+				  }
+				}
+				memset(data, 0, sizeof(struct IGDdatas));
+			}
+#ifdef DEBUG
+			else
+			{
+				printf("error getting XML description %s\n", dev->descURL);
+			}
+#endif
+		}
+	}
+	return 0;
+}
+
+/* UPNP_GetIGDFromUrl()
+ * Used when skipping the discovery process.
+ * return value :
+ *   0 - Not ok
+ *   1 - OK */
+int
+UPNP_GetIGDFromUrl(const char * rootdescurl,
+                   struct UPNPUrls * urls,
+                   struct IGDdatas * data,
+                   char * lanaddr, int lanaddrlen)
+{
+	char * descXML;
+	int descXMLsize = 0;
+	descXML = miniwget_getaddr(rootdescurl, &descXMLsize,
+	   	                       lanaddr, lanaddrlen);
+	if(descXML) {
+		memset(data, 0, sizeof(struct IGDdatas));
+		memset(urls, 0, sizeof(struct UPNPUrls));
+		parserootdesc(descXML, descXMLsize, data);
+		free(descXML);
+		descXML = NULL;
+		GetUPNPUrls(urls, data, rootdescurl);
+		return 1;
+	} else {
+		return 0;
+	}
+}
+

Deleted: vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniwget.c
===================================================================
--- vidalia/trunk/src/miniupnpc/miniwget.c	2011-03-18 11:30:36 UTC (rev 4532)
+++ vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniwget.c	2011-03-20 15:40:12 UTC (rev 4538)
@@ -1,250 +0,0 @@
-/* $Id: miniwget.c,v 1.36 2010/04/05 12:34:05 nanard Exp $ */
-/* Project : miniupnp
- * Author : Thomas Bernard
- * Copyright (c) 2005-2010 Thomas Bernard
- * This software is subject to the conditions detailed in the
- * LICENCE file provided in this distribution. */
- 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "miniupnpc.h"
-#ifdef WIN32
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#include <io.h>
-#define MAXHOSTNAMELEN 64
-#define MIN(x,y) (((x)<(y))?(x):(y))
-#define snprintf _snprintf
-#define socklen_t int
-#else /* #ifdef WIN32 */
-#include <unistd.h>
-#include <sys/param.h>
-#if defined(__amigaos__) && !defined(__amigaos4__)
-#define socklen_t int
-#else /* #if defined(__amigaos__) && !defined(__amigaos4__) */
-#include <sys/select.h>
-#endif /* #else defined(__amigaos__) && !defined(__amigaos4__) */
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#define closesocket close
-/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions
- * during the connect() call */
-#define MINIUPNPC_IGNORE_EINTR
-#endif /* #else WIN32 */
-#if defined(__sun) || defined(sun)
-#define MIN(x,y) (((x)<(y))?(x):(y))
-#endif
-
-#include "miniupnpcstrings.h"
-#include "miniwget.h"
-#include "connecthostport.h"
-
-/* miniwget2() :
- * do all the work.
- * Return NULL if something failed. */
-static void *
-miniwget2(const char * url, const char * host,
-		  unsigned short port, const char * path,
-		  int * size, char * addr_str, int addr_str_len)
-{
-	char buf[2048];
-    int s;
-	int n;
-	int len;
-	int sent;
-
-	*size = 0;
-	s = connecthostport(host, port);
-	if(s < 0)
-		return NULL;
-
-	/* get address for caller ! */
-	if(addr_str)
-	{
-		struct sockaddr saddr;
-		socklen_t saddrlen;
-
-		saddrlen = sizeof(saddr);
-		if(getsockname(s, &saddr, &saddrlen) < 0)
-		{
-			perror("getsockname");
-		}
-		else
-		{
-#if defined(__amigaos__) && !defined(__amigaos4__)
-	/* using INT WINAPI WSAAddressToStringA(LPSOCKADDR, DWORD, LPWSAPROTOCOL_INFOA, LPSTR, LPDWORD);
-     * But his function make a string with the port :  nn.nn.nn.nn:port */
-/*		if(WSAAddressToStringA((SOCKADDR *)&saddr, sizeof(saddr),
-                            NULL, addr_str, (DWORD *)&addr_str_len))
-		{
-		    printf("WSAAddressToStringA() failed : %d\n", WSAGetLastError());
-		}*/
-			strncpy(addr_str, inet_ntoa(((struct sockaddr_in *)&saddr)->sin_addr), addr_str_len);
-#else
-			/*inet_ntop(AF_INET, &saddr.sin_addr, addr_str, addr_str_len);*/
-			n = getnameinfo(&saddr, saddrlen,
-			                addr_str, addr_str_len,
-			                NULL, 0,
-			                NI_NUMERICHOST | NI_NUMERICSERV);
-			if(n != 0) {
-#ifdef WIN32
-				fprintf(stderr, "getnameinfo() failed : %d\n", n);
-#else
-				fprintf(stderr, "getnameinfo() failed : %s\n", gai_strerror(n));
-#endif
-			}
-#endif
-		}
-#ifdef DEBUG
-		printf("address miniwget : %s\n", addr_str);
-#endif
-	}
-
-	len = snprintf(buf, sizeof(buf),
-                 "GET %s HTTP/1.0\r\n"
-			     "Host: %s:%d\r\n"
-				 "Connection: Close\r\n"
-				 "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n"
-
-				 "\r\n",
-		    path, host, port);
-	sent = 0;
-	/* sending the HTTP request */
-	while(sent < len)
-	{
-		n = send(s, buf+sent, len-sent, 0);
-		if(n < 0)
-		{
-			perror("send");
-			closesocket(s);
-			return NULL;
-		}
-		else
-		{
-			sent += n;
-		}
-	}
-	{
-		/* TODO : in order to support HTTP/1.1, chunked transfer encoding
-		 *        must be supported. That means parsing of headers must be
-		 *        added.                                                   */
-		int headers=1;
-		char * respbuffer = NULL;
-		int allreadyread = 0;
-		/*while((n = recv(s, buf, 2048, 0)) > 0)*/
-		while((n = ReceiveData(s, buf, 2048, 5000)) > 0)
-		{
-			if(headers)
-			{
-				int i=0;
-				while(i<n-3)
-				{
-					/* searching for the end of the HTTP headers */
-					if(buf[i]=='\r' && buf[i+1]=='\n'
-					   && buf[i+2]=='\r' && buf[i+3]=='\n')
-					{
-						headers = 0;	/* end */
-						if(i<n-4)
-						{
-							/* Copy the content into respbuffet */
-							respbuffer = (char *)realloc((void *)respbuffer, 
-														 allreadyread+(n-i-4));
-							memcpy(respbuffer+allreadyread, buf + i + 4, n-i-4);
-							allreadyread += (n-i-4);
-						}
-						break;
-					}
-					i++;
-				}
-			}
-			else
-			{
-				respbuffer = (char *)realloc((void *)respbuffer, 
-								 allreadyread+n);
-				memcpy(respbuffer+allreadyread, buf, n);
-				allreadyread += n;
-			}
-		}
-		*size = allreadyread;
-#ifdef DEBUG
-		printf("%d bytes read\n", *size);
-#endif
-		closesocket(s);
-		return respbuffer;
-	}
-}
-
-/* parseURL()
- * arguments :
- *   url :		source string not modified
- *   hostname :	hostname destination string (size of MAXHOSTNAMELEN+1)
- *   port :		port (destination)
- *   path :		pointer to the path part of the URL 
- *
- * Return values :
- *    0 - Failure
- *    1 - Success         */
-int parseURL(const char * url, char * hostname, unsigned short * port, char * * path)
-{
-	char * p1, *p2, *p3;
-	p1 = strstr(url, "://");
-	if(!p1)
-		return 0;
-	p1 += 3;
-	if(  (url[0]!='h') || (url[1]!='t')
-	   ||(url[2]!='t') || (url[3]!='p'))
-		return 0;
-	p2 = strchr(p1, ':');
-	p3 = strchr(p1, '/');
-	if(!p3)
-		return 0;
-	memset(hostname, 0, MAXHOSTNAMELEN + 1);
-	if(!p2 || (p2>p3))
-	{
-		strncpy(hostname, p1, MIN(MAXHOSTNAMELEN, (int)(p3-p1)));
-		*port = 80;
-	}
-	else
-	{
-		strncpy(hostname, p1, MIN(MAXHOSTNAMELEN, (int)(p2-p1)));
-		*port = 0;
-		p2++;
-		while( (*p2 >= '0') && (*p2 <= '9'))
-		{
-			*port *= 10;
-			*port += (unsigned short)(*p2 - '0');
-			p2++;
-		}
-	}
-	*path = p3;
-	return 1;
-}
-
-void * miniwget(const char * url, int * size)
-{
-	unsigned short port;
-	char * path;
-	/* protocol://host:port/chemin */
-	char hostname[MAXHOSTNAMELEN+1];
-	*size = 0;
-	if(!parseURL(url, hostname, &port, &path))
-		return NULL;
-	return miniwget2(url, hostname, port, path, size, 0, 0);
-}
-
-void * miniwget_getaddr(const char * url, int * size, char * addr, int addrlen)
-{
-	unsigned short port;
-	char * path;
-	/* protocol://host:port/chemin */
-	char hostname[MAXHOSTNAMELEN+1];
-	*size = 0;
-	if(addr)
-		addr[0] = '\0';
-	if(!parseURL(url, hostname, &port, &path))
-		return NULL;
-	return miniwget2(url, hostname, port, path, size, addr, addrlen);
-}
-

Copied: vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniwget.c (from rev 4535, vidalia/trunk/src/miniupnpc/miniwget.c)
===================================================================
--- vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniwget.c	                        (rev 0)
+++ vidalia/tags/vidalia-0.2.11/src/miniupnpc/miniwget.c	2011-03-20 15:40:12 UTC (rev 4538)
@@ -0,0 +1,254 @@
+/* $Id: miniwget.c,v 1.36 2010/04/05 12:34:05 nanard Exp $ */
+/* Project : miniupnp
+ * Author : Thomas Bernard
+ * Copyright (c) 2005-2010 Thomas Bernard
+ * This software is subject to the conditions detailed in the
+ * LICENCE file provided in this distribution. */
+ 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "miniupnpc.h"
+#ifdef WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#ifdef WIN2K
+#  define __inline static inline
+#  include <wspiapi.h>
+#endif
+#include <io.h>
+#define MAXHOSTNAMELEN 64
+#define MIN(x,y) (((x)<(y))?(x):(y))
+#define snprintf _snprintf
+#define socklen_t int
+#else /* #ifdef WIN32 */
+#include <unistd.h>
+#include <sys/param.h>
+#if defined(__amigaos__) && !defined(__amigaos4__)
+#define socklen_t int
+#else /* #if defined(__amigaos__) && !defined(__amigaos4__) */
+#include <sys/select.h>
+#endif /* #else defined(__amigaos__) && !defined(__amigaos4__) */
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#define closesocket close
+/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions
+ * during the connect() call */
+#define MINIUPNPC_IGNORE_EINTR
+#endif /* #else WIN32 */
+#if defined(__sun) || defined(sun)
+#define MIN(x,y) (((x)<(y))?(x):(y))
+#endif
+
+#include "miniupnpcstrings.h"
+#include "miniwget.h"
+#include "connecthostport.h"
+
+/* miniwget2() :
+ * do all the work.
+ * Return NULL if something failed. */
+static void *
+miniwget2(const char * url, const char * host,
+		  unsigned short port, const char * path,
+		  int * size, char * addr_str, int addr_str_len)
+{
+	char buf[2048];
+    int s;
+	int n;
+	int len;
+	int sent;
+
+	*size = 0;
+	s = connecthostport(host, port);
+	if(s < 0)
+		return NULL;
+
+	/* get address for caller ! */
+	if(addr_str)
+	{
+		struct sockaddr saddr;
+		socklen_t saddrlen;
+
+		saddrlen = sizeof(saddr);
+		if(getsockname(s, &saddr, &saddrlen) < 0)
+		{
+			perror("getsockname");
+		}
+		else
+		{
+#if defined(__amigaos__) && !defined(__amigaos4__)
+	/* using INT WINAPI WSAAddressToStringA(LPSOCKADDR, DWORD, LPWSAPROTOCOL_INFOA, LPSTR, LPDWORD);
+     * But his function make a string with the port :  nn.nn.nn.nn:port */
+/*		if(WSAAddressToStringA((SOCKADDR *)&saddr, sizeof(saddr),
+                            NULL, addr_str, (DWORD *)&addr_str_len))
+		{
+		    printf("WSAAddressToStringA() failed : %d\n", WSAGetLastError());
+		}*/
+			strncpy(addr_str, inet_ntoa(((struct sockaddr_in *)&saddr)->sin_addr), addr_str_len);
+#else
+			/*inet_ntop(AF_INET, &saddr.sin_addr, addr_str, addr_str_len);*/
+			n = getnameinfo(&saddr, saddrlen,
+			                addr_str, addr_str_len,
+			                NULL, 0,
+			                NI_NUMERICHOST | NI_NUMERICSERV);
+			if(n != 0) {
+#ifdef WIN32
+				fprintf(stderr, "getnameinfo() failed : %d\n", n);
+#else
+				fprintf(stderr, "getnameinfo() failed : %s\n", gai_strerror(n));
+#endif
+			}
+#endif
+		}
+#ifdef DEBUG
+		printf("address miniwget : %s\n", addr_str);
+#endif
+	}
+
+	len = snprintf(buf, sizeof(buf),
+                 "GET %s HTTP/1.0\r\n"
+			     "Host: %s:%d\r\n"
+				 "Connection: Close\r\n"
+				 "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n"
+
+				 "\r\n",
+		    path, host, port);
+	sent = 0;
+	/* sending the HTTP request */
+	while(sent < len)
+	{
+		n = send(s, buf+sent, len-sent, 0);
+		if(n < 0)
+		{
+			perror("send");
+			closesocket(s);
+			return NULL;
+		}
+		else
+		{
+			sent += n;
+		}
+	}
+	{
+		/* TODO : in order to support HTTP/1.1, chunked transfer encoding
+		 *        must be supported. That means parsing of headers must be
+		 *        added.                                                   */
+		int headers=1;
+		char * respbuffer = NULL;
+		int allreadyread = 0;
+		/*while((n = recv(s, buf, 2048, 0)) > 0)*/
+		while((n = ReceiveData(s, buf, 2048, 5000)) > 0)
+		{
+			if(headers)
+			{
+				int i=0;
+				while(i<n-3)
+				{
+					/* searching for the end of the HTTP headers */
+					if(buf[i]=='\r' && buf[i+1]=='\n'
+					   && buf[i+2]=='\r' && buf[i+3]=='\n')
+					{
+						headers = 0;	/* end */
+						if(i<n-4)
+						{
+							/* Copy the content into respbuffet */
+							respbuffer = (char *)realloc((void *)respbuffer, 
+														 allreadyread+(n-i-4));
+							memcpy(respbuffer+allreadyread, buf + i + 4, n-i-4);
+							allreadyread += (n-i-4);
+						}
+						break;
+					}
+					i++;
+				}
+			}
+			else
+			{
+				respbuffer = (char *)realloc((void *)respbuffer, 
+								 allreadyread+n);
+				memcpy(respbuffer+allreadyread, buf, n);
+				allreadyread += n;
+			}
+		}
+		*size = allreadyread;
+#ifdef DEBUG
+		printf("%d bytes read\n", *size);
+#endif
+		closesocket(s);
+		return respbuffer;
+	}
+}
+
+/* parseURL()
+ * arguments :
+ *   url :		source string not modified
+ *   hostname :	hostname destination string (size of MAXHOSTNAMELEN+1)
+ *   port :		port (destination)
+ *   path :		pointer to the path part of the URL 
+ *
+ * Return values :
+ *    0 - Failure
+ *    1 - Success         */
+int parseURL(const char * url, char * hostname, unsigned short * port, char * * path)
+{
+	char * p1, *p2, *p3;
+	p1 = strstr(url, "://");
+	if(!p1)
+		return 0;
+	p1 += 3;
+	if(  (url[0]!='h') || (url[1]!='t')
+	   ||(url[2]!='t') || (url[3]!='p'))
+		return 0;
+	p2 = strchr(p1, ':');
+	p3 = strchr(p1, '/');
+	if(!p3)
+		return 0;
+	memset(hostname, 0, MAXHOSTNAMELEN + 1);
+	if(!p2 || (p2>p3))
+	{
+		strncpy(hostname, p1, MIN(MAXHOSTNAMELEN, (int)(p3-p1)));
+		*port = 80;
+	}
+	else
+	{
+		strncpy(hostname, p1, MIN(MAXHOSTNAMELEN, (int)(p2-p1)));
+		*port = 0;
+		p2++;
+		while( (*p2 >= '0') && (*p2 <= '9'))
+		{
+			*port *= 10;
+			*port += (unsigned short)(*p2 - '0');
+			p2++;
+		}
+	}
+	*path = p3;
+	return 1;
+}
+
+void * miniwget(const char * url, int * size)
+{
+	unsigned short port;
+	char * path;
+	/* protocol://host:port/chemin */
+	char hostname[MAXHOSTNAMELEN+1];
+	*size = 0;
+	if(!parseURL(url, hostname, &port, &path))
+		return NULL;
+	return miniwget2(url, hostname, port, path, size, 0, 0);
+}
+
+void * miniwget_getaddr(const char * url, int * size, char * addr, int addrlen)
+{
+	unsigned short port;
+	char * path;
+	/* protocol://host:port/chemin */
+	char hostname[MAXHOSTNAMELEN+1];
+	*size = 0;
+	if(addr)
+		addr[0] = '\0';
+	if(!parseURL(url, hostname, &port, &path))
+		return NULL;
+	return miniwget2(url, hostname, port, path, size, addr, addrlen);
+}
+

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits