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

Last change on this file since 621 was 621, checked in by djay, 9 years ago

Major update. Creation of a basic parsing api. Call validateRequest after fork if any.

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr
File size: 4.7 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>
32#ifndef WIN32
33#include <unistd.h>
34#endif
35#include <string.h>
36#include "time.h"
37#ifdef USE_JS
[364]38#ifdef WIN32
[453]39#define XP_WIN 1
[364]40#else
[1]41#define XP_UNIX 0
[364]42#endif
[1]43#include "jsapi.h"
44#endif
[507]45#ifndef bool
46#define bool int
47#endif
48#ifndef true
49#define true 1
[621]50#define false 0
[507]51#endif
[1]52
[507]53#define MAX_REQ 50
[1]54
55#ifdef _ULINET
[492]56static char CCookie[MAX_REQ][1024];
[1]57#else
[579]58/**
59 * The cookies found
60 */
[492]61extern char CCookie[MAX_REQ][1024];
[1]62#endif
63
64#ifdef __cplusplus
65extern "C" {
66#endif
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 {
77    CURL *handle; //!< the CURL handler
78    struct curl_slist *header; //!< the headers to send
79    char* filename; //!< the cached file name
80    FILE* file; //!< the file pointer
81    unsigned char *pabyData; //!< the downloaded content
82    char *mimeType; //!< the mimeType returned by the server
[621]83    char *post; //!< the potential POST XML content
[607]84    int hasCacheFile; //!< 1 if we used a cache file
85    int nDataLen; //!< the length of the downloaded content
86    int nDataAlloc; //!<
87    long code; //!< the last received response code
88    int id; //!< The position of the element in the queue
89  } _HINTERNET;
[492]90
[579]91  /**
92   * Multiple CURL handlers
93   */
[607]94  typedef struct {
95    CURLM *handle; //!< the CURLM handler
96    _HINTERNET ihandle[MAX_REQ]; //!< individual handlers in the queue
97    char *waitingRequests[MAX_REQ]; //!< request in the queue
98    char *agent; //!< The User-Agent to use for HTTP request
99    int nb; //!< number of element in the queue
100  } HINTERNET;
[1]101
[607]102  size_t write_data_into(void*,size_t,size_t,void*);
[1]103
[607]104  size_t header_write_data(void*,size_t,size_t,void*);
[1]105
[607]106  void setProxy(CURL*,char*,long);
[1]107
108#if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__))
109
110#include <CoreServices/CoreServices.h>
111#include <SystemConfiguration/SystemConfiguration.h>
[607]112  char* CFStringToCString(CFStringRef,char*);
113  OSStatus setProxiesForProtcol(CURL*,const char*);
[1]114
115#else
116
117//#include <gconf/gconf-client.h>
[607]118  int setProxiesForProtcol(CURL*,const char*);
[1]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
[607]130  HINTERNET InternetOpen(char*,int,char*,char*,int);
[1]131
[607]132  void InternetCloseHandle(HINTERNET*);
[1]133
134#define INTERNET_FLAG_EXISTING_CONNECT         0
135#define INTERNET_FLAG_HYPERLINK                1
136#define INTERNET_FLAG_IGNORE_CERT_CN_INVALID   2
137#define INTERNET_FLAG_IGNORE_CERT_DATE_INVALID 3
138#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP  4
139#define INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS 5
140#define INTERNET_FLAG_KEEP_CONNECTION          6
141#define INTERNET_FLAG_NEED_FILE                7
142#define INTERNET_FLAG_NO_AUTH                  8
143#define INTERNET_FLAG_NO_AUTO_REDIRECT         9
144#define INTERNET_FLAG_NO_CACHE_WRITE          10
145//typedef char* LPVOID;
146#ifndef WIN32
[607]147  typedef void* LPVOID;
148  typedef void* LPTSTR;
149  typedef size_t* LPDWORD;
[1]150#endif
151#ifndef bool
152#define bool int
153#endif
154
155#  define CHECK_INET_HANDLE(h) (h.handle != 0)
156
[607]157  HINTERNET InternetOpenUrl(HINTERNET*,LPCTSTR,LPCTSTR,size_t,size_t,size_t);
[1]158
[607]159  int processDownloads(HINTERNET*);
[492]160
[607]161  int freeCookieList(HINTERNET);
[1]162
[607]163  int InternetReadFile(_HINTERNET,LPVOID,int,size_t*);
[1]164
[607]165  int setBasicAuth(HINTERNET,char*,char*);
166
[1]167#ifdef __cplusplus
168}
169#endif
170
171#endif
172
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