4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek#pragma once
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek/***
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek This file is part of systemd.
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek Copyright 2015 Zbigniew Jędrzejewski-Szmek
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek (at your option) any later version.
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek***/
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek#include "macro.h"
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmek
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmekconst char *audit_type_to_string(int type);
4733607eec54034d2083534ebff2dad89c28574eZbigniew Jędrzejewski-Szmekint audit_type_from_string(const char *s);
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek/* This is inspired by DNS TYPEnnn formatting */
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek#define audit_type_name_alloca(type) \
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek ({ \
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek const char *_s_; \
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek _s_ = audit_type_to_string(type); \
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek if (!_s_) { \
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek _s_ = alloca(strlen("AUDIT") + DECIMAL_STR_MAX(int)); \
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek sprintf((char*) _s_, "AUDIT%04i", type); \
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek } \
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek _s_; \
8bb3626dac93c0157989fb87afe0212958d7dbb4Zbigniew Jędrzejewski-Szmek })