ObjFW  Check-in [21d9b80625]

Overview
Comment:ofdns: Allow repeating -t
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 21d9b806259bc2ca3a594639e29ebdad92c6e97e4fa2e1656d725f11dbb57eb7
User & Date: js on 2020-03-23 00:58:39
Other Links: manifest | tags
Context
2020-03-23
01:03
of_dns_record_type_parse(): Allow ALL check-in: 103f04241c user: js tags: trunk
00:58
ofdns: Allow repeating -t check-in: 21d9b80625 user: js tags: trunk
00:35
ofdns: Add German translation check-in: c1db390649 user: js tags: trunk
Changes

Modified utils/ofdns/OFDNS.m from [2b778189ed] to [7cbfa15818].

49
50
51
52
53
54
55
56

57
58
59
60
61
62
63
		    @"-c  --class "
		    @"  The DNS class to query (defaults to IN)\n    "
		    @"-h  --help  "
		    @"  Show this help\n    "
		    @"-s  --server"
		    @"  The server to query\n    "
		    @"-t  --type  "
		    @"  The record type to query (defaults to ALL)")];

	}

	[OFApplication terminateWithStatus: status];
}

@implementation OFDNS
-  (void)resolver: (OFDNSResolver *)resolver







|
>







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
		    @"-c  --class "
		    @"  The DNS class to query (defaults to IN)\n    "
		    @"-h  --help  "
		    @"  Show this help\n    "
		    @"-s  --server"
		    @"  The server to query\n    "
		    @"-t  --type  "
		    @"  The record type to query (defaults to ALL, can be "
		    @"repeated)")];
	}

	[OFApplication terminateWithStatus: status];
}

@implementation OFDNS
-  (void)resolver: (OFDNSResolver *)resolver
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119


120
121
122
123



124
125
126
127
128
129
130

	if (_inFlight == 0)
		[OFApplication terminateWithStatus: _errors];
}

