Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/util/ss/test_ss.c
34889 views
1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
/*
3
* util/ss/test_ss.c
4
*/
5
6
7
#include <stdio.h>
8
#include "ss.h"
9
10
extern ss_request_table test_cmds;
11
12
#define TRUE 1
13
#define FALSE 0
14
15
static char def_subsystem_name[5] = "test";
16
static char version [4] = "1.0";
17
18
int main(argc, argv)
19
int argc;
20
char **argv;
21
{
22
int code;
23
char *argv0 = argv[0];
24
char *initial_request = (char *)NULL;
25
int quit = FALSE; /* quit after processing request */
26
int sci_idx;
27
char *subsystem_name;
28
29
subsystem_name = def_subsystem_name;
30
31
for (; *argv; ++argv, --argc) {
32
printf("checking arg: %s\n", *argv);
33
if (!strcmp(*argv, "-prompt")) {
34
if (argc == 1) {
35
fprintf(stderr,
36
"No argument supplied with -prompt\n");
37
exit(1);
38
}
39
argc--; argv++;
40
subsystem_name = *argv;
41
}
42
else if (!strcmp(*argv, "-request") || !strcmp(*argv, "-rq")) {
43
if (argc == 1) {
44
fprintf(stderr,
45
"No string supplied with -request.\n");
46
exit(1);
47
}
48
argc--; argv++;
49
initial_request = *argv;
50
}
51
else if (!strcmp(*argv, "-quit"))
52
quit = TRUE;
53
else if (!strcmp(*argv, "-no_quit"))
54
quit = FALSE;
55
else if (**argv == '-') {
56
fprintf(stderr, "Unknown control argument %s\n",
57
*argv);
58
fprintf(stderr,
59
"Usage: %s [gateway] [ -prompt name ] [ -request name ] [ -quit ]\n",
60
argv0);
61
exit(1);
62
}
63
}
64
65
sci_idx = ss_create_invocation(subsystem_name, version,
66
(char *)NULL, &test_cmds, &code);
67
if (code) {
68
ss_perror(sci_idx, code, "creating invocation");
69
exit(1);
70
}
71
72
(void) ss_add_request_table (sci_idx, &ss_std_requests, 1, &code);
73
if (code) {
74
ss_perror (sci_idx, code, "adding standard requests");
75
exit (1);
76
}
77
78
if (!quit)
79
printf("test version %s. Type '?' for a list of commands.\n\n",
80
version);
81
82
if (initial_request != (char *)NULL) {
83
code = ss_execute_line(sci_idx, initial_request);
84
if (code != 0)
85
ss_perror(sci_idx, code, initial_request);
86
}
87
if (!quit || code)
88
code = ss_listen (sci_idx);
89
exit(0);
90
}
91
92
93
void test_cmd (argc, argv)
94
int argc;
95
char **argv;
96
{
97
while (++argv, --argc)
98
fputs(*argv, stdout);
99
putchar ('\n');
100
}
101
102