MCPcopy Create free account
hub / github.com/OpenPrinting/cups / eval_expr

Function eval_expr

tools/ippfind.c:1742–1851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1740 */
1741
1742static int /* O - Result of evaluation */
1743eval_expr(ippfind_srv_t *service, /* I - Service */
1744 ippfind_expr_t *expressions) /* I - Expressions */
1745{
1746 ippfind_op_t logic; /* Logical operation */
1747 int result; /* Result of current expression */
1748 ippfind_expr_t *expression; /* Current expression */
1749 const char *val; /* TXT value */
1750
1751 /*
1752 * Loop through the expressions...
1753 */
1754
1755 if (expressions && expressions->parent)
1756 logic = expressions->parent->op;
1757 else
1758 logic = IPPFIND_OP_AND;
1759
1760 for (expression = expressions; expression; expression = expression->next)
1761 {
1762 switch (expression->op)
1763 {
1764 default :
1765 case IPPFIND_OP_AND :
1766 case IPPFIND_OP_OR :
1767 if (expression->child)
1768 result = eval_expr(service, expression->child);
1769 else
1770 result = expression->op == IPPFIND_OP_AND;
1771 break;
1772 case IPPFIND_OP_TRUE :
1773 result = 1;
1774 break;
1775 case IPPFIND_OP_FALSE :
1776 result = 0;
1777 break;
1778 case IPPFIND_OP_IS_LOCAL :
1779 result = service->is_local;
1780 break;
1781 case IPPFIND_OP_IS_REMOTE :
1782 result = !service->is_local;
1783 break;
1784 case IPPFIND_OP_DOMAIN_REGEX :
1785 result = !regexec(&(expression->re), service->domain, 0, NULL, 0);
1786 break;
1787 case IPPFIND_OP_NAME_REGEX :
1788 result = !regexec(&(expression->re), service->name, 0, NULL, 0);
1789 break;
1790 case IPPFIND_OP_NAME_LITERAL :
1791 result = !_cups_strcasecmp(expression->name, service->name);
1792 break;
1793 case IPPFIND_OP_HOST_REGEX :
1794 result = !regexec(&(expression->re), service->host, 0, NULL, 0);
1795 break;
1796 case IPPFIND_OP_PORT_RANGE :
1797 result = service->port >= expression->range[0] &&
1798 service->port <= expression->range[1];
1799 break;

Callers 1

mainFunction · 0.85

Calls 6

regexecFunction · 0.85
_cups_strcasecmpFunction · 0.85
cupsGetOptionFunction · 0.85
exec_programFunction · 0.85
list_serviceFunction · 0.85
_cupsLangPutsFunction · 0.85

Tested by

no test coverage detected