1*96e28a40SPulkoMandy /* 2*96e28a40SPulkoMandy * Copyright 2004-2008, François Revol, <revol@free.fr>. 3*96e28a40SPulkoMandy * Distributed under the terms of the MIT License. 4*96e28a40SPulkoMandy */ 5*96e28a40SPulkoMandy #ifndef _DUCKDUCKGO_REQUEST_H 6*96e28a40SPulkoMandy #define _DUCKDUCKGO_REQUEST_H 7*96e28a40SPulkoMandy 8*96e28a40SPulkoMandy #ifdef __cplusplus 9*96e28a40SPulkoMandy #include <UrlRequest.h> 10*96e28a40SPulkoMandy using namespace BPrivate::Network; 11*96e28a40SPulkoMandy extern "C" { 12*96e28a40SPulkoMandy #else 13*96e28a40SPulkoMandy struct BUrlRequest; 14*96e28a40SPulkoMandy typedef struct BUrlRequest BUrlRequest; 15*96e28a40SPulkoMandy #endif 16*96e28a40SPulkoMandy 17*96e28a40SPulkoMandy struct duckduckgo_request { 18*96e28a40SPulkoMandy struct duckduckgo_request *next; 19*96e28a40SPulkoMandy struct fs_volume *volume; 20*96e28a40SPulkoMandy struct fs_node *query_node; /* root folder for that query */ 21*96e28a40SPulkoMandy char *query_string; 22*96e28a40SPulkoMandy BUrlRequest *cnx; 23*96e28a40SPulkoMandy struct duckduckgo_result *results; 24*96e28a40SPulkoMandy long nextid; 25*96e28a40SPulkoMandy }; 26*96e28a40SPulkoMandy 27*96e28a40SPulkoMandy /* those are quite arbitrary values */ 28*96e28a40SPulkoMandy #define GR_MAX_NAME 70 29*96e28a40SPulkoMandy #define GR_MAX_PROTO 16 30*96e28a40SPulkoMandy #define GR_MAX_URL 1024 31*96e28a40SPulkoMandy #define GR_MAX_SNIPSET 256 32*96e28a40SPulkoMandy struct duckduckgo_result { 33*96e28a40SPulkoMandy struct duckduckgo_result *next; 34*96e28a40SPulkoMandy long id; 35*96e28a40SPulkoMandy char name[GR_MAX_NAME]; 36*96e28a40SPulkoMandy char proto[GR_MAX_PROTO]; 37*96e28a40SPulkoMandy char url[GR_MAX_URL]; 38*96e28a40SPulkoMandy char snipset[GR_MAX_SNIPSET]; 39*96e28a40SPulkoMandy char cache_url[GR_MAX_URL]; 40*96e28a40SPulkoMandy char similar_url[GR_MAX_URL]; 41*96e28a40SPulkoMandy }; 42*96e28a40SPulkoMandy 43*96e28a40SPulkoMandy extern status_t duckduckgo_request_process(struct duckduckgo_request *req); 44*96e28a40SPulkoMandy extern status_t duckduckgo_request_process_async(struct duckduckgo_request *req); 45*96e28a40SPulkoMandy extern status_t duckduckgo_request_close(struct duckduckgo_request *req); 46*96e28a40SPulkoMandy extern status_t duckduckgo_request_open(const char *query_string, struct fs_volume *volume, struct fs_node *query_node, struct duckduckgo_request **req); 47*96e28a40SPulkoMandy extern status_t duckduckgo_request_free(struct duckduckgo_request *req); 48*96e28a40SPulkoMandy 49*96e28a40SPulkoMandy extern int duckduckgo_parse_results(const char *html, size_t htmlsize, long *nextid, struct duckduckgo_result **results); 50*96e28a40SPulkoMandy 51*96e28a40SPulkoMandy #ifdef __cplusplus 52*96e28a40SPulkoMandy } 53*96e28a40SPulkoMandy #endif 54*96e28a40SPulkoMandy 55*96e28a40SPulkoMandy #endif /* _DUCKDUCKGO_REQUEST_H */ 56