Lines Matching defs:be
16 int init_data(struct upload_backend *be, const char *argv[])
18 be->now = posix_time();
19 be->argv = argv;
21 memset(&be->zstream, 0, sizeof be->zstream);
23 be->zstream.next_out = NULL;
24 be->outbuf = NULL;
25 be->zstream.avail_out = be->alloc = 0;
26 be->dbytes = be->zbytes = 0;
29 if (deflateInit2(&be->zstream, 9, Z_DEFLATED,
36 static int do_deflate(struct upload_backend *be, int flush)
42 rv = deflate(&be->zstream, flush);
43 be->zbytes = be->alloc - be->zstream.avail_out;
44 if (be->zstream.avail_out)
47 buf = realloc(be->outbuf, be->alloc + ALLOC_CHUNK);
50 be->outbuf = buf;
51 be->alloc += ALLOC_CHUNK;
52 be->zstream.next_out = (void *)(buf + be->zbytes);
53 be->zstream.avail_out = be->alloc - be->zbytes;
58 int write_data(struct upload_backend *be, const void *buf, size_t len)
62 be->zstream.next_in = (void *)buf;
63 be->zstream.avail_in = len;
65 be->dbytes += len;
67 while (be->zstream.avail_in) {
68 rv = do_deflate(be, Z_NO_FLUSH);
78 int flush_data(struct upload_backend *be)
84 rv = do_deflate(be, Z_FINISH);
89 // printf("Uploading data, %u bytes... ", be->zbytes);
91 if ((err=be->write(be)) != 0)
94 free(be->outbuf);
95 be->outbuf = NULL;
96 be->dbytes = be->zbytes = be->alloc = 0;