Forum: NGINX Module to check if file contains a character

Posted by Alexander Koch (alexander_koch)
on 2013-03-16 16:15
(Received via mailing list)
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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.