22#include "icalgaugeimpl.h"
23#include "icalerror_p.h"
31extern int ssparse(
void);
32extern char *input_buffer;
33extern char *input_buffer_p;
35struct icalgauge_impl *icalss_yy_gauge;
40 struct icalgauge_impl *impl;
43 if ((impl = (
struct icalgauge_impl *)malloc(
sizeof(
struct icalgauge_impl))) == 0) {
48 impl->select = icalpvl_newlist();
49 impl->from = icalpvl_newlist();
50 impl->where = icalpvl_newlist();
51 impl->expand = expand;
53 icalss_yy_gauge = impl;
54 input_buffer = input_buffer_p = (
char *)sql;
68 icalerror_check_arg_rz((gauge != 0),
"gauge");
74 struct icalgauge_where *w;
76 assert(gauge->select != 0);
77 assert(gauge->where != 0);
78 assert(gauge->from != 0);
81 while ((w = icalpvl_pop(gauge->select)) != 0) {
87 icalpvl_free(gauge->select);
92 while ((w = icalpvl_pop(gauge->where)) != 0) {
98 icalpvl_free(gauge->where);
103 icalpvl_free(gauge->from);
112int icalgauge_compare_recurse(icalcomponent *comp, icalcomponent *gauge)
114 int pass = 1, localpass = 0;
116 icalcomponent *child, *subgauge;
119 icalerror_check_arg_rz((comp != 0),
"comp");
120 icalerror_check_arg_rz((gauge != 0),
"gauge");
137 icalproperty *targetprop;
146 if (compareparam != 0) {
159 if (targetprop != 0) {
171 }
else if (rel == compare) {
186 pass = pass && (localpass > 0);
205 localpass = icalgauge_compare_recurse(child, subgauge);
206 pass = pass && localpass;
218 icalcomponent *inner;
220 bool last_clause =
true;
222 int compare_recur = 0;
224 icalerror_check_arg_rz((comp != 0),
"comp");
225 icalerror_check_arg_rz((gauge != 0),
"gauge");
248 for (e = icalpvl_head(gauge->from); e != 0; e = icalpvl_next(e)) {
256 if (local_pass == 0) {
261 for (e = icalpvl_head(gauge->where); e != 0; e = icalpvl_next(e)) {
262 struct icalgauge_where *w = icalpvl_data(e);
263 icalcomponent *sub_comp;
281 if (w->compare == ICALGAUGECOMPARE_ISNULL || w->compare == ICALGAUGECOMPARE_ISNOTNULL) {
308 if (gauge->expand && rrule) {
316 local_pass = (w->compare == ICALGAUGECOMPARE_ISNULL) ? 1 : 0;
322 icalgaugecompare relation;
324 if (w->compare == ICALGAUGECOMPARE_ISNULL) {
329 if (w->compare == ICALGAUGECOMPARE_ISNOTNULL) {
344 if (relation == w->compare) {
346 }
else if (w->compare == ICALGAUGECOMPARE_LESSEQUAL &&
347 (relation == ICALGAUGECOMPARE_LESS || relation == ICALGAUGECOMPARE_EQUAL)) {
349 }
else if (w->compare == ICALGAUGECOMPARE_GREATEREQUAL &&
350 (relation == ICALGAUGECOMPARE_GREATER ||
351 relation == ICALGAUGECOMPARE_EQUAL)) {
353 }
else if (w->compare == ICALGAUGECOMPARE_NOTEQUAL &&
354 (relation == ICALGAUGECOMPARE_GREATER ||
355 relation == ICALGAUGECOMPARE_LESS)) {
362 bool this_clause = (local_pass > 0);
367 if (w->logic == ICALGAUGELOGIC_AND) {
368 last_clause = this_clause && last_clause;
369 }
else if (w->logic == ICALGAUGELOGIC_OR) {
370 last_clause = this_clause || last_clause;
372 last_clause = this_clause;
386 printf(
"--- Select ---\n");
387 for (p = icalpvl_head(gauge->select); p != 0; p = icalpvl_next(p)) {
388 struct icalgauge_where *w = icalpvl_data(p);
402 if (w->compare != ICALGAUGECOMPARE_NONE) {
403 printf(
"%d ", w->compare);
407 printf(
"%s", w->value);
413 printf(
"--- From ---\n");
414 for (p = icalpvl_head(gauge->from); p != 0; p = icalpvl_next(p)) {
420 printf(
"--- Where ---\n");
421 for (p = icalpvl_head(gauge->where); p != 0; p = icalpvl_next(p)) {
422 struct icalgauge_where *w = icalpvl_data(p);
428 if (w->logic != ICALGAUGELOGIC_NONE) {
429 printf(
"%d ", w->logic);
440 if (w->compare != ICALGAUGECOMPARE_NONE) {
441 printf(
"%d ", w->compare);
445 printf(
"%s", w->value);
icalproperty * icalcomponent_get_first_property(icalcomponent *c, icalproperty_kind kind)
icalcomponent * icalcomponent_get_next_component(icalcomponent *c, icalcomponent_kind kind)
icalcomponent * icalcomponent_get_first_component(icalcomponent *c, icalcomponent_kind kind)
const char * icalcomponent_kind_to_string(icalcomponent_kind kind)
icalcomponent * icalcomponent_get_first_real_component(const icalcomponent *c)
icalcomponent_kind icalcomponent_isa(const icalcomponent *component)
icalproperty * icalcomponent_get_next_property(icalcomponent *c, icalproperty_kind kind)
icalparameter_xliccomparetype icalparameter_get_xliccomparetype(const icalparameter *value)
@ ICAL_XLICCOMPARETYPE_PARAMETER
struct icalparameter_impl icalparameter
icalparameter_xliccomparetype
@ ICAL_XLICCOMPARETYPE_NOTEQUAL
@ ICAL_XLICCOMPARETYPE_LESSEQUAL
@ ICAL_XLICCOMPARETYPE_LESS
@ ICAL_XLICCOMPARETYPE_GREATER
@ ICAL_XLICCOMPARETYPE_EQUAL
@ ICAL_XLICCOMPARETYPE_NONE
@ ICAL_XLICCOMPARETYPE_GREATEREQUAL
@ ICAL_RECURRENCEID_PROPERTY
struct icalvalue_impl icalvalue
enum icalrequeststatus kind
@ ICAL_VJOURNAL_COMPONENT
void icalerror_set_errno(icalerrorenum x)
Sets the icalerrno to a given error.
@ ICAL_MALFORMEDDATA_ERROR
bool icalgauge_compare(icalgauge *gauge, icalcomponent *comp)
void icalgauge_free(icalgauge *gauge)
void icalgauge_dump(icalgauge *gauge)
int icalgauge_get_expand(const icalgauge *gauge)
icalgauge * icalgauge_new_from_sql(const char *sql, int expand)
Routines implementing a filter for ical components.
icalvalue * icalproperty_get_value(const icalproperty *prop)
icalproperty_kind icalproperty_isa(const icalproperty *p)
icalparameter * icalproperty_get_first_parameter(icalproperty *p, icalparameter_kind kind)
icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind)
const char * icalproperty_kind_to_string(icalproperty_kind kind)
icalvalue * icalvalue_new_from_string(icalvalue_kind kind, const char *str)
icalparameter_xliccomparetype icalvalue_compare(const icalvalue *a, const icalvalue *b)
icalvalue * icalvalue_new(icalvalue_kind kind)
void icalvalue_free(icalvalue *v)
Defines the data structure representing iCalendar parameter values.