1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 00:51:24 +03:00

install: when exporting prefix InstallInfo to become UnitFileInstallInfo

All other types exported from install.h should be namespaces like this,
hence namespace InstallInfo the same way.

Also, remove external forward definition of UnitFileScope type.
This commit is contained in:
Lennart Poettering 2015-05-11 22:53:54 +02:00
parent b2c23da8ce
commit cab6235f74
6 changed files with 55 additions and 45 deletions

View File

@ -28,7 +28,7 @@
#include "formats-util.h"
static int specifier_prefix_and_instance(char specifier, void *data, void *userdata, char **ret) {
InstallInfo *i = userdata;
UnitFileInstallInfo *i = userdata;
assert(i);
@ -36,7 +36,7 @@ static int specifier_prefix_and_instance(char specifier, void *data, void *userd
}
static int specifier_prefix(char specifier, void *data, void *userdata, char **ret) {
InstallInfo *i = userdata;
UnitFileInstallInfo *i = userdata;
assert(i);
@ -44,7 +44,7 @@ static int specifier_prefix(char specifier, void *data, void *userdata, char **r
}
static int specifier_instance(char specifier, void *data, void *userdata, char **ret) {
InstallInfo *i = userdata;
UnitFileInstallInfo *i = userdata;
char *instance;
int r;
@ -65,7 +65,7 @@ static int specifier_instance(char specifier, void *data, void *userdata, char *
}
static int specifier_user_name(char specifier, void *data, void *userdata, char **ret) {
InstallInfo *i = userdata;
UnitFileInstallInfo *i = userdata;
const char *username;
_cleanup_free_ char *tmp = NULL;
char *printed = NULL;
@ -102,7 +102,7 @@ static int specifier_user_name(char specifier, void *data, void *userdata, char
}
int install_full_printf(InstallInfo *i, const char *format, char **ret) {
int install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret) {
/* This is similar to unit_full_printf() but does not support
* anything path-related.

View File

@ -22,4 +22,5 @@
#pragma once
#include "install.h"
int install_full_printf(InstallInfo *i, const char *format, char **ret);
int install_full_printf(UnitFileInstallInfo *i, const char *format, char **ret);

View File

@ -809,7 +809,7 @@ void unit_file_changes_free(UnitFileChange *changes, unsigned n_changes) {
free(changes);
}
static void install_info_free(InstallInfo *i) {
static void install_info_free(UnitFileInstallInfo *i) {
assert(i);
free(i->name);
@ -823,7 +823,7 @@ static void install_info_free(InstallInfo *i) {
}
static void install_info_hashmap_free(OrderedHashmap *m) {
InstallInfo *i;
UnitFileInstallInfo *i;
if (!m)
return;
@ -847,7 +847,7 @@ static int install_info_add(
InstallContext *c,
const char *name,
const char *path) {
InstallInfo *i = NULL;
UnitFileInstallInfo *i = NULL;
int r;
assert(c);
@ -867,7 +867,7 @@ static int install_info_add(
if (r < 0)
return r;
i = new0(InstallInfo, 1);
i = new0(UnitFileInstallInfo, 1);
if (!i)
return -ENOMEM;
@ -926,7 +926,7 @@ static int config_parse_also(
size_t l;
const char *word, *state;
InstallContext *c = data;
InstallInfo *i = userdata;
UnitFileInstallInfo *i = userdata;
assert(filename);
assert(lvalue);
@ -967,7 +967,7 @@ static int config_parse_user(
void *data,
void *userdata) {
InstallInfo *i = data;
UnitFileInstallInfo *i = data;
char *printed;
int r;
@ -997,7 +997,7 @@ static int config_parse_default_instance(
void *data,
void *userdata) {
InstallInfo *i = data;
UnitFileInstallInfo *i = data;
char *printed;
int r;
@ -1022,7 +1022,7 @@ static int config_parse_default_instance(
static int unit_file_load(
InstallContext *c,
InstallInfo *info,
UnitFileInstallInfo *info,
const char *path,
const char *root_dir,
bool allow_symlink,
@ -1082,7 +1082,7 @@ static int unit_file_load(
static int unit_file_search(
InstallContext *c,
InstallInfo *info,
UnitFileInstallInfo *info,
const LookupPaths *paths,
const char *root_dir,
bool allow_symlink,
@ -1159,7 +1159,7 @@ static int unit_file_can_install(
bool *also) {
_cleanup_(install_context_done) InstallContext c = {};
InstallInfo *i;
UnitFileInstallInfo *i;
int r;
assert(paths);
@ -1226,7 +1226,7 @@ static int create_symlink(
}
static int install_info_symlink_alias(
InstallInfo *i,
UnitFileInstallInfo *i,
const char *config_path,
bool force,
UnitFileChange **changes,
@ -1258,7 +1258,7 @@ static int install_info_symlink_alias(
}
static int install_info_symlink_wants(
InstallInfo *i,
UnitFileInstallInfo *i,
const char *config_path,
char **list,
const char *suffix,
@ -1315,7 +1315,7 @@ static int install_info_symlink_wants(
}
static int install_info_symlink_link(
InstallInfo *i,
UnitFileInstallInfo *i,
const LookupPaths *paths,
const char *config_path,
const char *root_dir,
@ -1343,7 +1343,7 @@ static int install_info_symlink_link(
}
static int install_info_apply(
InstallInfo *i,
UnitFileInstallInfo *i,
const LookupPaths *paths,
const char *config_path,
const char *root_dir,
@ -1383,7 +1383,7 @@ static int install_context_apply(
UnitFileChange **changes,
unsigned *n_changes) {
InstallInfo *i;
UnitFileInstallInfo *i;
int r, q;
assert(c);
@ -1428,7 +1428,7 @@ static int install_context_mark_for_removal(
const char *config_path,
const char *root_dir) {
InstallInfo *i;
UnitFileInstallInfo *i;
int r, q;
assert(c);
@ -1513,7 +1513,7 @@ int unit_file_add_dependency(
_cleanup_free_ char *config_path = NULL;
char **i;
int r;
InstallInfo *info;
UnitFileInstallInfo *info;
assert(scope >= 0);
assert(scope < _UNIT_FILE_SCOPE_MAX);
@ -1702,7 +1702,7 @@ int unit_file_set_default(
_cleanup_free_ char *config_path = NULL;
char *path;
int r;
InstallInfo *i = NULL;
UnitFileInstallInfo *i = NULL;
assert(scope >= 0);
assert(scope < _UNIT_FILE_SCOPE_MAX);

View File

@ -21,19 +21,27 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
typedef enum UnitFileScope UnitFileScope;
typedef enum UnitFileState UnitFileState;
typedef enum UnitFilePresetMode UnitFilePresetMode;
typedef enum UnitFileChangeType UnitFileChangeType;
typedef struct UnitFileChange UnitFileChange;
typedef struct UnitFileList UnitFileList;
typedef struct UnitFileInstallInfo UnitFileInstallInfo;
#include "hashmap.h"
#include "unit-name.h"
#include "path-lookup.h"
typedef enum UnitFileScope {
enum UnitFileScope {
UNIT_FILE_SYSTEM,
UNIT_FILE_GLOBAL,
UNIT_FILE_USER,
_UNIT_FILE_SCOPE_MAX,
_UNIT_FILE_SCOPE_INVALID = -1
} UnitFileScope;
};
typedef enum UnitFileState {
enum UnitFileState {
UNIT_FILE_ENABLED,
UNIT_FILE_ENABLED_RUNTIME,
UNIT_FILE_LINKED,
@ -46,35 +54,35 @@ typedef enum UnitFileState {
UNIT_FILE_INVALID,
_UNIT_FILE_STATE_MAX,
_UNIT_FILE_STATE_INVALID = -1
} UnitFileState;
};
typedef enum UnitFilePresetMode {
enum UnitFilePresetMode {
UNIT_FILE_PRESET_FULL,
UNIT_FILE_PRESET_ENABLE_ONLY,
UNIT_FILE_PRESET_DISABLE_ONLY,
_UNIT_FILE_PRESET_MAX,
_UNIT_FILE_PRESET_INVALID = -1
} UnitFilePresetMode;
};
typedef enum UnitFileChangeType {
enum UnitFileChangeType {
UNIT_FILE_SYMLINK,
UNIT_FILE_UNLINK,
_UNIT_FILE_CHANGE_TYPE_MAX,
_UNIT_FILE_CHANGE_TYPE_INVALID = -1
} UnitFileChangeType;
};
typedef struct UnitFileChange {
struct UnitFileChange {
UnitFileChangeType type;
char *path;
char *source;
} UnitFileChange;
};
typedef struct UnitFileList {
struct UnitFileList {
char *path;
UnitFileState state;
} UnitFileList;
};
typedef struct {
struct UnitFileInstallInfo {
char *name;
char *path;
char *user;
@ -85,7 +93,7 @@ typedef struct {
char **also;
char *default_instance;
} InstallInfo;
};
int unit_file_enable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, bool force, UnitFileChange **changes, unsigned *n_changes);
int unit_file_disable(UnitFileScope scope, bool runtime, const char *root_dir, char **files, UnitFileChange **changes, unsigned *n_changes);

View File

@ -23,8 +23,6 @@
#include "macro.h"
typedef enum UnitFileScope UnitFileScope;
typedef struct LookupPaths {
char **unit_path;
#ifdef HAVE_SYSV_COMPAT
@ -52,9 +50,12 @@ int lookup_paths_init(LookupPaths *p,
const char *generator,
const char *generator_early,
const char *generator_late);
void lookup_paths_free(LookupPaths *p);
#include "install.h"
int lookup_paths_init_from_scope(LookupPaths *paths,
UnitFileScope scope,
const char *root_dir);
void lookup_paths_free(LookupPaths *p);
#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)

View File

@ -453,12 +453,12 @@ static void test_install_printf(void) {
char name[] = "name.service",
path[] = "/run/systemd/system/name.service",
user[] = "xxxx-no-such-user";
InstallInfo i = {name, path, user};
InstallInfo i2 = {name, path, NULL};
UnitFileInstallInfo i = {name, path, user};
UnitFileInstallInfo i2 = {name, path, NULL};
char name3[] = "name@inst.service",
path3[] = "/run/systemd/system/name.service";
InstallInfo i3 = {name3, path3, user};
InstallInfo i4 = {name3, path3, NULL};
UnitFileInstallInfo i3 = {name3, path3, user};
UnitFileInstallInfo i4 = {name3, path3, NULL};
_cleanup_free_ char *mid, *bid, *host;