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 ctx->eof = 0; in zip_source_crc()
70 ctx->validate = validate; in zip_source_crc()
71 ctx->e[0] = ctx->e[1] = 0; in zip_source_crc()
72 ctx->size = 0; in zip_source_crc()
73 ctx->crc = 0; in zip_source_crc()
75 return zip_source_layered(za, src, crc_read, ctx); in zip_source_crc()
84 struct crc_context *ctx; in crc_read() local
87 ctx = (struct crc_context *)_ctx; in crc_read()
91 ctx->eof = 0; in crc_read()
92 ctx->crc = (zip_uint32_t)crc32(0, NULL, 0); in crc_read()
93 ctx->size = 0; in crc_read()
98 if (ctx->eof || len == 0) in crc_read()
105 ctx->eof = 1; in crc_read()
106 if (ctx->validate) { in crc_read()
112 if ((st.valid & ZIP_STAT_CRC) && st.crc != ctx->crc) { in crc_read()
113 ctx->e[0] = ZIP_ER_CRC; in crc_read()
114 ctx->e[1] = 0; in crc_read()
118 if ((st.valid & ZIP_STAT_SIZE) && st.size != ctx->size) { in crc_read()
119 ctx->e[0] = ZIP_ER_INCONS; in crc_read()
120 ctx->e[1] = 0; in crc_read()
127 ctx->size += (zip_uint64_t)n; in crc_read()
128 …ctx->crc = (zip_uint32_t)crc32(ctx->crc, (const Bytef *)data, (uInt)n); /* TODO: check for overflo… in crc_read()
141 if (ctx->eof) { in crc_read()
144 st->size = ctx->size; in crc_read()
145 st->crc = ctx->crc; in crc_read()
146 st->comp_size = ctx->size; in crc_read()
155 memcpy(data, ctx->e, sizeof(ctx->e)); in crc_read()
159 free(ctx); in crc_read()