aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2019-05-14 16:05:27 +0200
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2019-05-14 16:05:27 +0200
commit1902eed479506d650cc1f0e310bfd5f971dde086 (patch)
tree39e18d90c10ca368bfba5c454504b2eebfce3fbc
parent537b59e3e1a064c96042d75180a851f411b4a4a0 (diff)
downloadembedlog-1902eed479506d650cc1f0e310bfd5f971dde086.tar.gz
embedlog-1902eed479506d650cc1f0e310bfd5f971dde086.tar.bz2
embedlog-1902eed479506d650cc1f0e310bfd5f971dde086.zip
API change: rename "struct el_options" to "struct el"
Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rw-r--r--examples/print-options.c8
-rw-r--r--include/embedlog.h.in28
-rw-r--r--man/el_cleanup.38
-rw-r--r--man/el_flush.38
-rw-r--r--man/el_init.346
-rw-r--r--man/el_option.320
-rw-r--r--man/el_overview.741
-rw-r--r--man/el_print.326
-rw-r--r--src/el-file.c188
-rw-r--r--src/el-flush.c24
-rw-r--r--src/el-options.c142
-rw-r--r--src/el-pbinary.c48
-rw-r--r--src/el-perror.c48
-rw-r--r--src/el-pmemory.c86
-rw-r--r--src/el-print.c141
-rw-r--r--src/el-private.h22
-rw-r--r--src/el-puts.c68
-rw-r--r--src/el-syslog.c36
-rw-r--r--src/el-ts.c26
-rw-r--r--src/el-tty.c38
-rw-r--r--tst/test-el-options.c202
-rw-r--r--tst/test-el-pbinary.c6
-rw-r--r--tst/test-el-perror.c17
-rw-r--r--tst/test-el-print.c42
24 files changed, 661 insertions, 658 deletions
diff --git a/examples/print-options.c b/examples/print-options.c
index 4af370f..72269c4 100644
--- a/examples/print-options.c
+++ b/examples/print-options.c
@@ -16,7 +16,7 @@ void too_long_function_to_present_trimming_but_it_could_be_impossible()
int main(void)
{
- struct el_options opts;
+ struct el opts;
el_init();
@@ -66,7 +66,7 @@ int main(void)
el_option(EL_TS, EL_TS_LONG);
el_option(EL_TS_TM, EL_TS_TM_REALTIME);
el_option(EL_PRINT_LEVEL, 1);
- el_print(ELF, "Different scenarios need different options");
+ el_print(ELF, "Different scenarios need different el object");
el_print(ELA, "So we can mix options however we want");
el_option(EL_PRINT_NL, 0);
@@ -99,9 +99,9 @@ int main(void)
el_oinit(&opts);
el_ooption(&opts, EL_OUT, EL_OUT_STDERR);
el_oprint(ELI, &opts, "you can do same thing as about with custom");
- el_oprint(ELI, &opts, "options object for two or more logger.");
+ el_oprint(ELI, &opts, "el object for two or more logger.");
el_oprint(OELE, "and if you define EL_OPTIONS_OBJECT you will be");
- el_oprint(OELF, "able to print messages without passing options");
+ el_oprint(OELF, "able to print messages without passing el object");
el_oprint(OELW, "each time to print functions");
el_ocleanup(&opts);
}
diff --git a/include/embedlog.h.in b/include/embedlog.h.in
index 524956a..53525bb 100644
--- a/include/embedlog.h.in
+++ b/include/embedlog.h.in
@@ -170,7 +170,7 @@ enum el_option_timestamp_fractions
typedef int (*el_custom_puts)(const char *s, void *user);
-struct el_options
+struct el
{
unsigned int outputs:7;
unsigned int colors:1;
@@ -216,30 +216,30 @@ int el_perror(const char *file, size_t line, const char *func,
enum el_level level, const char *fmt, ...);
int el_putb(const void *memory, size_t mlen);
int el_pbinary(enum el_level level, const void *memory, size_t mlen);
-const struct el_options *el_get_options(void);
+const struct el *el_get_el(void);
int el_flush(void);
-int el_oinit(struct el_options *options);
-int el_ocleanup(struct el_options *options);
-int el_ooption(struct el_options *options, int option, ...);
-int el_oputs(struct el_options *options, const char *string);
+int el_oinit(struct el *el);
+int el_ocleanup(struct el *el);
+int el_ooption(struct el *el, int option, ...);
+int el_oputs(struct el *el, const char *string);
int el_oprint(const char *file, size_t line, const char *func,
- enum el_level level, struct el_options *options, const char *fnt, ...);
+ enum el_level level, struct el *el, const char *fnt, ...);
int el_ovprint(const char *file, size_t line, const char *func,
- enum el_level level, struct el_options *options, const char *fmt,
+ enum el_level level, struct el *el, const char *fmt,
va_list ap);
int el_opmemory(const char *file, size_t line, const char *func,
- enum el_level level, struct el_options *options, const void *memory,
+ enum el_level level, struct el *el, const void *memory,
size_t mlen);
int el_opmemory_table(const char *file, size_t line, const char *func,
- enum el_level level, struct el_options *options, const void *memory,
+ enum el_level level, struct el *el, const void *memory,
size_t mlen);
int el_operror(const char *file, size_t line, const char *func,
- enum el_level level, struct el_options *options, const char *fmt, ...);
-int el_oputb(struct el_options *options, const void *memory, size_t mlen);
-int el_opbinary(enum el_level level, struct el_options *options,
+ enum el_level level, struct el *el, const char *fmt, ...);
+int el_oputb(struct el *el, const void *memory, size_t mlen);
+int el_opbinary(enum el_level level, struct el *el,
const void *memory, size_t mlen);
-int el_oflush(struct el_options *options);
+int el_oflush(struct el *el);
#ifdef __cplusplus
}
diff --git a/man/el_cleanup.3 b/man/el_cleanup.3
index 04dfd5e..20ff67e 100644
--- a/man/el_cleanup.3
+++ b/man/el_cleanup.3
@@ -13,7 +13,7 @@ calls.
.PP
.BI "int el_cleanup(void)"
.br
-.BI "int el_ocleanup(struct el_options *" options ")"
+.BI "int el_ocleanup(struct el *" el ")"
.SH DESCRIPTION
.PP
.BR el_cleanup (3)
@@ -23,8 +23,8 @@ After clean up, library calls cannot be used without initialization.
.PP
.BR el_ocleanup (3)
works just the same, but accepts custom
-.I options
-as argument.
+.I el
+object as argument.
.SH RETURN VALUE
.PP
Functions return 0 upon successful cleanup or -1 on errors.
@@ -38,7 +38,7 @@ function cannot fail.
may return:
.TP
.B EINVAL
-Passed options object is not valid
+Passed el object is not valid
.SH SEE ALSO
.PP
.BR el_init (3),
diff --git a/man/el_flush.3 b/man/el_flush.3
index f8d37b5..3ae99b2 100644
--- a/man/el_flush.3
+++ b/man/el_flush.3
@@ -9,7 +9,7 @@
.PP
.BI "int el_flush(void)"
.br
-.BI "int el_oflush(struct el_options *" options ")"
+.BI "int el_oflush(struct el *" el ")"
.SH DESCRIPTION
.PP
.B embedlog
@@ -38,8 +38,8 @@ This applies to files, but also to logs with network output.
.PP
.BR el_oflush (3)
works just the same, but accepts custom
-.I options
-as argument.
+.I el
+object as argument.
.SH RETURN VALUE
.PP
Functions return 0 upon successful flush or -1 on errors.
@@ -59,7 +59,7 @@ and/or
may additionally return:
.TP
.B EINVAL
-Passed options object is not valid
+Passed el object is not valid
.SH SEE ALSO
.PP
.BR el_init (3),
diff --git a/man/el_init.3 b/man/el_init.3
index 8575845..34dfb83 100644
--- a/man/el_init.3
+++ b/man/el_init.3
@@ -2,29 +2,29 @@
.SH NAME
.PP
.B el_init
-- initializes library and options for printing.
+- initializes library and el for printing.
.SH SYNOPSIS
.PP
.B "#include <embedlog.h>"
.PP
.BI "int el_init(void)"
.br
-.BI "int el_oinit(struct options *" options ")"
+.BI "int el_oinit(struct el *" el ")"
.SH DESCRIPTION
.PP
There are two types of functions in
.BR embedlog.
Functions that use global static structure inside library, these functions don't
accept
-.I options
-argument.
+.I el
+argument with options.
.PP
-Another type are functions that accept
-.I options
+Another type are functions that accept additional
+.I el
argument. These functions are prefixed with
.BR el_o .
.PP
-All functions (options or not) are "line" thread-safe (provided that
+All functions (el_o or not) are "line" thread-safe (provided that
.B \-\-enable\-reentrant
is turned on).
That means library buffers whole line before it calls
@@ -47,19 +47,19 @@ implementation in your operating system.
.BR el_init (3)
initializes static global option structure. This option structure is used by all
functions that don't accept
-.I options
-parameter.
+.I el
+object parameter.
If you want to use only one instance of
.BR embedlog ,
this is the function you want to use.
.PP
.BR el_oinit (3)
initializes only
-.I options
-structure passed to it.
+.I el
+struct passed to it.
Functions that accepts
-.I options
-may be used.
+.I el
+object may be used.
If you want to have multiple embedlog instances (ie. one for program logs,
and one for queries) that stores logs differently - this is the function you
want to use.
@@ -69,8 +69,8 @@ Both functions will return 0 upon success and -1 on errors.
.SH ERRORS
.TP
.B EINVAL
-.I options
-is invalid (null).
+.I el
+object is invalid (null).
.SH EXAMPLE
.PP
Note: error handling has been ommited for clarity sake
@@ -80,22 +80,22 @@ Note: error handling has been ommited for clarity sake
int main(void)
{
- struct el_options opts;
+ struct el el;
- /* initialize both default and opts */
+ /* initialize both default and custom el objects */
el_init();
- el_oinit(&opts);
+ el_oinit(&el);
- /* make opts to print to file and stderr */
- el_ooption(&opts, EL_OUT, EL_OUT_FILE | EL_OUT_STDERR);
- el_ooption(&opts, EL_FPATH, "/tmp/test.log");
+ /* make el to print to file and stderr */
+ el_ooption(&el, EL_OUT, EL_OUT_FILE | EL_OUT_STDERR);
+ el_ooption(&el, EL_FPATH, "/tmp/test.log");
/* print messages */
el_print(ELI, "will print to stderr");
- el_oprint(ELI, &opts, "will print to file /tmp/test.log and stderr");
+ el_oprint(ELI, &el, "will print to file /tmp/test.log and stderr");
/* cleanup after any initialization code (like fopen) */
- el_ocleanup(&opts);
+ el_ocleanup(&el);
el_cleanup();
return 0;
diff --git a/man/el_option.3 b/man/el_option.3
index abd1d53..511a1a5 100644
--- a/man/el_option.3
+++ b/man/el_option.3
@@ -9,21 +9,21 @@
.PP
.BI "int el_option(enum el_option " option ", " ... ")"
.br
-.B const struct el_options *el_get_options(void)
+.B const struct el *el_get_el(void)
.br
-.BI "int el_ooption(struct el_options *" options ", \
+.BI "int el_ooption(struct el *" el ", \
enum el_option " option ", " ... ")"
.SH DESCRIPTION
.PP
.BR el_option (3)
-allows user to configure logger's internal options, to tune logging to users
+allows user to configure logger's internal el object, to tune logging to users
needs.
.PP
-.BR el_get_options (3)
+.BR el_get_el (3)
allows user to get pointer to global embedlog object - that is used by all
embedlog functions that don't accept
-.I options
-object - to directly read its options.
+.I el
+object - to directly read its fields.
.SH OPTIONS
.PP
Below is a list of
@@ -254,7 +254,7 @@ Input argument is invalid
. PP
. B ENOSYS
. RS
-Timestamp support was not compiled in and setting this options is disabled
+Timestamp support was not compiled in and setting this option is disabled.
. RE
. RE
.RE
@@ -332,7 +332,7 @@ Specified timer source was not compiled in and is not available
.PP
.BI "EL_TS_FRACT (" enum " " el_option_timestamp_fraction " fraction)
.RS
-This options controls how to display fractions of seconds.
+This option controls how to display fractions of seconds.
If high resolution is not needed or not supported, it's best to set this to
lowest resolution possible.
Table will show exacly what this is about.
@@ -425,8 +425,8 @@ ie. stderr or another facility.
.I user
pointer can be used to pass own logger object where data shall be sent.
For example it may contain pointer to
-.B el_options
-struct, if you don't use global options struct.
+.B el
+struct, if you don't use global el struct.
Function cannot fail. If NULL is passed, custom function won't be called.
It is still mandatory to enable custom printing with
. BR el_option (3)
diff --git a/man/el_overview.7 b/man/el_overview.7
index 1cd4ffa..cb9813e 100644
--- a/man/el_overview.7
+++ b/man/el_overview.7
@@ -96,53 +96,53 @@ size_t " mlen ")
.br
.BI "int el_flush(void)"
.br
-.B const struct el_options *el_get_options(void)
+.B const struct el *el_get_el(void)
.PP
-Each functions has its equivalent function but accepting
-.I options
-as argument.
+Each functions has its equivalent function that accepts
+.I el
+object as argument.
This is helpful if we want to have more than one, separated loggers in a single
program.
Please see
.BR el_option (3)
for more information.
.PP
-.BI "int el_oinit(struct el_options *" options ")"
+.BI "int el_oinit(struct el *" el ")"
.br
-.BI "int el_ocleanup(struct el_options *" options ")"
+.BI "int el_ocleanup(struct el *" el ")"
.br
-.BI "int el_ooption(struct el_options *" options ", enum el_option " option ", \
+.BI "int el_ooption(struct el *" el ", enum el_option " option ", \
\&...)"
.br
-.BI "int el_oputs(struct el_options *" options ", const char *" string ")"
+.BI "int el_oputs(struct el *" el ", const char *" string ")"
.br
-.BI "int el_oputb(struct el_options *" options ", const void *" memory ", \
+.BI "int el_oputb(struct el *" el ", const void *" memory ", \
size_t " mlen ")"
.br
.BI "int el_oprint(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const char *" fmt ", " ... ")"
.br
.BI "int el_ovprint(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const char *" fmt ", va_list " ap ")"
.br
.BI "int el_operror(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const char *" fmt ", " ... ")"
.br
.BI "int el_opmemory(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const void *" memory ", size_t " mlen ")"
.br
.BI "int el_opmemory_table(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const void *" memory ", size_t " mlen ")"
.br
-.BI "int el_opbinary(enum el_level " level ", struct el_options *" options ", \
+.BI "int el_opbinary(enum el_level " level ", struct el *" el ", \
const void *" memory ", size_t " mlen ")"
.br
-.BI "int el_oflush(struct el_options *" options ")"
+.BI "int el_oflush(struct el *" el ")"
.PP
For more information about a function open manual page with functions name from
section 3 (ie. for el_oputs, you'd open
@@ -187,8 +187,11 @@ You can simply call it like
el_print(ELN, "Notice message");
.EE
.PP
-There are also equivalent macros for use with functions that also accepts
-.IR options .
+There are also equivalent macros for use with functions that also provides
+.I el
+object, so the can be used with
+.B el_o
+function family.
To make these work, you need to provide
.B EL_OPTIONS_OBJECT
macro.
@@ -233,7 +236,7 @@ You can simply call it like
.PP
Initial setup is very trivial.
One should call init function and it will print to stderr by default.
-Output can also be customized with proper options, see
+Output can also be customized with proper el object, see
.BR el_option (3)
for more details.
.PP
diff --git a/man/el_print.3 b/man/el_print.3
index bd4026f..26ed93e 100644
--- a/man/el_print.3
+++ b/man/el_print.3
@@ -36,32 +36,32 @@ size_t " mlen ")
.BI "int el_pbinary(enum el_level " level ", const void *" memory", \
size_t " mlen ")
.PP
-.BI "int el_oputs(struct el_options *" options ", const char *" message ")"
+.BI "int el_oputs(struct el *" el ", const char *" message ")"
.br
-.BI "int el_oputb(struct el_options *" options ", const void *" memory ", \
+.BI "int el_oputb(struct el *" el ", const void *" memory ", \
size_t " mlen ")"
.br
.BI "int el_oprint(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const char *" fmt ", " ... ")"
.br
.BI "int el_ovprint(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const char *" fmt ", va_list " ap ")"
.br
.BI "int el_operror(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const char *" fmt ", " ... ")"
.br
.BI "int el_opmemory(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const void *" memory ", size_t " mlen ")"
.br
.BI "int el_opmemory_table(const char *" file ", size_t " line ", \
-const char *" func ", enum el_level " level ", struct el_options *" options ", \
+const char *" func ", enum el_level " level ", struct el *" el ", \
const void *" memory ", size_t " mlen ")"
.br
-.BI "int el_opbinary(enum el_level " level ", struct el_options *" options ", \
+.BI "int el_opbinary(enum el_level " level ", struct el *" el ", \
const void *" memory ", size_t " mlen ")"
.PP
.BI "#define ELF " __FILE__ ", " __LINE__ ", " EL_FUNC_NAME ", " EL_FATAL
@@ -323,7 +323,9 @@ that is first byte is always the least significant byte.
.B data
is be whatever you want of any size.
.BR el_pbinary (3)
-uses only timestamp and log level, rest of the options are simply ignores.
+uses only timestamp and log level, rest of the options in
+.I el
+are simply ignores.
.PP
.BR el_print (3),
.BR el_vprint (3),
@@ -335,7 +337,7 @@ are filtered based on their
.IR level .
.PP
All of above functions have their counterpart that also accepts custom
-.I options
+.I el
object.
This is useful if we want for example, print logs into one file, and program
queries into another.
@@ -356,7 +358,7 @@ It usually is used with
keyword like
.PP
.nf
- extern struct el_options log_foobar;
+ extern struct el log_foobar;
#define EL_OPTIONS_OBJECT &log_foobar
.fi
.PP
@@ -420,7 +422,7 @@ will be unconditionally set to
and
.B 0
and no file information will be printed - even if it was enabled with
-.BR el_options (3).
+.BR el_option (3).
.PP
If user has access to
.B c99
diff --git a/src/el-file.c b/src/el-file.c
index cd8de68..6f9644f 100644
--- a/src/el-file.c
+++ b/src/el-file.c
@@ -186,21 +186,21 @@ static int el_file_exists
static int el_file_rotate
(
- struct el_options *options
+ struct el *el
)
{
- unsigned int i; /* simple iterator for loop */
+ unsigned int i; /* simple iterator for loop */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- if (options->file)
+ if (el->file)
{
- fclose(options->file);
- options->file = NULL;
+ fclose(el->file);
+ el->file = NULL;
}
- options->fcurrent_rotate++;
- if (options->fcurrent_rotate == options->frotate_number)
+ el->fcurrent_rotate++;
+ if (el->fcurrent_rotate == el->frotate_number)
{
/*
* it appears we used all rotating slots, reset counter and rename
@@ -214,9 +214,9 @@ static int el_file_rotate
* disapear making space for new log
*/
- options->fcurrent_rotate = options->frotate_number - 1;
+ el->fcurrent_rotate = el->frotate_number - 1;
- if (options->frotate_number == 1)
+ if (el->frotate_number == 1)
{
/*
* if frotate_number is equal to 1, this means only one file can
@@ -228,7 +228,7 @@ static int el_file_rotate
goto skip_rotate;
}
- for (i = 1; i != options->frotate_number; ++i)
+ for (i = 1; i != el->frotate_number; ++i)
{
char old_name[PATH_MAX + 1]; /* ie .2 suffix */
char new_name[PATH_MAX + 1]; /* ie .3 suffix */
@@ -241,8 +241,8 @@ static int el_file_rotate
* here as well
*/
- sprintf(old_name, "%s.%d", options->fname, i);
- sprintf(new_name, "%s.%d", options->fname, i - 1);
+ sprintf(old_name, "%s.%d", el->fname, i);
+ sprintf(new_name, "%s.%d", el->fname, i - 1);
rename(old_name, new_name);
@@ -267,16 +267,16 @@ skip_rotate:
* passes there, it will pass here as well
*/
- sprintf(options->current_log, "%s.%d",
- options->fname, options->fcurrent_rotate);
+ sprintf(el->current_log, "%s.%d",
+ el->fname, el->fcurrent_rotate);
- if ((options->file = fopen(options->current_log, "w")) == NULL)
+ if ((el->file = fopen(el->current_log, "w")) == NULL)
{
- options->fcurrent_rotate--;
+ el->fcurrent_rotate--;
return -1;
}
- options->fpos = 0;
+ el->fpos = 0;
return 0;
}
@@ -299,34 +299,34 @@ skip_rotate:
/* ==========================================================================
- opens log file specified in options and sets file position, so we can
+ opens log file specified in el and sets file position, so we can
track it.
========================================================================== */
int el_file_open
(
- struct el_options *options /* options with file information */
+ struct el *el /* el object with file information */
)
{
- if (options->current_log == NULL)
+ if (el->current_log == NULL)
{
/*
* yes, we need to dynamically allocate memory here. It's because we
- * need to keep current log privately in each of el_options objects
+ * need to keep current log privately in each of el_el objects
* or there will be problems in embedded systems that use flat
* memory. Since when working with files, OS will always make some
* dynamic allocation, we will be doing one too.
*/
- if ((options->current_log = malloc(PATH_MAX + 1)) == NULL)
+ if ((el->current_log = malloc(PATH_MAX + 1)) == NULL)
{
errno = ENOMEM;
return -1;
}
}
- if (options->file)
+ if (el->file)
{
/*
* to prevent any memory leak in case of double open, we first
@@ -334,11 +334,11 @@ int el_file_open
* user changes file name using EL_FPATH option,
*/
- fclose(options->file);
- options->file = NULL;
+ fclose(el->file);
+ el->file = NULL;
}
- if (options->frotate_number)
+ if (el->frotate_number)
{
FILE *f; /* opened file */
int i; /* simple interator for loop */
@@ -354,10 +354,10 @@ int el_file_open
* if there are less files).
*/
- for (i = options->frotate_number - 1; i >= 0; --i)
+ for (i = el->frotate_number - 1; i >= 0; --i)
{
- pathl = snprintf(options->current_log, PATH_MAX + 1, "%s.%d",
- options->fname, i);
+ pathl = snprintf(el->current_log, PATH_MAX + 1, "%s.%d",
+ el->fname, i);
if (pathl > PATH_MAX)
{
@@ -367,7 +367,7 @@ int el_file_open
* could result in some data lose on the disk.
*/
- options->current_log[0] = '\0';
+ el->current_log[0] = '\0';
errno = ENAMETOOLONG;
return -1;
}
@@ -386,7 +386,7 @@ int el_file_open
* thus this path is not taken in such case.
*/
- if (el_file_exists(options->current_log) == 0)
+ if (el_file_exists(el->current_log) == 0)
{
/*
* current log file does not exist, this is not the file
@@ -396,7 +396,7 @@ int el_file_open
continue;
}
- if (stat(options->current_log, &st) != 0)
+ if (stat(el->current_log, &st) != 0)
{
/*
* error while stating file, probably don't have access
@@ -405,7 +405,7 @@ int el_file_open
* exit with error from stat.
*/
- options->current_log[0] = '\0';
+ el->current_log[0] = '\0';
return -1;
}
@@ -419,7 +419,7 @@ int el_file_open
* doesn't botter us later
*/
- remove(options->current_log);
+ remove(el->current_log);
continue;
}
}
@@ -429,7 +429,7 @@ int el_file_open
* a day
*/
- if ((f = fopen(options->current_log, "a")) == NULL)
+ if ((f = fopen(el->current_log, "a")) == NULL)
{
/*
* couldn't open file, probably directory doesn't exist, or
@@ -450,7 +450,7 @@ int el_file_open
#else /* HAVE_STAT */
- if ((f = fopen(options->current_log, "a")) == NULL)
+ if ((f = fopen(el->current_log, "a")) == NULL)
{
/*
* if we cannot open file, that means there is some kind of
@@ -458,7 +458,7 @@ int el_file_open
* it's pointless to continue
*/
- options->current_log[0] = '\0';
+ el->current_log[0] = '\0';
return -1;
}
@@ -478,9 +478,9 @@ int el_file_open
* simply return from the function
*/
- options->fcurrent_rotate = i;
- options->fpos = ftell(f);
- options->file = f;
+ el->fcurrent_rotate = i;
+ el->fpos = ftell(f);
+ el->file = f;
return 0;
}
@@ -494,7 +494,7 @@ int el_file_open
*/
fclose(f);
- remove(options->current_log);
+ remove(el->current_log);
continue;
}
@@ -505,9 +505,9 @@ int el_file_open
* from the function
*/
- options->fcurrent_rotate = i;
- options->fpos = fsize;
- options->file = f;
+ el->fcurrent_rotate = i;
+ el->fpos = fsize;
+ el->file = f;
return 0;
}
}
@@ -516,19 +516,19 @@ int el_file_open
* rotation is disabled, simply open file with append flag
*/
- if (strlen(options->fname) > PATH_MAX)
+ if (strlen(el->fname) > PATH_MAX)
{
- options->current_log[0] = '\0';
+ el->current_log[0] = '\0';
errno = ENAMETOOLONG;
return -1;
}
- strcpy(options->current_log, options->fname);
+ strcpy(el->current_log, el->fname);
- if ((options->file = fopen(options->current_log, "a")) == NULL)
+ if ((el->file = fopen(el->current_log, "a")) == NULL)
{
/*
- * we couldn't open file, but don't set clear options->current_log,
+ * we couldn't open file, but don't set clear el->current_log,
* we will try to reopen this file each time we print to file. This
* is usefull when user tries to open log file in not-yet existing
* directory. Error is of course returned to user is aware of this
@@ -538,8 +538,8 @@ int el_file_open
return -1;
}
- fseek(options->file, 0, SEEK_END);
- options->fpos = ftell(options->file);
+ fseek(el->file, 0, SEEK_END);
+ el->fpos = ftell(el->file);
return 0;
}
@@ -552,7 +552,7 @@ int el_file_open
int el_file_flush
(
- struct el_options *options /* printing options */
+ struct el *el /* printing options */
)
{
/* file store operation has particular issue. You can like, write
@@ -572,19 +572,19 @@ int el_file_flush
*/
#if HAVE_FSYNC && HAVE_FILENO
- int fd; /* systems file descriptor for options->file */
+ int fd; /* systems file descriptor for el->file */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#endif /* HAVE_FSYNC && HAVE_FILENO */
- VALID(EINVAL, options);
- VALID(EBADF, options->current_log);
- VALID(EBADF, options->current_log[0] != '\0');
+ VALID(EINVAL, el);
+ VALID(EBADF, el->current_log);
+ VALID(EBADF, el->current_log[0] != '\0');
/*
* first flush data from stdio library buffers into kernel
*/
- if (fflush(options->file) != 0)
+ if (fflush(el->file) != 0)
{
return -1;
}
@@ -594,7 +594,7 @@ int el_file_flush
* and then sync data into block device
*/
- if ((fd = fileno(options->file)) < 0)
+ if ((fd = fileno(el->file)) < 0)
{
return -1;
}
@@ -610,16 +610,16 @@ int el_file_flush
* about data safety!
*/
- fclose(options->file);
+ fclose(el->file);
- if ((options->file = fopen(options->current_log, "a")) == NULL)
+ if ((el->file = fopen(el->current_log, "a")) == NULL)
{
errno = EBADF;
return -1;
}
- fseek(options->file, 0, SEEK_END);
- options->fpos = ftell(options->file);
+ fseek(el->file, 0, SEEK_END);
+ el->fpos = ftell(el->file);
#endif /* HAVE_FSYNC && HAVE_FILENO */
#ifdef RUN_TESTS
@@ -630,7 +630,7 @@ int el_file_flush
* don't trigger another flush right after this one
*/
- options->written_after_sync = 0;
+ el->written_after_sync = 0;
return 0;
}
@@ -643,17 +643,17 @@ int el_file_flush
int el_file_putb
(
- struct el_options *options, /* printing options */
- const void *mem, /* memory to 'put' into file */
- size_t mlen /* size of buffer 'mlen' */
+ struct el *el, /* printing el */
+ const void *mem, /* memory to 'put' into file */
+ size_t mlen /* size of buffer 'mlen' */
)
{
VALID(EINVAL, mem);
VALID(EINVAL, mlen);
- VALID(EINVAL, options);
- VALID(EBADF, options->current_log);
- VALID(EBADF, options->current_log[0] != '\0');
+ VALID(EINVAL, el);
+ VALID(EBADF, el->current_log);
+ VALID(EBADF, el->current_log[0] != '\0');
/*
@@ -661,17 +661,17 @@ int el_file_putb
* due to error or deliberate acion of user
*/
- if (el_file_exists(options->current_log) == 0 || options->file == NULL)
+ if (el_file_exists(el->current_log) == 0 || el->file == NULL)
{
- if (el_file_open(options) != 0)
+ if (el_file_open(el) != 0)
{
return -1;
}
}
- if (options->frotate_number)
+ if (el->frotate_number)
{
- if (options->fpos != 0 && options->fpos + mlen > options->frotate_size)
+ if (el->fpos != 0 && el->fpos + mlen > el->frotate_size)
{
/*
* we get here only when frotate is enabled, and writing to
@@ -681,13 +681,13 @@ int el_file_putb
* files, we remove the oldest one.
*/
- if (el_file_rotate(options) != 0)
+ if (el_file_rotate(el) != 0)
{
return -1;
}
}
- if (mlen > options->frotate_size)
+ if (mlen > el->frotate_size)
{
/*
* we can't fit message even in an empty file, in such case we
@@ -695,27 +695,27 @@ int el_file_putb
* configured frotate_size
*/
- mlen = options->frotate_size;
+ mlen = el->frotate_size;
}
}
- if (fwrite(mem, mlen, 1, options->file) != 1)
+ if (fwrite(mem, mlen, 1, el->file) != 1)
{
return -1;
}
- options->fpos += mlen;
- options->written_after_sync += mlen;
+ el->fpos += mlen;
+ el->written_after_sync += mlen;
- if (options->written_after_sync >= options->file_sync_every ||
- options->level_current_msg <= options->file_sync_level)
+ if (el->written_after_sync >= el->file_sync_every ||
+ el->level_current_msg <= el->file_sync_level)
{
/* we either written enough bytes to trigger flush, or log
* level is high enough it triggers log flush to block
* device
*/
- return el_file_flush(options);
+ return el_file_flush(el);
}
return 0;
@@ -729,16 +729,16 @@ int el_file_putb
int el_file_puts
(
- struct el_options *options, /* printing options */
- const char *s /* string to 'put' into file */
+ struct el *el, /* printing options */
+ const char *s /* string to 'put' into file */
)
{
- size_t slen; /* size of string 's' */
+ size_t slen; /* size of string 's' */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
slen = strlen(s);
- return el_file_putb(options, (unsigned char *)s, slen);
+ return el_file_putb(el, (unsigned char *)s, slen);
}
@@ -749,20 +749,20 @@ int el_file_puts
void el_file_cleanup
(
- struct el_options *options /* file options */
+ struct el *el /* file options */
)
{
- if (options->file)
+ if (el->file)
{
- fclose(options->file);
+ fclose(el->file);
}
- options->file = NULL;
+ el->file = NULL;
- if (options->current_log)
+ if (el->current_log)
{
- options->current_log[0] = '\0';
- free(options->current_log);
- options->current_log = NULL;
+ el->current_log[0] = '\0';
+ free(el->current_log);
+ el->current_log = NULL;
}
}
diff --git a/src/el-flush.c b/src/el-flush.c
index baba6df..7757af5 100644
--- a/src/el-flush.c
+++ b/src/el-flush.c
@@ -50,53 +50,53 @@ int el_flush
void
)
{
- return el_oflush(&g_options);
+ return el_oflush(&g_el);
}
/* ==========================================================================
- Same as el_flush() but takes options as argument
+ Same as el_flush() but takes el object as argument
========================================================================== */
int el_oflush
(
- struct el_options *options /* options defining printing style */
+ struct el *el /* options defining printing style */
)
{
- int rv; /* return value from function */
+ int rv; /* return value from function */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- VALID(EINVAL, options);
- VALID(ENODEV, options->outputs != 0);
+ VALID(EINVAL, el);
+ VALID(ENODEV, el->outputs != 0);
rv = 0;
#if ENABLE_OUT_STDERR
- if (options->outputs & EL_OUT_STDERR)
+ if (el->outputs & EL_OUT_STDERR)
{
rv |= fflush(stderr);
}
#endif
#if ENABLE_OUT_STDERR
- if (options->outputs & EL_OUT_STDOUT)
+ if (el->outputs & EL_OUT_STDOUT)
{
rv |= fflush(stdout);
}
#endif
#if ENABLE_OUT_FILE
- if (options->outputs & EL_OUT_FILE)
+ if (el->outputs & EL_OUT_FILE)
{
- rv |= el_file_flush(options);
+ rv |= el_file_flush(el);
}
#endif
#if 0
- if (options->outputs & EL_OUT_NET)
+ if (el->outputs & EL_OUT_NET)
{
- el_net_flush(options);
+ el_net_flush(el);
}
#endif
diff --git a/src/el-options.c b/src/el-options.c
index 55055b0..9b30f5c 100644
--- a/src/el-options.c
+++ b/src/el-options.c
@@ -57,7 +57,7 @@
========================================================================== */
-struct el_options g_options;
+struct el g_el;
/* ==========================================================================
@@ -125,7 +125,7 @@ static const int VALID_OUTS = 0
/* ==========================================================================
- sets 'option' with 'ap' values in 'options' object.
+ sets 'option' with 'ap' values in 'el' object.
errno
EINVAL option is invalid
@@ -136,14 +136,14 @@ static const int VALID_OUTS = 0
static int el_vooption
(
- struct el_options *options, /* options object to set option to */
- enum el_option option, /* option to set */
- va_list ap /* option value(s) */
+ struct el *el, /* el object to set option to */
+ enum el_option option, /* option to set */
+ va_list ap /* option value(s) */
)
{
- int value_int; /* ap value treated as integer */
- long value_long; /* ap value treated as long */
- const char *value_str; /* ap value treated as string */
+ int value_int; /* ap value treated as integer */
+ long value_long; /* ap value treated as long */
+ const char *value_str; /* ap value treated as string */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -154,13 +154,13 @@ static int el_vooption
case EL_LEVEL:
value_int = va_arg(ap, int);
VALID(EINVAL, value_int <= 7);
- options->level = value_int;
+ el->level = value_int;
return 0;
case EL_FSYNC_LEVEL:
value_int = va_arg(ap, int);
VALID(EINVAL, value_int <= 7);
- options->file_sync_level = value_int;
+ el->file_sync_level = value_int;
return 0;
case EL_OUT:
@@ -168,28 +168,28 @@ static int el_vooption
value_int = value_int == EL_OUT_ALL ? VALID_OUTS : value_int;
VALID(EINVAL, (value_int & ~ALL_OUTS) == 0x00);
VALID(ENODEV, (value_int & ~VALID_OUTS) == 0x00);
- options->outputs = value_int;
+ el->outputs = value_int;
return 0;
case EL_PRINT_LEVEL:
value_int = va_arg(ap, int);
VALID(EINVAL, (value_int & ~1) == 0);
- options->print_log_level = value_int;
+ el->print_log_level = value_int;
return 0;
case EL_PRINT_NL:
value_int = va_arg(ap, int);
VALID(EINVAL, (value_int & ~1) == 0);
- options->print_newline = value_int;
+ el->print_newline = value_int;
return 0;
# if ENABLE_PREFIX
case EL_PREFIX:
value_str = va_arg(ap, const char *);
- options->prefix = value_str;
+ el->prefix = value_str;
return 0;
# endif /* ENABLE_PREFIX */
@@ -204,7 +204,7 @@ static int el_vooption
value_int = va_arg(ap, int);
VALID(EINVAL, (value_int & ~1) == 0);
- options->colors = value_int;
+ el->colors = value_int;
return 0;
# endif /* ENABLE_COLORS */
@@ -215,7 +215,7 @@ static int el_vooption
value_int = va_arg(ap, int);
VALID(EINVAL, 0 <= value_int && value_int < EL_TS_ERROR);
- options->timestamp = value_int;
+ el->timestamp = value_int;
return 0;
# if ENABLE_FRACTIONS
@@ -224,7 +224,7 @@ static int el_vooption
value_int = va_arg(ap, int);
VALID(EINVAL, 0 <= value_int && value_int < EL_TS_FRACT_ERROR);
- options->timestamp_fractions = value_int;
+ el->timestamp_fractions = value_int;
return 0;
# endif /* ENABLE_FRACTIONS */
@@ -246,7 +246,7 @@ static int el_vooption
VALID(ENODEV, value_int != EL_TS_TM_CLOCK);
# endif
- options->timestamp_timer = value_int;
+ el->timestamp_timer = value_int;
return 0;
# endif /* ENABLE_TIMESTAMP */
@@ -257,7 +257,7 @@ static int el_vooption
value_int = va_arg(ap, int);
VALID(EINVAL, (value_int & ~1) == 0);
- options->finfo = value_int;
+ el->finfo = value_int;
return 0;
# endif /* ENABLE_FINFO */
@@ -279,7 +279,7 @@ static int el_vooption
value_int = va_arg(ap, int);
VALID(EINVAL, (value_int & ~1) == 0);
- options->funcinfo = value_int;
+ el->funcinfo = value_int;
return 0;
# endif /* __STDC_VERSION__ < 199901L */
@@ -291,8 +291,8 @@ static int el_vooption
case EL_FPATH:
value_str = va_arg(ap, const char *);
VALID(EINVAL, value_str);
- options->fname = value_str;
- return el_file_open(options);
+ el->fname = value_str;
+ return el_file_open(el);
case EL_FROTATE_NUMBER:
{
@@ -302,10 +302,10 @@ static int el_vooption
value_int = va_arg(ap, int);
VALID(EINVAL, value_int >= 0);
- previous_frotate = options->frotate_number;
- options->frotate_number = value_int;
+ previous_frotate = el->frotate_number;
+ el->frotate_number = value_int;
- if (previous_frotate == 0 && options->file)
+ if (previous_frotate == 0 && el->file)
{
/*
* user turned on file rotation when file is already opened
@@ -315,7 +315,7 @@ static int el_vooption
* reopening
*/
- return el_file_open(options);
+ return el_file_open(el);
}
return 0;
@@ -324,13 +324,13 @@ static int el_vooption
case EL_FROTATE_SIZE:
value_long = va_arg(ap, long);
VALID(EINVAL, value_long >= 1);
- options->frotate_size = value_long;
+ el->frotate_size = value_long;
return 0;
case EL_FSYNC_EVERY:
value_long = va_arg(ap, long);
VALID(EINVAL, value_long >= 0);
- options->file_sync_every = value_long;
+ el->file_sync_every = value_long;
return 0;
# endif /* ENABLE_OUT_FILE */
@@ -346,7 +346,7 @@ static int el_vooption
VALID(EINVAL, value_str);
- return el_tty_open(options, value_str, speed);
+ return el_tty_open(el, value_str, speed);
}
# endif /* ENABLE_OUT_TTY */
@@ -354,8 +354,8 @@ static int el_vooption
# if ENABLE_OUT_CUSTOM
case EL_CUSTOM_PUTS:
- options->custom_puts = va_arg(ap, el_custom_puts);
- options->custom_puts_user = va_arg(ap, void *);
+ el->custom_puts = va_arg(ap, el_custom_puts);
+ el->custom_puts_user = va_arg(ap, void *);
return 0;
# endif /* ENABLE_OUT_CUSTOM */
@@ -393,7 +393,7 @@ static int el_vooption
/* ==========================================================================
- initializes global options to default state
+ initializes global el object to default state
========================================================================== */
@@ -402,34 +402,34 @@ int el_init
void
)
{
- return el_oinit(&g_options);
+ return el_oinit(&g_el);
}
/* ==========================================================================
- Sets options object to sane values
+ Sets el object to sane values
errno
- EINVAL options is invalid (null)
+ EINVAL el is invalid (null)
========================================================================== */
int el_oinit
(
- struct el_options *options /* options object */
+ struct el *el /* el object */
)
{
- VALID(EINVAL, options);
-
- memset(options, 0, sizeof(struct el_options));
- options->outputs = EL_OUT_STDERR;
- options->print_log_level = 1;
- options->print_newline = 1;
- options->level = EL_INFO;
- options->level_current_msg = EL_DBG;
- options->file_sync_level = EL_FATAL;
- options->serial_fd = -1;
- options->file_sync_every = 32768;
+ VALID(EINVAL, el);
+
+ memset(el, 0, sizeof(struct el));
+ el->outputs = EL_OUT_STDERR;
+ el->print_log_level = 1;
+ el->print_newline = 1;
+ el->level = EL_INFO;
+ el->level_current_msg = EL_DBG;
+ el->file_sync_level = EL_FATAL;
+ el->serial_fd = -1;
+ el->file_sync_every = 32768;
return 0;
}
@@ -444,7 +444,7 @@ int el_cleanup
void
)
{
- return el_ocleanup(&g_options);
+ return el_ocleanup(&g_el);
}
@@ -453,26 +453,26 @@ int el_cleanup
el_init calls
errno
- EINVAL options is invalid (null)
+ EINVAL el is invalid (null)
========================================================================== */
int el_ocleanup
(
- struct el_options *options /* options object */
+ struct el *el /* el object */
)
{
- VALID(EINVAL, options);
+ VALID(EINVAL, el);
- options->outputs = 0;
+ el->outputs = 0;
#if ENABLE_OUT_FILE
- el_file_cleanup(options);
+ el_file_cleanup(el);
#endif
#if ENABLE_OUT_TTY
- if (options->serial_fd != -1)
+ if (el->serial_fd != -1)
{
- el_tty_close(options);
+ el_tty_close(el);
}
#endif
@@ -488,16 +488,16 @@ int el_ocleanup
int el_log_allowed
(
- struct el_options *options, /* options object */
- enum el_level level /* log level to check */
+ struct el *el, /* el object */
+ enum el_level level /* log level to check */
)
{
- return options->level >= (int)level;
+ return el->level >= (int)level;
}
/* ==========================================================================
- el_ooptions but for default g_options object
+ same as el_ooption but for default g_el object
========================================================================== */
@@ -512,7 +512,7 @@ int el_option
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
va_start(ap, (int)option);
- rc = el_vooption(&g_options, option, ap);
+ rc = el_vooption(&g_el, option, ap);
va_end(ap);
return rc;
@@ -520,24 +520,24 @@ int el_option
/* ==========================================================================
- same as el_vooptions but accepts variadic arguments
+ same as el_voel but accepts variadic arguments
========================================================================== */
int el_ooption
(
- struct el_options *options, /* options object to set option to */
- int option, /* option to set */
- ... /* option value(s) */
+ struct el *el, /* el object to set option to */
+ int option, /* option to set */
+ ... /* option value(s) */
)
{
- va_list ap; /* variadic arguments */
- int rc; /* return code from el_voooption */
+ va_list ap; /* variadic arguments */
+ int rc; /* return code from el_voooption */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
va_start(ap, option);
- rc = el_vooption(options, option, ap);
+ rc = el_vooption(el, option, ap);
va_end(ap);
return rc;
@@ -545,15 +545,15 @@ int el_ooption
/* ==========================================================================
- Returns const pointer to global options struct used by all el_ functions
- that don't take options object.
+ Returns const pointer to global el struct used by all el_ functions
+ that don't take el object.
========================================================================== */
-const struct el_options *el_get_options
+const struct el *el_get_el
(
void
)
{
- return (const struct el_options *)&g_options;
+ return (const struct el *)&g_el;
}
diff --git a/src/el-pbinary.c b/src/el-pbinary.c
index 607db7c..f83a06e 100644
--- a/src/el-pbinary.c
+++ b/src/el-pbinary.c
@@ -91,15 +91,15 @@
static size_t el_flags
(
- enum el_level level,
- struct el_options *options,
- unsigned char *buf
+ enum el_level level,
+ struct el *el,
+ unsigned char *buf
)
{
*buf = 0;
#if ENABLE_TIMESTAMP
- if (options->timestamp != EL_TS_OFF)
+ if (el->timestamp != EL_TS_OFF)
{
*buf |= FLAG_TS;
@@ -108,7 +108,7 @@ static size_t el_flags
* fraction of seconds can be printed only when timestamp is on
*/
- *buf |= options->timestamp_fractions << FLAG_TS_FRACT_SHIFT;
+ *buf |= el->timestamp_fractions << FLAG_TS_FRACT_SHIFT;
# endif
}
#endif
@@ -137,28 +137,28 @@ static size_t el_flags
int el_opbinary
(
- enum el_level level,
- struct el_options *options,
- const void *memory,
- size_t mlen
+ enum el_level level,
+ struct el *el,
+ const void *memory,
+ size_t mlen
)
{
- unsigned char buf[EL_BUF_MAX]; /* buffer for message to print */
- size_t l; /* length of encoded mlen */
- size_t w; /* bytes written to buf */
- int e; /* cache for errno */
+ unsigned char buf[EL_BUF_MAX]; /* buffer for message to print */
+ size_t l; /* length of encoded mlen */
+ size_t w; /* bytes written to buf */
+ int e; /* cache for errno */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
VALID(EINVAL, mlen);
VALID(EINVAL, memory);
- VALID(EINVAL, options);
- VALID(ENODEV, options->outputs);
- VALID(ERANGE, el_log_allowed(options, level));
+ VALID(EINVAL, el);
+ VALID(ENODEV, el->outputs);
+ VALID(ERANGE, el_log_allowed(el, level));
e = 0;
- w = el_flags(level, options, buf);
- w += el_timestamp(options, buf + w, TS_BINARY);
+ w = el_flags(level, el, buf);
+ w += el_timestamp(el, buf + w, TS_BINARY);
/*
* encode mlen to know how much bytes we are going to need
@@ -183,16 +183,16 @@ int el_opbinary
w += el_encode_number(mlen, buf + w);
memcpy(buf + w, memory, mlen);
- options->level_current_msg = level;
+ el->level_current_msg = level;
w += mlen;
- if (el_oputb(options, buf, w) != 0)
+ if (el_oputb(el, buf, w) != 0)
{
- options->level_current_msg = EL_DBG;
+ el->level_current_msg = EL_DBG;
return -1;
}
- options->level_current_msg = EL_DBG;
+ el->level_current_msg = EL_DBG;
if (e)
{
@@ -205,7 +205,7 @@ int el_opbinary
/* ==========================================================================
- Same as el_opbinary but uses global options object
+ Same as el_opbinary but uses global el object
========================================================================== */
@@ -216,5 +216,5 @@ int el_pbinary
size_t mlen
)
{
- return el_opbinary(level, &g_options, memory, mlen);
+ return el_opbinary(level, &g_el, memory, mlen);
}
diff --git a/src/el-perror.c b/src/el-perror.c
index b3686b6..5b17a48 100644
--- a/src/el-perror.c
+++ b/src/el-perror.c
@@ -55,21 +55,21 @@
static int el_ovperror
(
- const char *file, /* file name where log is printed */
- size_t num, /* line number where log is printed */
- const char *func, /* function name to print */
- enum el_level level, /* log level to print message with */
- struct el_options *options, /* options defining printing style */
- const char *fmt, /* message format (see printf (3)) */
- va_list ap /* additional parameters for fmt */
+ const char *file, /* file name where log is printed */
+ size_t num, /* line number where log is printed */
+ const char *func, /* function name to print */
+ enum el_level level, /* log level to print message with */
+ struct el *el, /* el defining printing style */
+ const char *fmt, /* message format (see printf (3)) */
+ va_list ap /* additional parameters for fmt */
)
{
- int rc; /* return code from el_print() */
- unsigned long e; /* errno from upper layer */
+ int rc; /* return code from el_print() */
+ unsigned long e; /* errno from upper layer */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- VALID(EINVAL, options);
+ VALID(EINVAL, el);
e = errno;
rc = 0;
@@ -81,10 +81,10 @@ static int el_ovperror
* otherwise only errno message will be printed
*/
- rc |= el_ovprint(file, num, func, level, options, fmt, ap);
+ rc |= el_ovprint(file, num, func, level, el, fmt, ap);
}
- rc |= el_oprint(file, num, func, level, options,
+ rc |= el_oprint(file, num, func, level, el,
"errno num: %lu, strerror: %s", e, strerror(e));
/*
@@ -135,7 +135,7 @@ int el_perror
va_start(ap, fmt);
- rc = el_ovperror(file, num, func, level, &g_options, fmt, ap);
+ rc = el_ovperror(file, num, func, level, &g_el, fmt, ap);
va_end(ap);
return rc;
@@ -143,28 +143,28 @@ int el_perror
/* ==========================================================================
- el_perror function with custom options
+ el_perror function with custom el
========================================================================== */
int el_operror
(
- const char *file, /* file name where log is printed */
- size_t num, /* line number where log is printed*/
- const char *func, /* function name to print */
- enum el_level level, /* log level to print message with */
- struct el_options *options, /* options defining printing style */
- const char *fmt, /* message format (see printf (3)) */
- ... /* additional parameters for fmt */
+ const char *file, /* file name where log is printed */
+ size_t num, /* line number where log is printed*/
+ const char *func, /* function name to print */
+ enum el_level level, /* log level to print message with */
+ struct el *el, /* el defining printing style */
+ const char *fmt, /* message format (see printf (3)) */
+ ... /* additional parameters for fmt */
)
{
- int rc; /* return code from el_operror() */
- va_list ap; /* argument pointer for variadic variables */
+ int rc; /* return code from el_operror() */
+ va_list ap; /* argument pointer for variadic variables */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
va_start(ap, fmt);
- rc = el_ovperror(file, num, func, level, options, fmt, ap);
+ rc = el_ovperror(file, num, func, level, el, fmt, ap);
va_end(ap);
return rc;
diff --git a/src/el-pmemory.c b/src/el-pmemory.c
index bf78d26..d41d7c6 100644
--- a/src/el-pmemory.c
+++ b/src/el-pmemory.c
@@ -69,14 +69,14 @@
static int el_print_line
(
- const char *file, /* file name where log is printed */
- size_t num, /* line number where log is printed */
- const char *func, /* function name to print */
- enum el_level level, /* log level to print message with */
- struct el_options *options, /* options defining printing style */
- const unsigned char *buf, /* memory location to print */
- size_t line_size, /* size of line in bytes */
- size_t line_number /* line number beign processed */
+ const char *file, /* file name where log is printed */
+ size_t num, /* line number where log is printed */
+ const char *func, /* function name to print */
+ enum el_level level, /* log level to print message with */
+ struct el *el, /* el defining printing style */
+ const unsigned char *buf, /* memory location to print */
+ size_t line_size, /* size of line in bytes */
+ size_t line_number /* line number beign processed */
)
{
/*
@@ -124,7 +124,7 @@ static int el_print_line
* print constructed line
*/
- return el_oprint(file, num, func, level, options, "0x%04x %-*s %s",
+ return el_oprint(file, num, func, level, el, "0x%04x %-*s %s",
offset, EL_MEM_HEX_LEN, hex_data, char_data);
}
@@ -160,14 +160,14 @@ static int el_print_line
static int el_pmem
(
- const char *file, /* file name where log is printed */
- size_t num, /* line number where log is printed */
- const char *func, /* function name to print */
- enum el_level level, /* log level to print message with */
- struct el_options *options, /* options defining printing style */
- const void *mem, /* memory location to print */
- size_t mlen, /* number of bytes to print */
- int table /* print table? or not to print table? */
+ const char *file, /* file name where log is printed */
+ size_t num, /* line number where log is printed */
+ const char *func, /* function name to print */
+ enum el_level level, /* log level to print message with */
+ struct el *el, /* el defining printing style */
+ const void *mem, /* memory location to print */
+ size_t mlen, /* number of bytes to print */
+ int table /* print table? or not to print table? */
)
{
/*
@@ -199,8 +199,8 @@ static int el_pmem
VALID(EINVAL, mem);
VALID(EINVAL, mlen);
- VALID(EINVAL, options);
- VALID(ERANGE, el_log_allowed(options, level));
+ VALID(EINVAL, el);
+ VALID(ERANGE, el_log_allowed(el, level));
/*
* print log table preamble that is:
@@ -213,16 +213,16 @@ static int el_pmem
if (table)
{
rv = 0;
- rv |= el_oprint(file, num, func, level, options, "%.*s %.*s %.*s",
+ rv |= el_oprint(file, num, func, level, el, "%.*s %.*s %.*s",
EL_MEM_OFFSET_LEN - 2, separator,
EL_MEM_HEX_LEN - 1, separator,
EL_MEM_CHAR_LEN, separator);
- rv |= el_oprint(file, num, func, level, options, "%-*s%-*s%s",
+ rv |= el_oprint(file, num, func, level, el, "%-*s%-*s%s",
EL_MEM_OFFSET_LEN, "offset",
EL_MEM_HEX_LEN + 1, "hex", "ascii");
- rv |= el_oprint(file, num, func, level, options, "%.*s %.*s %.*s",
+ rv |= el_oprint(file, num, func, level, el, "%.*s %.*s %.*s",
EL_MEM_OFFSET_LEN - 2, separator,
EL_MEM_HEX_LEN - 1, separator,
EL_MEM_CHAR_LEN, separator);
@@ -235,7 +235,7 @@ static int el_pmem
for (line_number = 0; line_number < lines_count; ++line_number)
{
- rv |= el_print_line(file, num, func, level, options,
+ rv |= el_print_line(file, num, func, level, el,
mem, EL_MEM_LINE_SIZE, line_number);
/*
@@ -252,7 +252,7 @@ static int el_pmem
if (last_line_size)
{
- rv |= el_print_line(file, num, func, level, options,
+ rv |= el_print_line(file, num, func, level, el,
mem, last_line_size, line_number);
}
@@ -264,7 +264,7 @@ static int el_pmem
if (table)
{
- rv |= el_oprint(file, num, func, level, options, "%.*s %.*s %.*s",
+ rv |= el_oprint(file, num, func, level, el, "%.*s %.*s %.*s",
EL_MEM_OFFSET_LEN - 2, separator,
EL_MEM_HEX_LEN - 1, separator,
EL_MEM_CHAR_LEN, separator);
@@ -297,16 +297,16 @@ static int el_pmem
int el_opmemory_table
(
- const char *file, /* file name where log is printed */
- size_t num, /* line number where log is printed */
- const char *func, /* function name to print */
- enum el_level level, /* log level to print message with */
- struct el_options *options, /* options defining printing style */
- const void *mem, /* memory location to print */
- size_t mlen /* number of bytes to print */
+ const char *file, /* file name where log is printed */
+ size_t num, /* line number where log is printed */
+ const char *func, /* function name to print */
+ enum el_level level, /* log level to print message with */
+ struct el *el, /* el defining printing style */
+ const void *mem, /* memory location to print */
+ size_t mlen /* number of bytes to print */
)
{
- return el_pmem(file, num, func, level, options, mem, mlen, 1);
+ return el_pmem(file, num, func, level, el, mem, mlen, 1);
}
@@ -325,7 +325,7 @@ int el_pmemory_table
size_t mlen /* number of bytes to print */
)
{
- return el_opmemory_table(file, num, func, level, &g_options, mem, mlen);
+ return el_opmemory_table(file, num, func, level, &g_el, mem, mlen);
}
/* ==========================================================================
@@ -335,16 +335,16 @@ int el_pmemory_table
int el_opmemory
(
- const char *file, /* file name where log is printed */
- size_t num, /* line number where log is printed */
- const char *func, /* function name to print */
- enum el_level level, /* log level to print message with */
- struct el_options *options, /* options defining printing style */
- const void *mem, /* memory location to print */
- size_t mlen /* number of bytes to print */
+ const char *file, /* file name where log is printed */
+ size_t num, /* line number where log is printed */
+ const char *func, /* function name to print */
+ enum el_level level, /* log level to print message with */
+ struct el *el, /* el defining printing style */
+ const void *mem, /* memory location to print */
+ size_t mlen /* number of bytes to print */
)
{
- return el_pmem(file, num, func, level, options, mem, mlen, 0);
+ return el_pmem(file, num, func, level, el, mem, mlen, 0);
}
@@ -363,5 +363,5 @@ int el_pmemory
size_t mlen /* number of bytes to print */
)
{
- return el_opmemory(file, num, func, level, &g_options, mem, mlen);
+ return el_opmemory(file, num, func, level, &g_el, mem, mlen);
}
diff --git a/src/el-print.c b/src/el-print.c
index 2db0ec2..173c43a 100644
--- a/src/el-print.c
+++ b/src/el-print.c
@@ -153,13 +153,13 @@ static const char *color[] =
static size_t el_color
(
- struct el_options *options, /* options defining printing style */
- char *buf, /* buffer where to store color info */
- int level /* log level or 8 for reset */
+ struct el *el, /* el defining printing style */
+ char *buf, /* buffer where to store color info */
+ int level /* log level or 8 for reset */
)
{
#if ENABLE_COLORS
- if (options->colors == 0)
+ if (el->colors == 0)
{
/*
* no colors, you got it!
@@ -215,25 +215,25 @@ static const char *el_basename
/* ==========================================================================
stores file and line information in 'buf'. Number of bytes stored in
- 'buf' is returned, if file info is disabled during compilation or in
- runtime options 0 is returned
+ 'buf' is returned. If file info is disabled during compilation or in
+ runtime, value 0 is returned
========================================================================== */
static size_t el_finfo
(
- struct el_options *options, /* options defining printing style */
- char *buf, /* location whre to store file information */
- const char *file, /* path to file - will be basenamed */
- int num /* line number (max 99999) */
+ struct el *el, /* el defining printing style */
+ char *buf, /* location whre to store file information */
+ const char *file, /* path to file - will be basenamed */
+ int num /* line number (max 99999) */
)
{
#if ENABLE_FINFO
- const char *base; /* basenem of the 'file' */
- size_t fl; /* number of bytes stored in 'buf' */
+ const char *base; /* basenem of the 'file' */
+ size_t fl; /* number of bytes stored in 'buf' */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- if (options->finfo == 0 || file == NULL || num == 0)
+ if (el->finfo == 0 || file == NULL || num == 0)
{
/*
* no file info for this caller
@@ -250,7 +250,7 @@ static size_t el_finfo
fl = strlen(buf);
fl += sprintf(buf + fl, ":%d", num);
- if (options->funcinfo == 0)
+ if (el->funcinfo == 0)
{
/* when function info is printed, we don't close ']', to
* let it print function in same [] brackets, we close
@@ -275,16 +275,16 @@ static size_t el_finfo
static size_t el_funcinfo
(
- struct el_options *options, /* options defining printing style */
- char *buf, /* location whre to store file information */
- const char *func /* function name to print */
+ struct el *el, /* el defining printing style */
+ char *buf, /* location whre to store file information */
+ const char *func /* function name to print */
)
{
#if ENABLE_FUNCINFO
- size_t fl; /* number of bytes stored in 'buf' */
+ size_t fl; /* number of bytes stored in 'buf' */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- if (options->funcinfo == 0 || func == NULL)
+ if (el->funcinfo == 0 || func == NULL)
{
/* no function print for this caller
*/
@@ -297,7 +297,7 @@ static size_t el_funcinfo
* '[' bracket, as it was not already opened by finfo
*/
- buf[0] = options->finfo ? ':' : '[';
+ buf[0] = el->finfo ? ':' : '[';
/* copy function name to buffer
*/
@@ -354,21 +354,21 @@ static size_t el_funcinfo
int el_print
(
- const char *file, /* file name where log is printed */
- size_t num, /* line number where log is printed */
- const char *func, /* function name to print */
- enum el_level level, /* log level to print message with */
- const char *fmt, /* message format (see printf (3)) */
- ... /* additional parameters for fmt */
+ const char *file, /* file name where log is printed */
+ size_t num, /* line number where log is printed */
+ const char *func, /* function name to print */
+ enum el_level level, /* log level to print message with */
+ const char *fmt, /* message format (see printf (3)) */
+ ... /* additional parameters for fmt */
)
{
- va_list ap; /* arguments '...' for 'fmt' */
- int rc; /* return code from el_printfv() */
+ va_list ap; /* arguments '...' for 'fmt' */
+ int rc; /* return code from el_printfv() */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
va_start(ap, fmt);
- rc = el_ovprint(file, num, func, level, &g_options, fmt, ap);
+ rc = el_ovprint(file, num, func, level, &g_el, fmt, ap);
va_end(ap);
return rc;
@@ -376,28 +376,28 @@ int el_print
/* ==========================================================================
- el_print but with custom options
+ el_print but with custom el
========================================================================== */
int el_oprint
(
- const char *file, /* file name to print in log */
- size_t num, /* line number to print in log */
- const char *func, /* function name to print */
- enum el_level level, /* log level to print log with */
- struct el_options *options, /* printing style options */
- const char *fmt, /* message format (man printf) */
- ... /* additional params for fmt */
+ const char *file, /* file name to print in log */
+ size_t num, /* line number to print in log */
+ const char *func, /* function name to print */
+ enum el_level level, /* log level to print log with */
+ struct el *el, /* printing style el */
+ const char *fmt, /* message format (man printf) */
+ ... /* additional params for fmt */
)
{
- va_list ap; /* arguments '...' for 'fmt' */
- int rc; /* return code from el_printfv() */
+ va_list ap; /* arguments '...' for 'fmt' */
+ int rc; /* return code from el_printfv() */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
va_start(ap, fmt);
- rc = el_ovprint(file, num, func, level, options, fmt, ap);
+ rc = el_ovprint(file, num, func, level, el, fmt, ap);
va_end(ap);
return rc;
@@ -419,7 +419,7 @@ int el_vprint
va_list ap /* additional parameters for fmt */
)
{
- return el_ovprint(file, num, func, level, &g_options, fmt, ap);
+ return el_ovprint(file, num, func, level, &g_el, fmt, ap);
}
@@ -428,7 +428,7 @@ int el_vprint
line number 'num' information, with specified 'level' into configured
outputs. Function allocates on callers stack EL_BUF_MAX of memory.
If log message is longer than available buffer, it will be truncated
- and part of message will be lost. Additionally options may be passed to
+ and part of message will be lost. Additionally el may be passed to
tune printing style in runtime
errno:
@@ -441,26 +441,26 @@ int el_vprint
int el_ovprint
(
- const char *file, /* file name to print in log */
- size_t num, /* line number to print in log */
- const char *func, /* function name to print */
- enum el_level level, /* log level to print log with */
- struct el_options *options, /* options defining print style */
- const char *fmt, /* message format (man printf) */
- va_list ap /* additional params for fmt */
+ const char *file, /* file name to print in log */
+ size_t num, /* line number to print in log */
+ const char *func, /* function name to print */
+ enum el_level level, /* log level to print log with */
+ struct el *el, /* el defining print style */
+ const char *fmt, /* message format (man printf) */
+ va_list ap /* additional params for fmt */
)
{
- char buf[EL_BUF_MAX + 2]; /* buffer for message to print */
- size_t w; /* bytes written to buf */
- size_t flen; /* length of the fmt output */
- int e; /* error code */
+ char buf[EL_BUF_MAX + 2]; /* buffer for message to print */
+ size_t w; /* bytes written to buf */
+ size_t flen; /* length of the fmt output */
+ int e; /* error code */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
VALID(EINVAL, fmt);
- VALID(EINVAL, options);
- VALID(ERANGE, el_log_allowed(options, level));
- VALID(ENODEV, options->outputs);
+ VALID(EINVAL, el);
+ VALID(ERANGE, el_log_allowed(el, level));
+ VALID(ENODEV, el->outputs);
e = 0;
@@ -481,10 +481,10 @@ int el_ovprint
*/
buf[0] = '\0';
- w = el_color(options, buf, level);
- w += el_timestamp(options, buf + w, TS_STRING);
- w += el_finfo(options, buf + w, file, num);
- w += el_funcinfo(options, buf + w, func);
+ w = el_color(el, buf, level);
+ w += el_timestamp(el, buf + w, TS_STRING);
+ w += el_finfo(el, buf + w, file, num);
+ w += el_funcinfo(el, buf + w, func);
if (w != 0 && buf[w - 1] == ']')
{
@@ -497,13 +497,13 @@ int el_ovprint
++w;
}
- if (options->print_log_level)
+ if (el->print_log_level)
{
w += sprintf(buf + w, "%c/", char_level[level]);
}
#if ENABLE_PREFIX
- if (options->prefix)
+ if (el->prefix)
{
/*
* there is a case where buf[w] will point to something different
@@ -512,9 +512,9 @@ int el_ovprint
*/
buf[w] = '\0';
- strncat(buf + w, options->prefix, EL_PREFIX_LEN);
+ strncat(buf + w, el->prefix, EL_PREFIX_LEN);
- if ((flen = strlen(options->prefix)) > EL_PREFIX_LEN)
+ if ((flen = strlen(el->prefix)) > EL_PREFIX_LEN)
{
/*
* dodge a bullet - overflow would have occured
@@ -551,9 +551,9 @@ int el_ovprint
* add terminal formatting reset sequence
*/
- w += el_color(options, buf + w, 8 /* reset colors */);
+ w += el_color(el, buf + w, 8 /* reset colors */);
- if (options->print_newline)
+ if (el->print_newline)
{
/*
* add new line to log
@@ -570,11 +570,11 @@ int el_ovprint
* we set it here in a 'object global' variable
*/
- options->level_current_msg = level;
+ el->level_current_msg = level;
- if (el_oputs(options, buf) != 0)
+ if (el_oputs(el, buf) != 0)
{
- options->level_current_msg = EL_DBG;
+ el->level_current_msg = EL_DBG;
return -1;
}
@@ -587,7 +587,7 @@ int el_ovprint
* data to file or not.
*/
- options->level_current_msg = EL_DBG;
+ el->level_current_msg = EL_DBG;
if (e)
{
@@ -597,4 +597,3 @@ int el_ovprint
return 0;
}
-
diff --git a/src/el-private.h b/src/el-private.h
index 4215f40..eb0dde8 100644
--- a/src/el-private.h
+++ b/src/el-private.h
@@ -54,7 +54,7 @@
========================================================================== */
-extern struct el_options g_options;
+extern struct el g_el;
/* ==========================================================================
@@ -303,22 +303,22 @@ extern struct el_options g_options;
#if ENABLE_OUT_FILE
-int el_file_open(struct el_options *options);
-int el_file_puts(struct el_options *options, const char *s);
-int el_file_putb(struct el_options *options, const void *mem, size_t mlen);
-void el_file_cleanup(struct el_options *options);
-int el_file_flush(struct el_options *options);
+int el_file_open(struct el *el);
+int el_file_puts(struct el *el, const char *s);
+int el_file_putb(struct el *el, const void *mem, size_t mlen);
+void el_file_cleanup(struct el *el);
+int el_file_flush(struct el *el);
#endif
#if ENABLE_OUT_TTY
-int el_tty_open(struct el_options *options, const char *dev, unsigned int speed);
-int el_tty_puts(struct el_options *options, const char *s);
-int el_tty_close(struct el_options *options);
+int el_tty_open(struct el *el, const char *dev, unsigned int speed);
+int el_tty_puts(struct el *el, const char *s);
+int el_tty_close(struct el *el);
#endif
-int el_log_allowed(struct el_options *options, enum el_level level);
-size_t el_timestamp(struct el_options *options, void *buf, int binary);
+int el_log_allowed(struct el *el, enum el_level level);
+size_t el_timestamp(struct el *el, void *buf, int binary);
#if LLONG_MAX
size_t el_encode_number(unsigned long long number, void *out);
diff --git a/src/el-puts.c b/src/el-puts.c
index 026db91..89ae41a 100644
--- a/src/el-puts.c
+++ b/src/el-puts.c
@@ -54,8 +54,8 @@
/* ==========================================================================
- puts string 's' to all enabled output facilities specified by default
- options
+ puts string 's' to all enabled output facilities specified by default
+ el object
========================================================================== */
@@ -64,76 +64,76 @@ int el_puts
const char *s /* string to put into output */
)
{
- return el_oputs(&g_options, s);
+ return el_oputs(&g_el, s);
}
/* ==========================================================================
- puts string 's' to all enabled output facilities specified by options
+ puts string 's' to all enabled output facilities specified by el
========================================================================== */
int el_oputs
(
- struct el_options *options, /* options defining printing style */
- const char *s /* string to put into output */
+ struct el *el, /* el defining printing style */
+ const char *s /* string to put into output */
)
{
- int rv; /* return value from function */
+ int rv; /* return value from function */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
VALID(EINVAL, s);
- VALID(EINVAL, options);
- VALID(ENODEV, options->outputs != 0);
+ VALID(EINVAL, el);
+ VALID(ENODEV, el->outputs != 0);
rv = 0;
#if ENABLE_OUT_STDERR
- if (options->outputs & EL_OUT_STDERR)
+ if (el->outputs & EL_OUT_STDERR)
{
rv |= fputs(s, stderr) == EOF ? -1 : 0;
}
#endif
#if ENABLE_OUT_STDERR
- if (options->outputs & EL_OUT_STDOUT)
+ if (el->outputs & EL_OUT_STDOUT)
{
rv |= fputs(s, stdout) == EOF ? -1 : 0;
}
#endif
#if ENABLE_OUT_SYSLOG
- if (options->outputs & EL_OUT_SYSLOG)
+ if (el->outputs & EL_OUT_SYSLOG)
{
- syslog(options->level, s);
+ syslog(el->level, s);
}
#endif
#if ENABLE_OUT_FILE
- if (options->outputs & EL_OUT_FILE)
+ if (el->outputs & EL_OUT_FILE)
{
- rv |= el_file_puts(options, s);
+ rv |= el_file_puts(el, s);
}
#endif
#if 0
- if (options->outputs & EL_OUT_NET)
+ if (el->outputs & EL_OUT_NET)
{
el_puts_net(s);
}
#endif
#if ENABLE_OUT_TTY
- if (options->outputs & EL_OUT_TTY)
+ if (el->outputs & EL_OUT_TTY)
{
- rv |= el_tty_puts(options, s);
+ rv |= el_tty_puts(el, s);
}
#endif
#if ENABLE_OUT_CUSTOM
- if (options->outputs & EL_OUT_CUSTOM && options->custom_puts)
+ if (el->outputs & EL_OUT_CUSTOM && el->custom_puts)
{
- rv |= options->custom_puts(s, options->custom_puts_user);
+ rv |= el->custom_puts(s, el->custom_puts_user);
}
#endif
@@ -143,51 +143,51 @@ int el_oputs
/* ==========================================================================
puts memory 'mem' to all supported output facilities specified by
- default options. Not all outputs support printing binary data
+ default el object. Not all outputs support printing binary data
========================================================================== */
int el_putb
(
- const void *mem, /* memory location to 'print' */
- size_t mlen /* size of the mem buffer */
+ const void *mem, /* memory location to 'print' */
+ size_t mlen /* size of the mem buffer */
)
{
- return el_oputb(&g_options, mem, mlen);
+ return el_oputb(&g_el, mem, mlen);
}
/* ==========================================================================
Puts binary data 'mem' of size 'mlen' to enabled output facilities
- specified by 'options'. No all outputs support printing binary data
+ specified by 'el object'. No all outputs support printing binary data
========================================================================== */
int el_oputb
(
- struct el_options *options, /* options defining printing style */
- const void *mem, /* memory location to 'print' */
- size_t mlen /* size of the mem buffer */
+ struct el *el, /* el defining printing style */
+ const void *mem, /* memory location to 'print' */
+ size_t mlen /* size of the mem buffer */
)
{
- int rv; /* return value from function */
- int called; /* at least one output was called */
+ int rv; /* return value from function */
+ int called; /* at least one output was called */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
VALID(EINVAL, mem);
VALID(EINVAL, mlen);
- VALID(EINVAL, options);
- VALID(ENODEV, options->outputs != 0);
+ VALID(EINVAL, el);
+ VALID(ENODEV, el->outputs != 0);
rv = 0;
called = 0;
#if ENABLE_OUT_FILE
- if (options->outputs & EL_OUT_FILE)
+ if (el->outputs & EL_OUT_FILE)
{
called = 1;
- rv |= el_file_putb(options, mem, mlen);
+ rv |= el_file_putb(el, mem, mlen);
}
#endif
diff --git a/src/el-syslog.c b/src/el-syslog.c
index 1b4bcc9..390605e 100644
--- a/src/el-syslog.c
+++ b/src/el-syslog.c
@@ -49,13 +49,13 @@
int el_tty_open
(
- struct el_options *options, /* store serial file descriptor here */
- const char *dev, /* device to open like /dev/ttyS0 */
- speed_t speed /* serial port baud rate */
+ struct el *el, /* store serial file descriptor here */
+ const char *dev, /* device to open like /dev/ttyS0 */
+ speed_t speed /* serial port baud rate */
)
{
- struct termios tty; /* serial port settings */
- int e; /* holder for errno */
+ struct termios tty; /* serial port settings */
+ int e; /* holder for errno */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -65,9 +65,9 @@ int el_tty_open
* socket first
*/
- el_tty_close(options);
+ el_tty_close(el);
- if ((options->serial_fd = open(dev, O_WRONLY | O_NOCTTY | O_SYNC)) < 0)
+ if ((el->serial_fd = open(dev, O_WRONLY | O_NOCTTY | O_SYNC)) < 0)
{
return -1;
}
@@ -92,7 +92,7 @@ int el_tty_open
return 0;
}
- if (tcgetattr(options->serial_fd, &tty) != 0)
+ if (tcgetattr(el->serial_fd, &tty) != 0)
{
goto error;
}
@@ -111,7 +111,7 @@ int el_tty_open
tty.c_cflag &= ~CREAD; /* disable receiver - we only send data */
tty.c_oflag |= OPOST | ONLCR; /* enable output post-processing by OS */
- if (tcsetattr(options->serial_fd, TCSANOW, &tty) != 0)
+ if (tcsetattr(el->serial_fd, TCSANOW, &tty) != 0)
{
goto error;
}
@@ -120,8 +120,8 @@ int el_tty_open
error:
e = errno;
- close(options->serial_fd);
- options->serial_fd = -1;
+ close(el->serial_fd);
+ el->serial_fd = -1;
errno = e;
return -1;
@@ -140,27 +140,27 @@ error:
int el_tty_close
(
- struct el_options *options /* options object with serial descriptor */
+ struct el *el /* el object with serial descriptor */
)
{
- VALID(EINVAL, options->serial_fd != -1);
+ VALID(EINVAL, el->serial_fd != -1);
- close(options->serial_fd);
- options->serial_fd = -1;
+ close(el->serial_fd);
+ el->serial_fd = -1;
return 0;
}
/* ==========================================================================
- Simply sends string pointed by s to serial port configured in options
+ Simply sends string pointed by s to serial port configured in el
========================================================================== */
int el_tty_puts
(
- struct el_options *options, /* options object with serial descriptor */
+ struct el *el, /* el object with serial descriptor */
const char *s /* string to send */
)
{
- return write(options->serial_fd, s, strlen(s));
+ return write(el->serial_fd, s, strlen(s));
}
diff --git a/src/el-ts.c b/src/el-ts.c
index 4667bc2..1047162 100644
--- a/src/el-ts.c
+++ b/src/el-ts.c
@@ -97,19 +97,19 @@ static void el_ts_clock_gettime
size_t el_timestamp
(
- struct el_options *options, /* options defining printing style */
- void *b, /* buffer where timestamp will be stored */
- int binary /* 1 if timestamp should be binary */
+ struct el *el, /* el defining printing style */
+ void *b, /* buffer where timestamp will be stored */
+ int binary /* 1 if timestamp should be binary */
)
{
#if ENABLE_TIMESTAMP
- time_t s; /* timestamp seconds */
- long ns; /* timestamp nanoseconds */
- size_t tl; /* timestamp length */
- char *buf; /* b threated as known type */
+ time_t s; /* timestamp seconds */
+ long ns; /* timestamp nanoseconds */
+ size_t tl; /* timestamp length */
+ char *buf; /* b threated as known type */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- if (options->timestamp == EL_TS_OFF)
+ if (el->timestamp == EL_TS_OFF)
{
/*
* user doesn't want us to print timestamp, that's fine
@@ -124,7 +124,7 @@ size_t el_timestamp
* first we get seconds and nanoseconds from proper timer
*/
- switch (options->timestamp_timer)
+ switch (el->timestamp_timer)
{
# if ENABLE_REALTIME
@@ -181,7 +181,7 @@ size_t el_timestamp
*/
# if ENABLE_FRACTIONS
- switch (options->timestamp_fractions)
+ switch (el->timestamp_fractions)
{
case EL_TS_FRACT_OFF:
/*
@@ -226,7 +226,7 @@ size_t el_timestamp
* then convert retrieved time into string timestamp
*/
- if (options->timestamp == EL_TS_LONG)
+ if (el->timestamp == EL_TS_LONG)
{
struct tm tm; /* timestamp splitted */
struct tm *tmp; /* timestamp splitted pointer */
@@ -260,7 +260,7 @@ size_t el_timestamp
* if requested, add proper fractions of seconds
*/
# if ENABLE_FRACTIONS
- switch (options->timestamp_fractions)
+ switch (el->timestamp_fractions)
{
case EL_TS_FRACT_OFF:
/*
@@ -298,7 +298,7 @@ size_t el_timestamp
#else /* ENABLE_TIMESTAMP */
- (void)options;
+ (void)el;
(void)b;
(void)binary;
return 0;
diff --git a/src/el-tty.c b/src/el-tty.c
index 66bfa97..e8a3a8a 100644
--- a/src/el-tty.c
+++ b/src/el-tty.c
@@ -48,14 +48,14 @@
int el_tty_open
(
- struct el_options *options, /* store serial file descriptor here */
- const char *dev, /* device to open like /dev/ttyS0 */
- unsigned int speed /* serial port baud rate */
+ struct el *el, /* store serial file descriptor here */
+ const char *dev, /* device to open like /dev/ttyS0 */
+ unsigned int speed /* serial port baud rate */
)
{
#if HAVE_TERMIOS_H
- struct termios tty; /* serial port settings */
- int e; /* holder for errno */
+ struct termios tty; /* serial port settings */
+ int e; /* holder for errno */
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -66,9 +66,9 @@ int el_tty_open
* socket first
*/
- el_tty_close(options);
+ el_tty_close(el);
- if ((options->serial_fd = open(dev, O_WRONLY | O_NOCTTY | O_SYNC)) < 0)
+ if ((el->serial_fd = open(dev, O_WRONLY | O_NOCTTY | O_SYNC)) < 0)
{
return -1;
}
@@ -93,7 +93,7 @@ int el_tty_open
return 0;
}
- if (tcgetattr(options->serial_fd, &tty) != 0)
+ if (tcgetattr(el->serial_fd, &tty) != 0)
{
goto error;
}
@@ -112,7 +112,7 @@ int el_tty_open
tty.c_cflag &= ~CREAD; /* disable receiver - we only send data */
tty.c_oflag |= OPOST | ONLCR; /* enable output post-processing by OS */
- if (tcsetattr(options->serial_fd, TCSANOW, &tty) != 0)
+ if (tcsetattr(el->serial_fd, TCSANOW, &tty) != 0)
{
goto error;
}
@@ -121,8 +121,8 @@ int el_tty_open
error:
e = errno;
- close(options->serial_fd);
- options->serial_fd = -1;
+ close(el->serial_fd);
+ el->serial_fd = -1;
errno = e;
return -1;
@@ -139,27 +139,27 @@ error:
int el_tty_close
(
- struct el_options *options /* options object with serial descriptor */
+ struct el *el /* el object with serial descriptor */
)
{
- VALID(EINVAL, options->serial_fd != -1);
+ VALID(EINVAL, el->serial_fd != -1);
- close(options->serial_fd);
- options->serial_fd = -1;
+ close(el->serial_fd);
+ el->serial_fd = -1;
return 0;
}
/* ==========================================================================
- Simply sends string pointed by s to serial port configured in options
+ Simply sends string pointed by s to serial port configured in el
========================================================================== */
int el_tty_puts
(
- struct el_options *options, /* options object with serial descriptor */
- const char *s /* string to send */
+ struct el *el, /* el object with serial descriptor */
+ const char *s /* string to send */
)
{
- return write(options->serial_fd, s, strlen(s));
+ return write(el->serial_fd, s, strlen(s));
}
diff --git a/tst/test-el-options.c b/tst/test-el-options.c
index 0db6b6a..9c98f3e 100644
--- a/tst/test-el-options.c
+++ b/tst/test-el-options.c
@@ -38,8 +38,8 @@
========================================================================== */
-mt_defs_ext(); /* external variables for mtest */
-extern struct el_options g_options; /* global embedlog options */
+mt_defs_ext(); /* external variables for mtest */
+extern struct el g_el; /* global embedlog el */
/* ==========================================================================
@@ -86,41 +86,41 @@ static void test_cleanup(void)
static void options_init(void)
{
- struct el_options default_options; /* expected default options */
- struct el_options options; /* custom options to init */
+ struct el default_el; /* expected default el */
+ struct el el; /* custom el to init */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- memset(&default_options, 0, sizeof(default_options));
- default_options.outputs = EL_OUT_STDERR;
- default_options.level = EL_INFO;
- default_options.file_sync_level = EL_FATAL;
- default_options.level_current_msg = EL_DBG;
- default_options.colors = 0;
- default_options.timestamp = EL_TS_OFF;
- default_options.timestamp_timer = EL_TS_TM_TIME;
- default_options.timestamp_fractions = EL_TS_FRACT_OFF;
- default_options.print_log_level = 1;
- default_options.print_newline = 1;
- default_options.custom_puts = NULL;
- default_options.serial_fd = -1;
-
- default_options.funcinfo = 0;
- default_options.finfo = 0;
- default_options.frotate_number = 0;
- default_options.fcurrent_rotate = 0;
- default_options.frotate_size = 0;
- default_options.fpos = 0;
- default_options.file = NULL;
- default_options.file_sync_every = 32768;
- default_options.fname = NULL;
-
- mt_fail(el_oinit(&options) == 0);
- mt_fail(memcmp(&options, &default_options, sizeof(options)) == 0);
- mt_fail(el_ocleanup(&options) == 0);
+ memset(&default_el, 0, sizeof(default_el));
+ default_el.outputs = EL_OUT_STDERR;
+ default_el.level = EL_INFO;
+ default_el.file_sync_level = EL_FATAL;
+ default_el.level_current_msg = EL_DBG;
+ default_el.colors = 0;
+ default_el.timestamp = EL_TS_OFF;
+ default_el.timestamp_timer = EL_TS_TM_TIME;
+ default_el.timestamp_fractions = EL_TS_FRACT_OFF;
+ default_el.print_log_level = 1;
+ default_el.print_newline = 1;
+ default_el.custom_puts = NULL;
+ default_el.serial_fd = -1;
+
+ default_el.funcinfo = 0;
+ default_el.finfo = 0;
+ default_el.frotate_number = 0;
+ default_el.fcurrent_rotate = 0;
+ default_el.frotate_size = 0;
+ default_el.fpos = 0;
+ default_el.file = NULL;
+ default_el.file_sync_every = 32768;
+ default_el.fname = NULL;
+
+ mt_fail(el_oinit(&el) == 0);
+ mt_fail(memcmp(&el, &default_el, sizeof(el)) == 0);
+ mt_fail(el_ocleanup(&el) == 0);
mt_fail(el_init() == 0);
- mt_fail(memcmp(&g_options, &default_options, sizeof(default_options)) == 0);
+ mt_fail(memcmp(&g_el, &default_el, sizeof(default_el)) == 0);
mt_fail(el_cleanup() == 0);
}
@@ -152,12 +152,12 @@ static void options_level_set(void)
if (i <= EL_DBG)
{
mt_fail(el_option(EL_LEVEL, i) == 0);
- mt_fail(g_options.level == i);
+ mt_fail(g_el.level == i);
}
else
{
mt_ferr(el_option(EL_LEVEL, i), EINVAL);
- mt_fail(g_options.level == EL_DBG);
+ mt_fail(g_el.level == EL_DBG);
}
}
}
@@ -178,12 +178,12 @@ static void options_file_sync_level_set(void)
if (i <= EL_DBG)
{
mt_fail(el_option(EL_FSYNC_LEVEL, i) == 0);
- mt_fail(g_options.file_sync_level == i);
+ mt_fail(g_el.file_sync_level == i);
}
else
{
mt_ferr(el_option(EL_FSYNC_LEVEL, i), EINVAL);
- mt_fail(g_options.file_sync_level == EL_DBG);
+ mt_fail(g_el.file_sync_level == EL_DBG);
}
}
}
@@ -276,7 +276,7 @@ static void options_output(void)
}
mt_fok(el_option(EL_OUT, EL_OUT_ALL));
- mt_fail(g_options.outputs == valid_outs);
+ mt_fail(g_el.outputs == valid_outs);
}
@@ -286,17 +286,17 @@ static void options_output(void)
static void options_log_allowed(void)
{
- g_options.level = EL_ERROR;
- g_options.outputs = EL_OUT_STDERR;
-
- mt_fail(el_log_allowed(&g_options, EL_FATAL) == 1);
- mt_fail(el_log_allowed(&g_options, EL_ALERT) == 1);
- mt_fail(el_log_allowed(&g_options, EL_CRIT) == 1);
- mt_fail(el_log_allowed(&g_options, EL_ERROR) == 1);
- mt_fail(el_log_allowed(&g_options, EL_WARN) == 0);
- mt_fail(el_log_allowed(&g_options, EL_NOTICE) == 0);
- mt_fail(el_log_allowed(&g_options, EL_INFO) == 0);
- mt_fail(el_log_allowed(&g_options, EL_DBG) == 0);
+ g_el.level = EL_ERROR;
+ g_el.outputs = EL_OUT_STDERR;
+
+ mt_fail(el_log_allowed(&g_el, EL_FATAL) == 1);
+ mt_fail(el_log_allowed(&g_el, EL_ALERT) == 1);
+ mt_fail(el_log_allowed(&g_el, EL_CRIT) == 1);
+ mt_fail(el_log_allowed(&g_el, EL_ERROR) == 1);
+ mt_fail(el_log_allowed(&g_el, EL_WARN) == 0);
+ mt_fail(el_log_allowed(&g_el, EL_NOTICE) == 0);
+ mt_fail(el_log_allowed(&g_el, EL_INFO) == 0);
+ mt_fail(el_log_allowed(&g_el, EL_DBG) == 0);
}
@@ -307,9 +307,9 @@ static void options_log_allowed(void)
static void options_opt_print_level(void)
{
mt_fail(el_option(EL_PRINT_LEVEL, 0) == 0);
- mt_fail(g_options.print_log_level == 0);
+ mt_fail(g_el.print_log_level == 0);
mt_fail(el_option(EL_PRINT_LEVEL, 1) == 0);
- mt_fail(g_options.print_log_level == 1);
+ mt_fail(g_el.print_log_level == 1);
errno = 0;
mt_fail(el_option(EL_PRINT_LEVEL, 2) == -1);
@@ -328,9 +328,9 @@ static void options_opt_colors(void)
{
#if ENABLE_COLORS
mt_fok(el_option(EL_COLORS, 0));
- mt_fail(g_options.colors == 0);
+ mt_fail(g_el.colors == 0);
mt_fok(el_option(EL_COLORS, 1));
- mt_fail(g_options.colors == 1);
+ mt_fail(g_el.colors == 1);
mt_ferr(el_option(EL_COLORS, 2), EINVAL);
mt_ferr(el_option(EL_COLORS, 3), EINVAL);
@@ -356,7 +356,7 @@ static void options_opt_timestamp(void)
{
#if ENABLE_TIMESTAMP
mt_fok(el_option(EL_TS, i));
- mt_fail(g_options.timestamp == i);
+ mt_fail(g_el.timestamp == i);
#else
mt_ferr(el_option(EL_TS, i), ENOSYS);
#endif
@@ -409,7 +409,7 @@ static void options_opt_timestamp_timer(void)
# endif
mt_fok(el_option(EL_TS_TM, i));
- mt_fail(g_options.timestamp_timer == i);
+ mt_fail(g_el.timestamp_timer == i);
#else
mt_ferr(el_option(EL_TS, i), ENOSYS);
#endif
@@ -437,7 +437,7 @@ static void options_opt_timestamp_fraction(void)
{
#if ENABLE_FRACTIONS && ENABLE_TIMESTAMP
mt_fok(el_option(EL_TS_FRACT, i));
- mt_fail(g_options.timestamp_fractions == i);
+ mt_fail(g_el.timestamp_fractions == i);
#else
mt_ferr(el_option(EL_TS_FRACT, i), ENOSYS);
#endif
@@ -456,7 +456,7 @@ static void options_opt_timestamp_fraction(void)
static void options_ooption_test(void)
{
- struct el_options opts;
+ struct el opts;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -477,13 +477,13 @@ static void options_prefix(void)
{
el_option(EL_PREFIX, "prefix");
#if ENABLE_PREFIX
- mt_fok(strcmp("prefix", g_options.prefix));
+ mt_fok(strcmp("prefix", g_el.prefix));
#else
- mt_fail(g_options.prefix == NULL);
+ mt_fail(g_el.prefix == NULL);
#endif
el_option(EL_PREFIX, NULL);
- mt_fail(g_options.prefix == NULL);
+ mt_fail(g_el.prefix == NULL);
}
@@ -501,51 +501,51 @@ static void options_einval(void)
========================================================================== */
-static void options_global_options_after_options_cleanup(void)
+static void options_global_el_after_el_cleanup(void)
{
- struct el_options default_options; /* expected default options */
- struct el_options options; /* custom options to init */
+ struct el default_el; /* expected default el */
+ struct el el; /* custom el to init */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- memset(&default_options, 0, sizeof(default_options));
- default_options.outputs = EL_OUT_STDERR;
- default_options.level = EL_INFO;
- default_options.file_sync_level = EL_FATAL;
- default_options.level_current_msg = EL_DBG;
- default_options.colors = 0;
- default_options.timestamp = EL_TS_OFF;
- default_options.timestamp_timer = EL_TS_TM_TIME;
- default_options.timestamp_fractions = EL_TS_FRACT_OFF;
- default_options.print_log_level = 1;
- default_options.print_newline = 1;
- default_options.custom_puts = NULL;
- default_options.serial_fd = -1;
-
- default_options.funcinfo = 0;
- default_options.finfo = 0;
- default_options.frotate_number = 0;
- default_options.fcurrent_rotate = 0;
- default_options.frotate_size = 0;
- default_options.fpos = 0;
- default_options.file = NULL;
- default_options.file_sync_every = 32768;
- default_options.fname = NULL;
+ memset(&default_el, 0, sizeof(default_el));
+ default_el.outputs = EL_OUT_STDERR;
+ default_el.level = EL_INFO;
+ default_el.file_sync_level = EL_FATAL;
+ default_el.level_current_msg = EL_DBG;
+ default_el.colors = 0;
+ default_el.timestamp = EL_TS_OFF;
+ default_el.timestamp_timer = EL_TS_TM_TIME;
+ default_el.timestamp_fractions = EL_TS_FRACT_OFF;
+ default_el.print_log_level = 1;
+ default_el.print_newline = 1;
+ default_el.custom_puts = NULL;
+ default_el.serial_fd = -1;
+
+ default_el.funcinfo = 0;
+ default_el.finfo = 0;
+ default_el.frotate_number = 0;
+ default_el.fcurrent_rotate = 0;
+ default_el.frotate_size = 0;
+ default_el.fpos = 0;
+ default_el.file = NULL;
+ default_el.file_sync_every = 32768;
+ default_el.fname = NULL;
el_init();
- el_oinit(&options);
- mt_fail(memcmp(&g_options, &default_options, sizeof(default_options)) == 0);
- mt_fail(g_options.outputs == EL_OUT_STDERR);
- mt_fail(options.outputs == EL_OUT_STDERR);
+ el_oinit(&el);
+ mt_fail(memcmp(&g_el, &default_el, sizeof(default_el)) == 0);
+ mt_fail(g_el.outputs == EL_OUT_STDERR);
+ mt_fail(el.outputs == EL_OUT_STDERR);
- el_ocleanup(&options);
+ el_ocleanup(&el);
- /* global options should not be altered when el_ocleanup is called
+ /* global el should not be altered when el_ocleanup is called
*/
- mt_fail(memcmp(&g_options, &default_options, sizeof(default_options)) == 0);
- mt_fail(options.outputs == 0);
+ mt_fail(memcmp(&g_el, &default_el, sizeof(default_el)) == 0);
+ mt_fail(el.outputs == 0);
}
@@ -557,9 +557,9 @@ static void options_set_funcinfo(void)
{
#if ENABLE_FUNCINFO && (__STDC_VERSION__ >= 199901L)
mt_fok(el_option(EL_FUNCINFO, 0));
- mt_fail(g_options.funcinfo == 0);
+ mt_fail(g_el.funcinfo == 0);
mt_fok(el_option(EL_FUNCINFO, 1));
- mt_fail(g_options.funcinfo == 1);
+ mt_fail(g_el.funcinfo == 1);
mt_ferr(el_option(EL_FUNCINFO, 2), EINVAL);
mt_ferr(el_option(EL_FUNCINFO, 3), EINVAL);
@@ -576,13 +576,13 @@ static void options_set_funcinfo(void)
========================================================================== */
-static void options_get_global_options(void)
+static void options_get_global_el(void)
{
- const struct el_options *opts;
+ const struct el *opts;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- opts = el_get_options();
- mt_fail(opts == &g_options);
+ opts = el_get_el();
+ mt_fail(opts == &g_el);
}
@@ -616,7 +616,7 @@ void el_options_test_group(void)
mt_run(options_ooption_test);
mt_run(options_einval);
mt_run(options_prefix);
- mt_run(options_global_options_after_options_cleanup);
+ mt_run(options_global_el_after_el_cleanup);
mt_run(options_set_funcinfo);
- mt_run(options_get_global_options);
+ mt_run(options_get_global_el);
}
diff --git a/tst/test-el-pbinary.c b/tst/test-el-pbinary.c
index 4b6bb41..befd28d 100644
--- a/tst/test-el-pbinary.c
+++ b/tst/test-el-pbinary.c
@@ -136,7 +136,7 @@ static int pbinary_check(void)
{
slevel = expected.level > EL_DBG ? EL_DBG : expected.level;
- if (expected.level > g_options.level)
+ if (expected.level > g_el.level)
{
/*
* log should not have been printed due to current log level
@@ -170,7 +170,7 @@ static int pbinary_check(void)
* check printing timestamp
*/
- if (g_options.timestamp != EL_TS_OFF)
+ if (g_el.timestamp != EL_TS_OFF)
{
# ifdef LLONG_MAX
unsigned long long tmp;
@@ -200,7 +200,7 @@ static int pbinary_check(void)
* fraction of seconds checks makes sense only when ts is set
*/
- if (g_options.timestamp_fractions)
+ if (g_el.timestamp_fractions)
{
# ifdef LLONG_MAX
unsigned long long usec;
diff --git a/tst/test-el-perror.c b/tst/test-el-perror.c
index a7fd5d3..eb8fb99 100644
--- a/tst/test-el-perror.c
+++ b/tst/test-el-perror.c
@@ -143,22 +143,21 @@ static void perror_user_message(void)
========================================================================== */
-static void perror_custom_options_user_message(void)
+static void perror_custom_el_user_message(void)
{
- struct el_options opts;
+ struct el el;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- el_oinit(&opts);
- el_ooption(&opts, EL_CUSTOM_PUTS, print_to_buffer, logbuf);
- el_ooption(&opts, EL_PRINT_LEVEL, 0);
- el_ooption(&opts, EL_OUT, EL_OUT_CUSTOM);
+ el_oinit(&el);
+ el_ooption(&el, EL_CUSTOM_PUTS, print_to_buffer, logbuf);
+ el_ooption(&el, EL_PRINT_LEVEL, 0);
+ el_ooption(&el, EL_OUT, EL_OUT_CUSTOM);
errno = 1;
- el_operror(ELF, &opts, "additional message");
+ el_operror(ELF, &el, "additional message");
mt_fok(strncmp(logbuf, "additional message\n"
"errno num: 1, strerror: ", 43));
-
}
@@ -179,5 +178,5 @@ void el_perror_test_group(void)
mt_run(perror_no_message);
mt_run(perror_user_message);
- mt_run(perror_custom_options_user_message);
+ mt_run(perror_custom_el_user_message);
}
diff --git a/tst/test-el-print.c b/tst/test-el-print.c
index 61e8ba1..1cf64c0 100644
--- a/tst/test-el-print.c
+++ b/tst/test-el-print.c
@@ -159,7 +159,7 @@ static int print_check(void)
{
slevel = expected.level > EL_DBG ? EL_DBG : expected.level;
- if (expected.level > g_options.level)
+ if (expected.level > g_el.level)
{
/*
* log should not have been printed due to current log level
@@ -170,7 +170,7 @@ static int print_check(void)
continue;
}
- if (g_options.colors)
+ if (g_el.colors)
{
if (strncmp(msg, color[slevel], 5) != 0)
{
@@ -192,7 +192,7 @@ static int print_check(void)
* check printing timestamp
*/
- if (g_options.timestamp == EL_TS_LONG)
+ if (g_el.timestamp == EL_TS_LONG)
{
IS_CHAR('[');
IS_DIGIT();
@@ -215,11 +215,11 @@ static int print_check(void)
IS_DIGIT();
IS_DIGIT();
- if (g_options.timestamp_fractions)
+ if (g_el.timestamp_fractions)
{
IS_CHAR('.');
- for (i = 0; i != 3 * g_options.timestamp_fractions; ++i)
+ for (i = 0; i != 3 * g_el.timestamp_fractions; ++i)
{
IS_DIGIT();
}
@@ -228,11 +228,11 @@ static int print_check(void)
IS_CHAR(']');
}
- else if (g_options.timestamp == EL_TS_SHORT)
+ else if (g_el.timestamp == EL_TS_SHORT)
{
IS_CHAR('[');
- if (g_options.timestamp_fractions)
+ if (g_el.timestamp_fractions)
{
while (*msg != '.')
{
@@ -241,7 +241,7 @@ static int print_check(void)
++msg; /* skip the '.' character */
- for (i = 0; i != 3 * g_options.timestamp_fractions; ++i)
+ for (i = 0; i != 3 * g_el.timestamp_fractions; ++i)
{
IS_DIGIT();
}
@@ -256,7 +256,7 @@ static int print_check(void)
IS_CHAR(']');
}
- else if (g_options.timestamp == EL_TS_OFF)
+ else if (g_el.timestamp == EL_TS_OFF)
{
/*
* we check for nothing here
@@ -275,7 +275,7 @@ static int print_check(void)
* check printing file information
*/
- if (g_options.finfo && expected.file != NULL && expected.line != 0)
+ if (g_el.finfo && expected.file != NULL && expected.line != 0)
{
char expected_file[8192];
char f_func_info_separator;
@@ -320,7 +320,7 @@ static int print_check(void)
* [file.c:2:foo()] instead of [file.c:2]
*/
- f_func_info_separator = g_options.funcinfo ? ':' : ']';
+ f_func_info_separator = g_el.funcinfo ? ':' : ']';
while (*msg != f_func_info_separator)
{
@@ -359,9 +359,9 @@ static int print_check(void)
/* check for function information
*/
- if (g_options.funcinfo && expected.func != NULL)
+ if (g_el.funcinfo && expected.func != NULL)
{
- if (g_options.finfo == 0 || expected.file == NULL ||
+ if (g_el.finfo == 0 || expected.file == NULL ||
expected.line == 0)
{
/* file info was not printed, so check for opening
@@ -409,9 +409,9 @@ static int print_check(void)
IS_CHAR(']');
}
- if ((g_options.finfo && expected.file != NULL && expected.line != 0) ||
- g_options.timestamp != EL_TS_OFF ||
- (g_options.funcinfo && expected.func != NULL))
+ if ((g_el.finfo && expected.file != NULL && expected.line != 0) ||
+ g_el.timestamp != EL_TS_OFF ||
+ (g_el.funcinfo && expected.func != NULL))
{
/*
* prefix or timestamp information is enabled, in that case
@@ -428,7 +428,7 @@ static int print_check(void)
* check printing log level
*/
- if (g_options.print_log_level)
+ if (g_el.print_log_level)
{
if (*msg++ != levelstr[slevel])
{
@@ -445,13 +445,13 @@ static int print_check(void)
* check for prefix
*/
- if (g_options.prefix)
+ if (g_el.prefix)
{
char expected_prefix[EL_PREFIX_LEN + 1] = {0};
size_t expected_prefix_len;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- strncat(expected_prefix, g_options.prefix, EL_PREFIX_LEN);
+ strncat(expected_prefix, g_el.prefix, EL_PREFIX_LEN);
expected_prefix_len = strlen(expected_prefix);
if (strncmp(expected_prefix, msg, expected_prefix_len) != 0)
@@ -471,7 +471,7 @@ static int print_check(void)
msg += msglen;
- if (g_options.colors)
+ if (g_el.colors)
{
if (strncmp(msg, color[8], 4) != 0)
{
@@ -489,7 +489,7 @@ static int print_check(void)
msg += 4;
}
- if (g_options.print_newline)
+ if (g_el.print_newline)
{
if (*msg != '\n')
{