source: trunk/zoo-project/zoo-kernel/ulinet.h @ 944

Last change on this file since 944 was 944, checked in by djay, 5 years ago

Fix #172 and add the documentation on how to use the curl section to define cainfo.

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