i3
Data Structures | Macros | Typedefs | Functions | Variables
config_parser.c File Reference
#include "all.h"
#include <fcntl.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <xcb/xcb_xrm.h>
#include "GENERATED_config_enums.h"
#include "GENERATED_config_tokens.h"
#include "GENERATED_config_call.h"
Include dependency graph for config_parser.c:

Go to the source code of this file.

Data Structures

struct  token
 
struct  tokenptr
 
struct  stack_entry
 

Macros

#define y(x, ...)   yajl_gen_##x(command_output.json_gen, ##__VA_ARGS__)
 
#define ystr(str)   yajl_gen_string(command_output.json_gen, (unsigned char *)str, strlen(str))
 

Typedefs

typedef struct token cmdp_token
 
typedef struct tokenptr cmdp_token_ptr
 

Functions

static void push_string (const char *identifier, const char *str)
 
static void push_long (const char *identifier, long num)
 
static const char * get_string (const char *identifier)
 
static long get_long (const char *identifier)
 
static void clear_stack (void)
 
static void next_state (const cmdp_token *token)
 
static const char * start_of_line (const char *walk, const char *beginning)
 
static char * single_line (const char *start)
 
struct ConfigResultIRparse_config (const char *input, struct context *context)
 
static int detect_version (char *buf)
 
static char * migrate_config (char *input, off_t size)
 
void start_config_error_nagbar (const char *configpath, bool has_errors)
 Launch nagbar to indicate errors in the configuration file. More...
 
static void upsert_variable (struct variables_head *variables, char *key, char *value)
 
static char * get_resource (char *name)
 
bool parse_file (const char *f, bool use_nagbar)
 Parses the given file by first replacing the variables, then calling parse_config and launching i3-nagbar if use_nagbar is true. More...
 

Variables

xcb_xrm_database_t * database = NULL
 
pid_t config_error_nagbar_pid = -1
 
static struct contextcontext
 
static struct stack_entry stack [10]
 
static cmdp_state state
 
static Match current_match
 
static struct ConfigResultIR subcommand_output
 
static struct ConfigResultIR command_output
 
static cmdp_state statelist [10] = {INITIAL}
 
static int statelist_idx = 1
 

Macro Definition Documentation

◆ y

#define y (   x,
  ... 
)    yajl_gen_##x(command_output.json_gen, ##__VA_ARGS__)

Definition at line 42 of file config_parser.c.

◆ ystr

#define ystr (   str)    yajl_gen_string(command_output.json_gen, (unsigned char *)str, strlen(str))

Definition at line 43 of file config_parser.c.

Typedef Documentation

◆ cmdp_token

typedef struct token cmdp_token

◆ cmdp_token_ptr

typedef struct tokenptr cmdp_token_ptr

Function Documentation

◆ clear_stack()

static void clear_stack ( void  )
static

◆ detect_version()

static int detect_version ( char *  buf)
static

Definition at line 628 of file config_parser.c.

References LOG.

Referenced by parse_file().

◆ get_long()

static long get_long ( const char *  identifier)
static

Definition at line 163 of file config_parser.c.

References stack_entry::identifier, stack_entry::num, stack, and stack_entry::val.

◆ get_resource()

static char* get_resource ( char *  name)
static

Definition at line 855 of file config_parser.c.

References conn, database, and ELOG.

Referenced by parse_file().

◆ get_string()

static const char* get_string ( const char *  identifier)
static

Definition at line 153 of file config_parser.c.

References stack_entry::identifier, stack, stack_entry::str, and stack_entry::val.

◆ migrate_config()

static char* migrate_config ( char *  input,
off_t  size 
)
static

Definition at line 697 of file config_parser.c.

References exec_i3_utility(), FREE, scalloc(), srealloc(), and writeall().

Referenced by parse_file().

Here is the call graph for this function:

◆ next_state()

static void next_state ( const cmdp_token token)
static

◆ parse_config()

struct ConfigResultIR* parse_config ( const char *  input,
struct context context 
)

◆ parse_file()

bool parse_file ( const char *  f,
bool  use_nagbar 
)

