ObjFW  Check-in [2ef6db8a44]

Overview
Comment:Remove utils/ofatalkcfg

Instead, in the future there should be something more generic that is
not limited to AppleTalk.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2ef6db8a44fdaea6c09c060e1e49bd910146e0bd8d4f3404e3e414a282cdd8d2
User & Date: js on 2023-05-21 13:02:53
Other Links: manifest | tags
Context
2023-05-21
13:10
Remove support for configuring AppleTalk check-in: 550bd1b7bb user: js tags: trunk
13:02
Remove utils/ofatalkcfg check-in: 2ef6db8a44 user: js tags: trunk
11:04
OFTCPSocket: Return socket address bound to check-in: fc161d1948 user: js tags: trunk
Changes

Modified .fossil-settings/clean-glob from [af205be7e9] to [0ae1b8a1ac].

47
48
49
50
51
52
53
54
55
56
57
tests/tests.arm9
tests/tests.nds
tests/tests.nro
tests/tests.rpx
utils/objfw-config
utils/objfw-new/objfw-new
utils/ofarc/ofarc
utils/ofatalkcfg/ofatalkcfg
utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp







<



47
48
49
50
51
52
53

54
55
56
tests/tests.arm9
tests/tests.nds
tests/tests.nro
tests/tests.rpx
utils/objfw-config
utils/objfw-new/objfw-new
utils/ofarc/ofarc

utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp

Modified .fossil-settings/ignore-glob from [72d7550f75] to [eed8ea3523].

52
53
54
55
56
57
58
59
60
61
62
tests/tests.arm9
tests/tests.nds
tests/tests.nro
tests/tests.rpx
utils/objfw-config
utils/objfw-new/objfw-new
utils/ofarc/ofarc
utils/ofatalkcfg/ofatalkcfg
utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp







<



52
53
54
55
56
57
58

59
60
61
tests/tests.arm9
tests/tests.nds
tests/tests.nro
tests/tests.rpx
utils/objfw-config
utils/objfw-new/objfw-new
utils/ofarc/ofarc

utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp

Modified .gitignore from [968910a4e3] to [9fa51c850c].

52
53
54
55
56
57
58
59
60
61
62
tests/tests.arm9
tests/tests.nds
tests/tests.nro
tests/tests.rpx
utils/objfw-config
utils/objfw-new/objfw-new
utils/ofarc/ofarc
utils/ofatalkcfg/ofatalkcfg
utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp







<



52
53
54
55
56
57
58

59
60
61
tests/tests.arm9
tests/tests.nds
tests/tests.nro
tests/tests.rpx
utils/objfw-config
utils/objfw-new/objfw-new
utils/ofarc/ofarc

utils/ofdns/ofdns
utils/ofhash/ofhash
utils/ofhttp/ofhttp

Modified configure.ac from [b9167f6245] to [945ea348f4].

1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738

			AC_CHECK_TYPE([struct ifreq], [
				AC_DEFINE(OF_HAVE_APPLETALK_IFCONFIG, 1,
				    m4_normalize([
					Whether AppleTalk interfaces
					can be configured
				]))
				AC_SUBST(OFATALKCFG, ofatalkcfg)
			], [], [
				#ifdef OF_HAVE_SYS_SOCKET_H
				# include <sys/socket.h>
				#endif
				#include <net/if.h>
			])
		])







<







1724
1725
1726
1727
1728
1729
1730

1731
1732
1733
1734
1735
1736
1737

			AC_CHECK_TYPE([struct ifreq], [
				AC_DEFINE(OF_HAVE_APPLETALK_IFCONFIG, 1,
				    m4_normalize([
					Whether AppleTalk interfaces
					can be configured
				]))

			], [], [
				#ifdef OF_HAVE_SYS_SOCKET_H
				# include <sys/socket.h>
				#endif
				#include <net/if.h>
			])
		])

Modified extra.mk.in from [356ea19232] to [44ae1c186b].

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
LOOKUP_ASM_A = @LOOKUP_ASM_A@
LOOKUP_ASM_AMIGALIB_A = @LOOKUP_ASM_AMIGALIB_A@
LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@
MAP_LDFLAGS = @MAP_LDFLAGS@
OBJC_SYNC = @OBJC_SYNC@
OBJFW_NEW = @OBJFW_NEW@
OFARC = @OFARC@
OFATALKCFG = @OFATALKCFG@
OFDNS = @OFDNS@
OFHASH = @OFHASH@
OFHTTP = @OFHTTP@
OFHTTP_LIBS = @OFHTTP_LIBS@
OF_BLOCK_TESTS_M = @OF_BLOCK_TESTS_M@
OF_EPOLL_KERNEL_EVENT_OBSERVER_M = @OF_EPOLL_KERNEL_EVENT_OBSERVER_M@
OF_GNUTLS_TLS_STREAM_M = @OF_GNUTLS_TLS_STREAM_M@







