stumpless 2.2.0
Loading...
Searching...
No Matches
element.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: Apache-2.0 */
2
3/*
4 * Copyright 2018-2024 Joel E. Anderson
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
23#ifndef __STUMPLESS_ELEMENT_H
24# define __STUMPLESS_ELEMENT_H
25
26# include <stdbool.h>
27# include <stddef.h>
28# include <stumpless/config.h>
29# include <stumpless/entry.h>
30# include <stumpless/param.h>
31
33# define STUMPLESS_MAX_ELEMENT_NAME_LENGTH 32
34
35# ifdef __cplusplus
36extern "C" {
37# endif
38
39// this is required due to the circular dependency with the entry header.
40struct stumpless_entry;
41
42#ifdef STUMPLESS_JOURNALD_TARGETS_SUPPORTED
79typedef
80size_t
81( *stumpless_element_namer_func_t )( const struct stumpless_entry *entry,
82 size_t element_index,
83 char *destination,
84 size_t size );
85#endif
86
128#ifdef STUMPLESS_JOURNALD_TARGETS_SUPPORTED
132 stumpless_element_namer_func_t get_journald_name;
133#endif
134#ifdef STUMPLESS_THREAD_SAFETY_SUPPORTED
139 void *mutex;
140#endif
141};
142
176struct stumpless_element *
178 const char *param_name,
179 const char *param_value );
180
206struct stumpless_element *
208 struct stumpless_param *param );
209
240struct stumpless_element *
242
268void
270
292void
294
316void
318
346bool
348 const char *name );
349
376const char *
378
409const char *
411
437struct stumpless_param *
439 size_t index );
440
476struct stumpless_param *
478 const char *name );
479
503size_t
505
541size_t
543 const char *name );
544
579const char *
581 size_t index );
582
614size_t
616 const char *name );
617
652const char *
654 size_t index );
655
694const char *
696 const char *name );
697
735struct stumpless_element *
736stumpless_load_element( struct stumpless_element *element, const char *name );
737
760struct stumpless_element *
762
791struct stumpless_element *
793 const char *name );
794
830struct stumpless_element *
832 size_t index,
833 struct stumpless_param *param );
834
865struct stumpless_element *
867 size_t index,
868 const char *value );
869
908struct stumpless_element *
910 const char *name,
911 const char *value );
912
938void
940
967void
969
970
971# ifdef __cplusplus
972} /* extern "C" */
973# endif
974
975#endif /* __STUMPLESS_ELEMENT_H */
#define STUMPLESS_PUBLIC_FUNCTION
Marks functions that are provided for use by the library.
Definition config.h:31
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_element_to_string(const struct stumpless_element *element)
Returns name and params from element as a formatted string.
STUMPLESS_PUBLIC_FUNCTION void stumpless_destroy_element_and_contents(const struct stumpless_element *e)
Destroys an element as well as all params that it contains, freeing any allocated memory.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_element_name(const struct stumpless_element *element)
Returns the name of the given element.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_param_name_by_index(const struct stumpless_element *element, size_t index)
Gets the name of the param with the given index in this element.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_set_param_value_by_index(struct stumpless_element *element, size_t index, const char *value)
Sets the value of the param at the given index in the given element.
STUMPLESS_PUBLIC_FUNCTION void stumpless_unload_element_and_contents(const struct stumpless_element *e)
Unloads an element as well as all params that it contains.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_add_param(struct stumpless_element *element, struct stumpless_param *param)
Adds a param to an element.
STUMPLESS_PUBLIC_FUNCTION void stumpless_destroy_element_only(const struct stumpless_element *element)
Destroys an element, freeing any allocated memory.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_new_element(const char *name)
Creates a new element with the given name.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_add_new_param(struct stumpless_element *element, const char *param_name, const char *param_value)
Creates a new param and adds it to the given element.
STUMPLESS_PUBLIC_FUNCTION size_t stumpless_get_param_index(const struct stumpless_element *element, const char *name)
Gives the index of the first occurrence of a param with the given name in the given element.
STUMPLESS_PUBLIC_FUNCTION bool stumpless_element_has_param(const struct stumpless_element *element, const char *name)
True if the given element has a param with the given name, false otherwise.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_load_element(struct stumpless_element *element, const char *name)
Loads a provided element with the given name.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_param_value_by_name(const struct stumpless_element *element, const char *name)
Returns the value of the first param with the given name in the given element.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_set_param_value_by_name(struct stumpless_element *element, const char *name, const char *value)
Sets the value of the first param with the given name in the given element.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_set_element_name(struct stumpless_element *element, const char *name)
Sets the name of the given element.
STUMPLESS_PUBLIC_FUNCTION size_t stumpless_get_param_count(const struct stumpless_element *element)
Returns the number of params in the given element.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_copy_element(const struct stumpless_element *element)
Creates a copy of an element.
STUMPLESS_PUBLIC_FUNCTION size_t stumpless_get_param_name_count(const struct stumpless_element *element, const char *name)
Gives the number of params with the given name found in the given element.
STUMPLESS_PUBLIC_FUNCTION void stumpless_unload_element_only(const struct stumpless_element *element)
Unloads an element, freeing any allocated memory.
STUMPLESS_PUBLIC_FUNCTION void stumpless_destroy_element(const struct stumpless_element *element)
An alias for stumpless_destroy_element_and_contents.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_set_param(struct stumpless_element *element, size_t index, struct stumpless_param *param)
Puts the param at the given index in the given element.
#define STUMPLESS_MAX_ELEMENT_NAME_LENGTH
The maximum length of an element name, as specified by RFC 5424.
Definition element.h:33
STUMPLESS_PUBLIC_FUNCTION struct stumpless_param * stumpless_get_param_by_index(const struct stumpless_element *element, size_t index)
Returns the param in the given element at the specified index.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_param_value_by_index(const struct stumpless_element *element, size_t index)
Returns the value of the param at the given index in the given element.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_param * stumpless_get_param_by_name(const struct stumpless_element *element, const char *name)
Returns the first occurrence of a param with the given name in element, if it is found.
Types and functions for creating and modifying entries.
Types and functions for creating and modifying params.
An element of structured data.
Definition element.h:93
size_t name_length
The number of characters in name.
Definition element.h:116
char name[32+1]
The name of the element.
Definition element.h:114
size_t param_count
The number of params in the array.
Definition element.h:127
struct stumpless_param ** params
The parameters this element contains.
Definition element.h:125
A log entry.
Definition entry.h:60
A parameter within a structured data element.
Definition param.h:93
char name[32+1]
The name of the parameter.
Definition param.h:108