Subversion Repositories SvarDOS

Rev

Rev 331 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 331 Rev 332
Line 32... Line 32...
32
#include <string.h>
32
#include <string.h>
33
#include <time.h>
33
#include <time.h>
34
 
34
 
35
#include "net.h"
35
#include "net.h"
36
 
36
 
37
#define PVER "20210513"
37
#define PVER "20210514"
38
#define PDATE "2021"
38
#define PDATE "2021"
39
 
39
 
40
#define HOSTADDR "svardos.osdn.io"
40
#define HOSTADDR "svardos.osdn.io"
41
 
41
 
42
 
42
 
Line 115... Line 115...
115
  struct net_tcpsocket *sock;
115
  struct net_tcpsocket *sock;
116
  unsigned char buffer[4096];
116
  unsigned char buffer[4096];
117
  time_t lastactivity, lastprogressoutput = 0;
117
  time_t lastactivity, lastprogressoutput = 0;
118
  int headersdone = 0;
118
  int headersdone = 0;
119
  int httpcode = -1;
119
  int httpcode = -1;
120
  long flen = 0;
120
  long flen = 0, lastflen = 0;
121
  FILE *fd = NULL;
121
  FILE *fd = NULL;
122
 
122
 
123
  sock = net_connect(ipaddr, 80);
123
  sock = net_connect(ipaddr, 80);
124
  if (sock == NULL) {
124
  if (sock == NULL) {
125
    puts("ERROR: failed to connect to " HOSTADDR);
125
    puts("ERROR: failed to connect to " HOSTADDR);
Line 206... Line 206...
206
        }
206
        }
207
        flen += byteread;
207
        flen += byteread;
208
        /* update progress once a sec */
208
        /* update progress once a sec */
209
        if (lastprogressoutput != lastactivity) {
209
        if (lastprogressoutput != lastactivity) {
210
          lastprogressoutput = lastactivity;
210
          lastprogressoutput = lastactivity;
-
 
211
          printf("%ld KiB (%ld KiB/s)\r", flen >> 10, (flen >> 10) - (lastflen >> 10));
211
          printf("%ld KiB\r", flen >> 10);
212
          lastflen = flen;
-
 
213
          fflush(stdout); /* avoid console buffering */
212
        }
214
        }
213
        /* update the bsd sum */
215
        /* update the bsd sum */
214
        for (i = 0; i < byteread; i++) {
216
        for (i = 0; i < byteread; i++) {
215
          /* rotr16 */
217
          /* rotr16 */
216
          unsigned short bsumlsb = *bsum & 1;
218
          unsigned short bsumlsb = *bsum & 1;