-
Notifications
You must be signed in to change notification settings - Fork 2
/
print_option_settings.c
104 lines (93 loc) · 3.85 KB
/
print_option_settings.c
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
#include <stdio.h>
#include "cli-sub.h"
#include "err_ref.h"
/* --- */
void print_option_settings( FILE *out, int nflags, struct option_set *opset)
{
int off, *int_p;
struct option_set *co = 0;
struct value_chain *chain = 0;
/* Print out settings just for options included on the command line */
fprintf( out, "Seq Num Typ Fl Opt\n");
for( off= 0; off < nflags; off++)
{
co = opset + off;
if( co->opt_num)
{
if( co->flags & OP_FL_REPEATS)
{
for( chain = (struct value_chain *) co->parsed; chain; chain = chain->next)
{
fprintf( out, "%2d+ %3d %3d %2X ", off + 1, co->num, co->type, chain->flags);
fprintf( out, "%3d ", chain->opt_num);
if( co->type == OP_TYPE_INT)
{
int_p = (int *) chain->parsed;
fprintf( out, "%d ", *int_p);
}
else if( co->type == OP_TYPE_CHAR) fprintf( out, "(%s) ", (char *) chain->parsed);
else if( co->type == OP_TYPE_FLOAT) fprintf( out, "%f ", *((float *) chain->parsed));
else fprintf( out, "/?/ ");
fprintf( out, "(%s) (%s) ", co->name, chain->val);
fprintf( out, "\n");
}
}
else
{
fprintf( out, "%2d. %3d %3d %2X ", off + 1, co->num, co->type, co->flags);
fprintf( out, "%3d ", co->opt_num);
if( co->type == OP_TYPE_INT || co->type == OP_TYPE_FLAG)
{
int_p = (int *) co->parsed;
fprintf( out, "%d ", *int_p);
}
else if( co->type == OP_TYPE_CHAR) fprintf( out, "(%s) ", (char *) co->parsed);
else if( co->type == OP_TYPE_FLOAT) fprintf( out, "%f ", *((float *) co->parsed));
else fprintf( out, "/?/ ");
fprintf( out, "(%s) (%s) ", co->name, co->val);
fprintf( out, "\n");
}
}
}
/* Print out all options settings, includes defaults for unspecified options */
fprintf( out, "Seq Num Typ Fl Opt\n");
for( off= 0; off < nflags; off++)
{
co = opset + off;
if(( co->flags & OP_FL_REPEATS) && co->parsed)
{
for( chain = (struct value_chain *) co->parsed; chain; chain = chain->next)
{
fprintf( out, "%2d+ %3d %3d %2X ", off + 1, co->num, co->type, chain->flags);
fprintf( out, "%3d ", chain->opt_num);
if( co->type == OP_TYPE_INT)
{
int_p = (int *) chain->parsed;
fprintf( out, "%d ", *int_p);
}
else if( co->type == OP_TYPE_CHAR) fprintf( out, "(%s) ", (char *) chain->parsed);
else if( co->type == OP_TYPE_FLOAT) fprintf( out, "%f ", *((float *) chain->parsed));
else fprintf( out, "/?/ ");
fprintf( out, "(%s) (%s) ", co->name, chain->val);
fprintf( out, "\n");
}
}
else
{
fprintf( out, "%2d. %3d %3d %2X ", off + 1, co->num, co->type, co->flags);
fprintf( out, "%3d ", co->opt_num);
if( !co->parsed) fprintf( out, "(%s) ", co->def);
else if( co->type == OP_TYPE_INT || co->type == OP_TYPE_FLAG)
{
int_p = (int *) co->parsed;
fprintf( out, "%d ", *int_p);
}
else if( co->type == OP_TYPE_CHAR) fprintf( out, "(%s) ", (char *) co->parsed);
else if( co->type == OP_TYPE_FLOAT) fprintf( out, "%f ", *((float *) co->parsed));
else fprintf( out, "/?/ ");
fprintf( out, "(%s) (%s) ", co->name, co->val);
fprintf( out, "\n");
}
}
return;
}