Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. char DL_URL[10000];
  3. dword DL_bufpointer, DL_bufsize, DL_http_transfer, DL_http_buffer;
  4.  
  5. int downloaded_size, full_size;
  6.  
  7. byte download_state;
  8. enum { STATE_NOT_STARTED, STATE_IN_PROGRESS, STATE_COMPLETED };
  9.  
  10.  
  11.  
  12.  
  13. void Downloading_SetDefaults()
  14. {
  15.         downloaded_size = full_size = 0;
  16. }
  17.  
  18. void Downloading_Stop()
  19. {
  20.         download_state = STATE_NOT_STARTED;
  21.         if (DL_http_transfer<>0)
  22.         {
  23.                 EAX = DL_http_transfer;
  24.                 EAX = EAX.http_msg.content_ptr;         // get pointer to data
  25.                 $push   EAX                                                     // save it on the stack
  26.                 http_free stdcall (DL_http_transfer);   // abort connection
  27.                 $pop    EAX                                                    
  28.                 mem_Free(EAX);                                          // free data
  29.                 DL_http_transfer=0;
  30.                 DL_bufsize = 0;
  31.                 DL_bufpointer = mem_Free(DL_bufpointer);
  32.                 Downloading_SetDefaults();
  33.         }
  34. }
  35.  
  36. void Downloading_Start()
  37. {
  38.         download_state = STATE_IN_PROGRESS;
  39.         http_get stdcall (#DL_URL, 0, 0, #accept_language);
  40.         DL_http_transfer = EAX;
  41. }
  42.  
  43. void Downloading_Completed()
  44. {
  45.         ESI = DL_http_transfer;
  46.         DL_bufpointer = ESI.http_msg.content_ptr;
  47.         DL_bufsize = ESI.http_msg.content_received;
  48.         http_free stdcall (DL_http_transfer);
  49.         DL_http_transfer=0;
  50.         download_state = STATE_COMPLETED;
  51. }