Lines Matching refs:ctx
63 struct window *ctx; in _zip_source_window_new() local
70 if ((ctx=(struct window *)malloc(sizeof(*ctx))) == NULL) { in _zip_source_window_new()
75 ctx->start = start; in _zip_source_window_new()
76 ctx->end = start + length; in _zip_source_window_new()
77 zip_stat_init(&ctx->stat); in _zip_source_window_new()
78 zip_error_init(&ctx->error); in _zip_source_window_new()
79 …ctx->supports = (zip_source_supports(src) & ZIP_SOURCE_SUPPORTS_SEEKABLE) | (zip_source_make_comma… in _zip_source_window_new()
80 …ctx->needs_seek = (ctx->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK)) ? true : fals… in _zip_source_window_new()
83 if (_zip_stat_merge(&ctx->stat, st, error) < 0) { in _zip_source_window_new()
84 free(ctx); in _zip_source_window_new()
89 return zip_source_layered_create(src, window_read, ctx, error); in _zip_source_window_new()
116 struct window *ctx; in window_read() local
121 ctx = (struct window *)_ctx; in window_read()
128 return zip_error_to_data(&ctx->error, data, len); in window_read()
131 free(ctx); in window_read()
135 if (!ctx->needs_seek) { in window_read()
136 for (n=0; n<ctx->start; n+=(zip_uint64_t)ret) { in window_read()
137 i = (ctx->start-n > sizeof(b) ? sizeof(b) : ctx->start-n); in window_read()
139 _zip_error_set_from_source(&ctx->error, src); in window_read()
143 zip_error_set(&ctx->error, ZIP_ER_EOF, 0); in window_read()
149 ctx->offset = ctx->start; in window_read()
153 if (len > ctx->end - ctx->offset) in window_read()
154 len = ctx->end - ctx->offset; in window_read()
159 if (ctx->needs_seek) { in window_read()
160 if (zip_source_seek(src, (zip_int64_t)ctx->offset, SEEK_SET) < 0) { in window_read()
161 _zip_error_set_from_source(&ctx->error, src); in window_read()
167 zip_error_set(&ctx->error, ZIP_ER_EOF, 0); in window_read()
171 ctx->offset += (zip_uint64_t)ret; in window_read()
174 if (ctx->offset < ctx->end) { in window_read()
175 zip_error_set(&ctx->error, ZIP_ER_EOF, 0); in window_read()
183 …new_offset = zip_source_seek_compute_offset(ctx->offset - ctx->start, ctx->end - ctx->start, data,… in window_read()
189 ctx->offset = (zip_uint64_t)new_offset + ctx->start; in window_read()
199 if (_zip_stat_merge(st, &ctx->stat, &ctx->error) < 0) { in window_read()
206 return ctx->supports; in window_read()
209 return (zip_int64_t)(ctx->offset - ctx->start); in window_read()
212 zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); in window_read()