stumpless  2.1.0
entry.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_ENTRY_H
24 # define __STUMPLESS_ENTRY_H
25 
26 # include <stdarg.h>
27 # include <stdbool.h>
28 # include <stddef.h>
29 # include <stumpless/config.h>
30 # include <stumpless/element.h>
31 # include <stumpless/facility.h>
32 # include <stumpless/id.h>
33 # include <stumpless/param.h>
34 # include <stumpless/severity.h>
35 
37 #define STUMPLESS_MAX_PROCID_LENGTH 128
38 
40 #define STUMPLESS_MAX_HOSTNAME_LENGTH 255
41 
43 # define STUMPLESS_MAX_APP_NAME_LENGTH 48
44 
46 # define STUMPLESS_MAX_MSGID_LENGTH 32
47 
49 # define STUMPLESS_MAX_PARAM_NAME_LENGTH 32
50 
51 # ifdef __cplusplus
52 extern "C" {
53 # endif
54 
78  size_t procid_length;
96  int prival;
102  char *message;
108  size_t msgid_length;
113 # ifdef STUMPLESS_WINDOWS_EVENT_LOG_TARGETS_SUPPORTED
114 
115  void *wel_data;
116 # endif
117 # ifdef STUMPLESS_THREAD_SAFETY_SUPPORTED
118 
122  void *mutex;
123 # endif
124 };
125 
156 struct stumpless_entry *
158  struct stumpless_element *element );
159 
191 struct stumpless_entry *
193  const char *name );
194 
231 struct stumpless_entry *
233  const char *element_name,
234  const char *param_name,
235  const char *param_value );
236 
265 struct stumpless_entry *
266 stumpless_copy_entry( const struct stumpless_entry *entry );
267 
293 void
295 
317 void
319 
341 void
343 
371 bool
373  const char *name );
374 
401 struct stumpless_element *
403  size_t index );
404 
432 struct stumpless_element *
434  const char *name );
435 
459 size_t
461 
490 size_t
492  const char *name );
493 
525 const char *
527 
556 stumpless_get_entry_facility( const struct stumpless_entry *entry );
557 
585 const char *
587 
622 const char *
624 
656 const char *
658 
686 struct stumpless_param *
688  size_t element_index,
689  size_t param_index );
690 
726 struct stumpless_param *
728  const char *element_name,
729  const char *param_name );
730 
765 const char *
767  size_t element_index,
768  size_t param_index );
769 
811 const char *
813  const char *element_name,
814  const char *param_name );
815 
839 int
841 
869 const char *
871 
900 stumpless_get_entry_severity( const struct stumpless_entry *entry );
901 
952 struct stumpless_entry *
954  enum stumpless_severity severity,
955  const char *app_name,
956  const char *msgid,
957  const char *message,
958  ... );
959 
997 struct stumpless_entry *
999  enum stumpless_severity severity,
1000  const char *app_name,
1001  const char *msgid,
1002  const char *message );
1003 
1043 struct stumpless_entry *
1045  size_t index,
1046  struct stumpless_element *element );
1047 
1078 struct stumpless_entry *
1080  const char *app_name );
1081 
1111 struct stumpless_entry *
1113  enum stumpless_facility facility );
1114 
1141 struct stumpless_entry *
1143  const char *hostname );
1144 
1178 struct stumpless_entry *
1180  const char *msgid );
1181 
1221 struct stumpless_entry *
1223  const char *message,
1224  ... );
1225 
1255 struct stumpless_entry *
1257  const char *message );
1258 
1298 struct stumpless_entry *
1300  size_t element_index,
1301  size_t param_index,
1302  struct stumpless_param *param );
1303 
1336 struct stumpless_entry *
1338  size_t element_index,
1339  size_t param_index,
1340  const char *value );
1341 
1385 struct stumpless_entry *
1387  const char *element_name,
1388  const char *param_name,
1389  const char *value );
1390 
1423 struct stumpless_entry *
1425  enum stumpless_facility facility,
1426  enum stumpless_severity severity );
1427 
1455 struct stumpless_entry *
1457  int prival );
1458 
1485 struct stumpless_entry *
1486 stumpless_set_entry_procid( struct stumpless_entry *entry, const char *procid );
1487 
1517 struct stumpless_entry *
1519  enum stumpless_severity severity );
1520 
1568 struct stumpless_entry *
1570  enum stumpless_severity severity,
1571  const char *app_name,
1572  const char *msgid,
1573  const char *message,
1574  va_list subs );
1575 
1610 struct stumpless_entry *
1612  const char *message,
1613  va_list subs );
1614 
1615 # ifdef __cplusplus
1616 } /* extern "C" */
1617 # endif
1618 #endif /* __STUMPLESS_ENTRY_H */
STUMPLESS_MAX_PROCID_LENGTH
#define STUMPLESS_MAX_PROCID_LENGTH
The maximum length of a procid, as specified by RFC 5424.
Definition: entry.h:37
stumpless_set_entry_param_value_by_name
struct stumpless_entry * stumpless_set_entry_param_value_by_name(struct stumpless_entry *entry, const char *element_name, const char *param_name, const char *value)
Sets the value of the first param in the named element an entry.
stumpless_entry::id
stumpless_id_t id
A unique identifier of this entry.
Definition: entry.h:65
stumpless_severity
stumpless_severity
All possible severity codes available to log entries.
Definition: severity.h:185
facility.h
severity.h
stumpless_entry::wel_data
void * wel_data
A pointer to a wel_data structure.
Definition: entry.h:115
id.h
stumpless_get_entry_app_name
const char * stumpless_get_entry_app_name(const struct stumpless_entry *entry)
Returns the app name of the given entry.
stumpless_entry::prival
int prival
The prival of this entry.
Definition: entry.h:96
stumpless_set_entry_app_name
struct stumpless_entry * stumpless_set_entry_app_name(struct stumpless_entry *entry, const char *app_name)
Sets the app name for an entry.
stumpless_destroy_entry_and_contents
void stumpless_destroy_entry_and_contents(const struct stumpless_entry *entry)
Destroys an entry as well as all elements and params that it contains, freeing any allocated memory.
vstumpless_set_entry_message
struct stumpless_entry * vstumpless_set_entry_message(struct stumpless_entry *entry, const char *message, va_list subs)
Sets the message of a given entry.
stumpless_get_element_count
size_t stumpless_get_element_count(const struct stumpless_entry *entry)
Returns the number of elements in the given entry.
stumpless_set_entry_message_str
struct stumpless_entry * stumpless_set_entry_message_str(struct stumpless_entry *entry, const char *message)
Sets the message of a given entry.
stumpless_destroy_entry
void stumpless_destroy_entry(const struct stumpless_entry *entry)
An alias for stumpless_destroy_entry_and_contents.
stumpless_set_entry_param_value_by_index
struct stumpless_entry * stumpless_set_entry_param_value_by_index(struct stumpless_entry *entry, size_t element_index, size_t param_index, const char *value)
Sets the value of the param in the element at the given index of an entry.
stumpless_set_entry_facility
struct stumpless_entry * stumpless_set_entry_facility(struct stumpless_entry *entry, enum stumpless_facility facility)
Sets the facility of an entry.
stumpless_new_entry
struct stumpless_entry * stumpless_new_entry(enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message,...)
Creates a new entry with the given characteristics.
stumpless_get_entry_prival
int stumpless_get_entry_prival(const struct stumpless_entry *entry)
Returns the prival of the given entry, as defined in RFC 5424.
stumpless_param
A parameter within a structured data element.
Definition: param.h:90
stumpless_get_entry_message
const char * stumpless_get_entry_message(const struct stumpless_entry *entry)
Returns the message of the given entry.
stumpless_get_entry_msgid
const char * stumpless_get_entry_msgid(const struct stumpless_entry *entry)
Returns the msgid of the given entry.
stumpless_entry::elements
struct stumpless_element ** elements
An array holding the elements of this entry.
Definition: entry.h:110
stumpless_get_element_index
size_t stumpless_get_element_index(const struct stumpless_entry *entry, const char *name)
Returns the index of the element with the given name in this entry, if it is found.
stumpless_get_entry_hostname
const char * stumpless_get_entry_hostname(const struct stumpless_entry *entry)
Returns the hostname of a given entry.
stumpless_set_entry_severity
struct stumpless_entry * stumpless_set_entry_severity(struct stumpless_entry *entry, enum stumpless_severity severity)
Sets the severity of an entry.
vstumpless_new_entry
struct stumpless_entry * vstumpless_new_entry(enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message, va_list subs)
Creates a new entry with the given parameters.
STUMPLESS_MAX_APP_NAME_LENGTH
#define STUMPLESS_MAX_APP_NAME_LENGTH
The maximum length of an app name, as specified by RFC 5424.
Definition: entry.h:43
stumpless_add_new_element
struct stumpless_entry * stumpless_add_new_element(struct stumpless_entry *entry, const char *name)
Creates a new element with the given name and adds it to this entry.
STUMPLESS_MAX_HOSTNAME_LENGTH
#define STUMPLESS_MAX_HOSTNAME_LENGTH
The maximum length of a hostname, as specified by RFC 5424.
Definition: entry.h:40
stumpless_set_entry_priority
struct stumpless_entry * stumpless_set_entry_priority(struct stumpless_entry *entry, enum stumpless_facility facility, enum stumpless_severity severity)
Sets the facility and severity of an entry.
stumpless_element::name
char name[32+1]
The name of the element.
Definition: element.h:114
stumpless_get_entry_severity
enum stumpless_severity stumpless_get_entry_severity(const struct stumpless_entry *entry)
Returns the severity code of the given entry.
stumpless_add_element
struct stumpless_entry * stumpless_add_element(struct stumpless_entry *entry, struct stumpless_element *element)
Adds an element to an entry.
param.h
stumpless_entry::msgid_length
size_t msgid_length
The length of the message id, without the NULL terminator.
Definition: entry.h:108
stumpless_facility
stumpless_facility
All possible facility codes available to log entries.
Definition: facility.h:346
element.h
stumpless_destroy_entry_only
void stumpless_destroy_entry_only(const struct stumpless_entry *entry)
Destroys an entry, freeing any allocated memory.
stumpless_set_element
struct stumpless_entry * stumpless_set_element(struct stumpless_entry *entry, size_t index, struct stumpless_element *element)
Puts the element at the given index in the given entry.
stumpless_entry::app_name
char app_name[48+1]
The app name of this entry, as a NULL-terminated string.
Definition: entry.h:98
stumpless_get_entry_param_value_by_name
const char * stumpless_get_entry_param_value_by_name(const struct stumpless_entry *entry, const char *element_name, const char *param_name)
Gets the value of the first param from the element with the given name in an entry.
stumpless_get_element_by_name
struct stumpless_element * stumpless_get_element_by_name(const struct stumpless_entry *entry, const char *name)
Returns the element with the given name in this entry, if it is found.
stumpless_copy_entry
struct stumpless_entry * stumpless_copy_entry(const struct stumpless_entry *entry)
Creates a copy of an entry.
stumpless_entry::procid_length
size_t procid_length
The length of the procid of this entry (in bytes), without a NULL terminator.
Definition: entry.h:78
stumpless_entry::message_length
size_t message_length
The length of the message in bytes, without the NULL terminator.
Definition: entry.h:104
stumpless_id_t
void * stumpless_id_t
Definition: id.h:30
stumpless_entry::message
char * message
The message of this entry, as a NULL-terminated string.
Definition: entry.h:102
stumpless_new_entry_str
struct stumpless_entry * stumpless_new_entry_str(enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message)
Creates a new entry with the given characteristics.
STUMPLESS_PUBLIC_FUNCTION
#define STUMPLESS_PUBLIC_FUNCTION
Marks functions that are provided for use by the library.
Definition: config.h:31
stumpless_entry::app_name_length
size_t app_name_length
The length of the app name, without the NULL terminator.
Definition: entry.h:100
stumpless_set_entry_procid
struct stumpless_entry * stumpless_set_entry_procid(struct stumpless_entry *entry, const char *procid)
Sets the procid of a given entry.
stumpless_entry::element_count
size_t element_count
The number of elements in this entry.
Definition: entry.h:112
config.h
stumpless_set_entry_param_by_index
struct stumpless_entry * stumpless_set_entry_param_by_index(struct stumpless_entry *entry, size_t element_index, size_t param_index, struct stumpless_param *param)
Puts the param in the element at the given index of an entry.
stumpless_get_entry_param_value_by_index
const char * stumpless_get_entry_param_value_by_index(const struct stumpless_entry *entry, size_t element_index, size_t param_index)
Gets the value of the param from the element at the given index in an entry.
stumpless_set_entry_prival
struct stumpless_entry * stumpless_set_entry_prival(struct stumpless_entry *entry, int prival)
Sets the prival of an entry, as defined in RFC 5424.
stumpless_entry
A log entry.
Definition: entry.h:63
stumpless_entry::mutex
void * mutex
A pointer to a mutex which protects all entry fields.
Definition: entry.h:122
stumpless_entry::msgid
char msgid[32+1]
The message id of this entry, as a NULL-terminated string.
Definition: entry.h:106
stumpless_get_entry_param_by_name
struct stumpless_param * stumpless_get_entry_param_by_name(const struct stumpless_entry *entry, const char *element_name, const char *param_name)
Gets the first param from the element with the given name in an entry.
stumpless_entry::hostname_length
size_t hostname_length
The length of the hostname of this entry (in bytes), without a NULL terminator.
Definition: entry.h:91
STUMPLESS_MAX_MSGID_LENGTH
#define STUMPLESS_MAX_MSGID_LENGTH
The maximum length of a msgid, as specified by RFC 5424.
Definition: entry.h:46
stumpless_set_entry_msgid
struct stumpless_entry * stumpless_set_entry_msgid(struct stumpless_entry *entry, const char *msgid)
Sets the msgid for an entry.
stumpless_element
An element of structured data.
Definition: element.h:93
stumpless_add_new_param_to_entry
struct stumpless_entry * stumpless_add_new_param_to_entry(struct stumpless_entry *entry, const char *element_name, const char *param_name, const char *param_value)
Creates a new param and adds it to the given element in the given entry.
stumpless_entry_has_element
bool stumpless_entry_has_element(const struct stumpless_entry *entry, const char *name)
True if the given entry has an element with the given name, false otherwise.
stumpless_get_entry_param_by_index
struct stumpless_param * stumpless_get_entry_param_by_index(const struct stumpless_entry *entry, size_t element_index, size_t param_index)
Gets the param from the element at the given index in an entry.
stumpless_entry::hostname
char hostname[255+1]
The hostname of this entry, as a NULL-terminated string.
Definition: entry.h:84
stumpless_entry::procid
char procid[128+1]
The procid of this entry, as a NULL-terminated string.
Definition: entry.h:71
stumpless_get_entry_procid
const char * stumpless_get_entry_procid(const struct stumpless_entry *entry)
Returns the procid of a given entry.
stumpless_set_entry_hostname
struct stumpless_entry * stumpless_set_entry_hostname(struct stumpless_entry *entry, const char *hostname)
Sets the hostname of a given entry.
stumpless_set_entry_message
struct stumpless_entry * stumpless_set_entry_message(struct stumpless_entry *entry, const char *message,...)
Sets the message of a given entry.
stumpless_get_entry_facility
enum stumpless_facility stumpless_get_entry_facility(const struct stumpless_entry *entry)
Returns the facility code of the given entry.
stumpless_get_element_by_index
struct stumpless_element * stumpless_get_element_by_index(const struct stumpless_entry *entry, size_t index)
Returns the element at the given index in this Entry.