1
2 /*
3 * Copyright (C) Igor Sysoev
4 */
5
6
7 #ifndef _NGX_FILE_H_INCLUDED_
8 #define _NGX_FILE_H_INCLUDED_
9
10
11 #include <ngx_config.h>
12 #include <ngx_core.h>
13
14 typedef struct ngx_path_s ngx_path_t;
15
16 #include <ngx_garbage_collector.h>
17
18
19 struct ngx_file_s {
20 ngx_fd_t fd;
21 ngx_str_t name;
22 ngx_file_info_t info;
23
24 off_t offset;
25 off_t sys_offset;
26
27 ngx_log_t *log;
28
29 ngx_uint_t valid_info; /* unsigned valid_info:1; */
30 };
31
32 #define NGX_MAX_PATH_LEVEL 3
33
34 struct ngx_path_s {
35 ngx_str_t name;
36 size_t len;
37 size_t level[3];
38 ngx_gc_handler_pt cleaner;
39
40 u_char *conf_file;
41 ngx_uint_t line;
42 };
43
44
45 typedef struct {
46 ngx_file_t file;
47 off_t offset;
48 ngx_path_t *path;
49 ngx_pool_t *pool;
50 char *warn;
51
52 ngx_uint_t access;
53
54 unsigned log_level:8;
55 unsigned persistent:1;
56 unsigned clean:1;
57 } ngx_temp_file_t;
58
59
60 typedef struct {
61 ngx_uint_t access;
62 time_t time;
63 ngx_fd_t fd;
64
65 unsigned create_path:1;
66 unsigned delete:1;
67
68 ngx_log_t *log;
69 } ngx_ext_rename_file_t;
70
71
72 typedef struct ngx_tree_ctx_s ngx_tree_ctx_t;
73
74 typedef ngx_int_t (*ngx_tree_init_handler_pt) (void *ctx, void *prev);
75 typedef ngx_int_t (*ngx_tree_handler_pt) (ngx_tree_ctx_t *ctx, ngx_str_t *name);
76
77 struct ngx_tree_ctx_s {
78 off_t size;
79 ngx_uint_t access;
80 time_t mtime;
81
82 ngx_tree_init_handler_pt init_handler;
83 ngx_tree_handler_pt file_handler;
84 ngx_tree_handler_pt pre_tree_handler;
85 ngx_tree_handler_pt post_tree_handler;
86 ngx_tree_handler_pt spec_handler;
87
88 void *data;
89 size_t alloc;
90
91 ngx_log_t *log;
92 };
93
94
95 ssize_t ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain);
96 ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
97 ngx_pool_t *pool, ngx_uint_t persistent, ngx_uint_t clean,
98 ngx_uint_t access);
99 void ngx_create_hashed_filename(ngx_path_t *path, u_char *file, size_t len);
100 ngx_int_t ngx_create_path(ngx_file_t *file, ngx_path_t *path);
101 ngx_err_t ngx_create_full_path(u_char *dir, ngx_uint_t access);
102 ngx_int_t ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot);
103 ngx_int_t ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user);
104 ngx_int_t ngx_ext_rename_file(ngx_str_t *src, ngx_str_t *to,
105 ngx_ext_rename_file_t *ext);
106 ngx_int_t ngx_walk_tree(ngx_tree_ctx_t *ctx, ngx_str_t *tree);
107
108 void ngx_init_temp_number(void);
109 ngx_atomic_uint_t ngx_next_temp_number(ngx_uint_t collision);
110
111 char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
112 char *ngx_conf_set_access_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
113
114
115 #define ngx_conf_merge_path_value(curr, prev, path, l1, l2, l3, clean, cf) \
116 if (curr == NULL) { \
117 if (prev == NULL) { \
118 curr = ngx_palloc(cf->pool, sizeof(ngx_path_t)); \
119 if (curr == NULL) { \
120 return NGX_CONF_ERROR; \
121 } \
122 \
123 curr->name.len = sizeof(path) - 1; \
124 curr->name.data = (u_char *) path; \
125 \
126 if (ngx_conf_full_name(cf->cycle, &curr->name, 0) == NGX_ERROR) { \
127 return NGX_CONF_ERROR; \
128 } \
129 \
130 curr->level[0] = l1; \
131 curr->level[1] = l2; \
132 curr->level[2] = l3; \
133 curr->len = l1 + l2 + l3 + (l1 ? 1:0) + (l2 ? 1:0) + (l3 ? 1:0); \
134 curr->cleaner = clean; \
135 curr->conf_file = NULL; \
136 \
137 if (ngx_add_path(cf, &curr) == NGX_ERROR) { \
138 return NGX_CONF_ERROR; \
139 } \
140 \
141 } else { \
142 curr = prev; \
143 } \
144 }
145
146
147
148 #endif /* _NGX_FILE_H_INCLUDED_ */
149
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.