- (void)applicationDidFinishLaunching
{
	OFString *DNSClassString, *server, *recordTypeString;
	const of_options_parser_option_t options[] = {
		{ 'c', @"class", 1, NULL, &DNSClassString },
		{ 'h', @"help", 0, NULL, NULL },
		{ 's', @"server", 1, NULL, &server },
		{ 't', @"type", 1, NULL, &recordTypeString },
		{ '\0', nil, 0, NULL, NULL }
	};

	OFOptionsParser *optionsParser;
	of_unichar_t option;
	OFArray OF_GENERIC(OFString *) *remainingArguments;
	OFDNSResolver *resolver;
	of_dns_class_t DNSClass;
	of_dns_record_type_t recordType;

#ifdef OF_HAVE_FILES
# ifndef OF_AMIGAOS
	[OFLocale addLanguageDirectory: @LANGUAGE_DIR];
# else
	[OFLocale addLanguageDirectory: @"PROGDIR:/share/ofdns/lang"];
# endif
#endif

#ifdef OF_HAVE_SANDBOX
	OFSandbox *sandbox = [[OFSandbox alloc] init];
	@try {
		sandbox.allowsStdIO = true;
		sandbox.allowsDNS = true;

		[OFApplication activateSandbox: sandbox];
	} @finally {
		[sandbox release];
	}
#endif



	optionsParser = [OFOptionsParser parserWithOptions: options];
	while ((option = [optionsParser nextOption]) != '\0') {
		switch (option) {



		case 'h':
			help(of_stdout, true, 0);
			break;
		case ':':
			if (optionsParser.lastLongOption != nil)
				[of_stderr writeLine: OF_LOCALIZED(
				    @"long_option_required_argument",







|




|


>





<




















>
>




>
>
>







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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

	if (_inFlight == 0)
		[OFApplication terminateWithStatus: _errors];
}

- (void)applicationDidFinishLaunching
{
	OFString *DNSClassString, *server;
	const of_options_parser_option_t options[] = {
		{ 'c', @"class", 1, NULL, &DNSClassString },
		{ 'h', @"help", 0, NULL, NULL },
		{ 's', @"server", 1, NULL, &server },
		{ 't', @"type", 1, NULL, NULL },
		{ '\0', nil, 0, NULL, NULL }
	};
	OFMutableArray OF_GENERIC(OFString *) *recordTypes;
	OFOptionsParser *optionsParser;
	of_unichar_t option;
	OFArray OF_GENERIC(OFString *) *remainingArguments;
	OFDNSResolver *resolver;
	of_dns_class_t DNSClass;


#ifdef OF_HAVE_FILES
# ifndef OF_AMIGAOS
	[OFLocale addLanguageDirectory: @LANGUAGE_DIR];
# else
	[OFLocale addLanguageDirectory: @"PROGDIR:/share/ofdns/lang"];
# endif
#endif

#ifdef OF_HAVE_SANDBOX
	OFSandbox *sandbox = [[OFSandbox alloc] init];
	@try {
		sandbox.allowsStdIO = true;
		sandbox.allowsDNS = true;

		[OFApplication activateSandbox: sandbox];
	} @finally {
		[sandbox release];
	}
#endif

	recordTypes = [OFMutableArray array];

	optionsParser = [OFOptionsParser parserWithOptions: options];
	while ((option = [optionsParser nextOption]) != '\0') {
		switch (option) {
		case 't':
			[recordTypes addObject: optionsParser.argument];
			break;
		case 'h':
			help(of_stdout, true, 0);
			break;
		case ':':
			if (optionsParser.lastLongOption != nil)
				[of_stderr writeLine: OF_LOCALIZED(
				    @"long_option_required_argument",
171
172
173
174
175
176
177
178
179
180
181
182
183
184



185
186
187
188
189
190
191



192
193
194
195
196

197
198

199
200
201

	remainingArguments = optionsParser.remainingArguments;

	if (remainingArguments.count < 1)
		help(of_stderr, false, 1);

	resolver = [OFDNSResolver resolver];
	recordType = (recordTypeString != nil
	    ? of_dns_record_type_parse(recordTypeString)
	    : OF_DNS_RECORD_TYPE_ALL);
	DNSClass = (DNSClassString != nil
	    ? of_dns_class_parse(DNSClassString)
	    : OF_DNS_CLASS_IN);




	if (server != nil) {
		resolver.configReloadInterval = 0;
		resolver.nameServers = [OFArray arrayWithObject: server];
	}

	_inFlight = remainingArguments.count;
	for (OFString *domainName in remainingArguments) {



		OFDNSQuery *query =
		    [OFDNSQuery queryWithDomainName: domainName
					   DNSClass: DNSClass
					 recordType: recordType];


		[resolver asyncPerformQuery: query
				   delegate: self];

	}
}
@end







<
<
<




>
>
>





<

>
>
>
|
|
|
|

>
|
|
>



177
178
179
180
181
182
183



184
185
186
187
188
189
190
191
192
193
194
195

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211

	remainingArguments = optionsParser.remainingArguments;

	if (remainingArguments.count < 1)
		help(of_stderr, false, 1);

	resolver = [OFDNSResolver resolver];



	DNSClass = (DNSClassString != nil
	    ? of_dns_class_parse(DNSClassString)
	    : OF_DNS_CLASS_IN);

	if (recordTypes.count == 0)
		[recordTypes addObject: @"ALL"];

	if (server != nil) {
		resolver.configReloadInterval = 0;
		resolver.nameServers = [OFArray arrayWithObject: server];
	}


	for (OFString *domainName in remainingArguments) {
		for (OFString *recordTypeString in recordTypes) {
			of_dns_record_type_t recordType =
			    of_dns_record_type_parse(recordTypeString);
			OFDNSQuery *query =
			    [OFDNSQuery queryWithDomainName: domainName
						   DNSClass: DNSClass
						 recordType: recordType];

			_inFlight++;
			[resolver asyncPerformQuery: query
					   delegate: self];
		}
	}
}
@end

Modified utils/ofdns/lang/de.json from [e3d5a9129f] to [a2dd6e542b].

1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
16
17
{
    "usage": "Benutzung: %[prog] -[chst] domain1 [domain2 ...]",
    "full_usage": [
        "Optionen:\n",
        "    -c  --class   Die anzufragende DNS-Klasse (standardmäßig IN)\n",
        "    -h  --help    Diese Hilfe anzeigen\n",
        "    -s  --server  Der abzufragende Server\n",
        "    -t  --type    Der anzufragende Record-Typ (standardmäßig ALL)"

    ],
    "long_option_requires_argument": [
        "%[prog]: Option --%[opt] benötigt ein Argument"
    ],
    "option_requires_argument": "%[prog]: Option -%[opt] benötigt ein Argument",
    "unknown_long_option": "%[prog]: Unbekannte Option: --%[opt]",
    "unknown_option": "%[prog]: Unbekannte Option: -%[opt]",
    "failed_to_resolve": "Auflösen fehlgeschlagen: %[exception]"
}







|
>









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
    "usage": "Benutzung: %[prog] -[chst] domain1 [domain2 ...]",
    "full_usage": [
        "Optionen:\n",
        "    -c  --class   Die anzufragende DNS-Klasse (standardmäßig IN)\n",
        "    -h  --help    Diese Hilfe anzeigen\n",
        "    -s  --server  Der abzufragende Server\n",
        "    -t  --type    Der anzufragende Record-Typ (standardmäßig ALL,\n",
        "                  kann wiederholt werden)"
    ],
    "long_option_requires_argument": [
        "%[prog]: Option --%[opt] benötigt ein Argument"
    ],
    "option_requires_argument": "%[prog]: Option -%[opt] benötigt ein Argument",
    "unknown_long_option": "%[prog]: Unbekannte Option: --%[opt]",
    "unknown_option": "%[prog]: Unbekannte Option: -%[opt]",
    "failed_to_resolve": "Auflösen fehlgeschlagen: %[exception]"
}