Give only those information the util functions need to work.
* EX_FLAG_CMD is not set also on | */
while (**input && **input != '\n' && (cmdlist || **input != '|')) {
/* check for expansion placeholder */
- util_parse_expansion(c, input, arg->rhs, flags, "|\\");
+ util_parse_expansion(c->state, input, arg->rhs, flags, "|\\");
if (VB_IS_SEPARATOR(**input)) {
/* add tilde expansion for next loop needs to be first char or to
case EX_SAVE: /* Fallthrough */
case EX_SOURCE:
- found = util_filename_fill_completion(c, store, token);
+ found = util_filename_fill_completion(c->state, store, token);
break;
#ifdef FEATURE_AUTOCMD
/* Prepare the path to save the download. */
if (path && *path) {
- file = util_build_path(c, path, download_path);
+ file = util_build_path(c->state, path, download_path);
/* if file is an directory append a file name */
if (g_file_test(file, (G_FILE_TEST_IS_DIR))) {
g_free(dir);
}
} else {
- file = util_build_path(c, suggested_filename, download_path);
+ file = util_build_path(c->state, suggested_filename, download_path);
}
g_free(basename);
};
typedef struct Client Client;
+typedef struct State State;
typedef struct Map Map;
typedef struct Mode Mode;
typedef struct Arg Arg;
*
* Returned path must be freed.
*/
-char *util_build_path(Client *c, const char *path, const char *dir)
+char *util_build_path(State state, const char *path, const char *dir)
{
char *fullPath = NULL, *fexp, *dexp, *p;
int expflags = UTIL_EXP_TILDE|UTIL_EXP_DOLLAR;
/* if the path could be expanded */
- if ((fexp = util_expand(c, path, expflags))) {
+ if ((fexp = util_expand(state, path, expflags))) {
if (*fexp == '/') {
/* path is already absolute, no need to use given dir - there is
* no need to free fexp, because this should be done by the caller
fullPath = fexp;
} else if (dir && *dir) {
/* try to expand also the dir given - this may be ~/path */
- if ((dexp = util_expand(c, dir, expflags))) {
+ if ((dexp = util_expand(state, dir, expflags))) {
/* use expanded dir and append expanded path */
fullPath = g_build_filename(dexp, fexp, NULL);
g_free(dexp);
*
* Returned path must be g_freed.
*/
-char *util_expand(Client *c, const char *src, int expflags)
+char *util_expand(State state, const char *src, int expflags)
{
const char **input = &src;
char *result;
int flags = expflags;
while (**input) {
- util_parse_expansion(c, input, dst, flags, "\\");
+ util_parse_expansion(state, input, dst, flags, "\\");
if (VB_IS_SEPARATOR(**input)) {
/* after space the tilde expansion is allowed */
flags = expflags;
* Fills file path completion entries into given list store for also given
* input.
*/
-gboolean util_filename_fill_completion(Client *c, GtkListStore *store, const char *input)
+gboolean util_filename_fill_completion(State state, GtkListStore *store, const char *input)
{
gboolean found = FALSE;
GError *error = NULL;
input_basename = last_slash ? last_slash + 1 : input;
input_dirname = g_strndup(input, input_basename - input);
real_dirname = util_expand(
- c,
+ state,
*input_dirname ? input_dirname : ".",
UTIL_EXP_TILDE|UTIL_EXP_DOLLAR|UTIL_EXP_SPECIAL
);
* @quoteable: String of chars that are additionally escapable by \.
* Returns TRUE if input started with expandable pattern.
*/
-gboolean util_parse_expansion(Client *c, const char **input, GString *str,
+gboolean util_parse_expansion(State state, const char **input, GString *str,
int flags, const char *quoteable)
{
GString *name;
expanded = TRUE;
g_string_free(name, TRUE);
} else if (flags & UTIL_EXP_SPECIAL && **input == '%') {
- if (*c->state.uri) {
+ if (state.uri) {
/* TODO check for modifiers like :h:t:r:e */
- g_string_append(str, c->state.uri);
+ g_string_append(str, state.uri);
expanded = TRUE;
}
}
};
typedef void *(*Util_Content_Func)(const char*, const char*);
-char *util_build_path(Client *c, const char *path, const char *dir);
+char *util_build_path(State state, const char *path, const char *dir);
void util_cleanup(void);
gboolean util_create_dir_if_not_exists(const char *dirpath);
gboolean util_create_tmp_file(const char *content, char **file);
-char *util_expand(Client *c, const char *src, int expflags);
+char *util_expand(State state, const char *src, int expflags);
gboolean util_file_append(const char *file, const char *format, ...);
gboolean util_file_prepend(const char *file, const char *format, ...);
void util_file_prepend_line(const char *file, const char *line,
GList *util_file_to_unique_list(const char *filename, Util_Content_Func func,
guint max_items);
gboolean util_fill_completion(GtkListStore *store, const char *input, GList *src);
-gboolean util_filename_fill_completion(Client *c, GtkListStore *store, const char *input);
+gboolean util_filename_fill_completion(State state, GtkListStore *store, const char *input);
char *util_js_result_as_string(WebKitJavascriptResult *result);
double util_js_result_as_number(WebKitJavascriptResult *result);
-gboolean util_parse_expansion(Client *c, const char **input, GString *str,
+gboolean util_parse_expansion(State state, const char **input, GString *str,
int flags, const char *quoteable);
char *util_sanitize_filename(char *filename);
char *util_sanitize_uri(const char *uri_str);