aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tinytacutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tinytacutil.h')
-rw-r--r--src/tinytacutil.h202
1 files changed, 202 insertions, 0 deletions
diff --git a/src/tinytacutil.h b/src/tinytacutil.h
new file mode 100644
index 0000000..d813182
--- /dev/null
+++ b/src/tinytacutil.h
@@ -0,0 +1,202 @@
1/*
2 * Tiny TACACS+ Client Library
3 * Copyright (C) 2022 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_TTU_TINYTACUTIL_H
32#define _SRC_TTU_TINYTACUTIL_H 1
33
34///////////////
35// //
36// Headers //
37// //
38///////////////
39#pragma mark - Headers
40
41#include <tinytac_compat.h>
42
43#ifdef HAVE_CONFIG_H
44#include <config.h>
45#endif
46
47#include <stdlib.h>
48#include <tinytac.h>
49
50
51///////////////////
52// //
53// Definitions //
54// //
55///////////////////
56#pragma mark - Definitions
57
58#undef PROGRAM_NAME
59#define PROGRAM_NAME "tinytac"
60
61#define TTUTILS_OPT_QUIET 0x00000001U
62#define TTUTILS_OPT_VERBOSE 0x00000002U
63#define TTUTILS_OPT_PASSPROMPT 0x00000004U
64
65
66//////////////////
67// //
68// Data Types //
69// //
70//////////////////
71#pragma mark - Data Types
72
73typedef struct _tinytac_util_widget ttu_widget_t;
74typedef struct _tinytac_util_config ttu_config_t;
75
76struct _tinytac_util_config
77{
78 unsigned opts;
79 int argc;
80 char ** argv;
81 const char * pass;
82 const char * pass_file;
83 char * pass_buff;
84 const char * prog_name;
85 const ttu_widget_t * widget;
86 TinyTac * tt;
87};
88
89
90struct _tinytac_util_widget
91{
92 const char * name;
93 const char * desc;
94 const char * usage;
95 const char * const * aliases;
96 int (*func_exec)(ttu_config_t * cnf);
97 int (*func_usage)(ttu_config_t * cnf);
98};
99
100
101/////////////////
102// //
103// Variables //
104// //
105/////////////////
106#pragma mark - Variables
107
108extern ttu_widget_t ttu_widget_map[];
109
110
111//////////////////
112// //
113// Prototypes //
114// //
115//////////////////
116#pragma mark - Prototypes
117
118//--------------------//
119// logging prototypes //
120//--------------------//
121#pragma mark logging prototypes
122
123extern int
124ttu_error(
125 ttu_config_t * cnf,
126 int rc,
127 const char * fmt,
128 ... );
129
130
131extern int
132ttu_printf(
133 ttu_config_t * cnf,
134 const char * fmt,
135 ... );
136
137
138extern int
139tru_verbose(
140 ttu_config_t * cnf,
141 const char * fmt,
142 ... );
143
144
145//--------------------------//
146// miscellaneous prototypes //
147//--------------------------//
148#pragma mark miscellaneous prototypes
149
150extern char *
151ttu_file2str(
152 const char * path );
153
154
155extern int
156ttu_password(
157 ttu_config_t * cnf );
158
159
160//------------------//
161// usage prototypes //
162//------------------//
163#pragma mark usage prototypes
164
165extern int
166ttu_cli_arguments(
167 ttu_config_t * cnf,
168 int argc,
169 char * const * argv );
170
171
172extern int
173ttu_usage(
174 ttu_config_t * cnf );
175
176
177//-------------------//
178// widget prototypes //
179//-------------------//
180#pragma mark widget prototypes
181
182extern int
183ttu_widget_acct(
184 ttu_config_t * cnf );
185
186
187extern int
188ttu_widget_authen(
189 ttu_config_t * cnf );
190
191
192extern int
193ttu_widget_author(
194 ttu_config_t * cnf );
195
196
197extern int
198ttu_widget_config(
199 ttu_config_t * cnf );
200
201
202#endif /* end of header */