Parses the given file by first replacing the variables, then calling parse_config and launching i3-nagbar if use_nagbar is true.

The return value is a boolean indicating whether there were errors during parsing.

Definition at line 885 of file config_parser.c.

References check_for_duplicate_bindings(), current_config, database, detect_version(), die, DLOG, ELOG, extract_workspace_names_from_bindings(), context::filename, FREE, get_resource(), context::has_errors, context::has_warnings, i3_version, ConfigResultIR::json_gen, Variable::key, context::line_copy, LOG, migrate_config(), Variable::next_match, parse_config(), reorder_bindings(), scalloc(), SLIST_EMPTY, SLIST_FIRST, SLIST_FOREACH, SLIST_HEAD_INITIALIZER, SLIST_REMOVE_HEAD, sstrdup(), start_config_error_nagbar(), upsert_variable(), and Variable::value.

Referenced by load_configuration().

Here is the call graph for this function:

◆ push_long()

static void push_long ( const char *  identifier,
long  num 
)
static

◆ push_string()

static void push_string ( const char *  identifier,
const char *  str 
)
static

Definition at line 105 of file config_parser.c.

References stack_entry::identifier, sasprintf(), sstrdup(), stack, stack_entry::STACK_STR, stack_entry::str, stack_entry::type, and stack_entry::val.

Referenced by parse_config().

Here is the call graph for this function:

◆ single_line()

static char* single_line ( const char *  start)
static

Definition at line 252 of file config_parser.c.

References sstrdup().

Referenced by parse_config().

Here is the call graph for this function:

◆ start_config_error_nagbar()

void start_config_error_nagbar ( const char *  configpath,
bool  has_errors 
)

Launch nagbar to indicate errors in the configuration file.

launch nagbar to indicate errors in the configuration file.

Definition at line 793 of file config_parser.c.

References config, config_error_nagbar_pid, errorfilename, Config::font, context::has_errors, Font::pattern, sasprintf(), and start_nagbar().

Referenced by parse_file(), and translate_keysyms().

Here is the call graph for this function:

◆ start_of_line()

static const char* start_of_line ( const char *  walk,
const char *  beginning 
)
static

Definition at line 238 of file config_parser.c.

Referenced by parse_config().

◆ upsert_variable()

static void upsert_variable ( struct variables_head *  variables,
char *  key,
char *  value 
)
static

Definition at line 822 of file config_parser.c.

References DLOG, FREE, Variable::key, scalloc(), SLIST_FOREACH, SLIST_INSERT_AFTER, SLIST_INSERT_HEAD, sstrdup(), and Variable::value.

Referenced by parse_file().

Here is the call graph for this function:

Variable Documentation

◆ command_output

struct ConfigResultIR command_output
static

Definition at line 188 of file config_parser.c.

Referenced by next_state(), and parse_config().

◆ config_error_nagbar_pid

pid_t config_error_nagbar_pid = -1

Definition at line 48 of file config_parser.c.

Referenced by cmd_reload(), i3_exit(), i3_restart(), and start_config_error_nagbar().

◆ context

struct context* context
static

Definition at line 49 of file config_parser.c.

Referenced by start_application().

◆ current_match

Match current_match
static

Definition at line 188 of file config_parser.c.

Referenced by parse_config().

◆ database

xcb_xrm_database_t* database = NULL

Definition at line 45 of file config_parser.c.

Referenced by get_resource(), and parse_file().

◆ stack

struct stack_entry stack[10]
static

Definition at line 49 of file config_parser.c.

Referenced by clear_stack(), get_long(), get_string(), push_long(), and push_string().

◆ state

cmdp_state state
static

Definition at line 187 of file config_parser.c.

Referenced by next_state(), and parse_config().

◆ statelist

cmdp_state statelist[10] = {INITIAL}
static

Definition at line 197 of file config_parser.c.

Referenced by next_state(), and parse_config().

◆ statelist_idx

int statelist_idx = 1
static

Definition at line 199 of file config_parser.c.

Referenced by next_state(), and parse_config().

◆ subcommand_output

struct ConfigResultIR subcommand_output
static

Definition at line 188 of file config_parser.c.

Referenced by next_state(), and parse_config().