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

Last change on this file since 933 was 933, checked in by knut, 5 years ago

Resolve certain string-related type conflicts, e.g., char* vs. const char* or char[N], that may cause errors in some build environments. Resolve a problem with the include order of fcgi_stdio.h (note: should verify that this harmonizes with resolution of same problem in trunk).

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr
File size: 5.2 KB
Line 
1/*
2 * Author : Gérald FENOY
3 *
4 *  Copyright 2008-2019 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
28#include "fcgi_stdio.h"
29
30#include <stdlib.h>
31#include <fcntl.h>
32#include <curl/curl.h>
33#include <curl/curlver.h>
34#include "service.h"
35#ifndef WIN32
36#include <unistd.h>
37#endif
38#include <string.h>
39#include "time.h"
40#ifdef USE_JS
41#ifdef WIN32
42#define XP_WIN 1
43#else
44#define XP_UNIX 0
45#endif
46#include "jsapi.h"
47#endif
48#ifndef __cplusplus
49// knut: see new def of bool in service.h
50//#ifndef bool
51//#define bool int
52//#endif
53//#ifndef true
54//#define true 1
55//#define false 0
56//#endif
57#endif
58
59#define MAX_REQ 50
60
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65  /**
66   * Headers storage
67   * @see header_write_data
68   */
69  struct MemoryStruct {
70    char *memory; //!< the memory space to store data
71    size_t size; //!< size of the memory space
72  };
73
74  /**
75   * Individual CURL handler
76   */
77  typedef struct {
78    CURL *handle; //!< the CURL handler
79    struct curl_slist *header; //!< the headers to send
80    char* filename; //!< the cached file name
81    FILE* file; //!< the file pointer   
82    unsigned char *pabyData; //!< the downloaded content
83    char *url; //!< the url used to access the server
84    char *mimeType; //!< the mimeType returned by the server
85    char *post; //!< the potential POST XML content
86    char* cookie; //!< The potential Cookie returned by the server
87    int hasCacheFile; //!< 1 if we used a cache file
88    int nDataLen; //!< the length of the downloaded content
89    int nDataAlloc; //!<
90    long code; //!< the last received response code
91    int id; //!< The position of the element in the queue
92  } _HINTERNET;
93
94  /**
95   * Multiple CURL handlers
96   */
97  typedef struct {
98    CURLM *handle; //!< the CURLM handler
99    _HINTERNET ihandle[MAX_REQ]; //!< individual handlers in the queue
100    char *waitingRequests[MAX_REQ]; //!< request in the queue
101    char *agent; //!< The User-Agent to use for HTTP request
102    int nb; //!< number of element in the queue
103  } HINTERNET;
104
105  size_t write_data_into(void*,size_t,size_t,void*);
106
107  size_t write_data_into_file(void*,size_t,size_t,void*);
108
109  size_t header_write_data(void*,size_t,size_t,void*);
110
111  void setProxy(CURL*,char*,long);
112
113#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
114
115#include <CoreServices/CoreServices.h>
116#include <SystemConfiguration/SystemConfiguration.h>
117  char* CFStringToCString(CFStringRef,char*);
118  OSStatus setProxiesForProtcol(CURL*,const char*);
119
120#else
121
122//#include <gconf/gconf-client.h>
123  int setProxiesForProtcol(CURL*,const char*);
124
125#endif
126
127
128#define INTERNET_OPEN_TYPE_DIRECT                      0
129#define INTERNET_OPEN_TYPE_PRECONFIG                   1
130#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 2
131#define INTERNET_OPEN_TYPE_PROXY                       3
132#ifndef WIN32
133typedef char* LPCTSTR;
134#endif
135  HINTERNET InternetOpen(char*,int,char*,char*,int);
136
137  char* getProvenance(maps*,const char*);
138  int isProtectedHost(const char*,const char*);
139  int AddMissingHeaderEntry(_HINTERNET*,const char*,const char*);
140  void AddHeaderEntries(HINTERNET*,maps*);
141
142  void InternetCloseHandle(HINTERNET*);
143
144#define INTERNET_FLAG_EXISTING_CONNECT         0
145#define INTERNET_FLAG_HYPERLINK                1
146#define INTERNET_FLAG_IGNORE_CERT_CN_INVALID   2
147#define INTERNET_FLAG_IGNORE_CERT_DATE_INVALID 3
148#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP  4
149#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS 5
150#define INTERNET_FLAG_KEEP_CONNECTION          6
151#define INTERNET_FLAG_NEED_FILE                7
152#define INTERNET_FLAG_NO_AUTH                  8
153#define INTERNET_FLAG_NO_AUTO_REDIRECT         9
154#define INTERNET_FLAG_NO_CACHE_WRITE          10
155//typedef char* LPVOID;
156#ifndef WIN32
157  typedef void* LPVOID;
158  typedef void* LPTSTR;
159  typedef size_t* LPDWORD;
160#endif
161// knut: see new definition of bool in service.h
162//#ifndef bool
163//#define bool int
164//#endif
165
166#  define CHECK_INET_HANDLE(h) (h.handle != 0)
167
168  HINTERNET InternetOpenUrl(HINTERNET*,LPCTSTR,LPCTSTR,size_t,size_t,size_t,const maps*);
169
170  int processDownloads(HINTERNET*);
171
172  int freeCookieList(HINTERNET);
173
174  int InternetReadFile(_HINTERNET,LPVOID,int,size_t*);
175
176  int setBasicAuth(HINTERNET,char*,char*);
177
178#ifdef __cplusplus
179}
180#endif
181
182#endif
183
Note: See TracBrowser for help on using the repository browser.

Search

Context Navigation

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