Overview
Comment: | Improve API for +[OFSystemInfo networkInterfaces] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ef038319288f5543b5266d09ccdcbaa0 |
User & Date: | js on 2023-06-04 15:33:55 |
Other Links: | manifest | tags |
Context
2023-06-05
| ||
00:50 | +[OFSystemInfo networkInterfaces]: Add IPv4s check-in: a15a0854be user: js tags: trunk | |
2023-06-04
| ||
15:33 | Improve API for +[OFSystemInfo networkInterfaces] check-in: ef03831928 user: js tags: trunk | |
2023-05-27
| ||
10:54 | GitHub Actions: Restore devkitPPC builds check-in: c294e5877d user: js tags: trunk | |
Changes
Modified src/OFSystemInfo.h from [c58919a56b] to [757e7e248c].
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFIRI; /** * @class OFSystemInfo OFSystemInfo.h ObjFW/OFSystemInfo.h * * @brief A class for querying information about the system. */ OF_SUBCLASSING_RESTRICTED @interface OFSystemInfo: OFObject | > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFIRI; #ifdef OF_HAVE_SOCKETS /** * @brief A dictionary describing a network interface, as returned by * @ref networkInterfaces. * * Keys are of type @ref OFNetworkInterfaceKey. */ typedef OFDictionary OF_GENERIC(OFString *, id) *OFNetworkInterface; /** * @brief A key of an @ref OFNetworkInterface. * * Possible values are: * * * @ref OFNetworkInterfaceIndex */ typedef OFConstantString *OFNetworkInterfaceKey; /** * @brief The index of a network interface. * * This maps to a @ref OFNumber. */ extern OFNetworkInterfaceKey OFNetworkInterfaceIndex; #endif /** * @class OFSystemInfo OFSystemInfo.h ObjFW/OFSystemInfo.h * * @brief A class for querying information about the system. */ OF_SUBCLASSING_RESTRICTED @interface OFSystemInfo: OFObject |
︙ | ︙ | |||
61 62 63 64 65 66 67 | @property (class, readonly, nonatomic) bool supportsAltiVec; # endif # ifdef OF_WINDOWS @property (class, readonly, nonatomic, getter=isWindowsNT) bool windowsNT; # endif # ifdef OF_HAVE_SOCKETS @property (class, readonly, nullable, nonatomic) | | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | @property (class, readonly, nonatomic) bool supportsAltiVec; # endif # ifdef OF_WINDOWS @property (class, readonly, nonatomic, getter=isWindowsNT) bool windowsNT; # endif # ifdef OF_HAVE_SOCKETS @property (class, readonly, nullable, nonatomic) OFDictionary OF_GENERIC(OFString *, OFNetworkInterface) *networkInterfaces; # endif #endif /** * @brief Returns the size of a page. * * @return The size of a page |
︙ | ︙ | |||
346 347 348 349 350 351 352 | #ifdef OF_HAVE_SOCKETS /** * @brief Returns the available (though not necessarily configured) network * interfaces. * * @return The available network interfaces */ | > | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | #ifdef OF_HAVE_SOCKETS /** * @brief Returns the available (though not necessarily configured) network * interfaces. * * @return The available network interfaces */ + (nullable OFDictionary OF_GENERIC(OFString *, OFNetworkInterface) *) networkInterfaces; #endif + (instancetype)alloc OF_UNAVAILABLE; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END |
Modified src/OFSystemInfo.m from [29fca6defb] to [8a22d63aae].
︙ | ︙ | |||
120 121 122 123 124 125 126 127 128 129 130 131 132 133 | typedef unsigned int NSSearchPathEnumerationState; extern NSSearchPathEnumerationState NSStartSearchPathEnumeration( NSSearchPathDirectory, NSSearchPathDomainMask); extern NSSearchPathEnumerationState NSGetNextSearchPathEnumeration( NSSearchPathEnumerationState, char *); #endif #if defined(OF_AMD64) || defined(OF_X86) struct X86Regs { uint32_t eax, ebx, ecx, edx; }; #endif | > > > > | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | typedef unsigned int NSSearchPathEnumerationState; extern NSSearchPathEnumerationState NSStartSearchPathEnumeration( NSSearchPathDirectory, NSSearchPathDomainMask); extern NSSearchPathEnumerationState NSGetNextSearchPathEnumeration( NSSearchPathEnumerationState, char *); #endif #ifdef OF_HAVE_SOCKETS OFNetworkInterfaceKey OFNetworkInterfaceIndex = @"OFNetworkInterfaceIndex"; #endif #if defined(OF_AMD64) || defined(OF_X86) struct X86Regs { uint32_t eax, ebx, ecx, edx; }; #endif |
︙ | ︙ | |||
835 836 837 838 839 840 841 | + (bool)isWindowsNT { return !(GetVersion() & 0x80000000); } #endif #ifdef OF_HAVE_SOCKETS | | | | | | > > > > > > > > | 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 | + (bool)isWindowsNT { return !(GetVersion() & 0x80000000); } #endif #ifdef OF_HAVE_SOCKETS + (OFDictionary OF_GENERIC(OFString *, OFNetworkInterface) *)networkInterfaces { # ifdef HAVE_IF_NAMEINDEX OFMutableDictionary *ret = [OFMutableDictionary dictionary]; void *pool = objc_autoreleasePoolPush(); OFStringEncoding encoding = [OFLocale encoding]; struct if_nameindex *nameindex = if_nameindex(); if (nameindex == NULL) { objc_autoreleasePoolPop(pool); return nil; } @try { for (size_t i = 0; nameindex[i].if_index != 0; i++) { OFString *name = [OFString stringWithCString: nameindex[i].if_name encoding: encoding]; OFNumber *index = [OFNumber numberWithUnsignedInt: nameindex[i].if_index]; OFDictionary *interface = [OFDictionary dictionaryWithObject: index forKey: OFNetworkInterfaceIndex]; [ret setObject: interface forKey: name]; } } @finally { if_freenameindex(nameindex); } [ret makeImmutable]; objc_autoreleasePoolPop(pool); |
︙ | ︙ |
Modified tests/OFSystemInfoTests.m from [bc94edf915] to [4c99d3ac50].
︙ | ︙ | |||
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", | > > > > | 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_HAVE_SOCKETS 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", |
︙ | ︙ | |||
104 105 106 107 108 109 110 | #ifdef OF_POWERPC [OFStdOut writeFormat: @"[OFSystemInfo] Supports AltiVec: %d\n", [OFSystemInfo supportsAltiVec]]; #endif #ifdef OF_HAVE_SOCKETS | > | > > > | > > > > > | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | #ifdef OF_POWERPC [OFStdOut writeFormat: @"[OFSystemInfo] Supports AltiVec: %d\n", [OFSystemInfo supportsAltiVec]]; #endif #ifdef OF_HAVE_SOCKETS networkInterfaces = [OFSystemInfo networkInterfaces]; [OFStdOut writeString: @"[OFSystemInfo] Network interfaces: "]; for (OFString *name in networkInterfaces) { if (!firstInterface) [OFStdOut writeString: @"; "]; firstInterface = false; [OFStdOut writeString: name]; } [OFStdOut writeString: @"\n"]; #endif objc_autoreleasePoolPop(pool); } @end |