Advertisement
Guest User

HGET progressbar bugfix for small files

a guest
Aug 15th, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | Source Code | 0 0
  1. diff --git a/Working Folder/hget.c b/Working Folder/hget.c
  2. index 70fa742..459e25f 100644
  3. --- a/Working Folder/hget.c
  4. +++ b/Working Folder/hget.c
  5. @@ -1,4 +1,4 @@
  6. -/* HTTP getter 1.3
  7. +/* HTTP getter 1.3.1
  8. By Konamiman 1/2011 v1.1
  9. By Oduvaldo Pavan Junior 07/2019 v1.3
  10.  
  11. @@ -102,6 +102,8 @@ typedef unsigned char bool;
  12.  
  13. #define MAX_REDIRECTIONS 10
  14.  
  15. +#define PROGRESS_BAR_SIZE 25
  16. +
  17. enum TcpipUnapiFunctions {
  18. UNAPI_GET_INFO = 0,
  19. TCPIP_GET_CAPAB = 1,
  20. @@ -141,7 +143,7 @@ enum TcpipErrorCodes {
  21. #define strDefaultFilename "index.htm";
  22.  
  23. const char* strTitle=
  24. - "HTTP file downloader 1.3\r\n"
  25. + "HTTP file downloader 1.3.1\r\n"
  26. "By Oduvaldo (ducasp@gmail.com) 7/2019\r\n"
  27. "Based on HGET 1.1 by Konamiman\r\n"
  28. "\r\n";
  29. @@ -224,6 +226,7 @@ int remainingInputData = 0;
  30. byte* inputDataPointer;
  31. int emptyLineReaded;
  32. long contentLength,blockSize,currentBlock;
  33. +byte printedProgressBar;
  34. bool isFirstUpdate;
  35. int isChunkedTransfer;
  36. long currentChunkSize = 0;
  37. @@ -1422,7 +1425,8 @@ void DoDirectDatatransfer()
  38. print(" ");
  39. if (contentLength)
  40. {
  41. - blockSize = contentLength/25;
  42. + printedProgressBar = 0;
  43. + blockSize = contentLength/PROGRESS_BAR_SIZE;
  44. currentBlock = 0;
  45. isFirstUpdate = true;
  46. }
  47. @@ -1445,7 +1449,7 @@ void DoChunkedDataTransfer()
  48. print(" ");
  49. if (contentLength)
  50. {
  51. - blockSize = contentLength/25;
  52. + blockSize = contentLength/PROGRESS_BAR_SIZE;
  53. currentBlock = 0;
  54. isFirstUpdate = true;
  55. }
  56. @@ -1573,11 +1577,16 @@ void UpdateReceivingMessage()
  57. isFirstUpdate=false;
  58. print("\r[ ]\r\x1c");
  59. }
  60. - while (currentBlock>=blockSize)
  61. + if (!blockSize) {
  62. + currentBlock = PROGRESS_BAR_SIZE;
  63. + blockSize = 1;
  64. + }
  65. + while (printedProgressBar < PROGRESS_BAR_SIZE && currentBlock>=blockSize)
  66. {
  67. + printedProgressBar++;
  68. currentBlock-=blockSize;
  69. print("=");
  70. - }
  71. + }
  72. }
  73. else
  74. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement