1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

shared: add formats-util.h

This commit is contained in:
Ronny Chevalier 2015-04-10 20:43:52 +02:00
parent 05a08cb60f
commit 6482f6269c
77 changed files with 139 additions and 41 deletions

View File

@ -41,6 +41,7 @@
#include "capability.h"
#include "bus-xml-policy.h"
#include "proxy.h"
#include "formats-util.h"
static char *arg_address = NULL;
static char **arg_configuration = NULL;

View File

@ -27,6 +27,7 @@
#include "bus-internal.h"
#include "bus-xml-policy.h"
#include "sd-login.h"
#include "formats-util.h"
static void policy_item_free(PolicyItem *i) {
assert(i);

View File

@ -42,6 +42,7 @@
#include "driver.h"
#include "proxy.h"
#include "synthesize.h"
#include "formats-util.h"
static int proxy_create_destination(Proxy *p, const char *destination, const char *local_sec, bool negotiate_fds) {
_cleanup_bus_close_unref_ sd_bus *b = NULL;

View File

@ -37,6 +37,7 @@
#include "strv.h"
#include "def.h"
#include "proxy.h"
#include "formats-util.h"
static char *arg_address = NULL;
static char *arg_command_line_buffer = NULL;

View File

@ -40,6 +40,7 @@
#include "dbus-automount.h"
#include "bus-util.h"
#include "bus-error.h"
#include "formats-util.h"
static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
[AUTOMOUNT_DEAD] = UNIT_INACTIVE,

View File

@ -30,6 +30,7 @@
#include "bus-policy.h"
#include "dbus-busname.h"
#include "busname.h"
#include "formats-util.h"
static const UnitActiveState state_translation_table[_BUSNAME_STATE_MAX] = {
[BUSNAME_DEAD] = UNIT_INACTIVE,

View File

@ -40,6 +40,7 @@
#include "dbus-snapshot.h"
#include "dbus-execute.h"
#include "bus-common-errors.h"
#include "formats-util.h"
static int property_get_version(
sd_bus *bus,

View File

@ -76,6 +76,7 @@
#include "smack-util.h"
#include "bus-endpoint.h"
#include "cap-list.h"
#include "formats-util.h"
#ifdef HAVE_APPARMOR
#include "apparmor-util.h"

View File

@ -27,6 +27,7 @@
#include "util.h"
#include "killall.h"
#include "set.h"
#include "formats-util.h"
#define TIMEOUT_USEC (10 * USEC_PER_SEC)

View File

@ -72,6 +72,7 @@
#include "ima-setup.h"
#include "smack-setup.h"
#include "kmod-setup.h"
#include "formats-util.h"
static enum {
ACTION_RUN,

View File

@ -40,6 +40,7 @@
#include "special.h"
#include "exit-status.h"
#include "fstab-util.h"
#include "formats-util.h"
#define RETRY_UMOUNT_MAX 32

View File

@ -45,6 +45,7 @@
#include "bus-error.h"
#include "bus-util.h"
#include "bus-kernel.h"
#include "formats-util.h"
static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = {
[SERVICE_DEAD] = UNIT_INACTIVE,

View File

@ -48,6 +48,7 @@
#include "dbus-socket.h"
#include "unit.h"
#include "socket.h"
#include "formats-util.h"
static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
[SOCKET_DEAD] = UNIT_INACTIVE,

View File

@ -35,6 +35,7 @@
#include "virt.h"
#include "udev-util.h"
#include "fstab-util.h"
#include "formats-util.h"
static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
[SWAP_DEAD] = UNIT_INACTIVE,

View File

@ -26,6 +26,7 @@
#include "unit-printf.h"
#include "macro.h"
#include "cgroup-util.h"
#include "formats-util.h"
static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) {
Unit *u = userdata;

View File

@ -46,6 +46,7 @@
#include "dbus.h"
#include "execute.h"
#include "dropin.h"
#include "formats-util.h"
const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
[UNIT_SERVICE] = &service_vtable,

View File

@ -36,6 +36,7 @@
#include "bus-util.h"
#include "bus-error.h"
#include "def.h"
#include "formats-util.h"
#define SERVER_FD_MAX 16
#define TIMEOUT_MSEC ((int) (DEFAULT_EXIT_USEC/USEC_PER_MSEC))

View File

@ -34,6 +34,7 @@
#include "conf-parser.h"
#include "sigbus.h"
#include "journal-upload.h"
#include "formats-util.h"
#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-upload.pem"
#define CERT_FILE CERTIFICATE_ROOT "/certs/journal-upload.pem"

View File

@ -26,6 +26,7 @@
#include "fileio.h"
#include "journald-server.h"
#include "journald-console.h"
#include "formats-util.h"
static bool prefix_timestamp(void) {

View File

@ -31,6 +31,7 @@
#include "journald-server.h"
#include "journald-kmsg.h"
#include "journald-syslog.h"
#include "formats-util.h"
void server_forward_kmsg(
Server *s,

View File

@ -50,6 +50,7 @@
#include "journald-audit.h"
#include "journald-server.h"
#include "acl-util.h"
#include "formats-util.h"
#ifdef HAVE_SELINUX
#include <selinux/selinux.h>

View File

@ -31,6 +31,7 @@
#include "journald-kmsg.h"
#include "journald-console.h"
#include "journald-wall.h"
#include "formats-util.h"
/* Warn once every 30s if we missed syslog message */
#define WARN_FORWARD_SYSLOG_MISSED_USEC (30 * USEC_PER_SEC)

View File

@ -22,6 +22,7 @@
#include "utmp-wtmp.h"
#include "journald-server.h"
#include "journald-wall.h"
#include "formats-util.h"
void server_forward_wall(
Server *s,

View File

@ -30,6 +30,7 @@
#include "journald-syslog.h"
#include "sigbus.h"
#include "formats-util.h"
int main(int argc, char *argv[]) {
Server server;

View File

@ -42,6 +42,7 @@
#include "catalog.h"
#include "replace-var.h"
#include "fileio.h"
#include "formats-util.h"
#define JOURNAL_FILES_MAX 7168

View File

@ -25,6 +25,7 @@
#include "util.h"
#include "macro.h"
#include "stacktrace.h"
#include "formats-util.h"
#define FRAMES_MAX 64
#define THREADS_MAX 64

View File

@ -23,6 +23,7 @@
#include <linux/capability.h>
#include "util.h"
#include "formats-util.h"
#include "capability.h"
#include "cgroup-util.h"
#include "fileio.h"

View File

@ -24,6 +24,7 @@
#include "strv.h"
#include "macro.h"
#include "cap-list.h"
#include "formats-util.h"
#include "bus-message.h"
#include "bus-internal.h"

View File

@ -39,6 +39,7 @@
#include "memfd-util.h"
#include "capability.h"
#include "fileio.h"
#include "formats-util.h"
#include "bus-internal.h"
#include "bus-message.h"

View File

@ -29,6 +29,7 @@
#include "missing.h"
#include "utf8.h"
#include "sd-daemon.h"
#include "formats-util.h"
#include "sd-bus.h"
#include "bus-socket.h"

View File

@ -27,6 +27,7 @@
#include "log.h"
#include "util.h"
#include "macro.h"
#include "formats-util.h"
#include "sd-bus.h"
#include "bus-error.h"

View File

@ -31,6 +31,7 @@
#include "strv.h"
#include "fileio.h"
#include "login-shared.h"
#include "formats-util.h"
#include "sd-login.h"
_public_ int sd_pid_get_session(pid_t pid, char **session) {

View File

@ -26,6 +26,7 @@
#include "util.h"
#include "strv.h"
#include "formats-util.h"
static void test_login(void) {
_cleanup_close_pair_ int pair[2] = { -1, -1 };

View File

@ -24,6 +24,7 @@
#include <unistd.h>
#include "util.h"
#include "formats-util.h"
#include "refcnt.h"
#include "missing.h"

View File

@ -32,6 +32,7 @@
#include "libudev-private.h"
#include "socket-util.h"
#include "missing.h"
#include "formats-util.h"
/**
* SECTION:libudev-monitor

View File

@ -31,6 +31,7 @@
#include "util.h"
#include "build.h"
#include "strv.h"
#include "formats-util.h"
static const char* arg_what = "idle:sleep:shutdown";
static const char* arg_who = NULL;

View File

@ -23,6 +23,7 @@
#include <string.h>
#include "util.h"
#include "formats-util.h"
#include "acl-util.h"
#include "set.h"
#include "logind-acl.h"

View File

@ -27,6 +27,7 @@
#include "bus-util.h"
#include "bus-error.h"
#include "logind-action.h"
#include "formats-util.h"
int manager_handle_action(
Manager *m,

View File

@ -40,6 +40,7 @@
#include "selinux-util.h"
#include "efivars.h"
#include "logind.h"
#include "formats-util.h"
int manager_get_session_from_creds(Manager *m, sd_bus_message *message, const char *name, sd_bus_error *error, Session **ret) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;

View File

@ -28,6 +28,7 @@
#include "mkdir.h"
#include "logind-inhibit.h"
#include "fileio.h"
#include "formats-util.h"
Inhibitor* inhibitor_new(Manager *m, const char* id) {
Inhibitor *i;

View File

@ -29,6 +29,7 @@
#include "logind-acl.h"
#include "util.h"
#include "mkdir.h"
#include "formats-util.h"
Seat *seat_new(Manager *m, const char *id) {
Seat *s;

View File

@ -37,6 +37,7 @@
#include "bus-util.h"
#include "bus-error.h"
#include "logind-session.h"
#include "formats-util.h"
#define RELEASE_USEC (20*USEC_PER_SEC)

View File

@ -26,6 +26,7 @@
#include "bus-util.h"
#include "logind.h"
#include "logind-user.h"
#include "formats-util.h"
static int property_get_display(
sd_bus *bus,

View File

@ -38,6 +38,7 @@
#include "clean-ipc.h"
#include "logind-user.h"
#include "smack-util.h"
#include "formats-util.h"
User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name) {
User *u;

View File

@ -32,6 +32,7 @@
#include "bus-error.h"
#include "logind.h"
#include "udev-util.h"
#include "formats-util.h"
Manager *manager_new(void) {
Manager *m;

View File

@ -40,6 +40,7 @@
#include "socket-util.h"
#include "fileio.h"
#include "bus-error.h"
#include "formats-util.h"
static int parse_argv(
pam_handle_t *handle,

View File

@ -42,6 +42,7 @@
#include "bus-internal.h"
#include "machine.h"
#include "machine-dbus.h"
#include "formats-util.h"
static int property_get_id(
sd_bus *bus,

View File

@ -35,6 +35,7 @@
#include "bus-error.h"
#include "machine.h"
#include "machine-dbus.h"
#include "formats-util.h"
Machine* machine_new(Manager *manager, const char *name) {
Machine *m;

View File

@ -35,6 +35,7 @@
#include "image-dbus.h"
#include "machined.h"
#include "machine-dbus.h"
#include "formats-util.h"
static int property_get_pool_path(
sd_bus *bus,

View File

@ -30,6 +30,7 @@
#include "label.h"
#include "machine-image.h"
#include "machined.h"
#include "formats-util.h"
Manager *manager_new(void) {
Manager *m;

View File

@ -32,6 +32,7 @@
#include "log.h"
#include "build.h"
#include "env-util.h"
#include "formats-util.h"
static bool arg_ready = false;
static pid_t arg_pid = 0;

View File

@ -91,6 +91,7 @@
#include "in-addr-util.h"
#include "fw-util.h"
#include "local-addresses.h"
#include "formats-util.h"
#ifdef HAVE_SECCOMP
#include "seccomp-util.h"

View File

@ -34,6 +34,7 @@
#include "bus-error.h"
#include "calendarspec.h"
#include "ptyfwd.h"
#include "formats-util.h"
static bool arg_scope = false;
static bool arg_remain_after_exit = false;

View File

@ -32,6 +32,7 @@
#include <sys/signalfd.h>
#include "util.h"
#include "formats-util.h"
#include "mkdir.h"
#include "strv.h"

View File

@ -25,6 +25,7 @@
#include <errno.h>
#include "util.h"
#include "formats-util.h"
#include "macro.h"
#include "path-util.h"
#include "cgroup-util.h"

View File

@ -33,6 +33,7 @@
#include "set.h"
#include "macro.h"
#include "util.h"
#include "formats-util.h"
#include "path-util.h"
#include "unit-name.h"
#include "fileio.h"

View File

@ -29,6 +29,7 @@
#include <mqueue.h>
#include "util.h"
#include "formats-util.h"
#include "strv.h"
#include "clean-ipc.h"

63
src/shared/formats-util.h Normal file
View File

@ -0,0 +1,63 @@
#pragma once
/***
This file is part of systemd.
Copyright 2015 Ronny Chevalier
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <inttypes.h>
#if SIZEOF_PID_T == 4
# define PID_PRI PRIi32
#elif SIZEOF_PID_T == 2
# define PID_PRI PRIi16
#else
# error Unknown pid_t size
#endif
#define PID_FMT "%" PID_PRI
#if SIZEOF_UID_T == 4
# define UID_FMT "%" PRIu32
#elif SIZEOF_UID_T == 2
# define UID_FMT "%" PRIu16
#else
# error Unknown uid_t size
#endif
#if SIZEOF_GID_T == 4
# define GID_FMT "%" PRIu32
#elif SIZEOF_GID_T == 2
# define GID_FMT "%" PRIu16
#else
# error Unknown gid_t size
#endif
#if SIZEOF_TIME_T == 8
# define PRI_TIME PRIi64
#elif SIZEOF_TIME_T == 4
# define PRI_TIME PRIu32
#else
# error Unknown time_t size
#endif
#if SIZEOF_RLIM_T == 8
# define RLIM_FMT "%" PRIu64
#elif SIZEOF_RLIM_T == 4
# define RLIM_FMT "%" PRIu32
#else
# error Unknown rlim_t size
#endif

View File

@ -25,6 +25,7 @@
#include "unit-name.h"
#include "util.h"
#include "install-printf.h"
#include "formats-util.h"
static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) {
InstallInfo *i = userdata;

View File

@ -34,6 +34,7 @@
#include "missing.h"
#include "macro.h"
#include "socket-util.h"
#include "formats-util.h"
#define SNDBUF_SIZE (8*1024*1024)

View File

@ -31,6 +31,7 @@
#include "utf8.h"
#include "hashmap.h"
#include "journal-internal.h"
#include "formats-util.h"
/* up to three lines (each up to 100 characters),
or 300 characters, whichever is less */

View File

@ -35,6 +35,7 @@
#include "socket-util.h"
#include "missing.h"
#include "fileio.h"
#include "formats-util.h"
int socket_address_parse(SocketAddress *a, const char *s) {
char *e, *n;

View File

@ -92,6 +92,7 @@
#include "virt.h"
#include "def.h"
#include "sparse-endian.h"
#include "formats-util.h"
/* Put this test here for a lack of better place */
assert_cc(EAGAIN == EWOULDBLOCK);

View File

@ -43,50 +43,10 @@
#include <sys/inotify.h>
#include <sys/statfs.h>
#if SIZEOF_PID_T == 4
# define PID_PRI PRIi32
#elif SIZEOF_PID_T == 2
# define PID_PRI PRIi16
#else
# error Unknown pid_t size
#endif
#define PID_FMT "%" PID_PRI
#if SIZEOF_UID_T == 4
# define UID_FMT "%" PRIu32
#elif SIZEOF_UID_T == 2
# define UID_FMT "%" PRIu16
#else
# error Unknown uid_t size
#endif
#if SIZEOF_GID_T == 4
# define GID_FMT "%" PRIu32
#elif SIZEOF_GID_T == 2
# define GID_FMT "%" PRIu16
#else
# error Unknown gid_t size
#endif
#if SIZEOF_TIME_T == 8
# define PRI_TIME PRIi64
#elif SIZEOF_TIME_T == 4
# define PRI_TIME PRIu32
#else
# error Unknown time_t size
#endif
#if SIZEOF_RLIM_T == 8
# define RLIM_FMT "%" PRIu64
#elif SIZEOF_RLIM_T == 4
# define RLIM_FMT "%" PRIu32
#else
# error Unknown rlim_t size
#endif
#include "macro.h"
#include "missing.h"
#include "time-util.h"
#include "formats-util.h"
/* What is interpreted as whitespace? */
#define WHITESPACE " \t\n\r"

View File

@ -35,6 +35,7 @@
#include "utmp-wtmp.h"
#include "mkdir.h"
#include "fileio.h"
#include "formats-util.h"
union shutdown_buffer {
struct sd_shutdown_command command;

View File

@ -69,6 +69,7 @@
#include "mkdir.h"
#include "dropin.h"
#include "efivars.h"
#include "formats-util.h"
static char **arg_types = NULL;
static char **arg_states = NULL;

View File

@ -38,6 +38,7 @@
#include "fileio-label.h"
#include "uid-range.h"
#include "selinux-util.h"
#include "formats-util.h"
typedef enum ItemType {
ADD_USER = 'u',

View File

@ -23,6 +23,7 @@
#include "util.h"
#include "cgroup-util.h"
#include "test-helper.h"
#include "formats-util.h"
static void check_p_d_u(const char *path, int code, const char *result) {
_cleanup_free_ char *unit = NULL;

View File

@ -24,6 +24,7 @@
#include "log.h"
#include "util.h"
#include "formats-util.h"
int main(int argc, char* argv[]) {

View File

@ -25,6 +25,7 @@
#include <stdio.h>
#include "util.h"
#include "formats-util.h"
int main(int argc, char** argv) {
const char *p = argv[1] ?: "/tmp";

View File

@ -56,6 +56,7 @@
#include "selinux-util.h"
#include "btrfs-util.h"
#include "acl-util.h"
#include "formats-util.h"
/* This reads all files listed in /etc/tmpfiles.d/?*.conf and creates
* them in the file system. This is intended to be used to create

View File

@ -19,6 +19,7 @@
#include <sys/un.h>
#include "socket-util.h"
#include "formats-util.h"
#include "udev.h"
/* wire protocol magic must match */

View File

@ -32,6 +32,7 @@
#include "udev.h"
#include "rtnl-util.h"
#include "formats-util.h"
struct udev_event *udev_event_new(struct udev_device *dev) {
struct udev *udev = udev_device_get_udev(dev);

View File

@ -28,6 +28,7 @@
#include "udev.h"
#include "smack-util.h"
#include "selinux-util.h"
#include "formats-util.h"
static int node_symlink(struct udev_device *dev, const char *node, const char *slink) {
struct stat stats;

View File

@ -27,6 +27,7 @@
#include "udev.h"
#include "udev-util.h"
#include "formats-util.h"
static bool udev_exit;

View File

@ -48,6 +48,7 @@
#include "selinux-util.h"
#include "udev.h"
#include "udev-util.h"
#include "formats-util.h"
static struct udev_rules *rules;
static struct udev_ctrl *udev_ctrl;

View File

@ -37,6 +37,7 @@
#include "bus-util.h"
#include "bus-error.h"
#include "unit-name.h"
#include "formats-util.h"
typedef struct Context {
sd_bus *bus;