Module to check if file contains a character

alexander_koch_log alexander_koch_log at
Sat Mar 16 15:15:20 UTC 2013


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]  == ?



More information about the nginx mailing list