~ubuntu-branches/ubuntu/trusty/libprelude/trusty

« back to all changes in this revision

Viewing changes to src/idmef-criteria-string.yac.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-04-29 11:31:50 UTC
  • mfrom: (1.1.12 upstream) (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090429113150-qw9oxc1e50ldljck
Tags: 0.9.22-2ubuntu1
* Merge from debian unstable, remaining changes:
  - Build-Depend on libltdl7-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
#include <stdarg.h>
130
130
#include <ctype.h>
131
131
 
132
 
#include "prelude-thread.h"
 
132
#include "glthread/lock.h"
 
133
 
133
134
#include "prelude-log.h"
134
135
#include "prelude-error.h"
135
136
#include "prelude-inttypes.h"
144
145
static idmef_criteria_t *processed_criteria;
145
146
static idmef_criterion_operator_t cur_operator;
146
147
 
147
 
pthread_mutex_t _criteria_parse_mutex = PTHREAD_MUTEX_INITIALIZER;
 
148
gl_lock_t _criteria_parse_mutex = gl_lock_initializer;
148
149
 
149
150
 
150
151
#define operator_or 1
212
213
 
213
214
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
214
215
typedef union YYSTYPE
215
 
#line 98 "idmef-criteria-string.yac.y"
 
216
#line 99 "idmef-criteria-string.yac.y"
216
217
{
217
218
        char *str;
218
219
        int operator;
221
222
        idmef_criterion_operator_t relation;
222
223
}
223
224
/* Line 187 of yacc.c.  */
224
 
#line 225 "idmef-criteria-string.yac.c"
 
225
#line 226 "idmef-criteria-string.yac.c"
225
226
        YYSTYPE;
226
227
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
227
228
# define YYSTYPE_IS_DECLARED 1
234
235
 
235
236
 
236
237
/* Line 216 of yacc.c.  */
237
 
#line 238 "idmef-criteria-string.yac.c"
 
238
#line 239 "idmef-criteria-string.yac.c"
238
239
 
239
240
#ifdef short
240
241
# undef short
529
530
/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
530
531
static const yytype_uint16 yyrline[] =
531
532
{
532
 
       0,   153,   153,   160,   164,   175,   179,   183,   191,   195,
533
 
     199,   209,   222,   236,   257,   266,   270,   277,   278,   279,
534
 
     280,   281,   282,   283,   284,   285,   286,   287,   288,   289,
535
 
     290,   291,   292,   293,   294,   298,   299
 
533
       0,   154,   154,   161,   165,   176,   180,   184,   192,   196,
 
534
     200,   210,   223,   237,   258,   267,   271,   278,   279,   280,
 
535
     281,   282,   283,   284,   285,   286,   287,   288,   289,   290,
 
536
     291,   292,   293,   294,   295,   299,   300
536
537
};
537
538
#endif
538
539
 
1157
1158
  switch (yytype)
1158
1159
    {
1159
1160
      case 3: /* "\"<IDMEF-Value>\"" */
1160
 
#line 111 "idmef-criteria-string.yac.y"
1161
 
        { free ((yyvaluep->str)); };
1162
 
#line 1163 "idmef-criteria-string.yac.c"
 
1161
#line 112 "idmef-criteria-string.yac.y"
 
1162
        { free((yyvaluep->str)); };
 
1163
#line 1164 "idmef-criteria-string.yac.c"
1163
1164
        break;
1164
1165
      case 4: /* "\"<IDMEF-Path>\"" */
1165
 
#line 111 "idmef-criteria-string.yac.y"
1166
 
        { free ((yyvaluep->str)); };
1167
 
#line 1168 "idmef-criteria-string.yac.c"
 
1166
#line 112 "idmef-criteria-string.yac.y"
 
1167
        { free((yyvaluep->str)); };
 
1168
#line 1169 "idmef-criteria-string.yac.c"
1168
1169
        break;
1169
1170
      case 29: /* "criteria" */
1170
 
#line 112 "idmef-criteria-string.yac.y"
 
1171
#line 113 "idmef-criteria-string.yac.y"
1171
1172
        { idmef_criteria_destroy((yyvaluep->criteria)); };
1172
 
#line 1173 "idmef-criteria-string.yac.c"
 
1173
#line 1174 "idmef-criteria-string.yac.c"
1173
1174
        break;
1174
1175
 
1175
1176
      default:
1478
1479
  switch (yyn)
1479
1480
    {
1480
1481
        case 2:
1481
 
#line 153 "idmef-criteria-string.yac.y"
 
1482
#line 154 "idmef-criteria-string.yac.y"
1482
1483
    {
1483
1484
                processed_criteria = (yyvsp[(1) - (1)].criteria);
1484
1485
        }
1485
1486
    break;
1486
1487
 
1487
1488
  case 3:
1488
 
#line 160 "idmef-criteria-string.yac.y"
 
1489
#line 161 "idmef-criteria-string.yac.y"
1489
1490
    {
1490
1491
                (yyval.criteria) = (yyvsp[(1) - (1)].criteria);
1491
1492
        }
1492
1493
    break;
1493
1494
 
1494
1495
  case 4:
1495
 
#line 164 "idmef-criteria-string.yac.y"
 
1496
#line 165 "idmef-criteria-string.yac.y"
1496
1497
    {
1497
1498
                if ( (yyvsp[(2) - (3)].operator) == operator_or )
1498
1499
                        idmef_criteria_or_criteria((yyvsp[(1) - (3)].criteria), (yyvsp[(3) - (3)].criteria));
1504
1505
    break;
1505
1506
 
1506
1507
  case 5:
1507
 
#line 175 "idmef-criteria-string.yac.y"
 
1508
#line 176 "idmef-criteria-string.yac.y"
1508
1509
    {
1509
1510
                (yyval.criteria) = (yyvsp[(1) - (1)].criteria);
1510
1511
        }
1511
1512
    break;
1512
1513
 
1513
1514
  case 6:
1514
 
#line 179 "idmef-criteria-string.yac.y"
 
1515
#line 180 "idmef-criteria-string.yac.y"
1515
1516
    {
1516
1517
                (yyval.criteria) = (yyvsp[(2) - (3)].criteria);
1517
1518
        }
1518
1519
    break;
1519
1520
 
1520
1521
  case 7:
1521
 
#line 183 "idmef-criteria-string.yac.y"
 
1522
#line 184 "idmef-criteria-string.yac.y"
1522
1523
    {
1523
1524
                idmef_criteria_set_negation((yyvsp[(3) - (4)].criteria), TRUE);
1524
1525
                (yyval.criteria) = (yyvsp[(3) - (4)].criteria);
1526
1527
    break;
1527
1528
 
1528
1529
  case 8:
1529
 
#line 191 "idmef-criteria-string.yac.y"
 
1530
#line 192 "idmef-criteria-string.yac.y"
1530
1531
    {
1531
1532
                (yyval.criteria) = (yyvsp[(4) - (5)].criteria);
1532
1533
        }
1533
1534
    break;
1534
1535
 
1535
1536
  case 9:
1536
 
#line 195 "idmef-criteria-string.yac.y"
 
1537
#line 196 "idmef-criteria-string.yac.y"
1537
1538
    {
1538
1539
                (yyval.criteria) = (yyvsp[(3) - (3)].criteria);
1539
1540
        }
1540
1541
    break;
1541
1542
 
1542
1543
  case 10:
1543
 
#line 199 "idmef-criteria-string.yac.y"
 
1544
#line 200 "idmef-criteria-string.yac.y"
1544
1545
    {
1545
1546
                idmef_criteria_t *criteria;
1546
1547
 
1553
1554
    break;
1554
1555
 
1555
1556
  case 11:
1556
 
#line 209 "idmef-criteria-string.yac.y"
 
1557
#line 210 "idmef-criteria-string.yac.y"
1557
1558
    {
1558
1559
                idmef_criteria_t *criteria;
1559
1560
 
1566
1567
    break;
1567
1568
 
1568
1569
  case 12:
1569
 
#line 222 "idmef-criteria-string.yac.y"
 
1570
#line 223 "idmef-criteria-string.yac.y"
1570
1571
    {
1571
1572
                real_ret = idmef_path_new_fast(&cur_path, (yyvsp[(1) - (1)].str));
1572
1573
                free((yyvsp[(1) - (1)].str));
1580
1581
    break;
1581
1582
 
1582
1583
  case 13:
1583
 
#line 236 "idmef-criteria-string.yac.y"
 
1584
#line 237 "idmef-criteria-string.yac.y"
1584
1585
    {
1585
1586
                idmef_criteria_t *criteria;
1586
1587
                idmef_criterion_value_t *value = NULL;
1600
1601
    break;
1601
1602
 
1602
1603
  case 14:
1603
 
#line 257 "idmef-criteria-string.yac.y"
 
1604
#line 258 "idmef-criteria-string.yac.y"
1604
1605
    {
1605
1606
                if ( (yyvsp[(2) - (3)].operator) == operator_or )
1606
1607
                        idmef_criteria_or_criteria((yyvsp[(1) - (3)].criteria), (yyvsp[(3) - (3)].criteria));
1612
1613
    break;
1613
1614
 
1614
1615
  case 15:
1615
 
#line 266 "idmef-criteria-string.yac.y"
 
1616
#line 267 "idmef-criteria-string.yac.y"
1616
1617
    {
1617
1618
                (yyval.criteria) = (yyvsp[(2) - (3)].criteria);
1618
1619
        }
1619
1620
    break;
1620
1621
 
1621
1622
  case 16:
1622
 
#line 270 "idmef-criteria-string.yac.y"
 
1623
#line 271 "idmef-criteria-string.yac.y"
1623
1624
    {
1624
1625
                (yyval.criteria) = (yyvsp[(1) - (1)].criteria);
1625
1626
        }
1626
1627
    break;
1627
1628
 
1628
1629
  case 17:
1629
 
#line 277 "idmef-criteria-string.yac.y"
 
1630
#line 278 "idmef-criteria-string.yac.y"
1630
1631
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_SUBSTR; }
1631
1632
    break;
1632
1633
 
1633
1634
  case 18:
1634
 
#line 278 "idmef-criteria-string.yac.y"
 
1635
#line 279 "idmef-criteria-string.yac.y"
1635
1636
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_SUBSTR|IDMEF_CRITERION_OPERATOR_NOCASE; }
1636
1637
    break;
1637
1638
 
1638
1639
  case 19:
1639
 
#line 279 "idmef-criteria-string.yac.y"
 
1640
#line 280 "idmef-criteria-string.yac.y"
1640
1641
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_SUBSTR|IDMEF_CRITERION_OPERATOR_NOT; }
1641
1642
    break;
1642
1643
 
1643
1644
  case 20:
1644
 
#line 280 "idmef-criteria-string.yac.y"
 
1645
#line 281 "idmef-criteria-string.yac.y"
1645
1646
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_SUBSTR|IDMEF_CRITERION_OPERATOR_NOT|IDMEF_CRITERION_OPERATOR_NOCASE; }
1646
1647
    break;
1647
1648
 
1648
1649
  case 21:
1649
 
#line 281 "idmef-criteria-string.yac.y"
 
1650
#line 282 "idmef-criteria-string.yac.y"
1650
1651
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_REGEX; }
1651
1652
    break;
1652
1653
 
1653
1654
  case 22:
1654
 
#line 282 "idmef-criteria-string.yac.y"
 
1655
#line 283 "idmef-criteria-string.yac.y"
1655
1656
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_REGEX|IDMEF_CRITERION_OPERATOR_NOCASE; }
1656
1657
    break;
1657
1658
 
1658
1659
  case 23:
1659
 
#line 283 "idmef-criteria-string.yac.y"
 
1660
#line 284 "idmef-criteria-string.yac.y"
1660
1661
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_REGEX|IDMEF_CRITERION_OPERATOR_NOT; }
1661
1662
    break;
1662
1663
 
1663
1664
  case 24:
1664
 
#line 284 "idmef-criteria-string.yac.y"
 
1665
#line 285 "idmef-criteria-string.yac.y"
1665
1666
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_REGEX|IDMEF_CRITERION_OPERATOR_NOT|IDMEF_CRITERION_OPERATOR_NOCASE; }
1666
1667
    break;
1667
1668
 
1668
1669
  case 25:
1669
 
#line 285 "idmef-criteria-string.yac.y"
 
1670
#line 286 "idmef-criteria-string.yac.y"
1670
1671
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_GREATER; }
1671
1672
    break;
1672
1673
 
1673
1674
  case 26:
1674
 
#line 286 "idmef-criteria-string.yac.y"
 
1675
#line 287 "idmef-criteria-string.yac.y"
1675
1676
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_GREATER|IDMEF_CRITERION_OPERATOR_EQUAL; }
1676
1677
    break;
