/*! @file


    Compile for Linux:

    @code
    g++ test.cxx -I. -lproxy -ldl
    @endcode

    On Linux: install http://code.google.com/p/libproxy/
    
    @code
      ./configure --without-gnome --without-kde \
                  --without-webkit --without-mozjs \
                  --without-networkmanager --without-python
      make && sudo make install
    @endcode

    Cross-Compile for Windoze:

    @code
    i586-mingw32msvc-g++ test.cxx             \
      -I . -I ~/.wine/drive_c/MicrosoftSDK/include \
      winhttp.a
    @endcode

    @id $Id$
*/
//       1         2         3         4         5         6         7         8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890

#include <proxyface/autoproxy.hxx>
#include <iostream>

int main(int argc, char** argv) try {
  proxy::Face detect;
  while (++argv, --argc) {
    std::cout<<"detecting proxies for url: "<<*argv<<std::endl;
    for (proxy::List p(detect.proxies(*argv));
         p.size();
         p.pop_front())
      std::cout<<" -> found "
               <<(p.begin()->type==proxy::DIRECT?"DIRECT"
                  :(p.begin()->type==proxy::DEFAULT?"DEFAULT"
                    :(p.begin()->type==proxy::HTTP?"HTTP"
                      :(p.begin()->type==proxy::SOCKS?"SOCKS":"**ERROR**"))))
               <<" proxy host: "<<p.begin()->host
               <<" (Port: "<<p.begin()->port<<")"<<std::endl;
  }
  return 0;
 } catch(std::exception& x) {
  std::cerr<<" **** Exception: "<<x.what()<<std::endl;
 }
