Subversion Repositories Kolibri OS

Rev

Rev 5725 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #ifndef __HTTP_H__
  2. #define __HTTP_H__
  3.  
  4. #define FLAG_GOT_ALL_DATA       (1 << 2)
  5.  
  6. #define FLAG_STREAM             (1 << 9)
  7. #define FLAG_REUSE_BUFFER       (1 << 10)
  8.  
  9.  
  10. typedef struct
  11. {
  12.     int   socket;               // socket on which the actual transfer happens
  13.     int   flags;                // flags, reflects status of the transfer using bitflags
  14.     int   write_ptr;            // internal use only (where to write new data in buffer)
  15.     int   buffer_length;        // internal use only (number of available bytes in buffer)
  16.     int   chunk_ptr;            // internal use only (where the next chunk begins)
  17.     int   timestamp;            // internal use only (when last data was received)
  18.  
  19.     int   status;               // HTTP status
  20.     int   header_length;        // length of HTTP header
  21.     void *content_ptr;          // ptr to content
  22.     int   content_length;       // total length of HTTP content
  23.     int   content_received;     // number of currently received content bytes
  24. }http_t;
  25.  
  26. int http_init();
  27. int http_load(char *buf, const char *path);
  28.  
  29. http_t* __stdcall http_get(const char *url, http_t *conn, int flags, const char *header);
  30. int     __stdcall http_receive(http_t *conn);
  31. void    __stdcall http_free(http_t *conn);
  32.  
  33. static inline int http_receive_with_retry(http_t *http, int retry_count)
  34. {
  35.     int err;
  36.  
  37.     do
  38.     {
  39.         err = http_receive(http);
  40.         if(err)
  41.             wait_for_event(1);
  42.  
  43.     }while(err && --retry_count);
  44.  
  45.     return err;
  46. }
  47.  
  48. void     __stdcall con_init(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t);
  49. void     __stdcall con_exit(char bCloseWindow);
  50. unsigned __stdcall con_get_flags(void);
  51. unsigned __stdcall con_set_flags(unsigned new_flags);
  52. void     __stdcall con_cls(void);
  53. void     __stdcall con_write_asciiz(const char* string);
  54.  
  55.  
  56. #endif /* __HTTP_H__ */
  57.