p = paths_user;
for (i = 0; i < _EXEC_DIRECTORY_TYPE_MAX; i++) {
- r = sd_path_home(p[i].type, p[i].suffix, &m->prefix[i]);
+ r = sd_path_lookup(p[i].type, p[i].suffix, &m->prefix[i]);
if (r < 0)
return r;
}
return -ENOMEM;
/* ~/.config/systemd/environment.d */
- r = sd_path_home(SD_PATH_USER_CONFIGURATION, "environment.d", &c);
+ r = sd_path_lookup(SD_PATH_USER_CONFIGURATION, "environment.d", &c);
if (r < 0)
return r;
return -EOPNOTSUPP;
}
-_public_ int sd_path_home(uint64_t type, const char *suffix, char **path) {
+_public_ int sd_path_lookup(uint64_t type, const char *suffix, char **path) {
_cleanup_free_ char *buffer = NULL;
const char *ret;
char *cc;
_cleanup_strv_free_ char **l = NULL;
- r = sd_path_search(type, suffix, &l);
+ r = sd_path_lookup_strv(type, suffix, &l);
if (r < 0)
return r;
return -EOPNOTSUPP;
}
-_public_ int sd_path_search(uint64_t type, const char *suffix, char ***paths) {
+_public_ int sd_path_lookup_strv(uint64_t type, const char *suffix, char ***paths) {
char **i, **j;
_cleanup_strv_free_ char **l = NULL, **n = NULL;
int r;
char *p;
- r = sd_path_home(type, suffix, &p);
+ r = sd_path_lookup(type, suffix, &p);
if (r < 0)
return r;
_cleanup_free_ char *p = NULL;
int q;
- q = sd_path_home(i, arg_suffix, &p);
+ q = sd_path_lookup(i, arg_suffix, &p);
if (q == -ENXIO)
continue;
if (q < 0) {
if (streq(path_table[i], n)) {
_cleanup_free_ char *p = NULL;
- r = sd_path_home(i, arg_suffix, &p);
+ r = sd_path_lookup(i, arg_suffix, &p);
if (r < 0)
return log_error_errno(r, "Failed to query %s: %m", n);
_SD_PATH_MAX,
};
-int sd_path_home(uint64_t type, const char *suffix, char **path);
-int sd_path_search(uint64_t type, const char *suffix, char ***paths);
+int sd_path_lookup(uint64_t type, const char *suffix, char **path);
+int sd_path_lookup_strv(uint64_t type, const char *suffix, char ***paths);
_SD_END_DECLARATIONS;
#include "strv.h"
#include "tests.h"
-static void test_sd_path_home(void) {
+static void test_sd_path_lookup(void) {
log_info("/* %s */", __func__);
for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
_cleanup_free_ char *t, *s;
- assert_se(sd_path_home(i, NULL, &t) == 0);
+ assert_se(sd_path_lookup(i, NULL, &t) == 0);
assert_se(t);
log_info("%02"PRIu64": \"%s\"", i, t);
- assert_se(sd_path_home(i, "suffix", &s) == 0);
+ assert_se(sd_path_lookup(i, "suffix", &s) == 0);
assert_se(s);
log_info("%02"PRIu64": \"%s\"", i, s);
assert_se(endswith(s, "/suffix"));
}
char *tt;
- assert_se(sd_path_home(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
+ assert_se(sd_path_lookup(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
}
-static void test_sd_path_search(void) {
+static void test_sd_path_lookup_strv(void) {
log_info("/* %s */", __func__);
for (uint64_t i = 0; i < _SD_PATH_MAX; i++) {
_cleanup_strv_free_ char **t, **s;
char **item;
- assert_se(sd_path_search(i, NULL, &t) == 0);
+ assert_se(sd_path_lookup_strv(i, NULL, &t) == 0);
assert_se(t);
log_info("%02"PRIu64":", i);
STRV_FOREACH(item, t)
log_debug(" %s", *item);
- assert_se(sd_path_search(i, "suffix", &s) == 0);
+ assert_se(sd_path_lookup_strv(i, "suffix", &s) == 0);
assert_se(s);
log_info("%02"PRIu64":", i);
STRV_FOREACH(item, s) {
}
char *tt;
- assert_se(sd_path_home(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
+ assert_se(sd_path_lookup(_SD_PATH_MAX, NULL, &tt) == -EOPNOTSUPP);
}
int main(void) {
test_setup_logging(LOG_DEBUG);
- test_sd_path_home();
- test_sd_path_search();
+ test_sd_path_lookup();
+ test_sd_path_lookup_strv();
}
i = PTR_TO_UINT(data);
assert(i < ELEMENTSOF(paths_system));
- return sd_path_home(paths[i].type, paths[i].suffix, ret);
+ return sd_path_lookup(paths[i].type, paths[i].suffix, ret);
}
static int log_unresolvable_specifier(const char *filename, unsigned line) {