}
_public_ int sd_uid_is_on_seat(uid_t uid, int require_active, const char *seat) {
- char *w, *state;
_cleanup_free_ char *t = NULL, *s = NULL, *p = NULL;
size_t l;
int r;
- const char *variable;
+ const char *word, *variable, *state;
assert_return(seat, -EINVAL);
if (asprintf(&t, UID_FMT, uid) < 0)
return -ENOMEM;
- FOREACH_WORD(w, l, s, state) {
- if (strneq(t, w, l))
+ FOREACH_WORD(word, l, s, state) {
+ if (strneq(t, word, l))
return 1;
}
return session_get_string(session, "CLASS", class);
}
+_public_ int sd_session_get_desktop(const char *session, char **desktop) {
+ _cleanup_free_ char *escaped = NULL;
+ char *t;
+ int r;
+
+ assert_return(desktop, -EINVAL);
+
+ r = session_get_string(session, "DESKTOP", &escaped);
+ if (r < 0)
+ return r;
+
+ t = cunescape(escaped);
+ if (!t)
+ return -ENOMEM;
+
+ *desktop = t;
+ return 0;
+}
+
_public_ int sd_session_get_display(const char *session, char **display) {
return session_get_string(session, "DISPLAY", display);
}
}
if (uids && t) {
- char *w, *state;
+ const char *word, *state;
size_t l;
- FOREACH_WORD(w, l, t, state)
+ FOREACH_WORD(word, l, t, state)
n++;
if (n > 0) {
if (!b)
return -ENOMEM;
- FOREACH_WORD(w, l, t, state) {
+ FOREACH_WORD(word, l, t, state) {
_cleanup_free_ char *k = NULL;
- k = strndup(w, l);
+ k = strndup(word, l);
if (!k)
return -ENOMEM;
_public_ int sd_machine_get_ifindices(const char *machine, int **ifindices) {
_cleanup_free_ char *netif = NULL;
size_t l, allocated = 0, nr = 0;
- char *w, *state;
int *ni = NULL;
- const char *p;
+ const char *p, *word, *state;
int r;
assert_return(machine_name_is_valid(machine), -EINVAL);
return 0;
}
- FOREACH_WORD(w, l, netif, state) {
+ FOREACH_WORD(word, l, netif, state) {
char buf[l+1];
int ifi;
- *(char*) (mempcpy(buf, w, l)) = 0;
+ *(char*) (mempcpy(buf, word, l)) = 0;
if (safe_atoi(buf, &ifi) < 0)
continue;