blob: 9135c670911720eeac55552604a2720dc81a58a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#ifndef _SWAY_COMMANDS_H
#define _SWAY_COMMANDS_H
#include <stdbool.h>
#include <json-c/json.h>
#include <wlc/wlc.h>
#include "config.h"
/**
* Indicates the result of a command's execution.
*/
enum cmd_status {
CMD_SUCCESS, /**< The command was successful */
CMD_FAILURE, /**< The command resulted in an error */
CMD_INVALID, /**< Unknown command or parser error */
CMD_DEFER, /**< Command execution deferred */
// Config Blocks
CMD_BLOCK_END,
CMD_BLOCK_MODE,
};
/**
* Stores the result of executing a command.
*/
struct cmd_results {
enum cmd_status status;
char *input;
/**
* Human friendly error message, or NULL on success
*/
char *error;
};
/**
* Parse and handles a command.
*/
struct cmd_results *handle_command(char *command);
/**
* Parse and handles a command during config file loading.
*
* Do not use this under normal conditions.
*/
struct cmd_results *config_command(char *command);
/**
* Allocates a cmd_results object.
*/
struct cmd_results *cmd_results_new(enum cmd_status status, const char* input, const char *error, ...);
/**
* Frees a cmd_results object.
*/
void free_cmd_results(struct cmd_results *results);
/**
* Serializes cmd_results to a JSON string.
*
* Free the JSON string later on.
*/
const char *cmd_results_to_json(struct cmd_results *results);
void remove_view_from_scratchpad();
#endif
|