Skip to content

Commit

Permalink
Merge branch 'obsd-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAdam committed Dec 12, 2019
2 parents 0d99519 + 5134666 commit 7922f4e
Show file tree
Hide file tree
Showing 15 changed files with 1,108 additions and 533 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ dist_tmux_SOURCES = \
control-notify.c \
control.c \
environ.c \
file.c \
format.c \
format-draw.c \
grid-view.c \
Expand Down
46 changes: 46 additions & 0 deletions cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,52 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,
return (0);
}

int
load_cfg_from_buffer(const void *buf, size_t len, const char *path,
struct client *c, struct cmdq_item *item, int flags,
struct cmdq_item **new_item)
{
struct cmd_parse_input pi;
struct cmd_parse_result *pr;
struct cmdq_item *new_item0;

if (new_item != NULL)
*new_item = NULL;

log_debug("loading %s", path);

memset(&pi, 0, sizeof pi);
pi.flags = flags;
pi.file = path;
pi.line = 1;
pi.item = item;
pi.c = c;

pr = cmd_parse_from_buffer(buf, len, &pi);
if (pr->status == CMD_PARSE_EMPTY)
return (0);
if (pr->status == CMD_PARSE_ERROR) {
cfg_add_cause("%s", pr->error);
free(pr->error);
return (-1);
}
if (flags & CMD_PARSE_PARSEONLY) {
cmd_list_free(pr->cmdlist);
return (0);
}

new_item0 = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
if (item != NULL)
cmdq_insert_after(item, new_item0);
else
cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist);

if (new_item != NULL)
*new_item = new_item0;
return (0);
}

void
cfg_add_cause(const char *fmt, ...)
{
Expand Down
Loading

0 comments on commit 7922f4e

Please sign in to comment.