842 |
842 |
843 static int set_client_condition(pool_handle_t *pool, ConfigNode *node, Condition *condition) { |
843 static int set_client_condition(pool_handle_t *pool, ConfigNode *node, Condition *condition) { |
844 return 0; |
844 return 0; |
845 } |
845 } |
846 |
846 |
847 static int set_if_condition(pool_handle_t *pool, ConfigNode *node, Condition *condition) { |
847 static int set_if_condition(pool_handle_t *pool, ConfigNode *node, Condition *condition) { |
848 printf("\n"); |
848 // convert to parameters to a list of tokens |
849 |
849 // usually, one parameter is one token, however the config parser |
850 ConfigParam *token = node->args; |
850 // converts name=value pairs to one ConfigParam |
851 while(token) { |
851 |
852 printf("token: %s %s\n", token->name.ptr, token->value.ptr); |
852 // list of cxmutstr, however the expression parser will use this |
853 token = token->next; |
853 // as list of cxstring, but that is totally fine |
854 } |
854 CxList *tokens = cxLinkedListCreate(pool_allocator(pool), cx_cmp_ptr, sizeof(cxmutstr)); |
855 printf("\n"); |
855 ConfigParam *arg = node->args; |
856 fflush(stdout); |
856 while(arg) { |
857 |
857 if(arg->name.length > 0) { |
858 return 0; |
858 // arg text is name=value, therefore we add 3 tokens |
|
859 // name, "=", value |
|
860 cxListAdd(tokens, &arg->name); |
|
861 cxmutstr op = (cxmutstr){ "=", 1 }; |
|
862 cxListAdd(tokens, &op); |
|
863 } |
|
864 if(cxListAdd(tokens, &arg->value)) { |
|
865 cxListDestroy(tokens); |
|
866 return 1; // OOM |
|
867 } |
|
868 arg = arg->next; |
|
869 } |
|
870 |
|
871 int ret = 0; |
|
872 condition->expression = condition_create(pool, tokens); |
|
873 if(!condition->expression) { |
|
874 ret = 1; |
|
875 } |
|
876 |
|
877 // don't need the token list anymore |
|
878 cxListDestroy(tokens); |
|
879 |
|
880 return ret; |
859 } |
881 } |
860 |
882 |
861 // convert a condition |
883 // convert a condition |
862 static Condition* convert_objconf_condition( |
884 static Condition* convert_objconf_condition( |
863 pool_handle_t *pool, |
885 pool_handle_t *pool, |