|
wlmaker
|
#include "desktop-parser.h"#include <ini.h>#include <libbase/libbase.h>#include <regex.h>#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <string.h>
Classes | |
| struct | _desktop_parser_handler_arg |
| struct | desktop_parser |
| struct | key_descriptor |
Functions | |
| static int | _desktop_parser_handler (void *userdata_ptr, const char *section_ptr, const char *name_ptr, const char *value_ptr) |
| static char * | _create_locale_key (const char *l, const char *t, const char *m) |
| static bool | _desktop_parser_translate_type (const char *value_ptr, void *dest_ptr) |
| static bool | _desktop_parser_translate_boolean (const char *value_ptr, void *dest_ptr) |
| static bool | _desktop_parser_translate_string (const char *value_ptr, void *dest_ptr) |
| static bool | _desktop_parser_translate_strings (const char *value_ptr, void *dest_ptr) |
| static bool | _desktop_parser_translate_exec (const char *value_ptr, void *dest_ptr) |
| static void | _desktop_parser_destroy_string (void *dest_ptr) |
| static void | _desktop_parser_destroy_strings (void *dest_ptr) |
| struct desktop_parser * | desktop_parser_create (const char *locale_ptr) |
| void | desktop_parser_destroy (struct desktop_parser *parser) |
| int | desktop_parser_file_to_entry (const struct desktop_parser *parser, const char *fname_ptr, struct desktop_entry *entry_ptr) |
| int | desktop_parser_string_to_entry (const struct desktop_parser *parser, const char *string_ptr, struct desktop_entry *entry_ptr) |
| void | desktop_parser_entry_release (struct desktop_entry *entry_ptr) |
| static void | _desktop_parser_test_ini_string (bs_test_t *test_ptr) |
| static void | _desktop_parser_test_ini_file (bs_test_t *test_ptr) |
| static void | _desktop_parser_test_locale_string (bs_test_t *test_ptr) |
| static void | _desktop_parser_test_translate (bs_test_t *test_ptr) |
Variables | |
| static const char * | desktop_entry_group_name = "Desktop Entry" |
| static const char * | key_regex_str |
| struct key_descriptor | keys [] |
| static const bs_test_case_t | _desktop_parser_test_cases [] |
| const bs_test_set_t | desktop_parser_test_set |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
static |
Creates a lookup key for localization.
| l | Language ("lang"). If NULL, no string is created. |
| t | Territory (Freedesktop speficication: "COUNTRY"), may be NULL. |
| m | Modifier ("MODIFIER"), may be NULL. |
|
static |
Frees the memory associated with the string.
|
static |
Frees the memory associated with the NULL-terminated string array.
|
static |
Callback handler for the inih parse methods. Parses "Desktop Entry".
| userdata_ptr | |
| section_ptr | |
| name_ptr | |
| value_ptr |
|
static |
Tests parsing a sample .desktop file.
|
static |
Tests parsing INI content, but from a string.
|
static |
Tests parsing localized strings.
|
static |
Tests translators: Escaped string.
|
static |
Translates a boolean-typed value into a bool at *dest_ptr.
| value_ptr | Must either be "false" or "true". |
| dest_ptr | Pointer to a bool. |
|
static |
Translates an exec key value, and un-escapes the specific escape codes.
https://specifications.freedesktop.org/desktop-entry/latest/exec-variables.html
TODO(kaese.nosp@m.r@gu.nosp@m.bbe.c.nosp@m.h): This is... lossy. When un-escaping the arguments, the result should be stored as separate strings, such as usable for execve(2).
| value_ptr | |
| dest_ptr |
|
static |
Translates a string, while un-escaping supported escape codes (s, n, t, r).
| value_ptr | |
| dest_ptr |
|
static |
Translates multiple strings, separated by semicolon; as for "Categories".
| value_ptr | |
| dest_ptr |
|
static |
Translates the "Type" key into an enum deskop_entry_type.
| value_ptr | |
| dest_ptr |
| struct desktop_parser * desktop_parser_create | ( | const char * | locale_ptr | ) |
Creates a desktop parser, using the provided locale.
| locale_ptr | Locale set for LC_MESSAGES. See setlocale(3). |
| void desktop_parser_destroy | ( | struct desktop_parser * | parser | ) |
Destroys the desktop parser.
| parser |
| void desktop_parser_entry_release | ( | struct desktop_entry * | entry_ptr | ) |
Releases the resources associated to the entry.
| entry_ptr |
| int desktop_parser_file_to_entry | ( | const struct desktop_parser * | parser, |
| const char * | fname_ptr, | ||
| struct desktop_entry * | entry_ptr ) |
Parses a file into the provided entry.
| parser | |
| fname_ptr | |
| entry_ptr |
| int desktop_parser_string_to_entry | ( | const struct desktop_parser * | parser, |
| const char * | string_ptr, | ||
| struct desktop_entry * | entry_ptr ) |
Parses an in-memory string into the provided entry.
| parser | |
| string_ptr | |
| entry_ptr |
|
static |
Test cases for action items.
|
static |
Group name for the application details in a .desktop file.
| const bs_test_set_t desktop_parser_test_set |
Unit test set.
|
static |
Regular expression describing a (possibly localized) key.
| struct key_descriptor keys[] |
Supported keys.