Compare commits
5 Commits
f04cc2c61e
...
75fc6f1c37
| Author | SHA1 | Date | |
|---|---|---|---|
|
75fc6f1c37
|
|||
|
8a8437634a
|
|||
|
e78b410a6a
|
|||
|
bf44e827e8
|
|||
|
8386af0420
|
@@ -1381,7 +1381,7 @@ struct mpd_client
|
|||||||
|
|
||||||
// Protocol:
|
// Protocol:
|
||||||
|
|
||||||
bool got_hello; ///< Got the OK MPD hello message
|
char *got_hello; ///< Version from OK MPD hello message
|
||||||
|
|
||||||
bool idling; ///< Sent idle as the last command
|
bool idling; ///< Sent idle as the last command
|
||||||
unsigned idling_subsystems; ///< Subsystems we're idling for
|
unsigned idling_subsystems; ///< Subsystems we're idling for
|
||||||
@@ -1482,7 +1482,7 @@ mpd_client_reset (struct mpd_client *self)
|
|||||||
str_reset (&self->read_buffer);
|
str_reset (&self->read_buffer);
|
||||||
str_reset (&self->write_buffer);
|
str_reset (&self->write_buffer);
|
||||||
|
|
||||||
self->got_hello = false;
|
cstr_set (&self->got_hello, NULL);
|
||||||
self->idling = false;
|
self->idling = false;
|
||||||
self->idling_subsystems = 0;
|
self->idling_subsystems = 0;
|
||||||
self->in_list = false;
|
self->in_list = false;
|
||||||
@@ -1549,7 +1549,8 @@ mpd_client_parse_hello (struct mpd_client *self, const char *line)
|
|||||||
|
|
||||||
// TODO: call "on_connected" now. We should however also set up a timer
|
// TODO: call "on_connected" now. We should however also set up a timer
|
||||||
// so that we don't wait on this message forever.
|
// so that we don't wait on this message forever.
|
||||||
return self->got_hello = true;
|
cstr_set (&self->got_hello, xstrdup (line + sizeof hello - 1));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@@ -1634,30 +1635,30 @@ mpd_client_on_ready (const struct pollfd *pfd, void *user_data)
|
|||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
static bool
|
|
||||||
mpd_client_must_quote_char (char c)
|
|
||||||
{
|
|
||||||
return (unsigned char) c <= ' ' || c == '"' || c == '\'';
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
mpd_client_must_quote (const char *s)
|
mpd_client_must_quote (const char *s)
|
||||||
{
|
{
|
||||||
if (!*s)
|
if (!*s)
|
||||||
return true;
|
return true;
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
if (mpd_client_must_quote_char (*s))
|
if ((unsigned char) *s <= ' ' || *s == '"' || *s == '\'')
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
mpd_client_must_escape_in_quote (char c)
|
||||||
|
{
|
||||||
|
return c == '"' || c == '\'' || c == '\\';
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mpd_client_quote (const char *s, struct str *output)
|
mpd_client_quote (const char *s, struct str *output)
|
||||||
{
|
{
|
||||||
str_append_c (output, '"');
|
str_append_c (output, '"');
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
if (mpd_client_must_quote_char (*s))
|
if (mpd_client_must_escape_in_quote (*s))
|
||||||
str_append_c (output, '\\');
|
str_append_c (output, '\\');
|
||||||
str_append_c (output, *s);
|
str_append_c (output, *s);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,12 @@
|
|||||||
// It is surprisingly hard to find a good library to handle Unicode shenanigans,
|
// It is surprisingly hard to find a good library to handle Unicode shenanigans,
|
||||||
// and there's enough of those for it to be impractical to reimplement them.
|
// and there's enough of those for it to be impractical to reimplement them.
|
||||||
//
|
//
|
||||||
// GLib ICU libunistring utf8proc
|
// GLib ICU libunistring utf8proc libgrapheme
|
||||||
// Decently sized . . x x
|
// Decently sized . . x x x
|
||||||
// Grapheme breaks . x . x
|
// Grapheme breaks . x . x x
|
||||||
// Character width x . x x
|
// Character width x . x x .
|
||||||
// Locale handling . . x .
|
// Locale handling . . x . .
|
||||||
// Liberal license . x . x
|
// Liberal license . x . x x
|
||||||
//
|
//
|
||||||
// Also note that the ICU API is icky and uses UTF-16 for its primary encoding.
|
// Also note that the ICU API is icky and uses UTF-16 for its primary encoding.
|
||||||
//
|
//
|
||||||
|
|||||||
15
liberty.c
15
liberty.c
@@ -292,7 +292,8 @@ xreallocarray (void *o, size_t n, size_t m)
|
|||||||
static char *
|
static char *
|
||||||
xstrdup (const char *s)
|
xstrdup (const char *s)
|
||||||
{
|
{
|
||||||
return strcpy (xmalloc (strlen (s) + 1), s);
|
size_t len = strlen (s) + 1;
|
||||||
|
return memcpy (xmalloc (len), s, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@@ -4500,7 +4501,7 @@ struct config_item
|
|||||||
}
|
}
|
||||||
value; ///< The value of this item
|
value; ///< The value of this item
|
||||||
|
|
||||||
struct config_schema *schema; ///< Schema describing this value
|
const struct config_schema *schema; ///< Schema describing this value
|
||||||
void *user_data; ///< User value attached by schema owner
|
void *user_data; ///< User value attached by schema owner
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4652,7 +4653,7 @@ config_item_object (void)
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
config_schema_accepts_type
|
config_schema_accepts_type
|
||||||
(struct config_schema *self, enum config_item_type type)
|
(const struct config_schema *self, enum config_item_type type)
|
||||||
{
|
{
|
||||||
if (self->type == type)
|
if (self->type == type)
|
||||||
return true;
|
return true;
|
||||||
@@ -4665,7 +4666,7 @@ config_schema_accepts_type
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
config_item_validate_by_schema (struct config_item *self,
|
config_item_validate_by_schema (struct config_item *self,
|
||||||
struct config_schema *schema, struct error **e)
|
const struct config_schema *schema, struct error **e)
|
||||||
{
|
{
|
||||||
struct error *error = NULL;
|
struct error *error = NULL;
|
||||||
if (!config_schema_accepts_type (schema, self->type))
|
if (!config_schema_accepts_type (schema, self->type))
|
||||||
@@ -4686,7 +4687,7 @@ static bool
|
|||||||
config_item_set_from (struct config_item *self, struct config_item *source,
|
config_item_set_from (struct config_item *self, struct config_item *source,
|
||||||
struct error **e)
|
struct error **e)
|
||||||
{
|
{
|
||||||
struct config_schema *schema = self->schema;
|
const struct config_schema *schema = self->schema;
|
||||||
if (!schema)
|
if (!schema)
|
||||||
{
|
{
|
||||||
// Easy, we don't know what this item is
|
// Easy, we don't know what this item is
|
||||||
@@ -5482,7 +5483,7 @@ end:
|
|||||||
|
|
||||||
/// "user_data" is passed to allow its immediate use in validation callbacks
|
/// "user_data" is passed to allow its immediate use in validation callbacks
|
||||||
static struct config_item *
|
static struct config_item *
|
||||||
config_schema_initialize_item (struct config_schema *schema,
|
config_schema_initialize_item (const struct config_schema *schema,
|
||||||
struct config_item *parent, void *user_data, struct error **warning,
|
struct config_item *parent, void *user_data, struct error **warning,
|
||||||
struct error **e)
|
struct error **e)
|
||||||
{
|
{
|
||||||
@@ -5539,7 +5540,7 @@ keep_current:
|
|||||||
/// Assign schemas and user_data to multiple items at once;
|
/// Assign schemas and user_data to multiple items at once;
|
||||||
/// feel free to copy over and modify to suit your particular needs
|
/// feel free to copy over and modify to suit your particular needs
|
||||||
static void
|
static void
|
||||||
config_schema_apply_to_object (struct config_schema *schema_array,
|
config_schema_apply_to_object (const struct config_schema *schema_array,
|
||||||
struct config_item *object, void *user_data)
|
struct config_item *object, void *user_data)
|
||||||
{
|
{
|
||||||
while (schema_array->name)
|
while (schema_array->name)
|
||||||
|
|||||||
Reference in New Issue
Block a user