From 7b2a26f5ade7740c41daf090053dc01edf16a8e9 Mon Sep 17 00:00:00 2001 From: Charles Forsyth Date: Sat, 10 Oct 2015 12:03:40 +0100 Subject: tidy up and simplify the eia port initialisation code, eliminating references to undefined values --- emu/MacOSX/deveia.c | 149 +++++++++++++++++++++------------------------------- 1 file changed, 59 insertions(+), 90 deletions(-) diff --git a/emu/MacOSX/deveia.c b/emu/MacOSX/deveia.c index bb7a01c6..c9c9b27f 100644 --- a/emu/MacOSX/deveia.c +++ b/emu/MacOSX/deveia.c @@ -22,6 +22,11 @@ #include #include +#include +#include + +#undef nil + #define B14400 14400 #define B28800 28800 #define B57600 57600 @@ -31,101 +36,12 @@ extern int vflag; -#define MAXDEV 8 +#define MAXDEV 16 static char *sysdev[MAXDEV]; -#include -#include - static void _buildsysdev(void); #define buildsysdev() _buildsysdev() /* for devfs-posix.c */ -static void -_buildsysdev(void) -{ - kern_return_t kernResult; - mach_port_t masterPort; - CFMutableDictionaryRef classesToMatch; - io_iterator_t serialPortIterator; - io_object_t serialDevice; - CFMutableArrayRef array; - CFIndex idx; - - kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort); - if (KERN_SUCCESS != kernResult) - { - printf("IOMasterPort returned %d\n", kernResult); - } else { - classesToMatch = IOServiceMatching(kIOSerialBSDServiceValue); - if (classesToMatch == NULL) - { - printf("IOServiceMatching returned a NULL dictionary.\n"); - } else { - CFDictionarySetValue(classesToMatch, - CFSTR(kIOSerialBSDTypeKey), - CFSTR(kIOSerialBSDAllTypes)); - } - - kernResult = IOServiceGetMatchingServices(masterPort, classesToMatch, &serialPortIterator); - if (KERN_SUCCESS != kernResult) - { - printf("IOServiceGetMatchingServices returned %d\n", kernResult); - } else { - array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); - - while ((serialDevice = IOIteratorNext(serialPortIterator))) { - CFTypeRef bsdPathAsCFString; - bsdPathAsCFString = IORegistryEntryCreateCFProperty(serialDevice, - CFSTR(kIOCalloutDeviceKey), - kCFAllocatorDefault, - 0); - if (bsdPathAsCFString) { - CFArrayAppendValue(array, bsdPathAsCFString); - } - - (void) IOObjectRelease(serialDevice); - } - - idx = CFArrayGetCount(array); - if (idx > 0) { - Boolean result; - char bsdPath[MAXPATHLEN]; - char *tmpsysdev[idx+1]; - CFIndex i; - - for (i=0; i