···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2015-2016 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef AUDIOHARDWAREIMPL_H
2121-#define AUDIOHARDWAREIMPL_H
2222-#include <CoreAudio/AudioHardware.h>
2323-#include <map>
2424-#include <mutex>
2525-#include "AudioHardwareStream.h"
2626-2727-class AudioHardwareImpl
2828-{
2929-public:
3030- AudioHardwareImpl();
3131- virtual ~AudioHardwareImpl();
3232-3333- virtual void show();
3434- virtual bool hasProperty(const AudioObjectPropertyAddress* address);
3535- virtual OSStatus getPropertyDataSize(const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize,
3636- const void* inQualifierData, UInt32* outDataSize);
3737-3838- virtual OSStatus isPropertySettable(const AudioObjectPropertyAddress* inAddress, Boolean* outIsSettable);
3939-4040- virtual OSStatus getPropertyData(const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize,
4141- const void* inQualifierData, UInt32* ioDataSize, void* outData);
4242-4343- virtual OSStatus setPropertyData(const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize,
4444- const void* inQualifierData, UInt32 inDataSize, const void* inData);
4545-4646- virtual OSStatus addPropertyListener(const AudioObjectPropertyAddress* inAddress,
4747- AudioObjectPropertyListenerProc inListener, void* inClientData);
4848-4949- virtual OSStatus removePropertyListener(const AudioObjectPropertyAddress* inAddress,
5050- AudioObjectPropertyListenerProc inListener, void* inClientData);
5151-5252- OSStatus createIOProcID(AudioDeviceIOProc inProc, void* inClientData,
5353- AudioDeviceIOProcID* outIOProcID);
5454- OSStatus destroyIOProcID(AudioDeviceIOProcID inIOProcID);
5555-5656- virtual OSStatus start(AudioDeviceIOProcID inProcID,
5757- AudioTimeStamp* ioRequestedStartTime, UInt32 inFlags);
5858- virtual OSStatus stop(AudioDeviceIOProcID inProcID);
5959-6060- virtual OSStatus getCurrentTime(AudioTimeStamp* outTime) = 0;
6161-6262- virtual OSStatus translateTime(const AudioTimeStamp* inTime,
6363- AudioTimeStamp* outTime) = 0;
6464-6565- virtual OSStatus getNearestStartTime(AudioTimeStamp* ioRequestedStartTime,
6666- UInt32 inFlags) = 0;
6767-protected:
6868- virtual AudioHardwareStream* createStream(AudioDeviceIOProcID procID) = 0;
6969-protected:
7070- std::mutex m_procMutex;
7171- std::map<AudioDeviceIOProcID, std::pair<AudioDeviceIOProc, void*>> m_proc;
7272- int m_nextProcId = 1;
7373-7474- std::map<AudioDeviceIOProcID, std::unique_ptr<AudioHardwareStream> m_streams;
7575-};
7676-7777-#endif /* AUDIOHARDWAREIMPL_H */
7878-11+include/CoreAudio/AudioHardwareImpl.h
+1-33
src/CoreAudio/AudioHardwareStream.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2015-2016 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef AUDIOHARDWARESTREAM_H
2121-#define AUDIOHARDWARESTREAM_H
2222-2323-class AudioHardwareStream
2424-{
2525-public:
2626- AudioHardwareStream();
2727- virtual ~AudioHardwareStream();
2828-private:
2929-3030-};
3131-3232-#endif /* AUDIOHARDWARESTREAM_H */
3333-11+include/CoreAudio/AudioHardwareStream.h
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2015-2016 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef AUDIOHARDWARESTREAM_H
2121+#define AUDIOHARDWARESTREAM_H
2222+2323+class AudioHardwareStream
2424+{
2525+public:
2626+ AudioHardwareStream();
2727+ virtual ~AudioHardwareStream();
2828+private:
2929+3030+};
3131+3232+#endif /* AUDIOHARDWARESTREAM_H */
3333+
···11-#ifndef COMPONENTSINTERNAL_H
22-#define COMPONENTSINTERNAL_H
33-44-class CarbonComponent
55-{
66-public:
77- virtual ~CarbonComponent() {}
88-};
99-1010-inline static UInt32 GetComponentType(Component comp)
1111-{
1212- long l = long(comp);
1313- return l & 0xffff0000;
1414-}
1515-1616-inline static UInt32 GetComponentIndex(Component comp)
1717-{
1818- long l = long(comp);
1919- return l & 0xffff;
2020-}
2121-2222-inline static Component CreateComponent(UInt32 type, UInt32 index)
2323-{
2424- long l = type & 0xffff0000;
2525- l |= (index & 0xffff);
2626- return (void*) l;
2727-}
2828-2929-enum
3030-{
3131- kComponentTypeAudioUnit = 'au\0\0'
3232-};
3333-3434-#endif
3535-11+include/CoreServices/ComponentsInternal.h
+1-85
src/CoreServices/CoreEndian.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2013 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef COREENDIAN_H
2121-#define COREENDIAN_H
2222-#include <MacTypes.h>
2323-#include <stdint.h>
2424-2525-#ifdef __cplusplus
2626-extern "C" {
2727-#endif
2828-2929-UInt16 Endian16_Swap(UInt16 value);
3030-UInt32 Endian32_Swap(UInt32 value);
3131-UInt64 Endian64_Swap(UInt64 value);
3232-3333-SInt16 EndianS16_BtoL(SInt16 value);
3434-SInt16 EndianS16_BtoN(SInt16 value);
3535-SInt16 EndianS16_LtoB(SInt16 value);
3636-SInt16 EndianS16_LtoN(SInt16 value);
3737-SInt16 EndianS16_NtoB(SInt16 value);
3838-SInt16 EndianS16_NtoL(SInt16 value);
3939-4040-SInt32 EndianS32_BtoL(SInt32 value);
4141-SInt32 EndianS32_BtoN(SInt32 value);
4242-SInt32 EndianS32_LtoB(SInt32 value);
4343-SInt32 EndianS32_LtoN(SInt32 value);
4444-SInt32 EndianS32_NtoB(SInt32 value);
4545-SInt32 EndianS32_NtoL(SInt32 value);
4646-4747-SInt64 EndianS64_BtoL(SInt64 value);
4848-SInt64 EndianS64_BtoN(SInt64 value);
4949-SInt64 EndianS64_LtoB(SInt64 value);
5050-SInt64 EndianS64_LtoN(SInt64 value);
5151-SInt64 EndianS64_NtoB(SInt64 value);
5252-SInt64 EndianS64_NtoL(SInt64 value);
5353-5454-UInt16 EndianU16_BtoL(UInt16 value);
5555-UInt16 EndianU16_BtoN(UInt16 value);
5656-UInt16 EndianU16_LtoB(UInt16 value);
5757-UInt16 EndianU16_LtoN(UInt16 value);
5858-UInt16 EndianU16_NtoB(UInt16 value);
5959-UInt16 EndianU16_NtoL(UInt16 value);
6060-6161-UInt32 EndianU32_BtoL(UInt32 value);
6262-UInt32 EndianU32_BtoN(UInt32 value);
6363-UInt32 EndianU32_LtoB(UInt32 value);
6464-UInt32 EndianU32_LtoN(UInt32 value);
6565-UInt32 EndianU32_NtoB(UInt32 value);
6666-UInt32 EndianU32_NtoL(UInt32 value);
6767-6868-UInt64 EndianU64_BtoL(UInt64 value);
6969-UInt64 EndianU64_BtoN(UInt64 value);
7070-UInt64 EndianU64_LtoB(UInt64 value);
7171-UInt64 EndianU64_LtoN(UInt64 value);
7272-UInt64 EndianU64_NtoB(UInt64 value);
7373-UInt64 EndianU64_NtoL(UInt64 value);
7474-7575-typedef OSStatus (*CEFlipper)(uint32_t dataDomain, uint32_t dataType, int16_t id, void* data, unsigned long length, Boolean isNative, void* opaque);
7676-7777-OSStatus CoreEndianFlipData(uint32_t dataDomain, uint32_t dataType, int16_t id, void* data, unsigned long length, Boolean isNative);
7878-OSStatus CoreEndianInstallFlipper(uint32_t dataDomain, uint32_t dataType, CEFlipper flipper, void* opaque);
7979-OSStatus CoreEndianGetFlipper(uint32_t dataDomain, uint32_t dataType, CEFlipper* flipper, void** opaque);
8080-8181-#ifdef __cplusplus
8282-}
8383-#endif
8484-8585-#endif
11+include/CoreServices/CoreEndian.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2012-2013 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-2121-#ifndef UTCUTILS_H
2222-#define UTCUTILS_H
2323-#include <stdint.h>
2424-#include <time.h>
2525-#include <CoreFoundation/CFDate.h>
2626-#include "MacErrors.h"
2727-2828-#define UNIX_OFFSET 2082844800ll // 1970 - 1904
2929-#define CF_OFFSET 3061152000ll // 2001 - 1904: "Seconds" is since 2001+
3030-3131-#pragma pack(2)
3232-struct UTCDateTime
3333-{
3434- uint16_t highSeconds;
3535- uint32_t lowSeconds;
3636- uint16_t fraction;
3737-};
3838-#pragma pack()
3939-4040-typedef struct UTCDateTime LocalDateTime;
4141-typedef struct UTCDateTime* UTCDateTimePtr;
4242-typedef struct UTCDateTime** UTCDateTimeHandle;
4343-typedef LocalDateTime* LocalDateTimePtr;
4444-typedef LocalDateTime** LocalDateTimeHandle;
4545-4646-#ifdef __cplusplus
4747-extern "C" {
4848-#endif
4949-5050-OSErr UCConvertUTCDateTimeToCFAbsoluteTime(const UTCDateTimePtr in, CFAbsoluteTime* out);
5151-OSErr UCConvertSecondsToCFAbsoluteTime(uint32_t seconds, CFAbsoluteTime* out);
5252-OSErr UCConvertLongDateTimeToCFAbsoluteTime(int64_t seconds, CFAbsoluteTime* out);
5353-OSErr UCConvertCFAbsoluteTimeToUTCDateTime(CFAbsoluteTime in, UTCDateTimePtr out);
5454-OSErr UCConvertCFAbsoluteTimeToSeconds(CFAbsoluteTime in, uint32_t* out);
5555-OSErr UCConvertCFAbsoluteTimeToLongDateTime(CFAbsoluteTime in, int64_t* out);
5656-5757-// Seconds since 1.1.1904
5858-void GetDateTime(unsigned long* secs);
5959-6060-#ifdef __cplusplus
6161-}
6262-6363-namespace Darling
6464-{
6565- UTCDateTime time_tToUTC(time_t t);
6666-}
6767-6868-#endif
6969-7070-#endif
7171-11+include/CoreServices/DateTimeUtils.h
+1-78
src/CoreServices/DriverServices.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2013 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef DRIVERSERVICES_H
2121-#define DRIVERSERVICES_H
2222-#include <MacTypes.h>
2323-#include <limits.h>
2424-2525-#ifdef __cplusplus
2626-extern "C" {
2727-#endif
2828-2929-typedef UnsignedWide Nanoseconds;
3030-3131-enum
3232-{
3333- durationMicrosecond = -1L,
3434- durationMillisecond = 1,
3535- durationSecond = 1000,
3636- durationMinute = 60*1000,
3737- durationHour = 60*60*1000,
3838- durationDay = 60*60*1000*24,
3939- durationNoWait = 0,
4040- durationForever = INT_MAX
4141-};
4242-4343-AbsoluteTime UpTime();
4444-4545-Nanoseconds AbsoluteToNanoseconds(AbsoluteTime absTime);
4646-4747-Duration AbsoluteToDuration(AbsoluteTime absTime);
4848-4949-AbsoluteTime NanosecondsToAbsolute(Nanoseconds ns);
5050-5151-AbsoluteTime DurationToAbsolute(Duration duration);
5252-5353-AbsoluteTime AddAbsoluteToAbsolute(AbsoluteTime time1, AbsoluteTime time2);
5454-5555-AbsoluteTime SubAbsoluteFromAbsolute(AbsoluteTime time1, AbsoluteTime time2);
5656-5757-AbsoluteTime AddNanosecondsToAbsolute(Nanoseconds ns, AbsoluteTime absTime);
5858-5959-AbsoluteTime AddDurationToAbsolute(Duration duration, AbsoluteTime absTime);
6060-6161-AbsoluteTime SubNanosecondsFromAbsolute(Nanoseconds ns, AbsoluteTime absTime);
6262-6363-AbsoluteTime SubDurationFromAbsolute(Duration duration, AbsoluteTime absTime);
6464-6565-Nanoseconds AbsoluteDeltaToNanoseconds(AbsoluteTime time1, AbsoluteTime time2);
6666-6767-Duration AbsoluteDeltaToDuration(AbsoluteTime time1, AbsoluteTime time2);
6868-6969-Nanoseconds DurationToNanoseconds(Duration duration);
7070-7171-Duration NanosecondsToDuration(Nanoseconds ns);
7272-7373-#ifdef __cplusplus
7474-}
7575-#endif
7676-7777-#endif
7878-11+include/CoreServices/DriverServices.h
+1-76
src/CoreServices/DriverSynchronization.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2013 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef DRIVERSYNCHRONIZATION_H
2121-#define DRIVERSYNCHRONIZATION_H
2222-2323-#include "MacTypes.h"
2424-2525-#ifdef __cplusplus
2626-extern "C" {
2727-#endif
2828-2929-Boolean CompareAndSwap(UInt32 old, UInt32 _new, UInt32* ptr);
3030-3131-Boolean TestAndClear(UInt32 bit, UInt8* ptr);
3232-3333-Boolean TestAndSet(UInt32 bit, UInt8* ptr) ;
3434-3535-SInt8 IncrementAtomic8(SInt8* ptr);
3636-3737-SInt8 DecrementAtomic8(SInt8* ptr);
3838-3939-SInt8 AddAtomic8(SInt32 val, SInt8* ptr);
4040-4141-UInt8 BitAndAtomic8(UInt32 val, UInt8* ptr);
4242-4343-UInt8 BitOrAtomic8(UInt32 val, UInt8* ptr);
4444-4545-UInt8 BitXorAtomic8(UInt32 val, UInt8* ptr);
4646-4747-SInt16 IncrementAtomic16(SInt16* ptr);
4848-4949-SInt16 DecrementAtomic16(SInt16* ptr);
5050-5151-SInt16 AddAtomic16(SInt32 val, SInt16* ptr);
5252-5353-UInt16 BitAndAtomic16(UInt32 val, UInt16* ptr);
5454-5555-UInt16 BitOrAtomic16(UInt32 val, UInt16* ptr);
5656-5757-UInt16 BitXorAtomic16(UInt32 val, UInt16* ptr);
5858-5959-SInt32 IncrementAtomic(SInt32* ptr);
6060-6161-SInt32 DecrementAtomic(SInt32* ptr);
6262-6363-SInt32 AddAtomic(SInt32 val, SInt32* ptr);
6464-6565-UInt32 BitAndAtomic(UInt32 val, UInt32* ptr);
6666-6767-UInt32 BitOrAtomic(UInt32 val, UInt32* ptr);
6868-6969-UInt32 BitXorAtomic(UInt32 val, UInt32* ptr);
7070-7171-#ifdef __cplusplus
7272-}
7373-#endif
7474-7575-#endif
7676-11+include/CoreServices/DriverSynchronization.h
+1-74
src/CoreServices/FixMath.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2012-2013 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef FIXMATH_H
2121-#define FIXMATH_H
2222-#include "MacTypes.h"
2323-#include <stdint.h>
2424-2525-#ifdef __cplusplus
2626-extern "C" {
2727-#endif
2828-2929-float FixedToFloat(Fixed f);
3030-Fixed FloatToFixed(float f);
3131-3232-Fract FloatToFract(float f);
3333-float FractToFloat(Fract f);
3434-3535-Fixed FixRatio(short n, short denominator);
3636-Fixed FixMul(Fixed a, Fixed b);
3737-short FixRound(Fixed f);
3838-Fract Fix2Frac(Fixed f);
3939-int32_t Fix2Long(Fixed f);
4040-Fixed Long2Fix(int32_t v);
4141-Fixed Frac2Fix(Fract f);
4242-4343-Fract FracMul(Fract x, Fract y);
4444-Fixed FixDiv(Fixed x, Fixed y);
4545-Fract FracDiv(Fract x, Fract y);
4646-Fract FracSqrt(Fract x);
4747-Fract FracSin(Fixed x);
4848-Fract FracCos(Fixed x);
4949-Fixed FixATan2(int32_t x, int32_t y);
5050-5151-double Frac2X(Fract f);
5252-double Fix2X(Fract f);
5353-Fixed X2Fix(double d);
5454-Fract X2Frac(double d);
5555-5656-short WideCompare(const wide* a, const wide* b);
5757-wide* WideAdd(wide* dst, const wide* val);
5858-wide* WideSubtract(wide* dst, const wide* val);
5959-wide* WideNegate(wide* val);
6060-wide* WideShift(wide* dst, int32_t shift); // rounds upwards
6161-uint32_t WideSquareRoot(const wide* val);
6262-wide* WideMultiply(int32_t a, int32_t b, wide* dst);
6363-int32_t WideDivide(const wide* divd, int32_t divs, int32_t* remainder);
6464-wide* WideWideDivide(wide* divd, int32_t divs, int32_t* remainder);
6565-wide* WideBitShift(wide* dst, int32_t shift);
6666-6767-UnsignedFixed UnsignedFixedMulDiv(UnsignedFixed a, UnsignedFixed mul, UnsignedFixed div);
6868-6969-#ifdef __cplusplus
7070-}
7171-#endif
7272-7373-#endif
7474-11+include/CoreServices/FixMath.h
+1-43
src/CoreServices/Gestalt.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2012-2013 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef GESTALT_H
2121-#define GESTALT_H
2222-2323-#define gestaltSystemVersion 'sysv'
2424-#define gestaltSystemVersionMajor 'sys1'
2525-#define gestaltSystemVersionMinor 'sys2'
2626-#define gestaltSystemVersionPatch 'sys3'
2727-2828-#define gestaltSysArchitecture 'sysa'
2929-#define gestaltPowerPC 2
3030-#define gestaltIntel 10
3131-3232-#ifdef __cplusplus
3333-extern "C" {
3434-#endif
3535-3636-OSStatus Gestalt(uint32_t type, int* value);
3737-3838-#ifdef __cplusplus
3939-}
4040-#endif
4141-4242-#endif
4343-11+include/CoreServices/Gestalt.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2012-2013 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef MACLOCALES_H
2121-#define MACLOCALES_H
2222-#include "MacErrors.h"
2323-#include <stdint.h>
2424-2525-typedef int16_t RegionCode;
2626-typedef int16_t LangCode;
2727-typedef int16_t Utf16Char;
2828-2929-typedef int LocaleRef;
3030-typedef uint32_t LocaleOperationClass;
3131-typedef uint32_t LocaleOperationVariant;
3232-3333-struct LocaleAndVariant
3434-{
3535- LocaleRef ref;
3636- LocaleOperationVariant variant;
3737-};
3838-3939-#define kLocaleLanguageMask 0x1
4040-#define kLocaleLanguageVariantMask 0x2
4141-#define kLocaleScriptMask 0x4
4242-#define kLocaleScriptVariantMask 0x8
4343-#define kLocaleRegionMask 0x10
4444-#define kLocaleRegionVariantMask 0x20
4545-#define kLocaleAllPartsMask 0x3f
4646-4747-#define kLocaleNameMask 0x1
4848-#define kLocaleOperationVariantNameMask 0x2
4949-#define kLocaleAndVariantNameMask (kLocaleNameMask|kLocaleOperationVariantNameMask)
5050-5151-#define kTextLanguageDontCare -128
5252-#define kTextScriptDontCare -128
5353-#define kTextRegionDontCare -128
5454-5555-#ifdef __cplusplus
5656-extern "C" {
5757-#endif
5858-5959-OSStatus LocaleRefFromLangOrRegionCode(LangCode langCode, RegionCode regionCode, LocaleRef* refOut);
6060-OSStatus LocaleRefFromLocaleString(const char* str, LocaleRef* refOut);
6161-OSStatus LocaleRefGetPartString(LocaleRef ref, uint32_t partMask, unsigned long maxStringLen, char* stringOut);
6262-OSStatus LocaleStringToLangAndRegionCodes(const char* name, LangCode* langCode, RegionCode* regionCode);
6363-OSStatus LocaleOperationCountLocales(LocaleOperationClass cls, unsigned long* count);
6464-OSStatus LocaleOperationGetLocales(LocaleOperationClass cls, unsigned long max, unsigned long* countOut, struct LocaleAndVariant* out);
6565-OSStatus LocaleGetName(LocaleRef ref, LocaleOperationVariant variant, uint32_t nameMask, LocaleRef refDisplay, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName);
6666-OSStatus LocaleCountNames(LocaleRef ref, LocaleOperationVariant variant, uint32_t nameMask, unsigned long* countOut);
6767-OSStatus LocaleGetIndName(LocaleRef ref, LocaleOperationVariant variant, uint32_t nameMask, unsigned long index, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName, LocaleRef* displayLocale);
6868-OSStatus LocaleGetRegionLanguageName(RegionCode regionCode, char name[256]);
6969-OSStatus LocaleOperationGetName(LocaleOperationClass cls, LocaleRef ref, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName);
7070-OSStatus LocaleOperationCountNames(LocaleOperationClass cls, unsigned long* count);
7171-OSStatus LocaleOperationGetIndName(LocaleOperationClass cls, unsigned long index, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName, LocaleRef* displayLocale);
7272-7373-#ifdef __cplusplus
7474-}
7575-#endif
7676-7777-#endif
7878-11+include/CoreServices/MacLocales.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2017 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef _TEXTCOMMON_H
2121-#define _TEXTCOMMON_H
2222-#include <MacTypes.h>
2323-2424-#ifdef __cplusplus
2525-extern "C" {
2626-#endif
2727-2828-typedef UInt8* TextPtr;
2929-typedef const UInt8* ConstTextPtr;
3030-3131-enum {
3232- kTextEncodingUnicodeDefault = 0x100
3333-};
3434-3535-enum {
3636- kTextEncodingDefaultVariant = 0
3737-};
3838-3939-enum {
4040- kTextEncodingDefaultFormat = 0,
4141- kUnicodeUTF16Format = 0,
4242- kUnicodeUTF7Format = 1,
4343- kUnicodeUTF8Format = 2,
4444- kUnicodeUTF32Format = 3,
4545- kUnicodeUTF16BEFormat = 4,
4646- kUnicodeUTF16LEFormat = 5,
4747- kUnicodeUTF32BEFormat = 6,
4848- kUnicodeUTF32LEFormat = 7,
4949- kUnicodeSCSUFormat = 8,
5050- kUnicode16BitFormat = 0,
5151- kUnicode32BitFormat = 3,
5252-};
5353-5454-enum {
5555- kUnicodeNoSubset = 0,
5656- kUnicodeNormalizationFormD = 5,
5757- kUnicodeNormalizationFormC = 3,
5858- kUnicodeCanonicalCompVariant = kUnicodeNormalizationFormC,
5959- kUnicodeHFSPlusDecompVariant = 8,
6060- kUnicodeHFSPlusCompVariant = 9,
6161-};
6262-6363-typedef UInt32 TextEncoding;
6464-typedef UInt32 TextEncodingBase;
6565-typedef UInt32 TextEncodingFormat;
6666-typedef UInt32 TextEncodingVariant;
6767-6868-TextEncoding CreateTextEncoding(TextEncodingBase encodingBase, TextEncodingVariant encodingVariant, TextEncodingFormat encodingFormat);
6969-7070-#ifdef __cplusplus
7171-}
7272-#endif
7373-7474-#endif
7575-11+include/CoreServices/TextCommon.h
+1-44
src/CoreServices/TextEncodingConverter.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2017 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef _TEXTENCODINGCONVERTER_H
2121-#define _TEXTENCODINGCONVERTER_H
2222-#include <MacTypes.h>
2323-#include "TextCommon.h"
2424-2525-#ifdef __cplusplus
2626-extern "C" {
2727-#endif
2828-2929-typedef struct OpaqueTECObjectRef* TECObjectRef;
3030-3131-OSStatus TECCreateConverter(TECObjectRef *newEncodingConverter, TextEncoding inputEncoding, TextEncoding outputEncoding);
3232-3333-OSStatus TECConvertText(TECObjectRef encodingConverter, ConstTextPtr inputBuffer, ByteCount inputBufferLength, ByteCount *actualInputLength, TextPtr outputBuffer, ByteCount outputBufferLength, ByteCount *actualOutputLength);
3434-3535-OSStatus TECFlushText(TECObjectRef encodingConverter, TextPtr outputBuffer, ByteCount outputBufferLength, ByteCount *actualOutputLength);
3636-3737-OSStatus TECDisposeConverter(TECObjectRef newEncodingConverter);
3838-3939-#ifdef __cplusplus
4040-}
4141-#endif
4242-4343-#endif
4444-11+include/CoreServices/TextEncodingConverter.h
+1-31
src/CoreServices/TextUtils.h
···11-#ifndef TEXTUTILS_H
22-#define TEXTUTILS_H
33-#include "MacTypes.h"
44-55-#ifdef __cplusplus
66-extern "C" {
77-#endif
88-99-// There are many functions missing, but will be added as-needed.
1010-// There is no point in spending time implementing all this ancient stuff.
1111-1212-StringHandle NewString(const Str255 str);
1313-void SetString(StringHandle handle, const Str255 str);
1414-1515-void UpperString(Str255 str, Boolean diac);
1616-void upperstring(char* str, Boolean diac);
1717-1818-void c2pstrcpy(Str255 dst, const char* src);
1919-void p2cstrcpy(char* dst, const Str255 src);
2020-void CopyPascalStringToC(const Str255 src, char* dst);
2121-void CopyCStringToPascal(const char* src, Str255 dst);
2222-StringPtr c2pstr(char* str);
2323-StringPtr C2PStr(Ptr str);
2424-char* p2cstr(StringPtr str);
2525-Ptr P2CStr(StringPtr str);
2626-2727-#ifdef __cplusplus
2828-}
2929-#endif
3030-3131-#endif
11+include/CoreServices/TextUtils.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2012-2013 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef TOOLUTILS_H
2121-#define TOOLUTILS_H
2222-2323-#ifdef __cplusplus
2424-extern "C" {
2525-#endif
2626-2727-int BitTst(const void* bytePtr, long bitNum);
2828-void BitSet(void* bytePtr, long bitNum);
2929-void BitClr(void* bytePtr, long bitNum);
3030-long BitAnd(long v1, long v2);
3131-long BitXor(long v1, long v2);
3232-long BitNot(long v1);
3333-long BitShift(long value, short count);
3434-3535-#ifdef __cplusplus
3636-}
3737-#endif
3838-3939-#endif
4040-11+include/CoreServices/ToolUtils.h
···11-/*
22-This file is part of Darling.
33-44-Copyright (C) 2013 Lubos Dolezel
55-66-Darling is free software: you can redistribute it and/or modify
77-it under the terms of the GNU General Public License as published by
88-the Free Software Foundation, either version 3 of the License, or
99-(at your option) any later version.
1010-1111-Darling is distributed in the hope that it will be useful,
1212-but WITHOUT ANY WARRANTY; without even the implied warranty of
1313-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414-GNU General Public License for more details.
1515-1616-You should have received a copy of the GNU General Public License
1717-along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818-*/
1919-2020-#ifndef UNICODEUTILITIES_H
2121-#define UNICODEUTILITIES_H
2222-#include "MacTypes.h"
2323-#include "MacLocales.h"
2424-#include <stdint.h>
2525-2626-#ifdef __cplusplus
2727-extern "C" {
2828-#endif
2929-3030-typedef void* CollatorRef;
3131-enum //: uint32_t
3232-{
3333- kUCCollateComposeInsensitiveMask = 0x2,
3434- kUCCollateWidthInsensitiveMask = 0x4,
3535- kUCCollateCaseInsensitiveMask = 0x8,
3636- kUCCollateDiacritInsensitiveMask = 0x10,
3737- kUCCollatePunctuationSignificantMask = 0x8000,
3838- kUCCollateDigitsOverrideMask = 0x10000,
3939- kUCCollateDigitsAsNumberMask = 0x20000
4040-};
4141-4242-4343-OSStatus UCCreateCollator(LocaleRef locale, LocaleOperationVariant opVariant, uint32_t options, CollatorRef* collator);
4444-4545-OSStatus UCGetCollationKey(CollatorRef collator, const UniChar * text, unsigned long textlen, unsigned long maxKeySize, unsigned long* actualKeySize, uint32_t* collationKey);
4646-4747-OSStatus UCCompareCollationKeys(const uint32_t* key1, unsigned long key1len, const uint32_t* key2, unsigned long key2len, Boolean* equiv, int32_t* order);
4848-4949-OSStatus UCCompareText(CollatorRef collator, const UniChar* text1, unsigned long text1len, const UniChar* text2, unsigned long text2len, Boolean* equiv, int32_t* order);
5050-5151-OSStatus UCDisposeCollator(CollatorRef* collator);
5252-5353-OSStatus UCCompareTextDefault(uint32_t options, const UniChar* text1, unsigned long text1len, const UniChar* text2, unsigned long text2len, Boolean* equiv, int32_t* order);
5454-5555-OSStatus UCCompareTextNoLocale(uint32_t options, const UniChar* text1, unsigned long text1len, const UniChar* text2, unsigned long text2len, Boolean* equiv, int32_t* order);
5656-5757-#ifdef __cplusplus
5858-}
5959-#endif
6060-6161-#endif
11+include/CoreServices/UnicodeUtilities.h
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef COREENDIAN_H
2121+#define COREENDIAN_H
2222+#include <MacTypes.h>
2323+#include <stdint.h>
2424+2525+#ifdef __cplusplus
2626+extern "C" {
2727+#endif
2828+2929+UInt16 Endian16_Swap(UInt16 value);
3030+UInt32 Endian32_Swap(UInt32 value);
3131+UInt64 Endian64_Swap(UInt64 value);
3232+3333+SInt16 EndianS16_BtoL(SInt16 value);
3434+SInt16 EndianS16_BtoN(SInt16 value);
3535+SInt16 EndianS16_LtoB(SInt16 value);
3636+SInt16 EndianS16_LtoN(SInt16 value);
3737+SInt16 EndianS16_NtoB(SInt16 value);
3838+SInt16 EndianS16_NtoL(SInt16 value);
3939+4040+SInt32 EndianS32_BtoL(SInt32 value);
4141+SInt32 EndianS32_BtoN(SInt32 value);
4242+SInt32 EndianS32_LtoB(SInt32 value);
4343+SInt32 EndianS32_LtoN(SInt32 value);
4444+SInt32 EndianS32_NtoB(SInt32 value);
4545+SInt32 EndianS32_NtoL(SInt32 value);
4646+4747+SInt64 EndianS64_BtoL(SInt64 value);
4848+SInt64 EndianS64_BtoN(SInt64 value);
4949+SInt64 EndianS64_LtoB(SInt64 value);
5050+SInt64 EndianS64_LtoN(SInt64 value);
5151+SInt64 EndianS64_NtoB(SInt64 value);
5252+SInt64 EndianS64_NtoL(SInt64 value);
5353+5454+UInt16 EndianU16_BtoL(UInt16 value);
5555+UInt16 EndianU16_BtoN(UInt16 value);
5656+UInt16 EndianU16_LtoB(UInt16 value);
5757+UInt16 EndianU16_LtoN(UInt16 value);
5858+UInt16 EndianU16_NtoB(UInt16 value);
5959+UInt16 EndianU16_NtoL(UInt16 value);
6060+6161+UInt32 EndianU32_BtoL(UInt32 value);
6262+UInt32 EndianU32_BtoN(UInt32 value);
6363+UInt32 EndianU32_LtoB(UInt32 value);
6464+UInt32 EndianU32_LtoN(UInt32 value);
6565+UInt32 EndianU32_NtoB(UInt32 value);
6666+UInt32 EndianU32_NtoL(UInt32 value);
6767+6868+UInt64 EndianU64_BtoL(UInt64 value);
6969+UInt64 EndianU64_BtoN(UInt64 value);
7070+UInt64 EndianU64_LtoB(UInt64 value);
7171+UInt64 EndianU64_LtoN(UInt64 value);
7272+UInt64 EndianU64_NtoB(UInt64 value);
7373+UInt64 EndianU64_NtoL(UInt64 value);
7474+7575+typedef OSStatus (*CEFlipper)(uint32_t dataDomain, uint32_t dataType, int16_t id, void* data, unsigned long length, Boolean isNative, void* opaque);
7676+7777+OSStatus CoreEndianFlipData(uint32_t dataDomain, uint32_t dataType, int16_t id, void* data, unsigned long length, Boolean isNative);
7878+OSStatus CoreEndianInstallFlipper(uint32_t dataDomain, uint32_t dataType, CEFlipper flipper, void* opaque);
7979+OSStatus CoreEndianGetFlipper(uint32_t dataDomain, uint32_t dataType, CEFlipper* flipper, void** opaque);
8080+8181+#ifdef __cplusplus
8282+}
8383+#endif
8484+8585+#endif
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2012-2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+2121+#ifndef UTCUTILS_H
2222+#define UTCUTILS_H
2323+#include <stdint.h>
2424+#include <time.h>
2525+#include <CoreFoundation/CFDate.h>
2626+#include "MacErrors.h"
2727+2828+#define UNIX_OFFSET 2082844800ll // 1970 - 1904
2929+#define CF_OFFSET 3061152000ll // 2001 - 1904: "Seconds" is since 2001+
3030+3131+#pragma pack(2)
3232+struct UTCDateTime
3333+{
3434+ uint16_t highSeconds;
3535+ uint32_t lowSeconds;
3636+ uint16_t fraction;
3737+};
3838+#pragma pack()
3939+4040+typedef struct UTCDateTime LocalDateTime;
4141+typedef struct UTCDateTime* UTCDateTimePtr;
4242+typedef struct UTCDateTime** UTCDateTimeHandle;
4343+typedef LocalDateTime* LocalDateTimePtr;
4444+typedef LocalDateTime** LocalDateTimeHandle;
4545+4646+#ifdef __cplusplus
4747+extern "C" {
4848+#endif
4949+5050+OSErr UCConvertUTCDateTimeToCFAbsoluteTime(const UTCDateTimePtr in, CFAbsoluteTime* out);
5151+OSErr UCConvertSecondsToCFAbsoluteTime(uint32_t seconds, CFAbsoluteTime* out);
5252+OSErr UCConvertLongDateTimeToCFAbsoluteTime(int64_t seconds, CFAbsoluteTime* out);
5353+OSErr UCConvertCFAbsoluteTimeToUTCDateTime(CFAbsoluteTime in, UTCDateTimePtr out);
5454+OSErr UCConvertCFAbsoluteTimeToSeconds(CFAbsoluteTime in, uint32_t* out);
5555+OSErr UCConvertCFAbsoluteTimeToLongDateTime(CFAbsoluteTime in, int64_t* out);
5656+5757+// Seconds since 1.1.1904
5858+void GetDateTime(unsigned long* secs);
5959+6060+#ifdef __cplusplus
6161+}
6262+6363+namespace Darling
6464+{
6565+ UTCDateTime time_tToUTC(time_t t);
6666+}
6767+6868+#endif
6969+7070+#endif
7171+
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef DRIVERSERVICES_H
2121+#define DRIVERSERVICES_H
2222+#include <MacTypes.h>
2323+#include <limits.h>
2424+2525+#ifdef __cplusplus
2626+extern "C" {
2727+#endif
2828+2929+typedef UnsignedWide Nanoseconds;
3030+3131+enum
3232+{
3333+ durationMicrosecond = -1L,
3434+ durationMillisecond = 1,
3535+ durationSecond = 1000,
3636+ durationMinute = 60*1000,
3737+ durationHour = 60*60*1000,
3838+ durationDay = 60*60*1000*24,
3939+ durationNoWait = 0,
4040+ durationForever = INT_MAX
4141+};
4242+4343+AbsoluteTime UpTime();
4444+4545+Nanoseconds AbsoluteToNanoseconds(AbsoluteTime absTime);
4646+4747+Duration AbsoluteToDuration(AbsoluteTime absTime);
4848+4949+AbsoluteTime NanosecondsToAbsolute(Nanoseconds ns);
5050+5151+AbsoluteTime DurationToAbsolute(Duration duration);
5252+5353+AbsoluteTime AddAbsoluteToAbsolute(AbsoluteTime time1, AbsoluteTime time2);
5454+5555+AbsoluteTime SubAbsoluteFromAbsolute(AbsoluteTime time1, AbsoluteTime time2);
5656+5757+AbsoluteTime AddNanosecondsToAbsolute(Nanoseconds ns, AbsoluteTime absTime);
5858+5959+AbsoluteTime AddDurationToAbsolute(Duration duration, AbsoluteTime absTime);
6060+6161+AbsoluteTime SubNanosecondsFromAbsolute(Nanoseconds ns, AbsoluteTime absTime);
6262+6363+AbsoluteTime SubDurationFromAbsolute(Duration duration, AbsoluteTime absTime);
6464+6565+Nanoseconds AbsoluteDeltaToNanoseconds(AbsoluteTime time1, AbsoluteTime time2);
6666+6767+Duration AbsoluteDeltaToDuration(AbsoluteTime time1, AbsoluteTime time2);
6868+6969+Nanoseconds DurationToNanoseconds(Duration duration);
7070+7171+Duration NanosecondsToDuration(Nanoseconds ns);
7272+7373+#ifdef __cplusplus
7474+}
7575+#endif
7676+7777+#endif
7878+
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef DRIVERSYNCHRONIZATION_H
2121+#define DRIVERSYNCHRONIZATION_H
2222+2323+#include "MacTypes.h"
2424+2525+#ifdef __cplusplus
2626+extern "C" {
2727+#endif
2828+2929+Boolean CompareAndSwap(UInt32 old, UInt32 _new, UInt32* ptr);
3030+3131+Boolean TestAndClear(UInt32 bit, UInt8* ptr);
3232+3333+Boolean TestAndSet(UInt32 bit, UInt8* ptr) ;
3434+3535+SInt8 IncrementAtomic8(SInt8* ptr);
3636+3737+SInt8 DecrementAtomic8(SInt8* ptr);
3838+3939+SInt8 AddAtomic8(SInt32 val, SInt8* ptr);
4040+4141+UInt8 BitAndAtomic8(UInt32 val, UInt8* ptr);
4242+4343+UInt8 BitOrAtomic8(UInt32 val, UInt8* ptr);
4444+4545+UInt8 BitXorAtomic8(UInt32 val, UInt8* ptr);
4646+4747+SInt16 IncrementAtomic16(SInt16* ptr);
4848+4949+SInt16 DecrementAtomic16(SInt16* ptr);
5050+5151+SInt16 AddAtomic16(SInt32 val, SInt16* ptr);
5252+5353+UInt16 BitAndAtomic16(UInt32 val, UInt16* ptr);
5454+5555+UInt16 BitOrAtomic16(UInt32 val, UInt16* ptr);
5656+5757+UInt16 BitXorAtomic16(UInt32 val, UInt16* ptr);
5858+5959+SInt32 IncrementAtomic(SInt32* ptr);
6060+6161+SInt32 DecrementAtomic(SInt32* ptr);
6262+6363+SInt32 AddAtomic(SInt32 val, SInt32* ptr);
6464+6565+UInt32 BitAndAtomic(UInt32 val, UInt32* ptr);
6666+6767+UInt32 BitOrAtomic(UInt32 val, UInt32* ptr);
6868+6969+UInt32 BitXorAtomic(UInt32 val, UInt32* ptr);
7070+7171+#ifdef __cplusplus
7272+}
7373+#endif
7474+7575+#endif
7676+
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2012-2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+2121+#ifndef FILEMANAGER_H
2222+#define FILEMANAGER_H
2323+#include <stdint.h>
2424+#include <dirent.h>
2525+#include "MacErrors.h"
2626+#include "DateTimeUtils.h"
2727+#include "MacTypes.h"
2828+#include <CoreFoundation/CFURL.h>
2929+3030+#ifdef __cplusplus
3131+extern "C" {
3232+#endif
3333+3434+#define FSRef_MAX_DEPTH (80 / sizeof(ino_t))
3535+3636+struct FSRef
3737+{
3838+ union
3939+ {
4040+ uint8_t hidden[80];
4141+4242+ // Inode numbers leading to the file in the directory structure
4343+ //
4444+ // EXAMPLES:
4545+ // All zeroes: /
4646+ // sequence 1,2,0: [dir with inode 1]/[dir or file with inode 2]
4747+ ino_t inodes[FSRef_MAX_DEPTH];
4848+ };
4949+};
5050+typedef struct FSRef* FSRefPtr;
5151+typedef struct FSRef FSRef;
5252+5353+struct HFSUniStr255
5454+{
5555+ uint16_t length;
5656+ uint16_t unicode[255];
5757+};
5858+struct FSSpec;
5959+6060+typedef struct FSSpec* FSSpecPtr;
6161+6262+struct FSPermissionInfo
6363+{
6464+ uint32_t userID, groupID; // uid, gid
6565+ uint8_t reserved1;
6666+ uint8_t userAccess; // mode for the current user
6767+ uint16_t mode; // mode
6868+ uint32_t reserved2;
6969+};
7070+7171+struct FSCatalogInfo
7272+{
7373+ uint16_t nodeFlags;
7474+ int16_t volume;
7575+ uint32_t parentDirID;
7676+ uint32_t nodeID;
7777+ uint8_t sharingFlags;
7878+ uint8_t userPrivileges;
7979+ uint8_t reserved1;
8080+ uint8_t reserved2;
8181+ struct UTCDateTime createDate;
8282+ struct UTCDateTime contentModDate;
8383+ struct UTCDateTime attributeModDate;
8484+ struct UTCDateTime accessDate;
8585+ struct UTCDateTime backupDate;
8686+8787+ union
8888+ {
8989+ uint32_t permissions[4];
9090+ struct FSPermissionInfo fsPermissionInfo;
9191+ };
9292+9393+ uint8_t finderInfo[16];
9494+ uint8_t extFinderInfo[16];
9595+ uint64_t dataLogicalSize;
9696+ uint64_t dataPhysicalSize;
9797+ uint64_t rsrcLogicalSize;
9898+ uint64_t rsrcPhysicalSize;
9999+ uint32_t valence; // file count within a directory
100100+ uint32_t textEncodingHint;
101101+};
102102+103103+typedef void* IOCompletionUPP;
104104+typedef void* QElemPtr;
105105+typedef uint16_t FSAllocationFlags;
106106+typedef uint32_t FSCatalogInfoBitmap;
107107+typedef unsigned long UniCharCount;
108108+typedef UInt32 TextEncoding;
109109+110110+struct FSRefParam
111111+{
112112+ QElemPtr qLink;
113113+ short qType;
114114+ short ioTrap;
115115+ Ptr ioCmdAddr;
116116+ IOCompletionUPP ioCompletion;
117117+ volatile OSErr ioResult;
118118+ const Str255* ioNamePtr;
119119+ short ioVRefNum;
120120+ SInt16 reserved1;
121121+ UInt8 reserved2;
122122+ UInt8 reserved3;
123123+ const FSRefPtr ref;
124124+ FSCatalogInfoBitmap whichInfo;
125125+ struct FSCatalogInfo* catInfo;
126126+ UniCharCount nameLength;
127127+ const UniChar* name;
128128+ long ioDirID;
129129+ FSSpecPtr spec;
130130+ FSRefPtr parentRef;
131131+ FSRefPtr newRef;
132132+ TextEncoding textEncodingHint;
133133+ struct HFSUniStr255* outName;
134134+};
135135+136136+struct CatPositionRec
137137+{
138138+ long initialize;
139139+ short priv[6];
140140+};
141141+142142+struct FSForkIOParam
143143+{
144144+ QElemPtr qLink;
145145+ short qType;
146146+ short ioTrap;
147147+ Ptr ioCmdAddr;
148148+ IOCompletionUPP ioCompletion;
149149+ volatile OSErr ioResult;
150150+ void * reserved1;
151151+ SInt16 reserved2;
152152+ SInt16 forkRefNum;
153153+ UInt8 reserved3;
154154+ SInt8 permissions;
155155+ const FSRefPtr ref;
156156+ Ptr buffer;
157157+ UInt32 requestCount;
158158+ UInt32 actualCount;
159159+ UInt16 positionMode;
160160+ SInt64 positionOffset;
161161+ FSAllocationFlags allocationFlags;
162162+ UInt64 allocationAmount;
163163+ UniCharCount forkNameLength;
164164+ const UniChar * forkName;
165165+ struct CatPositionRec forkIterator;
166166+ struct HFSUniStr255* outForkName;
167167+};
168168+169169+enum
170170+{
171171+ kFSPathMakeRefDefaultOptions = 0,
172172+ kFSPathMakeRefDoNotFollowLeafSymlink = 1
173173+};
174174+175175+enum
176176+{
177177+ kFSCatInfoNone = 0x0,
178178+ kFSCatInfoTextEncoding = 0x1,
179179+ kFSCatInfoNodeFlags = 0x2,
180180+ kFSCatInfoVolume = 0x4,
181181+ kFSCatInfoParentDirID = 0x8,
182182+ kFSCatInfoNodeID = 0x10,
183183+ kFSCatInfoCreateDate = 0x20,
184184+ kFSCatInfoContentMod = 0x40,
185185+ kFSCatInfoAttrMod = 0x80,
186186+ kFSCatInfoAccessDate = 0x100,
187187+ kFSCatInfoBackupDate = 0x200,
188188+ kFSCatInfoPermissions = 0x400,
189189+ kFSCatInfoFinderInfo = 0x800,
190190+ kFSCatInfoFinderXInfo = 0x1000,
191191+ kFSCatInfoValence = 0x2000,
192192+ kFSCatInfoDataSizes = 0x4000,
193193+ kFSCatInfoRsrcSizes = 0x8000,
194194+ kFSCatInfoSharingFlags = 0x10000,
195195+ kFSCatInfoUserPrivs = 0x20000,
196196+ kFSCatInfoUserAccess = 0x80000,
197197+ kFSCatInfoSetOwnership = 0x100000
198198+};
199199+200200+enum
201201+{
202202+ kSystemFolderType = 'macs',
203203+ kDesktopFolderType = 'desk',
204204+ kSystemDesktopFolderType = 'sdsk',
205205+ kTrashFolderType = 'trsh',
206206+ kSystemTrashFolderType = 'strs',
207207+ kWhereToEmptyTrashFolderType = 'empt',
208208+ kPrintMonitorDocsFolderType = 'prnt',
209209+ kStartupFolderType = 'strt',
210210+ kShutdownFolderType = 'shdf',
211211+ kAppleMenuFolderType = 'amnu',
212212+ kControlPanelFolderType = 'ctrl',
213213+ kSystemControlPanelFolderType = 'sctl',
214214+ kExtensionFolderType = 'extn',
215215+ kFontsFolderType = 'font',
216216+ kPreferencesFolderType = 'pref',
217217+ kSystemPreferencesFolderType = 'sprf',
218218+ kTemporaryFolderType = 'temp'
219219+};
220220+221221+OSStatus FSPathMakeRef(const uint8_t* path, struct FSRef* fsref, Boolean* isDirectory);
222222+OSStatus FSPathMakeRefWithOptions(const uint8_t* path, long options, struct FSRef* fsref, Boolean* isDirectory);
223223+OSStatus FSRefMakePath(const struct FSRef* fsref, uint8_t* path, uint32_t maxSize);
224224+Boolean CFURLGetFSRef(CFURLRef urlref, struct FSRef* fsref); // in CF
225225+CFURLRef CFURLCreateFromFSRef(CFAllocatorRef alloc, struct FSRef* location); // --> in CF
226226+OSStatus FSFindFolder(long vRefNum, OSType folderType, Boolean createFolder, struct FSRef* location);
227227+228228+OSStatus FSGetCatalogInfo(const FSRefPtr ref, uint32_t infoBits, struct FSCatalogInfo* infoOut, struct HFSUniStr255* nameOut, FSSpecPtr fsspec, FSRefPtr parentDir);
229229+230230+OSErr PBCreateDirectoryUnicodeSync(struct FSRefParam* paramBlock);
231231+OSErr PBCreateFileUnicodeSync(struct FSRefParam* paramBlock);
232232+OSErr PBGetCatalogInfoSync(struct FSRefParam *paramBlock);
233233+OSErr PBMakeFSRefUnicodeSync(struct FSRefParam *paramBlock);
234234+OSErr PBOpenForkSync(struct FSForkIOParam *paramBlock);
235235+OSErr PBReadForkSync(struct FSForkIOParam *paramBlock);
236236+OSErr PBWriteForkSync(struct FSForkIOParam *paramBlock);
237237+OSErr PBIterateForksSync(struct FSForkIOParam *paramBlock);
238238+OSErr PBCloseForkSync(struct FSForkIOParam *paramBlock);
239239+240240+#ifdef __cplusplus
241241+}
242242+#endif
243243+244244+#endif
245245+
+74
src/CoreServices/include/CoreServices/FixMath.h
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2012-2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef FIXMATH_H
2121+#define FIXMATH_H
2222+#include "MacTypes.h"
2323+#include <stdint.h>
2424+2525+#ifdef __cplusplus
2626+extern "C" {
2727+#endif
2828+2929+float FixedToFloat(Fixed f);
3030+Fixed FloatToFixed(float f);
3131+3232+Fract FloatToFract(float f);
3333+float FractToFloat(Fract f);
3434+3535+Fixed FixRatio(short n, short denominator);
3636+Fixed FixMul(Fixed a, Fixed b);
3737+short FixRound(Fixed f);
3838+Fract Fix2Frac(Fixed f);
3939+int32_t Fix2Long(Fixed f);
4040+Fixed Long2Fix(int32_t v);
4141+Fixed Frac2Fix(Fract f);
4242+4343+Fract FracMul(Fract x, Fract y);
4444+Fixed FixDiv(Fixed x, Fixed y);
4545+Fract FracDiv(Fract x, Fract y);
4646+Fract FracSqrt(Fract x);
4747+Fract FracSin(Fixed x);
4848+Fract FracCos(Fixed x);
4949+Fixed FixATan2(int32_t x, int32_t y);
5050+5151+double Frac2X(Fract f);
5252+double Fix2X(Fract f);
5353+Fixed X2Fix(double d);
5454+Fract X2Frac(double d);
5555+5656+short WideCompare(const wide* a, const wide* b);
5757+wide* WideAdd(wide* dst, const wide* val);
5858+wide* WideSubtract(wide* dst, const wide* val);
5959+wide* WideNegate(wide* val);
6060+wide* WideShift(wide* dst, int32_t shift); // rounds upwards
6161+uint32_t WideSquareRoot(const wide* val);
6262+wide* WideMultiply(int32_t a, int32_t b, wide* dst);
6363+int32_t WideDivide(const wide* divd, int32_t divs, int32_t* remainder);
6464+wide* WideWideDivide(wide* divd, int32_t divs, int32_t* remainder);
6565+wide* WideBitShift(wide* dst, int32_t shift);
6666+6767+UnsignedFixed UnsignedFixedMulDiv(UnsignedFixed a, UnsignedFixed mul, UnsignedFixed div);
6868+6969+#ifdef __cplusplus
7070+}
7171+#endif
7272+7373+#endif
7474+
+43
src/CoreServices/include/CoreServices/Gestalt.h
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2012-2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef GESTALT_H
2121+#define GESTALT_H
2222+2323+#define gestaltSystemVersion 'sysv'
2424+#define gestaltSystemVersionMajor 'sys1'
2525+#define gestaltSystemVersionMinor 'sys2'
2626+#define gestaltSystemVersionPatch 'sys3'
2727+2828+#define gestaltSysArchitecture 'sysa'
2929+#define gestaltPowerPC 2
3030+#define gestaltIntel 10
3131+3232+#ifdef __cplusplus
3333+extern "C" {
3434+#endif
3535+3636+OSStatus Gestalt(uint32_t type, int* value);
3737+3838+#ifdef __cplusplus
3939+}
4040+#endif
4141+4242+#endif
4343+
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2012-2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef MACLOCALES_H
2121+#define MACLOCALES_H
2222+#include "MacErrors.h"
2323+#include <stdint.h>
2424+2525+typedef int16_t RegionCode;
2626+typedef int16_t LangCode;
2727+typedef int16_t Utf16Char;
2828+2929+typedef int LocaleRef;
3030+typedef uint32_t LocaleOperationClass;
3131+typedef uint32_t LocaleOperationVariant;
3232+3333+struct LocaleAndVariant
3434+{
3535+ LocaleRef ref;
3636+ LocaleOperationVariant variant;
3737+};
3838+3939+#define kLocaleLanguageMask 0x1
4040+#define kLocaleLanguageVariantMask 0x2
4141+#define kLocaleScriptMask 0x4
4242+#define kLocaleScriptVariantMask 0x8
4343+#define kLocaleRegionMask 0x10
4444+#define kLocaleRegionVariantMask 0x20
4545+#define kLocaleAllPartsMask 0x3f
4646+4747+#define kLocaleNameMask 0x1
4848+#define kLocaleOperationVariantNameMask 0x2
4949+#define kLocaleAndVariantNameMask (kLocaleNameMask|kLocaleOperationVariantNameMask)
5050+5151+#define kTextLanguageDontCare -128
5252+#define kTextScriptDontCare -128
5353+#define kTextRegionDontCare -128
5454+5555+#ifdef __cplusplus
5656+extern "C" {
5757+#endif
5858+5959+OSStatus LocaleRefFromLangOrRegionCode(LangCode langCode, RegionCode regionCode, LocaleRef* refOut);
6060+OSStatus LocaleRefFromLocaleString(const char* str, LocaleRef* refOut);
6161+OSStatus LocaleRefGetPartString(LocaleRef ref, uint32_t partMask, unsigned long maxStringLen, char* stringOut);
6262+OSStatus LocaleStringToLangAndRegionCodes(const char* name, LangCode* langCode, RegionCode* regionCode);
6363+OSStatus LocaleOperationCountLocales(LocaleOperationClass cls, unsigned long* count);
6464+OSStatus LocaleOperationGetLocales(LocaleOperationClass cls, unsigned long max, unsigned long* countOut, struct LocaleAndVariant* out);
6565+OSStatus LocaleGetName(LocaleRef ref, LocaleOperationVariant variant, uint32_t nameMask, LocaleRef refDisplay, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName);
6666+OSStatus LocaleCountNames(LocaleRef ref, LocaleOperationVariant variant, uint32_t nameMask, unsigned long* countOut);
6767+OSStatus LocaleGetIndName(LocaleRef ref, LocaleOperationVariant variant, uint32_t nameMask, unsigned long index, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName, LocaleRef* displayLocale);
6868+OSStatus LocaleGetRegionLanguageName(RegionCode regionCode, char name[256]);
6969+OSStatus LocaleOperationGetName(LocaleOperationClass cls, LocaleRef ref, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName);
7070+OSStatus LocaleOperationCountNames(LocaleOperationClass cls, unsigned long* count);
7171+OSStatus LocaleOperationGetIndName(LocaleOperationClass cls, unsigned long index, unsigned long maxLen, unsigned long* lenOut, Utf16Char* displayName, LocaleRef* displayLocale);
7272+7373+#ifdef __cplusplus
7474+}
7575+#endif
7676+7777+#endif
7878+
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2017 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef _TEXTCOMMON_H
2121+#define _TEXTCOMMON_H
2222+#include <MacTypes.h>
2323+2424+#ifdef __cplusplus
2525+extern "C" {
2626+#endif
2727+2828+typedef UInt8* TextPtr;
2929+typedef const UInt8* ConstTextPtr;
3030+3131+enum {
3232+ kTextEncodingUnicodeDefault = 0x100
3333+};
3434+3535+enum {
3636+ kTextEncodingDefaultVariant = 0
3737+};
3838+3939+enum {
4040+ kTextEncodingDefaultFormat = 0,
4141+ kUnicodeUTF16Format = 0,
4242+ kUnicodeUTF7Format = 1,
4343+ kUnicodeUTF8Format = 2,
4444+ kUnicodeUTF32Format = 3,
4545+ kUnicodeUTF16BEFormat = 4,
4646+ kUnicodeUTF16LEFormat = 5,
4747+ kUnicodeUTF32BEFormat = 6,
4848+ kUnicodeUTF32LEFormat = 7,
4949+ kUnicodeSCSUFormat = 8,
5050+ kUnicode16BitFormat = 0,
5151+ kUnicode32BitFormat = 3,
5252+};
5353+5454+enum {
5555+ kUnicodeNoSubset = 0,
5656+ kUnicodeNormalizationFormD = 5,
5757+ kUnicodeNormalizationFormC = 3,
5858+ kUnicodeCanonicalCompVariant = kUnicodeNormalizationFormC,
5959+ kUnicodeHFSPlusDecompVariant = 8,
6060+ kUnicodeHFSPlusCompVariant = 9,
6161+};
6262+6363+typedef UInt32 TextEncoding;
6464+typedef UInt32 TextEncodingBase;
6565+typedef UInt32 TextEncodingFormat;
6666+typedef UInt32 TextEncodingVariant;
6767+6868+TextEncoding CreateTextEncoding(TextEncodingBase encodingBase, TextEncodingVariant encodingVariant, TextEncodingFormat encodingFormat);
6969+7070+#ifdef __cplusplus
7171+}
7272+#endif
7373+7474+#endif
7575+
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2017 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef _TEXTENCODINGCONVERTER_H
2121+#define _TEXTENCODINGCONVERTER_H
2222+#include <MacTypes.h>
2323+#include "TextCommon.h"
2424+2525+#ifdef __cplusplus
2626+extern "C" {
2727+#endif
2828+2929+typedef struct OpaqueTECObjectRef* TECObjectRef;
3030+3131+OSStatus TECCreateConverter(TECObjectRef *newEncodingConverter, TextEncoding inputEncoding, TextEncoding outputEncoding);
3232+3333+OSStatus TECConvertText(TECObjectRef encodingConverter, ConstTextPtr inputBuffer, ByteCount inputBufferLength, ByteCount *actualInputLength, TextPtr outputBuffer, ByteCount outputBufferLength, ByteCount *actualOutputLength);
3434+3535+OSStatus TECFlushText(TECObjectRef encodingConverter, TextPtr outputBuffer, ByteCount outputBufferLength, ByteCount *actualOutputLength);
3636+3737+OSStatus TECDisposeConverter(TECObjectRef newEncodingConverter);
3838+3939+#ifdef __cplusplus
4040+}
4141+#endif
4242+4343+#endif
4444+
+31
src/CoreServices/include/CoreServices/TextUtils.h
···11+#ifndef TEXTUTILS_H
22+#define TEXTUTILS_H
33+#include "MacTypes.h"
44+55+#ifdef __cplusplus
66+extern "C" {
77+#endif
88+99+// There are many functions missing, but will be added as-needed.
1010+// There is no point in spending time implementing all this ancient stuff.
1111+1212+StringHandle NewString(const Str255 str);
1313+void SetString(StringHandle handle, const Str255 str);
1414+1515+void UpperString(Str255 str, Boolean diac);
1616+void upperstring(char* str, Boolean diac);
1717+1818+void c2pstrcpy(Str255 dst, const char* src);
1919+void p2cstrcpy(char* dst, const Str255 src);
2020+void CopyPascalStringToC(const Str255 src, char* dst);
2121+void CopyCStringToPascal(const char* src, Str255 dst);
2222+StringPtr c2pstr(char* str);
2323+StringPtr C2PStr(Ptr str);
2424+char* p2cstr(StringPtr str);
2525+Ptr P2CStr(StringPtr str);
2626+2727+#ifdef __cplusplus
2828+}
2929+#endif
3030+3131+#endif
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2012-2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef TOOLUTILS_H
2121+#define TOOLUTILS_H
2222+2323+#ifdef __cplusplus
2424+extern "C" {
2525+#endif
2626+2727+int BitTst(const void* bytePtr, long bitNum);
2828+void BitSet(void* bytePtr, long bitNum);
2929+void BitClr(void* bytePtr, long bitNum);
3030+long BitAnd(long v1, long v2);
3131+long BitXor(long v1, long v2);
3232+long BitNot(long v1);
3333+long BitShift(long value, short count);
3434+3535+#ifdef __cplusplus
3636+}
3737+#endif
3838+3939+#endif
4040+
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2013 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef UNICODEUTILITIES_H
2121+#define UNICODEUTILITIES_H
2222+#include "MacTypes.h"
2323+#include "MacLocales.h"
2424+#include <stdint.h>
2525+2626+#ifdef __cplusplus
2727+extern "C" {
2828+#endif
2929+3030+typedef void* CollatorRef;
3131+enum //: uint32_t
3232+{
3333+ kUCCollateComposeInsensitiveMask = 0x2,
3434+ kUCCollateWidthInsensitiveMask = 0x4,
3535+ kUCCollateCaseInsensitiveMask = 0x8,
3636+ kUCCollateDiacritInsensitiveMask = 0x10,
3737+ kUCCollatePunctuationSignificantMask = 0x8000,
3838+ kUCCollateDigitsOverrideMask = 0x10000,
3939+ kUCCollateDigitsAsNumberMask = 0x20000
4040+};
4141+4242+4343+OSStatus UCCreateCollator(LocaleRef locale, LocaleOperationVariant opVariant, uint32_t options, CollatorRef* collator);
4444+4545+OSStatus UCGetCollationKey(CollatorRef collator, const UniChar * text, unsigned long textlen, unsigned long maxKeySize, unsigned long* actualKeySize, uint32_t* collationKey);
4646+4747+OSStatus UCCompareCollationKeys(const uint32_t* key1, unsigned long key1len, const uint32_t* key2, unsigned long key2len, Boolean* equiv, int32_t* order);
4848+4949+OSStatus UCCompareText(CollatorRef collator, const UniChar* text1, unsigned long text1len, const UniChar* text2, unsigned long text2len, Boolean* equiv, int32_t* order);
5050+5151+OSStatus UCDisposeCollator(CollatorRef* collator);
5252+5353+OSStatus UCCompareTextDefault(uint32_t options, const UniChar* text1, unsigned long text1len, const UniChar* text2, unsigned long text2len, Boolean* equiv, int32_t* order);
5454+5555+OSStatus UCCompareTextNoLocale(uint32_t options, const UniChar* text1, unsigned long text1len, const UniChar* text2, unsigned long text2len, Boolean* equiv, int32_t* order);
5656+5757+#ifdef __cplusplus
5858+}
5959+#endif
6060+6161+#endif
···11+/*
22+ * Copyright (c) 1998-2015 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. Please obtain a copy of the License at
1010+ * http://www.opensource.apple.com/apsl/ and read it before using this
1111+ * file.
1212+ *
1313+ * The Original Code and all software distributed under the License are
1414+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1515+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
1616+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
1717+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
1818+ * Please see the License for the specific language governing rights and
1919+ * limitations under the License.
2020+ *
2121+ * @APPLE_LICENSE_HEADER_END@
2222+ */
2323+2424+#ifndef __DISKARBITRATION_DADISK__
2525+#define __DISKARBITRATION_DADISK__
2626+2727+#include <CoreFoundation/CoreFoundation.h>
2828+#include <IOKit/IOKitLib.h>
2929+3030+#include <DiskArbitration/DASession.h>
3131+3232+#ifdef __cplusplus
3333+extern "C" {
3434+#endif /* __cplusplus */
3535+3636+CF_ASSUME_NONNULL_BEGIN
3737+CF_IMPLICIT_BRIDGING_ENABLED
3838+3939+extern const CFStringRef kDADiskDescriptionVolumeKindKey; /* ( CFString ) */
4040+extern const CFStringRef kDADiskDescriptionVolumeMountableKey; /* ( CFBoolean ) */
4141+extern const CFStringRef kDADiskDescriptionVolumeNameKey; /* ( CFString ) */
4242+extern const CFStringRef kDADiskDescriptionVolumeNetworkKey; /* ( CFBoolean ) */
4343+extern const CFStringRef kDADiskDescriptionVolumePathKey; /* ( CFURL ) */
4444+extern const CFStringRef kDADiskDescriptionVolumeTypeKey; /* ( CFString ) */
4545+extern const CFStringRef kDADiskDescriptionVolumeUUIDKey; /* ( CFUUID ) */
4646+4747+extern const CFStringRef kDADiskDescriptionMediaBlockSizeKey; /* ( CFNumber ) */
4848+extern const CFStringRef kDADiskDescriptionMediaBSDMajorKey; /* ( CFNumber ) */
4949+extern const CFStringRef kDADiskDescriptionMediaBSDMinorKey; /* ( CFNumber ) */
5050+extern const CFStringRef kDADiskDescriptionMediaBSDNameKey; /* ( CFString ) */
5151+extern const CFStringRef kDADiskDescriptionMediaBSDUnitKey; /* ( CFNumber ) */
5252+extern const CFStringRef kDADiskDescriptionMediaContentKey; /* ( CFString ) */
5353+extern const CFStringRef kDADiskDescriptionMediaEjectableKey; /* ( CFBoolean ) */
5454+extern const CFStringRef kDADiskDescriptionMediaIconKey; /* ( CFDictionary ) */
5555+extern const CFStringRef kDADiskDescriptionMediaKindKey; /* ( CFString ) */
5656+extern const CFStringRef kDADiskDescriptionMediaLeafKey; /* ( CFBoolean ) */
5757+extern const CFStringRef kDADiskDescriptionMediaNameKey; /* ( CFString ) */
5858+extern const CFStringRef kDADiskDescriptionMediaPathKey; /* ( CFString ) */
5959+extern const CFStringRef kDADiskDescriptionMediaRemovableKey; /* ( CFBoolean ) */
6060+extern const CFStringRef kDADiskDescriptionMediaSizeKey; /* ( CFNumber ) */
6161+extern const CFStringRef kDADiskDescriptionMediaTypeKey; /* ( CFString ) */
6262+extern const CFStringRef kDADiskDescriptionMediaUUIDKey; /* ( CFUUID ) */
6363+extern const CFStringRef kDADiskDescriptionMediaWholeKey; /* ( CFBoolean ) */
6464+extern const CFStringRef kDADiskDescriptionMediaWritableKey; /* ( CFBoolean ) */
6565+6666+extern const CFStringRef kDADiskDescriptionDeviceGUIDKey; /* ( CFData ) */
6767+extern const CFStringRef kDADiskDescriptionDeviceInternalKey; /* ( CFBoolean ) */
6868+extern const CFStringRef kDADiskDescriptionDeviceModelKey; /* ( CFString ) */
6969+extern const CFStringRef kDADiskDescriptionDevicePathKey; /* ( CFString ) */
7070+extern const CFStringRef kDADiskDescriptionDeviceProtocolKey; /* ( CFString ) */
7171+extern const CFStringRef kDADiskDescriptionDeviceRevisionKey; /* ( CFString ) */
7272+extern const CFStringRef kDADiskDescriptionDeviceUnitKey; /* ( CFNumber ) */
7373+extern const CFStringRef kDADiskDescriptionDeviceVendorKey; /* ( CFString ) */
7474+7575+extern const CFStringRef kDADiskDescriptionBusNameKey; /* ( CFString ) */
7676+extern const CFStringRef kDADiskDescriptionBusPathKey; /* ( CFString ) */
7777+7878+#ifndef __DISKARBITRATIOND__
7979+8080+/*!
8181+ * @typedef DADiskRef
8282+ * Type of a reference to DADisk instances.
8383+ */
8484+8585+typedef struct CF_BRIDGED_TYPE( id ) __DADisk * DADiskRef;
8686+8787+/*!
8888+ * @function DADiskGetTypeID
8989+ * @abstract Returns the type identifier of all DADisk instances.
9090+ */
9191+9292+extern CFTypeID DADiskGetTypeID( void );
9393+9494+/*!
9595+ * @function DADiskCreateFromBSDName
9696+ * @abstract Creates a new disk object.
9797+ * @param allocator The allocator object to be used to allocate memory.
9898+ * @param session The DASession in which to contact Disk Arbitration.
9999+ * @param name The BSD device name.
100100+ * @result A reference to a new DADisk.
101101+ * @discussion
102102+ * The caller of this function receives a reference to the returned object. The
103103+ * caller also implicitly retains the object and is responsible for releasing it
104104+ * with CFRelease().
105105+ */
106106+107107+extern DADiskRef __nullable DADiskCreateFromBSDName( CFAllocatorRef __nullable allocator, DASessionRef session, const char * name );
108108+109109+/*!
110110+ * @function DADiskCreateFromIOMedia
111111+ * @abstract Creates a new disk object.
112112+ * @param allocator The allocator object to be used to allocate memory.
113113+ * @param session The DASession in which to contact Disk Arbitration.
114114+ * @param media The I/O Kit media object.
115115+ * @result A reference to a new DADisk.
116116+ * @discussion
117117+ * The caller of this function receives a reference to the returned object. The
118118+ * caller also implicitly retains the object and is responsible for releasing it
119119+ * with CFRelease().
120120+ */
121121+122122+extern DADiskRef __nullable DADiskCreateFromIOMedia( CFAllocatorRef __nullable allocator, DASessionRef session, io_service_t media );
123123+124124+/*!
125125+ * @function DADiskCreateFromVolumePath
126126+ * @abstract Creates a new disk object.
127127+ * @param allocator The allocator object to be used to allocate memory.
128128+ * @param session The DASession in which to contact Disk Arbitration.
129129+ * @param path The BSD mount point.
130130+ * @result A reference to a new DADisk.
131131+ * @discussion
132132+ * The caller of this function receives a reference to the returned object. The
133133+ * caller also implicitly retains the object and is responsible for releasing it
134134+ * with CFRelease().
135135+ */
136136+137137+extern DADiskRef __nullable DADiskCreateFromVolumePath( CFAllocatorRef __nullable allocator, DASessionRef session, CFURLRef path );
138138+139139+/*!
140140+ * @function DADiskGetBSDName
141141+ * @abstract Obtains the BSD device name for the specified disk.
142142+ * @param disk The DADisk for which to obtain the BSD device name.
143143+ * @result The disk's BSD device name.
144144+ * @discussion
145145+ * The BSD device name can be used with opendev() to open the BSD device.
146146+ */
147147+148148+extern const char * __nullable DADiskGetBSDName( DADiskRef disk );
149149+150150+/*!
151151+ * @function DADiskCopyIOMedia
152152+ * @abstract Obtains the I/O Kit media object for the specified disk.
153153+ * @param disk The DADisk for which to obtain the I/O Kit media object.
154154+ * @result The disk's I/O Kit media object.
155155+ * @discussion
156156+ * The caller of this function receives a reference to the returned object. The
157157+ * caller also implicitly retains the object and is responsible for releasing it
158158+ * with IOObjectRelease().
159159+ */
160160+161161+extern io_service_t DADiskCopyIOMedia( DADiskRef disk );
162162+163163+/*!
164164+ * @function DADiskCopyDescription
165165+ * @abstract Obtains the Disk Arbitration description of the specified disk.
166166+ * @param disk The DADisk for which to obtain the Disk Arbitration description.
167167+ * @result The disk's Disk Arbitration description.
168168+ * @discussion
169169+ * This function will contact Disk Arbitration to acquire the latest description
170170+ * of the specified disk, unless this function is called on a disk object passed
171171+ * within the context of a registered callback, in which case the description is
172172+ * current as of that callback event.
173173+ *
174174+ * The caller of this function receives a reference to the returned object. The
175175+ * caller also implicitly retains the object and is responsible for releasing it
176176+ * with CFRelease().
177177+ */
178178+179179+extern CFDictionaryRef __nullable DADiskCopyDescription( DADiskRef disk );
180180+181181+/*!
182182+ * @function DADiskCopyWholeDisk
183183+ * @abstract Obtain the associated whole disk object for the specified disk.
184184+ * @param disk The disk object.
185185+ * @result The disk's associated whole disk object.
186186+ * @discussion
187187+ * The caller of this function receives a reference to the returned object. The
188188+ * caller also implicitly retains the object and is responsible for releasing it
189189+ * with CFRelease().
190190+ */
191191+192192+extern DADiskRef __nullable DADiskCopyWholeDisk( DADiskRef disk );
193193+194194+#endif /* !__DISKARBITRATIOND__ */
195195+196196+CF_IMPLICIT_BRIDGING_DISABLED
197197+CF_ASSUME_NONNULL_END
198198+199199+#ifdef __cplusplus
200200+}
201201+#endif /* __cplusplus */
202202+203203+#endif /* !__DISKARBITRATION_DADISK__ */
···11+/*
22+ * Copyright (c) 1998-2015 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. Please obtain a copy of the License at
1010+ * http://www.opensource.apple.com/apsl/ and read it before using this
1111+ * file.
1212+ *
1313+ * The Original Code and all software distributed under the License are
1414+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1515+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
1616+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
1717+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
1818+ * Please see the License for the specific language governing rights and
1919+ * limitations under the License.
2020+ *
2121+ * @APPLE_LICENSE_HEADER_END@
2222+ */
2323+2424+#ifndef __DISKARBITRATION_DASESSION__
2525+#define __DISKARBITRATION_DASESSION__
2626+2727+#include <CoreFoundation/CoreFoundation.h>
2828+2929+#ifdef __cplusplus
3030+extern "C" {
3131+#endif /* __cplusplus */
3232+3333+CF_ASSUME_NONNULL_BEGIN
3434+CF_IMPLICIT_BRIDGING_ENABLED
3535+3636+#ifndef __DISKARBITRATIOND__
3737+3838+/*!
3939+ * @typedef DASessionRef
4040+ * Type of a reference to DASession instances.
4141+ */
4242+4343+typedef struct CF_BRIDGED_TYPE( id ) __DASession * DASessionRef;
4444+4545+/*!
4646+ * @function DASessionGetTypeID
4747+ * @abstract Returns the type identifier of all DASession instances.
4848+ */
4949+5050+extern CFTypeID DASessionGetTypeID( void );
5151+5252+/*!
5353+ * @function DASessionCreate
5454+ * @abstract Creates a new session.
5555+ * @result A reference to a new DASession.
5656+ * @discussion
5757+ * The caller of this function receives a reference to the returned object. The
5858+ * caller also implicitly retains the object and is responsible for releasing it.
5959+ */
6060+6161+extern DASessionRef __nullable DASessionCreate( CFAllocatorRef __nullable allocator );
6262+6363+/*!
6464+ * @function DASessionScheduleWithRunLoop
6565+ * @abstract Schedules the session on a run loop.
6666+ * @param session The session which is being scheduled.
6767+ * @param runLoop The run loop on which the session should be scheduled.
6868+ * @param runLoopMode The run loop mode in which the session should be scheduled.
6969+ */
7070+7171+extern void DASessionScheduleWithRunLoop( DASessionRef session, CFRunLoopRef runLoop, CFStringRef runLoopMode );
7272+7373+/*!
7474+ * @function DASessionUnscheduleFromRunLoop
7575+ * @abstract Unschedules the session from a run loop.
7676+ * @param session The session which is being unscheduled.
7777+ * @param runLoop The run loop on which the session is scheduled.
7878+ * @param runLoopMode The run loop mode in which the session is scheduled.
7979+ */
8080+8181+extern void DASessionUnscheduleFromRunLoop( DASessionRef session, CFRunLoopRef runLoop, CFStringRef runLoopMode );
8282+8383+/*!
8484+ * @function DASessionSetDispatchQueue
8585+ * @abstract Schedules the session on a dispatch queue.
8686+ * @param session The session which is being scheduled.
8787+ * @param queue The dispatch queue on which the session should be scheduled. Pass NULL to unschedule.
8888+ */
8989+9090+extern void DASessionSetDispatchQueue( DASessionRef session, dispatch_queue_t __nullable queue );
9191+9292+/*
9393+ * @typedef DAApprovalSessionRef
9494+ * Type of a reference to DAApprovalSession instances.
9595+ */
9696+9797+typedef struct CF_BRIDGED_TYPE( id ) __DASession * DAApprovalSessionRef CF_SWIFT_UNAVAILABLE( "Use DASessionRef instead" );
9898+9999+/*
100100+ * @function DAApprovalSessionGetTypeID
101101+ * @abstract Returns the type identifier of all DAApprovalSession instances.
102102+ */
103103+104104+extern CFTypeID DAApprovalSessionGetTypeID( void ) CF_SWIFT_UNAVAILABLE( "Use DASessionGetTypeID instead" );
105105+106106+/*
107107+ * @function DAApprovalSessionCreate
108108+ * @abstract Creates a new approval session.
109109+ * @result A reference to a new DAApprovalSession.
110110+ * @discussion
111111+ * The caller of this function receives a reference to the returned object. The
112112+ * caller also implicitly retains the object and is responsible for releasing it.
113113+ */
114114+115115+extern DAApprovalSessionRef __nullable DAApprovalSessionCreate( CFAllocatorRef __nullable allocator ) CF_SWIFT_UNAVAILABLE( "Use DASessionCreate instead" );
116116+117117+/*
118118+ * @function DAApprovalSessionScheduleWithRunLoop
119119+ * @abstract Schedules the approval session on a run loop.
120120+ * @param session The approval session which is being scheduled.
121121+ * @param runLoop The run loop on which the approval session should be scheduled.
122122+ * @param runLoopMode The run loop mode in which the approval session should be scheduled.
123123+ */
124124+125125+extern void DAApprovalSessionScheduleWithRunLoop( DAApprovalSessionRef session, CFRunLoopRef runLoop, CFStringRef runLoopMode ) CF_SWIFT_UNAVAILABLE( "Use DASessionSetDispatchQueue instead" );
126126+127127+/*
128128+ * @function DAApprovalSessionUnscheduleFromRunLoop
129129+ * @abstract Unschedules the approval session from a run loop.
130130+ * @param session The approval session which is being unscheduled.
131131+ * @param runLoop The run loop on which the approval session is scheduled.
132132+ * @param runLoopMode The run loop mode in which the approval session is scheduled.
133133+ */
134134+135135+extern void DAApprovalSessionUnscheduleFromRunLoop( DAApprovalSessionRef session, CFRunLoopRef runLoop, CFStringRef runLoopMode ) CF_SWIFT_UNAVAILABLE( "Use DASessionSetDispatchQueue instead" );
136136+137137+#endif /* !__DISKARBITRATIOND__ */
138138+139139+CF_IMPLICIT_BRIDGING_DISABLED
140140+CF_ASSUME_NONNULL_END
141141+142142+#ifdef __cplusplus
143143+}
144144+#endif /* __cplusplus */
145145+146146+#endif /* !__DISKARBITRATION_DASESSION__ */
···11+/*
22+ * Copyright (c) 1998-2015 Apple Inc. All rights reserved.
33+ *
44+ * @APPLE_LICENSE_HEADER_START@
55+ *
66+ * This file contains Original Code and/or Modifications of Original Code
77+ * as defined in and that are subject to the Apple Public Source License
88+ * Version 2.0 (the 'License'). You may not use this file except in
99+ * compliance with the License. Please obtain a copy of the License at
1010+ * http://www.opensource.apple.com/apsl/ and read it before using this
1111+ * file.
1212+ *
1313+ * The Original Code and all software distributed under the License are
1414+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1515+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
1616+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
1717+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
1818+ * Please see the License for the specific language governing rights and
1919+ * limitations under the License.
2020+ *
2121+ * @APPLE_LICENSE_HEADER_END@
2222+ */
2323+2424+#ifndef __DISKARBITRATION_DISKARBITRATION__
2525+#define __DISKARBITRATION_DISKARBITRATION__
2626+2727+#include <CoreFoundation/CoreFoundation.h>
2828+2929+#include <DiskArbitration/DADisk.h>
3030+#include <DiskArbitration/DADissenter.h>
3131+#include <DiskArbitration/DASession.h>
3232+3333+#ifdef __cplusplus
3434+extern "C" {
3535+#endif /* __cplusplus */
3636+3737+CF_ASSUME_NONNULL_BEGIN
3838+CF_IMPLICIT_BRIDGING_ENABLED
3939+4040+/*!
4141+ * @enum DADiskMountOptions
4242+ * @abstract Options for DADiskMount().
4343+ * @constant kDADiskMountOptionWhole Mount the volumes tied to the whole disk object.
4444+ */
4545+4646+enum
4747+{
4848+ kDADiskMountOptionDefault = 0x00000000,
4949+ kDADiskMountOptionWhole = 0x00000001
5050+};
5151+5252+typedef UInt32 DADiskMountOptions;
5353+5454+/*!
5555+ * @enum DADiskRenameOptions
5656+ * @abstract Options for DADiskRename().
5757+ */
5858+5959+enum
6060+{
6161+ kDADiskRenameOptionDefault = 0x00000000
6262+};
6363+6464+typedef UInt32 DADiskRenameOptions;
6565+6666+/*!
6767+ * @enum DADiskUnmountOptions
6868+ * @abstract Options for DADiskUnmount().
6969+ * @constant kDADiskUnmountOptionForce Unmount the volume even if files are still active.
7070+ * @constant kDADiskUnmountOptionWhole Unmount the volumes tied to the whole disk object.
7171+ */
7272+7373+enum
7474+{
7575+ kDADiskUnmountOptionDefault = 0x00000000,
7676+ kDADiskUnmountOptionForce = 0x00080000,
7777+ kDADiskUnmountOptionWhole = 0x00000001
7878+};
7979+8080+typedef UInt32 DADiskUnmountOptions;
8181+8282+/*!
8383+ * @enum DADiskEjectOptions
8484+ * @abstract Options for DADiskEject().
8585+ */
8686+8787+enum
8888+{
8989+ kDADiskEjectOptionDefault = 0x00000000
9090+};
9191+9292+typedef UInt32 DADiskEjectOptions;
9393+9494+/*!
9595+ * @enum DADiskClaimOptions
9696+ * @abstract Options for DADiskClaim().
9797+ */
9898+9999+enum
100100+{
101101+ kDADiskClaimOptionDefault = 0x00000000
102102+};
103103+104104+typedef UInt32 DADiskClaimOptions;
105105+106106+/*!
107107+ * @enum DADiskOptions
108108+ * @abstract Options for DADiskGetOptions() and DADiskSetOptions().
109109+ */
110110+111111+enum
112112+{
113113+ kDADiskOptionDefault = 0x00000000
114114+};
115115+116116+typedef UInt32 DADiskOptions;
117117+118118+/*!
119119+ * @constant kDADiskDescriptionMatchMediaUnformatted
120120+ * Predefined CFDictionary object containing a set of disk description keys and values
121121+ * appropriate for matching unformatted media using DARegister*Callback().
122122+ */
123123+124124+extern CFDictionaryRef kDADiskDescriptionMatchMediaUnformatted;
125125+126126+/*!
127127+ * @constant kDADiskDescriptionMatchMediaWhole
128128+ * Predefined CFDictionary object containing a set of disk description keys and values
129129+ * appropriate for matching whole media using DARegister*Callback().
130130+ */
131131+132132+extern CFDictionaryRef kDADiskDescriptionMatchMediaWhole;
133133+134134+/*!
135135+ * @constant kDADiskDescriptionMatchVolumeMountable
136136+ * Predefined CFDictionary object containing a set of disk description keys and values
137137+ * appropriate for matching mountable volumes using DARegister*Callback().
138138+ */
139139+140140+extern CFDictionaryRef kDADiskDescriptionMatchVolumeMountable;
141141+142142+/*!
143143+ * @constant kDADiskDescriptionMatchVolumeUnrecognized
144144+ * Predefined CFDictionary object containing a set of disk description keys and values
145145+ * appropriate for matching unrecognized volumes using DARegister*Callback().
146146+ */
147147+148148+extern CFDictionaryRef kDADiskDescriptionMatchVolumeUnrecognized;
149149+150150+/*!
151151+ * @constant kDADiskDescriptionWatchVolumeName
152152+ * Predefined CFArray object containing a set of disk description keys appropriate for
153153+ * watching volume name changes using DARegisterDiskDescriptionChangedCallback().
154154+ */
155155+156156+extern CFArrayRef kDADiskDescriptionWatchVolumeName;
157157+158158+/*!
159159+ * @constant kDADiskDescriptionWatchVolumePath
160160+ * Predefined CFArray object containing a set of disk description keys appropriate for
161161+ * watching volume mount changes using DARegisterDiskDescriptionChangedCallback().
162162+ */
163163+164164+extern CFArrayRef kDADiskDescriptionWatchVolumePath;
165165+166166+#ifndef __DISKARBITRATIOND__
167167+168168+/*!
169169+ * @typedef DADiskAppearedCallback
170170+ * @abstract Type of the callback function used by DARegisterDiskAppearedCallback().
171171+ * @param disk A disk object.
172172+ * @param context The user-defined context parameter given to the registration function.
173173+ */
174174+175175+typedef void ( *DADiskAppearedCallback )( DADiskRef disk, void * __nullable context );
176176+177177+/*!
178178+ * @function DARegisterDiskAppearedCallback
179179+ * @abstract Registers a callback function to be called whenever a disk has appeared.
180180+ * @param session The session object.
181181+ * @param match The disk description keys to match. Pass NULL for all disk objects.
182182+ * @param callback The callback function to call when a disk has appeared.
183183+ * @param context The user-defined context parameter to pass to the callback function.
184184+ */
185185+186186+extern void DARegisterDiskAppearedCallback( DASessionRef session,
187187+ CFDictionaryRef __nullable match,
188188+ DADiskAppearedCallback callback,
189189+ void * __nullable context );
190190+191191+/*!
192192+ * @typedef DADiskDescriptionChangedCallback
193193+ * @abstract Type of the callback function used by DARegisterDiskDescriptionChangedCallback().
194194+ * @param disk A disk object.
195195+ * @param keys A list of changed keys.
196196+ * @param context The user-defined context parameter given to the registration function.
197197+ */
198198+199199+typedef void ( *DADiskDescriptionChangedCallback )( DADiskRef disk, CFArrayRef keys, void * __nullable context );
200200+201201+/*!
202202+ * @function DARegisterDiskDescriptionChangedCallback
203203+ * @abstract Registers a callback function to be called whenever a disk description has changed.
204204+ * @param session The session object.
205205+ * @param match The disk description keys to match. Pass NULL for all disk objects.
206206+ * @param watch The disk description keys to watch. Pass NULL for all keys.
207207+ * @param callback The callback function to call when a watched key changes.
208208+ * @param context The user-defined context parameter to pass to the callback function.
209209+ */
210210+211211+extern void DARegisterDiskDescriptionChangedCallback( DASessionRef session,
212212+ CFDictionaryRef __nullable match,
213213+ CFArrayRef __nullable watch,
214214+ DADiskDescriptionChangedCallback callback,
215215+ void * __nullable context );
216216+217217+/*!
218218+ * @typedef DADiskDisappearedCallback
219219+ * @abstract Type of the callback function used by DARegisterDiskDisappearedCallback().
220220+ * @param disk A disk object.
221221+ * @param context The user-defined context parameter given to the registration function.
222222+ */
223223+224224+typedef void ( *DADiskDisappearedCallback )( DADiskRef disk, void * __nullable context );
225225+226226+/*!
227227+ * @function DARegisterDiskDisappearedCallback
228228+ * @abstract Registers a callback function to be called whenever a disk has disappeared.
229229+ * @param session The session object.
230230+ * @param match The disk description keys to match. Pass NULL for all disk objects.
231231+ * @param callback The callback function to call when a disk has disappeared.
232232+ * @param context The user-defined context parameter to pass to the callback function.
233233+ */
234234+235235+extern void DARegisterDiskDisappearedCallback( DASessionRef session,
236236+ CFDictionaryRef __nullable match,
237237+ DADiskDisappearedCallback callback,
238238+ void * __nullable context );
239239+240240+/*!
241241+ * @typedef DADiskMountCallback
242242+ * @abstract Type of the callback function used by DADiskMount().
243243+ * @param disk The disk object.
244244+ * @param dissenter A dissenter object on failure or NULL on success.
245245+ * @param context The user-defined context parameter given to the mount function.
246246+ */
247247+248248+typedef void ( *DADiskMountCallback )( DADiskRef disk, DADissenterRef __nullable dissenter, void * __nullable context );
249249+250250+/*!
251251+ * @function DADiskMount
252252+ * @abstract Mounts the volume at the specified disk object.
253253+ * @param disk The disk object.
254254+ * @param path The mount path. Pass NULL for a "standard" mount path.
255255+ * @param options The mount options.
256256+ * @param callback The callback function to call once the mount completes.
257257+ * @param context The user-defined context parameter to pass to the callback function.
258258+ */
259259+260260+extern void DADiskMount( DADiskRef disk,
261261+ CFURLRef __nullable path,
262262+ DADiskMountOptions options,
263263+ DADiskMountCallback __nullable callback,
264264+ void * __nullable context );
265265+266266+/*!
267267+ * @function DADiskMountWithArguments
268268+ * @abstract Mounts the volume at the specified disk object, with the specified mount options.
269269+ * @param disk The disk object.
270270+ * @param path The mount path. Pass NULL for a "standard" mount path.
271271+ * @param options The mount options.
272272+ * @param callback The callback function to call once the mount completes.
273273+ * @param context The user-defined context parameter to pass to the callback function.
274274+ * @param arguments The null-terminated list of mount options to pass to /sbin/mount -o.
275275+ */
276276+277277+extern void DADiskMountWithArguments( DADiskRef disk,
278278+ CFURLRef __nullable path,
279279+ DADiskMountOptions options,
280280+ DADiskMountCallback __nullable callback,
281281+ void * __nullable context,
282282+ CFStringRef arguments[] );
283283+284284+/*!
285285+ * @typedef DADiskMountApprovalCallback
286286+ * @abstract Type of the callback function used by DARegisterDiskMountApprovalCallback().
287287+ * @param disk A disk object.
288288+ * @param context The user-defined context parameter given to the registration function.
289289+ * @result A dissenter reference. Pass NULL to approve.
290290+ * @discussion
291291+ * The caller of this callback receives a reference to the returned object. The
292292+ * caller also implicitly retains the object and is responsible for releasing it
293293+ * with CFRelease().
294294+ */
295295+296296+typedef DADissenterRef __nullable ( *DADiskMountApprovalCallback )( DADiskRef disk, void * __nullable context );
297297+298298+/*!
299299+ * @function DARegisterDiskMountApprovalCallback
300300+ * @abstract Registers a callback function to be called whenever a volume is to be mounted.
301301+ * @param session The session object.
302302+ * @param match The disk description keys to match. Pass NULL for all disk objects.
303303+ * @param callback The callback function to call when a volume is to be mounted.
304304+ * @param context The user-defined context parameter to pass to the callback function.
305305+ */
306306+307307+extern void DARegisterDiskMountApprovalCallback( DASessionRef session,
308308+ CFDictionaryRef __nullable match,
309309+ DADiskMountApprovalCallback callback,
310310+ void * __nullable context );
311311+312312+/*!
313313+ * @typedef DADiskRenameCallback
314314+ * @abstract Type of the callback function used by DADiskRename().
315315+ * @param disk The disk object.
316316+ * @param dissenter A dissenter object on failure or NULL on success.
317317+ * @param context The user-defined context parameter given to the rename function.
318318+ */
319319+320320+typedef void ( *DADiskRenameCallback )( DADiskRef disk, DADissenterRef __nullable dissenter, void * __nullable context );
321321+322322+/*!
323323+ * @function DADiskRename
324324+ * @abstract Renames the volume at the specified disk object.
325325+ * @param disk The disk object.
326326+ * @param options The rename options.
327327+ * @param callback The callback function to call once the rename completes.
328328+ * @param context The user-defined context parameter to pass to the callback function.
329329+ */
330330+331331+extern void DADiskRename( DADiskRef disk,
332332+ CFStringRef name,
333333+ DADiskRenameOptions options,
334334+ DADiskRenameCallback __nullable callback,
335335+ void * __nullable context );
336336+337337+/*!
338338+ * @typedef DADiskUnmountCallback
339339+ * @abstract Type of the callback function used by DADiskUnmount().
340340+ * @param disk The disk object.
341341+ * @param dissenter A dissenter object on failure or NULL on success.
342342+ * @param context The user-defined context parameter given to the unmount function.
343343+ */
344344+345345+typedef void ( *DADiskUnmountCallback )( DADiskRef disk, DADissenterRef __nullable dissenter, void * __nullable context );
346346+347347+/*!
348348+ * @function DADiskUnmount
349349+ * @abstract Unmounts the volume at the specified disk object.
350350+ * @param disk The disk object.
351351+ * @param options The unmount options.
352352+ * @param callback The callback function to call once the unmount completes.
353353+ * @param context The user-defined context parameter to pass to the callback function.
354354+ */
355355+356356+extern void DADiskUnmount( DADiskRef disk,
357357+ DADiskUnmountOptions options,
358358+ DADiskUnmountCallback __nullable callback,
359359+ void * __nullable context );
360360+361361+/*!
362362+ * @typedef DADiskUnmountApprovalCallback
363363+ * @abstract Type of the callback function used by DARegisterDiskUnmountApprovalCallback().
364364+ * @param disk A disk object.
365365+ * @param context The user-defined context parameter given to the registration function.
366366+ * @result A dissenter reference. Pass NULL to approve.
367367+ * @discussion
368368+ * The caller of this callback receives a reference to the returned object. The
369369+ * caller also implicitly retains the object and is responsible for releasing it
370370+ * with CFRelease().
371371+ */
372372+373373+typedef DADissenterRef __nullable ( *DADiskUnmountApprovalCallback )( DADiskRef disk, void * __nullable context );
374374+375375+/*!
376376+ * @function DARegisterDiskUnmountApprovalCallback
377377+ * @abstract Registers a callback function to be called whenever a volume is to be unmounted.
378378+ * @param session The session object.
379379+ * @param match The disk description keys to match. Pass NULL for all disk objects.
380380+ * @param callback The callback function to call when a volume is to be unmounted.
381381+ * @param context The user-defined context parameter to pass to the callback function.
382382+ */
383383+384384+extern void DARegisterDiskUnmountApprovalCallback( DASessionRef session,
385385+ CFDictionaryRef __nullable match,
386386+ DADiskUnmountApprovalCallback callback,
387387+ void * __nullable context );
388388+389389+/*!
390390+ * @typedef DADiskEjectCallback
391391+ * @abstract Type of the callback function used by DADiskEject().
392392+ * @param disk The disk object.
393393+ * @param dissenter A dissenter object on failure or NULL on success.
394394+ * @param context The user-defined context parameter given to the eject function.
395395+ */
396396+397397+typedef void ( *DADiskEjectCallback )( DADiskRef disk, DADissenterRef __nullable dissenter, void * __nullable context );
398398+399399+/*!
400400+ * @function DADiskEject
401401+ * @abstract Ejects the specified disk object.
402402+ * @param disk The disk object.
403403+ * @param options The eject options.
404404+ * @param callback The callback function to call once the ejection completes.
405405+ * @param context The user-defined context parameter to pass to the callback function.
406406+ */
407407+408408+extern void DADiskEject( DADiskRef disk,
409409+ DADiskEjectOptions options,
410410+ DADiskEjectCallback __nullable callback,
411411+ void * __nullable context );
412412+413413+/*!
414414+ * @typedef DADiskEjectApprovalCallback
415415+ * @abstract Type of the callback function used by DARegisterDiskEjectApprovalCallback().
416416+ * @param disk A disk object.
417417+ * @param context The user-defined context parameter given to the registration function.
418418+ * @result A dissenter reference. Pass NULL to approve.
419419+ * @discussion
420420+ * The caller of this callback receives a reference to the returned object. The
421421+ * caller also implicitly retains the object and is responsible for releasing it
422422+ * with CFRelease().
423423+ */
424424+425425+typedef DADissenterRef __nullable ( *DADiskEjectApprovalCallback )( DADiskRef disk, void * __nullable context );
426426+427427+/*!
428428+ * @function DARegisterDiskEjectApprovalCallback
429429+ * @abstract Registers a callback function to be called whenever a volume is to be ejected.
430430+ * @param session The session object.
431431+ * @param match The disk description keys to match. Pass NULL for all disk objects.
432432+ * @param callback The callback function to call when a volume is to be ejected.
433433+ * @param context The user-defined context parameter to pass to the callback function.
434434+ */
435435+436436+extern void DARegisterDiskEjectApprovalCallback( DASessionRef session,
437437+ CFDictionaryRef __nullable match,
438438+ DADiskEjectApprovalCallback callback,
439439+ void * __nullable context );
440440+441441+/*!
442442+ * @typedef DADiskClaimCallback
443443+ * @abstract Type of the callback function used by DADiskClaim().
444444+ * @param disk The disk object.
445445+ * @param dissenter A dissenter object on failure or NULL on success.
446446+ * @param context The user-defined context parameter given to the claim function.
447447+ */
448448+449449+typedef void ( *DADiskClaimCallback )( DADiskRef disk, DADissenterRef __nullable dissenter, void * __nullable context );
450450+451451+/*!
452452+ * @typedef DADiskClaimReleaseCallback
453453+ * @abstract Type of the callback function used by DADiskClaim().
454454+ * @param disk The disk object.
455455+ * @param context The user-defined context parameter given to the claim function.
456456+ * @result A dissenter reference. Pass NULL to release claim.
457457+ * @discussion
458458+ * The caller of this callback receives a reference to the returned object. The
459459+ * caller also implicitly retains the object and is responsible for releasing it
460460+ * with CFRelease().
461461+ */
462462+463463+typedef DADissenterRef __nullable ( *DADiskClaimReleaseCallback )( DADiskRef disk, void * __nullable context );
464464+465465+/*!
466466+ * @function DADiskClaim
467467+ * @abstract Claims the specified disk object for exclusive use.
468468+ * @param disk The disk object.
469469+ * @param options The claim options.
470470+ * @param release The callback function to call when the claim is to be released.
471471+ * @param releaseContext The user-defined context parameter to pass to the callback function.
472472+ * @param callback The callback function to call once the claim completes.
473473+ * @param callbackContext The user-defined context parameter to pass to the callback function.
474474+ */
475475+476476+extern void DADiskClaim( DADiskRef disk,
477477+ DADiskClaimOptions options,
478478+ DADiskClaimReleaseCallback __nullable release,
479479+ void * __nullable releaseContext,
480480+ DADiskClaimCallback __nullable callback,
481481+ void * __nullable callbackContext );
482482+483483+/*!
484484+ * @function DADiskIsClaimed
485485+ * @abstract Reports whether or not the disk is claimed.
486486+ * @param disk The disk object.
487487+ * @result TRUE if the disk is claimed, otherwise FALSE.
488488+ */
489489+490490+extern Boolean DADiskIsClaimed( DADiskRef disk );
491491+492492+/*!
493493+ * @function DADiskUnclaim
494494+ * @abstract Unclaims the specified disk object.
495495+ * @param disk The disk object.
496496+ */
497497+498498+extern void DADiskUnclaim( DADiskRef disk );
499499+500500+/*!
501501+ * @typedef DADiskPeekCallback
502502+ * @abstract Type of the callback function used by DARegisterDiskPeekCallback().
503503+ * @param disk A disk object.
504504+ * @param context The user-defined context parameter given to the registration function.
505505+ * @discussion
506506+ * The peek callback functions are called in a specific order, from lowest order to highest
507507+ * order. DADiskClaim() could be used here to claim the disk object and DADiskSetOptions()
508508+ * could be used here to set up options on the disk object.
509509+ */
510510+511511+typedef void ( *DADiskPeekCallback )( DADiskRef disk, void * __nullable context );
512512+513513+/*!
514514+ * @function DARegisterDiskPeekCallback
515515+ * @abstract Registers a callback function to be called whenever a disk has been probed.
516516+ * @param session The session object.
517517+ * @param match The disk description keys to match. Pass NULL for all disk objects.
518518+ * @param order The callback order, from lowest to highest. Pass 0 for the default.
519519+ * @param callback The callback function to call when a disk has been probed.
520520+ * @param context The user-defined context parameter to pass to the callback function.
521521+ */
522522+523523+extern void DARegisterDiskPeekCallback( DASessionRef session,
524524+ CFDictionaryRef __nullable match,
525525+ CFIndex order,
526526+ DADiskPeekCallback callback,
527527+ void * __nullable context );
528528+529529+/*!
530530+ * @function DADiskGetOptions
531531+ * @abstract Obtains the options for the specified disk.
532532+ * @param disk The disk object for which to obtain the options.
533533+ * @result The options.
534534+ */
535535+536536+extern DADiskOptions DADiskGetOptions( DADiskRef disk );
537537+538538+/*!
539539+ * @function DADiskSetOptions
540540+ * @abstract Sets the options for the specified disk.
541541+ * @param disk The disk object for which to set the options.
542542+ * @param options The options to set or clear.
543543+ * @param value Pass TRUE to set options; otherwise pass FALSE to clear options.
544544+ * @result A result code.
545545+ */
546546+547547+extern DAReturn DADiskSetOptions( DADiskRef disk, DADiskOptions options, Boolean value );
548548+549549+/*!
550550+ * @function DAUnregisterCallback
551551+ * @abstract Unregisters a registered callback function.
552552+ * @param session The session object.
553553+ * @param callback The registered callback function.
554554+ * @param context The user-defined context parameter.
555555+ */
556556+557557+extern void DAUnregisterCallback( DASessionRef session, void * callback, void * __nullable context );
558558+559559+/*
560560+ * @function DAUnregisterApprovalCallback
561561+ * @abstract Unregisters a registered callback function.
562562+ * @param session The session object.
563563+ * @param callback The registered callback function.
564564+ * @param context The user-defined context parameter.
565565+ */
566566+567567+extern void DAUnregisterApprovalCallback( DASessionRef session, void * callback, void * __nullable context ) CF_SWIFT_UNAVAILABLE( "Use DAUnregisterCallback instead" );
568568+569569+#endif /* !__DISKARBITRATIOND__ */
570570+571571+CF_IMPLICIT_BRIDGING_DISABLED
572572+CF_ASSUME_NONNULL_END
573573+574574+#ifdef __cplusplus
575575+}
576576+#endif /* __cplusplus */
577577+578578+#endif /* !__DISKARBITRATION_DISKARBITRATION__ */