File: cmdline_types.h

package info (click to toggle)
brltty 6.9-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,984 kB
  • sloc: ansic: 154,183; java: 13,514; sh: 9,934; xml: 5,672; tcl: 2,679; makefile: 2,346; awk: 713; lisp: 366; python: 321; ml: 301
file content (135 lines) | stat: -rw-r--r-- 3,314 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * BRLTTY - A background process providing access to the console screen (when in
 *          text mode) for a blind person using a refreshable braille display.
 *
 * Copyright (C) 1995-2025 by The BRLTTY Developers.
 *
 * BRLTTY comes with ABSOLUTELY NO WARRANTY.
 *
 * This is free software, placed under the terms of the
 * GNU Lesser General Public License, as published by the Free Software
 * Foundation; either version 2.1 of the License, or (at your option) any
 * later version. Please see the file LICENSE-LGPL for details.
 *
 * Web Page: http://brltty.app/
 *
 * This software is maintained by Dave Mielke <dave@mielke.cc>.
 */

#ifndef BRLTTY_INCLUDED_CMDLINE_TYPES
#define BRLTTY_INCLUDED_CMDLINE_TYPES

#include "strfmt_types.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#define OPT_WORD_TRUE "on"
#define OPT_WORD_FALSE "off"

typedef enum {
  OPT_Extend	= 0X01,
  OPT_Config	= 0X02,
  OPT_EnvVar	= 0X04,
  OPT_Format  	= 0X08,
} CommandLineOptionFlag;

typedef struct {
  const char *word;
  const char *argument;
  const char *description;

  struct {
    const char *setting;
    int (*adjust) (char **setting);
  } internal;

  unsigned char letter;
  unsigned char bootParameter;
  unsigned char flags;

  union {
    int *flag;
    char **string;
  } setting;

  union {
    const char *const *array;
    STR_DECLARE_FORMATTER((*format), unsigned int index);
  } strings;
} CommandLineOption;

typedef struct {
  const CommandLineOption *table;
  size_t count;
} CommandLineOptions;

#define BEGIN_COMMAND_LINE_OPTIONS(name) \
static const CommandLineOption name##Table[] = { \
  { .word = "help", \
    .letter = 'h', \
    .description = strtext("Show this usage summary, and then exit.") \
  },

#define END_COMMAND_LINE_OPTIONS(name) }; \
static const CommandLineOptions name = { \
  .table = name##Table, \
  .count = ARRAY_COUNT(name##Table), \
};

typedef struct {
  const char *name;
  const char *description;
  const char **setting;
  char optional;
} CommandLineParameter;

typedef struct {
  const CommandLineParameter *table;
  size_t count;
} CommandLineParameters;

#define BEGIN_COMMAND_LINE_PARAMETERS(name) \
static const CommandLineParameter name##Table[] = {

#define END_COMMAND_LINE_PARAMETERS(name) }; \
static const CommandLineParameters name = { \
  .table = name##Table, \
  .count = ARRAY_COUNT(name##Table), \
};

#define DECLARE_COMMAND_LINE_NOTES(name) const char *const name[]
#define START_COMMAND_LINE_NOTES(name) DECLARE_COMMAND_LINE_NOTES(name) = {
#define BEGIN_COMMAND_LINE_NOTES(name) static START_COMMAND_LINE_NOTES(name)
#define END_COMMAND_LINE_NOTES NULL};
#define COMMAND_LINE_NOTES(...) (const char *const *const []){__VA_ARGS__, NULL}

typedef struct {
  const char *name;
  const char *purpose;

  const CommandLineOptions *options;
  const CommandLineParameters *parameters;
  const char *const *const *notes;

  struct {
    const char *name;
    const char *description;
  } extraParameters;

  char **configurationFile;
  int *doEnvironmentVariables;
  int *doBootParameters;
} CommandLineDescriptor;

#define BEGIN_COMMAND_LINE_DESCRIPTOR(name) \
static const CommandLineDescriptor name = {

#define END_COMMAND_LINE_DESCRIPTOR };

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* BRLTTY_INCLUDED_CMDLINE_TYPES */