conf-parse.h (2383B)
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20#ifndef _GUACD_CONF_PARSE_H 21#define _GUACD_CONF_PARSE_H 22 23/** 24 * The maximum length of a name, in characters. 25 */ 26#define GUACD_CONF_MAX_NAME_LENGTH 255 27 28/** 29 * The maximum length of a value, in characters. 30 */ 31#define GUACD_CONF_MAX_VALUE_LENGTH 8191 32 33/** 34 * A callback function which is provided to guacd_parse_conf() and is called 35 * for each parameter/value pair set. The current section is always given. This 36 * function will not be called for parameters outside of sections, which are 37 * illegal. 38 */ 39typedef int guacd_param_callback(const char* section, const char* param, const char* value, void* data); 40 41/** 42 * Parses an arbitrary buffer of configuration file data, calling the given 43 * callback for each valid parameter/value pair. Upon success, the number of 44 * characters parsed is returned. On failure, a negative value is returned, and 45 * guacd_conf_parse_error and guacd_conf_parse_error_location are set. The 46 * provided data will be passed to the callback for each invocation. 47 */ 48int guacd_parse_conf(guacd_param_callback* callback, char* buffer, int length, void* data); 49 50/** 51 * Parses the given level name, returning the corresponding log level, or -1 if 52 * no such log level exists. 53 */ 54int guacd_parse_log_level(const char* name); 55 56/** 57 * Human-readable description of the current error, if any. 58 */ 59extern char* guacd_conf_parse_error; 60 61/** 62 * The location of the most recent parse error. This will be a pointer to the 63 * location of the error within the buffer passed to guacd_parse_conf(). 64 */ 65extern char* guacd_conf_parse_error_location; 66 67#endif 68