Module to check if file contains a character

Hello,

Without reading the whole file, what is the best approach to only check
if the beginning of the file contains a specific character?

Would something like this be the right approach?

b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
b->file = ngx_pcalloc(r->pool, sizeof(ngx_file_t));

then set file_pos, file_last etc.

and later do ngx_cpymem(s, b->pos, size) to copy it in a u_char and then
do a if s[0] == ?

Thanks,

Alex

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs