| 1 |
/* yamlconf.h - YAML configuration file loader for rsyslog |
| 2 |
* |
| 3 |
* Provides yamlconf_load(), which parses a .yaml/.yml config file and |
| 4 |
* populates the rsyslog loadConf object by building the same cnfobj/nvlst |
| 5 |
* structures the RainerScript bison parser produces, then routing them |
| 6 |
* through the existing cnfDoObj() / cnfDoScript() dispatcher. |
| 7 |
* |
| 8 |
* Compilation is conditional on HAVE_LIBYAML (configure.ac detects yaml-0.1 |
| 9 |
* via pkg-config). The caller in rsconf.c is responsible for the #ifdef guard. |
| 10 |
* |
| 11 |
* Copyright 2025 Rainer Gerhards and Adiscon GmbH. |
| 12 |
* |
| 13 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 14 |
* you may not use this file except in compliance with the License. |
| 15 |
* You may obtain a copy of the License at |
| 16 |
* |
| 17 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 18 |
* -or- |
| 19 |
* see COPYING.ASL20 in the source distribution |
| 20 |
* |
| 21 |
* Unless required by applicable law or agreed to in writing, software |
| 22 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 23 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 24 |
* See the License for the specific language governing permissions and |
| 25 |
* limitations under the License. |
| 26 |
*/ |
| 27 |
#ifndef YAMLCONF_H_INCLUDED |
| 28 |
#define YAMLCONF_H_INCLUDED |
| 29 |
|
| 30 |
#include "rsyslog.h" |
| 31 |
|
| 32 |
#ifdef HAVE_LIBYAML |
| 33 |
|
| 34 |
/* Load a rsyslog configuration from a YAML file. |
| 35 |
* |
| 36 |
* fname - path to the .yaml / .yml config file |
| 37 |
* |
| 38 |
* Returns RS_RET_OK on success, RS_RET_CONF_FILE_NOT_FOUND if the file cannot |
| 39 |
* be opened, RS_RET_CONF_PARSE_ERROR on YAML or semantic errors. On error |
| 40 |
* LogError() is called with a descriptive message before returning. |
| 41 |
* |
| 42 |
* This function populates the global loadConf object (runtime/rsconf.c) by |
| 43 |
* calling cnfDoObj() / cnfDoScript() / cnfAddConfigBuffer() exactly as the |
| 44 |
* RainerScript yyparse() path does. The caller (rsconf.c::load()) must have |
| 45 |
* already called rsconfConstruct() before invoking this function. |
| 46 |
*/ |
| 47 |
rsRetVal yamlconf_load(const char *fname); |
| 48 |
|
| 49 |
#endif /* HAVE_LIBYAML */ |
| 50 |
|
| 51 |
#endif /* YAMLCONF_H_INCLUDED */ |