Created
August 15, 2015 05:03
-
-
Save SpringMT/95781581639f66e64351 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <ngx_config.h> | |
| #include <ngx_core.h> | |
| #include <nginx.h> | |
| static u_char *ngx_conf_file; | |
| int main(int argc, char *const *argv) | |
| { | |
| ngx_buf_t *b; | |
| ngx_log_t *log; | |
| ngx_uint_t i; | |
| ngx_cycle_t *cycle, init_cycle; | |
| ngx_conf_dump_t *cd; | |
| ngx_core_conf_t *ccf; | |
| ngx_conf_file = (u_char *) argv[1]; | |
| printf("Nginx config file is %s\n", ngx_conf_file); | |
| ngx_memzero(&init_cycle, sizeof(ngx_cycle_t)); | |
| init_cycle.log = log; | |
| ngx_cycle = &init_cycle; | |
| init_cycle.pool = ngx_create_pool(1024, log); | |
| if (init_cycle.pool == NULL) { | |
| return 1; | |
| } | |
| cycle = ngx_init_cycle(&init_cycle); | |
| if (cycle == NULL) { | |
| ngx_log_stderr(0, "configuration file %s test failed", init_cycle.conf_file.data); | |
| return 1; | |
| } | |
| cd = cycle->config_dump.elts; | |
| for (i = 0; i < cycle->config_dump.nelts; i++) { | |
| ngx_write_stdout("# configuration file "); | |
| (void) ngx_write_fd(ngx_stdout, cd[i].name.data, cd[i].name.len); | |
| ngx_write_stdout(":" NGX_LINEFEED); | |
| b = cd[i].buffer; | |
| (void) ngx_write_fd(ngx_stdout, b->pos, b->last - b->pos); | |
| ngx_write_stdout(NGX_LINEFEED); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment