1 /* 2 Copyright 2021 Northern.tech AS 3 4 This file is part of CFEngine 3 - written and maintained by Northern.tech AS. 5 6 This program is free software; you can redistribute it and/or modify it 7 under the terms of the GNU General Public License as published by the 8 Free Software Foundation; version 3. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 19 To the extent this program is licensed as part of the Enterprise 20 versions of CFEngine, the applicable Commercial Open Source License 21 (COSL) may apply to this file if you as a licensee so wish it. See 22 included file COSL.txt. 23 */ 24 25 #ifndef CFENGINE_PARSER_STATE_H 26 #define CFENGINE_PARSER_STATE_H 27 28 #include <cf3.defs.h> 29 #include <rlist.h> 30 #include <fncall.h> 31 #include <parser_helpers.h> // ParserBlock 32 33 #define CF_MAX_NESTING 10 34 35 typedef struct 36 { 37 AgentType agent_type; 38 39 ParserBlock block; // enum for bundle/body 40 char blocktype[CF_MAXVARSIZE]; 41 char blockid[CF_MAXVARSIZE]; 42 43 char filename[CF_MAXVARSIZE]; 44 char *current_line; 45 int line_pos; 46 int line_no; 47 int error_count; 48 49 int warning_count; 50 int warnings; // bitfield of warnings not considered to be an error 51 int warnings_error; // bitfield of warnings considered to be an error 52 53 int if_depth; 54 55 int arg_nesting; 56 int list_nesting; 57 58 char lval[CF_MAXVARSIZE]; 59 Rval rval; 60 bool references_body; 61 62 char *promiser; 63 void *promisee; 64 65 char *current_namespace; 66 char currentid[CF_MAXVARSIZE]; 67 char currenttype[CF_MAXVARSIZE]; 68 char *currentstring; 69 char *currentclasses; 70 char *currentvarclasses; 71 72 Policy *policy; 73 74 Bundle *currentbundle; 75 Body *currentbody; 76 Promise *currentpromise; 77 BundleSection *currentstype; 78 Rlist *useargs; 79 80 Rlist *currentRlist; 81 82 char *currentfnid[CF_MAX_NESTING]; 83 Rlist *giveargs[CF_MAX_NESTING]; 84 FnCall *currentfncall[CF_MAX_NESTING]; 85 86 struct OffsetState 87 { 88 size_t current; 89 size_t last_id; 90 size_t last_string; 91 size_t last_block_id; 92 size_t last_promise_guard_id; 93 size_t last_class_id; 94 } offsets; 95 } ParserState; 96 97 extern ParserState PARSER_STATE; 98 99 #endif 100