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