add env var support
This commit is contained in:
		
							parent
							
								
									203bab3a7e
								
							
						
					
					
						commit
						8643448ff1
					
				@ -549,6 +549,9 @@ static int ptql_branch_match(ptql_branch_t *branch)
 | 
				
			|||||||
                                 branch->value.chr[0]);
 | 
					                                 branch->value.chr[0]);
 | 
				
			||||||
      case PTQL_VALUE_TYPE_STR:
 | 
					      case PTQL_VALUE_TYPE_STR:
 | 
				
			||||||
      case PTQL_VALUE_TYPE_ANY:
 | 
					      case PTQL_VALUE_TYPE_ANY:
 | 
				
			||||||
 | 
					        if (!branch->value.str) {
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        return branch->match.str(branch,
 | 
					        return branch->match.str(branch,
 | 
				
			||||||
                                 (char *)DATA_PTR(branch),
 | 
					                                 (char *)DATA_PTR(branch),
 | 
				
			||||||
                                 branch->value.str);
 | 
					                                 branch->value.str);
 | 
				
			||||||
@ -1066,10 +1069,15 @@ static int ptql_branch_add(ptql_parse_branch_t *parsed,
 | 
				
			|||||||
        return SIGAR_PTQL_MALFORMED_QUERY;
 | 
					        return SIGAR_PTQL_MALFORMED_QUERY;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ((*parsed->value == '$') &&
 | 
					    if (*parsed->value == '$') {
 | 
				
			||||||
        sigar_isdigit(*(parsed->value+1)))
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        is_set = 1;
 | 
					        is_set = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (branch->op_name == PTQL_OP_RE) {
 | 
				
			||||||
 | 
					            /* not for use with .re */
 | 
				
			||||||
 | 
					            return SIGAR_PTQL_MALFORMED_QUERY;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (sigar_isdigit(*(parsed->value+1))) {
 | 
				
			||||||
            branch->op_flags |= PTQL_OP_FLAG_REF;
 | 
					            branch->op_flags |= PTQL_OP_FLAG_REF;
 | 
				
			||||||
            branch->value.ui32 = atoi(parsed->value+1) - 1;
 | 
					            branch->value.ui32 = atoi(parsed->value+1) - 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1081,9 +1089,14 @@ static int ptql_branch_add(ptql_parse_branch_t *parsed,
 | 
				
			|||||||
                /* self reference */
 | 
					                /* self reference */
 | 
				
			||||||
                return SIGAR_PTQL_MALFORMED_QUERY;
 | 
					                return SIGAR_PTQL_MALFORMED_QUERY;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        else if (branch->op_name == PTQL_OP_RE) {
 | 
					        }
 | 
				
			||||||
            /* not for use with .re */
 | 
					        else {
 | 
				
			||||||
            return SIGAR_PTQL_MALFORMED_QUERY;
 | 
					            if ((ptr = getenv(parsed->value+1))) {
 | 
				
			||||||
 | 
					                branch->value.str = strdup(ptr);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else {
 | 
				
			||||||
 | 
					                branch->value.str = NULL;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else if (branch->op_name == PTQL_OP_RE) {
 | 
					    else if (branch->op_name == PTQL_OP_RE) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user