ObjFW  Diff

Differences From Artifact [f271eb5ab9]:

To Artifact [bc94edf915]:


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#import "TestsAppDelegate.h"

@implementation TestsAppDelegate (OFSystemInfoTests)
- (void)systemInfoTests
{
	void *pool = objc_autoreleasePoolPush();
#ifdef OF_SYSTEM_INFO_HAS_NETWORK_INTERFACES
	OFDictionary *networkInterfaces;
	bool firstInterface = true;
#endif

	[OFStdOut setForegroundColor: [OFColor lime]];

	[OFStdOut writeFormat: @"[OFSystemInfo] Page size: %zd\n",
	    [OFSystemInfo pageSize]];

	[OFStdOut writeFormat: @"[OFSystemInfo] Number of CPUs: %zd\n",







<
<
<
<







17
18
19
20
21
22
23




24
25
26
27
28
29
30

#import "TestsAppDelegate.h"

@implementation TestsAppDelegate (OFSystemInfoTests)
- (void)systemInfoTests
{
	void *pool = objc_autoreleasePoolPush();





	[OFStdOut setForegroundColor: [OFColor lime]];

	[OFStdOut writeFormat: @"[OFSystemInfo] Page size: %zd\n",
	    [OFSystemInfo pageSize]];

	[OFStdOut writeFormat: @"[OFSystemInfo] Number of CPUs: %zd\n",
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
#endif

#ifdef OF_POWERPC
	[OFStdOut writeFormat: @"[OFSystemInfo] Supports AltiVec: %d\n",
	    [OFSystemInfo supportsAltiVec]];
#endif

#ifdef OF_SYSTEM_INFO_HAS_NETWORK_INTERFACES
	[OFStdOut writeString: @"[OFSystemInfo] Network interfaces: "];
	networkInterfaces = [OFSystemInfo networkInterfaces];
	for (OFString *name in networkInterfaces) {
		OFDictionary *interface = [networkInterfaces
		    objectForKey: name];
		OFData *etherAddr = [interface
		    objectForKey: OFNetworkInterfaceEthernetAddress];
		bool firstAddress = true;
		OFData *addrs;

		if (!firstInterface)
			[OFStdOut writeString: @"; "];
		firstInterface = false;

		[OFStdOut writeFormat: @"%@(", name];

		if (etherAddr.itemSize == 1 && etherAddr.count == 6) {
			const unsigned char *addr = etherAddr.items;
			[OFStdOut writeFormat:
			    @"MAC=%02X:%02X:%02X:%02X:%02X:%02X",
			    addr[0], addr[1], addr[2], addr[3], addr[4],
			    addr[5]];
			firstAddress = false;
		}

		addrs = [interface objectForKey: OFNetworkInterfaceAddresses];
		for (size_t i = 0; i < addrs.count; i++) {
			const OFSocketAddress *addr = [addrs itemAtIndex: i];
			OFString *string;

			@try {
				string = OFSocketAddressString(addr);
			} @catch (OFInvalidArgumentException *e) {
				continue;
			}

			if (!firstAddress)
				[OFStdOut writeString: @", "];
			firstAddress = nil;

			switch (addr->family) {
			case OFSocketAddressFamilyIPv4:
				[OFStdOut writeString: @"IPv4="];
				break;
			case OFSocketAddressFamilyIPv6:
				[OFStdOut writeString: @"IPv6="];
				break;
			case OFSocketAddressFamilyIPX:
				[OFStdOut writeString: @"IPX="];
				break;
			case OFSocketAddressFamilyAppleTalk:
				[OFStdOut writeString: @"AppleTalk="];
				break;
			default:
				[OFStdOut writeString: @"unknown="];
			}

			[OFStdOut writeString: string];
		}

		[OFStdOut writeString: @")"];
	}
	[OFStdOut writeString: @"\n"];
#endif

	objc_autoreleasePoolPop(pool);
}
@end







|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<





103
104
105
106
107
108
109
110
111
112





























































113
114
115
116
117
#endif

#ifdef OF_POWERPC
	[OFStdOut writeFormat: @"[OFSystemInfo] Supports AltiVec: %d\n",
	    [OFSystemInfo supportsAltiVec]];
#endif

#ifdef OF_HAVE_SOCKETS
	[OFStdOut writeFormat: @"[OFSystemInfo] Network interfaces: %@\n",
	    [[OFSystemInfo networkInterfaces] componentsJoinedByString: @", "]];





























































#endif

	objc_autoreleasePoolPop(pool);
}
@end