source: branches/prototype-v0/zoo-project/zoo-kernel/ulinet.h @ 871

Last change on this file since 871 was 871, checked in by djay, 6 years ago

Use curl_multi_wait only in case libcurl minor version number is upper or equal to 28.

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr
File size: 5.1 KB
RevLine 
[579]1/*
[1]2 * Author : Gérald FENOY
3 *
4 *  Copyright 2008-2009 GeoLabs SARL. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25#ifndef _ULINET_H
26#define _ULINET_H
27
[471]28#include "fcgi_stdio.h"
[1]29#include <stdlib.h>
30#include <fcntl.h>
31#include <curl/curl.h>
[871]32#include <curl/curlver.h>
[817]33#include "service.h"
[1]34#ifndef WIN32
35#include <unistd.h>
36#endif
37#include <string.h>
38#include "time.h"
39#ifdef USE_JS
[364]40#ifdef WIN32
[453]41#define XP_WIN 1
[364]42#else
[1]43#define XP_UNIX 0
[364]44#endif
[1]45#include "jsapi.h"
46#endif
[507]47#ifndef bool
48#define bool int
49#endif
50#ifndef true
51#define true 1
[621]52#define false 0
[507]53#endif
[1]54
[507]55#define MAX_REQ 50
[1]56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
[630]61  /**
62   * Headers storage
63   * @see header_write_data
64   */
[607]65  struct MemoryStruct {
66    char *memory; //!< the memory space to store data
67    size_t size; //!< size of the memory space
68  };
[1]69
[579]70  /**
71   * Individual CURL handler
72   */
[607]73  typedef struct {
74    CURL *handle; //!< the CURL handler
75    struct curl_slist *header; //!< the headers to send
76    char* filename; //!< the cached file name
77    FILE* file; //!< the file pointer
78    unsigned char *pabyData; //!< the downloaded content
[817]79    char *url; //!< the url used to access the server
[607]80    char *mimeType; //!< the mimeType returned by the server
[621]81    char *post; //!< the potential POST XML content
[839]82    char* cookie; //!< The potential Cookie returned by the server
[607]83    int hasCacheFile; //!< 1 if we used a cache file
84    int nDataLen; //!< the length of the downloaded content
85    int nDataAlloc; //!<
86    long code; //!< the last received response code
87    int id; //!< The position of the element in the queue
88  } _HINTERNET;
[492]89
[579]90  /**
91   * Multiple CURL handlers
92   */
[607]93  typedef struct {
94    CURLM *handle; //!< the CURLM handler
95    _HINTERNET ihandle[MAX_REQ]; //!< individual handlers in the queue
96    char *waitingRequests[MAX_REQ]; //!< request in the queue
97    char *agent; //!< The User-Agent to use for HTTP request
98    int nb; //!< number of element in the queue
99  } HINTERNET;
[1]100
[607]101  size_t write_data_into(void*,size_t,size_t,void*);
[1]102
[863]103  size_t write_data_into_file(void*,size_t,size_t,void*);
104
[607]105  size_t header_write_data(void*,size_t,size_t,void*);
[1]106
[607]107  void setProxy(CURL*,char*,long);
[1]108
109#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
110
111#include <CoreServices/CoreServices.h>
112#include <SystemConfiguration/SystemConfiguration.h>
[607]113  char* CFStringToCString(CFStringRef,char*);
114  OSStatus setProxiesForProtcol(CURL*,const char*);
[1]115
116#else
117
118//#include <gconf/gconf-client.h>
[607]119  int setProxiesForProtcol(CURL*,const char*);
[1]120
121#endif
122
123
124#define INTERNET_OPEN_TYPE_DIRECT                      0
125#define INTERNET_OPEN_TYPE_PRECONFIG                   1
126#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 2
127#define INTERNET_OPEN_TYPE_PROXY                       3
128#ifndef WIN32
129typedef char* LPCTSTR;
130#endif
[607]131  HINTERNET InternetOpen(char*,int,char*,char*,int);
[1]132
[854]133  char* getProvenance(maps*,const char*);
[817]134  int isProtectedHost(const char*,const char*);
135  int AddMissingHeaderEntry(_HINTERNET*,const char*,const char*);
136  void AddHeaderEntries(HINTERNET*,maps*);
137
[607]138  void InternetCloseHandle(HINTERNET*);
[1]139
140#define INTERNET_FLAG_EXISTING_CONNECT         0
141#define INTERNET_FLAG_HYPERLINK                1
142#define INTERNET_FLAG_IGNORE_CERT_CN_INVALID   2
143#define INTERNET_FLAG_IGNORE_CERT_DATE_INVALID 3
144#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP  4
145#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS 5
146#define INTERNET_FLAG_KEEP_CONNECTION          6
147#define INTERNET_FLAG_NEED_FILE                7
148#define INTERNET_FLAG_NO_AUTH                  8
149#define INTERNET_FLAG_NO_AUTO_REDIRECT         9
150#define INTERNET_FLAG_NO_CACHE_WRITE          10
151//typedef char* LPVOID;
152#ifndef WIN32
[607]153  typedef void* LPVOID;
154  typedef void* LPTSTR;
155  typedef size_t* LPDWORD;
[1]156#endif
157#ifndef bool
158#define bool int
159#endif
160
161#  define CHECK_INET_HANDLE(h) (h.handle != 0)
162
[863]163  HINTERNET InternetOpenUrl(HINTERNET*,LPCTSTR,LPCTSTR,size_t,size_t,size_t,const maps*);
[1]164
[607]165  int processDownloads(HINTERNET*);
[492]166
[607]167  int freeCookieList(HINTERNET);
[1]168
[607]169  int InternetReadFile(_HINTERNET,LPVOID,int,size_t*);
[1]170
[607]171  int setBasicAuth(HINTERNET,char*,char*);
172
[1]173#ifdef __cplusplus
174}
175#endif
176
177#endif
178
Note: See TracBrowser for help on using the repository browser.

Search

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png