Compare commits
No commits in common. "e029aae1d3d1884ca868c3694bdec0456b3e8267" and "7023c513477eca7832f5ae3c6204a7240c1401c0" have entirely different histories.
e029aae1d3
...
7023c51347
73
liberty.c
73
liberty.c
@ -731,21 +731,6 @@ set_blocking (int fd, bool blocking)
|
|||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
xwrite (int fd, const char *data, size_t len, struct error **e)
|
|
||||||
{
|
|
||||||
size_t written = 0;
|
|
||||||
while (written < len)
|
|
||||||
{
|
|
||||||
ssize_t res = write (fd, data + written, len - written);
|
|
||||||
if (res >= 0)
|
|
||||||
written += res;
|
|
||||||
else if (errno != EINTR)
|
|
||||||
return error_set (e, "%s", strerror (errno));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xclose (int fd)
|
xclose (int fd)
|
||||||
{
|
{
|
||||||
@ -1372,7 +1357,6 @@ struct poller_idle
|
|||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
// The heap could definitely be made faster but we'll prefer simplicity
|
|
||||||
struct poller_timers
|
struct poller_timers
|
||||||
{
|
{
|
||||||
struct poller_timer **heap; ///< Min-heap of timers
|
struct poller_timer **heap; ///< Min-heap of timers
|
||||||
@ -2939,13 +2923,6 @@ base64_encode (const void *data, size_t len, struct str *output)
|
|||||||
|
|
||||||
// --- Utilities ---------------------------------------------------------------
|
// --- Utilities ---------------------------------------------------------------
|
||||||
|
|
||||||
static void
|
|
||||||
cstr_set (char **s, char *new)
|
|
||||||
{
|
|
||||||
free (*s);
|
|
||||||
*s = new;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstr_split (const char *s, const char *delimiters, bool ignore_empty,
|
cstr_split (const char *s, const char *delimiters, bool ignore_empty,
|
||||||
struct strv *out)
|
struct strv *out)
|
||||||
@ -2975,10 +2952,10 @@ cstr_strip_in_place (char *s, const char *stripped_chars)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cstr_transform (char *s, int (*xform) (int c))
|
cstr_transform (char *s, int (*tolower) (int c))
|
||||||
{
|
{
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
*s = xform (*s);
|
*s = tolower (*s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@ -3025,7 +3002,6 @@ iconv_xstrdup (iconv_t conv, char *in, size_t in_len, size_t *out_len)
|
|||||||
|
|
||||||
char *in_ptr = in;
|
char *in_ptr = in;
|
||||||
if (in_len == (size_t) -1)
|
if (in_len == (size_t) -1)
|
||||||
// XXX: out_len will be one character longer than the string!
|
|
||||||
in_len = strlen (in) + 1;
|
in_len = strlen (in) + 1;
|
||||||
|
|
||||||
while (iconv (conv, (char **) &in_ptr, &in_len,
|
while (iconv (conv, (char **) &in_ptr, &in_len,
|
||||||
@ -3285,8 +3261,16 @@ resolve_relative_data_filename (const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
resolve_relative_runtime_filename_finish (struct str path)
|
resolve_relative_runtime_filename (const char *filename)
|
||||||
{
|
{
|
||||||
|
struct str path = str_make ();
|
||||||
|
const char *runtime_dir = getenv ("XDG_RUNTIME_DIR");
|
||||||
|
if (runtime_dir && *runtime_dir == '/')
|
||||||
|
str_append (&path, runtime_dir);
|
||||||
|
else
|
||||||
|
get_xdg_home_dir (&path, "XDG_DATA_HOME", ".local/share");
|
||||||
|
str_append_printf (&path, "/%s/%s", PROGRAM_NAME, filename);
|
||||||
|
|
||||||
// Try to create the file's ancestors;
|
// Try to create the file's ancestors;
|
||||||
// typically the user will want to immediately create a file in there
|
// typically the user will want to immediately create a file in there
|
||||||
const char *last_slash = strrchr (path.str, '/');
|
const char *last_slash = strrchr (path.str, '/');
|
||||||
@ -3299,41 +3283,6 @@ resolve_relative_runtime_filename_finish (struct str path)
|
|||||||
return str_steal (&path);
|
return str_steal (&path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
resolve_relative_runtime_filename (const char *filename)
|
|
||||||
{
|
|
||||||
struct str path = str_make ();
|
|
||||||
const char *runtime_dir = getenv ("XDG_RUNTIME_DIR");
|
|
||||||
if (runtime_dir && *runtime_dir == '/')
|
|
||||||
str_append (&path, runtime_dir);
|
|
||||||
else
|
|
||||||
get_xdg_home_dir (&path, "XDG_DATA_HOME", ".local/share");
|
|
||||||
|
|
||||||
str_append_printf (&path, "/%s/%s", PROGRAM_NAME, filename);
|
|
||||||
return resolve_relative_runtime_filename_finish (path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// This differs from resolve_relative_runtime_filename() in that we expect
|
|
||||||
/// the filename to be something like a pattern for mkstemp(), so the resulting
|
|
||||||
/// path can reside in a system-wide directory with no risk of a conflict.
|
|
||||||
/// However, we have to take care about permissions. Do we even need this?
|
|
||||||
static char *
|
|
||||||
resolve_relative_runtime_template (const char *template)
|
|
||||||
{
|
|
||||||
struct str path = str_make ();
|
|
||||||
const char *runtime_dir = getenv ("XDG_RUNTIME_DIR");
|
|
||||||
const char *tmpdir = getenv ("TMPDIR");
|
|
||||||
if (runtime_dir && *runtime_dir == '/')
|
|
||||||
str_append_printf (&path, "%s/%s", runtime_dir, PROGRAM_NAME);
|
|
||||||
else if (tmpdir && *tmpdir == '/')
|
|
||||||
str_append_printf (&path, "%s/%s.%d", tmpdir, PROGRAM_NAME, geteuid ());
|
|
||||||
else
|
|
||||||
str_append_printf (&path, "/tmp/%s.%d", PROGRAM_NAME, geteuid ());
|
|
||||||
|
|
||||||
str_append_printf (&path, "/%s", template);
|
|
||||||
return resolve_relative_runtime_filename_finish (path);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
try_expand_tilde (const char *filename)
|
try_expand_tilde (const char *filename)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user