58 |
58 |
59 void free_acl_file(ACLFile *conf) { |
59 void free_acl_file(ACLFile *conf) { |
60 cxListDestroy(conf->namedACLs); |
60 cxListDestroy(conf->namedACLs); |
61 cxListDestroy(conf->uriACLs); |
61 cxListDestroy(conf->uriACLs); |
62 cxListDestroy(conf->pathACLs); |
62 cxListDestroy(conf->pathACLs); |
63 cxMempoolDestroy(conf->parser.mp->data); // TODO: is there a better way to access the mempool? |
63 cxMempoolDestroy(conf->parser.a->data); // TODO: is there a better way to access the mempool? |
64 free(conf); |
64 free(conf); |
65 } |
65 } |
66 |
66 |
67 int acl_parse(void *p, ConfigLine *begin, ConfigLine *end, cxmutstr line) { |
67 int acl_parse(void *p, ConfigLine *begin, ConfigLine *end, cxmutstr line) { |
68 ACLFile *aclf = p; |
68 ACLFile *aclf = p; |
69 CxAllocator *mp = aclf->parser.mp; |
69 CxAllocator *mp = aclf->parser.a; |
70 |
70 |
71 if(cx_strprefix(cx_strcast(line), cx_str("ACL "))) { |
71 if(cx_strprefix(cx_strcast(line), cx_str("ACL "))) { |
72 cxmutstr param = cx_strsubs_m(line, 4); |
72 cxmutstr param = cx_strsubs_m(line, 4); |
73 ConfigParam *plist = cfg_param_list(param, mp); |
73 ConfigParam *plist = cfg_param_list(param, mp); |
74 ACLConfig *acl = OBJ_NEW(mp, ACLConfig); |
74 ACLConfig *acl = OBJ_NEW(mp, ACLConfig); |
112 |
112 |
113 #define ACE_MAX_TOKENS 2048 |
113 #define ACE_MAX_TOKENS 2048 |
114 |
114 |
115 int parse_ace(ACLFile *f, cxmutstr line) { |
115 int parse_ace(ACLFile *f, cxmutstr line) { |
116 ACLConfig *cur = f->cur; |
116 ACLConfig *cur = f->cur; |
117 CxAllocator *mp = f->parser.mp; |
117 CxAllocator *mp = f->parser.a; |
118 |
118 |
119 cxstring *tk = NULL; |
119 cxstring *tk = NULL; |
120 ssize_t tkn = cx_strsplit_a(mp, cx_strcast(line), cx_str(":"), ACE_MAX_TOKENS, &tk); |
120 ssize_t tkn = cx_strsplit_a(mp, cx_strcast(line), cx_str(":"), ACE_MAX_TOKENS, &tk); |
121 if(!tk || tkn < 3) { |
121 if(!tk || tkn < 3) { |
122 ws_cfg_log(LOG_FAILURE, "parse_ace: to few tokens: %.*s", (int)line.length, line.ptr); |
122 ws_cfg_log(LOG_FAILURE, "parse_ace: to few tokens: %.*s", (int)line.length, line.ptr); |