cf-lex.l 15.4 KB
Newer Older
Martin Mareš's avatar
Martin Mareš committed
1 2 3
/*
 *	BIRD -- Configuration Lexer
 *
4
 *	(c) 1998--2000 Martin Mares <mj@ucw.cz>
Martin Mareš's avatar
Martin Mareš committed
5 6 7 8
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

Martin Mareš's avatar
Martin Mareš committed
9
/**
10
 * DOC: Lexical analyzer
Martin Mareš's avatar
Martin Mareš committed
11
 *
12
 * The lexical analyzer used for configuration files and CLI commands
Martin Mareš's avatar
Martin Mareš committed
13
 * is generated using the |flex| tool accompanied by a couple of
Martin Mareš's avatar
Martin Mareš committed
14 15 16 17
 * functions maintaining the hash tables containing information about
 * symbols and keywords.
 *
 * Each symbol is represented by a &symbol structure containing name
18 19 20 21
 * of the symbol, its lexical scope, symbol class (%SYM_PROTO for a
 * name of a protocol, %SYM_CONSTANT for a constant etc.) and class
 * dependent data.  When an unknown symbol is encountered, it's
 * automatically added to the symbol table with class %SYM_VOID.
Martin Mareš's avatar
Martin Mareš committed
22 23 24 25 26
 *
 * The keyword tables are generated from the grammar templates
 * using the |gen_keywords.m4| script.
 */

Martin Mareš's avatar
Martin Mareš committed
27
%{
28
#undef REJECT     /* Avoid name clashes */
Martin Mareš's avatar
Martin Mareš committed
29 30 31

#include <errno.h>
#include <stdlib.h>
32
#include <stdarg.h>
33
#include <unistd.h>
34 35 36 37 38 39
#include <libgen.h>
#include <glob.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/stat.h>
Martin Mareš's avatar
Martin Mareš committed
40

41 42
#define PARSER 1

Martin Mareš's avatar
Martin Mareš committed
43
#include "nest/bird.h"
Martin Mareš's avatar
Martin Mareš committed
44
#include "nest/route.h"
45
#include "nest/protocol.h"
Martin Mareš's avatar
Martin Mareš committed
46
#include "filter/filter.h"
Martin Mareš's avatar
Martin Mareš committed
47 48
#include "conf/conf.h"
#include "conf/cf-parse.tab.h"
49
#include "lib/string.h"
Martin Mareš's avatar
Martin Mareš committed
50

51
struct keyword {
Martin Mareš's avatar
Martin Mareš committed
52 53 54
  byte *name;
  int value;
  struct keyword *next;
55 56
};

57
#include "conf/keywords.h"
Martin Mareš's avatar
Martin Mareš committed
58 59

#define KW_HASH_SIZE 64
60 61 62
static struct keyword *kw_hash[KW_HASH_SIZE];
static int kw_hash_inited;

Martin Mareš's avatar
Martin Mareš committed
63 64 65
#define SYM_HASH_SIZE 128
#define SYM_MAX_LEN 32

Martin Mareš's avatar
Martin Mareš committed
66 67 68 69 70 71 72
struct sym_scope {
  struct sym_scope *next;		/* Next on scope stack */
  struct symbol *name;			/* Name of this scope */
  int active;				/* Currently entered */
};
static struct sym_scope *conf_this_scope;

Martin Mareš's avatar
Martin Mareš committed
73 74 75
static int cf_hash(byte *c);
static struct symbol *cf_find_sym(byte *c, unsigned int h0);

76
linpool *cfg_mem;
Martin Mareš's avatar
Martin Mareš committed
77

78
int (*cf_read_hook)(byte *buf, unsigned int max, int fd);
Ondřej Zajíček's avatar
Ondřej Zajíček committed
79
struct include_file_stack *ifs;
80 81 82
static struct include_file_stack *ifs_head;

#define MAX_INCLUDE_DEPTH 8
Martin Mareš's avatar
Martin Mareš committed
83

84
#define YY_INPUT(buf,result,max) result = cf_read_hook(buf, max, ifs->fd);
Martin Mareš's avatar
Martin Mareš committed
85 86 87
#define YY_NO_UNPUT
#define YY_FATAL_ERROR(msg) cf_error(msg)

88
static void cf_include(char *arg, int alen);
89 90
static int check_eof(void);

Martin Mareš's avatar
Martin Mareš committed
91 92 93
%}

