i3
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 <libgen.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

Typedefs

typedef struct token cmdp_token
typedef struct tokenptr cmdp_token_ptr

Functions

static void push_string (struct stack *ctx, const char *identifier, const char *str)
static void push_long (struct stack *ctx, const char *identifier, long num)
static const char * get_string (struct stack *ctx, const char *identifier)
static long get_long (struct stack *ctx, const char *identifier)
static void clear_stack (struct stack *ctx)
static void next_state (const cmdp_token *token, struct parser_ctx *ctx)
static const char * start_of_line (const char *walk, const char *beginning)
static char * single_line (const char *start)
static void parse_config (struct parser_ctx *ctx, const char *input, struct context *context)
void start_config_error_nagbar (const char *configpath, bool has_errors)
 Launch nagbar to indicate errors in the configuration file.
static void upsert_variable (struct variables_head *variables, char *key, char *value)
static char * get_resource (char *name)
void free_variables (struct parser_ctx *ctx)
 Releases the memory of all variables in ctx.
parse_file_result_t parse_file (struct parser_ctx *ctx, const char *f, IncludedFile *included_file)
 Parses the given file by first replacing the variables, then calling parse_config and launching i3-nagbar if use_nagbar is true.

Variables

xcb_xrm_database_t * database = NULL
pid_t config_error_nagbar_pid = -1

Typedef Documentation

◆ cmdp_token

typedef struct token cmdp_token

◆ cmdp_token_ptr

typedef struct tokenptr cmdp_token_ptr

Function Documentation

◆ clear_stack()

void clear_stack ( struct stack * ctx)
static

Definition at line 154 of file config_parser.c.

References clear_stack(), stack_entry::identifier, stack::stack, stack_entry::type, and stack_entry::val.

Here is the call graph for this function:

◆ free_variables()

void free_variables ( struct parser_ctx * ctx)

Releases the memory of all variables in ctx.

Definition at line 689 of file config_parser.c.

References FREE, free_variables(), Variable::key, SLIST_EMPTY, SLIST_FIRST, SLIST_REMOVE_HEAD, Variable::value, and parser_ctx::variables.

Referenced by free_variables(), and load_configuration().

Here is the call graph for this function:

◆ get_long()

long get_long ( struct stack * ctx,
const char * identifier )
static

Definition at line 142 of file config_parser.c.

References get_long(), stack_entry::identifier, stack::stack, and stack_entry::val.

Here is the call graph for this function:

◆ get_resource()

char * get_resource ( char * name)
static

Definition at line 660 of file config_parser.c.

References conn, database, ELOG, and get_resource().

Referenced by get_resource(), and parse_file().

Here is the call graph for this function:

◆ get_string()

const char * get_string ( struct stack * ctx,
const char * identifier )
static

Definition at line 130 of file config_parser.c.

References get_string(), stack_entry::identifier, stack::stack, and stack_entry::val.

Here is the call graph for this function:

◆ next_state()

◆ parse_config()

◆ parse_file()

parse_file_result_t parse_file ( struct parser_ctx * ctx,
const char * f,
IncludedFile * included_file )

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 705 of file config_parser.c.

References check_for_duplicate_bindings(), database, DLOG, ELOG, context::filename, FREE, get_resource(), context::has_errors, parser_ctx::has_errors, context::has_warnings, i3_version, Variable::key, context::line_copy, LOG, Variable::next_match, parse_config(), parse_file(), PARSE_FILE_CONFIG_ERRORS, PARSE_FILE_FAILED, PARSE_FILE_SUCCESS, IncludedFile::raw_contents, scalloc(), SLIST_FOREACH, sstrdup(), start_config_error_nagbar(), upsert_variable(), parser_ctx::use_nagbar, Variable::value, IncludedFile::variable_replaced_contents, and parser_ctx::variables.

Referenced by CFGFUN(), load_configuration(), and parse_file().

Here is the call graph for this function:

◆ push_long()

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

Definition at line 109 of file config_parser.c.

References stack_entry::identifier, push_long(), stack::stack, stack_entry::type, and stack_entry::val.

Here is the call graph for this function:

◆ push_string()

void push_string ( struct stack * ctx,
const char * identifier,
const char * str )
static

Definition at line 80 of file config_parser.c.

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

Here is the call graph for this function:

◆ single_line()

char * single_line ( const char * start)
static

Definition at line 224 of file config_parser.c.

References single_line(), and sstrdup().

Referenced by parse_config(), and single_line().

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.

Launch nagbar to indicate errors in the configuration file.

Definition at line 597 of file config_parser.c.

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

Referenced by parse_file(), start_config_error_nagbar(), and translate_keysyms().

Here is the call graph for this function:

◆ start_of_line()

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

Definition at line 210 of file config_parser.c.

References start_of_line().

Referenced by parse_config(), and start_of_line().

Here is the call graph for this function:

◆ upsert_variable()

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

Definition at line 626 of file config_parser.c.

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

Referenced by parse_file(), and upsert_variable().

Here is the call graph for this function:

Variable Documentation

◆ config_error_nagbar_pid

pid_t config_error_nagbar_pid = -1

◆ database

xcb_xrm_database_t* database = NULL

Definition at line 42 of file config_parser.c.

Referenced by get_resource(), and parse_file().