1 /* A Bison parser, made by GNU Bison 3.3.2. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
6 Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37 /* All symbols defined below should begin with yy or YY, to avoid
38 infringing on user name space. This should be done even for local
39 variables, as they might otherwise be expanded by user macros.
40 There are some unavoidable exceptions within include files to
41 define necessary library symbols; they are noted "INFRINGES ON
42 USER NAME SPACE" below. */
43
44 /* Undocumented macros, especially those whose name start with YY_,
45 are private implementation details. Do not rely on them. */
46
47 /* Identify Bison output. */
48 #define YYBISON 1
49
50 /* Bison version. */
51 #define YYBISON_VERSION "3.3.2"
52
53 /* Skeleton name. */
54 #define YYSKELETON_NAME "yacc.c"
55
56 /* Pure parsers. */
57 #define YYPURE 1
58
59 /* Push parsers. */
60 #define YYPUSH 0
61
62 /* Pull parsers. */
63 #define YYPULL 1
64
65
66 /* Substitute the variable and function names. */
67 #define yyparse sieveparse
68 #define yylex sievelex
69 #define yyerror sieveerror
70 #define yydebug sievedebug
71 #define yynerrs sievenerrs
72
73
74 /* First part of user prologue. */
75 #line 1 "sieve/sieve.y" /* yacc.c:337 */
76
77 /* sieve.y -- sieve parser
78 * Larry Greenfield
79 *
80 * Copyright (c) 1994-2008 Carnegie Mellon University. All rights reserved.
81 *
82 * Redistribution and use in source and binary forms, with or without
83 * modification, are permitted provided that the following conditions
84 * are met:
85 *
86 * 1. Redistributions of source code must retain the above copyright
87 * notice, this list of conditions and the following disclaimer.
88 *
89 * 2. Redistributions in binary form must reproduce the above copyright
90 * notice, this list of conditions and the following disclaimer in
91 * the documentation and/or other materials provided with the
92 * distribution.
93 *
94 * 3. The name "Carnegie Mellon University" must not be used to
95 * endorse or promote products derived from this software without
96 * prior written permission. For permission or any legal
97 * details, please contact
98 * Carnegie Mellon University
99 * Center for Technology Transfer and Enterprise Creation
100 * 4615 Forbes Avenue
101 * Suite 302
102 * Pittsburgh, PA 15213
103 * (412) 268-7393, fax: (412) 268-7395
104 * innovation@andrew.cmu.edu
105 *
106 * 4. Redistributions of any form whatsoever must retain the following
107 * acknowledgment:
108 * "This product includes software developed by Computing Services
109 * at Carnegie Mellon University (http://www.cmu.edu/computing/)."
110 *
111 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
112 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
113 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
114 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
115 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
116 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
117 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
118 */
119
120 #ifdef HAVE_CONFIG_H
121 #include <config.h>
122 #endif
123
124 #include <stdlib.h>
125 #include <assert.h>
126 #include <string.h>
127 #include "xmalloc.h"
128 #include "sieve/comparator.h"
129 #include "sieve/interp.h"
130 #include "sieve/script.h"
131 #include "sieve/tree.h"
132 #include "sieve/flags.h"
133 #include "sieve/grammar.h"
134 #include "sieve/sieve_err.h"
135
136 #include "imapurl.h"
137 #include "lib/gmtoff.h"
138 #include "util.h"
139 #include "imparse.h"
140 #include "libconfig.h"
141 #include "times.h"
142
143 #define ERR_BUF_SIZE 1024
144
145 /*
146 * Definitions
147 */
148
149 extern int addrparse(sieve_script_t*);
150 typedef struct yy_buffer_state *YY_BUFFER_STATE;
151 extern YY_BUFFER_STATE addr_scan_string(const char*);
152 extern void addr_delete_buffer(YY_BUFFER_STATE);
153
154 extern int sievelineno;
155
156 struct vtags {
157 int seconds;
158 strarray_t *addresses;
159 char *subject;
160 char *from;
161 char *handle;
162 int mime;
163 };
164
165 struct comptags {
166 int match;
167 int relation;
168 char *comparator; /* only used where comparator can be defined */
169 int index; /* only used where index extension is defined */
170 };
171
172 struct aetags {
173 struct comptags comptags; /* MUST be first so we can typecast */
174 int addrtag;
175 };
176
177 struct btags {
178 struct comptags comptags; /* MUST be first so we can typecast */
179 int transform;
180 int offset;
181 strarray_t *content_types;
182 };
183
184 struct ntags {
185 char *method;
186 char *id;
187 strarray_t *options;
188 int priority;
189 char *message;
190 };
191
192 struct dtags {
193 struct comptags comptags; /* MUST be first so we can typecast */
194 void *pattern;
195 int priority;
196 };
197
198 struct itags {
199 int location;
200 int once;
201 int optional;
202 };
203
204 struct dttags {
205 struct comptags comptags; /* MUST be first so we can typecast */
206 int zonetag;
207 char *zone;
208 };
209
210 struct ftags {
211 int copy;
212 int create;
213 strarray_t *flags;
214 };
215
216 struct stags {
217 int mod40; /* :lower or :upper */
218 int mod30; /* :lowerfirst or :upperfirst */
219 int mod20; /* :quotewildcard */
220 int mod10; /* :length */
221 };
222
223 static char *check_reqs(sieve_script_t *script, strarray_t *sl);
224
225 static test_t *build_address(int t, struct aetags *ae,
226 strarray_t *sl, strarray_t *pl);
227 static test_t *build_header(int t, struct comptags *c,
228 strarray_t *sl, strarray_t *pl);
229 static test_t *build_body(int t, struct btags *b, strarray_t *pl);
230 static test_t *build_date(int t, struct dttags *dt,
231 char *hn, int part, strarray_t *kl);
232 static test_t *build_mailboxtest(int t, struct comptags *c, const char *extname,
233 const char *keyname, strarray_t *keylist);
234
235 static commandlist_t *build_vacation(int t, struct vtags *h, char *s);
236 static commandlist_t *build_notify(int t, struct ntags *n);
237 static commandlist_t *build_denotify(int t, struct dtags *n);
238 static commandlist_t *build_keep(int t, struct ftags *f);
239 static commandlist_t *build_fileinto(int t, struct ftags *f, char *folder);
240 static commandlist_t *build_redirect(int t, int c, char *a);
241 static commandlist_t *build_include(int, struct itags *, char*);
242 static commandlist_t *build_set(int t, struct stags *s,
243 char *variable, char *value);
244 static commandlist_t *build_flag(int t, char *variable, strarray_t *flags);
245
246 static struct aetags *new_aetags(void);
247 static struct aetags *canon_aetags(struct aetags *ae);
248 static void free_aetags(struct aetags *ae);
249
250 static struct comptags *new_comptags(void);
251 static struct comptags *init_comptags(struct comptags *c);
252 static struct comptags *canon_comptags(struct comptags *c);
253 static void free_comptags(struct comptags *c, int destroy);
254
255 static struct btags *new_btags(void);
256 static struct btags *canon_btags(struct btags *b);
257 static void free_btags(struct btags *b);
258
259 static struct vtags *new_vtags(void);
260 static struct vtags *canon_vtags(sieve_script_t *script, struct vtags *v);
261 static void free_vtags(struct vtags *v);
262
263 static struct ntags *new_ntags(void);
264 static struct ntags *canon_ntags(struct ntags *n);
265 static void free_ntags(struct ntags *n);
266
267 static struct dtags *new_dtags(void);
268 static struct dtags *canon_dtags(struct dtags *d);
269 static void free_dtags(struct dtags *d);
270
271 static struct itags *new_itags(void);
272
273 static struct dttags *new_dttags(void);
274 static struct dttags *canon_dttags(struct dttags *dt);
275 static void free_dttags(struct dttags *b);
276
277 static struct ftags *new_ftags(void);
278 static struct ftags *canon_ftags(struct ftags *f);
279 static void free_ftags(struct ftags *f);
280
281 static struct stags *new_stags(void);
282 static struct stags *canon_stags(struct stags *s);
283 static void free_stags(struct stags *s);
284
285 static int verify_stringlist(sieve_script_t*, strarray_t *sl,
286 int (*verify)(sieve_script_t*, char *));
287 static int verify_patternlist(sieve_script_t *parse_script,
288 strarray_t *sl, struct comptags *c,
289 int (*verify)(sieve_script_t*, char *));
290 static int verify_mailbox(sieve_script_t*, char *s);
291 static int verify_address(sieve_script_t*, char *s);
292 static int verify_header(sieve_script_t*, char *s);
293 static int verify_addrheader(sieve_script_t*, char *s);
294 static int verify_envelope(sieve_script_t*, char *s);
295 static int verify_relat(sieve_script_t*, char *s);
296 static int verify_zone(sieve_script_t*, char *s);
297 static int verify_date_part(sieve_script_t *parse_script, char *dp);
298 static int verify_utf8(sieve_script_t*, char *s);
299 static int verify_identifier(sieve_script_t*, char *s);
300
301 static void parse_error(sieve_script_t *parse_script, int err, ...);
302 void yyerror(sieve_script_t*, const char *msg);
303 extern int yylex(void*, sieve_script_t*);
304 extern void sieverestart(FILE *f);
305
306 #define YYERROR_VERBOSE /* i want better error messages! */
307
308 /* byacc default is 500, bison default is 10000 - go with the
309 larger to support big sieve scripts (see Bug #3461) */
310 #define YYSTACKSIZE 10000
311
312 #line 313 "sieve/sieve.c" /* yacc.c:337 */
313 # ifndef YY_NULLPTR
314 # if defined __cplusplus
315 # if 201103L <= __cplusplus
316 # define YY_NULLPTR nullptr
317 # else
318 # define YY_NULLPTR 0
319 # endif
320 # else
321 # define YY_NULLPTR ((void*)0)
322 # endif
323 # endif
324
325 /* Enabling verbose error messages. */
326 #ifdef YYERROR_VERBOSE
327 # undef YYERROR_VERBOSE
328 # define YYERROR_VERBOSE 1
329 #else
330 # define YYERROR_VERBOSE 0
331 #endif
332
333 /* In a future release of Bison, this section will be replaced
334 by #include "y.tab.h". */
335 #ifndef YY_SIEVE_SIEVE_SIEVE_H_INCLUDED
336 # define YY_SIEVE_SIEVE_SIEVE_H_INCLUDED
337 /* Debug traces. */
338 #ifndef YYDEBUG
339 # define YYDEBUG 0
340 #endif
341 #if YYDEBUG
342 extern int sievedebug;
343 #endif
344
345 /* Token type. */
346 #ifndef YYTOKENTYPE
347 # define YYTOKENTYPE
348 enum yytokentype
349 {
350 NUMBER = 258,
351 STRING = 259,
352 IF = 260,
353 ELSIF = 261,
354 ELSE = 262,
355 REJCT = 263,
356 FILEINTO = 264,
357 REDIRECT = 265,
358 KEEP = 266,
359 STOP = 267,
360 DISCARD = 268,
361 VACATION = 269,
362 REQUIRE = 270,
363 MARK = 271,
364 UNMARK = 272,
365 FLAGS = 273,
366 NOTIFY = 274,
367 DENOTIFY = 275,
368 ANYOF = 276,
369 ALLOF = 277,
370 EXISTS = 278,
371 SFALSE = 279,
372 STRUE = 280,
373 HEADER = 281,
374 NOT = 282,
375 SIZE = 283,
376 ADDRESS = 284,
377 ENVELOPE = 285,
378 BODY = 286,
379 COMPARATOR = 287,
380 IS = 288,
381 CONTAINS = 289,
382 MATCHES = 290,
383 REGEX = 291,
384 COUNT = 292,
385 VALUE = 293,
386 OVER = 294,
387 UNDER = 295,
388 GT = 296,
389 GE = 297,
390 LT = 298,
391 LE = 299,
392 EQ = 300,
393 NE = 301,
394 ALL = 302,
395 LOCALPART = 303,
396 DOMAIN = 304,
397 USER = 305,
398 DETAIL = 306,
399 RAW = 307,
400 TEXT = 308,
401 CONTENT = 309,
402 DAYS = 310,
403 ADDRESSES = 311,
404 SUBJECT = 312,
405 FROM = 313,
406 HANDLE = 314,
407 MIME = 315,
408 SECONDS = 316,
409 METHOD = 317,
410 ID = 318,
411 OPTIONS = 319,
412 LOW = 320,
413 NORMAL = 321,
414 HIGH = 322,
415 ANY = 323,
416 MESSAGE = 324,
417 INCLUDE = 325,
418 PERSONAL = 326,
419 GLOBAL = 327,
420 RETURN = 328,
421 OPTIONAL = 329,
422 ONCE = 330,
423 COPY = 331,
424 DATE = 332,
425 CURRENTDATE = 333,
426 INDEX = 334,
427 LAST = 335,
428 ZONE = 336,
429 ORIGINALZONE = 337,
430 MAILBOXEXISTS = 338,
431 CREATE = 339,
432 METADATA = 340,
433 METADATAEXISTS = 341,
434 SERVERMETADATA = 342,
435 SERVERMETADATAEXISTS = 343,
436 YEAR = 344,
437 MONTH = 345,
438 DAY = 346,
439 JULIAN = 347,
440 HOUR = 348,
441 MINUTE = 349,
442 SECOND = 350,
443 TIME = 351,
444 ISO8601 = 352,
445 STD11 = 353,
446 WEEKDAY = 354,
447 STRINGT = 355,
448 SET = 356,
449 LOWER = 357,
450 UPPER = 358,
451 LOWERFIRST = 359,
452 UPPERFIRST = 360,
453 QUOTEWILDCARD = 361,
454 LENGTH = 362,
455 SETFLAG = 363,
456 ADDFLAG = 364,
457 REMOVEFLAG = 365,
458 HASFLAG = 366
459 };
460 #endif
461 /* Tokens. */
462 #define NUMBER 258
463 #define STRING 259
464 #define IF 260
465 #define ELSIF 261
466 #define ELSE 262
467 #define REJCT 263
468 #define FILEINTO 264
469 #define REDIRECT 265
470 #define KEEP 266
471 #define STOP 267
472 #define DISCARD 268
473 #define VACATION 269
474 #define REQUIRE 270
475 #define MARK 271
476 #define UNMARK 272
477 #define FLAGS 273
478 #define NOTIFY 274
479 #define DENOTIFY 275
480 #define ANYOF 276
481 #define ALLOF 277
482 #define EXISTS 278
483 #define SFALSE 279
484 #define STRUE 280
485 #define HEADER 281
486 #define NOT 282
487 #define SIZE 283
488 #define ADDRESS 284
489 #define ENVELOPE 285
490 #define BODY 286
491 #define COMPARATOR 287
492 #define IS 288
493 #define CONTAINS 289
494 #define MATCHES 290
495 #define REGEX 291
496 #define COUNT 292
497 #define VALUE 293
498 #define OVER 294
499 #define UNDER 295
500 #define GT 296
501 #define GE 297
502 #define LT 298
503 #define LE 299
504 #define EQ 300
505 #define NE 301
506 #define ALL 302
507 #define LOCALPART 303
508 #define DOMAIN 304
509 #define USER 305
510 #define DETAIL 306
511 #define RAW 307
512 #define TEXT 308
513 #define CONTENT 309
514 #define DAYS 310
515 #define ADDRESSES 311
516 #define SUBJECT 312
517 #define FROM 313
518 #define HANDLE 314
519 #define MIME 315
520 #define SECONDS 316
521 #define METHOD 317
522 #define ID 318
523 #define OPTIONS 319
524 #define LOW 320
525 #define NORMAL 321
526 #define HIGH 322
527 #define ANY 323
528 #define MESSAGE 324
529 #define INCLUDE 325
530 #define PERSONAL 326
531 #define GLOBAL 327
532 #define RETURN 328
533 #define OPTIONAL 329
534 #define ONCE 330
535 #define COPY 331
536 #define DATE 332
537 #define CURRENTDATE 333
538 #define INDEX 334
539 #define LAST 335
540 #define ZONE 336
541 #define ORIGINALZONE 337
542 #define MAILBOXEXISTS 338
543 #define CREATE 339
544 #define METADATA 340
545 #define METADATAEXISTS 341
546 #define SERVERMETADATA 342
547 #define SERVERMETADATAEXISTS 343
548 #define YEAR 344
549 #define MONTH 345
550 #define DAY 346
551 #define JULIAN 347
552 #define HOUR 348
553 #define MINUTE 349
554 #define SECOND 350
555 #define TIME 351
556 #define ISO8601 352
557 #define STD11 353
558 #define WEEKDAY 354
559 #define STRINGT 355
560 #define SET 356
561 #define LOWER 357
562 #define UPPER 358
563 #define LOWERFIRST 359
564 #define UPPERFIRST 360
565 #define QUOTEWILDCARD 361
566 #define LENGTH 362
567 #define SETFLAG 363
568 #define ADDFLAG 364
569 #define REMOVEFLAG 365
570 #define HASFLAG 366
571
572 /* Value type. */
573 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
574
575 union YYSTYPE
576 {
577 #line 238 "sieve/sieve.y" /* yacc.c:352 */
578
579 int nval;
580 char *sval;
581 strarray_t *sl;
582 test_t *test;
583 testlist_t *testl;
584 commandlist_t *cl;
585 struct vtags *vtag;
586 struct aetags *aetag;
587 struct comptags *ctag;
588 struct btags *btag;
589 struct ntags *ntag;
590 struct dtags *dtag;
591 struct itags *itag;
592 struct dttags *dttag;
593 struct ftags *ftag;
594 struct stags *stag;
595
596 #line 597 "sieve/sieve.c" /* yacc.c:352 */
597 };
598
599 typedef union YYSTYPE YYSTYPE;
600 # define YYSTYPE_IS_TRIVIAL 1
601 # define YYSTYPE_IS_DECLARED 1
602 #endif
603
604
605
606 int sieveparse (sieve_script_t *parse_script);
607
608 #endif /* !YY_SIEVE_SIEVE_SIEVE_H_INCLUDED */
609
610
611
612 #ifdef short
613 # undef short
614 #endif
615
616 #ifdef YYTYPE_UINT8
617 typedef YYTYPE_UINT8 yytype_uint8;
618 #else
619 typedef unsigned char yytype_uint8;
620 #endif
621
622 #ifdef YYTYPE_INT8
623 typedef YYTYPE_INT8 yytype_int8;
624 #else
625 typedef signed char yytype_int8;
626 #endif
627
628 #ifdef YYTYPE_UINT16
629 typedef YYTYPE_UINT16 yytype_uint16;
630 #else
631 typedef unsigned short yytype_uint16;
632 #endif
633
634 #ifdef YYTYPE_INT16
635 typedef YYTYPE_INT16 yytype_int16;
636 #else
637 typedef short yytype_int16;
638 #endif
639
640 #ifndef YYSIZE_T
641 # ifdef __SIZE_TYPE__
642 # define YYSIZE_T __SIZE_TYPE__
643 # elif defined size_t
644 # define YYSIZE_T size_t
645 # elif ! defined YYSIZE_T
646 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
647 # define YYSIZE_T size_t
648 # else
649 # define YYSIZE_T unsigned
650 # endif
651 #endif
652
653 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
654
655 #ifndef YY_
656 # if defined YYENABLE_NLS && YYENABLE_NLS
657 # if ENABLE_NLS
658 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
659 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
660 # endif
661 # endif
662 # ifndef YY_
663 # define YY_(Msgid) Msgid
664 # endif
665 #endif
666
667 #ifndef YY_ATTRIBUTE
668 # if (defined __GNUC__ \
669 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
670 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
671 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
672 # else
673 # define YY_ATTRIBUTE(Spec) /* empty */
674 # endif
675 #endif
676
677 #ifndef YY_ATTRIBUTE_PURE
678 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
679 #endif
680
681 #ifndef YY_ATTRIBUTE_UNUSED
682 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
683 #endif
684
685 /* Suppress unused-variable warnings by "using" E. */
686 #if ! defined lint || defined __GNUC__
687 # define YYUSE(E) ((void) (E))
688 #else
689 # define YYUSE(E) /* empty */
690 #endif
691
692 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
693 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
694 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
695 _Pragma ("GCC diagnostic push") \
696 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
697 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
698 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
699 _Pragma ("GCC diagnostic pop")
700 #else
701 # define YY_INITIAL_VALUE(Value) Value
702 #endif
703 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
704 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
705 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
706 #endif
707 #ifndef YY_INITIAL_VALUE
708 # define YY_INITIAL_VALUE(Value) /* Nothing. */
709 #endif
710
711
712 #if ! defined yyoverflow || YYERROR_VERBOSE
713
714 /* The parser invokes alloca or malloc; define the necessary symbols. */
715
716 # ifdef YYSTACK_USE_ALLOCA
717 # if YYSTACK_USE_ALLOCA
718 # ifdef __GNUC__
719 # define YYSTACK_ALLOC __builtin_alloca
720 # elif defined __BUILTIN_VA_ARG_INCR
721 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
722 # elif defined _AIX
723 # define YYSTACK_ALLOC __alloca
724 # elif defined _MSC_VER
725 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
726 # define alloca _alloca
727 # else
728 # define YYSTACK_ALLOC alloca
729 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
730 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
731 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
732 # ifndef EXIT_SUCCESS
733 # define EXIT_SUCCESS 0
734 # endif
735 # endif
736 # endif
737 # endif
738 # endif
739
740 # ifdef YYSTACK_ALLOC
741 /* Pacify GCC's 'empty if-body' warning. */
742 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
743 # ifndef YYSTACK_ALLOC_MAXIMUM
744 /* The OS might guarantee only one guard page at the bottom of the stack,
745 and a page size can be as small as 4096 bytes. So we cannot safely
746 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
747 to allow for a few compiler-allocated temporary stack slots. */
748 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
749 # endif
750 # else
751 # define YYSTACK_ALLOC YYMALLOC
752 # define YYSTACK_FREE YYFREE
753 # ifndef YYSTACK_ALLOC_MAXIMUM
754 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
755 # endif
756 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
757 && ! ((defined YYMALLOC || defined malloc) \
758 && (defined YYFREE || defined free)))
759 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
760 # ifndef EXIT_SUCCESS
761 # define EXIT_SUCCESS 0
762 # endif
763 # endif
764 # ifndef YYMALLOC
765 # define YYMALLOC malloc
766 # if ! defined malloc && ! defined EXIT_SUCCESS
767 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
768 # endif
769 # endif
770 # ifndef YYFREE
771 # define YYFREE free
772 # if ! defined free && ! defined EXIT_SUCCESS
773 void free (void *); /* INFRINGES ON USER NAME SPACE */
774 # endif
775 # endif
776 # endif
777 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
778
779
780 #if (! defined yyoverflow \
781 && (! defined __cplusplus \
782 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
783
784 /* A type that is properly aligned for any stack member. */
785 union yyalloc
786 {
787 yytype_int16 yyss_alloc;
788 YYSTYPE yyvs_alloc;
789 };
790
791 /* The size of the maximum gap between one aligned stack and the next. */
792 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
793
794 /* The size of an array large to enough to hold all stacks, each with
795 N elements. */
796 # define YYSTACK_BYTES(N) \
797 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
798 + YYSTACK_GAP_MAXIMUM)
799
800 # define YYCOPY_NEEDED 1
801
802 /* Relocate STACK from its old location to the new one. The
803 local variables YYSIZE and YYSTACKSIZE give the old and new number of
804 elements in the stack, and YYPTR gives the new location of the
805 stack. Advance YYPTR to a properly aligned location for the next
806 stack. */
807 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
808 do \
809 { \
810 YYSIZE_T yynewbytes; \
811 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
812 Stack = &yyptr->Stack_alloc; \
813 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
814 yyptr += yynewbytes / sizeof (*yyptr); \
815 } \
816 while (0)
817
818 #endif
819
820 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
821 /* Copy COUNT objects from SRC to DST. The source and destination do
822 not overlap. */
823 # ifndef YYCOPY
824 # if defined __GNUC__ && 1 < __GNUC__
825 # define YYCOPY(Dst, Src, Count) \
826 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
827 # else
828 # define YYCOPY(Dst, Src, Count) \
829 do \
830 { \
831 YYSIZE_T yyi; \
832 for (yyi = 0; yyi < (Count); yyi++) \
833 (Dst)[yyi] = (Src)[yyi]; \
834 } \
835 while (0)
836 # endif
837 # endif
838 #endif /* !YYCOPY_NEEDED */
839
840 /* YYFINAL -- State number of the termination state. */
841 #define YYFINAL 8
842 /* YYLAST -- Last index in YYTABLE. */
843 #define YYLAST 419
844
845 /* YYNTOKENS -- Number of terminals. */
846 #define YYNTOKENS 120
847 /* YYNNTS -- Number of nonterminals. */
848 #define YYNNTS 48
849 /* YYNRULES -- Number of rules. */
850 #define YYNRULES 167
851 /* YYNSTATES -- Number of states. */
852 #define YYNSTATES 244
853
854 #define YYUNDEFTOK 2
855 #define YYMAXUTOK 366
856
857 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
858 as returned by yylex, with out-of-bounds checking. */
859 #define YYTRANSLATE(YYX) \
860 ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
861
862 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
863 as returned by yylex. */
864 static const yytype_uint8 yytranslate[] =
865 {
866 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
867 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
868 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
869 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
870 118, 119, 2, 2, 115, 2, 2, 2, 2, 2,
871 2, 2, 2, 2, 2, 2, 2, 2, 2, 112,
872 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
873 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
874 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
875 2, 113, 2, 114, 2, 2, 2, 2, 2, 2,
876 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
877 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
878 2, 2, 2, 116, 2, 117, 2, 2, 2, 2,
879 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
880 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
881 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
882 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
883 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
884 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
885 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
886 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
887 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
888 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
889 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
890 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
891 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
892 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
893 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
894 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
895 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
896 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
897 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
898 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
899 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
900 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
901 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
902 105, 106, 107, 108, 109, 110, 111
903 };
904
905 #if YYDEBUG
906 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
907 static const yytype_uint16 yyrline[] =
908 {
909 0, 314, 314, 315, 318, 319, 322, 333, 334, 337,
910 338, 339, 342, 343, 344, 347, 362, 377, 385, 386,
911 387, 389, 406, 422, 433, 444, 456, 475, 496, 507,
912 525, 526, 527, 530, 531, 552, 553, 563, 573, 608,
913 620, 621, 623, 624, 626, 628, 631, 632, 642, 652,
914 662, 673, 674, 684, 694, 704, 714, 726, 727, 737,
915 752, 753, 754, 757, 758, 768, 784, 798, 811, 824,
916 837, 849, 850, 856, 860, 866, 867, 870, 871, 872,
917 873, 874, 876, 899, 932, 967, 992, 1015, 1044, 1069,
918 1070, 1073, 1101, 1127, 1146, 1165, 1184, 1203, 1222, 1225,
919 1226, 1237, 1238, 1239, 1242, 1243, 1254, 1255, 1261, 1272,
920 1295, 1321, 1344, 1368, 1369, 1370, 1371, 1374, 1375, 1376,
921 1379, 1380, 1381, 1384, 1385, 1386, 1389, 1390, 1401, 1412,
922 1426, 1427, 1430, 1431, 1442, 1443, 1444, 1445, 1448, 1449,
923 1450, 1451, 1457, 1476, 1485, 1486, 1487, 1488, 1498, 1509,
924 1510, 1511, 1512, 1524, 1534, 1547, 1548, 1551, 1563, 1575,
925 1576, 1587, 1598, 1622, 1623, 1636, 1639, 1640
926 };
927 #endif
928
929 #if YYDEBUG || YYERROR_VERBOSE || 0
930 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
931 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
932 static const char *const yytname[] =
933 {
934 "$end", "error", "$undefined", "NUMBER", "STRING", "IF", "ELSIF",
935 "ELSE", "REJCT", "FILEINTO", "REDIRECT", "KEEP", "STOP", "DISCARD",
936 "VACATION", "REQUIRE", "MARK", "UNMARK", "FLAGS", "NOTIFY", "DENOTIFY",
937 "ANYOF", "ALLOF", "EXISTS", "SFALSE", "STRUE", "HEADER", "NOT", "SIZE",
938 "ADDRESS", "ENVELOPE", "BODY", "COMPARATOR", "IS", "CONTAINS", "MATCHES",
939 "REGEX", "COUNT", "VALUE", "OVER", "UNDER", "GT", "GE", "LT", "LE", "EQ",
940 "NE", "ALL", "LOCALPART", "DOMAIN", "USER", "DETAIL", "RAW", "TEXT",
941 "CONTENT", "DAYS", "ADDRESSES", "SUBJECT", "FROM", "HANDLE", "MIME",
942 "SECONDS", "METHOD", "ID", "OPTIONS", "LOW", "NORMAL", "HIGH", "ANY",
943 "MESSAGE", "INCLUDE", "PERSONAL", "GLOBAL", "RETURN", "OPTIONAL", "ONCE",
944 "COPY", "DATE", "CURRENTDATE", "INDEX", "LAST", "ZONE", "ORIGINALZONE",
945 "MAILBOXEXISTS", "CREATE", "METADATA", "METADATAEXISTS",
946 "SERVERMETADATA", "SERVERMETADATAEXISTS", "YEAR", "MONTH", "DAY",
947 "JULIAN", "HOUR", "MINUTE", "SECOND", "TIME", "ISO8601", "STD11",
948 "WEEKDAY", "STRINGT", "SET", "LOWER", "UPPER", "LOWERFIRST",
949 "UPPERFIRST", "QUOTEWILDCARD", "LENGTH", "SETFLAG", "ADDFLAG",
950 "REMOVEFLAG", "HASFLAG", "';'", "'['", "']'", "','", "'{'", "'}'", "'('",
951 "')'", "$accept", "start", "reqs", "require", "commands", "command",
952 "elsif", "action", "flagaction", "flagtags", "stags", "mod40", "mod30",
953 "mod20", "mod10", "itags", "ntags", "dtags", "priority", "vtags",
954 "stringlist", "strings", "block", "test", "atags", "etags", "matchtags",
955 "comparator", "idxtags", "htags", "strtags", "hftags", "mtags", "btags",
956 "dttags", "cdtags", "zone", "datepart", "addrparttag", "match",
957 "relmatch", "sizetag", "copy", "creat", "ftags", "rtags", "testlist",
958 "tests", YY_NULLPTR
959 };
960 #endif
961
962 # ifdef YYPRINT
963 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
964 (internal) symbol number NUM (which must be that of a token). */
965 static const yytype_uint16 yytoknum[] =
966 {
967 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
968 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
969 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
970 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
971 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
972 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
973 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
974 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
975 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
976 345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
977 355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
978 365, 366, 59, 91, 93, 44, 123, 125, 40, 41
979 };
980 # endif
981
982 #define YYPACT_NINF -199
983
984 #define yypact_value_is_default(Yystate) \
985 (!!((Yystate) == (-199)))
986
987 #define YYTABLE_NINF -73
988
989 #define yytable_value_is_error(Yytable_value) \
990 0
991
992 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
993 STATE-NUM. */
994 static const yytype_int16 yypact[] =
995 {
996 -9, -2, 13, 195, -9, -199, 20, -82, -199, -75,
997 140, 29, -199, -199, -199, -199, -199, -199, -199, -199,
998 -199, -199, -199, -199, -199, -199, -199, -199, -199, 9,
999 -72, -199, -199, -199, -79, -199, -199, -199, -76, -76,
1000 -2, -199, -199, -199, 140, 7, -199, -199, -199, -199,
1001 -199, -2, -199, 47, -199, -2, -199, -199, -64, -199,
1002 23, 1, -3, 297, 350, 301, 245, 176, -199, -199,
1003 -1, -199, 51, 140, -199, -199, -199, 220, -199, -199,
1004 -199, 53, 197, 237, 68, 293, 28, -199, 308, -2,
1005 344, -199, 257, 257, 75, 42, -199, -2, -199, -199,
1006 -199, -199, -199, -199, -199, 54, -2, 55, 64, 66,
1007 -199, 71, 67, 74, -2, -199, -199, -199, 86, -199,
1008 -199, -199, -199, -199, -199, -199, -199, 89, -199, 92,
1009 -199, -199, -199, -199, -199, 93, -199, -199, -199, -199,
1010 -199, -199, -199, -199, -199, -199, -14, -199, -199, -7,
1011 -6, 110, 113, -199, -2, -199, -199, -199, -199, -199,
1012 -199, -199, -199, -199, -2, -199, -199, -199, -199, -2,
1013 -199, -199, -199, -199, -199, -2, -199, -199, -199, 119,
1014 120, -199, -199, -199, -199, -199, -199, -199, -199, -199,
1015 -2, 123, -199, -199, -199, -2, -2, -199, -199, -2,
1016 -199, -199, -199, 11, 140, -64, -199, -199, -199, -199,
1017 -199, -199, -199, -199, -199, -199, -199, -199, -199, -199,
1018 -199, 140, -199, -199, -199, -199, -199, -199, -199, -2,
1019 -199, -199, -2, -199, -199, -199, -199, -64, -199, -199,
1020 -199, -199, 42, -199
1021 };
1022
1023 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
1024 Performed when YYTABLE does not specify something else to do. Zero
1025 means the default is an error. */
1026 static const yytype_uint8 yydefact[] =
1027 {
1028 4, 0, 0, 0, 4, 72, 0, 0, 1, 0,
1029 0, 0, 159, 163, 159, 19, 20, 63, 23, 24,
1030 51, 57, 46, 28, 35, 31, 30, 32, 3, 0,
1031 0, 33, 5, 73, 0, 6, 11, 98, 0, 0,
1032 0, 80, 81, 113, 0, 0, 99, 104, 126, 132,
1033 138, 0, 123, 0, 123, 0, 117, 120, 0, 15,
1034 0, 0, 18, 0, 25, 26, 0, 0, 8, 9,
1035 0, 71, 0, 0, 77, 78, 79, 0, 89, 155,
1036 156, 0, 0, 0, 0, 0, 0, 93, 0, 0,
1037 0, 97, 0, 0, 0, 12, 16, 0, 157, 158,
1038 160, 161, 17, 164, 21, 0, 0, 0, 0, 0,
1039 70, 0, 0, 0, 0, 60, 61, 62, 0, 55,
1040 149, 150, 151, 152, 153, 154, 58, 0, 108, 0,
1041 27, 47, 48, 50, 49, 0, 40, 41, 42, 43,
1042 44, 45, 36, 37, 38, 39, 34, 22, 74, 166,
1043 0, 0, 0, 112, 0, 114, 115, 116, 90, 144,
1044 145, 146, 147, 148, 0, 101, 102, 103, 100, 0,
1045 106, 107, 105, 127, 128, 0, 88, 130, 131, 0,
1046 0, 133, 135, 136, 137, 134, 143, 140, 141, 139,
1047 0, 0, 124, 125, 95, 0, 0, 118, 119, 85,
1048 121, 122, 76, 0, 0, 0, 10, 162, 64, 66,
1049 67, 68, 69, 65, 53, 52, 54, 56, 59, 109,
1050 29, 0, 165, 110, 111, 82, 86, 87, 129, 0,
1051 142, 92, 0, 96, 83, 84, 75, 0, 14, 167,
1052 91, 94, 12, 13
1053 };
1054
1055 /* YYPGOTO[NTERM-NUM]. */
1056 static const yytype_int16 yypgoto[] =
1057 {
1058 -199, -199, 125, -199, -25, -199, -111, -199, -199, -199,
1059 -199, -199, -199, -199, -199, -199, -199, -199, 69, -199,
1060 -39, -199, -198, -10, -199, -199, 306, 318, -74, -199,
1061 -199, -199, 78, -199, -199, -199, 49, -46, 56, -199,
1062 -199, -199, 76, -199, 124, -199, 101, -78
1063 };
1064
1065 /* YYDEFGOTO[NTERM-NUM]. */
1066 static const yytype_int16 yydefgoto[] =
1067 {
1068 -1, 2, 3, 4, 28, 29, 206, 30, 31, 70,
1069 67, 142, 143, 144, 145, 66, 64, 65, 119, 63,
1070 7, 34, 95, 149, 82, 83, 192, 193, 157, 77,
1071 92, 93, 88, 84, 85, 86, 185, 190, 168, 128,
1072 129, 81, 100, 101, 60, 61, 74, 150
1073 };
1074
1075 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
1076 positive, shift that token. If negative, reduce the rule whose
1077 number is the opposite. If YYTABLE_NINF, syntax error. */
1078 static const yytype_int16 yytable[] =
1079 {
1080 58, 76, 5, 146, 68, 102, 1, 238, 167, -7,
1081 9, 184, 87, 8, 10, 97, 91, 11, 12, 13,
1082 14, 15, 16, 17, 33, 18, 19, 96, 20, 21,
1083 35, 147, 186, 59, 78, 71, 72, 36, 154, 242,
1084 69, 97, 73, 164, 169, 176, 79, 80, 204, 205,
1085 194, 89, 94, 196, 199, 148, 158, 208, 207, 210,
1086 151, 120, 121, 122, 123, 124, 125, 209, 211, 203,
1087 212, 214, 5, 98, 213, 216, 9, 98, 215, 22,
1088 10, 99, 23, 11, 12, 13, 14, 15, 16, 17,
1089 217, 18, 19, 218, 20, 21, 219, 220, -72, 98,
1090 151, 120, 121, 122, 123, 124, 125, 99, 221, 180,
1091 24, 6, 6, 222, 223, 225, 224, 25, 26, 27,
1092 173, 174, 175, 186, 230, 226, -7, 232, 236, 32,
1093 227, 243, 90, 229, 126, 189, 228, 103, 62, 172,
1094 75, 37, 0, 239, 0, 22, 0, 0, 23, 0,
1095 0, 231, 0, 0, 0, 0, 233, 234, 0, 0,
1096 235, 38, 39, 40, 41, 42, 43, 44, 45, 46,
1097 47, 48, 0, 0, 0, 0, 24, 0, 0, 0,
1098 135, 6, 0, 25, 26, 27, 0, 0, 0, 0,
1099 240, 0, 202, 241, 237, -2, 9, 0, 0, 0,
1100 10, 5, 0, 11, 12, 13, 14, 15, 16, 17,
1101 0, 18, 19, 0, 20, 21, 0, 49, 50, 0,
1102 0, 0, 0, 51, 5, 52, 53, 54, 55, 151,
1103 120, 121, 122, 123, 124, 125, 0, 0, 0, 0,
1104 56, 5, 0, 0, 159, 160, 161, 162, 163, 130,
1105 0, 57, 151, 120, 121, 122, 123, 124, 125, 0,
1106 0, 5, 0, 0, 0, 22, 0, 0, 23, 151,
1107 120, 121, 122, 123, 124, 125, 152, 153, 136, 137,
1108 138, 139, 140, 141, 159, 160, 161, 162, 163, 151,
1109 120, 121, 122, 123, 124, 125, 24, 179, 0, 152,
1110 153, 104, 0, 25, 26, 27, 0, 0, 0, 0,
1111 6, 0, 191, 0, 0, 0, 131, 132, 0, 133,
1112 134, 0, 0, 0, 0, 151, 120, 121, 122, 123,
1113 124, 125, 0, 6, 120, 121, 122, 123, 124, 125,
1114 151, 120, 121, 122, 123, 124, 125, 0, 195, 0,
1115 6, 0, 105, 106, 107, 108, 109, 110, 111, 0,
1116 0, 0, 0, 0, 0, 0, 115, 116, 117, 0,
1117 6, 127, 152, 153, 180, 181, 151, 120, 121, 122,
1118 123, 124, 125, 155, 0, 0, 0, 0, 165, 170,
1119 177, 182, 187, 0, 0, 156, 0, 0, 197, 200,
1120 166, 171, 178, 183, 188, 0, 0, 0, 0, 0,
1121 198, 201, 112, 113, 114, 115, 116, 117, 0, 118
1122 };
1123
1124 static const yytype_int16 yycheck[] =
1125 {
1126 10, 40, 4, 4, 29, 4, 15, 205, 82, 0,
1127 1, 85, 51, 0, 5, 18, 55, 8, 9, 10,
1128 11, 12, 13, 14, 4, 16, 17, 4, 19, 20,
1129 112, 70, 4, 4, 44, 114, 115, 112, 77, 237,
1130 112, 18, 118, 82, 83, 84, 39, 40, 6, 7,
1131 89, 4, 116, 92, 93, 4, 3, 3, 97, 4,
1132 32, 33, 34, 35, 36, 37, 38, 106, 4, 94,
1133 4, 4, 4, 76, 3, 114, 1, 76, 4, 70,
1134 5, 84, 73, 8, 9, 10, 11, 12, 13, 14,
1135 4, 16, 17, 4, 19, 20, 4, 4, 112, 76,
1136 32, 33, 34, 35, 36, 37, 38, 84, 115, 81,
1137 101, 113, 113, 119, 4, 154, 3, 108, 109, 110,
1138 52, 53, 54, 4, 4, 164, 117, 4, 117, 4,
1139 169, 242, 54, 179, 65, 86, 175, 61, 14, 83,
1140 39, 1, -1, 221, -1, 70, -1, -1, 73, -1,
1141 -1, 190, -1, -1, -1, -1, 195, 196, -1, -1,
1142 199, 21, 22, 23, 24, 25, 26, 27, 28, 29,
1143 30, 31, -1, -1, -1, -1, 101, -1, -1, -1,
1144 4, 113, -1, 108, 109, 110, -1, -1, -1, -1,
1145 229, -1, 117, 232, 204, 0, 1, -1, -1, -1,
1146 5, 4, -1, 8, 9, 10, 11, 12, 13, 14,
1147 -1, 16, 17, -1, 19, 20, -1, 77, 78, -1,
1148 -1, -1, -1, 83, 4, 85, 86, 87, 88, 32,
1149 33, 34, 35, 36, 37, 38, -1, -1, -1, -1,
1150 100, 4, -1, -1, 47, 48, 49, 50, 51, 4,
1151 -1, 111, 32, 33, 34, 35, 36, 37, 38, -1,
1152 -1, 4, -1, -1, -1, 70, -1, -1, 73, 32,
1153 33, 34, 35, 36, 37, 38, 79, 80, 102, 103,
1154 104, 105, 106, 107, 47, 48, 49, 50, 51, 32,
1155 33, 34, 35, 36, 37, 38, 101, 4, -1, 79,
1156 80, 4, -1, 108, 109, 110, -1, -1, -1, -1,
1157 113, -1, 4, -1, -1, -1, 71, 72, -1, 74,
1158 75, -1, -1, -1, -1, 32, 33, 34, 35, 36,
1159 37, 38, -1, 113, 33, 34, 35, 36, 37, 38,
1160 32, 33, 34, 35, 36, 37, 38, -1, 4, -1,
1161 113, -1, 55, 56, 57, 58, 59, 60, 61, -1,
1162 -1, -1, -1, -1, -1, -1, 65, 66, 67, -1,
1163 113, 65, 79, 80, 81, 82, 32, 33, 34, 35,
1164 36, 37, 38, 77, -1, -1, -1, -1, 82, 83,
1165 84, 85, 86, -1, -1, 77, -1, -1, 92, 93,
1166 82, 83, 84, 85, 86, -1, -1, -1, -1, -1,
1167 92, 93, 62, 63, 64, 65, 66, 67, -1, 69
1168 };
1169
1170 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1171 symbol of state STATE-NUM. */
1172 static const yytype_uint8 yystos[] =
1173 {
1174 0, 15, 121, 122, 123, 4, 113, 140, 0, 1,
1175 5, 8, 9, 10, 11, 12, 13, 14, 16, 17,
1176 19, 20, 70, 73, 101, 108, 109, 110, 124, 125,
1177 127, 128, 122, 4, 141, 112, 112, 1, 21, 22,
1178 23, 24, 25, 26, 27, 28, 29, 30, 31, 77,
1179 78, 83, 85, 86, 87, 88, 100, 111, 143, 4,
1180 164, 165, 164, 139, 136, 137, 135, 130, 124, 112,
1181 129, 114, 115, 118, 166, 166, 140, 149, 143, 39,
1182 40, 161, 144, 145, 153, 154, 155, 140, 152, 4,
1183 152, 140, 150, 151, 116, 142, 4, 18, 76, 84,
1184 162, 163, 4, 162, 4, 55, 56, 57, 58, 59,
1185 60, 61, 62, 63, 64, 65, 66, 67, 69, 138,
1186 33, 34, 35, 36, 37, 38, 138, 146, 159, 160,
1187 4, 71, 72, 74, 75, 4, 102, 103, 104, 105,
1188 106, 107, 131, 132, 133, 134, 4, 140, 4, 143,
1189 167, 32, 79, 80, 140, 146, 147, 148, 3, 47,
1190 48, 49, 50, 51, 140, 146, 147, 148, 158, 140,
1191 146, 147, 158, 52, 53, 54, 140, 146, 147, 4,
1192 81, 82, 146, 147, 148, 156, 4, 146, 147, 156,
1193 157, 4, 146, 147, 140, 4, 140, 146, 147, 140,
1194 146, 147, 117, 124, 6, 7, 126, 140, 3, 140,
1195 4, 4, 4, 3, 4, 4, 140, 4, 4, 4,
1196 4, 115, 119, 4, 3, 140, 140, 140, 140, 157,
1197 4, 140, 4, 140, 140, 140, 117, 143, 142, 167,
1198 140, 140, 142, 126
1199 };
1200
1201 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
1202 static const yytype_uint8 yyr1[] =
1203 {
1204 0, 120, 121, 121, 122, 122, 123, 124, 124, 125,
1205 125, 125, 126, 126, 126, 127, 127, 127, 127, 127,
1206 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
1207 128, 128, 128, 129, 129, 130, 130, 130, 130, 130,
1208 131, 131, 132, 132, 133, 134, 135, 135, 135, 135,
1209 135, 136, 136, 136, 136, 136, 136, 137, 137, 137,
1210 138, 138, 138, 139, 139, 139, 139, 139, 139, 139,
1211 139, 140, 140, 141, 141, 142, 142, 143, 143, 143,
1212 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
1213 143, 143, 143, 143, 143, 143, 143, 143, 143, 144,
1214 144, 144, 144, 144, 145, 145, 145, 145, 146, 146,
1215 147, 148, 148, 149, 149, 149, 149, 150, 150, 150,
1216 151, 151, 151, 152, 152, 152, 153, 153, 153, 153,
1217 153, 153, 154, 154, 154, 154, 154, 154, 155, 155,
1218 155, 155, 156, 157, 158, 158, 158, 158, 158, 159,
1219 159, 159, 159, 160, 160, 161, 161, 162, 163, 164,
1220 164, 164, 164, 165, 165, 166, 167, 167
1221 };
1222
1223 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
1224 static const yytype_uint8 yyr2[] =
1225 {
1226 0, 2, 1, 2, 0, 2, 3, 1, 2, 2,
1227 4, 2, 0, 4, 2, 2, 3, 3, 2, 1,
1228 1, 3, 3, 1, 1, 2, 2, 3, 1, 4,
1229 1, 1, 1, 0, 2, 0, 2, 2, 2, 2,
1230 1, 1, 1, 1, 1, 1, 0, 2, 2, 2,
1231 2, 0, 3, 3, 3, 2, 3, 0, 2, 3,
1232 1, 1, 1, 0, 3, 3, 3, 3, 3, 3,
1233 2, 3, 1, 1, 3, 3, 2, 2, 2, 2,
1234 1, 1, 4, 4, 4, 3, 4, 4, 3, 2,
1235 3, 5, 4, 2, 5, 3, 4, 2, 1, 0,
1236 2, 2, 2, 2, 0, 2, 2, 2, 1, 2,
1237 2, 2, 1, 0, 2, 2, 2, 0, 2, 2,
1238 0, 2, 2, 0, 2, 2, 0, 2, 2, 3,
1239 2, 2, 0, 2, 2, 2, 2, 2, 0, 2,
1240 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
1241 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
1242 2, 2, 3, 0, 2, 3, 1, 3
1243 };
1244
1245
1246 #define yyerrok (yyerrstatus = 0)
1247 #define yyclearin (yychar = YYEMPTY)
1248 #define YYEMPTY (-2)
1249 #define YYEOF 0
1250
1251 #define YYACCEPT goto yyacceptlab
1252 #define YYABORT goto yyabortlab
1253 #define YYERROR goto yyerrorlab
1254
1255
1256 #define YYRECOVERING() (!!yyerrstatus)
1257
1258 #define YYBACKUP(Token, Value) \
1259 do \
1260 if (yychar == YYEMPTY) \
1261 { \
1262 yychar = (Token); \
1263 yylval = (Value); \
1264 YYPOPSTACK (yylen); \
1265 yystate = *yyssp; \
1266 goto yybackup; \
1267 } \
1268 else \
1269 { \
1270 yyerror (parse_script, YY_("syntax error: cannot back up")); \
1271 YYERROR; \
1272 } \
1273 while (0)
1274
1275 /* Error token number */
1276 #define YYTERROR 1
1277 #define YYERRCODE 256
1278
1279
1280
1281 /* Enable debugging if requested. */
1282 #if YYDEBUG
1283
1284 # ifndef YYFPRINTF
1285 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1286 # define YYFPRINTF fprintf
1287 # endif
1288
1289 # define YYDPRINTF(Args) \
1290 do { \
1291 if (yydebug) \
1292 YYFPRINTF Args; \
1293 } while (0)
1294
1295 /* This macro is provided for backward compatibility. */
1296 #ifndef YY_LOCATION_PRINT
1297 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1298 #endif
1299
1300
1301 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1302 do { \
1303 if (yydebug) \
1304 { \
1305 YYFPRINTF (stderr, "%s ", Title); \
1306 yy_symbol_print (stderr, \
1307 Type, Value, parse_script); \
1308 YYFPRINTF (stderr, "\n"); \
1309 } \
1310 } while (0)
1311
1312
1313 /*-----------------------------------.
1314 | Print this symbol's value on YYO. |
1315 `-----------------------------------*/
1316
1317 static void
yy_symbol_value_print(FILE * yyo,int yytype,YYSTYPE const * const yyvaluep,sieve_script_t * parse_script)1318 yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, sieve_script_t *parse_script)
1319 {
1320 FILE *yyoutput = yyo;
1321 YYUSE (yyoutput);
1322 YYUSE (parse_script);
1323 if (!yyvaluep)
1324 return;
1325 # ifdef YYPRINT
1326 if (yytype < YYNTOKENS)
1327 YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
1328 # endif
1329 YYUSE (yytype);
1330 }
1331
1332
1333 /*---------------------------.
1334 | Print this symbol on YYO. |
1335 `---------------------------*/
1336
1337 static void
yy_symbol_print(FILE * yyo,int yytype,YYSTYPE const * const yyvaluep,sieve_script_t * parse_script)1338 yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, sieve_script_t *parse_script)
1339 {
1340 YYFPRINTF (yyo, "%s %s (",
1341 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1342
1343 yy_symbol_value_print (yyo, yytype, yyvaluep, parse_script);
1344 YYFPRINTF (yyo, ")");
1345 }
1346
1347 /*------------------------------------------------------------------.
1348 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1349 | TOP (included). |
1350 `------------------------------------------------------------------*/
1351
1352 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)1353 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1354 {
1355 YYFPRINTF (stderr, "Stack now");
1356 for (; yybottom <= yytop; yybottom++)
1357 {
1358 int yybot = *yybottom;
1359 YYFPRINTF (stderr, " %d", yybot);
1360 }
1361 YYFPRINTF (stderr, "\n");
1362 }
1363
1364 # define YY_STACK_PRINT(Bottom, Top) \
1365 do { \
1366 if (yydebug) \
1367 yy_stack_print ((Bottom), (Top)); \
1368 } while (0)
1369
1370
1371 /*------------------------------------------------.
1372 | Report that the YYRULE is going to be reduced. |
1373 `------------------------------------------------*/
1374
1375 static void
yy_reduce_print(yytype_int16 * yyssp,YYSTYPE * yyvsp,int yyrule,sieve_script_t * parse_script)1376 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, sieve_script_t *parse_script)
1377 {
1378 unsigned long yylno = yyrline[yyrule];
1379 int yynrhs = yyr2[yyrule];
1380 int yyi;
1381 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1382 yyrule - 1, yylno);
1383 /* The symbols being reduced. */
1384 for (yyi = 0; yyi < yynrhs; yyi++)
1385 {
1386 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1387 yy_symbol_print (stderr,
1388 yystos[yyssp[yyi + 1 - yynrhs]],
1389 &yyvsp[(yyi + 1) - (yynrhs)]
1390 , parse_script);
1391 YYFPRINTF (stderr, "\n");
1392 }
1393 }
1394
1395 # define YY_REDUCE_PRINT(Rule) \
1396 do { \
1397 if (yydebug) \
1398 yy_reduce_print (yyssp, yyvsp, Rule, parse_script); \
1399 } while (0)
1400
1401 /* Nonzero means print parse trace. It is left uninitialized so that
1402 multiple parsers can coexist. */
1403 int yydebug;
1404 #else /* !YYDEBUG */
1405 # define YYDPRINTF(Args)
1406 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1407 # define YY_STACK_PRINT(Bottom, Top)
1408 # define YY_REDUCE_PRINT(Rule)
1409 #endif /* !YYDEBUG */
1410
1411
1412 /* YYINITDEPTH -- initial size of the parser's stacks. */
1413 #ifndef YYINITDEPTH
1414 # define YYINITDEPTH 200
1415 #endif
1416
1417 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1418 if the built-in stack extension method is used).
1419
1420 Do not make this value too large; the results are undefined if
1421 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1422 evaluated with infinite-precision integer arithmetic. */
1423
1424 #ifndef YYMAXDEPTH
1425 # define YYMAXDEPTH 10000
1426 #endif
1427
1428
1429 #if YYERROR_VERBOSE
1430
1431 # ifndef yystrlen
1432 # if defined __GLIBC__ && defined _STRING_H
1433 # define yystrlen strlen
1434 # else
1435 /* Return the length of YYSTR. */
1436 static YYSIZE_T
yystrlen(const char * yystr)1437 yystrlen (const char *yystr)
1438 {
1439 YYSIZE_T yylen;
1440 for (yylen = 0; yystr[yylen]; yylen++)
1441 continue;
1442 return yylen;
1443 }
1444 # endif
1445 # endif
1446
1447 # ifndef yystpcpy
1448 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1449 # define yystpcpy stpcpy
1450 # else
1451 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1452 YYDEST. */
1453 static char *
yystpcpy(char * yydest,const char * yysrc)1454 yystpcpy (char *yydest, const char *yysrc)
1455 {
1456 char *yyd = yydest;
1457 const char *yys = yysrc;
1458
1459 while ((*yyd++ = *yys++) != '\0')
1460 continue;
1461
1462 return yyd - 1;
1463 }
1464 # endif
1465 # endif
1466
1467 # ifndef yytnamerr
1468 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1469 quotes and backslashes, so that it's suitable for yyerror. The
1470 heuristic is that double-quoting is unnecessary unless the string
1471 contains an apostrophe, a comma, or backslash (other than
1472 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1473 null, do not copy; instead, return the length of what the result
1474 would have been. */
1475 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1476 yytnamerr (char *yyres, const char *yystr)
1477 {
1478 if (*yystr == '"')
1479 {
1480 YYSIZE_T yyn = 0;
1481 char const *yyp = yystr;
1482
1483 for (;;)
1484 switch (*++yyp)
1485 {
1486 case '\'':
1487 case ',':
1488 goto do_not_strip_quotes;
1489
1490 case '\\':
1491 if (*++yyp != '\\')
1492 goto do_not_strip_quotes;
1493 else
1494 goto append;
1495
1496 append:
1497 default:
1498 if (yyres)
1499 yyres[yyn] = *yyp;
1500 yyn++;
1501 break;
1502
1503 case '"':
1504 if (yyres)
1505 yyres[yyn] = '\0';
1506 return yyn;
1507 }
1508 do_not_strip_quotes: ;
1509 }
1510
1511 if (! yyres)
1512 return yystrlen (yystr);
1513
1514 return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
1515 }
1516 # endif
1517
1518 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1519 about the unexpected token YYTOKEN for the state stack whose top is
1520 YYSSP.
1521
1522 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1523 not large enough to hold the message. In that case, also set
1524 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1525 required number of bytes is too large to store. */
1526 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1527 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1528 yytype_int16 *yyssp, int yytoken)
1529 {
1530 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1531 YYSIZE_T yysize = yysize0;
1532 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1533 /* Internationalized format string. */
1534 const char *yyformat = YY_NULLPTR;
1535 /* Arguments of yyformat. */
1536 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1537 /* Number of reported tokens (one for the "unexpected", one per
1538 "expected"). */
1539 int yycount = 0;
1540
1541 /* There are many possibilities here to consider:
1542 - If this state is a consistent state with a default action, then
1543 the only way this function was invoked is if the default action
1544 is an error action. In that case, don't check for expected
1545 tokens because there are none.
1546 - The only way there can be no lookahead present (in yychar) is if
1547 this state is a consistent state with a default action. Thus,
1548 detecting the absence of a lookahead is sufficient to determine
1549 that there is no unexpected or expected token to report. In that
1550 case, just report a simple "syntax error".
1551 - Don't assume there isn't a lookahead just because this state is a
1552 consistent state with a default action. There might have been a
1553 previous inconsistent state, consistent state with a non-default
1554 action, or user semantic action that manipulated yychar.
1555 - Of course, the expected token list depends on states to have
1556 correct lookahead information, and it depends on the parser not
1557 to perform extra reductions after fetching a lookahead from the
1558 scanner and before detecting a syntax error. Thus, state merging
1559 (from LALR or IELR) and default reductions corrupt the expected
1560 token list. However, the list is correct for canonical LR with
1561 one exception: it will still contain any token that will not be
1562 accepted due to an error action in a later state.
1563 */
1564 if (yytoken != YYEMPTY)
1565 {
1566 int yyn = yypact[*yyssp];
1567 yyarg[yycount++] = yytname[yytoken];
1568 if (!yypact_value_is_default (yyn))
1569 {
1570 /* Start YYX at -YYN if negative to avoid negative indexes in
1571 YYCHECK. In other words, skip the first -YYN actions for
1572 this state because they are default actions. */
1573 int yyxbegin = yyn < 0 ? -yyn : 0;
1574 /* Stay within bounds of both yycheck and yytname. */
1575 int yychecklim = YYLAST - yyn + 1;
1576 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1577 int yyx;
1578
1579 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1580 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1581 && !yytable_value_is_error (yytable[yyx + yyn]))
1582 {
1583 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1584 {
1585 yycount = 1;
1586 yysize = yysize0;
1587 break;
1588 }
1589 yyarg[yycount++] = yytname[yyx];
1590 {
1591 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1592 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1593 yysize = yysize1;
1594 else
1595 return 2;
1596 }
1597 }
1598 }
1599 }
1600
1601 switch (yycount)
1602 {
1603 # define YYCASE_(N, S) \
1604 case N: \
1605 yyformat = S; \
1606 break
1607 default: /* Avoid compiler warnings. */
1608 YYCASE_(0, YY_("syntax error"));
1609 YYCASE_(1, YY_("syntax error, unexpected %s"));
1610 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1611 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1612 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1613 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1614 # undef YYCASE_
1615 }
1616
1617 {
1618 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1619 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1620 yysize = yysize1;
1621 else
1622 return 2;
1623 }
1624
1625 if (*yymsg_alloc < yysize)
1626 {
1627 *yymsg_alloc = 2 * yysize;
1628 if (! (yysize <= *yymsg_alloc
1629 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1630 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1631 return 1;
1632 }
1633
1634 /* Avoid sprintf, as that infringes on the user's name space.
1635 Don't have undefined behavior even if the translation
1636 produced a string with the wrong number of "%s"s. */
1637 {
1638 char *yyp = *yymsg;
1639 int yyi = 0;
1640 while ((*yyp = *yyformat) != '\0')
1641 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1642 {
1643 yyp += yytnamerr (yyp, yyarg[yyi++]);
1644 yyformat += 2;
1645 }
1646 else
1647 {
1648 yyp++;
1649 yyformat++;
1650 }
1651 }
1652 return 0;
1653 }
1654 #endif /* YYERROR_VERBOSE */
1655
1656 /*-----------------------------------------------.
1657 | Release the memory associated to this symbol. |
1658 `-----------------------------------------------*/
1659
1660 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep,sieve_script_t * parse_script)1661 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, sieve_script_t *parse_script)
1662 {
1663 YYUSE (yyvaluep);
1664 YYUSE (parse_script);
1665 if (!yymsg)
1666 yymsg = "Deleting";
1667 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1668
1669 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1670 switch (yytype)
1671 {
1672 case 124: /* commands */
1673 #line 302 "sieve/sieve.y" /* yacc.c:1257 */
1674 { free_tree(((*yyvaluep).cl)); }
1675 #line 1676 "sieve/sieve.c" /* yacc.c:1257 */
1676 break;
1677
1678 case 125: /* command */
1679 #line 302 "sieve/sieve.y" /* yacc.c:1257 */
1680 { free_tree(((*yyvaluep).cl)); }
1681 #line 1682 "sieve/sieve.c" /* yacc.c:1257 */
1682 break;
1683
1684 case 126: /* elsif */
1685 #line 302 "sieve/sieve.y" /* yacc.c:1257 */
1686 { free_tree(((*yyvaluep).cl)); }
1687 #line 1688 "sieve/sieve.c" /* yacc.c:1257 */
1688 break;
1689
1690 case 127: /* action */
1691 #line 302 "sieve/sieve.y" /* yacc.c:1257 */
1692 { free_tree(((*yyvaluep).cl)); }
1693 #line 1694 "sieve/sieve.c" /* yacc.c:1257 */
1694 break;
1695
1696 case 142: /* block */
1697 #line 302 "sieve/sieve.y" /* yacc.c:1257 */
1698 { free_tree(((*yyvaluep).cl)); }
1699 #line 1700 "sieve/sieve.c" /* yacc.c:1257 */
1700 break;
1701
1702 default:
1703 break;
1704 }
1705 YY_IGNORE_MAYBE_UNINITIALIZED_END
1706 }
1707
1708
1709
1710
1711 /*----------.
1712 | yyparse. |
1713 `----------*/
1714
1715 int
yyparse(sieve_script_t * parse_script)1716 yyparse (sieve_script_t *parse_script)
1717 {
1718 /* The lookahead symbol. */
1719 int yychar;
1720
1721
1722 /* The semantic value of the lookahead symbol. */
1723 /* Default value used for initialization, for pacifying older GCCs
1724 or non-GCC compilers. */
1725 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1726 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1727
1728 /* Number of syntax errors so far. */
1729 int yynerrs;
1730
1731 int yystate;
1732 /* Number of tokens to shift before error messages enabled. */
1733 int yyerrstatus;
1734
1735 /* The stacks and their tools:
1736 'yyss': related to states.
1737 'yyvs': related to semantic values.
1738
1739 Refer to the stacks through separate pointers, to allow yyoverflow
1740 to reallocate them elsewhere. */
1741
1742 /* The state stack. */
1743 yytype_int16 yyssa[YYINITDEPTH];
1744 yytype_int16 *yyss;
1745 yytype_int16 *yyssp;
1746
1747 /* The semantic value stack. */
1748 YYSTYPE yyvsa[YYINITDEPTH];
1749 YYSTYPE *yyvs;
1750 YYSTYPE *yyvsp;
1751
1752 YYSIZE_T yystacksize;
1753
1754 int yyn;
1755 int yyresult;
1756 /* Lookahead token as an internal (translated) token number. */
1757 int yytoken = 0;
1758 /* The variables used to return semantic value and location from the
1759 action routines. */
1760 YYSTYPE yyval;
1761
1762 #if YYERROR_VERBOSE
1763 /* Buffer for error messages, and its allocated size. */
1764 char yymsgbuf[128];
1765 char *yymsg = yymsgbuf;
1766 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1767 #endif
1768
1769 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1770
1771 /* The number of symbols on the RHS of the reduced rule.
1772 Keep to zero when no symbol should be popped. */
1773 int yylen = 0;
1774
1775 yyssp = yyss = yyssa;
1776 yyvsp = yyvs = yyvsa;
1777 yystacksize = YYINITDEPTH;
1778
1779 YYDPRINTF ((stderr, "Starting parse\n"));
1780
1781 yystate = 0;
1782 yyerrstatus = 0;
1783 yynerrs = 0;
1784 yychar = YYEMPTY; /* Cause a token to be read. */
1785 goto yysetstate;
1786
1787
1788 /*------------------------------------------------------------.
1789 | yynewstate -- push a new state, which is found in yystate. |
1790 `------------------------------------------------------------*/
1791 yynewstate:
1792 /* In all cases, when you get here, the value and location stacks
1793 have just been pushed. So pushing a state here evens the stacks. */
1794 yyssp++;
1795
1796
1797 /*--------------------------------------------------------------------.
1798 | yynewstate -- set current state (the top of the stack) to yystate. |
1799 `--------------------------------------------------------------------*/
1800 yysetstate:
1801 *yyssp = (yytype_int16) yystate;
1802
1803 if (yyss + yystacksize - 1 <= yyssp)
1804 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1805 goto yyexhaustedlab;
1806 #else
1807 {
1808 /* Get the current used size of the three stacks, in elements. */
1809 YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
1810
1811 # if defined yyoverflow
1812 {
1813 /* Give user a chance to reallocate the stack. Use copies of
1814 these so that the &'s don't force the real ones into
1815 memory. */
1816 YYSTYPE *yyvs1 = yyvs;
1817 yytype_int16 *yyss1 = yyss;
1818
1819 /* Each stack pointer address is followed by the size of the
1820 data in use in that stack, in bytes. This used to be a
1821 conditional around just the two extra args, but that might
1822 be undefined if yyoverflow is a macro. */
1823 yyoverflow (YY_("memory exhausted"),
1824 &yyss1, yysize * sizeof (*yyssp),
1825 &yyvs1, yysize * sizeof (*yyvsp),
1826 &yystacksize);
1827 yyss = yyss1;
1828 yyvs = yyvs1;
1829 }
1830 # else /* defined YYSTACK_RELOCATE */
1831 /* Extend the stack our own way. */
1832 if (YYMAXDEPTH <= yystacksize)
1833 goto yyexhaustedlab;
1834 yystacksize *= 2;
1835 if (YYMAXDEPTH < yystacksize)
1836 yystacksize = YYMAXDEPTH;
1837
1838 {
1839 yytype_int16 *yyss1 = yyss;
1840 union yyalloc *yyptr =
1841 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1842 if (! yyptr)
1843 goto yyexhaustedlab;
1844 YYSTACK_RELOCATE (yyss_alloc, yyss);
1845 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1846 # undef YYSTACK_RELOCATE
1847 if (yyss1 != yyssa)
1848 YYSTACK_FREE (yyss1);
1849 }
1850 # endif
1851
1852 yyssp = yyss + yysize - 1;
1853 yyvsp = yyvs + yysize - 1;
1854
1855 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1856 (unsigned long) yystacksize));
1857
1858 if (yyss + yystacksize - 1 <= yyssp)
1859 YYABORT;
1860 }
1861 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1862
1863 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1864
1865 if (yystate == YYFINAL)
1866 YYACCEPT;
1867
1868 goto yybackup;
1869
1870
1871 /*-----------.
1872 | yybackup. |
1873 `-----------*/
1874 yybackup:
1875 /* Do appropriate processing given the current state. Read a
1876 lookahead token if we need one and don't already have one. */
1877
1878 /* First try to decide what to do without reference to lookahead token. */
1879 yyn = yypact[yystate];
1880 if (yypact_value_is_default (yyn))
1881 goto yydefault;
1882
1883 /* Not known => get a lookahead token if don't already have one. */
1884
1885 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1886 if (yychar == YYEMPTY)
1887 {
1888 YYDPRINTF ((stderr, "Reading a token: "));
1889 yychar = yylex (&yylval, parse_script);
1890 }
1891
1892 if (yychar <= YYEOF)
1893 {
1894 yychar = yytoken = YYEOF;
1895 YYDPRINTF ((stderr, "Now at end of input.\n"));
1896 }
1897 else
1898 {
1899 yytoken = YYTRANSLATE (yychar);
1900 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1901 }
1902
1903 /* If the proper action on seeing token YYTOKEN is to reduce or to
1904 detect an error, take that action. */
1905 yyn += yytoken;
1906 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1907 goto yydefault;
1908 yyn = yytable[yyn];
1909 if (yyn <= 0)
1910 {
1911 if (yytable_value_is_error (yyn))
1912 goto yyerrlab;
1913 yyn = -yyn;
1914 goto yyreduce;
1915 }
1916
1917 /* Count tokens shifted since error; after three, turn off error
1918 status. */
1919 if (yyerrstatus)
1920 yyerrstatus--;
1921
1922 /* Shift the lookahead token. */
1923 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1924
1925 /* Discard the shifted token. */
1926 yychar = YYEMPTY;
1927
1928 yystate = yyn;
1929 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1930 *++yyvsp = yylval;
1931 YY_IGNORE_MAYBE_UNINITIALIZED_END
1932
1933 goto yynewstate;
1934
1935
1936 /*-----------------------------------------------------------.
1937 | yydefault -- do the default action for the current state. |
1938 `-----------------------------------------------------------*/
1939 yydefault:
1940 yyn = yydefact[yystate];
1941 if (yyn == 0)
1942 goto yyerrlab;
1943 goto yyreduce;
1944
1945
1946 /*-----------------------------.
1947 | yyreduce -- do a reduction. |
1948 `-----------------------------*/
1949 yyreduce:
1950 /* yyn is the number of a rule to reduce with. */
1951 yylen = yyr2[yyn];
1952
1953 /* If YYLEN is nonzero, implement the default value of the action:
1954 '$$ = $1'.
1955
1956 Otherwise, the following line sets YYVAL to garbage.
1957 This behavior is undocumented and Bison
1958 users should not rely upon it. Assigning to YYVAL
1959 unconditionally makes the parser a bit smaller, and it avoids a
1960 GCC warning that YYVAL may be used uninitialized. */
1961 yyval = yyvsp[1-yylen];
1962
1963
1964 YY_REDUCE_PRINT (yyn);
1965 switch (yyn)
1966 {
1967 case 2:
1968 #line 314 "sieve/sieve.y" /* yacc.c:1652 */
1969 { parse_script->cmds = NULL; }
1970 #line 1971 "sieve/sieve.c" /* yacc.c:1652 */
1971 break;
1972
1973 case 3:
1974 #line 315 "sieve/sieve.y" /* yacc.c:1652 */
1975 { parse_script->cmds = (yyvsp[0].cl); }
1976 #line 1977 "sieve/sieve.c" /* yacc.c:1652 */
1977 break;
1978
1979 case 6:
1980 #line 323 "sieve/sieve.y" /* yacc.c:1652 */
1981 {
1982 char *err = check_reqs(parse_script, (yyvsp[-1].sl));
1983 if (err) {
1984 yyerror(parse_script, err);
1985 free(err);
1986 YYERROR;
1987 }
1988 }
1989 #line 1990 "sieve/sieve.c" /* yacc.c:1652 */
1990 break;
1991
1992 case 7:
1993 #line 333 "sieve/sieve.y" /* yacc.c:1652 */
1994 { (yyval.cl) = (yyvsp[0].cl); }
1995 #line 1996 "sieve/sieve.c" /* yacc.c:1652 */
1996 break;
1997
1998 case 8:
1999 #line 334 "sieve/sieve.y" /* yacc.c:1652 */
2000 { (yyvsp[-1].cl)->next = (yyvsp[0].cl); (yyval.cl) = (yyvsp[-1].cl); }
2001 #line 2002 "sieve/sieve.c" /* yacc.c:1652 */
2002 break;
2003
2004 case 9:
2005 #line 337 "sieve/sieve.y" /* yacc.c:1652 */
2006 { (yyval.cl) = (yyvsp[-1].cl); }
2007 #line 2008 "sieve/sieve.c" /* yacc.c:1652 */
2008 break;
2009
2010 case 10:
2011 #line 338 "sieve/sieve.y" /* yacc.c:1652 */
2012 { (yyval.cl) = new_if((yyvsp[-2].test), (yyvsp[-1].cl), (yyvsp[0].cl)); }
2013 #line 2014 "sieve/sieve.c" /* yacc.c:1652 */
2014 break;
2015
2016 case 11:
2017 #line 339 "sieve/sieve.y" /* yacc.c:1652 */
2018 { (yyval.cl) = new_command(STOP); }
2019 #line 2020 "sieve/sieve.c" /* yacc.c:1652 */
2020 break;
2021
2022 case 12:
2023 #line 342 "sieve/sieve.y" /* yacc.c:1652 */
2024 { (yyval.cl) = NULL; }
2025 #line 2026 "sieve/sieve.c" /* yacc.c:1652 */
2026 break;
2027
2028 case 13:
2029 #line 343 "sieve/sieve.y" /* yacc.c:1652 */
2030 { (yyval.cl) = new_if((yyvsp[-2].test), (yyvsp[-1].cl), (yyvsp[0].cl)); }
2031 #line 2032 "sieve/sieve.c" /* yacc.c:1652 */
2032 break;
2033
2034 case 14:
2035 #line 344 "sieve/sieve.y" /* yacc.c:1652 */
2036 { (yyval.cl) = (yyvsp[0].cl); }
2037 #line 2038 "sieve/sieve.c" /* yacc.c:1652 */
2038 break;
2039
2040 case 15:
2041 #line 348 "sieve/sieve.y" /* yacc.c:1652 */
2042 {
2043 if (!parse_script->support.reject) {
2044 parse_error(parse_script,
2045 SIEVE_MISSING_REQUIRE,
2046 "reject");
2047 YYERROR; /* pe should call yyerror() */
2048 }
2049 if (!verify_utf8(parse_script, (yyvsp[0].sval))) {
2050 YYERROR; /* vu should call yyerror() */
2051 }
2052 (yyval.cl) = new_command(REJCT);
2053 (yyval.cl)->u.reject = (yyvsp[0].sval);
2054 }
2055 #line 2056 "sieve/sieve.c" /* yacc.c:1652 */
2056 break;
2057
2058 case 16:
2059 #line 363 "sieve/sieve.y" /* yacc.c:1652 */
2060 {
2061 if (!parse_script->support.fileinto) {
2062 parse_error(parse_script,
2063 SIEVE_MISSING_REQUIRE,
2064 "fileinto");
2065 YYERROR; /* pe should call yyerror() */
2066 }
2067 if (!verify_mailbox(parse_script, (yyvsp[0].sval))) {
2068 YYERROR; /* vm should call yyerror() */
2069 }
2070 (yyval.cl) = build_fileinto(FILEINTO,
2071 canon_ftags((yyvsp[-1].ftag)), (yyvsp[0].sval));
2072 }
2073 #line 2074 "sieve/sieve.c" /* yacc.c:1652 */
2074 break;
2075
2076 case 17:
2077 #line 378 "sieve/sieve.y" /* yacc.c:1652 */
2078 {
2079 if (!verify_address(parse_script, (yyvsp[0].sval))) {
2080 YYERROR; /* va should call yyerror() */
2081 }
2082 (yyval.cl) = build_redirect(REDIRECT, (yyvsp[-1].nval), (yyvsp[0].sval));
2083 }
2084 #line 2085 "sieve/sieve.c" /* yacc.c:1652 */
2085 break;
2086
2087 case 18:
2088 #line 385 "sieve/sieve.y" /* yacc.c:1652 */
2089 { (yyval.cl) = build_keep(KEEP,canon_ftags((yyvsp[0].ftag))); }
2090 #line 2091 "sieve/sieve.c" /* yacc.c:1652 */
2091 break;
2092
2093 case 19:
2094 #line 386 "sieve/sieve.y" /* yacc.c:1652 */
2095 { (yyval.cl) = new_command(STOP); }
2096 #line 2097 "sieve/sieve.c" /* yacc.c:1652 */
2097 break;
2098
2099 case 20:
2100 #line 387 "sieve/sieve.y" /* yacc.c:1652 */
2101 { (yyval.cl) = new_command(DISCARD); }
2102 #line 2103 "sieve/sieve.c" /* yacc.c:1652 */
2103 break;
2104
2105 case 21:
2106 #line 390 "sieve/sieve.y" /* yacc.c:1652 */
2107 {
2108 if (!parse_script->support.vacation) {
2109 parse_error(parse_script,
2110 SIEVE_MISSING_REQUIRE,
2111 "vacation");
2112 YYERROR; /* pe should call yyerror() */
2113 }
2114 if (((yyvsp[-1].vtag)->mime == -1) &&
2115 !verify_utf8(parse_script, (yyvsp[0].sval))) {
2116 YYERROR; /* vu should call yyerror() */
2117 }
2118 (yyval.cl) = build_vacation(VACATION,
2119 canon_vtags(parse_script, (yyvsp[-1].vtag)),
2120 (yyvsp[0].sval));
2121 }
2122 #line 2123 "sieve/sieve.c" /* yacc.c:1652 */
2123 break;
2124
2125 case 22:
2126 #line 407 "sieve/sieve.y" /* yacc.c:1652 */
2127 {
2128 if (!(parse_script->support.imapflags ||
2129 parse_script->support.imap4flags)) {
2130 parse_error(parse_script,
2131 SIEVE_MISSING_REQUIRE,
2132 "imap[4]flags");
2133 YYERROR; /* pe should call yyerror() */
2134 }
2135 if (!parse_script->support.variables) {
2136 verify_flaglist((yyvsp[0].sl));
2137 }
2138 if (!(yyvsp[0].sl)->count) strarray_add((yyvsp[0].sl), "");
2139 (yyval.cl) = build_flag((yyvsp[-2].nval), (yyvsp[-1].sval), (yyvsp[0].sl));
2140 }
2141 #line 2142 "sieve/sieve.c" /* yacc.c:1652 */
2142 break;
2143
2144 case 23:
2145 #line 423 "sieve/sieve.y" /* yacc.c:1652 */
2146 {
2147 if (!parse_script->support.imapflags) {
2148 parse_error(parse_script,
2149 SIEVE_MISSING_REQUIRE,
2150 "imapflags");
2151 YYERROR; /* pe should call yyerror() */
2152 }
2153 (yyval.cl) = new_command(MARK);
2154 }
2155 #line 2156 "sieve/sieve.c" /* yacc.c:1652 */
2156 break;
2157
2158 case 24:
2159 #line 434 "sieve/sieve.y" /* yacc.c:1652 */
2160 {
2161 if (!parse_script->support.imapflags) {
2162 parse_error(parse_script,
2163 SIEVE_MISSING_REQUIRE,
2164 "imapflags");
2165 YYERROR; /* pe should call yyerror() */
2166 }
2167 (yyval.cl) = new_command(UNMARK);
2168 }
2169 #line 2170 "sieve/sieve.c" /* yacc.c:1652 */
2170 break;
2171
2172 case 25:
2173 #line 445 "sieve/sieve.y" /* yacc.c:1652 */
2174 {
2175 if (!parse_script->support.notify) {
2176 parse_error(parse_script,
2177 SIEVE_MISSING_REQUIRE,
2178 "notify");
2179 (yyval.cl) = new_command(NOTIFY);
2180 YYERROR; /* pe should call yyerror() */
2181 }
2182 (yyval.cl) = build_notify(NOTIFY, canon_ntags((yyvsp[0].ntag)));
2183 }
2184 #line 2185 "sieve/sieve.c" /* yacc.c:1652 */
2185 break;
2186
2187 case 26:
2188 #line 457 "sieve/sieve.y" /* yacc.c:1652 */
2189 {
2190 if (!parse_script->support.notify) {
2191 parse_error(parse_script,
2192 SIEVE_MISSING_REQUIRE,
2193 "notify");
2194 (yyval.cl) = new_command(DENOTIFY);
2195 YYERROR; /* pe should call yyerror() */
2196 }
2197 (yyval.cl) = build_denotify(DENOTIFY,
2198 canon_dtags((yyvsp[0].dtag)));
2199 if ((yyval.cl) == NULL) {
2200 parse_error(parse_script,
2201 SIEVE_BUILD_FAILURE,
2202 "denotify action");
2203 YYERROR; /* pe should call yyerror() */
2204 }
2205 }
2206 #line 2207 "sieve/sieve.c" /* yacc.c:1652 */
2207 break;
2208
2209 case 27:
2210 #line 476 "sieve/sieve.y" /* yacc.c:1652 */
2211 {
2212 if (!parse_script->support.include) {
2213 parse_error(parse_script,
2214 SIEVE_MISSING_REQUIRE,
2215 "include");
2216 YYERROR; /* pe should call yyerror() */
2217 }
2218 int i;
2219 for (i = 0; (yyvsp[0].sval)[i] != '\0'; i++) {
2220 if ((yyvsp[0].sval)[i] == '/') {
2221 parse_error(parse_script,
2222 SIEVE_INVALID_VALUE,
2223 "script-name");
2224 YYERROR; /* pe should call yyerror() */
2225 break;
2226 }
2227 }
2228 (yyval.cl) = build_include(INCLUDE, (yyvsp[-1].itag), (yyvsp[0].sval));
2229 }
2230 #line 2231 "sieve/sieve.c" /* yacc.c:1652 */
2231 break;
2232
2233 case 28:
2234 #line 497 "sieve/sieve.y" /* yacc.c:1652 */
2235 {
2236 if (!parse_script->support.include) {
2237 parse_error(parse_script,
2238 SIEVE_MISSING_REQUIRE,
2239 "include");
2240 YYERROR; /* pe should call yyerror() */
2241 }
2242 (yyval.cl) = new_command(RETURN);
2243 }
2244 #line 2245 "sieve/sieve.c" /* yacc.c:1652 */
2245 break;
2246
2247 case 29:
2248 #line 508 "sieve/sieve.y" /* yacc.c:1652 */
2249 {
2250 if (!parse_script->support.variables) {
2251 parse_error(parse_script,
2252 SIEVE_MISSING_REQUIRE,
2253 "variables");
2254 YYERROR; /* pe should call yyerror() */
2255 }
2256 if (!verify_identifier(parse_script, (yyvsp[-1].sval))) {
2257 YYERROR; /* vi should call yyerror() */
2258 }
2259 if (!verify_utf8(parse_script, (yyvsp[0].sval))) {
2260 YYERROR; /* vu should call yyerror() */
2261 }
2262 (yyval.cl) = build_set(SET, canon_stags((yyvsp[-2].stag)), (yyvsp[-1].sval), (yyvsp[0].sval));
2263 }
2264 #line 2265 "sieve/sieve.c" /* yacc.c:1652 */
2265 break;
2266
2267 case 33:
2268 #line 530 "sieve/sieve.y" /* yacc.c:1652 */
2269 { (yyval.sval) = NULL; }
2270 #line 2271 "sieve/sieve.c" /* yacc.c:1652 */
2271 break;
2272
2273 case 34:
2274 #line 532 "sieve/sieve.y" /* yacc.c:1652 */
2275 {
2276 if (!(parse_script->support.imap4flags)) {
2277 parse_error(parse_script,
2278 SIEVE_MISSING_REQUIRE,
2279 "imap4flags");
2280 YYERROR; /* pe should call yyerror() */
2281 }
2282 if ((yyvsp[-1].sval)) {
2283 parse_error(parse_script,
2284 SIEVE_DUPLICATE_ARG,
2285 "variablename");
2286 YYERROR; /* pe should call yyerror() */
2287 }
2288 if (!is_identifier((yyvsp[0].sval))) {
2289 YYERROR; /* id should call yyerror() */
2290 }
2291 (yyval.sval) = (yyvsp[0].sval);
2292 }
2293 #line 2294 "sieve/sieve.c" /* yacc.c:1652 */
2294 break;
2295
2296 case 35:
2297 #line 552 "sieve/sieve.y" /* yacc.c:1652 */
2298 { (yyval.stag) = new_stags(); }
2299 #line 2300 "sieve/sieve.c" /* yacc.c:1652 */
2300 break;
2301
2302 case 36:
2303 #line 554 "sieve/sieve.y" /* yacc.c:1652 */
2304 {
2305 if ((yyval.stag)->mod40) {
2306 parse_error(parse_script,
2307 SIEVE_DUPLICATE_TAG,
2308 "precedence 40 modifier");
2309 YYERROR; /* pe should call yyerror() */
2310 }
2311 else (yyval.stag)->mod40 = (yyvsp[0].nval);
2312 }
2313 #line 2314 "sieve/sieve.c" /* yacc.c:1652 */
2314 break;
2315
2316 case 37:
2317 #line 564 "sieve/sieve.y" /* yacc.c:1652 */
2318 {
2319 if ((yyval.stag)->mod30) {
2320 parse_error(parse_script,
2321 SIEVE_DUPLICATE_TAG,
2322 "precedence 30 modifier");
2323 YYERROR; /* pe should call yyerror() */
2324 }
2325 else (yyval.stag)->mod30 = (yyvsp[0].nval);
2326 }
2327 #line 2328 "sieve/sieve.c" /* yacc.c:1652 */
2328 break;
2329
2330 case 38:
2331 #line 574 "sieve/sieve.y" /* yacc.c:1652 */
2332 {
2333 if ((yyval.stag)->mod20) {
2334 parse_error(parse_script,
2335 SIEVE_DUPLICATE_TAG,
2336 "precedence 20 modifier");
2337 YYERROR; /* pe should call yyerror() */
2338 }
2339 else (yyval.stag)->mod20 = (yyvsp[0].nval);
2340 }
2341 #line 2342 "sieve/sieve.c" /* yacc.c:1652 */
2342 break;
2343
2344 case 39:
2345 #line 609 "sieve/sieve.y" /* yacc.c:1652 */
2346 {
2347 if ((yyval.stag)->mod10) {
2348 parse_error(parse_script,
2349 SIEVE_DUPLICATE_TAG,
2350 "precedence 10 modifier");
2351 YYERROR; /* pe should call yyerror() */
2352 }
2353 else (yyval.stag)->mod10 = (yyvsp[0].nval);
2354 }
2355 #line 2356 "sieve/sieve.c" /* yacc.c:1652 */
2356 break;
2357
2358 case 46:
2359 #line 631 "sieve/sieve.y" /* yacc.c:1652 */
2360 { (yyval.itag) = new_itags(); }
2361 #line 2362 "sieve/sieve.c" /* yacc.c:1652 */
2362 break;
2363
2364 case 47:
2365 #line 633 "sieve/sieve.y" /* yacc.c:1652 */
2366 {
2367 if ((yyval.itag)->location != -1) {
2368 parse_error(parse_script,
2369 SIEVE_DUPLICATE_TAG,
2370 "location");
2371 YYERROR; /* pe should call yyerror() */
2372 }
2373 else (yyval.itag)->location = PERSONAL;
2374 }
2375 #line 2376 "sieve/sieve.c" /* yacc.c:1652 */
2376 break;
2377
2378 case 48:
2379 #line 643 "sieve/sieve.y" /* yacc.c:1652 */
2380 {
2381 if ((yyval.itag)->location != -1) {
2382 parse_error(parse_script,
2383 SIEVE_DUPLICATE_TAG,
2384 "location");
2385 YYERROR; /* pe should call yyerror() */
2386 }
2387 else (yyval.itag)->location = GLOBAL;
2388 }
2389 #line 2390 "sieve/sieve.c" /* yacc.c:1652 */
2390 break;
2391
2392 case 49:
2393 #line 653 "sieve/sieve.y" /* yacc.c:1652 */
2394 {
2395 if ((yyval.itag)->once != -1) {
2396 parse_error(parse_script,
2397 SIEVE_DUPLICATE_TAG,
2398 ":once");
2399 YYERROR; /* pe should call yyerror() */
2400 }
2401 else (yyval.itag)->once = 1;
2402 }
2403 #line 2404 "sieve/sieve.c" /* yacc.c:1652 */
2404 break;
2405
2406 case 50:
2407 #line 663 "sieve/sieve.y" /* yacc.c:1652 */
2408 { if ((yyval.itag)->optional != -1) {
2409 parse_error(parse_script,
2410 SIEVE_DUPLICATE_TAG,
2411 ":optional");
2412 YYERROR; /* pe should call yyerror() */
2413 }
2414 else (yyval.itag)->optional = 1;
2415 }
2416 #line 2417 "sieve/sieve.c" /* yacc.c:1652 */
2417 break;
2418
2419 case 51:
2420 #line 673 "sieve/sieve.y" /* yacc.c:1652 */
2421 { (yyval.ntag) = new_ntags(); }
2422 #line 2423 "sieve/sieve.c" /* yacc.c:1652 */
2423 break;
2424
2425 case 52:
2426 #line 675 "sieve/sieve.y" /* yacc.c:1652 */
2427 {
2428 if ((yyval.ntag)->id != NULL) {
2429 parse_error(parse_script,
2430 SIEVE_DUPLICATE_TAG,
2431 ":id");
2432 YYERROR; /* pe should call yyerror() */
2433 }
2434 else (yyval.ntag)->id = (yyvsp[0].sval);
2435 }
2436 #line 2437 "sieve/sieve.c" /* yacc.c:1652 */
2437 break;
2438
2439 case 53:
2440 #line 685 "sieve/sieve.y" /* yacc.c:1652 */
2441 {
2442 if ((yyval.ntag)->method != NULL) {
2443 parse_error(parse_script,
2444 SIEVE_DUPLICATE_TAG,
2445 ":method");
2446 YYERROR; /* pe should call yyerror() */
2447 }
2448 else (yyval.ntag)->method = (yyvsp[0].sval);
2449 }
2450 #line 2451 "sieve/sieve.c" /* yacc.c:1652 */
2451 break;
2452
2453 case 54:
2454 #line 695 "sieve/sieve.y" /* yacc.c:1652 */
2455 {
2456 if ((yyval.ntag)->options != NULL) {
2457 parse_error(parse_script,
2458 SIEVE_DUPLICATE_TAG,
2459 ":options");
2460 YYERROR; /* pe should call yyerror() */
2461 }
2462 else (yyval.ntag)->options = (yyvsp[0].sl);
2463 }
2464 #line 2465 "sieve/sieve.c" /* yacc.c:1652 */
2465 break;
2466
2467 case 55:
2468 #line 705 "sieve/sieve.y" /* yacc.c:1652 */
2469 {
2470 if ((yyval.ntag)->priority != -1) {
2471 parse_error(parse_script,
2472 SIEVE_DUPLICATE_TAG,
2473 "priority");
2474 YYERROR; /* pe should call yyerror() */
2475 }
2476 else (yyval.ntag)->priority = (yyvsp[0].nval);
2477 }
2478 #line 2479 "sieve/sieve.c" /* yacc.c:1652 */
2479 break;
2480
2481 case 56:
2482 #line 715 "sieve/sieve.y" /* yacc.c:1652 */
2483 {
2484 if ((yyval.ntag)->message != NULL) {
2485 parse_error(parse_script,
2486 SIEVE_DUPLICATE_TAG,
2487 ":message");
2488 YYERROR; /* pe should call yyerror() */
2489 }
2490 else (yyval.ntag)->message = (yyvsp[0].sval);
2491 }
2492 #line 2493 "sieve/sieve.c" /* yacc.c:1652 */
2493 break;
2494
2495 case 57:
2496 #line 726 "sieve/sieve.y" /* yacc.c:1652 */
2497 { (yyval.dtag) = new_dtags(); }
2498 #line 2499 "sieve/sieve.c" /* yacc.c:1652 */
2499 break;
2500
2501 case 58:
2502 #line 728 "sieve/sieve.y" /* yacc.c:1652 */
2503 {
2504 if ((yyval.dtag)->priority != -1) {
2505 parse_error(parse_script,
2506 SIEVE_DUPLICATE_TAG,
2507 "priority");
2508 YYERROR; /* pe should call yyerror() */
2509 }
2510 else (yyval.dtag)->priority = (yyvsp[0].nval);
2511 }
2512 #line 2513 "sieve/sieve.c" /* yacc.c:1652 */
2513 break;
2514
2515 case 59:
2516 #line 738 "sieve/sieve.y" /* yacc.c:1652 */
2517 {
2518 (yyval.dtag)->pattern = (yyvsp[0].sval);
2519
2520 strarray_t sa = STRARRAY_INITIALIZER;
2521 strarray_appendm(&sa, (yyvsp[0].sval));
2522 if (!verify_patternlist(parse_script, &sa,
2523 &((yyval.dtag)->comptags),
2524 NULL)) {
2525 YYERROR; /* vp should call yyerror() */
2526 }
2527 strarray_fini(&sa);
2528 }
2529 #line 2530 "sieve/sieve.c" /* yacc.c:1652 */
2530 break;
2531
2532 case 60:
2533 #line 752 "sieve/sieve.y" /* yacc.c:1652 */
2534 { (yyval.nval) = LOW; }
2535 #line 2536 "sieve/sieve.c" /* yacc.c:1652 */
2536 break;
2537
2538 case 61:
2539 #line 753 "sieve/sieve.y" /* yacc.c:1652 */
2540 { (yyval.nval) = NORMAL; }
2541 #line 2542 "sieve/sieve.c" /* yacc.c:1652 */
2542 break;
2543
2544 case 62:
2545 #line 754 "sieve/sieve.y" /* yacc.c:1652 */
2546 { (yyval.nval) = HIGH; }
2547 #line 2548 "sieve/sieve.c" /* yacc.c:1652 */
2548 break;
2549
2550 case 63:
2551 #line 757 "sieve/sieve.y" /* yacc.c:1652 */
2552 { (yyval.vtag) = new_vtags(); }
2553 #line 2554 "sieve/sieve.c" /* yacc.c:1652 */
2554 break;
2555
2556 case 64:
2557 #line 759 "sieve/sieve.y" /* yacc.c:1652 */
2558 {
2559 if ((yyval.vtag)->seconds != -1) {
2560 parse_error(parse_script,
2561 SIEVE_DUPLICATE_TAG,
2562 "period");
2563 YYERROR; /* pe should call yyerror() */
2564 }
2565 else (yyval.vtag)->seconds = (yyvsp[0].nval) * DAY2SEC;
2566 }
2567 #line 2568 "sieve/sieve.c" /* yacc.c:1652 */
2568 break;
2569
2570 case 65:
2571 #line 769 "sieve/sieve.y" /* yacc.c:1652 */
2572 {
2573 if (!parse_script->support.vacation_seconds) {
2574 parse_error(parse_script,
2575 SIEVE_MISSING_REQUIRE,
2576 "vacation-seconds");
2577 YYERROR; /* pe should call yyerror() */
2578 }
2579 if ((yyval.vtag)->seconds != -1) {
2580 parse_error(parse_script,
2581 SIEVE_DUPLICATE_TAG,
2582 "period");
2583 YYERROR; /* pe should call yyerror() */
2584 }
2585 (yyval.vtag)->seconds = (yyvsp[0].nval);
2586 }
2587 #line 2588 "sieve/sieve.c" /* yacc.c:1652 */
2588 break;
2589
2590 case 66:
2591 #line 785 "sieve/sieve.y" /* yacc.c:1652 */
2592 {
2593 if ((yyval.vtag)->addresses != NULL) {
2594 parse_error(parse_script,
2595 SIEVE_DUPLICATE_TAG,
2596 ":addresses");
2597 YYERROR; /* pe should call yyerror() */
2598 }
2599 if (!verify_stringlist(parse_script, (yyvsp[0].sl),
2600 verify_address)) {
2601 YYERROR;
2602 }
2603 (yyval.vtag)->addresses = (yyvsp[0].sl);
2604 }
2605 #line 2606 "sieve/sieve.c" /* yacc.c:1652 */
2606 break;
2607
2608 case 67:
2609 #line 799 "sieve/sieve.y" /* yacc.c:1652 */
2610 {
2611 if ((yyval.vtag)->subject != NULL) {
2612 parse_error(parse_script,
2613 SIEVE_DUPLICATE_TAG,
2614 ":subject");
2615 YYERROR; /* pe should call yyerror() */
2616 }
2617 if (!verify_utf8(parse_script, (yyvsp[0].sval))) {
2618 YYERROR; /* vu should call yyerror() */
2619 }
2620 (yyval.vtag)->subject = (yyvsp[0].sval);
2621 }
2622 #line 2623 "sieve/sieve.c" /* yacc.c:1652 */
2623 break;
2624
2625 case 68:
2626 #line 812 "sieve/sieve.y" /* yacc.c:1652 */
2627 {
2628 if ((yyval.vtag)->from != NULL) {
2629 parse_error(parse_script,
2630 SIEVE_DUPLICATE_TAG,
2631 ":from");
2632 YYERROR; /* pe should call yyerror() */
2633 }
2634 if (!verify_address(parse_script, (yyvsp[0].sval))) {
2635 YYERROR; /* va should call yyerror() */
2636 }
2637 (yyval.vtag)->from = (yyvsp[0].sval);
2638 }
2639 #line 2640 "sieve/sieve.c" /* yacc.c:1652 */
2640 break;
2641
2642 case 69:
2643 #line 825 "sieve/sieve.y" /* yacc.c:1652 */
2644 {
2645 if ((yyval.vtag)->handle != NULL) {
2646 parse_error(parse_script,
2647 SIEVE_DUPLICATE_TAG,
2648 ":handle");
2649 YYERROR; /* pe should call yyerror() */
2650 }
2651 if (!verify_utf8(parse_script, (yyvsp[0].sval))) {
2652 YYERROR; /* vu should call yyerror() */
2653 }
2654 (yyval.vtag)->handle = (yyvsp[0].sval);
2655 }
2656 #line 2657 "sieve/sieve.c" /* yacc.c:1652 */
2657 break;
2658
2659 case 70:
2660 #line 838 "sieve/sieve.y" /* yacc.c:1652 */
2661 {
2662 if ((yyval.vtag)->mime != -1) {
2663 parse_error(parse_script,
2664 SIEVE_DUPLICATE_TAG,
2665 ":mime");
2666 YYERROR; /* pe should call yyerror() */
2667 }
2668 (yyval.vtag)->mime = MIME;
2669 }
2670 #line 2671 "sieve/sieve.c" /* yacc.c:1652 */
2671 break;
2672
2673 case 71:
2674 #line 849 "sieve/sieve.y" /* yacc.c:1652 */
2675 { (yyval.sl) = (yyvsp[-1].sl); }
2676 #line 2677 "sieve/sieve.c" /* yacc.c:1652 */
2677 break;
2678
2679 case 72:
2680 #line 850 "sieve/sieve.y" /* yacc.c:1652 */
2681 {
2682 (yyval.sl) = strarray_new();
2683 strarray_appendm((yyval.sl), (yyvsp[0].sval));
2684 }
2685 #line 2686 "sieve/sieve.c" /* yacc.c:1652 */
2686 break;
2687
2688 case 73:
2689 #line 856 "sieve/sieve.y" /* yacc.c:1652 */
2690 {
2691 (yyval.sl) = strarray_new();
2692 strarray_appendm((yyval.sl), (yyvsp[0].sval));
2693 }
2694 #line 2695 "sieve/sieve.c" /* yacc.c:1652 */
2695 break;
2696
2697 case 74:
2698 #line 860 "sieve/sieve.y" /* yacc.c:1652 */
2699 {
2700 (yyval.sl) = (yyvsp[-2].sl);
2701 strarray_appendm((yyval.sl), (yyvsp[0].sval));
2702 }
2703 #line 2704 "sieve/sieve.c" /* yacc.c:1652 */
2704 break;
2705
2706 case 75:
2707 #line 866 "sieve/sieve.y" /* yacc.c:1652 */
2708 { (yyval.cl) = (yyvsp[-1].cl); }
2709 #line 2710 "sieve/sieve.c" /* yacc.c:1652 */
2710 break;
2711
2712 case 76:
2713 #line 867 "sieve/sieve.y" /* yacc.c:1652 */
2714 { (yyval.cl) = NULL; }
2715 #line 2716 "sieve/sieve.c" /* yacc.c:1652 */
2716 break;
2717
2718 case 77:
2719 #line 870 "sieve/sieve.y" /* yacc.c:1652 */
2720 { (yyval.test) = new_test(ANYOF); (yyval.test)->u.tl = (yyvsp[0].testl); }
2721 #line 2722 "sieve/sieve.c" /* yacc.c:1652 */
2722 break;
2723
2724 case 78:
2725 #line 871 "sieve/sieve.y" /* yacc.c:1652 */
2726 { (yyval.test) = new_test(ALLOF); (yyval.test)->u.tl = (yyvsp[0].testl); }
2727 #line 2728 "sieve/sieve.c" /* yacc.c:1652 */
2728 break;
2729
2730 case 79:
2731 #line 872 "sieve/sieve.y" /* yacc.c:1652 */
2732 { (yyval.test) = new_test(EXISTS); (yyval.test)->u.sl = (yyvsp[0].sl); }
2733 #line 2734 "sieve/sieve.c" /* yacc.c:1652 */
2734 break;
2735
2736 case 80:
2737 #line 873 "sieve/sieve.y" /* yacc.c:1652 */
2738 { (yyval.test) = new_test(SFALSE); }
2739 #line 2740 "sieve/sieve.c" /* yacc.c:1652 */
2740 break;
2741
2742 case 81:
2743 #line 874 "sieve/sieve.y" /* yacc.c:1652 */
2744 { (yyval.test) = new_test(STRUE); }
2745 #line 2746 "sieve/sieve.c" /* yacc.c:1652 */
2746 break;
2747
2748 case 82:
2749 #line 877 "sieve/sieve.y" /* yacc.c:1652 */
2750 {
2751 if (!verify_stringlist(parse_script,
2752 (yyvsp[-1].sl), verify_header)) {
2753 YYERROR; /* vh should call yyerror() */
2754 }
2755 (yyvsp[-2].ctag) = canon_comptags((yyvsp[-2].ctag));
2756
2757 if (!verify_patternlist(parse_script,
2758 (yyvsp[0].sl), (yyvsp[-2].ctag),
2759 verify_utf8)) {
2760 YYERROR; /* vp should call yyerror() */
2761 }
2762
2763 (yyval.test) = build_header(HEADER, (yyvsp[-2].ctag), (yyvsp[-1].sl), (yyvsp[0].sl));
2764 if ((yyval.test) == NULL) {
2765 parse_error(parse_script,
2766 SIEVE_BUILD_FAILURE,
2767 "header test");
2768 YYERROR; /* pe should call yyerror() */
2769 }
2770 }
2771 #line 2772 "sieve/sieve.c" /* yacc.c:1652 */
2772 break;
2773
2774 case 83:
2775 #line 900 "sieve/sieve.y" /* yacc.c:1652 */
2776 {
2777 if (!parse_script->support.variables) {
2778 parse_error(parse_script,
2779 SIEVE_MISSING_REQUIRE,
2780 "variables");
2781 YYERROR; /* pe should call yyerror() */
2782 }
2783 if (!verify_stringlist(parse_script,
2784 (yyvsp[-1].sl), verify_utf8)) {
2785 YYERROR; /* vu should call yyerror() */
2786 }
2787 (yyvsp[-2].ctag) = canon_comptags((yyvsp[-2].ctag));
2788
2789 if (!verify_patternlist(parse_script,
2790 (yyvsp[0].sl), (yyvsp[-2].ctag),
2791 verify_utf8)) {
2792 YYERROR; /* vp should call yyerror() */
2793 }
2794
2795 (yyval.test) = build_header(STRINGT, (yyvsp[-2].ctag), (yyvsp[-1].sl), (yyvsp[0].sl));
2796 if ((yyval.test) == NULL) {
2797 parse_error(parse_script,
2798 SIEVE_BUILD_FAILURE,
2799 "string test");
2800 YYERROR; /* pe should call yyerror() */
2801 }
2802 }
2803 #line 2804 "sieve/sieve.c" /* yacc.c:1652 */
2804 break;
2805
2806 case 84:
2807 #line 933 "sieve/sieve.y" /* yacc.c:1652 */
2808 {
2809 if (!parse_script->support.imap4flags) {
2810 parse_error(parse_script,
2811 SIEVE_MISSING_REQUIRE,
2812 "imap4flags");
2813 YYERROR; /* pe should call yyerror() */
2814 }
2815 if (!parse_script->support.variables) {
2816 parse_error(parse_script,
2817 SIEVE_MISSING_REQUIRE,
2818 "variables");
2819 YYERROR; /* pe should call yyerror() */
2820 }
2821 if (!verify_stringlist(parse_script, (yyvsp[-1].sl),
2822 verify_identifier)) {
2823 YYERROR; /* vi should call yyerror() */
2824 }
2825 (yyvsp[-2].ctag) = canon_comptags((yyvsp[-2].ctag));
2826
2827 if (!verify_patternlist(parse_script,
2828 (yyvsp[0].sl), (yyvsp[-2].ctag),
2829 verify_utf8)) {
2830 YYERROR; /* vp should call yyerror() */
2831 }
2832
2833 (yyval.test) = build_header(HASFLAG, (yyvsp[-2].ctag), (yyvsp[-1].sl), (yyvsp[0].sl));
2834 if ((yyval.test) == NULL) {
2835 parse_error(parse_script,
2836 SIEVE_BUILD_FAILURE,
2837 "hasflag test");
2838 YYERROR; /* pe should call yyerror() */
2839 }
2840 }
2841 #line 2842 "sieve/sieve.c" /* yacc.c:1652 */
2842 break;
2843
2844 case 85:
2845 #line 968 "sieve/sieve.y" /* yacc.c:1652 */
2846 {
2847 if (!parse_script->support.imap4flags) {
2848 parse_error(parse_script,
2849 SIEVE_MISSING_REQUIRE,
2850 "imap4flags");
2851 YYERROR; /* pe should call yyerror() */
2852 }
2853 (yyvsp[-1].ctag) = canon_comptags((yyvsp[-1].ctag));
2854
2855 if (!verify_patternlist(parse_script,
2856 (yyvsp[0].sl), (yyvsp[-1].ctag),
2857 verify_utf8)) {
2858 YYERROR; /* vp should call yyerror() */
2859 }
2860
2861 (yyval.test) = build_header(HASFLAG, (yyvsp[-1].ctag), NULL, (yyvsp[0].sl));
2862 if ((yyval.test) == NULL) {
2863 parse_error(parse_script,
2864 SIEVE_BUILD_FAILURE,
2865 "hasflag test");
2866 YYERROR; /* pe should call yyerror() */
2867 }
2868 }
2869 #line 2870 "sieve/sieve.c" /* yacc.c:1652 */
2870 break;
2871
2872 case 86:
2873 #line 993 "sieve/sieve.y" /* yacc.c:1652 */
2874 {
2875 if (!verify_stringlist(parse_script, (yyvsp[-1].sl),
2876 verify_addrheader)) {
2877 YYERROR; /* vah should call yyerror() */
2878 }
2879 (yyvsp[-2].aetag) = canon_aetags((yyvsp[-2].aetag));
2880
2881 if (!verify_patternlist(parse_script, (yyvsp[0].sl),
2882 &((yyvsp[-2].aetag)->comptags),
2883 NULL)) {
2884 YYERROR; /* vp should call yyerror() */
2885 }
2886
2887 (yyval.test) = build_address(ADDRESS, (yyvsp[-2].aetag), (yyvsp[-1].sl), (yyvsp[0].sl));
2888 if ((yyval.test) == NULL) {
2889 parse_error(parse_script,
2890 SIEVE_BUILD_FAILURE,
2891 "address test");
2892 YYERROR; /* pe should call yyerror() */
2893 }
2894 }
2895 #line 2896 "sieve/sieve.c" /* yacc.c:1652 */
2896 break;
2897
2898 case 87:
2899 #line 1016 "sieve/sieve.y" /* yacc.c:1652 */
2900 {
2901 if (!parse_script->support.envelope) {
2902 parse_error(parse_script,
2903 SIEVE_MISSING_REQUIRE,
2904 "envelope");
2905 YYERROR; /* pe should call yyerror() */
2906 }
2907 if (!verify_stringlist(parse_script, (yyvsp[-1].sl),
2908 verify_envelope)) {
2909 YYERROR;
2910 }
2911 (yyvsp[-2].aetag) = canon_aetags((yyvsp[-2].aetag));
2912
2913 if (!verify_patternlist(parse_script, (yyvsp[0].sl),
2914 &((yyvsp[-2].aetag)->comptags),
2915 NULL)) {
2916 YYERROR; /* vp should call yyerror() */
2917 }
2918
2919 (yyval.test) = build_address(ENVELOPE, (yyvsp[-2].aetag), (yyvsp[-1].sl), (yyvsp[0].sl));
2920 if ((yyval.test) == NULL) {
2921 parse_error(parse_script,
2922 SIEVE_BUILD_FAILURE,
2923 "envelope test");
2924 YYERROR; /* pe should call yyerror() */
2925 }
2926 }
2927 #line 2928 "sieve/sieve.c" /* yacc.c:1652 */
2928 break;
2929
2930 case 88:
2931 #line 1045 "sieve/sieve.y" /* yacc.c:1652 */
2932 {
2933 if (!parse_script->support.body) {
2934 parse_error(parse_script,
2935 SIEVE_MISSING_REQUIRE,
2936 "body");
2937 YYERROR; /* pe should call yyerror() */
2938 }
2939 (yyvsp[-1].btag) = canon_btags((yyvsp[-1].btag));
2940
2941 if (!verify_patternlist(parse_script, (yyvsp[0].sl),
2942 &((yyvsp[-1].btag)->comptags),
2943 verify_utf8)) {
2944 YYERROR; /* vp should call yyerror() */
2945 }
2946
2947 (yyval.test) = build_body(BODY, (yyvsp[-1].btag), (yyvsp[0].sl));
2948 if ((yyval.test) == NULL) {
2949 parse_error(parse_script,
2950 SIEVE_BUILD_FAILURE,
2951 "body test");
2952 YYERROR; /* pe should call yyerror() */
2953 }
2954 }
2955 #line 2956 "sieve/sieve.c" /* yacc.c:1652 */
2956 break;
2957
2958 case 89:
2959 #line 1069 "sieve/sieve.y" /* yacc.c:1652 */
2960 { (yyval.test) = new_test(NOT); (yyval.test)->u.t = (yyvsp[0].test); }
2961 #line 2962 "sieve/sieve.c" /* yacc.c:1652 */
2962 break;
2963
2964 case 90:
2965 #line 1070 "sieve/sieve.y" /* yacc.c:1652 */
2966 { (yyval.test) = new_test(SIZE); (yyval.test)->u.sz.t = (yyvsp[-1].nval);
2967 (yyval.test)->u.sz.n = (yyvsp[0].nval); }
2968 #line 2969 "sieve/sieve.c" /* yacc.c:1652 */
2969 break;
2970
2971 case 91:
2972 #line 1074 "sieve/sieve.y" /* yacc.c:1652 */
2973 {
2974 if (!parse_script->support.date) {
2975 parse_error(parse_script,
2976 SIEVE_MISSING_REQUIRE,
2977 "date");
2978 YYERROR; /* pe should call yyerror() */
2979 }
2980 if (!verify_header(parse_script, (yyvsp[-2].sval))) {
2981 YYERROR; /* vh should call yyerror() */
2982 }
2983 (yyvsp[-3].dttag) = canon_dttags((yyvsp[-3].dttag));
2984
2985 if (!verify_patternlist(parse_script, (yyvsp[0].sl),
2986 &((yyvsp[-3].dttag)->comptags),
2987 NULL)) {
2988 YYERROR; /* vp should call yyerror() */
2989 }
2990
2991 (yyval.test) = build_date(DATE, (yyvsp[-3].dttag), (yyvsp[-2].sval), (yyvsp[-1].nval), (yyvsp[0].sl));
2992 if ((yyval.test) == NULL) {
2993 parse_error(parse_script,
2994 SIEVE_BUILD_FAILURE,
2995 "date test");
2996 YYERROR; /* pe should call yyerror() */
2997 }
2998 }
2999 #line 3000 "sieve/sieve.c" /* yacc.c:1652 */
3000 break;
3001
3002 case 92:
3003 #line 1102 "sieve/sieve.y" /* yacc.c:1652 */
3004 {
3005 if (!parse_script->support.date) {
3006 parse_error(parse_script,
3007 SIEVE_MISSING_REQUIRE,
3008 "date");
3009 YYERROR; /* pe should call yyerror() */
3010 }
3011 (yyvsp[-2].dttag) = canon_dttags((yyvsp[-2].dttag));
3012
3013 if (!verify_patternlist(parse_script, (yyvsp[0].sl),
3014 &((yyvsp[-2].dttag)->comptags),
3015 NULL)) {
3016 YYERROR; /* vp should call yyerror() */
3017 }
3018
3019 (yyval.test) = build_date(CURRENTDATE,
3020 (yyvsp[-2].dttag), NULL, (yyvsp[-1].nval), (yyvsp[0].sl));
3021 if ((yyval.test) == NULL) {
3022 parse_error(parse_script,
3023 SIEVE_BUILD_FAILURE,
3024 "currentdate test");
3025 YYERROR; /* pe should call yyerror() */
3026 }
3027 }
3028 #line 3029 "sieve/sieve.c" /* yacc.c:1652 */
3029 break;
3030
3031 case 93:
3032 #line 1128 "sieve/sieve.y" /* yacc.c:1652 */
3033 {
3034 if (!parse_script->support.mailbox) {
3035 parse_error(parse_script,
3036 SIEVE_MISSING_REQUIRE,
3037 "mailbox");
3038 YYERROR; /* pe should call yyerror() */
3039 }
3040
3041 (yyval.test) = build_mailboxtest(MAILBOXEXISTS, NULL,
3042 NULL, NULL, (yyvsp[0].sl));
3043 if ((yyval.test) == NULL) {
3044 parse_error(parse_script,
3045 SIEVE_BUILD_FAILURE,
3046 "mailboxexists test");
3047 YYERROR; /* pe should call yyerror() */
3048 }
3049 }
3050 #line 3051 "sieve/sieve.c" /* yacc.c:1652 */
3051 break;
3052
3053 case 94:
3054 #line 1147 "sieve/sieve.y" /* yacc.c:1652 */
3055 {
3056 if (!parse_script->support.mboxmetadata) {
3057 parse_error(parse_script,
3058 SIEVE_MISSING_REQUIRE,
3059 "mboxmetadata");
3060 YYERROR; /* pe should call yyerror() */
3061 }
3062
3063 (yyval.test) = build_mailboxtest(METADATA,
3064 (yyvsp[-3].ctag), (yyvsp[-2].sval), (yyvsp[-1].sval), (yyvsp[0].sl));
3065 if ((yyval.test) == NULL) {
3066 parse_error(parse_script,
3067 SIEVE_BUILD_FAILURE,
3068 "metadata test");
3069 YYERROR; /* pe should call yyerror() */
3070 }
3071 }
3072 #line 3073 "sieve/sieve.c" /* yacc.c:1652 */
3073 break;
3074
3075 case 95:
3076 #line 1166 "sieve/sieve.y" /* yacc.c:1652 */
3077 {
3078 if (!parse_script->support.mboxmetadata) {
3079 parse_error(parse_script,
3080 SIEVE_MISSING_REQUIRE,
3081 "mboxmetadata");
3082 YYERROR; /* pe should call yyerror() */
3083 }
3084
3085 (yyval.test) = build_mailboxtest(METADATAEXISTS,
3086 NULL, (yyvsp[-1].sval), NULL, (yyvsp[0].sl));
3087 if ((yyval.test) == NULL) {
3088 parse_error(parse_script,
3089 SIEVE_BUILD_FAILURE,
3090 "metadataexists test");
3091 YYERROR; /* pe should call yyerror() */
3092 }
3093 }
3094 #line 3095 "sieve/sieve.c" /* yacc.c:1652 */
3095 break;
3096
3097 case 96:
3098 #line 1185 "sieve/sieve.y" /* yacc.c:1652 */
3099 {
3100 if (!parse_script->support.servermetadata) {
3101 parse_error(parse_script,
3102 SIEVE_MISSING_REQUIRE,
3103 "servermetadata");
3104 YYERROR; /* pe should call yyerror() */
3105 }
3106
3107 (yyval.test) = build_mailboxtest(SERVERMETADATA,
3108 (yyvsp[-2].ctag), NULL, (yyvsp[-1].sval), (yyvsp[0].sl));
3109 if ((yyval.test) == NULL) {
3110 parse_error(parse_script,
3111 SIEVE_BUILD_FAILURE,
3112 "servermetadata test");
3113 YYERROR; /* pe should call yyerror() */
3114 }
3115 }
3116 #line 3117 "sieve/sieve.c" /* yacc.c:1652 */
3117 break;
3118
3119 case 97:
3120 #line 1204 "sieve/sieve.y" /* yacc.c:1652 */
3121 {
3122 if (!parse_script->support.servermetadata) {
3123 parse_error(parse_script,
3124 SIEVE_MISSING_REQUIRE,
3125 "servermetadata");
3126 YYERROR; /* pe should call yyerror() */
3127 }
3128
3129 (yyval.test) = build_mailboxtest(SERVERMETADATAEXISTS,
3130 NULL, NULL, NULL, (yyvsp[0].sl));
3131 if ((yyval.test) == NULL) {
3132 parse_error(parse_script,
3133 SIEVE_BUILD_FAILURE,
3134 "servermetadataexists test");
3135 YYERROR; /* pe should call yyerror() */
3136 }
3137 }
3138 #line 3139 "sieve/sieve.c" /* yacc.c:1652 */
3139 break;
3140
3141 case 98:
3142 #line 1222 "sieve/sieve.y" /* yacc.c:1652 */
3143 { (yyval.test) = NULL; }
3144 #line 3145 "sieve/sieve.c" /* yacc.c:1652 */
3145 break;
3146
3147 case 99:
3148 #line 1225 "sieve/sieve.y" /* yacc.c:1652 */
3149 { (yyval.aetag) = new_aetags(); }
3150 #line 3151 "sieve/sieve.c" /* yacc.c:1652 */
3151 break;
3152
3153 case 100:
3154 #line 1227 "sieve/sieve.y" /* yacc.c:1652 */
3155 {
3156 (yyval.aetag) = (yyvsp[-1].aetag);
3157 if ((yyval.aetag)->addrtag != -1) {
3158 parse_error(parse_script,
3159 SIEVE_DUPLICATE_TAG,
3160 "address-part");
3161 YYERROR; /* pe should call yyerror() */
3162 }
3163 else (yyval.aetag)->addrtag = (yyvsp[0].nval);
3164 }
3165 #line 3166 "sieve/sieve.c" /* yacc.c:1652 */
3166 break;
3167
3168 case 104:
3169 #line 1242 "sieve/sieve.y" /* yacc.c:1652 */
3170 { (yyval.aetag) = new_aetags(); }
3171 #line 3172 "sieve/sieve.c" /* yacc.c:1652 */
3172 break;
3173
3174 case 105:
3175 #line 1244 "sieve/sieve.y" /* yacc.c:1652 */
3176 {
3177 (yyval.aetag) = (yyvsp[-1].aetag);
3178 if ((yyval.aetag)->addrtag != -1) {
3179 parse_error(parse_script,
3180 SIEVE_DUPLICATE_TAG,
3181 "address-part");
3182 YYERROR; /* pe should call yyerror() */
3183 }
3184 else (yyval.aetag)->addrtag = (yyvsp[0].nval);
3185 }
3186 #line 3187 "sieve/sieve.c" /* yacc.c:1652 */
3187 break;
3188
3189 case 108:
3190 #line 1262 "sieve/sieve.y" /* yacc.c:1652 */
3191 {
3192 struct comptags *ctags = (yyvsp[-1].ctag);
3193 if (ctags->match != -1) {
3194 parse_error(parse_script,
3195 SIEVE_DUPLICATE_TAG,
3196 "match-type");
3197 YYERROR; /* pe should call yyerror() */
3198 }
3199 else ctags->match = (yyvsp[0].nval);
3200 }
3201 #line 3202 "sieve/sieve.c" /* yacc.c:1652 */
3202 break;
3203
3204 case 109:
3205 #line 1273 "sieve/sieve.y" /* yacc.c:1652 */
3206 {
3207 struct comptags *ctags = (yyvsp[-2].ctag);
3208 if (ctags->match != -1) {
3209 parse_error(parse_script,
3210 SIEVE_DUPLICATE_TAG,
3211 "match-type");
3212 YYERROR; /* pe should call yyerror() */
3213 }
3214 else {
3215 ctags->match = (yyvsp[-1].nval);
3216 ctags->relation =
3217 verify_relat(parse_script, (yyvsp[0].sval));
3218 if (ctags->relation == -1) {
3219 YYERROR; /*vr called yyerror()*/
3220 }
3221 }
3222 }
3223 #line 3224 "sieve/sieve.c" /* yacc.c:1652 */
3224 break;
3225
3226 case 110:
3227 #line 1296 "sieve/sieve.y" /* yacc.c:1652 */
3228 {
3229 struct comptags *ctags = (yyvsp[-2].ctag);
3230 if (ctags->comparator != NULL) {
3231 parse_error(parse_script,
3232 SIEVE_DUPLICATE_TAG,
3233 ":comparator");
3234 YYERROR; /* pe should call yyerror() */
3235 }
3236 else if (!strcmp((yyvsp[0].sval), "i;ascii-numeric") &&
3237 !parse_script->support.i_ascii_numeric) {
3238 parse_error(parse_script,
3239 SIEVE_MISSING_REQUIRE,
3240 "comparator-i;ascii-numeric");
3241 YYERROR; /* pe should call yyerror() */
3242 }
3243 else ctags->comparator = (yyvsp[0].sval);
3244 }
3245 #line 3246 "sieve/sieve.c" /* yacc.c:1652 */
3246 break;
3247
3248 case 111:
3249 #line 1322 "sieve/sieve.y" /* yacc.c:1652 */
3250 {
3251 struct comptags *ctags = (yyvsp[-2].ctag);
3252 if (!parse_script->support.index) {
3253 parse_error(parse_script,
3254 SIEVE_MISSING_REQUIRE,
3255 "index");
3256 YYERROR; /* pe should call yyerror() */
3257 }
3258 if (ctags->index != 0) {
3259 parse_error(parse_script,
3260 SIEVE_DUPLICATE_TAG,
3261 ":index");
3262 YYERROR; /* pe should call yyerror() */
3263 }
3264 if ((yyvsp[0].nval) <= 0) {
3265 parse_error(parse_script,
3266 SIEVE_INVALID_VALUE,
3267 ":index");
3268 YYERROR; /* pe should call yyerror() */
3269 }
3270 else ctags->index = (yyvsp[0].nval);
3271 }
3272 #line 3273 "sieve/sieve.c" /* yacc.c:1652 */
3273 break;
3274
3275 case 112:
3276 #line 1345 "sieve/sieve.y" /* yacc.c:1652 */
3277 { struct comptags *ctags = (yyvsp[-1].ctag);
3278 if (!parse_script->support.index) {
3279 parse_error(parse_script,
3280 SIEVE_MISSING_REQUIRE,
3281 "index");
3282 YYERROR; /* pe should call yyerror() */
3283 }
3284 if (ctags->index == 0) {
3285 parse_error(parse_script,
3286 SIEVE_MISSING_TAG,
3287 ":index");
3288 YYERROR; /* pe should call yyerror() */
3289 }
3290 else if (ctags->index < 0) {
3291 parse_error(parse_script,
3292 SIEVE_DUPLICATE_TAG,
3293 ":last");
3294 YYERROR; /* pe should call yyerror() */
3295 }
3296 else ctags->index *= -1;
3297 }
3298 #line 3299 "sieve/sieve.c" /* yacc.c:1652 */
3299 break;
3300
3301 case 113:
3302 #line 1368 "sieve/sieve.y" /* yacc.c:1652 */
3303 { (yyval.ctag) = new_comptags(); }
3304 #line 3305 "sieve/sieve.c" /* yacc.c:1652 */
3305 break;
3306
3307 case 117:
3308 #line 1374 "sieve/sieve.y" /* yacc.c:1652 */
3309 { (yyval.ctag) = new_comptags(); }
3310 #line 3311 "sieve/sieve.c" /* yacc.c:1652 */
3311 break;
3312
3313 case 120:
3314 #line 1379 "sieve/sieve.y" /* yacc.c:1652 */
3315 { (yyval.ctag) = new_comptags(); }
3316 #line 3317 "sieve/sieve.c" /* yacc.c:1652 */
3317 break;
3318
3319 case 123:
3320 #line 1384 "sieve/sieve.y" /* yacc.c:1652 */
3321 { (yyval.ctag) = new_comptags(); }
3322 #line 3323 "sieve/sieve.c" /* yacc.c:1652 */
3323 break;
3324
3325 case 126:
3326 #line 1389 "sieve/sieve.y" /* yacc.c:1652 */
3327 { (yyval.btag) = new_btags(); }
3328 #line 3329 "sieve/sieve.c" /* yacc.c:1652 */
3329 break;
3330
3331 case 127:
3332 #line 1391 "sieve/sieve.y" /* yacc.c:1652 */
3333 {
3334 (yyval.btag) = (yyvsp[-1].btag);
3335 if ((yyval.btag)->transform != -1) {
3336 parse_error(parse_script,
3337 SIEVE_DUPLICATE_TAG,
3338 "transform");
3339 YYERROR; /* pe should call yyerror() */
3340 }
3341 else (yyval.btag)->transform = RAW;
3342 }
3343 #line 3344 "sieve/sieve.c" /* yacc.c:1652 */
3344 break;
3345
3346 case 128:
3347 #line 1402 "sieve/sieve.y" /* yacc.c:1652 */
3348 {
3349 (yyval.btag) = (yyvsp[-1].btag);
3350 if ((yyval.btag)->transform != -1) {
3351 parse_error(parse_script,
3352 SIEVE_DUPLICATE_TAG,
3353 "transform");
3354 YYERROR; /* pe should call yyerror() */
3355 }
3356 else (yyval.btag)->transform = TEXT;
3357 }
3358 #line 3359 "sieve/sieve.c" /* yacc.c:1652 */
3359 break;
3360
3361 case 129:
3362 #line 1413 "sieve/sieve.y" /* yacc.c:1652 */
3363 {
3364 (yyval.btag) = (yyvsp[-2].btag);
3365 if ((yyval.btag)->transform != -1) {
3366 parse_error(parse_script,
3367 SIEVE_DUPLICATE_TAG,
3368 "transform");
3369 YYERROR; /* pe should call yyerror() */
3370 }
3371 else {
3372 (yyval.btag)->transform = CONTENT;
3373 (yyval.btag)->content_types = (yyvsp[0].sl);
3374 }
3375 }
3376 #line 3377 "sieve/sieve.c" /* yacc.c:1652 */
3377 break;
3378
3379 case 132:
3380 #line 1430 "sieve/sieve.y" /* yacc.c:1652 */
3381 { (yyval.dttag) = new_dttags(); }
3382 #line 3383 "sieve/sieve.c" /* yacc.c:1652 */
3383 break;
3384
3385 case 133:
3386 #line 1432 "sieve/sieve.y" /* yacc.c:1652 */
3387 {
3388 (yyval.dttag) = (yyvsp[-1].dttag);
3389 if ((yyval.dttag)->zonetag != -1) {
3390 parse_error(parse_script,
3391 SIEVE_DUPLICATE_TAG,
3392 ":originalzone");
3393 YYERROR; /* pe should call yyerror() */
3394 }
3395 else (yyval.dttag)->zonetag = ORIGINALZONE;
3396 }
3397 #line 3398 "sieve/sieve.c" /* yacc.c:1652 */
3398 break;
3399
3400 case 138:
3401 #line 1448 "sieve/sieve.y" /* yacc.c:1652 */
3402 { (yyval.dttag) = new_dttags(); }
3403 #line 3404 "sieve/sieve.c" /* yacc.c:1652 */
3404 break;
3405
3406 case 142:
3407 #line 1458 "sieve/sieve.y" /* yacc.c:1652 */
3408 {
3409 struct dttags *dttags = (yyvsp[-2].dttag);
3410 if (dttags->zonetag != -1) {
3411 parse_error(parse_script,
3412 SIEVE_DUPLICATE_TAG,
3413 ":zone");
3414 YYERROR; /* pe should call yyerror() */
3415 }
3416 else if (verify_zone(parse_script, (yyvsp[0].sval)) == -1) {
3417 YYERROR; /*vr called yyerror()*/
3418 }
3419 else {
3420 dttags->zone = (yyvsp[0].sval);
3421 dttags->zonetag = ZONE;
3422 }
3423 }
3424 #line 3425 "sieve/sieve.c" /* yacc.c:1652 */
3425 break;
3426
3427 case 143:
3428 #line 1477 "sieve/sieve.y" /* yacc.c:1652 */
3429 {
3430 (yyval.nval) = verify_date_part(parse_script, (yyvsp[0].sval));
3431 if ((yyval.nval) == -1) {
3432 YYERROR; /* vdp called yyerror() */
3433 }
3434 }
3435 #line 3436 "sieve/sieve.c" /* yacc.c:1652 */
3436 break;
3437
3438 case 144:
3439 #line 1485 "sieve/sieve.y" /* yacc.c:1652 */
3440 { (yyval.nval) = ALL; }
3441 #line 3442 "sieve/sieve.c" /* yacc.c:1652 */
3442 break;
3443
3444 case 145:
3445 #line 1486 "sieve/sieve.y" /* yacc.c:1652 */
3446 { (yyval.nval) = LOCALPART; }
3447 #line 3448 "sieve/sieve.c" /* yacc.c:1652 */
3448 break;
3449
3450 case 146:
3451 #line 1487 "sieve/sieve.y" /* yacc.c:1652 */
3452 { (yyval.nval) = DOMAIN; }
3453 #line 3454 "sieve/sieve.c" /* yacc.c:1652 */
3454 break;
3455
3456 case 147:
3457 #line 1489 "sieve/sieve.y" /* yacc.c:1652 */
3458 {
3459 if (!parse_script->support.subaddress) {
3460 parse_error(parse_script,
3461 SIEVE_MISSING_REQUIRE,
3462 "subaddress");
3463 YYERROR; /* pe should call yyerror() */
3464 }
3465 (yyval.nval) = USER;
3466 }
3467 #line 3468 "sieve/sieve.c" /* yacc.c:1652 */
3468 break;
3469
3470 case 148:
3471 #line 1499 "sieve/sieve.y" /* yacc.c:1652 */
3472 {
3473 if (!parse_script->support.subaddress) {
3474 parse_error(parse_script,
3475 SIEVE_MISSING_REQUIRE,
3476 "subaddress");
3477 YYERROR; /* pe should call yyerror() */
3478 }
3479 (yyval.nval) = DETAIL;
3480 }
3481 #line 3482 "sieve/sieve.c" /* yacc.c:1652 */
3482 break;
3483
3484 case 149:
3485 #line 1509 "sieve/sieve.y" /* yacc.c:1652 */
3486 { (yyval.nval) = IS; }
3487 #line 3488 "sieve/sieve.c" /* yacc.c:1652 */
3488 break;
3489
3490 case 150:
3491 #line 1510 "sieve/sieve.y" /* yacc.c:1652 */
3492 { (yyval.nval) = CONTAINS; }
3493 #line 3494 "sieve/sieve.c" /* yacc.c:1652 */
3494 break;
3495
3496 case 151:
3497 #line 1511 "sieve/sieve.y" /* yacc.c:1652 */
3498 { (yyval.nval) = MATCHES; }
3499 #line 3500 "sieve/sieve.c" /* yacc.c:1652 */
3500 break;
3501
3502 case 152:
3503 #line 1513 "sieve/sieve.y" /* yacc.c:1652 */
3504 {
3505 if (!parse_script->support.regex) {
3506 parse_error(parse_script,
3507 SIEVE_MISSING_REQUIRE,
3508 "regex");
3509 YYERROR; /* pe should call yyerror() */
3510 }
3511 (yyval.nval) = REGEX;
3512 }
3513 #line 3514 "sieve/sieve.c" /* yacc.c:1652 */
3514 break;
3515
3516 case 153:
3517 #line 1525 "sieve/sieve.y" /* yacc.c:1652 */
3518 {
3519 if (!parse_script->support.relational) {
3520 parse_error(parse_script,
3521 SIEVE_MISSING_REQUIRE,
3522 "relational");
3523 YYERROR; /* pe should call yyerror() */
3524 }
3525 (yyval.nval) = COUNT;
3526 }
3527 #line 3528 "sieve/sieve.c" /* yacc.c:1652 */
3528 break;
3529
3530 case 154:
3531 #line 1535 "sieve/sieve.y" /* yacc.c:1652 */
3532 {
3533 if (!parse_script->support.relational) {
3534 parse_error(parse_script,
3535 SIEVE_MISSING_REQUIRE,
3536 "relational");
3537 YYERROR; /* pe should call yyerror() */
3538 }
3539 (yyval.nval) = VALUE;
3540 }
3541 #line 3542 "sieve/sieve.c" /* yacc.c:1652 */
3542 break;
3543
3544 case 155:
3545 #line 1547 "sieve/sieve.y" /* yacc.c:1652 */
3546 { (yyval.nval) = OVER; }
3547 #line 3548 "sieve/sieve.c" /* yacc.c:1652 */
3548 break;
3549
3550 case 156:
3551 #line 1548 "sieve/sieve.y" /* yacc.c:1652 */
3552 { (yyval.nval) = UNDER; }
3553 #line 3554 "sieve/sieve.c" /* yacc.c:1652 */
3554 break;
3555
3556 case 157:
3557 #line 1552 "sieve/sieve.y" /* yacc.c:1652 */
3558 {
3559 if (!parse_script->support.copy) {
3560 parse_error(parse_script,
3561 SIEVE_MISSING_REQUIRE,
3562 "copy");
3563 YYERROR; /* pe should call yyerror() */
3564 }
3565 (yyval.nval) = 1;
3566 }
3567 #line 3568 "sieve/sieve.c" /* yacc.c:1652 */
3568 break;
3569
3570 case 158:
3571 #line 1564 "sieve/sieve.y" /* yacc.c:1652 */
3572 {
3573 if (!parse_script->support.mailbox) {
3574 parse_error(parse_script,
3575 SIEVE_MISSING_REQUIRE,
3576 "mailbox");
3577 YYERROR; /* pe should call yyerror() */
3578 }
3579 (yyval.nval) = 1;
3580 }
3581 #line 3582 "sieve/sieve.c" /* yacc.c:1652 */
3582 break;
3583
3584 case 159:
3585 #line 1575 "sieve/sieve.y" /* yacc.c:1652 */
3586 { (yyval.ftag) = new_ftags(); }
3587 #line 3588 "sieve/sieve.c" /* yacc.c:1652 */
3588 break;
3589
3590 case 160:
3591 #line 1577 "sieve/sieve.y" /* yacc.c:1652 */
3592 {
3593 (yyval.ftag) = (yyvsp[-1].ftag);
3594 if ((yyval.ftag)->copy) {
3595 parse_error(parse_script,
3596 SIEVE_DUPLICATE_TAG,
3597 ":copy");
3598 YYERROR; /* pe should call yyerror() */
3599 }
3600 else (yyval.ftag)->copy = (yyvsp[0].nval);
3601 }
3602 #line 3603 "sieve/sieve.c" /* yacc.c:1652 */
3603 break;
3604
3605 case 161:
3606 #line 1588 "sieve/sieve.y" /* yacc.c:1652 */
3607 {
3608 (yyval.ftag) = (yyvsp[-1].ftag);
3609 if ((yyval.ftag)->create) {
3610 parse_error(parse_script,
3611 SIEVE_DUPLICATE_TAG,
3612 ":create");
3613 YYERROR; /* pe should call yyerror() */
3614 }
3615 else (yyval.ftag)->create = (yyvsp[0].nval);
3616 }
3617 #line 3618 "sieve/sieve.c" /* yacc.c:1652 */
3618 break;
3619
3620 case 162:
3621 #line 1599 "sieve/sieve.y" /* yacc.c:1652 */
3622 {
3623 if (!parse_script->support.imap4flags) {
3624 parse_error(parse_script,
3625 SIEVE_MISSING_REQUIRE,
3626 "imap4flags");
3627 YYERROR; /* pe should call yyerror() */
3628 }
3629 if ((yyval.ftag)->flags != NULL) {
3630 parse_error(parse_script,
3631 SIEVE_DUPLICATE_TAG,
3632 ":flags");
3633 YYERROR; /* pe should call yyerror() */
3634 }
3635
3636 (yyval.ftag) = (yyvsp[-2].ftag);
3637 if (!parse_script->support.variables) {
3638 verify_flaglist((yyvsp[0].sl));
3639 }
3640 if (!(yyvsp[0].sl)->count) strarray_add((yyvsp[0].sl), "");
3641 (yyval.ftag)->flags = (yyvsp[0].sl);
3642 }
3643 #line 3644 "sieve/sieve.c" /* yacc.c:1652 */
3644 break;
3645
3646 case 163:
3647 #line 1622 "sieve/sieve.y" /* yacc.c:1652 */
3648 { (yyval.nval) = 0; }
3649 #line 3650 "sieve/sieve.c" /* yacc.c:1652 */
3650 break;
3651
3652 case 164:
3653 #line 1624 "sieve/sieve.y" /* yacc.c:1652 */
3654 {
3655 (yyval.nval) = (yyvsp[-1].nval);
3656 if ((yyval.nval)) {
3657 parse_error(parse_script,
3658 SIEVE_DUPLICATE_TAG,
3659 ":copy");
3660 YYERROR; /* pe should call yyerror() */
3661 }
3662 else (yyval.nval) = (yyvsp[0].nval);
3663 }
3664 #line 3665 "sieve/sieve.c" /* yacc.c:1652 */
3665 break;
3666
3667 case 165:
3668 #line 1636 "sieve/sieve.y" /* yacc.c:1652 */
3669 { (yyval.testl) = (yyvsp[-1].testl); }
3670 #line 3671 "sieve/sieve.c" /* yacc.c:1652 */
3671 break;
3672
3673 case 166:
3674 #line 1639 "sieve/sieve.y" /* yacc.c:1652 */
3675 { (yyval.testl) = new_testlist((yyvsp[0].test), NULL); }
3676 #line 3677 "sieve/sieve.c" /* yacc.c:1652 */
3677 break;
3678
3679 case 167:
3680 #line 1640 "sieve/sieve.y" /* yacc.c:1652 */
3681 { (yyval.testl) = new_testlist((yyvsp[-2].test), (yyvsp[0].testl)); }
3682 #line 3683 "sieve/sieve.c" /* yacc.c:1652 */
3683 break;
3684
3685
3686 #line 3687 "sieve/sieve.c" /* yacc.c:1652 */
3687 default: break;
3688 }
3689 /* User semantic actions sometimes alter yychar, and that requires
3690 that yytoken be updated with the new translation. We take the
3691 approach of translating immediately before every use of yytoken.
3692 One alternative is translating here after every semantic action,
3693 but that translation would be missed if the semantic action invokes
3694 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
3695 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
3696 incorrect destructor might then be invoked immediately. In the
3697 case of YYERROR or YYBACKUP, subsequent parser actions might lead
3698 to an incorrect destructor call or verbose syntax error message
3699 before the lookahead is translated. */
3700 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
3701
3702 YYPOPSTACK (yylen);
3703 yylen = 0;
3704 YY_STACK_PRINT (yyss, yyssp);
3705
3706 *++yyvsp = yyval;
3707
3708 /* Now 'shift' the result of the reduction. Determine what state
3709 that goes to, based on the state we popped back to and the rule
3710 number reduced by. */
3711 {
3712 const int yylhs = yyr1[yyn] - YYNTOKENS;
3713 const int yyi = yypgoto[yylhs] + *yyssp;
3714 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
3715 ? yytable[yyi]
3716 : yydefgoto[yylhs]);
3717 }
3718
3719 goto yynewstate;
3720
3721
3722 /*--------------------------------------.
3723 | yyerrlab -- here on detecting error. |
3724 `--------------------------------------*/
3725 yyerrlab:
3726 /* Make sure we have latest lookahead translation. See comments at
3727 user semantic actions for why this is necessary. */
3728 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
3729
3730 /* If not already recovering from an error, report this error. */
3731 if (!yyerrstatus)
3732 {
3733 ++yynerrs;
3734 #if ! YYERROR_VERBOSE
3735 yyerror (parse_script, YY_("syntax error"));
3736 #else
3737 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
3738 yyssp, yytoken)
3739 {
3740 char const *yymsgp = YY_("syntax error");
3741 int yysyntax_error_status;
3742 yysyntax_error_status = YYSYNTAX_ERROR;
3743 if (yysyntax_error_status == 0)
3744 yymsgp = yymsg;
3745 else if (yysyntax_error_status == 1)
3746 {
3747 if (yymsg != yymsgbuf)
3748 YYSTACK_FREE (yymsg);
3749 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
3750 if (!yymsg)
3751 {
3752 yymsg = yymsgbuf;
3753 yymsg_alloc = sizeof yymsgbuf;
3754 yysyntax_error_status = 2;
3755 }
3756 else
3757 {
3758 yysyntax_error_status = YYSYNTAX_ERROR;
3759 yymsgp = yymsg;
3760 }
3761 }
3762 yyerror (parse_script, yymsgp);
3763 if (yysyntax_error_status == 2)
3764 goto yyexhaustedlab;
3765 }
3766 # undef YYSYNTAX_ERROR
3767 #endif
3768 }
3769
3770
3771
3772 if (yyerrstatus == 3)
3773 {
3774 /* If just tried and failed to reuse lookahead token after an
3775 error, discard it. */
3776
3777 if (yychar <= YYEOF)
3778 {
3779 /* Return failure if at end of input. */
3780 if (yychar == YYEOF)
3781 YYABORT;
3782 }
3783 else
3784 {
3785 yydestruct ("Error: discarding",
3786 yytoken, &yylval, parse_script);
3787 yychar = YYEMPTY;
3788 }
3789 }
3790
3791 /* Else will try to reuse lookahead token after shifting the error
3792 token. */
3793 goto yyerrlab1;
3794
3795
3796 /*---------------------------------------------------.
3797 | yyerrorlab -- error raised explicitly by YYERROR. |
3798 `---------------------------------------------------*/
3799 yyerrorlab:
3800 /* Pacify compilers when the user code never invokes YYERROR and the
3801 label yyerrorlab therefore never appears in user code. */
3802 if (0)
3803 YYERROR;
3804
3805 /* Do not reclaim the symbols of the rule whose action triggered
3806 this YYERROR. */
3807 YYPOPSTACK (yylen);
3808 yylen = 0;
3809 YY_STACK_PRINT (yyss, yyssp);
3810 yystate = *yyssp;
3811 goto yyerrlab1;
3812
3813
3814 /*-------------------------------------------------------------.
3815 | yyerrlab1 -- common code for both syntax error and YYERROR. |
3816 `-------------------------------------------------------------*/
3817 yyerrlab1:
3818 yyerrstatus = 3; /* Each real token shifted decrements this. */
3819
3820 for (;;)
3821 {
3822 yyn = yypact[yystate];
3823 if (!yypact_value_is_default (yyn))
3824 {
3825 yyn += YYTERROR;
3826 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
3827 {
3828 yyn = yytable[yyn];
3829 if (0 < yyn)
3830 break;
3831 }
3832 }
3833
3834 /* Pop the current state because it cannot handle the error token. */
3835 if (yyssp == yyss)
3836 YYABORT;
3837
3838
3839 yydestruct ("Error: popping",
3840 yystos[yystate], yyvsp, parse_script);
3841 YYPOPSTACK (1);
3842 yystate = *yyssp;
3843 YY_STACK_PRINT (yyss, yyssp);
3844 }
3845
3846 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
3847 *++yyvsp = yylval;
3848 YY_IGNORE_MAYBE_UNINITIALIZED_END
3849
3850
3851 /* Shift the error token. */
3852 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
3853
3854 yystate = yyn;
3855 goto yynewstate;
3856
3857
3858 /*-------------------------------------.
3859 | yyacceptlab -- YYACCEPT comes here. |
3860 `-------------------------------------*/
3861 yyacceptlab:
3862 yyresult = 0;
3863 goto yyreturn;
3864
3865
3866 /*-----------------------------------.
3867 | yyabortlab -- YYABORT comes here. |
3868 `-----------------------------------*/
3869 yyabortlab:
3870 yyresult = 1;
3871 goto yyreturn;
3872
3873
3874 #if !defined yyoverflow || YYERROR_VERBOSE
3875 /*-------------------------------------------------.
3876 | yyexhaustedlab -- memory exhaustion comes here. |
3877 `-------------------------------------------------*/
3878 yyexhaustedlab:
3879 yyerror (parse_script, YY_("memory exhausted"));
3880 yyresult = 2;
3881 /* Fall through. */
3882 #endif
3883
3884
3885 /*-----------------------------------------------------.
3886 | yyreturn -- parsing is finished, return the result. |
3887 `-----------------------------------------------------*/
3888 yyreturn:
3889 if (yychar != YYEMPTY)
3890 {
3891 /* Make sure we have latest lookahead translation. See comments at
3892 user semantic actions for why this is necessary. */
3893 yytoken = YYTRANSLATE (yychar);
3894 yydestruct ("Cleanup: discarding lookahead",
3895 yytoken, &yylval, parse_script);
3896 }
3897 /* Do not reclaim the symbols of the rule whose action triggered
3898 this YYABORT or YYACCEPT. */
3899 YYPOPSTACK (yylen);
3900 YY_STACK_PRINT (yyss, yyssp);
3901 while (yyssp != yyss)
3902 {
3903 yydestruct ("Cleanup: popping",
3904 yystos[*yyssp], yyvsp, parse_script);
3905 YYPOPSTACK (1);
3906 }
3907 #ifndef yyoverflow
3908 if (yyss != yyssa)
3909 YYSTACK_FREE (yyss);
3910 #endif
3911 #if YYERROR_VERBOSE
3912 if (yymsg != yymsgbuf)
3913 YYSTACK_FREE (yymsg);
3914 #endif
3915 return yyresult;
3916 }
3917 #line 1643 "sieve/sieve.y" /* yacc.c:1918 */
3918
3919
3920
3921 /*
3922 * Actions
3923 */
3924
yyerror(sieve_script_t * parse_script,const char * msg)3925 void yyerror(sieve_script_t *parse_script, const char *msg)
3926 {
3927 parse_script->err++;
3928 if (parse_script->interp.err) {
3929 parse_script->interp.err(sievelineno, msg,
3930 parse_script->interp.interp_context,
3931 parse_script->script_context);
3932 }
3933 }
3934
parse_error(sieve_script_t * parse_script,int err,...)3935 static void parse_error(sieve_script_t *parse_script, int err, ...)
3936 {
3937 va_list args;
3938
3939 va_start(args, err);
3940 vsnprintf(parse_script->sieveerr, ERR_BUF_SIZE, error_message(err), args);
3941 yyerror(parse_script, parse_script->sieveerr);
3942 va_end(args);
3943 }
3944
check_reqs(sieve_script_t * parse_script,strarray_t * sa)3945 static char *check_reqs(sieve_script_t *parse_script, strarray_t *sa)
3946 {
3947 char *s;
3948 struct buf errs = BUF_INITIALIZER;
3949 char *res;
3950
3951 while ((s = strarray_shift(sa))) {
3952 if (!script_require(parse_script, s)) {
3953 if (!errs.len)
3954 buf_printf(&errs,
3955 "Unsupported feature(s) in \"require\": \"%s\"", s);
3956 else buf_printf(&errs, ", \"%s\"", s);
3957 }
3958 free(s);
3959 }
3960 strarray_free(sa);
3961
3962 res = buf_release(&errs);
3963 if (!res[0]) {
3964 free(res);
3965 return NULL;
3966 }
3967
3968 return res;
3969 }
3970
build_address(int t,struct aetags * ae,strarray_t * sl,strarray_t * pl)3971 static test_t *build_address(int t, struct aetags *ae,
3972 strarray_t *sl, strarray_t *pl)
3973 {
3974 test_t *ret = new_test(t); /* can be either ADDRESS or ENVELOPE */
3975
3976 assert((t == ADDRESS) || (t == ENVELOPE));
3977
3978 if (ret) {
3979 ret->u.ae.comptag = ae->comptags.match;
3980 ret->u.ae.relation=ae->comptags.relation;
3981 ret->u.ae.comparator=xstrdup(ae->comptags.comparator);
3982 ret->u.ae.index = ae->comptags.index;
3983 ret->u.ae.sl = sl;
3984 ret->u.ae.pl = pl;
3985 ret->u.ae.addrpart = ae->addrtag;
3986 free_aetags(ae);
3987
3988 }
3989 return ret;
3990 }
3991
build_header(int t,struct comptags * c,strarray_t * sl,strarray_t * pl)3992 static test_t *build_header(int t, struct comptags *c,
3993 strarray_t *sl, strarray_t *pl)
3994 {
3995 test_t *ret = new_test(t); /* can be HEADER or HASFLAG or STRINGT */
3996
3997 assert((t == HEADER) || (t == HASFLAG) || (t == STRINGT));
3998
3999 if (ret) {
4000 ret->u.h.comptag = c->match;
4001 ret->u.h.relation = c->relation;
4002 ret->u.h.comparator = xstrdup(c->comparator);
4003 ret->u.h.index = c->index;
4004 ret->u.h.sl = sl;
4005 ret->u.h.pl = pl;
4006 free_comptags(c, 1);
4007 }
4008 return ret;
4009 }
4010
build_body(int t,struct btags * b,strarray_t * pl)4011 static test_t *build_body(int t, struct btags *b, strarray_t *pl)
4012 {
4013 test_t *ret = new_test(t); /* can be BODY */
4014
4015 assert(t == BODY);
4016
4017 if (ret) {
4018 ret->u.b.comptag = b->comptags.match;
4019 ret->u.b.relation = b->comptags.relation;
4020 ret->u.b.comparator = xstrdup(b->comptags.comparator);
4021 ret->u.b.transform = b->transform;
4022 ret->u.b.offset = b->offset;
4023 ret->u.b.content_types = b->content_types; b->content_types = NULL;
4024 ret->u.b.pl = pl;
4025 free_btags(b);
4026 }
4027 return ret;
4028 }
4029
build_mailboxtest(int t,struct comptags * c,const char * extname,const char * keyname,strarray_t * keylist)4030 static test_t *build_mailboxtest(int t, struct comptags *c,
4031 const char *extname, const char *keyname,
4032 strarray_t *keylist)
4033 {
4034 test_t *ret = new_test(t);
4035
4036 if (ret) {
4037 ret->u.mbx.extname = xstrdupnull(extname);
4038 ret->u.mbx.keyname = xstrdupnull(keyname);
4039 ret->u.mbx.keylist = keylist;
4040 if (c) {
4041 canon_comptags(c);
4042 ret->u.mbx.comptag = c->match;
4043 ret->u.mbx.relation = c->relation;
4044 ret->u.mbx.comparator = xstrdup(c->comparator);
4045 free_comptags(c, 1);
4046 }
4047 }
4048
4049 return ret;
4050 }
4051
build_vacation(int t,struct vtags * v,char * reason)4052 static commandlist_t *build_vacation(int t, struct vtags *v, char *reason)
4053 {
4054 commandlist_t *ret = new_command(t);
4055
4056 assert(t == VACATION);
4057
4058 if (ret) {
4059 ret->u.v.subject = v->subject; v->subject = NULL;
4060 ret->u.v.from = v->from; v->from = NULL;
4061 ret->u.v.handle = v->handle; v->handle = NULL;
4062 ret->u.v.seconds = v->seconds;
4063 ret->u.v.mime = v->mime;
4064 ret->u.v.addresses = v->addresses; v->addresses = NULL;
4065 free_vtags(v);
4066 ret->u.v.message = reason;
4067 }
4068 return ret;
4069 }
4070
build_notify(int t,struct ntags * n)4071 static commandlist_t *build_notify(int t, struct ntags *n)
4072 {
4073 commandlist_t *ret = new_command(t);
4074
4075 assert(t == NOTIFY);
4076 if (ret) {
4077 ret->u.n.method = n->method; n->method = NULL;
4078 ret->u.n.id = n->id; n->id = NULL;
4079 ret->u.n.options = n->options; n->options = NULL;
4080 ret->u.n.priority = n->priority;
4081 ret->u.n.message = n->message; n->message = NULL;
4082 free_ntags(n);
4083 }
4084 return ret;
4085 }
4086
build_denotify(int t,struct dtags * d)4087 static commandlist_t *build_denotify(int t, struct dtags *d)
4088 {
4089 commandlist_t *ret = new_command(t);
4090
4091 assert(t == DENOTIFY);
4092
4093 if (ret) {
4094 ret->u.d.comptag = d->comptags.match;
4095 ret->u.d.relation = d->comptags.relation;
4096 ret->u.d.pattern = xstrdupnull(d->pattern);
4097 ret->u.d.priority = d->priority;
4098 free_dtags(d);
4099 }
4100 return ret;
4101 }
4102
build_keep(int t,struct ftags * f)4103 static commandlist_t *build_keep(int t, struct ftags *f)
4104 {
4105 commandlist_t *ret = new_command(t);
4106
4107 assert(t == KEEP);
4108
4109 if (ret) {
4110 ret->u.k.copy = f->copy;
4111 ret->u.k.flags = f->flags; f->flags = NULL;
4112 free_ftags(f);
4113 }
4114 return ret;
4115 }
4116
build_fileinto(int t,struct ftags * f,char * folder)4117 static commandlist_t *build_fileinto(int t, struct ftags *f, char *folder)
4118 {
4119 commandlist_t *ret = new_command(t);
4120
4121 assert(t == FILEINTO);
4122
4123 if (ret) {
4124 ret->u.f.copy = f->copy;
4125 ret->u.f.create = f->create;
4126 ret->u.f.flags = f->flags; f->flags = NULL;
4127 if (config_getswitch(IMAPOPT_SIEVE_UTF8FILEINTO)) {
4128 ret->u.f.folder = xmalloc(5 * strlen(folder) + 1);
4129 UTF8_to_mUTF7(ret->u.f.folder, folder);
4130 }
4131 else {
4132 ret->u.f.folder = xstrdup(folder);
4133 }
4134 free_ftags(f);
4135 }
4136 return ret;
4137 }
4138
build_redirect(int t,int copy,char * address)4139 static commandlist_t *build_redirect(int t, int copy, char *address)
4140 {
4141 commandlist_t *ret = new_command(t);
4142
4143 assert(t == REDIRECT);
4144
4145 if (ret) {
4146 ret->u.r.copy = copy;
4147 ret->u.r.address = address;
4148 }
4149 return ret;
4150 }
4151
build_include(int t,struct itags * i,char * script)4152 static commandlist_t *build_include(int t, struct itags *i, char* script)
4153 {
4154 commandlist_t *ret = new_command(t);
4155
4156 assert(t == INCLUDE);
4157
4158 if (i->location == -1) i->location = PERSONAL;
4159 if (i->once == -1) i->once = 0;
4160 if (i->optional == -1) i->optional = 0;
4161
4162 if (ret) {
4163 ret->u.inc.location = i->location;
4164 ret->u.inc.once = i->once;
4165 ret->u.inc.optional = i->optional;
4166 ret->u.inc.script = script;
4167 free(i);
4168 }
4169 return ret;
4170 }
4171
build_date(int t,struct dttags * dt,char * hn,int part,strarray_t * kl)4172 static test_t *build_date(int t, struct dttags *dt,
4173 char *hn, int part, strarray_t *kl)
4174 {
4175 test_t *ret = new_test(t);
4176 assert(t == DATE || t == CURRENTDATE);
4177
4178 if (ret) {
4179 ret->u.dt.comptag = dt->comptags.match;
4180 ret->u.dt.relation = dt->comptags.relation;
4181 ret->u.dt.comparator = xstrdup(dt->comptags.comparator);
4182 ret->u.dt.index = dt->comptags.index;
4183 ret->u.dt.zone = xstrdupnull(dt->zone);
4184 ret->u.dt.zonetag = dt->zonetag;
4185 ret->u.dt.date_part = part;
4186 ret->u.dt.header_name = xstrdupnull(hn);
4187 ret->u.dt.kl = kl;
4188 free_dttags(dt);
4189 }
4190 return ret;
4191 }
4192
build_set(int t,struct stags * s,char * variable,char * value)4193 static commandlist_t *build_set(int t, struct stags *s,
4194 char *variable, char *value)
4195 {
4196 commandlist_t *ret = new_command(t);
4197
4198 assert(t == SET);
4199
4200 if (ret) {
4201 ret->u.s.mod40 = s->mod40;
4202 ret->u.s.mod30 = s->mod30;
4203 ret->u.s.mod20 = s->mod20;
4204 ret->u.s.mod10 = s->mod10;
4205 ret->u.s.variable = xstrdup(variable);
4206 ret->u.s.value = xstrdup(value);
4207
4208 free_stags(s);
4209 }
4210
4211 return ret;
4212 }
4213
build_flag(int t,char * variable,strarray_t * flags)4214 static commandlist_t *build_flag(int t, char *variable, strarray_t *flags)
4215 {
4216 commandlist_t *ret = new_command(t);
4217
4218 assert(t == SETFLAG || t == ADDFLAG || t == REMOVEFLAG);
4219
4220 if (ret) {
4221 ret->u.fl.variable = xstrdup(variable ? variable : "");
4222 ret->u.fl.flags = flags;
4223 }
4224
4225 return ret;
4226 }
4227
new_aetags(void)4228 static struct aetags *new_aetags(void)
4229 {
4230 struct aetags *r = (struct aetags *) xmalloc(sizeof(struct aetags));
4231
4232 init_comptags(&r->comptags);
4233 r->addrtag = -1;
4234
4235 return r;
4236 }
4237
canon_aetags(struct aetags * ae)4238 static struct aetags *canon_aetags(struct aetags *ae)
4239 {
4240 canon_comptags(&ae->comptags);
4241 if (ae->addrtag == -1) { ae->addrtag = ALL; }
4242 return ae;
4243 }
4244
free_aetags(struct aetags * ae)4245 static void free_aetags(struct aetags *ae)
4246 {
4247 free_comptags(&ae->comptags, 0);
4248 free(ae);
4249 }
4250
new_comptags(void)4251 static struct comptags *new_comptags(void)
4252 {
4253 struct comptags *c = (struct comptags *) xmalloc(sizeof(struct comptags));
4254
4255 return init_comptags(c);
4256 }
4257
init_comptags(struct comptags * c)4258 static struct comptags *init_comptags(struct comptags *c)
4259 {
4260 c->match = c->relation = -1;
4261 c->comparator = NULL;
4262 c->index = 0;
4263
4264 return c;
4265 }
4266
canon_comptags(struct comptags * c)4267 static struct comptags *canon_comptags(struct comptags *c)
4268 {
4269 if (c->match == -1) c->match = IS;
4270 if (c->comparator == NULL) c->comparator = xstrdup("i;ascii-casemap");
4271 return c;
4272 }
4273
free_comptags(struct comptags * c,int destroy)4274 static void free_comptags(struct comptags *c, int destroy)
4275 {
4276 free(c->comparator);
4277 if (destroy) free(c);
4278 }
4279
new_btags(void)4280 static struct btags *new_btags(void)
4281 {
4282 struct btags *r = (struct btags *) xmalloc(sizeof(struct btags));
4283
4284 init_comptags(&r->comptags);
4285 r->transform = r->offset = -1;
4286 r->content_types = NULL;
4287
4288 return r;
4289 }
4290
canon_btags(struct btags * b)4291 static struct btags *canon_btags(struct btags *b)
4292 {
4293 canon_comptags(&b->comptags);
4294 if (b->transform == -1) b->transform = TEXT;
4295 if (b->content_types == NULL) {
4296 b->content_types = strarray_new();
4297 if (b->transform == RAW) strarray_append(b->content_types, "");
4298 else strarray_append(b->content_types, "text");
4299 }
4300 if (b->offset == -1) b->offset = 0;
4301 return b;
4302 }
4303
free_btags(struct btags * b)4304 static void free_btags(struct btags *b)
4305 {
4306 free_comptags(&b->comptags, 0);
4307 if (b->content_types) strarray_free(b->content_types);
4308 free(b);
4309 }
4310
new_vtags(void)4311 static struct vtags *new_vtags(void)
4312 {
4313 struct vtags *r = (struct vtags *) xmalloc(sizeof(struct vtags));
4314
4315 r->seconds = -1;
4316 r->addresses = NULL;
4317 r->subject = NULL;
4318 r->from = NULL;
4319 r->handle = NULL;
4320 r->mime = -1;
4321
4322 return r;
4323 }
4324
canon_vtags(sieve_script_t * parse_script,struct vtags * v)4325 static struct vtags *canon_vtags(sieve_script_t *parse_script, struct vtags *v)
4326 {
4327 assert(parse_script->interp.vacation != NULL);
4328
4329 if (v->seconds == -1) v->seconds = 7 * DAY2SEC;
4330 if (v->seconds < parse_script->interp.vacation->min_response)
4331 v->seconds = parse_script->interp.vacation->min_response;
4332 if (v->seconds > parse_script->interp.vacation->max_response)
4333 v->seconds = parse_script->interp.vacation->max_response;
4334 if (v->mime == -1) v->mime = 0;
4335
4336 return v;
4337 }
4338
free_vtags(struct vtags * v)4339 static void free_vtags(struct vtags *v)
4340 {
4341 strarray_free(v->addresses);
4342 free(v->subject);
4343 free(v->from);
4344 free(v->handle);
4345 free(v);
4346 }
4347
new_itags()4348 static struct itags *new_itags()
4349 {
4350 struct itags *r = (struct itags *) xmalloc(sizeof(struct itags));
4351
4352 r->once = -1;
4353 r->location = -1;
4354 r->optional = -1;
4355
4356 return r;
4357 }
4358
new_dttags(void)4359 static struct dttags *new_dttags(void)
4360 {
4361 struct dttags *dt = (struct dttags *) xmalloc(sizeof(struct dttags));
4362
4363 init_comptags(&dt->comptags);
4364 dt->zonetag = -1;
4365 dt->zone = NULL;
4366 return dt;
4367 }
4368
canon_dttags(struct dttags * dt)4369 static struct dttags *canon_dttags(struct dttags *dt)
4370 {
4371 char zone[14];
4372 int gmoffset;
4373 int hours;
4374 int minutes;
4375 struct tm tm;
4376 time_t t;
4377
4378 canon_comptags(&dt->comptags);
4379 if (dt->comptags.index == 0) dt->comptags.index = 1;
4380 if (dt->zonetag == -1) {
4381 t = time(NULL);
4382 localtime_r(&t, &tm);
4383 gmoffset = gmtoff_of(&tm, t) / 60;
4384 hours = abs(gmoffset) / 60;
4385 minutes = abs(gmoffset) % 60;
4386 snprintf(zone, sizeof(zone), "%c%02d%02d",
4387 (gmoffset >= 0 ? '+' : '-'), hours, minutes);
4388 dt->zone = xstrdup(zone);
4389 dt->zonetag = ZONE;
4390 }
4391 return dt;
4392 }
4393
free_dttags(struct dttags * dt)4394 static void free_dttags(struct dttags *dt)
4395 {
4396 free_comptags(&dt->comptags, 0);
4397 free(dt->zone);
4398 free(dt);
4399 }
4400
4401
new_ntags(void)4402 static struct ntags *new_ntags(void)
4403 {
4404 struct ntags *r = (struct ntags *) xmalloc(sizeof(struct ntags));
4405
4406 r->method = NULL;
4407 r->id = NULL;
4408 r->options = NULL;
4409 r->priority = -1;
4410 r->message = NULL;
4411
4412 return r;
4413 }
4414
canon_ntags(struct ntags * n)4415 static struct ntags *canon_ntags(struct ntags *n)
4416 {
4417 if (n->priority == -1) n->priority = NORMAL;
4418 if (n->message == NULL) n->message = xstrdup("$from$: $subject$");
4419 if (n->method == NULL) n->method = xstrdup("default");
4420 return n;
4421 }
canon_dtags(struct dtags * d)4422 static struct dtags *canon_dtags(struct dtags *d)
4423 {
4424 canon_comptags(&d->comptags);
4425 if (d->priority == -1) d->priority = ANY;
4426 return d;
4427 }
4428
free_ntags(struct ntags * n)4429 static void free_ntags(struct ntags *n)
4430 {
4431 free(n->method);
4432 free(n->id);
4433 strarray_free(n->options);
4434 free(n->message);
4435 free(n);
4436 }
4437
new_dtags(void)4438 static struct dtags *new_dtags(void)
4439 {
4440 struct dtags *r = (struct dtags *) xzmalloc(sizeof(struct dtags));
4441
4442 init_comptags(&r->comptags);
4443 r->comptags.comparator = xstrdup("i;ascii-casemap");
4444 r->priority = -1;
4445
4446 return r;
4447 }
4448
free_dtags(struct dtags * d)4449 static void free_dtags(struct dtags *d)
4450 {
4451 if (!d) return;
4452 free_comptags(&d->comptags, 0);
4453 free(d);
4454 }
4455
new_ftags(void)4456 static struct ftags *new_ftags(void)
4457 {
4458 struct ftags *f = (struct ftags *) xzmalloc(sizeof(struct ftags));
4459 return f;
4460 }
4461
canon_ftags(struct ftags * f)4462 static struct ftags *canon_ftags(struct ftags *f)
4463 {
4464 return f;
4465 }
4466
new_stags(void)4467 static struct stags *new_stags(void)
4468 {
4469 struct stags *s = (struct stags *) xmalloc(sizeof(struct stags));
4470
4471 s->mod40 = 0;
4472 s->mod30 = 0;
4473 s->mod20 = 0;
4474 s->mod10 = 0;
4475
4476 return s;
4477 }
4478
canon_stags(struct stags * s)4479 static struct stags *canon_stags(struct stags *s)
4480 {
4481 return s;
4482 }
4483
free_stags(struct stags * s)4484 static void free_stags(struct stags *s)
4485 {
4486 free(s);
4487 }
4488
free_ftags(struct ftags * f)4489 static void free_ftags(struct ftags *f)
4490 {
4491 if (!f) return;
4492 strarray_free(f->flags);
4493 free(f);
4494 }
4495
verify_identifier(sieve_script_t * parse_script,char * s)4496 static int verify_identifier(sieve_script_t *parse_script, char *s)
4497 {
4498 /* identifier = (ALPHA / "_") *(ALPHA / DIGIT / "_") */
4499
4500 if (!is_identifier(s)) {
4501 snprintf(parse_script->sieveerr, ERR_BUF_SIZE,
4502 "string '%s': not a valid sieve identifier", s);
4503 yyerror(parse_script, parse_script->sieveerr);
4504 return 0;
4505 }
4506 return 1;
4507 }
4508
verify_stringlist(sieve_script_t * parse_script,strarray_t * sa,int (* verify)(sieve_script_t *,char *))4509 static int verify_stringlist(sieve_script_t *parse_script, strarray_t *sa,
4510 int (*verify)(sieve_script_t*, char *))
4511 {
4512 int i;
4513
4514 for (i = 0 ; i < sa->count ; i++) {
4515 if (!verify(parse_script, sa->data[i])) return 0;
4516 }
4517 return 1;
4518 }
4519
verify_address(sieve_script_t * parse_script,char * s)4520 static int verify_address(sieve_script_t *parse_script, char *s)
4521 {
4522 parse_script->addrerr[0] = '\0'; /* paranoia */
4523 YY_BUFFER_STATE buffer = addr_scan_string(s);
4524 if (addrparse(parse_script)) {
4525 snprintf(parse_script->sieveerr, ERR_BUF_SIZE,
4526 "address '%s': %s", s, parse_script->addrerr);
4527 yyerror(parse_script, parse_script->sieveerr);
4528 addr_delete_buffer(buffer);
4529 return 0;
4530 }
4531 addr_delete_buffer(buffer);
4532 return 1;
4533 }
4534
verify_mailbox(sieve_script_t * parse_script,char * s)4535 static int verify_mailbox(sieve_script_t *parse_script, char *s)
4536 {
4537 if (!verify_utf8(parse_script, s)) return 0;
4538
4539 /* xxx if not a mailbox, call yyerror */
4540 return 1;
4541 }
4542
verify_header(sieve_script_t * parse_script,char * hdr)4543 static int verify_header(sieve_script_t *parse_script, char *hdr)
4544 {
4545 char *h = hdr;
4546
4547 while (*h) {
4548 /* field-name = 1*ftext
4549 ftext = %d33-57 / %d59-126
4550 ; Any character except
4551 ; controls, SP, and
4552 ; ":". */
4553 if (!((*h >= 33 && *h <= 57) || (*h >= 59 && *h <= 126))) {
4554 snprintf(parse_script->sieveerr, ERR_BUF_SIZE,
4555 "header '%s': not a valid header", hdr);
4556 yyerror(parse_script, parse_script->sieveerr);
4557 return 0;
4558 }
4559 h++;
4560 }
4561 return 1;
4562 }
4563
verify_addrheader(sieve_script_t * parse_script,char * hdr)4564 static int verify_addrheader(sieve_script_t *parse_script, char *hdr)
4565 {
4566 const char **h, *hdrs[] = {
4567 "from", "sender", "reply-to", /* RFC2822 originator fields */
4568 "to", "cc", "bcc", /* RFC2822 destination fields */
4569 "resent-from", "resent-sender", /* RFC2822 resent fields */
4570 "resent-to", "resent-cc", "resent-bcc",
4571 "return-path", /* RFC2822 trace fields */
4572 "disposition-notification-to", /* RFC2298 MDN request fields */
4573 "delivered-to", /* non-standard (loop detection) */
4574 "approved", /* RFC1036 moderator/control fields */
4575 NULL
4576 };
4577
4578 if (!config_getswitch(IMAPOPT_RFC3028_STRICT))
4579 return verify_header(parse_script, hdr);
4580
4581 for (lcase(hdr), h = hdrs; *h; h++) {
4582 if (!strcmp(*h, hdr)) return 1;
4583 }
4584
4585 snprintf(parse_script->sieveerr, ERR_BUF_SIZE,
4586 "header '%s': not a valid header for an address test", hdr);
4587 yyerror(parse_script, parse_script->sieveerr);
4588 return 0;
4589 }
4590
verify_envelope(sieve_script_t * parse_script,char * env)4591 static int verify_envelope(sieve_script_t *parse_script, char *env)
4592 {
4593 lcase(env);
4594 if (!config_getswitch(IMAPOPT_RFC3028_STRICT) ||
4595 !strcmp(env, "from") || !strcmp(env, "to") || !strcmp(env, "auth")) {
4596 return 1;
4597 }
4598
4599 snprintf(parse_script->sieveerr, ERR_BUF_SIZE,
4600 "env-part '%s': not a valid part for an envelope test", env);
4601 yyerror(parse_script, parse_script->sieveerr);
4602 return 0;
4603 }
4604
verify_relat(sieve_script_t * parse_script,char * r)4605 static int verify_relat(sieve_script_t *parse_script, char *r)
4606 {
4607 /* this really should have been a token to begin with.*/
4608 lcase(r);
4609 if (!strcmp(r, "gt")) return GT;
4610 else if (!strcmp(r, "ge")) return GE;
4611 else if (!strcmp(r, "lt")) return LT;
4612 else if (!strcmp(r, "le")) return LE;
4613 else if (!strcmp(r, "ne")) return NE;
4614 else if (!strcmp(r, "eq")) return EQ;
4615 else {
4616 snprintf(parse_script->sieveerr, ERR_BUF_SIZE,
4617 "flag '%s': not a valid relational operation", r);
4618 yyerror(parse_script, parse_script->sieveerr);
4619 return -1;
4620 }
4621 }
4622
verify_zone(sieve_script_t * parse_script,char * tz)4623 static int verify_zone(sieve_script_t *parse_script, char *tz)
4624 {
4625 int valid = 0;
4626 unsigned hours;
4627 unsigned minutes;
4628 char sign;
4629
4630 if (sscanf(tz, "%c%02u%02u", &sign, &hours, &minutes) != 3) {
4631 valid |= -1;
4632 }
4633
4634 // test sign
4635 switch (sign) {
4636 case '+':
4637 case '-':
4638 break;
4639
4640 default:
4641 valid |= -1;
4642 break;
4643 }
4644
4645 // test minutes
4646 if (minutes > 59) {
4647 valid |= -1;
4648 }
4649
4650 if (valid != 0) {
4651 snprintf(parse_script->sieveerr, ERR_BUF_SIZE,
4652 "flag '%s': not a valid timezone offset", tz);
4653 yyerror(parse_script, parse_script->sieveerr);
4654 }
4655
4656 return valid;
4657 }
4658
verify_date_part(sieve_script_t * parse_script,char * dp)4659 static int verify_date_part(sieve_script_t *parse_script, char *dp)
4660 {
4661 lcase(dp);
4662 if (!strcmp(dp, "year")) return YEAR;
4663 else if (!strcmp(dp, "month")) return MONTH;
4664 else if (!strcmp(dp, "day")) return DAY;
4665 else if (!strcmp(dp, "date")) return DATE;
4666 else if (!strcmp(dp, "julian")) return JULIAN;
4667 else if (!strcmp(dp, "hour")) return HOUR;
4668 else if (!strcmp(dp, "minute")) return MINUTE;
4669 else if (!strcmp(dp, "second")) return SECOND;
4670 else if (!strcmp(dp, "time")) return TIME;
4671 else if (!strcmp(dp, "iso8601")) return ISO8601;
4672 else if (!strcmp(dp, "std11")) return STD11;
4673 else if (!strcmp(dp, "zone")) return ZONE;
4674 else if (!strcmp(dp, "weekday")) return WEEKDAY;
4675 else {
4676 snprintf(parse_script->sieveerr, ERR_BUF_SIZE,
4677 "'%s': not a valid date-part", dp);
4678 yyerror(parse_script, parse_script->sieveerr);
4679 }
4680
4681 return -1;
4682 }
4683
4684 #ifdef ENABLE_REGEX
verify_regex(sieve_script_t * parse_script,char * s,int cflags)4685 static int verify_regex(sieve_script_t *parse_script, char *s, int cflags)
4686 {
4687 int ret;
4688 regex_t *reg = (regex_t *) xmalloc(sizeof(regex_t));
4689
4690 if ((ret = regcomp(reg, s, cflags)) != 0) {
4691 (void) regerror(ret, reg, parse_script->sieveerr, ERR_BUF_SIZE);
4692 yyerror(parse_script, parse_script->sieveerr);
4693 free(reg);
4694 return 0;
4695 }
4696 free(reg);
4697 return 1;
4698 }
4699
verify_regexs(sieve_script_t * parse_script,const strarray_t * sa,char * comp)4700 static int verify_regexs(sieve_script_t *parse_script,
4701 const strarray_t *sa, char *comp)
4702 {
4703 int i;
4704 int cflags = REG_EXTENDED | REG_NOSUB;
4705
4706 #ifdef HAVE_PCREPOSIX_H
4707 /* support UTF8 comparisons */
4708 cflags |= REG_UTF8;
4709 #endif
4710
4711 if (!strcmp(comp, "i;ascii-casemap")) {
4712 cflags |= REG_ICASE;
4713 }
4714
4715 for (i = 0 ; i < sa->count ; i++) {
4716 if ((verify_regex(parse_script, sa->data[i], cflags)) == 0)
4717 return 0;
4718 }
4719 return 1;
4720 }
4721 #else
4722
verify_regexs(sieve_script_t * parse_script,const strarray_t * sa,char * comp)4723 static int verify_regexs(sieve_script_t *parse_script __attribute__((unused)),
4724 const strarray_t *sa __attribute__((unused)),
4725 char *comp __attribute__((unused)))
4726 {
4727 return 0;
4728 }
4729 #endif /* ENABLE_REGEX */
4730
verify_patternlist(sieve_script_t * parse_script,strarray_t * sa,struct comptags * c,int (* verify)(sieve_script_t *,char *))4731 static int verify_patternlist(sieve_script_t *parse_script,
4732 strarray_t *sa, struct comptags *c,
4733 int (*verify)(sieve_script_t*, char *))
4734 {
4735 if (verify && !verify_stringlist(parse_script, sa, verify)) return 0;
4736
4737 return (c->match == REGEX) ?
4738 verify_regexs(parse_script, sa, c->comparator) : 1;
4739 }
4740
4741 /*
4742 * Valid UTF-8 check (from RFC 2640 Annex B.1)
4743 *
4744 * The following routine checks if a byte sequence is valid UTF-8. This
4745 * is done by checking for the proper tagging of the first and following
4746 * bytes to make sure they conform to the UTF-8 format. It then checks
4747 * to assure that the data part of the UTF-8 sequence conforms to the
4748 * proper range allowed by the encoding. Note: This routine will not
4749 * detect characters that have not been assigned and therefore do not
4750 * exist.
4751 */
verify_utf8(sieve_script_t * parse_script,char * s)4752 static int verify_utf8(sieve_script_t *parse_script, char *s)
4753 {
4754 const char *buf = s;
4755 const char *endbuf = s + strlen(s);
4756 unsigned char byte2mask = 0x00, c;
4757 int trailing = 0; /* trailing (continuation) bytes to follow */
4758
4759 while (buf != endbuf) {
4760 c = *buf++;
4761 if (trailing) {
4762 if ((c & 0xC0) == 0x80) { /* Does trailing byte
4763 follow UTF-8 format? */
4764 if (byte2mask) { /* Need to check 2nd byte
4765 for proper range? */
4766 if (c & byte2mask) /* Are appropriate bits set? */
4767 byte2mask = 0x00;
4768 else
4769 break;
4770 }
4771 trailing--;
4772 }
4773 else
4774 break;
4775 }
4776 else {
4777 if ((c & 0x80) == 0x00) /* valid 1 byte UTF-8 */
4778 continue;
4779 else if ((c & 0xE0) == 0xC0) /* valid 2 byte UTF-8 */
4780 if (c & 0x1E) { /* Is UTF-8 byte
4781 in proper range? */
4782 trailing = 1;
4783 }
4784 else
4785 break;
4786 else if ((c & 0xF0) == 0xE0) { /* valid 3 byte UTF-8 */
4787 if (!(c & 0x0F)) { /* Is UTF-8 byte
4788 in proper range? */
4789 byte2mask = 0x20; /* If not, set mask
4790 to check next byte */
4791 }
4792 trailing = 2;
4793 }
4794 else if ((c & 0xF8) == 0xF0) { /* valid 4 byte UTF-8 */
4795 if (!(c & 0x07)) { /* Is UTF-8 byte
4796 in proper range? */
4797 byte2mask = 0x30; /* If not, set mask
4798 to check next byte */
4799 }
4800 trailing = 3;
4801 }
4802 else if ((c & 0xFC) == 0xF8) { /* valid 5 byte UTF-8 */
4803 if (!(c & 0x03)) { /* Is UTF-8 byte
4804 in proper range? */
4805 byte2mask = 0x38; /* If not, set mask
4806 to check next byte */
4807 }
4808 trailing = 4;
4809 }
4810 else if ((c & 0xFE) == 0xFC) { /* valid 6 byte UTF-8 */
4811 if (!(c & 0x01)) { /* Is UTF-8 byte
4812 in proper range? */
4813 byte2mask = 0x3C; /* If not, set mask
4814 to check next byte */
4815 }
4816 trailing = 5;
4817 }
4818 else
4819 break;
4820 }
4821 }
4822
4823 if ((buf != endbuf) || trailing) {
4824 snprintf(parse_script->sieveerr, ERR_BUF_SIZE,
4825 "string '%s': not valid utf8", s);
4826 yyerror(parse_script, parse_script->sieveerr);
4827 return 0;
4828 }
4829
4830 return 1;
4831 }
4832