xkbregistry.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. /*
  2. * Copyright © 2020 Red Hat, Inc.
  3. * SPDX-License-Identifier: MIT
  4. */
  5. #ifndef _XKBREGISTRY_H_
  6. #define _XKBREGISTRY_H_
  7. #include <stdarg.h>
  8. #include <stdbool.h>
  9. /**
  10. * @file
  11. * @brief Query for available RMLVO
  12. *
  13. */
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #if defined(__GNUC__) && !defined(__CYGWIN__)
  18. # define RXKB_EXPORT __attribute__((visibility("default")))
  19. #elif defined(_WIN32)
  20. # define RXKB_EXPORT __declspec(dllexport)
  21. #else
  22. # define RXKB_EXPORT
  23. #endif
  24. /**
  25. * @defgroup registry Query for available RMLVO
  26. *
  27. * The libxkbregistry API to query for available rules, models, layouts,
  28. * variants and options (RMLVO). libxkbregistry is a separate library to
  29. * libxkbcommon.
  30. *
  31. * This library is the replacement for clients currently parsing evdev.xml
  32. * directly. The library is intended to provide easy access to the set of
  33. * **possible** MLVO configurations for a given ruleset. It is not a library to
  34. * apply these configurations, merely to enumerate them. The intended users of
  35. * this library are the configuration UIs that allow a user to select their
  36. * keyboard layout of choice.
  37. *
  38. * @{
  39. */
  40. /**
  41. * @struct rxkb_context
  42. *
  43. * Opaque top level library context object.
  44. *
  45. * The context contains general library state, like include paths and parsed
  46. * data. Objects are created in a specific context, and multiple contexts
  47. * may coexist simultaneously. Objects from different contexts are
  48. * completely separated and do not share any memory or state.
  49. */
  50. struct rxkb_context;
  51. /**
  52. * @struct rxkb_model
  53. *
  54. * Opaque struct representing an XKB model.
  55. */
  56. struct rxkb_model;
  57. /**
  58. * @struct rxkb_layout
  59. *
  60. * Opaque struct representing an XKB layout, including an optional variant.
  61. * Where the variant is `NULL`, the layout is the base layout.
  62. *
  63. * For example, `us` is the base layout, `us(intl)` is the `intl` variant of the
  64. * layout `us`.
  65. */
  66. struct rxkb_layout;
  67. /**
  68. * @struct rxkb_option_group
  69. *
  70. * Opaque struct representing an option group. Option groups divide the
  71. * individual options into logical groups. Their main purpose is to indicate
  72. * whether some options are mutually exclusive or not.
  73. */
  74. struct rxkb_option_group;
  75. /**
  76. * @struct rxkb_option
  77. *
  78. * Opaque struct representing an XKB option. Options are grouped inside an @ref
  79. * rxkb_option_group.
  80. */
  81. struct rxkb_option;
  82. /**
  83. *
  84. * @struct rxkb_iso639_code
  85. *
  86. * Opaque struct representing an ISO 639-3 code (e.g. `eng`, `fra`). There
  87. * is no guarantee that two identical ISO codes share the same struct. You
  88. * must not rely on the pointer value of this struct.
  89. *
  90. * See https://iso639-3.sil.org/code_tables/639/data for a list of codes.
  91. */
  92. struct rxkb_iso639_code;
  93. /**
  94. *
  95. * @struct rxkb_iso3166_code
  96. *
  97. * Opaque struct representing an ISO 3166 Alpha 2 code (e.g. `US`, `FR`).
  98. * There is no guarantee that two identical ISO codes share the same struct.
  99. * You must not rely on the pointer value of this struct.
  100. *
  101. * See https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes for a list
  102. * of codes.
  103. */
  104. struct rxkb_iso3166_code;
  105. /**
  106. * Describes the popularity of an item. Historically, some highly specialized or
  107. * experimental definitions are excluded from the default list and shipped in
  108. * separate files. If these extra definitions are loaded (see @ref
  109. * RXKB_CONTEXT_LOAD_EXOTIC_RULES), the popularity of the item is set
  110. * accordingly.
  111. *
  112. * If the exotic items are not loaded, all items will have the standard
  113. * popularity.
  114. */
  115. enum rxkb_popularity {
  116. RXKB_POPULARITY_STANDARD = 1,
  117. RXKB_POPULARITY_EXOTIC,
  118. };
  119. /**
  120. * Flags for context creation.
  121. */
  122. enum rxkb_context_flags {
  123. RXKB_CONTEXT_NO_FLAGS = 0,
  124. /**
  125. * Skip the default include paths. This requires the caller to call
  126. * `rxkb_context_include_path_append()` or
  127. * `rxkb_context_include_path_append_default()`.
  128. */
  129. RXKB_CONTEXT_NO_DEFAULT_INCLUDES = (1 << 0),
  130. /**
  131. * Load the extra items that are considered too exotic for the default list.
  132. *
  133. * For historical reasons, xkeyboard-config ships those exotic rules in a
  134. * separate file (e.g. `evdev.extras.xml`). Where the exotic rules are
  135. * requested, libxkbregistry will look for and load `$ruleset.extras.xml`
  136. * in the include paths, see `rxkb_context_include_path_append()` for
  137. * details on the lookup behavior.
  138. */
  139. RXKB_CONTEXT_LOAD_EXOTIC_RULES = (1 << 1),
  140. /**
  141. * Disable the use of `secure_getenv()` for this context, so that privileged
  142. * processes can use environment variables. Client uses at their own risk.
  143. *
  144. * @since 1.5.0
  145. */
  146. RXKB_CONTEXT_NO_SECURE_GETENV = (1 << 2)
  147. };
  148. /**
  149. * Create a new xkb registry context.
  150. *
  151. * The context has an initial refcount of 1. Use `rxkb_context_unref()` to
  152. * release memory associated with this context.
  153. *
  154. * Creating a context does not parse the files yet, use
  155. * `rxkb_context_parse()`.
  156. *
  157. * @param flags Flags affecting context behavior
  158. * @return A new xkb registry context or `NULL` on failure
  159. */
  160. RXKB_EXPORT struct rxkb_context *
  161. rxkb_context_new(enum rxkb_context_flags flags);
  162. /** Specifies a logging level. */
  163. enum rxkb_log_level {
  164. RXKB_LOG_LEVEL_CRITICAL = 10, /**< Log critical internal errors only. */
  165. RXKB_LOG_LEVEL_ERROR = 20, /**< Log all errors. */
  166. RXKB_LOG_LEVEL_WARNING = 30, /**< Log warnings and errors. */
  167. RXKB_LOG_LEVEL_INFO = 40, /**< Log information, warnings, and errors. */
  168. RXKB_LOG_LEVEL_DEBUG = 50 /**< Log everything. */
  169. };
  170. /**
  171. * Set the current logging level.
  172. *
  173. * @param ctx The context in which to set the logging level.
  174. * @param level The logging level to use. Only messages from this level
  175. * and below will be logged.
  176. *
  177. * The default level is `::RXKB_LOG_LEVEL_ERROR`. The environment variable
  178. * `RXKB_LOG_LEVEL`, if set at the time the context was created, overrides the
  179. * default value. It may be specified as a level number or name.
  180. */
  181. RXKB_EXPORT void
  182. rxkb_context_set_log_level(struct rxkb_context *ctx,
  183. enum rxkb_log_level level);
  184. /**
  185. * Get the current logging level.
  186. */
  187. RXKB_EXPORT enum rxkb_log_level
  188. rxkb_context_get_log_level(struct rxkb_context *ctx);
  189. /**
  190. * Set a custom function to handle logging messages.
  191. *
  192. * @param ctx The context in which to use the set logging function.
  193. * @param log_fn The function that will be called for logging messages.
  194. * Passing `NULL` restores the default function, which logs to `stderr`.
  195. *
  196. * By default, log messages from this library are printed to stderr. This
  197. * function allows you to replace the default behavior with a custom
  198. * handler. The handler is only called with messages which match the
  199. * current logging level and verbosity settings for the context.
  200. * level is the logging level of the message. @a format and @a args are
  201. * the same as in the `vprintf(3)` function.
  202. *
  203. * You may use `rxkb_context_set_user_data()` on the context, and then call
  204. * `rxkb_context_get_user_data()` from within the logging function to provide
  205. * it with additional private context.
  206. */
  207. RXKB_EXPORT void
  208. rxkb_context_set_log_fn(struct rxkb_context *ctx,
  209. void (*log_fn)(struct rxkb_context *ctx,
  210. enum rxkb_log_level level,
  211. const char *format, va_list args));
  212. /**
  213. * Parse the given ruleset. This can only be called once per context and once
  214. * parsed the data in the context is considered constant and will never
  215. * change.
  216. *
  217. * This function parses all files with the given ruleset name. See
  218. * rxkb_context_include_path_append() for details.
  219. *
  220. * If this function returns false, libxkbregistry failed to parse the xml files.
  221. * This is usually caused by invalid files on the host and should be debugged by
  222. * the host’s administrator using external tools. Callers should reduce the
  223. * include paths to known good paths and/or fall back to a default RMLVO set.
  224. *
  225. * If this function returns false, the context should be be considered dead and
  226. * must be released with `rxkb_context_unref()`.
  227. *
  228. * @param ctx The xkb registry context
  229. * @param ruleset The ruleset to parse, e.g. `evdev`
  230. * @return `true` on success or `false` on failure
  231. */
  232. RXKB_EXPORT bool
  233. rxkb_context_parse(struct rxkb_context *ctx, const char *ruleset);
  234. /**
  235. * Parse the default ruleset as configured at build time. See
  236. * `rxkb_context_parse()` for details.
  237. */
  238. RXKB_EXPORT bool
  239. rxkb_context_parse_default_ruleset(struct rxkb_context *ctx);
  240. /**
  241. * Increases the refcount of this object by one and returns the object.
  242. *
  243. * @param ctx The xkb registry context
  244. * @return The passed in object
  245. */
  246. RXKB_EXPORT struct rxkb_context*
  247. rxkb_context_ref(struct rxkb_context *ctx);
  248. /**
  249. * Decreases the refcount of this object by one. Where the refcount of an
  250. * object hits zero, associated resources will be freed.
  251. *
  252. * @param ctx The xkb registry context
  253. * @return always `NULL`
  254. */
  255. RXKB_EXPORT struct rxkb_context*
  256. rxkb_context_unref(struct rxkb_context *ctx);
  257. /**
  258. * Assign user-specific data. libxkbregistry will not look at or modify the
  259. * data, it will merely return the same pointer in
  260. * `rxkb_context_get_user_data()`.
  261. *
  262. * @param ctx The xkb registry context
  263. * @param user_data User-specific data pointer
  264. */
  265. RXKB_EXPORT void
  266. rxkb_context_set_user_data(struct rxkb_context *ctx, void *user_data);
  267. /**
  268. * Return the pointer passed into `rxkb_context_get_user_data()`.
  269. *
  270. * @param ctx The xkb registry context
  271. * @return User-specific data pointer
  272. */
  273. RXKB_EXPORT void *
  274. rxkb_context_get_user_data(struct rxkb_context *ctx);
  275. /**
  276. * Append a new entry to the context’s include path.
  277. *
  278. * The include path handling is optimized for the most common use-case: a set of
  279. * system files that provide a complete set of MLVO and some
  280. * custom MLVO provided by a user **in addition** to the system set.
  281. *
  282. * The include paths should be given so that the least complete path is
  283. * specified first and the most complete path is appended last. For example:
  284. *
  285. * ```c
  286. * ctx = rxkb_context_new(RXKB_CONTEXT_NO_DEFAULT_INCLUDES);
  287. * rxkb_context_include_path_append(ctx, `/home/user/.config/xkb`);
  288. * rxkb_context_include_path_append(ctx, `/usr/share/X11/xkb`);
  289. * rxkb_context_parse(ctx, `evdev`);
  290. * ```
  291. *
  292. * The above example reflects the default behavior unless @ref
  293. * RXKB_CONTEXT_NO_DEFAULT_INCLUDES is provided.
  294. *
  295. * Loading of the files is in **reverse order**, i.e. the last path appended is
  296. * loaded first - in this case the ``/usr/share/X11/xkb`` path.
  297. * Any models, layouts, variants and options defined in the `evdev` ruleset
  298. * are loaded into the context. Then, any RMLVO found in the `evdev` ruleset of
  299. * the user’s path (``/home/user/.config/xkb`` in this example) are **appended**
  300. * to the existing set.
  301. *
  302. * Note that data from previously loaded include paths is never overwritten,
  303. * only appended to. It is not not possible to change the system-provided data,
  304. * only to append new models, layouts, variants and options to it.
  305. *
  306. * In other words, to define a new variant of the `us` layout called `banana`,
  307. * the following XML is sufficient.
  308. *
  309. * ```xml
  310. * <xkbConfigRegistry version="1.1">
  311. * <layoutList>
  312. * <layout>
  313. * <configItem>
  314. * <name>us</name>
  315. * </configItem>
  316. * <variantList>
  317. * <variant>
  318. * <configItem>
  319. * <name>banana</name>
  320. * <description>English (Banana)</description>
  321. * </configItem>
  322. * </variant>
  323. * </layout>
  324. * </layoutList>
  325. * </xkbConfigRegistry>
  326. * ```
  327. *
  328. * The list of models, options and all other layouts (including `us` and its
  329. * variants) is taken from the system files. The resulting list of layouts will
  330. * thus have a `us` keyboard layout with the variant `banana` and all other
  331. * system-provided variants (`dvorak`, `colemak`, `intl`, etc.)
  332. *
  333. * This function must be called before `rxkb_context_parse()` or
  334. * `rxkb_context_parse_default_ruleset()`.
  335. *
  336. * @returns `true` on success, or `false` if the include path could not be added
  337. * or is inaccessible.
  338. */
  339. RXKB_EXPORT bool
  340. rxkb_context_include_path_append(struct rxkb_context *ctx, const char *path);
  341. /**
  342. * Append the default include paths to the context’s include path.
  343. * See `rxkb_context_include_path_append()` for details about the merge order.
  344. *
  345. * This function must be called before `rxkb_context_parse()` or
  346. * `rxkb_context_parse_default_ruleset()`.
  347. *
  348. * @returns `true` on success, or `false` if the include path could not be added
  349. * or is inaccessible.
  350. */
  351. RXKB_EXPORT bool
  352. rxkb_context_include_path_append_default(struct rxkb_context *ctx);
  353. /**
  354. * Return the first model for this context. Use this to start iterating over
  355. * the models, followed by calls to `rxkb_model_next()`. Models are not sorted.
  356. *
  357. * The refcount of the returned model is not increased. Use `rxkb_model_ref()`
  358. * if you need to keep this struct outside the immediate scope.
  359. *
  360. * @return The first model in the model list.
  361. */
  362. RXKB_EXPORT struct rxkb_model *
  363. rxkb_model_first(struct rxkb_context *ctx);
  364. /**
  365. * Return the next model for this context. Returns `NULL` when no more models
  366. * are available.
  367. *
  368. * The refcount of the returned model is not increased. Use `rxkb_model_ref()`
  369. * if you need to keep this struct outside the immediate scope.
  370. *
  371. * @return the next model or `NULL` at the end of the list
  372. */
  373. RXKB_EXPORT struct rxkb_model *
  374. rxkb_model_next(struct rxkb_model *m);
  375. /**
  376. * Increase the refcount of the argument by one.
  377. *
  378. * @returns The argument passed in to this function.
  379. */
  380. RXKB_EXPORT struct rxkb_model *
  381. rxkb_model_ref(struct rxkb_model *m);
  382. /**
  383. * Decrease the refcount of the argument by one. When the refcount hits zero,
  384. * all memory associated with this struct is freed.
  385. *
  386. * @returns always `NULL`
  387. */
  388. RXKB_EXPORT struct rxkb_model *
  389. rxkb_model_unref(struct rxkb_model *m);
  390. /**
  391. * Return the name of this model. This is the value for M in RMLVO, to be used
  392. * with libxkbcommon.
  393. */
  394. RXKB_EXPORT const char *
  395. rxkb_model_get_name(struct rxkb_model *m);
  396. /**
  397. * Return a human-readable description of this model. This function may return
  398. * `NULL`.
  399. */
  400. RXKB_EXPORT const char *
  401. rxkb_model_get_description(struct rxkb_model *m);
  402. /**
  403. * Return the vendor name for this model. This function may return `NULL`.
  404. */
  405. RXKB_EXPORT const char *
  406. rxkb_model_get_vendor(struct rxkb_model *m);
  407. /**
  408. * Return the popularity for this model.
  409. */
  410. RXKB_EXPORT enum rxkb_popularity
  411. rxkb_model_get_popularity(struct rxkb_model *m);
  412. /**
  413. * Return the first layout for this context. Use this to start iterating over
  414. * the layouts, followed by calls to `rxkb_layout_next()`.
  415. *
  416. * @note Layouts are not sorted.
  417. *
  418. * The refcount of the returned layout is not increased.
  419. * Use `rxkb_layout_ref()` if you need to keep this struct outside the immediate
  420. * scope.
  421. *
  422. * @return The first layout in the layout list.
  423. */
  424. RXKB_EXPORT struct rxkb_layout *
  425. rxkb_layout_first(struct rxkb_context *ctx);
  426. /**
  427. * Return the next layout for this context. Returns `NULL` when no more layouts
  428. * are available.
  429. *
  430. * The refcount of the returned layout is not increased. Use `rxkb_layout_ref()`
  431. * if you need to keep this struct outside the immediate scope.
  432. *
  433. * @return the next layout or `NULL` at the end of the list
  434. */
  435. RXKB_EXPORT struct rxkb_layout *
  436. rxkb_layout_next(struct rxkb_layout *l);
  437. /**
  438. * Increase the refcount of the argument by one.
  439. *
  440. * @returns The argument passed in to this function.
  441. */
  442. RXKB_EXPORT struct rxkb_layout *
  443. rxkb_layout_ref(struct rxkb_layout *l);
  444. /**
  445. * Decrease the refcount of the argument by one. When the refcount hits zero,
  446. * all memory associated with this struct is freed.
  447. *
  448. * @returns always `NULL`
  449. */
  450. RXKB_EXPORT struct rxkb_layout *
  451. rxkb_layout_unref(struct rxkb_layout *l);
  452. /**
  453. * Return the name of this layout. This is the value for L in RMLVO, to be used
  454. * with libxkbcommon.
  455. */
  456. RXKB_EXPORT const char *
  457. rxkb_layout_get_name(struct rxkb_layout *l);
  458. /**
  459. * Return the variant of this layout. This is the value for V in RMLVO, to be
  460. * used with libxkbcommon.
  461. *
  462. * A variant does not stand on its own, it always depends on the base layout.
  463. * e.g. there may be multiple variants called `intl` but there is only one
  464. * `us(intl)`.
  465. *
  466. * Where the variant is `NULL`, the layout is the base layout (e.g. `us`).
  467. */
  468. RXKB_EXPORT const char *
  469. rxkb_layout_get_variant(struct rxkb_layout *l);
  470. /**
  471. * Return a short (one-word) description of this layout. This function may
  472. * return `NULL`.
  473. */
  474. RXKB_EXPORT const char *
  475. rxkb_layout_get_brief(struct rxkb_layout *l);
  476. /**
  477. * Return a human-readable description of this layout. This function may return
  478. * `NULL`.
  479. */
  480. RXKB_EXPORT const char *
  481. rxkb_layout_get_description(struct rxkb_layout *l);
  482. /**
  483. * Return the popularity for this layout.
  484. */
  485. RXKB_EXPORT enum rxkb_popularity
  486. rxkb_layout_get_popularity(struct rxkb_layout *l);
  487. /**
  488. * Return the first option group for this context. Use this to start iterating
  489. * over the option groups, followed by calls to `rxkb_option_group_next()`.
  490. * Option groups are not sorted.
  491. *
  492. * The refcount of the returned option group is not increased. Use
  493. * `rxkb_option_group_ref()` if you need to keep this struct outside the immediate
  494. * scope.
  495. *
  496. * @return The first option group in the option group list.
  497. */
  498. RXKB_EXPORT struct rxkb_option_group *
  499. rxkb_option_group_first(struct rxkb_context *ctx);
  500. /**
  501. * Return the next option group for this context. Returns `NULL` when no more
  502. * option groups are available.
  503. *
  504. * The refcount of the returned option group is not increased. Use
  505. * `rxkb_option_group_ref()` if you need to keep this struct outside the immediate
  506. * scope.
  507. *
  508. * @return the next option group or `NULL` at the end of the list
  509. */
  510. RXKB_EXPORT struct rxkb_option_group *
  511. rxkb_option_group_next(struct rxkb_option_group *g);
  512. /**
  513. * Increase the refcount of the argument by one.
  514. *
  515. * @returns The argument passed in to this function.
  516. */
  517. RXKB_EXPORT struct rxkb_option_group *
  518. rxkb_option_group_ref(struct rxkb_option_group *g);
  519. /**
  520. * Decrease the refcount of the argument by one. When the refcount hits zero,
  521. * all memory associated with this struct is freed.
  522. *
  523. * @returns always `NULL`
  524. */
  525. RXKB_EXPORT struct rxkb_option_group *
  526. rxkb_option_group_unref(struct rxkb_option_group *g);
  527. /**
  528. * Return the name of this option group. This is **not** the value for O in
  529. * RMLVO, the name can be used for internal sorting in the caller. This function
  530. * may return `NULL`.
  531. */
  532. RXKB_EXPORT const char *
  533. rxkb_option_group_get_name(struct rxkb_option_group *m);
  534. /**
  535. * Return a human-readable description of this option group. This function may
  536. * return `NULL`.
  537. */
  538. RXKB_EXPORT const char *
  539. rxkb_option_group_get_description(struct rxkb_option_group *m);
  540. /**
  541. * @return `true` if multiple options within this option group can be selected
  542. * simultaneously, `false` if all options within this option
  543. * group are mutually exclusive.
  544. */
  545. RXKB_EXPORT bool
  546. rxkb_option_group_allows_multiple(struct rxkb_option_group *g);
  547. /**
  548. * Return the popularity for this option group.
  549. */
  550. RXKB_EXPORT enum rxkb_popularity
  551. rxkb_option_group_get_popularity(struct rxkb_option_group *g);
  552. /**
  553. * Return the first option for this option group. Use this to start iterating
  554. * over the options, followed by calls to `rxkb_option_next()`. Options are not
  555. * sorted.
  556. *
  557. * The refcount of the returned option is not increased. Use `rxkb_option_ref()`
  558. * if you need to keep this struct outside the immediate scope.
  559. *
  560. * @return The first option in the option list.
  561. */
  562. RXKB_EXPORT struct rxkb_option *
  563. rxkb_option_first(struct rxkb_option_group *group);
  564. /**
  565. * Return the next option for this option group. Returns `NULL` when no more
  566. * options are available.
  567. *
  568. * The refcount of the returned options is not increased. Use `rxkb_option_ref()`
  569. * if you need to keep this struct outside the immediate scope.
  570. *
  571. * @returns The next option or `NULL` at the end of the list
  572. */
  573. RXKB_EXPORT struct rxkb_option *
  574. rxkb_option_next(struct rxkb_option *o);
  575. /**
  576. * Increase the refcount of the argument by one.
  577. *
  578. * @returns The argument passed in to this function.
  579. */
  580. RXKB_EXPORT struct rxkb_option *
  581. rxkb_option_ref(struct rxkb_option *o);
  582. /**
  583. * Decrease the refcount of the argument by one. When the refcount hits zero,
  584. * all memory associated with this struct is freed.
  585. *
  586. * @returns always `NULL`
  587. */
  588. RXKB_EXPORT struct rxkb_option *
  589. rxkb_option_unref(struct rxkb_option *o);
  590. /**
  591. * Return the name of this option. This is the value for O in RMLVO, to be used
  592. * with libxkbcommon.
  593. */
  594. RXKB_EXPORT const char *
  595. rxkb_option_get_name(struct rxkb_option *o);
  596. /**
  597. * Return a short (one-word) description of this option. This function may
  598. * return `NULL`.
  599. */
  600. RXKB_EXPORT const char *
  601. rxkb_option_get_brief(struct rxkb_option *o);
  602. /**
  603. * Return a human-readable description of this option. This function may return
  604. * `NULL`.
  605. */
  606. RXKB_EXPORT const char *
  607. rxkb_option_get_description(struct rxkb_option *o);
  608. /**
  609. * Return the popularity for this option.
  610. */
  611. RXKB_EXPORT enum rxkb_popularity
  612. rxkb_option_get_popularity(struct rxkb_option *o);
  613. /**
  614. * Return `true` if the given option accepts layout index specifiers to restrict
  615. * its application to the corresponding layouts, `false` otherwise.
  616. *
  617. * @sa `xkb_rmlvo_builder::xkb_rmlvo_builder_append_layout()`
  618. * @sa `xkb_rule_names::options`
  619. */
  620. RXKB_EXPORT bool
  621. rxkb_option_is_layout_specific(struct rxkb_option *o);
  622. /**
  623. * Increase the refcount of the argument by one.
  624. *
  625. * @returns The argument passed in to this function.
  626. */
  627. RXKB_EXPORT struct rxkb_iso639_code *
  628. rxkb_iso639_code_ref(struct rxkb_iso639_code *iso639);
  629. /**
  630. * Decrease the refcount of the argument by one. When the refcount hits zero,
  631. * all memory associated with this struct is freed.
  632. *
  633. * @returns always `NULL`
  634. */
  635. RXKB_EXPORT struct rxkb_iso639_code *
  636. rxkb_iso639_code_unref(struct rxkb_iso639_code *iso639);
  637. /**
  638. * Return the ISO 639-3 code for this code. E.g. `eng`, `fra`.
  639. */
  640. RXKB_EXPORT const char *
  641. rxkb_iso639_code_get_code(struct rxkb_iso639_code *iso639);
  642. /**
  643. * Return the first ISO 639 for this layout. Use this to start iterating over
  644. * the codes, followed by calls to `rxkb_iso639_code_next()`. Codes are not
  645. * sorted.
  646. *
  647. * The refcount of the returned code is not increased.
  648. * Use `rxkb_iso639_code_ref()` if you need to keep this struct outside the
  649. * immediate scope.
  650. *
  651. * @return The first code in the code list.
  652. */
  653. RXKB_EXPORT struct rxkb_iso639_code *
  654. rxkb_layout_get_iso639_first(struct rxkb_layout *layout);
  655. /**
  656. * Return the next code in the list. Returns `NULL` when no more codes
  657. * are available.
  658. *
  659. * The refcount of the returned codes is not increased.
  660. * Use `rxkb_iso639_code_ref()` if you need to keep this struct outside the
  661. * immediate scope.
  662. *
  663. * @returns The next code or `NULL` at the end of the list
  664. */
  665. RXKB_EXPORT struct rxkb_iso639_code *
  666. rxkb_iso639_code_next(struct rxkb_iso639_code *iso639);
  667. /**
  668. * Increase the refcount of the argument by one.
  669. *
  670. * @returns The argument passed in to this function.
  671. */
  672. RXKB_EXPORT struct rxkb_iso3166_code *
  673. rxkb_iso3166_code_ref(struct rxkb_iso3166_code *iso3166);
  674. /**
  675. * Decrease the refcount of the argument by one. When the refcount hits zero,
  676. * all memory associated with this struct is freed.
  677. *
  678. * @returns always `NULL`
  679. */
  680. RXKB_EXPORT struct rxkb_iso3166_code *
  681. rxkb_iso3166_code_unref(struct rxkb_iso3166_code *iso3166);
  682. /**
  683. * Return the ISO 3166 Alpha 2 code for this code (e.g. `US`, `FR`).
  684. */
  685. RXKB_EXPORT const char *
  686. rxkb_iso3166_code_get_code(struct rxkb_iso3166_code *iso3166);
  687. /**
  688. * Return the first ISO 3166 for this layout. Use this to start iterating over
  689. * the codes, followed by calls to `rxkb_iso3166_code_next()`. Codes are not
  690. * sorted.
  691. *
  692. * The refcount of the returned code is not increased. Use
  693. * `rxkb_iso3166_code_ref()` if you need to keep this struct outside the immediate
  694. * scope.
  695. *
  696. * @return The first code in the code list.
  697. */
  698. RXKB_EXPORT struct rxkb_iso3166_code *
  699. rxkb_layout_get_iso3166_first(struct rxkb_layout *layout);
  700. /**
  701. * Return the next code in the list. Returns `NULL` when no more codes
  702. * are available.
  703. *
  704. * The refcount of the returned codes is not increased. Use
  705. * `rxkb_iso3166_code_ref()` if you need to keep this struct outside the immediate
  706. * scope.
  707. *
  708. * @returns The next code or `NULL` at the end of the list
  709. */
  710. RXKB_EXPORT struct rxkb_iso3166_code *
  711. rxkb_iso3166_code_next(struct rxkb_iso3166_code *iso3166);
  712. /** @} */
  713. #ifdef __cplusplus
  714. } /* extern "C" */
  715. #endif
  716. #endif /* _XKBREGISTRY_H_ */