ngx_http_headers_static_module.c
/**	Populate a ngx_str_t with a newly-allocated path to a metafile, built from
	the contents of source_path and loc_conf.
*/
Populate a ngx_str_t with a newly-allocated path to a metafile, built from
the contents of source_path and loc_conf.
Populate a ngx_str_t with a newly - allocated path to a metafile built from the contents of source_path and loc_conf .
inline
static
ngx_int_t metafilename_build_(ngx_pool_t *pool, ngx_str_t *source_path, ngx_http_headers_static_loc_conf_t *loc_conf, ngx_str_t *metafilename) {
	ngx_str_t filename;
	u_char *x;
	filename = *source_path;
	x = (u_char *)strrchr((char *)source_path->data, '/');
	if (x == NULL) {
		source_path->len = 0;
	} else {
		source_path->len = x - source_path->data;
		filename.len -= source_path->len + 2;
		filename.data = x + 1;
		*x = '\0';
	}
	metafilename->len = source_path->len + (source_path->len ? 1 : 0) +
	                    loc_conf->path.len + (loc_conf->path.len ? 1 : 0) +
	                    filename.len +
	                    loc_conf->suffix.len;
	metafilename->data = ngx_pnalloc(pool, metafilename->len + 1);
	if (metafilename->data == NULL) {
		ngx_memset(metafilename, 0, sizeof *metafilename);
		return NGX_ERROR;
	}
	x = metafilename->data;
	if (source_path->len) {
		ngx_memcpy(x, source_path->data, source_path->len);
		x += source_path->len;
		*(x++) = '/';
	}
	if (loc_conf->path.len) {
		ngx_memcpy(x, loc_conf->path.data, loc_conf->path.len);
		x += loc_conf->path.len;
		*(x++) = '/';
	}
	ngx_memcpy(x, filename.data, filename.len);
	x += filename.len;
	if (loc_conf->suffix.len) {
		ngx_memcpy(x, loc_conf->suffix.data, loc_conf->suffix.len);
		x += loc_conf->suffix.len;
	}
	*x = '\0';
	return NGX_OK;
}
inline static ngx_int_t metafilename_build_ ( ngx_pool_t * pool , ngx_str_t * source_path , ngx_http_headers_static_loc_conf_t * loc_conf , ngx_str_t * metafilename ) { ngx_str_t filename ; u_char * x ; filename = * source_path ; x = ( u_char * ) strrchr ( ( char * ) source_path -> data , ' ' ) ; if ( x == NULL ) { source_path -> len = 0 ; } else { source_path -> len = x - source_path -> data ; filename . len -= source_path -> len + 2 ; filename . data = x + 1 ; * x = ' \0 ' ; } metafilename -> len = source_path -> len + ( source_path -> len ? 1 : 0 ) + loc_conf -> path . len + ( loc_conf -> path . len ? 1 : 0 ) + filename . len + loc_conf -> suffix . len ; metafilename -> data = ngx_pnalloc ( pool , metafilename -> len + 1 ) ; if ( metafilename -> data == NULL ) { ngx_memset ( metafilename , 0 , sizeof * metafilename ) ; return NGX_ERROR ; } x = metafilename -> data ; if ( source_path -> len ) { ngx_memcpy ( x , source_path -> data , source_path -> len ) ; x += source_path -> len ; * ( x ++ ) = ' ' ; } if ( loc_conf -> path . len ) { ngx_memcpy ( x , loc_conf -> path . data , loc_conf -> path . len ) ; x += loc_conf -> path . len ; * ( x ++ ) = ' ' ; } ngx_memcpy ( x , filename . data , filename . len ) ; x += filename . len ; if ( loc_conf -> suffix . len ) { ngx_memcpy ( x , loc_conf -> suffix . data , loc_conf -> suffix . len ) ; x += loc_conf -> suffix . len ; } * x = ' \0 ' ; return NGX_OK ; }
Populate a ngx_str_t with a newly-allocated path to a metafile, built from
the contents of source_path and loc_conf.
Populate a ngx_str_t with a newly - allocated path to a metafile built from the contents of source_path and loc_conf .
/* split source_path into filename and basename */