Subversion Repositories SvarDOS

Rev

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

Rev 218 Rev 327
Line 112... Line 112...
112
 * fills bsum with the BSD sum of the data
112
 * fills bsum with the BSD sum of the data
113
 * returns the length of data obtained, or neg value on error */
113
 * returns the length of data obtained, or neg value on error */
114
static long htget(const char *ipaddr, const char *url, const char *outfname, unsigned short *bsum) {
114
static long htget(const char *ipaddr, const char *url, const char *outfname, unsigned short *bsum) {
115
  struct net_tcpsocket *sock;
115
  struct net_tcpsocket *sock;
116
  unsigned char buffer[4096];
116
  unsigned char buffer[4096];
117
  time_t lastactivity;
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;
121
  FILE *fd = NULL;
121
  FILE *fd = NULL;
122
 
122
 
Line 203... Line 203...
203
          printf("ERROR: failed to write data to file %s after %ld bytes", outfname, flen);
203
          printf("ERROR: failed to write data to file %s after %ld bytes", outfname, flen);
204
          puts("");
204
          puts("");
205
          break;
205
          break;
206
        }
206
        }
207
        flen += byteread;
207
        flen += byteread;
-
 
208
        /* update progress once a sec */
-
 
209
        if (lastprogressoutput != lastactivity) {
-
 
210
          lastprogressoutput = lastactivity;
-
 
211
          printf("%ld KiB\r", flen >> 10);
-
 
212
        }
208
        /* update the bsd sum */
213
        /* update the bsd sum */
209
        for (i = 0; i < byteread; i++) {
214
        for (i = 0; i < byteread; i++) {
210
          /* rotr16 */
215
          /* rotr16 */
211
          unsigned short bsumlsb = *bsum & 1;
216
          unsigned short bsumlsb = *bsum & 1;
212
          *bsum >>= 1;
217
          *bsum >>= 1;