1677
1678
 
1678
1679
  case 27:
1679
 
#line 287 "idmef-criteria-string.yac.y"
 
1680
#line 288 "idmef-criteria-string.yac.y"
1680
1681
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_LESSER; }
1681
1682
    break;
1682
1683
 
1683
1684
  case 28:
1684
 
#line 288 "idmef-criteria-string.yac.y"
 
1685
#line 289 "idmef-criteria-string.yac.y"
1685
1686
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_LESSER|IDMEF_CRITERION_OPERATOR_EQUAL; }
1686
1687
    break;
1687
1688
 
1688
1689
  case 29:
1689
 
#line 289 "idmef-criteria-string.yac.y"
 
1690
#line 290 "idmef-criteria-string.yac.y"
1690
1691
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_EQUAL; }
1691
1692
    break;
1692
1693
 
1693
1694
  case 30:
1694
 
#line 290 "idmef-criteria-string.yac.y"
 
1695
#line 291 "idmef-criteria-string.yac.y"
1695
1696
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_EQUAL|IDMEF_CRITERION_OPERATOR_NOCASE; }
1696
1697
    break;
1697
1698
 
1698
1699
  case 31:
1699
 
#line 291 "idmef-criteria-string.yac.y"
 
1700
#line 292 "idmef-criteria-string.yac.y"
1700
1701
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_EQUAL|IDMEF_CRITERION_OPERATOR_NOT; }
1701
1702
    break;
