aboutsummaryrefslogtreecommitdiff
path: root/src/config.h
blob: f7b8e4563f0cca71aa04bcd521e1d5c63ca88938 (plain) (blame)
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
/* See LICENSE file for copyright & license details. */
#ifndef SM_CONFIG_H
#define SM_CONFIG_H

#include <stdint.h>

#define OPT_API_KEY "api-key"
#define OPT_HELP "help"
#define OPT_STEAM_ID "steam-id"
#define OPT_VERSION "version"
#define OPT_WIDTH "width"

#define MAX_CFG_LINE_SIZE 256

#define CFG_DEFAULT_WIDTH 10

#define STEAM_API_LEN 32
#define STEAM_ID_LEN 17

typedef struct {
    char *dirpath;
    int dirlen;
} runningdir;

struct config {
    char api_key[STEAM_API_LEN + 1];
    char steam_id[STEAM_ID_LEN + 1];
    uint16_t width;
};

#define CONFIG_DEFAULTS { \
    .api_key[0] = '\0', \
    .steam_id[0] = '\0', \
    .width = CFG_DEFAULT_WIDTH, \
}

int validate_input(struct config *cfg);

int parse_api_key(const char *arg, char *api_key);

int parse_steam_id(const char *arg, char *steam_id);

int parse_width(const char *arg, uint16_t *width);

int get_running_dir(runningdir *currdir);

int parse_config(char *cfgpath, struct config *cfg);

#endif
(git 2.53.0) at 2026-05-13 17:21:15 +0000