stumpless  2.1.0
param.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0 */
2 
3 /*
4  * Copyright 2018-2022 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_PARAM_H
24 # define __STUMPLESS_PARAM_H
25 
26 # include <stddef.h>
27 # include <stumpless/config.h>
28 # include <stumpless/entry.h>
29 
30 # ifdef __cplusplus
31 extern "C" {
32 # endif
33 
34 // this is required due to the circular dependency with the entry header.
35 struct stumpless_entry;
36 
37 #ifdef STUMPLESS_JOURNALD_TARGETS_SUPPORTED
38 
76 typedef
77 size_t
78 ( *stumpless_param_namer_func_t )( const struct stumpless_entry *entry,
79  size_t element_index,
80  size_t param_index,
81  char *destination,
82  size_t size );
83 #endif
84 
105  char *name;
107  size_t name_length;
122  char *value;
124  size_t value_length;
125 # ifdef STUMPLESS_JOURNALD_TARGETS_SUPPORTED
126 
128 # endif
129 # ifdef STUMPLESS_THREAD_SAFETY_SUPPORTED
130 
134  void *mutex;
135 # endif
136 };
137 
161 struct stumpless_param *
162 stumpless_copy_param( const struct stumpless_param *param );
163 
184 void
186 
217 const char *
219 
250 const char *
252 
276 struct stumpless_param *
277 stumpless_new_param( const char *name, const char *value );
278 
306 struct stumpless_param *
307 stumpless_set_param_name( struct stumpless_param *param, const char *name );
308 
336 struct stumpless_param *
337 stumpless_set_param_value( struct stumpless_param *param, const char *value );
338 
339 
366 const char *
368 
369 # ifdef __cplusplus
370 } /* extern "C" */
371 # endif
372 
373 #endif /* __STUMPLESS_PARAM_H */
stumpless_set_param_name
struct stumpless_param * stumpless_set_param_name(struct stumpless_param *param, const char *name)
Sets the name of the given param.
stumpless_param::name_length
size_t name_length
The number of characters in name (not including the NULL character).
Definition: param.h:107
stumpless_param::name
char * name
The name of the parameter.
Definition: param.h:105
stumpless_param_namer_func_t
size_t(* stumpless_param_namer_func_t)(const struct stumpless_entry *entry, size_t element_index, size_t param_index, char *destination, size_t size)
Gets the name to use for the journald field corresponding to this param.
Definition: param.h:78
stumpless_param_to_string
const char * stumpless_param_to_string(const struct stumpless_param *param)
Returns the name and the value from param as a formatted string.
stumpless_param::get_journald_name
stumpless_param_namer_func_t get_journald_name
Gets the name to use for the journald field corresponding to this param.
Definition: param.h:127
stumpless_get_param_name
const char * stumpless_get_param_name(const struct stumpless_param *param)
Returns the name of the given param.
stumpless_param
A parameter within a structured data element.
Definition: param.h:90
stumpless_param::value_length
size_t value_length
The number of characters in value (not including the NULL character).
Definition: param.h:124
entry.h
stumpless_new_param
struct stumpless_param * stumpless_new_param(const char *name, const char *value)
Creates a new param with the given name and value.
stumpless_param::mutex
void * mutex
A pointer to a mutex which protects all target fields.
Definition: param.h:134
stumpless_param::value
char * value
The value may be any UTF-8 string.
Definition: param.h:122
stumpless_get_param_value
const char * stumpless_get_param_value(const struct stumpless_param *param)
Returns the value of the given param.
stumpless_set_param_value
struct stumpless_param * stumpless_set_param_value(struct stumpless_param *param, const char *value)
Sets the value of the given param.
stumpless_destroy_param
void stumpless_destroy_param(const struct stumpless_param *param)
Destroys a param, freeing any allocated memory.
stumpless_copy_param
struct stumpless_param * stumpless_copy_param(const struct stumpless_param *param)
Creates a copy of a param.
STUMPLESS_PUBLIC_FUNCTION
#define STUMPLESS_PUBLIC_FUNCTION
Marks functions that are provided for use by the library.
Definition: config.h:31
config.h
stumpless_entry
A log entry.
Definition: entry.h:63