<







40
41
42
43
44
45
46

47
48
49
50
51
52
53
LOOKUP_ASM_A = @LOOKUP_ASM_A@
LOOKUP_ASM_AMIGALIB_A = @LOOKUP_ASM_AMIGALIB_A@
LOOKUP_ASM_LIB_A = @LOOKUP_ASM_LIB_A@
MAP_LDFLAGS = @MAP_LDFLAGS@
OBJC_SYNC = @OBJC_SYNC@
OBJFW_NEW = @OBJFW_NEW@
OFARC = @OFARC@

OFDNS = @OFDNS@
OFHASH = @OFHASH@
OFHTTP = @OFHTTP@
OFHTTP_LIBS = @OFHTTP_LIBS@
OF_BLOCK_TESTS_M = @OF_BLOCK_TESTS_M@
OF_EPOLL_KERNEL_EVENT_OBSERVER_M = @OF_EPOLL_KERNEL_EVENT_OBSERVER_M@
OF_GNUTLS_TLS_STREAM_M = @OF_GNUTLS_TLS_STREAM_M@

Modified objfw.spec from [8bee408a0e] to [77fa467494].

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
BuildRequires: make
BuildRequires: pkgconfig(gnutls)
Requires:      %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
Requires:      %{libobjfw_pkgname}-devel = %{version}-%{release}
Requires:      %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
Requires:      %{libobjfwrt_pkgname}-devel = %{version}-%{release}
Requires:      ofarc%{_isa} = %{version}-%{release}
Requires:      ofatalkcfg%{_isa} = %{version}-%{release}
Requires:      ofdns%{_isa} = %{version}-%{release}
Requires:      ofhash%{_isa} = %{version}-%{release}
Requires:      ofhttp%{_isa} = %{version}-%{release}

%description
ObjFW is a portable, lightweight framework for the Objective-C language. It
enables you to write an application in Objective-C that will run on any







<







34
35
36
37
38
39
40

41
42
43
44
45
46
47
BuildRequires: make
BuildRequires: pkgconfig(gnutls)
Requires:      %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
Requires:      %{libobjfw_pkgname}-devel = %{version}-%{release}
Requires:      %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}
Requires:      %{libobjfwrt_pkgname}-devel = %{version}-%{release}
Requires:      ofarc%{_isa} = %{version}-%{release}

Requires:      ofdns%{_isa} = %{version}-%{release}
Requires:      ofhash%{_isa} = %{version}-%{release}
Requires:      ofhttp%{_isa} = %{version}-%{release}

%description
ObjFW is a portable, lightweight framework for the Objective-C language. It
enables you to write an application in Objective-C that will run on any
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Requires:      %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}

%description -n ofarc
ofarc is a multi-format archive utility that allows creating, listing,
extracting and modifying ZIP, Tar and LHA archives using ObjFW's classes for
various archive types.

%package -n ofatalkcfg
Summary:       Utility to configure network interfaces for AppleTalk
Requires:      %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
Requires:      %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}

%description -n ofatalkcfg
ofatalkcfg is a utility to configure network interfaces for AppleTalk.

%package -n ofdns
Summary:       Utility for performing DNS requests on the command line
Requires:      %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
Requires:      %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}

%description -n ofdns
ofdns is an utility for performing DNS requests on the command line using







<
<
<
<
<
<
<
<







108
109
110
111
112
113
114








115
116
117
118
119
120
121
Requires:      %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}

%description -n ofarc
ofarc is a multi-format archive utility that allows creating, listing,
extracting and modifying ZIP, Tar and LHA archives using ObjFW's classes for
various archive types.









%package -n ofdns
Summary:       Utility for performing DNS requests on the command line
Requires:      %{libobjfw_pkgname}%{_isa} = %{version}-%{release}
Requires:      %{libobjfwrt_pkgname}%{_isa} = %{version}-%{release}

%description -n ofdns
ofdns is an utility for performing DNS requests on the command line using
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
%files -n ofarc
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.QPL
%{_bindir}/ofarc
%{_datadir}/ofarc

%files -n ofatalkcfg
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.QPL
%{_bindir}/ofatalkcfg

%files -n ofdns
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.QPL
%{_bindir}/ofdns
%{_datadir}/ofdns








<
<
<
<
<
<







218
219
220
221
222
223
224






225
226
227
228
229
230
231
%files -n ofarc
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.QPL
%{_bindir}/ofarc
%{_datadir}/ofarc







%files -n ofdns
%license LICENSE.GPLv2
%license LICENSE.GPLv3
%license LICENSE.QPL
%{_bindir}/ofdns
%{_datadir}/ofdns

