|
| 1 | +// SPDX-License-Identifier: BSD-3-Clause |
| 2 | +// Copyright The Music Player Daemon Project |
| 3 | + |
| 4 | +#ifndef LIBMPDCLIENT_STRINGNORMALIZATION_H |
| 5 | +#define LIBMPDCLIENT_STRINGNORMALIZATION_H |
| 6 | + |
| 7 | +#include "recv.h" |
| 8 | +#include "compiler.h" |
| 9 | + |
| 10 | +#include <stdbool.h> |
| 11 | + |
| 12 | +/** |
| 13 | + * @since libmpdclient 2.24 |
| 14 | + */ |
| 15 | +enum mpd_stringnormalization_option |
| 16 | +{ |
| 17 | + /** |
| 18 | + * Special value returned by mpd_stringnormalization_parse() when an |
| 19 | + * unknown name was passed. |
| 20 | + */ |
| 21 | + MPD_STRINGNORMALIZATION_UNKNOWN = -1, |
| 22 | + |
| 23 | + MPD_STRINGNORMALIZATION_STRIP_DIACRITICS, |
| 24 | + |
| 25 | + /* IMPORTANT: the ordering above must be |
| 26 | + retained, or else the libmpdclient ABI breaks */ |
| 27 | + |
| 28 | + MPD_STRINGNORMALIZATION_COUNT |
| 29 | +}; |
| 30 | + |
| 31 | +#ifdef __cplusplus |
| 32 | +extern "C" { |
| 33 | +#endif |
| 34 | + |
| 35 | +/** |
| 36 | + * Looks up the name of the specified stringnormalization option. |
| 37 | + * |
| 38 | + * @return the name, or NULL if the tag type is not valid |
| 39 | + */ |
| 40 | +const char * |
| 41 | +mpd_stringnormalization_name(enum mpd_stringnormalization_option option); |
| 42 | + |
| 43 | +/** |
| 44 | + * Parses a stringnormalization option name, and returns its #mpd_protocol_feature value. |
| 45 | + * |
| 46 | + * @return a #mpd_protocol_feature value, or MPD_FEATURE_UNKNOWN if the name was |
| 47 | + * not recognized |
| 48 | + */ |
| 49 | +enum mpd_stringnormalization_option |
| 50 | +mpd_stringnormalization_name_parse(const char *name); |
| 51 | + |
| 52 | +/** |
| 53 | + * Requests a list of enabled stringnormalization options. |
| 54 | + * Use mpd_recv_stringnormalization_pair() to obtain the list of |
| 55 | + * "option" pairs. |
| 56 | + * |
| 57 | + * @param connection the connection to MPD |
| 58 | + * @return true on success, false on error |
| 59 | + * |
| 60 | + * @since libmpdclient 2.24, MPD 0.25 |
| 61 | + */ |
| 62 | +bool |
| 63 | +mpd_send_list_stringnormalization(struct mpd_connection *connection); |
| 64 | + |
| 65 | +/** |
| 66 | + * Requests a list of available protocol features. |
| 67 | + * Use mpd_recv_stringnormalization_pair() to obtain the list of |
| 68 | + * "stringnormalization option" pairs. |
| 69 | + * |
| 70 | + * @param connection the connection to MPD |
| 71 | + * @return true on success, false on error |
| 72 | + * |
| 73 | + * @since libmpdclient 2.24, MPD 0.25 |
| 74 | + */ |
| 75 | +bool |
| 76 | +mpd_send_list_stringnormalization_available(struct mpd_connection *connection); |
| 77 | + |
| 78 | +/** |
| 79 | + * Receives the next stringnormalization option. Call this in a loop after |
| 80 | + * mpd_send_list_stringnormalization(). |
| 81 | + * |
| 82 | + * Free the return value with mpd_return_pair(). |
| 83 | + * |
| 84 | + * @param connection a #mpd_connection |
| 85 | + * @returns a "stringnormalization option" pair, or NULL on error or if the end of the |
| 86 | + * response is reached |
| 87 | + * |
| 88 | + * @since libmpdclient 2.24, MPD 0.25 |
| 89 | + */ |
| 90 | +mpd_malloc |
| 91 | +static inline struct mpd_pair * |
| 92 | +mpd_recv_stringnormalization_pair(struct mpd_connection *connection) |
| 93 | +{ |
| 94 | + return mpd_recv_pair_named(connection, "stringnormalization"); |
| 95 | +} |
| 96 | + |
| 97 | +/** |
| 98 | + * Disables one or more stringnormalization option from the list of stringnormalization options. |
| 99 | + * |
| 100 | + * @param connection the connection to MPD |
| 101 | + * @param options an array of stringnormalization options to disable |
| 102 | + * @param n the number of protocol features in the array |
| 103 | + * @return true on success, false on error |
| 104 | + * |
| 105 | + * @since libmpdclient 2.24, MPD 0.25 |
| 106 | + */ |
| 107 | +bool |
| 108 | +mpd_send_disable_stringnormalization(struct mpd_connection *connection, |
| 109 | + const enum mpd_stringnormalization_option *options, unsigned n); |
| 110 | + |
| 111 | +/** |
| 112 | + * Shortcut for mpd_send_disable_stringnormalization() and mpd_response_finish(). |
| 113 | + * |
| 114 | + * @since libmpdclient 2.24, MPD 0.25 |
| 115 | + */ |
| 116 | +bool |
| 117 | +mpd_run_disable_stringnormalization(struct mpd_connection *connection, |
| 118 | + const enum mpd_stringnormalization_option *options, unsigned n); |
| 119 | + |
| 120 | +/** |
| 121 | + * Re-enable one or more stringnormalization options from the list of stringnormalization options |
| 122 | + * for this client. |
| 123 | + * |
| 124 | + * @param connection the connection to MPD |
| 125 | + * @param options an array of stringnormalization options to enable |
| 126 | + * @param n the number of protocol features in the array |
| 127 | + * @return true on success, false on error |
| 128 | + * |
| 129 | + * @since libmpdclient 2.24, MPD 0.25 |
| 130 | + */ |
| 131 | +bool |
| 132 | +mpd_send_enable_stringnormalization(struct mpd_connection *connection, |
| 133 | + const enum mpd_stringnormalization_option *options, unsigned n); |
| 134 | + |
| 135 | +/** |
| 136 | + * Shortcut for mpd_send_enable_stringnormalization() and mpd_response_finish(). |
| 137 | + * |
| 138 | + * @since libmpdclient 2.24, MPD 0.25 |
| 139 | + */ |
| 140 | +bool |
| 141 | +mpd_run_enable_stringnormalization(struct mpd_connection *connection, |
| 142 | + const enum mpd_stringnormalization_option *options, unsigned n); |
| 143 | + |
| 144 | +/** |
| 145 | + * Clear the list of enabled stringnormalization options for this client. |
| 146 | + * |
| 147 | + * @param connection the connection to MPD |
| 148 | + * @return true on success, false on error |
| 149 | + * |
| 150 | + * @since libmpdclient 2.24, MPD 0.25 |
| 151 | + */ |
| 152 | +bool |
| 153 | +mpd_send_clear_stringnormalization(struct mpd_connection *connection); |
| 154 | + |
| 155 | +/** |
| 156 | + * Shortcut for mpd_send_clear_stringnormalization() and mpd_response_finish(). |
| 157 | + * |
| 158 | + * @since libmpdclient 2.24, MPD 0.25 |
| 159 | + */ |
| 160 | +bool |
| 161 | +mpd_run_clear_stringnormalization(struct mpd_connection *connection); |
| 162 | + |
| 163 | +/** |
| 164 | + * Enable all available stringnormalization options for this client. |
| 165 | + * |
| 166 | + * @param connection the connection to MPD |
| 167 | + * @return true on success, false on error |
| 168 | + * |
| 169 | + * @since libmpdclient 2.24, MPD 0.25 |
| 170 | + */ |
| 171 | +bool |
| 172 | +mpd_send_all_stringnormalization(struct mpd_connection *connection); |
| 173 | + |
| 174 | +/** |
| 175 | + * Shortcut for mpd_send_all_stringnormalization() and mpd_response_finish(). |
| 176 | + * |
| 177 | + * @since libmpdclient 2.24, MPD 0.25 |
| 178 | + */ |
| 179 | +bool |
| 180 | +mpd_run_all_stringnormalization(struct mpd_connection *connection); |
| 181 | + |
| 182 | +#ifdef __cplusplus |
| 183 | +} |
| 184 | +#endif |
| 185 | + |
| 186 | +#endif |
0 commit comments