hare-xdg/format/desktop_entry/desktop_entry.ha

52 lines
1.3 KiB
Hare
Raw Normal View History

use locale;
use strings;
2024-10-03 17:52:17 -06:00
// A line in the file, which can be a comment (or a blank line), an entry, or
// a localized entry.
2024-10-12 20:12:43 -06:00
export type line = (blank | comment | entry | localized_entry);
// A blank line.
// Specification: §3.1
export type blank = void;
2024-10-03 17:52:17 -06:00
// A comment.
// Specification: §3.1
export type comment = str;
2024-10-03 17:52:17 -06:00
// A group header.
// Specification: §3.2
export type group_header = str;
2024-10-03 17:52:17 -06:00
// A key/value pair.
// Specification: §3.3
export type entry = (str, str);
2024-10-03 17:52:17 -06:00
2024-10-04 22:51:10 -06:00
// A localized key/value pair.
2024-10-03 17:52:17 -06:00
// Specification: §5
export type localized_entry = (str, str, locale::locale);
// Duplicates an [[entry]]. Use [[entry_finish]] to get rid of it.
export fn entry_dup(entr: entry) entry = (
strings::dup(entr.0),
strings::dup(entr.1));
// Frees memory associated with an [[entry]].
export fn entry_finish(entr: entry) void = {
free(entr.0);
free(entr.1);
};
// Duplicates a [[localized_entry]]. Use [[localized_entry_finish]] to get rid
// of it.
export fn localized_entry_dup(entr: localized_entry) localized_entry = (
strings::dup(entr.0),
strings::dup(entr.1),
locale::dup(entr.2));
// Frees memory associated with an [[localized_entry]].
export fn localized_entry_finish(entr: localized_entry) void = {
free(entr.0);
free(entr.1);
locale::finish(entr.2);
};