rofi  1.7.3
helper.h
Go to the documentation of this file.
1 /*
2  * rofi
3  *
4  * MIT/X11 License
5  * Copyright © 2013-2021 Qball Cow <qball@gmpclient.org>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  */
27 
28 #ifndef ROFI_HELPER_H
29 #define ROFI_HELPER_H
30 #include "rofi-types.h"
31 #include <cairo.h>
32 G_BEGIN_DECLS
33 
54 int helper_parse_setup(char *string, char ***output, int *length, ...);
55 
64 rofi_int_matcher **helper_tokenize(const char *input, int case_sensitive);
65 
72 
82 int find_arg_char(const char *const key, char *val);
83 
92 int find_arg_uint(const char *const key, unsigned int *val);
93 
102 int find_arg_int(const char *const key, int *val);
103 
112 int find_arg_str(const char *const key, char **val);
113 
121 const char **find_arg_strv(const char *const key);
129 int find_arg(const char *const key);
130 
139 int helper_token_match(rofi_int_matcher *const *tokens, const char *input);
148 int execute_generator(const char *cmd) __attribute__((nonnull));
149 
156 int create_pid_file(const char *pidfile, gboolean kill);
157 
161 void remove_pid_file(int fd);
162 
170 int config_sanity_check(void);
171 
179 char helper_parse_char(const char *arg);
180 
187 void cmd_set_arguments(int argc, char **argv);
188 
196 char *rofi_expand_path(const char *input);
197 
208 unsigned int levenshtein(const char *needle, const glong needlelen,
209  const char *haystack, const glong haystacklen);
210 
220 char *rofi_force_utf8(const gchar *data, ssize_t length);
221 
230 char *rofi_latin_to_utf8_strdup(const char *input, gssize length);
231 
265 int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str,
266  glong slen);
280 int utf8_strncmp(const char *a, const char *b, size_t n)
281  __attribute__((nonnull(1, 2)));
282 
286 typedef struct {
288  const gchar *name;
290  const gchar *binary;
292  const gchar *description;
294  const gchar *icon;
296  const gchar *app_id;
298  const gchar *wmclass;
300  const gchar *command;
302 
314 gboolean helper_execute(const char *wd, char **args, const char *error_precmd,
315  const char *error_cmd,
316  RofiHelperExecuteContext *context);
317 
329 gboolean helper_execute_command(const char *wd, const char *cmd,
330  gboolean run_in_term,
331  RofiHelperExecuteContext *context);
332 
340 cairo_surface_t *cairo_image_surface_create_from_svg(const gchar *file,
341  int height);
342 
354 void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length);
355 
374 void rofi_output_formatted_line(const char *format, const char *string,
375  int selected_line, const char *filter);
376 
392 char *helper_string_replace_if_exists(char *string, ...);
393 
400 char *helper_get_theme_path(const char *file, const char *ext);
401 
402 G_END_DECLS
403 
405 #endif // ROFI_HELPER_H
void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length)
Definition: helper.c:1141
void cmd_set_arguments(int argc, char **argv)
Definition: helper.c:70
int find_arg_char(const char *const key, char *val)
Definition: helper.c:408
gboolean helper_execute_command(const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context)
Definition: helper.c:1007
void helper_tokenize_free(rofi_int_matcher **tokens)
Definition: helper.c:119
char helper_parse_char(const char *arg)
Definition: helper.c:360
void rofi_output_formatted_line(const char *format, const char *string, int selected_line, const char *filter)
Definition: helper.c:1158
gboolean helper_execute(const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context)
Definition: helper.c:979
unsigned int levenshtein(const char *needle, const glong needlelen, const char *haystack, const glong haystacklen)
Definition: helper.c:749
char * rofi_latin_to_utf8_strdup(const char *input, gssize length)
Definition: helper.c:785
const char ** find_arg_strv(const char *const key)
Definition: helper.c:321
int helper_parse_setup(char *string, char ***output, int *length,...)
Definition: helper.c:75
int execute_generator(const char *cmd) __attribute__((nonnull))
Definition: helper.c:516
int find_arg_int(const char *const key, int *val)
Definition: helper.c:341
void remove_pid_file(int fd)
Definition: helper.c:597
cairo_surface_t * cairo_image_surface_create_from_svg(const gchar *file, int height)
int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str, glong slen)
Definition: helper.c:897
char * rofi_expand_path(const char *input)
Definition: helper.c:717
int find_arg_str(const char *const key, char **val)
Definition: helper.c:311
int utf8_strncmp(const char *a, const char *b, size_t n) __attribute__((nonnull(1
rofi_int_matcher ** helper_tokenize(const char *input, int case_sensitive)
Definition: helper.c:263
char * helper_get_theme_path(const char *file, const char *ext)
Definition: helper.c:1047
int find_arg_uint(const char *const key, unsigned int *val)
Definition: helper.c:350
char * helper_string_replace_if_exists(char *string,...)
Definition: helper.c:1244
int find_arg(const char *const key)
Definition: helper.c:302
int helper_token_match(rofi_int_matcher *const *tokens, const char *input)
Definition: helper.c:495
int config_sanity_check(void)
Definition: helper.c:624
int create_pid_file(const char *pidfile, gboolean kill)
Definition: helper.c:539
char * rofi_force_utf8(const gchar *data, ssize_t length)
Definition: helper.c:791
char * pidfile
Definition: rofi.c:81
const gchar * binary
Definition: helper.h:290
const gchar * wmclass
Definition: helper.h:298
const gchar * app_id
Definition: helper.h:296
const gchar * description
Definition: helper.h:292
const gchar * name
Definition: helper.h:288
const gchar * icon
Definition: helper.h:294
const gchar * command
Definition: helper.h:300