1702
1703
 
1703
1704
  case 32:
1704
 
#line 292 "idmef-criteria-string.yac.y"
 
1705
#line 293 "idmef-criteria-string.yac.y"
1705
1706
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_EQUAL|IDMEF_CRITERION_OPERATOR_NOCASE|IDMEF_CRITERION_OPERATOR_NOT; }
1706
1707
    break;
1707
1708
 
1708
1709
  case 33:
1709
 
#line 293 "idmef-criteria-string.yac.y"
 
1710
#line 294 "idmef-criteria-string.yac.y"
1710
1711
    { cur_operator = (yyval.relation) = IDMEF_CRITERION_OPERATOR_NULL; }
1711
1712
    break;
1712
1713
 
1713
1714
  case 34:
1714
 
#line 294 "idmef-criteria-string.yac.y"
 
1715
#line 295 "idmef-criteria-string.yac.y"
1715
1716
    { real_ret = prelude_error_verbose(PRELUDE_ERROR_IDMEF_CRITERIA_PARSE,
1716
1717
                                                                       "Criteria parser reported: Invalid operator found"); YYERROR; }
1717
1718
    break;
1718
1719
 
1719
1720
  case 35:
1720
 
#line 298 "idmef-criteria-string.yac.y"
 
1721
#line 299 "idmef-criteria-string.yac.y"
1721
1722
    { (yyval.operator) = operator_and; }
