Subversion Repositories Kolibri OS

Rev

Rev 5731 | 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* __attribute__ ((stdcall)) http_get(const char *url, http_t *conn, int flags, const char *header);
  30. int     __attribute__ ((stdcall)) http_receive(http_t *conn);
  31. void    __attribute__ ((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.         if(err = http_receive(http))
  40.             delay(1);
  41.  
  42.     }while(err && --retry_count);
  43.  
  44.     return err;
  45. }
  46.  
  47. #endif /* __HTTP_H__ */
  48.