%option noyywrap
94 95 96
%option noinput
%option nounput
%option noreject
Martin Mareš's avatar
Martin Mareš committed
97

98
%x COMMENT CCOMM CLI
Martin Mareš's avatar
Martin Mareš committed
99 100 101 102 103 104

ALPHA [a-zA-Z_]
DIGIT [0-9]
XIGIT [0-9a-fA-F]
ALNUM [a-zA-Z_0-9]
WHITE [ \t]
105
include   ^{WHITE}*include{WHITE}*\".*\"{WHITE}*;
Martin Mareš's avatar
Martin Mareš committed
106 107

%%
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
{include} {
  char *start, *end;

  if (!ifs->depth)
    cf_error("Include not allowed in CLI");

  start = strchr(yytext, '"');
  start++;

  end = strchr(start, '"');
  *end = 0;

  if (start == end)
    cf_error("Include with empty argument");

  cf_include(start, end-start);
}
Martin Mareš's avatar
Martin Mareš committed
125 126

{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+ {
127 128 129 130 131
#ifdef IPV6
  if (ipv4_pton_u32(yytext, &cf_lval.i32))
    return RTRID;
  cf_error("Invalid IPv4 address %s", yytext);
#else
Martin Mareš's avatar
Martin Mareš committed
132 133
  if (ip_pton(yytext, &cf_lval.a))
    return IPA;
134 135 136 137 138 139 140 141 142 143 144 145
  cf_error("Invalid IP address %s", yytext);
#endif
}

({XIGIT}*::|({XIGIT}*:){3,})({XIGIT}*|{DIGIT}+\.{DIGIT}+\.{DIGIT}+\.{DIGIT}+) {
#ifdef IPV6
  if (ip_pton(yytext, &cf_lval.a))
    return IPA;
  cf_error("Invalid IP address %s", yytext);
#else
  cf_error("This is an IPv4 router, therefore IPv6 addresses are not supported");
#endif
Martin Mareš's avatar
Martin Mareš committed
146 147
}

148
0x{XIGIT}+ {
Martin Mareš's avatar
Martin Mareš committed
149
  char *e;
150
  unsigned long int l;
Martin Mareš's avatar
Martin Mareš committed
151 152
  errno = 0;
  l = strtoul(yytext+2, &e, 16);
153
  if (e && *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l)
Martin Mareš's avatar
Martin Mareš committed
154 155 156 157 158 159 160
    cf_error("Number out of range");
  cf_lval.i = l;
  return NUM;
}

{DIGIT}+ {
  char *e;
161
  unsigned long int l;
Martin Mareš's avatar
Martin Mareš committed
162 163
  errno = 0;
  l = strtoul(yytext, &e, 10);
164
  if (e && *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l)
Martin Mareš's avatar
Martin Mareš committed
165 166 167 168 169
    cf_error("Number out of range");
  cf_lval.i = l;
  return NUM;
}

170 171 172 173 174
else: {
  /* Hack to distinguish if..else from else: in case */
  return ELSECOL;
}

175
({ALPHA}{ALNUM}*|[']({ALNUM}|[-]|[\.]|[:])*[']) {
176 177 178 179
  if(*yytext == '\'') {
    yytext[yyleng-1] = 0;
    yytext++;
  }
Martin Mareš's avatar
Martin Mareš committed
180 181 182 183 184
  unsigned int h = cf_hash(yytext);
  struct keyword *k = kw_hash[h & (KW_HASH_SIZE-1)];
  while (k)
    {
      if (!strcmp(k->name, yytext))
Martin Mareš's avatar
Martin Mareš committed
185 186 187 188 189 190 191 192 193
	{
	  if (k->value > 0)
	    return k->value;
	  else
	    {
	      cf_lval.i = -k->value;
	      return ENUM;
	    }
	}
Martin Mareš's avatar
Martin Mareš committed
194 195 196 197 198 199
      k=k->next;
    }
  cf_lval.s = cf_find_sym(yytext, h);
  return SYM;
}

200
<CLI>(.|\n) {
201 202 203 204
  BEGIN(INITIAL);
  return CLI_MARKER;
}

205 206 207 208
\.\. {
  return DDOT;
}

209
[={}:;,.()+*/%<>~\[\]?!\|-] {
Martin Mareš's avatar
Martin Mareš committed
210 211 212 213
  return yytext[0];
}

["][^"\n]*["] {
214
  yytext[yyleng-1] = 0;
215
  cf_lval.t = cfg_strdup(yytext+1);
Martin Mareš's avatar
Martin Mareš committed
216 217 218 219 220
  return TEXT;
}

["][^"\n]*\n	cf_error("Unterminated string");

221
<INITIAL,COMMENT><<EOF>>	{ if (check_eof()) return END; }
Martin Mareš's avatar
Martin Mareš committed
222 223 224

{WHITE}+

225
\n	ifs->lino++;
Martin Mareš's avatar
Martin Mareš committed
226

227
#	BEGIN(COMMENT);
Martin Mareš's avatar
Martin Mareš committed
228

229
\/\*	BEGIN(CCOMM);
Martin Mareš's avatar
Martin Mareš committed
230 231 232 233

.	cf_error("Unknown character");

<COMMENT>\n {
234
  ifs->lino++;
Martin Mareš's avatar
Martin Mareš committed
235 236 237 238 239 240
  BEGIN(INITIAL);
}

<COMMENT>.

<CCOMM>\*\/	BEGIN(INITIAL);
241
<CCOMM>\n	ifs->lino++;
Martin Mareš's avatar
Martin Mareš committed
242 243 244 245
<CCOMM>\/\*	cf_error("Comment nesting not supported");
<CCOMM><<EOF>>	cf_error("Unterminated comment");
<CCOMM>.

Pavel Machek's avatar
Pavel Machek committed
246 247 248
\!\= return NEQ;
\<\= return LEQ;
\>\= return GEQ;
Pavel Machek's avatar
Pavel Machek committed
249 250
\&\& return AND;
\|\| return OR;
Pavel Machek's avatar
Pavel Machek committed
251

252 253 254
\[\= return PO;
\=\] return PC;

Martin Mareš's avatar
Martin Mareš committed
255 256 257 258 259 260 261 262 263 264 265 266
%%

static int
cf_hash(byte *c)
{
  unsigned int h = 13;

  while (*c)
    h = (h * 37) + *c++;
  return h;
}

267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300

/*
 * IFS stack - it contains structures needed for recursive processing
 * of include in config files. On the top of the stack is a structure
 * for currently processed file. Other structures are either for
 * active files interrupted because of include directive (these have
 * fd and flex buffer) or for inactive files scheduled to be processed
 * later (when parent requested including of several files by wildcard
 * match - these do not have fd and flex buffer yet).
 *
 * FIXME: Most of these ifs and include functions are really sysdep/unix.
 *
 * FIXME: Resources (fd, flex buffers and glob data) in IFS stack
 * are not freed when cf_error() is called.
 */

static struct include_file_stack *
push_ifs(struct include_file_stack *old)
{
  struct include_file_stack *ret;
  ret = cfg_allocz(sizeof(struct include_file_stack));
  ret->lino = 1;
  ret->prev = old;
  return ret;
}

static struct include_file_stack *
pop_ifs(struct include_file_stack *old)
{
 yy_delete_buffer(old->buffer);
 close(old->fd);
 return old->prev;
}

301
static void
302
enter_ifs(struct include_file_stack *new)
303
{
304 305 306 307 308 309 310 311 312 313 314
  if (!new->buffer)
    {
      new->fd = open(new->file_name, O_RDONLY);
      if (new->fd < 0)
        {
          ifs = ifs->up;
	  cf_error("Unable to open included file %s: %m", new->file_name);
        }

      new->buffer = yy_create_buffer(NULL, YY_BUF_SIZE);
    }
315

316 317
  yy_switch_to_buffer(new->buffer);
}
318

319 320 321 322 323 324 325 326 327 328 329
static void
cf_include(char *arg, int alen)
{
  struct include_file_stack *base_ifs = ifs;
  int new_depth, rv, i;
  char *patt;
  glob_t g;

  new_depth = ifs->depth + 1;
  if (new_depth > MAX_INCLUDE_DEPTH)
    cf_error("Max include depth reached");
330

331 332 333 334 335 336 337 338 339 340 341
  /* expand arg to properly handle relative filenames */
  if (*arg != '/')
    {
      int dlen = strlen(ifs->file_name);
      char *dir = alloca(dlen + 1);
      patt = alloca(dlen + alen + 2);
      memcpy(dir, ifs->file_name, dlen + 1);
      sprintf(patt, "%s/%s", dirname(dir), arg);
    }
  else
    patt = arg;
342

343 344 345 346 347 348 349 350 351 352 353
  /* Skip globbing if there are no wildcards, mainly to get proper
     response when the included config file is missing */
  if (!strpbrk(arg, "?*["))
    {
      ifs = push_ifs(ifs);
      ifs->file_name = cfg_strdup(patt);
      ifs->depth = new_depth;
      ifs->up = base_ifs;
      enter_ifs(ifs);
      return;
    }
354

355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
  /* Expand the pattern */
  rv = glob(patt, GLOB_ERR | GLOB_NOESCAPE, NULL, &g);
  if (rv == GLOB_ABORTED)
    cf_error("Unable to match pattern %s: %m", patt);
  if ((rv != 0) || (g.gl_pathc <= 0))
    return;

  /*
   * Now we put all found files to ifs stack in reverse order, they
   * will be activated and processed in order as ifs stack is popped
   * by pop_ifs() and enter_ifs() in check_eof().
   */
  for(i = g.gl_pathc - 1; i >= 0; i--)
    {
      char *fname = g.gl_pathv[i];
      struct stat fs;

      if (stat(fname, &fs) < 0)
        cf_error("Unable to stat included file %s: %m", fname);

      if (fs.st_mode & S_IFDIR)
        continue;

      /* Prepare new stack item */
      ifs = push_ifs(ifs);
      ifs->file_name = cfg_strdup(fname);
      ifs->depth = new_depth;
      ifs->up = base_ifs;
    }

  globfree(&g);
  enter_ifs(ifs);
387 388 389 390 391
}

static int
check_eof(void)
{
392 393 394 395 396 397
  if (ifs == ifs_head)
    {
      /* EOF in main config file */
      ifs->lino = 1; /* Why this? */
      return 1;
    }
398

399 400 401
  ifs = pop_ifs(ifs);
  enter_ifs(ifs);
  return 0;
402 403
}

404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
static struct symbol *
cf_new_sym(byte *c, unsigned int h)
{
  struct symbol *s, **ht;
  int l;

  if (!new_config->sym_hash)
    new_config->sym_hash = cfg_allocz(SYM_HASH_SIZE * sizeof(struct keyword *));
  ht = new_config->sym_hash;
  l = strlen(c);
  if (l > SYM_MAX_LEN)
    cf_error("Symbol too long");
  s = cfg_alloc(sizeof(struct symbol) + l);
  s->next = ht[h];
  ht[h] = s;
  s->scope = conf_this_scope;
  s->class = SYM_VOID;
  s->def = NULL;
  s->aux = 0;
  strcpy(s->name, c);
  return s;
}

Martin Mareš's avatar
Martin Mareš committed
427 428 429 430
static struct symbol *
cf_find_sym(byte *c, unsigned int h0)
{
  unsigned int h = h0 & (SYM_HASH_SIZE-1);
431
  struct symbol *s, **ht;
Martin Mareš's avatar
Martin Mareš committed
432

433 434 435 436 437 438 439 440 441 442
  if (ht = new_config->sym_hash)
    {
      for(s = ht[h]; s; s=s->next)
	if (!strcmp(s->name, c) && s->scope->active)
	  return s;
    }
  if (new_config->sym_fallback)
    {
      /* We know only top-level scope is active */
      for(s = new_config->sym_fallback[h]; s; s=s->next)
Martin Mareš's avatar
Martin Mareš committed
443
	if (!strcmp(s->name, c) && s->scope->active)
444
	  return s;
445
    }
446
  return cf_new_sym(c, h);
Martin Mareš's avatar
Martin Mareš committed
447 448
}

Martin Mareš's avatar
Martin Mareš committed
449 450 451 452 453 454 455 456 457 458
/**
 * cf_find_symbol - find a symbol by name
 * @c: symbol name
 *
 * This functions searches the symbol table for a symbol of given
 * name. First it examines the current scope, then the second recent
 * one and so on until it either finds the symbol and returns a pointer
 * to its &symbol structure or reaches the end of the scope chain
 * and returns %NULL to signify no match.
 */
459 460 461 462 463 464
struct symbol *
cf_find_symbol(byte *c)
{
  return cf_find_sym(c, cf_hash(c));
}

465
struct symbol *
466
cf_default_name(char *template, int *counter)
467 468 469
{
  char buf[32];
  struct symbol *s;
470
  char *perc = strchr(template, '%');
471

472
  for(;;)
473
    {
474
      bsprintf(buf, template, ++(*counter));
475
      s = cf_find_sym(buf, cf_hash(buf));
476 477 478 479 480 481
      if (!s)
	break;
      if (s->class == SYM_VOID)
	return s;
      if (!perc)
	break;
482
    }
483
  cf_error("Unable to generate default name");
484 485
}

Martin Mareš's avatar
Martin Mareš committed
486 487 488 489 490 491
/**
 * cf_define_symbol - define meaning of a symbol
 * @sym: symbol to be defined
 * @type: symbol class to assign
 * @def: class dependent data
 *
492 493 494 495 496 497 498 499
 * Defines new meaning of a symbol. If the symbol is an undefined
 * one (%SYM_VOID), it's just re-defined to the new type. If it's defined
 * in different scope, a new symbol in current scope is created and the
 * meaning is assigned to it. If it's already defined in the current scope,
 * an error is reported via cf_error().
 *
 * Result: Pointer to the newly defined symbol. If we are in the top-level
 * scope, it's the same @sym as passed to the function.
Martin Mareš's avatar
Martin Mareš committed
500
 */
501
struct symbol *
502 503 504
cf_define_symbol(struct symbol *sym, int type, void *def)
{
  if (sym->class)
505 506 507 508 509
    {
      if (sym->scope == conf_this_scope)
	cf_error("Symbol already defined");
      sym = cf_new_sym(sym->name, cf_hash(sym->name) & (SYM_HASH_SIZE-1));
    }
510 511
  sym->class = type;
  sym->def = def;
512
  return sym;
513 514
}

515 516 517 518 519 520 521 522 523 524 525 526 527 528
static void
cf_lex_init_kh(void)
{
  struct keyword *k;

  for(k=keyword_list; k->name; k++)
    {
      unsigned h = cf_hash(k->name) & (KW_HASH_SIZE-1);
      k->next = kw_hash[h];
      kw_hash[h] = k;
    }
  kw_hash_inited = 1;
}

Martin Mareš's avatar
Martin Mareš committed
529 530 531 532
/**
 * cf_lex_init - initialize the lexer
 * @is_cli: true if we're going to parse CLI command, false for configuration
 *
533
 * cf_lex_init() initializes the lexical analyzer and prepares it for
Martin Mareš's avatar
Martin Mareš committed
534 535
 * parsing of a new input.
 */
Martin Mareš's avatar
Martin Mareš committed
536
void
537
cf_lex_init(int is_cli, struct config *c)
Martin Mareš's avatar
Martin Mareš committed
538
{
539 540
  if (!kw_hash_inited)
    cf_lex_init_kh();
541 542 543 544 545 546 547 548 549

  ifs_head = ifs = push_ifs(NULL);
  if (!is_cli) 
    {
      ifs->file_name = c->file_name;
      ifs->fd = c->file_fd;
      ifs->depth = 1;
    }

550
  yyrestart(NULL);
551 552
  ifs->buffer = YY_CURRENT_BUFFER;

553 554 555 556
  if (is_cli)
    BEGIN(CLI);
  else
    BEGIN(INITIAL);
557

Martin Mareš's avatar
Martin Mareš committed
558 559
  conf_this_scope = cfg_allocz(sizeof(struct sym_scope));
  conf_this_scope->active = 1;
Martin Mareš's avatar
Martin Mareš committed
560 561
}

Martin Mareš's avatar
Martin Mareš committed
562 563 564 565 566 567 568 569 570 571
/**
 * cf_push_scope - enter new scope
 * @sym: symbol representing scope name
 *
 * If we want to enter a new scope to process declarations inside
 * a nested block, we can just call cf_push_scope() to push a new
 * scope onto the scope stack which will cause all new symbols to be
 * defined in this scope and all existing symbols to be sought for
 * in all scopes stored on the stack.
 */
Martin Mareš's avatar
Martin Mareš committed
572 573 574 575 576 577 578 579 580 581 582
void
cf_push_scope(struct symbol *sym)
{
  struct sym_scope *s = cfg_alloc(sizeof(struct sym_scope));

  s->next = conf_this_scope;
  conf_this_scope = s;
  s->active = 1;
  s->name = sym;
}

Martin Mareš's avatar
Martin Mareš committed
583 584 585 586 587 588 589
/**
 * cf_pop_scope - leave a scope
 *
 * cf_pop_scope() pops the topmost scope from the scope stack,
 * leaving all its symbols in the symbol table, but making them
 * invisible to the rest of the config.
 */
Martin Mareš's avatar
Martin Mareš committed
590 591 592 593 594 595 596
void
cf_pop_scope(void)
{
  conf_this_scope->active = 0;
  conf_this_scope = conf_this_scope->next;
  ASSERT(conf_this_scope);
}
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615

struct symbol *
cf_walk_symbols(struct config *cf, struct symbol *sym, int *pos)
{
  for(;;)
    {
      if (!sym)
	{
	  if (*pos >= SYM_HASH_SIZE)
	    return NULL;
	  sym = cf->sym_hash[(*pos)++];
	}
      else
	sym = sym->next;
      if (sym && sym->scope->active)
	return sym;
    }
}

Martin Mareš's avatar
Martin Mareš committed
616 617 618 619 620 621 622
/**
 * cf_symbol_class_name - get name of a symbol class
 * @sym: symbol
 *
 * This function returns a string representing the class
 * of the given symbol.
 */
623 624 625
char *
cf_symbol_class_name(struct symbol *sym)
{
626 627 628
  if ((sym->class & 0xff00) == SYM_CONSTANT)
    return "constant";

629 630 631 632 633 634
  switch (sym->class)
    {
    case SYM_VOID:
      return "undefined";
    case SYM_PROTO:
      return "protocol";
635 636
    case SYM_TEMPLATE:
      return "protocol template";
637 638 639 640 641 642
    case SYM_FUNCTION:
      return "function";
    case SYM_FILTER:
      return "filter";
    case SYM_TABLE:
      return "routing table";
643 644
    case SYM_ROA:
      return "ROA table";
645 646 647 648
    default:
      return "unknown type";
    }
}
649 650 651 652 653


/**
 * DOC: Parser
 *
654
 * Both the configuration and CLI commands are analyzed using a syntax
655 656 657 658 659
 * driven parser generated by the |bison| tool from a grammar which
 * is constructed from information gathered from grammar snippets by
 * the |gen_parser.m4| script.
 *
 * Grammar snippets are files (usually with extension |.Y|) contributed
Martin Mareš's avatar
Martin Mareš committed
660
 * by various BIRD modules in order to provide information about syntax of their
661
 * configuration and their CLI commands. Each snipped consists of several
662
 * sections, each of them starting with a special keyword: |CF_HDR| for
663 664 665
 * a list of |#include| directives needed by the C code, |CF_DEFINES|
 * for a list of C declarations, |CF_DECLS| for |bison| declarations
 * including keyword definitions specified as |CF_KEYWORDS|, |CF_GRAMMAR|
666
 * for the grammar rules, |CF_CODE| for auxiliary C code and finally
667 668 669 670 671 672 673
 * |CF_END| at the end of the snippet.
 *
 * To create references between the snippets, it's possible to define
 * multi-part rules by utilizing the |CF_ADDTO| macro which adds a new
 * alternative to a multi-part rule.
 *
 * CLI commands are defined using a |CF_CLI| macro. Its parameters are:
674
 * the list of keywords determining the command, the list of parameters,
675 676 677 678
 * help text for the parameters and help text for the command.
 *
 * Values of |enum| filter types can be defined using |CF_ENUM| with
 * the following parameters: name of filter type, prefix common for all
679
 * literals of this type and names of all the possible values.
680
 */