1 /*
2 * Project : ipv6calc/ipv6calc
3 * File : ipv6calchelp_local.c
4 * Version : $Id: 377cd99a33fe7592095a5d6ab403a327578de170 $
5 * Copyright : 2013-2019 by Peter Bieringer <pb (at) bieringer.de>
6 *
7 * Information:
8 * Help library
9 */
10
11 #include <stdio.h>
12 #include <string.h>
13 #include <stdlib.h>
14 #include <getopt.h>
15 #include "ipv6calc.h"
16 #include "ipv6calctypes.h"
17 #include "ipv6calcoptions.h"
18 #include "ipv6calchelp.h"
19 #include "config.h"
20
21 #include "../databases/lib/libipv6calc_db_wrapper.h"
22
23 // Note: part of help is still located at ../lib/ipv6calchelp.c
24
25 /* display info */
printversion(void)26 void printversion(void) {
27 char resultstring[IPV6CALC_STRING_MAX] = "";
28
29 libipv6calc_db_wrapper_features(resultstring, sizeof(resultstring));
30
31 fprintf(stderr, "%s: version %s", PROGRAM_NAME, PACKAGE_VERSION);
32
33 fprintf(stderr, " %s", resultstring);
34
35 if (feature_zeroize == 1) {
36 fprintf(stderr, " ANON_ZEROISE");
37 };
38
39 if (feature_anon == 1) {
40 fprintf(stderr, " ANON_ANONYMIZE");
41 };
42
43 if (feature_kp == 1) {
44 fprintf(stderr, " ANON_KEEP-TYPE-ASN-CC");
45 };
46
47 if (feature_kg == 1) {
48 fprintf(stderr, " ANON_KEEP-TYPE-GEONAMEID");
49 };
50
51 fprintf(stderr, "\n");
52 };
53
printversion_help(void)54 void printversion_help(void) {
55 char resultstring[IPV6CALC_STRING_MAX] = "";
56
57 libipv6calc_db_wrapper_features(resultstring, sizeof(resultstring));
58
59 fprintf(stderr, "\n");
60
61 fprintf(stderr, "Explanation of available(x)/possible(o) feature tokens\n");
62
63 libipv6calc_db_wrapper_features_help();
64
65 fprintf(stderr, "%-25s%c %s\n", "ANON_ZEROISE", (feature_zeroize == 1)? 'x' : 'o', "Anonymization method 'zeroize'");
66 fprintf(stderr, "%-25s%c %s\n", "ANON_ANONYMIZE", (feature_anon == 1) ? 'x' : 'o', "Anonymization method 'anonymize'");
67 fprintf(stderr, "%-25s%c %s\n", "ANON_KEEP-TYPE-ASN-CC", (feature_kp == 1) ? 'x' : 'o', "Anonymization method 'keep-type-asn-cc'");
68 fprintf(stderr, "%-25s%c %s\n", "ANON_KEEP-TYPE-GEONAMEID", (feature_kg == 1) ? 'x' : 'o', "Anonymization method 'keep-type-geonameid'");
69
70 fprintf(stderr, "\n");
71 };
72
printversion_verbose(int level_verbose)73 void printversion_verbose(int level_verbose) {
74 printversion();
75 fprintf(stderr, "\n");
76
77 ipv6calc_print_features_verbose(level_verbose);
78 };
79
printcopyright(void)80 void printcopyright(void) {
81 fprintf(stderr, "%s\n", PROGRAM_COPYRIGHT);
82 };
83
ipv6calc_printinfo(void)84 void ipv6calc_printinfo(void) {
85 printversion();
86 printcopyright();
87 fprintf(stderr, "This program formats and calculates IPv6 addresses and can do many more tricky things\n");
88 fprintf(stderr, "See '%s -?|-h|--help for online help\n", PROGRAM_NAME);
89 fprintf(stderr, "See '%s -v|--version -?|-h|--help' for explanation of feature tokens\n", PROGRAM_NAME);
90 fprintf(stderr, "See '%s -vv or -vvv for more internal version/feature information\n\n", PROGRAM_NAME);
91 };
92
93 /* print global help */
ipv6calc_printhelp(const struct option longopts[],const s_ipv6calc_longopts_shortopts_map longopts_shortopts_map[])94 void ipv6calc_printhelp(const struct option longopts[], const s_ipv6calc_longopts_shortopts_map longopts_shortopts_map[]) {
95 printversion();
96 printcopyright();
97 fprintf(stderr, "\n");
98
99 fprintf(stderr, "This program formats and calculates IPv6/IPv4/MAC addresses and can do many more tricky things\n");
100
101 printhelp_common(IPV6CALC_HELP_ALL & (~(IPV6CALC_HELP_QUIET)));
102
103 fprintf(stderr, " [-q|--quiet] : be more quiet (auto-enabled in pipe mode)\n");
104 fprintf(stderr, " [-f|--flush] : flush each line in pipe mode\n");
105 fprintf(stderr, "\n");
106 fprintf(stderr, " Usage with new style options:\n");
107 fprintf(stderr, " [--in|-I <input type>] : specify input type\n");
108 fprintf(stderr, " (default: autodetect)\n");
109 fprintf(stderr, " [--out|-O <output type>] : specify output type\n");
110 fprintf(stderr, " (sometimes: autodetect)\n");
111 fprintf(stderr, " [--action|-A <action>] : specify action\n");
112 fprintf(stderr, " (default: format conversion, sometimes: autodetect)\n");
113 fprintf(stderr, " [<format option> ...] : specify format options\n");
114 fprintf(stderr, " <input data> [...] : input data\n");
115 fprintf(stderr, "\n");
116 fprintf(stderr, " Available input types: [-m] -I|--in -?|-h|--help\n");
117 fprintf(stderr, " Available output types: [-m] -O|--out -?|-h|--help\n");
118 fprintf(stderr, " Available action types: [-m] -A|--action -?|-h|--help\n");
119 fprintf(stderr, "\n");
120 fprintf(stderr, " Special filter action : -E -?|-h|--help\n");
121 fprintf(stderr, "\n");
122 fprintf(stderr, " Other usage:\n");
123 fprintf(stderr, " --showinfo|-i [--machine_readable|-m] : show information about input data\n");
124 fprintf(stderr, " --showinfo|-i --mrqva : Machine Readable Quote Values Always\n");
125 fprintf(stderr, " --showinfo|-i --mrqvn : Machine Readable Quote Values Never\n");
126 fprintf(stderr, " --showinfo|-i --mrst <TOKEN> : Machine Readable Select Token\n");
127 fprintf(stderr, " --showinfo|-i --mrstpa <TOKEN> : Machine Readable Select Token Print Always\n");
128 fprintf(stderr, " --showinfo|-i --mrmt <TOKENPREFIX> : Machine Readable Match Token Prefix\n");
129 fprintf(stderr, " --showinfo|-i --mrmts <TOKENSUFFIX> : Machine Readable Match Token Suffix\n");
130 fprintf(stderr, " --showinfo|-i --mrtvo <TOKEN> : Machine Readable Token Value Only\n");
131 fprintf(stderr, " --showinfo|-i --show-tokens : show available tokens (aka types) on '-m'\n");
132
133 printhelp_shortcut_options(longopts, longopts_shortopts_map);
134
135 fprintf(stderr, "\n");
136 return;
137 };
138
139