1722
1723
    break;
1723
1724
 
1724
1725
  case 36:
1725
 
#line 299 "idmef-criteria-string.yac.y"
 
1726
#line 300 "idmef-criteria-string.yac.y"
1726
1727
    { (yyval.operator) = operator_or; }
1727
1728
    break;
1728
1729
 
1729
1730
 
1730
1731
/* Line 1267 of yacc.c.  */
1731
 
#line 1732 "idmef-criteria-string.yac.c"
 
1732
#line 1733 "idmef-criteria-string.yac.c"
1732
1733
      default: break;
1733
1734
    }
1734
1735
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1942
1943
}
1943
1944
 
1944
1945
 
1945
 
#line 302 "idmef-criteria-string.yac.y"
 
1946
#line 303 "idmef-criteria-string.yac.y"
1946
1947
 
1947
1948
 
1948
1949
static void yyerror(char *s)  /* Called by yyparse on error */
1960
1961
 
1961
1962
        prelude_return_val_if_fail(str, -1);
1962
1963
 
1963
 
        prelude_thread_mutex_lock(&_criteria_parse_mutex);
 
1964
        gl_lock_lock(_criteria_parse_mutex);
1964
1965
 
1965
1966
        real_ret = 0;
1966
1967
        processed_criteria = NULL;
1983
1984
 
1984
1985
        else *new_criteria = processed_criteria;
1985
1986
 
1986
 
        prelude_thread_mutex_unlock(&_criteria_parse_mutex);
 
1987
        gl_lock_unlock(_criteria_parse_mutex);
1987
1988
 
1988
1989
        return ret;
1989
1990
}