Lines Matching refs:ctx
57 struct crc_context *ctx; in zip_source_crc() local
64 if ((ctx=(struct crc_context *)malloc(sizeof(*ctx))) == NULL) { in zip_source_crc()
69 zip_error_init(&ctx->error); in zip_source_crc()
70 ctx->validate = validate; in zip_source_crc()
71 ctx->crc_complete = 0; in zip_source_crc()
72 ctx->crc_position = 0; in zip_source_crc()
73 ctx->crc = (zip_uint32_t)crc32(0, NULL, 0); in zip_source_crc()
74 ctx->size = 0; in zip_source_crc()
76 return zip_source_layered(za, src, crc_read, ctx); in zip_source_crc()
83 struct crc_context *ctx; in crc_read() local
86 ctx = (struct crc_context *)_ctx; in crc_read()
90 ctx->position = 0; in crc_read()
95 _zip_error_set_from_source(&ctx->error, src); in crc_read()
100 if (ctx->crc_position == ctx->position) { in crc_read()
101 ctx->crc_complete = 1; in crc_read()
102 ctx->size = ctx->position; in crc_read()
104 if (ctx->validate) { in crc_read()
108 _zip_error_set_from_source(&ctx->error, src); in crc_read()
112 if ((st.valid & ZIP_STAT_CRC) && st.crc != ctx->crc) { in crc_read()
113 zip_error_set(&ctx->error, ZIP_ER_CRC, 0); in crc_read()
116 if ((st.valid & ZIP_STAT_SIZE) && st.size != ctx->size) { in crc_read()
117 zip_error_set(&ctx->error, ZIP_ER_INCONS, 0); in crc_read()
123 else if (!ctx->crc_complete && ctx->position <= ctx->crc_position) { in crc_read()
126 for (i = ctx->crc_position - ctx->position; i < (zip_uint64_t)n; i += nn) { in crc_read()
129 ctx->crc = (zip_uint32_t)crc32(ctx->crc, (const Bytef *)data+i, (uInt)nn); in crc_read()
130 ctx->crc_position += nn; in crc_read()
133 ctx->position += (zip_uint64_t)n; in crc_read()
145 if (ctx->crc_complete) { in crc_read()
148 st->size = ctx->size; in crc_read()
149 st->crc = ctx->crc; in crc_read()
150 st->comp_size = ctx->size; in crc_read()
159 return zip_error_to_data(&ctx->error, data, len); in crc_read()
162 free(ctx); in crc_read()
170 _zip_error_set_from_source(&ctx->error, src); in crc_read()
180 …zip_source_args_seek_t *args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, data, len, &ctx->error); in crc_read()
186 _zip_error_set_from_source(&ctx->error, src); in crc_read()
190 ctx->position = (zip_uint64_t)new_position; in crc_read()
196 return (zip_int64_t)ctx->position; in crc_read()
199 zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); in crc_read()