Lines Matching refs:ctx
87 struct read_data *ctx; in zip_source_buffer_create() local
95 if ((ctx=(struct read_data *)malloc(sizeof(*ctx))) == NULL) { in zip_source_buffer_create()
100 if ((ctx->in = buffer_new_read(data, len, freep)) == NULL) { in zip_source_buffer_create()
102 free(ctx); in zip_source_buffer_create()
106 ctx->out = NULL; in zip_source_buffer_create()
107 ctx->mtime = time(NULL); in zip_source_buffer_create()
108 zip_error_init(&ctx->error); in zip_source_buffer_create()
110 if ((zs=zip_source_function_create(read_data, ctx, error)) == NULL) { in zip_source_buffer_create()
111 buffer_free(ctx->in); in zip_source_buffer_create()
112 free(ctx); in zip_source_buffer_create()
123 struct read_data *ctx = (struct read_data *)state; in read_data() local
127 if ((ctx->out = buffer_new_write(WRITE_FRAGMENT_SIZE)) == NULL) { in read_data()
128 zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); in read_data()
137 buffer_free(ctx->in); in read_data()
138 ctx->in = ctx->out; in read_data()
139 ctx->out = NULL; in read_data()
143 return zip_error_to_data(&ctx->error, data, len); in read_data()
146 buffer_free(ctx->in); in read_data()
147 buffer_free(ctx->out); in read_data()
148 free(ctx); in read_data()
152 ctx->in->offset = 0; in read_data()
157 zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); in read_data()
160 return buffer_read(ctx->in, data, len); in read_data()
166 zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); in read_data()
170 buffer_free(ctx->in); in read_data()
171 ctx->in = empty; in read_data()
176 buffer_free(ctx->out); in read_data()
177 ctx->out = NULL; in read_data()
181 return buffer_seek(ctx->in, data, len, &ctx->error); in read_data()
184 return buffer_seek(ctx->out, data, len, &ctx->error); in read_data()
191 zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); in read_data()
198 st->mtime = ctx->mtime; in read_data()
199 st->size = ctx->in->size; in read_data()
212 if (ctx->in->offset > ZIP_INT64_MAX) { in read_data()
213 zip_error_set(&ctx->error, ZIP_ER_TELL, EOVERFLOW); in read_data()
216 return (zip_int64_t)ctx->in->offset; in read_data()
220 if (ctx->out->offset > ZIP_INT64_MAX) { in read_data()
221 zip_error_set(&ctx->error, ZIP_ER_TELL, EOVERFLOW); in read_data()
224 return (zip_int64_t)ctx->out->offset; in read_data()
228 zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); in read_data()
231 return buffer_write(ctx->out, data, len, &ctx->error); in read_data()
234 zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); in read_data()