aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tru/tru.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tru/tru.h')
-rw-r--r--src/tru/tru.h209
1 files changed, 209 insertions, 0 deletions
diff --git a/src/tru/tru.h b/src/tru/tru.h
new file mode 100644
index 0000000..75c26c3
--- /dev/null
+++ b/src/tru/tru.h
@@ -0,0 +1,209 @@
1/*
2 * Tiny RADIUS Client Library
3 * Copyright (C) 2021 David M. Syzdek <david@syzdek.net>.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of David M. Syzdek nor the
16 * names of its contributors may be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M. SYZDEK BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31#ifndef _SRC_TRU_TRU_H
32#define _SRC_TRU_TRU_H 1
33
34///////////////
35// //
36// Headers //
37// //
38///////////////
39#pragma mark - Headers
40
41#include <tinyrad_utils.h>
42
43#include <stdio.h>
44#include <stdarg.h>
45#include <stdlib.h>
46#include <string.h>
47#include <strings.h>
48#include <unistd.h>
49#include <getopt.h>
50#include <sys/types.h>
51#include <sys/stat.h>
52#include <sys/uio.h>
53#include <unistd.h>
54#include <assert.h>
55#include <fcntl.h>
56#include <errno.h>
57
58
59///////////////////
60// //
61// Definitions //
62// //
63///////////////////
64#pragma mark - Definitions
65
66#undef PROGRAM_NAME
67#define PROGRAM_NAME "tinyrad"
68
69#define MY_OPT_DICT_DEFAULTS 0x0001UL
70#define MY_OPT_DICT_DUMP 0x0002UL
71#define MY_OPT_DICT_LOADED 0x0004UL
72#define MY_OPT_CONFIG_PRINT 0x0008UL
73
74
75#define MY_GETOPT_MATCHED -2
76#define MY_GETOPT_ERROR -3
77#define MY_GETOPT_EXIT -4
78
79
80#define TINYRAD_GETOPT_SHORT "d:f:hqVv"
81#define TINYRAD_GETOPT_LONG \
82 { "debug", optional_argument, NULL, 'd' }, \
83 { "help", no_argument, NULL, 'h' }, \
84 { "quiet", no_argument, NULL, 'q' }, \
85 { "silent", no_argument, NULL, 'q' }, \
86 { "version", no_argument, NULL, 'V' }, \
87 { "verbose", no_argument, NULL, 'v' }, \
88 { NULL, 0, NULL, 0 }
89
90
91#define TINYRAD_DICT_GETOPT_SHORT "bD:I:"
92#define TINYRAD_DICT_GETOPT_LONG \
93 { "builtin-dict", no_argument, NULL, 'b' }, \
94
95
96#define TINYRAD_REQ_GETOPT_SHORT "D:I:"
97#define TINYRAD_REQ_GETOPT_LONG \
98 { "file", optional_argument, NULL, 'f' }, \
99
100
101//////////////////
102// //
103// Data Types //
104// //
105//////////////////
106#pragma mark - Data Types
107
108typedef struct tinyrad_util_config TinyRadUtilConf;
109typedef struct tinyrad_util_widget TinyRadUtilWidget;
110
111
112typedef struct my_request_av
113{
114 char * attr_name;
115 char * attr_value;
116} MyRequestAV;
117
118
119struct tinyrad_util_config
120{
121 unsigned opts;
122 unsigned tr_opts;
123 int padint;
124 int cmd_argc;
125 char ** cmd_argv;
126 const char * cmd_name;
127 size_t cmd_len;
128 void * padptr;
129 const TinyRadUtilWidget * cmd;
130 TinyRad * tr;
131 const char * url;
132 char ** dict_files;
133 char ** dict_paths;
134};
135
136
137struct tinyrad_util_widget
138{
139 const char * name;
140 int (*func)(TinyRadUtilConf * cnf);
141 const char * shortopts;
142 struct option * longopts;
143 int min_arg;
144 int max_arg;
145 const char * usage;
146 const char * desc;
147};
148
149
150/////////////////
151// //
152// Variables //
153// //
154/////////////////
155#pragma mark - Variables
156
157#pragma mark tinyrad_cmdmap[]
158extern const TinyRadUtilWidget tru_widget_map[];
159
160
161//////////////////
162// //
163// Prototypes //
164// //
165//////////////////
166#pragma mark - Prototypes
167
168int
169main(
170 int argc,
171 char * argv[] );
172
173
174void
175tru_cleanup(
176 TinyRadUtilConf * cnf );
177
178
179int
180tru_widget_config(
181 TinyRadUtilConf * cnf );
182
183
184int
185tru_widget_dict(
186 TinyRadUtilConf * cnf );
187
188
189int
190tru_getopt(
191 TinyRadUtilConf * cnf,
192 int argc,
193 char * const * argv,
194 const char * short_opt,
195 const struct option * long_opt,
196 int * opt_index );
197
198
199int
200tru_load_tinyrad(
201 TinyRadUtilConf * cnf );
202
203
204int
205tru_usage(
206 TinyRadUtilConf * cnf );
207
208
209#endif /* end of header */