Blame src/internal.h

Packit 1422b7
/**
Packit 1422b7
 * @file internal.h
Packit 1422b7
 * @brief Internal things just needed for building the library, but
Packit 1422b7
 * not to be installed.
Packit 1422b7
 *//**
Packit 1422b7
 * @mainpage
Packit 1422b7
 * Liblognorm is an easy to use and fast samples-based log normalization
Packit 1422b7
 * library.
Packit 1422b7
 *
Packit 1422b7
 * It can be passed a stream of arbitrary log messages, one at a time, and for
Packit 1422b7
 * each message it will output well-defined name-value pairs and a set of
Packit 1422b7
 * tags describing the message.
Packit 1422b7
 *
Packit 1422b7
 * For further details, see it's initial announcement available at
Packit 1422b7
 *    http://blog.gerhards.net/2010/10/introducing-liblognorm.html
Packit 1422b7
 *
Packit 1422b7
 * The public interface of this library is describe in liblognorm.h.
Packit 1422b7
 *
Packit 1422b7
 * Liblognorm fully supports Unicode. Like most Linux tools, it operates
Packit 1422b7
 * on UTF-8 natively, called "passive mode". This was decided because we
Packit 1422b7
 * so can keep the size of data structures small while still supporting
Packit 1422b7
 * all of the world's languages (actually more than when we did UCS-2).
Packit 1422b7
 *
Packit 1422b7
 * At the  technical level, we can handle UTF-8 multibyte sequences transparently.
Packit 1422b7
 * Liblognorm needs to look at a few US-ASCII characters to do the
Packit 1422b7
 * sample base parsing (things to indicate fields), so this is no
Packit 1422b7
 * issue. Inside the parse tree, a multibyte sequence can simple be processed
Packit 1422b7
 * as if it were a sequence of different characters that make up a their
Packit 1422b7
 * own symbol each. In fact, this even allows for somewhat greater parsing
Packit 1422b7
 * speed.
Packit 1422b7
 *//*
Packit 1422b7
 *
Packit 1422b7
 * liblognorm - a fast samples-based log normalization library
Packit 1422b7
 * Copyright 2010-2018 by Rainer Gerhards and Adiscon GmbH.
Packit 1422b7
 *
Packit 1422b7
 * Modified by Pavel Levshin (pavel@levshin.spb.ru) in 2013
Packit 1422b7
 *
Packit 1422b7
 * This file is part of liblognorm.
Packit 1422b7
 *
Packit 1422b7
 * This library is free software; you can redistribute it and/or
Packit 1422b7
 * modify it under the terms of the GNU Lesser General Public
Packit 1422b7
 * License as published by the Free Software Foundation; either
Packit 1422b7
 * version 2.1 of the License, or (at your option) any later version.
Packit 1422b7
 *
Packit 1422b7
 * This library is distributed in the hope that it will be useful,
Packit 1422b7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 1422b7
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 1422b7
 * Lesser General Public License for more details.
Packit 1422b7
 *
Packit 1422b7
 * You should have received a copy of the GNU Lesser General Public
Packit 1422b7
 * License along with this library; if not, write to the Free Software
Packit 1422b7
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit 1422b7
 *
Packit 1422b7
 * A copy of the LGPL v2.1 can be found in the file "COPYING" in this distribution.
Packit 1422b7
 */
Packit 1422b7
#ifndef INTERNAL_H_INCLUDED
Packit 1422b7
#define	INTERNAL_H_INCLUDED
Packit 1422b7
Packit 1422b7
/* the jump-misses-init gcc warning is overdoing when we jump to the
Packit 1422b7
 * exit of a function to get proper finalization. So let's disable it.
Packit 1422b7
 * rgerhards, 2018-04-25
Packit 1422b7
 */
Packit 1422b7
#pragma GCC diagnostic ignored "-Wjump-misses-init"
Packit 1422b7
Packit 1422b7
#include "liblognorm.h"
Packit 1422b7
Packit 1422b7
#include <libestr.h>
Packit 1422b7
Packit 1422b7
/* we need to turn off this warning, as it also comes up in C99 mode, which
Packit 1422b7
 * we use.
Packit 1422b7
 */
Packit 1422b7
#pragma GCC diagnostic ignored "-Wdeclaration-after-statement"
Packit 1422b7
Packit 1422b7
/* support for simple error checking */
Packit 1422b7
Packit 1422b7
#define CHKR(x) \
Packit 1422b7
	if((r = (x)) != 0) goto done
Packit 1422b7
Packit 1422b7
#define CHKN(x) \
Packit 1422b7
	if((x) == NULL) { \
Packit 1422b7
		r = LN_NOMEM; \
Packit 1422b7
		goto done; \
Packit 1422b7
	}
Packit 1422b7
Packit 1422b7
#define FAIL(e) {r = (e); goto done;}
Packit 1422b7
Packit 1422b7
static inline char* ln_es_str2cstr(es_str_t **str)
Packit 1422b7
{
Packit 1422b7
	int r = -1;
Packit 1422b7
	char *buf;
Packit 1422b7
Packit 1422b7
	if (es_strlen(*str) == (*str)->lenBuf) {
Packit 1422b7
		CHKR(es_extendBuf(str, 1));
Packit 1422b7
	}
Packit 1422b7
	CHKN(buf = (char*)es_getBufAddr(*str));
Packit 1422b7
	buf[es_strlen(*str)] = '\0';
Packit 1422b7
	return buf;
Packit 1422b7
done:
Packit 1422b7
	return NULL;
Packit 1422b7
}
Packit 1422b7
Packit 1422b7
const char * ln_DataForDisplayCharTo(__attribute__((unused)) ln_ctx ctx, void *const pdata);
Packit 1422b7
const char * ln_DataForDisplayLiteral(__attribute__((unused)) ln_ctx ctx, void *const pdata);
Packit 1422b7
const char * ln_JsonConfLiteral(__attribute__((unused)) ln_ctx ctx, void *const pdata);
Packit 1422b7
Packit 1422b7
/* here we add some stuff from the compatibility layer */
Packit 1422b7
#ifndef HAVE_STRNDUP
Packit 1422b7
char * strndup(const char *s, size_t n);
Packit 1422b7
#endif
Packit 1422b7
Packit 1422b7
#endif /* #ifndef INTERNAL_H_INCLUDED */