File: cli_common.h

package info (click to toggle)
buffybox 3.4.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 108,056 kB
  • sloc: ansic: 357,060; cpp: 42,613; python: 10,534; xml: 1,214; sh: 823; asm: 665; ruby: 487; makefile: 66
file content (58 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download
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
/**
 * Copyright 2025 buffybox contributors
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#ifndef BBX_CLI_COMMON_H
#define BBX_CLI_COMMON_H

#include <stdbool.h>

/**
 * Common CLI options shared across buffybox tools
 */
typedef struct {
    /* Display geometry */
    int hor_res;
    int ver_res;
    int x_offset;
    int y_offset;
    /* DPI override */
    int dpi;
    /* Verbose logging */
    bool verbose;
} bbx_cli_common_opts;

/**
 * Initialize common CLI options with default values.
 *
 * @param opts pointer to the options struct
 */
void bbx_cli_init_common_opts(bbx_cli_common_opts *opts);

/**
 * Parse geometry argument in format "NxM[@X,Y]".
 *
 * @param optarg the argument string
 * @param opts pointer to options struct to populate
 * @return 0 on success, -1 on failure
 */
int bbx_cli_parse_geometry(const char *optarg, bbx_cli_common_opts *opts);

/**
 * Parse DPI argument.
 *
 * @param optarg the argument string
 * @param opts pointer to options struct to populate
 * @return 0 on success, -1 on failure
 */
int bbx_cli_parse_dpi(const char *optarg, bbx_cli_common_opts *opts);

/**
 * Print version information and exit.
 *
 * @param program_name name of the program
 */
void bbx_cli_print_version_and_exit(const char *program_name);

#endif /* BBX_CLI_COMMON_H */