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

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

Change the default ZOO-Kernel behavior, if an input has been passed by reference, the ZOO-Service will receive a cache_file map rather than the value field which was usually returned, same for array value apply. To use the previous behavior, one can add "memory=load" to the main section of the main.cfg file. Update ZOO-Services for using this new field if available.

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