nginx 基础结构

2021/6/21 7:26:09

本文主要是介绍nginx 基础结构,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 


//gcc -o ngx_list_main ngx_list_main.c -I /root/nginx-1.16.1/src/core/ -I /root/nginx-1.16.1/objs/  -I /root/nginx-1.16.1/src/os/unix/ -I /root/nginx-1.16.1/pcre-8.41/ -I /root/nginx-1.16.1/src/event/ /root/nginx-1.16.1/objs/src/core/ngx_list.o /root/nginx-1.16.1/objs/src/core/ngx_string.o /root/nginx-1.16.1//objs/src/core/ngx_palloc.o /root/nginx-1.16.1/objs/src/os/unix/ngx_alloc.o

#include <stdio.h>
#include <string.h>

#include "ngx_config.h"

#include "ngx_core.h"


#include "ngx_list.h"
#include "ngx_palloc.h"
#include "ngx_string.h"

#define N	10



volatile ngx_cycle_t *ngx_cycle;
 
void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log,
			ngx_err_t err, const char *fmt, ...)
{



}


void print_list(ngx_list_t *l) {
	ngx_list_part_t *p = &(l->part);
	
	while (p) {

		int i = 0;
		for (i = 0;i < p->nelts;i ++) {
			printf("%s\n", (char*)(((ngx_str_t*)p->elts + i)->data));
		}
		p = p->next;
		printf(" -------------------------- \n");
	}

}

int main() {

	ngx_pool_t *pool = ngx_create_pool(1024, NULL);

	ngx_list_t *l = ngx_list_create(pool, N, sizeof(ngx_str_t));

	int i = 0;
	for (i = 0;i < 24;i ++) {

		ngx_str_t *ptr = ngx_list_push(l);
		
		char *buf = ngx_palloc(pool, 32);
		sprintf(buf, "King %d", i+1);

		ptr->len = strlen(buf);
		ptr->data = buf;
	}

	print_list(l);

}


 



这篇关于nginx 基础结构的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程