Modified utils/Makefile from [af0f6dd2b8] to [66810ae4c9].

1
2
3
4
5
6
7
8
9
10
11
12
include ../extra.mk

SUBDIRS += ${OBJFW_NEW}		\
	   ${OFARC}		\
	   ${OFATALKCFG}	\
	   ${OFDNS}		\
	   ${OFHASH}		\
	   ${OFHTTP}

include ../buildsys.mk

DISTCLEAN = objfw-config




<







1
2
3
4

5
6
7
8
9
10
11
include ../extra.mk

SUBDIRS += ${OBJFW_NEW}		\
	   ${OFARC}		\

	   ${OFDNS}		\
	   ${OFHASH}		\
	   ${OFHTTP}

include ../buildsys.mk

DISTCLEAN = objfw-config

Deleted utils/ofatalkcfg/Makefile version [297ac97b13].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
include ../../extra.mk

PROG = ofatalkcfg${PROG_SUFFIX}
SRCS = OFATalkCfg.m

include ../../buildsys.mk

PACKAGE_NAME = ofatalkcfg

${PROG}: ${LIBOBJFW_DEP_LVL2} ${LIBOBJFWRT_DEP_LVL2}

CPPFLAGS += -I../../src							\
	    -I../../src/runtime						\
	    -I../../src/exceptions					\
	    -I../..
LIBS := -L../../src -lobjfw						\
	-L../../src/runtime -L../../src/runtime/linklib ${RUNTIME_LIBS}	\
	${LIBS}
LD = ${OBJC}
LDFLAGS += ${LDFLAGS_RPATH}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































Deleted utils/ofatalkcfg/OFATalkCfg.m version [60ff50c3af].

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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
 * Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <errno.h>

#import "OFApplication.h"
#import "OFArray.h"
#import "OFDDPSocket.h"
#import "OFDictionary.h"
#import "OFNumber.h"
#import "OFOptionsParser.h"
#import "OFPair.h"
#import "OFStdIOStream.h"

#import "OFGetOptionFailedException.h"
#import "OFInvalidFormatException.h"
#import "OFSetOptionFailedException.h"

@interface OFATalkCfg: OFObject <OFApplicationDelegate>
@end

OF_APPLICATION_DELEGATE(OFATalkCfg)

static void
showError(OFString *error)
{
	[OFStdErr writeFormat: @"%@: %@\n", [OFApplication programName], error];
	[OFApplication terminateWithStatus: 1];
}

static void
showConfiguration(OFArray OF_GENERIC(OFString *) *arguments)
{
	OFAppleTalkInterfaceConfiguration config;
	OFNumber *network, *node, *phase;
	OFPair OF_GENERIC(OFNumber *, OFNumber *) *range;

	if (arguments.count == 0)
		showError(@"No interface specified!");
	if (arguments.count > 1)
		showError(@"More than one interface specified!");

	config = [OFDDPSocket configurationForInterface: arguments.firstObject];
	network = [config
	    objectForKey: OFAppleTalkInterfaceConfigurationNetwork];
	node = [config objectForKey: OFAppleTalkInterfaceConfigurationNode];
	phase = [config objectForKey: OFAppleTalkInterfaceConfigurationPhase];
	range = [config
	    objectForKey: OFAppleTalkInterfaceConfigurationNetworkRange];

	if (network == nil || node == nil)
		[OFApplication terminateWithStatus: 1];

	[OFStdOut writeLine: arguments.firstObject];
	[OFStdOut writeFormat: @"\tNetwork:   %04X\n",
			       network.unsignedShortValue];
	[OFStdOut writeFormat: @"\tNode:      %02X\n", node.unsignedCharValue];
	if (phase != nil)
		[OFStdOut writeFormat: @"\tPhase:     %@\n", phase];
	if (range != nil) {
		unsigned short start = [range.firstObject unsignedShortValue];
		unsigned short end = [range.secondObject unsignedShortValue];
		[OFStdOut writeFormat: @"\tNet range: %04X-%04X\n", start, end];
	}
}

