/usr/include/fcitx-utils/desktop-parse.h is in fcitx-libs-dev 1:4.2.8.5-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | /***************************************************************************
* Copyright (C) 2012~2013 by Yichao Yu *
* yyc1992@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef _FCITX_DESKTOP_PARSE_H_
#define _FCITX_DESKTOP_PARSE_H_
#include <stdint.h>
#include <fcitx-utils/utils.h>
typedef struct _FcitxDesktopFile FcitxDesktopFile;
typedef struct _FcitxDesktopGroup FcitxDesktopGroup;
typedef struct _FcitxDesktopEntry FcitxDesktopEntry;
#define DESKTOP_PADDING_LEN 6
typedef struct {
FcitxDesktopGroup *(*new_group)(void *owner);
void (*free_group)(void *owner, FcitxDesktopGroup *group);
FcitxDesktopEntry *(*new_entry)(void *owner);
void (*free_entry)(void *owner, FcitxDesktopEntry *entry);
void *padding[DESKTOP_PADDING_LEN];
} FcitxDesktopVTable;
struct _FcitxDesktopFile {
FcitxDesktopGroup *first;
FcitxDesktopGroup *last;
UT_array comments; /* comment at the end of the file */
/* private */
const FcitxDesktopVTable *vtable;
FcitxDesktopGroup *groups;
void *owner;
void *padding[3];
};
struct _FcitxDesktopGroup {
FcitxDesktopEntry *first;
FcitxDesktopEntry *last;
FcitxDesktopGroup *prev;
FcitxDesktopGroup *next;
char *name; /* Read-only */
UT_array comments; /* comment before the group name */
/* private */
const FcitxDesktopVTable *vtable;
FcitxDesktopEntry *entries;
UT_hash_handle hh;
uint32_t flags;
void *owner;
int32_t ref_count;
void *padding[3];
};
struct _FcitxDesktopEntry {
FcitxDesktopEntry *prev;
FcitxDesktopEntry *next;
char *name; /* Read-only */
UT_array comments; /* comment before the entry */
char *value;
/* private */
const FcitxDesktopVTable *vtable;
UT_hash_handle hh;
uint32_t flags;
void *owner;
int32_t ref_count;
void *padding[3];
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* Memory management
**/
boolean fcitx_desktop_file_init(FcitxDesktopFile *file,
const FcitxDesktopVTable *vtable,
void *owner);
void fcitx_desktop_file_done(FcitxDesktopFile *file);
FcitxDesktopGroup *fcitx_desktop_group_ref(FcitxDesktopGroup *group);
void fcitx_desktop_group_unref(FcitxDesktopGroup *group);
FcitxDesktopEntry *fcitx_desktop_entry_ref(FcitxDesktopEntry *entry);
void fcitx_desktop_entry_unref(FcitxDesktopEntry *entry);
/**
* Read and Write
**/
boolean fcitx_desktop_file_load_fp(FcitxDesktopFile *file, FILE *fp);
boolean fcitx_desktop_file_load(FcitxDesktopFile *file, const char *name);
boolean fcitx_desktop_file_write_fp(const FcitxDesktopFile *file,
FILE *fp);
boolean fcitx_desktop_file_write(const FcitxDesktopFile *file,
const char *name);
/**
* Operations on FcitxDesktopGroups in a FcitxDesktopFile.
**/
FcitxDesktopGroup *fcitx_desktop_file_find_group_with_len(
const FcitxDesktopFile *file, const char *name, size_t name_len);
FcitxDesktopGroup *fcitx_desktop_file_add_group_after_with_len(
FcitxDesktopFile *file, FcitxDesktopGroup *base,
const char *name, size_t name_len, boolean move);
FcitxDesktopGroup *fcitx_desktop_file_add_group_before_with_len(
FcitxDesktopFile *file, FcitxDesktopGroup *base,
const char *name, size_t name_len, boolean move);
boolean fcitx_desktop_file_delete_group(FcitxDesktopFile *file,
FcitxDesktopGroup *group);
boolean fcitx_desktop_file_insert_group_after(
FcitxDesktopFile *file, FcitxDesktopGroup *base,
FcitxDesktopGroup *group, boolean move);
boolean fcitx_desktop_file_insert_group_before(
FcitxDesktopFile *file, FcitxDesktopGroup *base,
FcitxDesktopGroup *group, boolean move);
/**
* Operations on FcitxDesktopEntry's in a FcitxDesktopGroup
**/
FcitxDesktopEntry *fcitx_desktop_group_find_entry_with_len(
const FcitxDesktopGroup *group, const char *name, size_t name_len);
FcitxDesktopEntry *fcitx_desktop_group_add_entry_after_with_len(
FcitxDesktopGroup *group, FcitxDesktopEntry *base,
const char *name, size_t name_len, boolean move);
FcitxDesktopEntry *fcitx_desktop_group_add_entry_before_with_len(
FcitxDesktopGroup *group, FcitxDesktopEntry *base,
const char *name, size_t name_len, boolean move);
boolean fcitx_desktop_group_delete_entry(FcitxDesktopGroup *group,
FcitxDesktopEntry *entry);
boolean fcitx_desktop_group_insert_entry_after(
FcitxDesktopGroup *group, FcitxDesktopEntry *base,
FcitxDesktopEntry *entry, boolean move);
boolean fcitx_desktop_group_insert_entry_before(
FcitxDesktopGroup *group, FcitxDesktopEntry *base,
FcitxDesktopEntry *entry, boolean move);
/**
* Simplified inline functions
**/
static inline FcitxDesktopGroup*
fcitx_desktop_file_find_group(const FcitxDesktopFile *file,
const char *name)
{
return fcitx_desktop_file_find_group_with_len(file, name,
strlen(name));
}
static inline FcitxDesktopEntry*
fcitx_desktop_group_find_entry(const FcitxDesktopGroup *group,
const char *name)
{
return fcitx_desktop_group_find_entry_with_len(group, name,
strlen(name));
}
static inline FcitxDesktopGroup*
fcitx_desktop_file_ensure_group_with_len(
FcitxDesktopFile *file, const char *name, size_t name_len)
{
return fcitx_desktop_file_add_group_after_with_len(
file, NULL, name, name_len, false);
}
static inline FcitxDesktopGroup*
fcitx_desktop_file_ensure_group(FcitxDesktopFile *file, const char *name)
{
return fcitx_desktop_file_ensure_group_with_len(
file, name, strlen(name));
}
static inline FcitxDesktopGroup*
fcitx_desktop_file_move_group_after_with_len(
FcitxDesktopFile *file, FcitxDesktopGroup *base,
const char *name, size_t name_len)
{
return fcitx_desktop_file_add_group_after_with_len(
file, base, name, name_len, true);
}
static inline FcitxDesktopGroup*
fcitx_desktop_file_move_group_after(
FcitxDesktopFile *file, FcitxDesktopGroup *base, const char *name)
{
return fcitx_desktop_file_move_group_after_with_len(
file, base, name, strlen(name));
}
static inline FcitxDesktopGroup*
fcitx_desktop_file_add_group_after(
FcitxDesktopFile *file, FcitxDesktopGroup *base,
const char *name, boolean move)
{
return fcitx_desktop_file_add_group_after_with_len(
file, base, name, strlen(name), move);
}
static inline FcitxDesktopGroup*
fcitx_desktop_file_move_group_before_with_len(
FcitxDesktopFile *file, FcitxDesktopGroup *base,
const char *name, size_t name_len)
{
return fcitx_desktop_file_add_group_before_with_len(
file, base, name, name_len, true);
}
static inline FcitxDesktopGroup*
fcitx_desktop_file_move_group_before(
FcitxDesktopFile *file, FcitxDesktopGroup *base,
const char *name)
{
return fcitx_desktop_file_move_group_before_with_len(
file, base, name, strlen(name));
}
static inline FcitxDesktopGroup*
fcitx_desktop_file_add_group_before(
FcitxDesktopFile *file, FcitxDesktopGroup *base,
const char *name, boolean move)
{
return fcitx_desktop_file_add_group_before_with_len(
file, base, name, strlen(name), move);
}
static inline FcitxDesktopEntry*
fcitx_desktop_group_ensure_entry_with_len(
FcitxDesktopGroup *group, const char *name, size_t name_len)
{
return fcitx_desktop_group_add_entry_after_with_len(
group, NULL, name, name_len, false);
}
static inline FcitxDesktopEntry*
fcitx_desktop_group_ensure_entry(FcitxDesktopGroup *group, const char *name)
{
return fcitx_desktop_group_ensure_entry_with_len(
group, name, strlen(name));
}
static inline FcitxDesktopEntry*
fcitx_desktop_group_move_entry_after_with_len(
FcitxDesktopGroup *group, FcitxDesktopEntry *base,
const char *name, size_t name_len)
{
return fcitx_desktop_group_add_entry_after_with_len(
group, base, name, name_len, true);
}
static inline FcitxDesktopEntry*
fcitx_desktop_group_move_entry_after(
FcitxDesktopGroup *group, FcitxDesktopEntry *base,
const char *name)
{
return fcitx_desktop_group_move_entry_after_with_len(
group, base, name, strlen(name));
}
static inline FcitxDesktopEntry*
fcitx_desktop_group_add_entry_after(
FcitxDesktopGroup *group, FcitxDesktopEntry *base,
const char *name, boolean move)
{
return fcitx_desktop_group_add_entry_after_with_len(
group, base, name, strlen(name), move);
}
static inline FcitxDesktopEntry*
fcitx_desktop_group_move_entry_before_with_len(
FcitxDesktopGroup *group, FcitxDesktopEntry *base,
const char *name, size_t name_len)
{
return fcitx_desktop_group_add_entry_before_with_len(
group, base, name, name_len, true);
}
static inline FcitxDesktopEntry*
fcitx_desktop_group_move_entry_before(
FcitxDesktopGroup *group, FcitxDesktopEntry *base, const char *name)
{
return fcitx_desktop_group_move_entry_before_with_len(
group, base, name, strlen(name));
}
static inline FcitxDesktopEntry*
fcitx_desktop_group_add_entry_before(
FcitxDesktopGroup *group, FcitxDesktopEntry *base,
const char *name, boolean move)
{
return fcitx_desktop_group_add_entry_before_with_len(
group, base, name, strlen(name), move);
}
static inline FcitxDesktopEntry*
fcitx_desktop_entry_set_value_with_len(FcitxDesktopEntry *entry,
const char *value, size_t len)
{
fcitx_utils_string_swap_with_len(&entry->value, value, len);
return entry;
}
static inline FcitxDesktopEntry*
fcitx_desktop_entry_set_value(FcitxDesktopEntry *entry, const char *value)
{
fcitx_utils_string_swap(&entry->value, value);
return entry;
}
#ifdef __cplusplus
}
#endif
#endif
|