Lines Matching refs:ctx

166 void inithelpscan(struct scan_ctx *ctx,  in inithelpscan()  argument
171 ctx->trigger = trigger; in inithelpscan()
172 ctx->tlen = strlen(trigger); in inithelpscan()
173 ctx->arg = arg; in inithelpscan()
174 ctx->flen = strlen(arg); in inithelpscan()
175 ctx->endarg = endarg; in inithelpscan()
176 ctx->elen = strlen(endarg); in inithelpscan()
177 DEBUGASSERT((ctx->elen < sizeof(ctx->rbuf)) || in inithelpscan()
178 (ctx->flen < sizeof(ctx->rbuf))); in inithelpscan()
179 ctx->show = 0; in inithelpscan()
180 ctx->olen = 0; in inithelpscan()
181 memset(ctx->rbuf, 0, sizeof(ctx->rbuf)); in inithelpscan()
184 bool helpscan(unsigned char *buf, size_t len, struct scan_ctx *ctx) in helpscan() argument
188 if(!ctx->show) { in helpscan()
190 memmove(&ctx->rbuf[0], &ctx->rbuf[1], ctx->tlen - 1); in helpscan()
191 ctx->rbuf[ctx->tlen - 1] = buf[i]; in helpscan()
192 if(!memcmp(ctx->rbuf, ctx->trigger, ctx->tlen)) in helpscan()
193 ctx->show++; in helpscan()
197 if(ctx->show == 1) { in helpscan()
198 memmove(&ctx->rbuf[0], &ctx->rbuf[1], ctx->flen - 1); in helpscan()
199 ctx->rbuf[ctx->flen - 1] = buf[i]; in helpscan()
200 if(!memcmp(ctx->rbuf, ctx->arg, ctx->flen)) { in helpscan()
202 fputs(&ctx->arg[1], stdout); in helpscan()
203 ctx->show++; in helpscan()
208 memmove(&ctx->rbuf[0], &ctx->rbuf[1], ctx->elen - 1); in helpscan()
209 ctx->rbuf[ctx->elen - 1] = buf[i]; in helpscan()
210 if(!memcmp(ctx->rbuf, ctx->endarg, ctx->elen)) in helpscan()
214 DEBUGASSERT(ctx->olen < sizeof(ctx->obuf)); in helpscan()
215 if(ctx->olen == sizeof(ctx->obuf)) in helpscan()
217 ctx->obuf[ctx->olen++] = 0; in helpscan()
218 ctx->olen = 0; in helpscan()
219 puts(ctx->obuf); in helpscan()
222 DEBUGASSERT(ctx->olen < sizeof(ctx->obuf)); in helpscan()
223 if(ctx->olen == sizeof(ctx->obuf)) in helpscan()
225 ctx->obuf[ctx->olen++] = buf[i]; in helpscan()