static void
setConfiguration(OFArray OF_GENERIC(OFString *) *arguments,
    OFString *networkString, OFString *nodeString, OFString *phaseString,
    OFString *rangeString)
{
	OFMutableDictionary *config = [OFMutableDictionary dictionary];
	unsigned long long node, network, phase, rangeStart, rangeEnd;
	OFArray OF_GENERIC(OFString *) *rangeArray;

	if (arguments.count == 0)
		showError(@"No interface specified!");
	if (arguments.count > 1)
		showError(@"More than one interface specified!");

	if (networkString == nil)
		showError(@"--network not specified!");
	@try {
		network = [networkString unsignedLongLongValueWithBase: 0];
	} @catch (OFInvalidFormatException *e) {
		showError(@"Invalid format for --network!");
		return;
	}
	if (network > UINT16_MAX)
		showError(@"--network out of range!");
	[config setObject: [OFNumber numberWithUnsignedShort: (uint16_t)network]
		   forKey: OFAppleTalkInterfaceConfigurationNetwork];

	if (nodeString == nil)
		showError(@"--node not specified!");
	@try {
		node = [nodeString unsignedLongLongValueWithBase: 0];
	} @catch (OFInvalidFormatException *e) {
		showError(@"Invalid format for --node!");
		return;
	}
	if (node > UINT8_MAX)
		showError(@"--node out of range!");
	[config setObject: [OFNumber numberWithUnsignedChar: (uint8_t)node]
		   forKey: OFAppleTalkInterfaceConfigurationNode];

	if (phaseString != nil) {
		@try {
			phase = [phaseString unsignedLongLongValueWithBase: 0];
		} @catch (OFInvalidFormatException *e) {
			showError(@"Invalid format for "@"--phase!");
			return;
		}

		if (phase > 2)
			showError(@"--phase out of range!");

		[config setObject: [OFNumber
				       numberWithUnsignedChar: (uint8_t)phase]
			   forKey: OFAppleTalkInterfaceConfigurationPhase];
	}

	if (rangeString != nil) {
		const OFAppleTalkInterfaceConfigurationKey key =
		    OFAppleTalkInterfaceConfigurationNetworkRange;
		OFPair *range;

		rangeArray = [rangeString componentsSeparatedByString: @"-"];
		if (rangeArray.count != 2)
			showError(@"Invalid format for --range!");

		@try {
			rangeStart = [[rangeArray objectAtIndex: 0]
			    unsignedLongLongValueWithBase: 0];
			rangeEnd = [[rangeArray objectAtIndex: 1]
			    unsignedLongLongValueWithBase: 0];
		} @catch (OFInvalidFormatException *e) {
			showError(@"Invalid format for --range!");
			return;
		}
		if (rangeStart > UINT16_MAX || rangeEnd > UINT16_MAX)
			showError(@"--range out of range!");

		range = [OFPair
		    pairWithFirstObject: [OFNumber numberWithUnsignedShort:
					     (uint16_t)rangeStart]
			   secondObject: [OFNumber numberWithUnsignedShort:
					     (uint16_t)rangeEnd]];
		[config setObject: range forKey: key];
	}

	@try {
		[OFDDPSocket setConfiguration: config
				 forInterface: arguments.firstObject];
	} @catch (OFSetOptionFailedException *e) {
		showError([OFString stringWithFormat:
		    @"Setting configuration failed: %@", e]);
	}
}

@implementation OFATalkCfg
- (void)applicationDidFinishLaunching: (OFNotification *)notification
{
	OFString *nodeString = nil, *networkString = nil, *phaseString = nil;
	OFString *rangeString = nil;
	const OFOptionsParserOption options[] = {
		{ '\0', @"network", 1, NULL, &networkString },
		{ '\0', @"node", 1, NULL, &nodeString },
		{ '\0', @"phase", 1, NULL, &phaseString },
		{ '\0', @"range", 1, NULL, &rangeString },
		{ '\0', nil, 0, NULL, NULL }
	};
	OFOptionsParser *optionsParser =
	    [OFOptionsParser parserWithOptions: options];
	OFUnichar option;

	while ((option = [optionsParser nextOption]) != '\0') {
		switch (option) {
		case ':':
			if (optionsParser.lastLongOption != nil)
				[OFStdErr writeFormat:
				    @"%@: Argument for option --%@ missing\n",
				    [OFApplication programName],
				    optionsParser.lastLongOption];
			else
				[OFStdErr writeFormat:
				    @"%@: Argument for option -%C missing\n",
				    [OFApplication programName],
				    optionsParser.lastOption];

			[OFApplication terminateWithStatus: 1];
			break;
		case '?':
			if (optionsParser.lastLongOption != nil)
				[OFStdErr writeFormat:
				    @"%@: Unknown option: --%@\n",
				    [OFApplication programName],
				    optionsParser.lastLongOption];
			else
				[OFStdErr writeFormat:
				    @"%@: Unknown option: -%C\n",
				    [OFApplication programName],
				    optionsParser.lastOption];

			[OFApplication terminateWithStatus: 1];
			break;
		}
	}

	if (networkString == nil && nodeString == nil && phaseString == nil &&
	    rangeString == nil)
		showConfiguration(optionsParser.remainingArguments);
	else
		setConfiguration(optionsParser.remainingArguments,
		    networkString, nodeString, phaseString, rangeString);

	[OFApplication terminate];
}
@end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<