Add even more of the source

This should be about everything needed to build so far?
This commit is contained in:
Darren VanBuren 2017-03-07 17:14:16 -08:00
parent af3619d4fa
commit 849723c9cf
547 changed files with 149239 additions and 0 deletions

View file

@ -0,0 +1,91 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
/*
File: CDirService.h
Contains: Implements DSException.
Created By: chris jalbert
Created: 26 July 2000
*/
// This file is only meaningful if exceptions are enabled.
#if USE_EXCEPTIONS
// STL and Std C++ Library Headers
#include <cstdlib> // for abs()
#include <stdexcept> // for standard exceptions
// Project Headers
#include "CDirService.h"
using namespace DirectoryServices ;
using namespace std ;
// ----------------------------------------------------------------------------
// ¥ CDirService Class Globals
// These private typedefs, globals, and functions are not declared statically
// in the class definition because I want to hide the implementation details
// and reduce unrelated dependencies in the class header.
// ----------------------------------------------------------------------------
static const char * const _DSErr = "DirectoryService error: " ;
/*
* Convert an UInt32 to ASCII for printf purposes, returning
* a pointer to the first character of the string representation.
* Borrowed from vfprintf.c.
*/
static char *_ltoa (
SInt32 val,
char *endp)
{
register char *cp = endp ;
register SInt32 sval = std::abs (val) ;
// Terminate the string.
*--cp = '\0' ;
do {
*--cp = '0' + (sval % 10) ;
sval /= 10 ;
} while (sval != 0) ;
// Handle signed values.
if (val < 0)
*--cp = '-' ;
return cp ;
}
DSException::DSException (tDirStatus err)
: inherited (string (_DSErr) + _ltoa (err, &mErrStr[sizeof (mErrStr)])),
mErr (err)
{
}
#endif /* USE_EXCEPTIONS */

View file

@ -0,0 +1,87 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
/*
File: CDirService.h
Contains: Defines DSException.
Created By: chris jalbert
Created: 26 July 2000
*/
#ifndef _CDirService_h
#define _CDirService_h
// Framework Headers
#include <DirectoryService/DirServicesTypes.h>
namespace DirectoryServices {
const tDirReference kDSDirRefNull = 0 ;
// This file is only meaningful if exceptions are enabled.
#if __EXCEPTIONS
// STL and Std C++ Library Headers
#include <stdexcept> // for standard exceptions
//-----------------------------------------------------------------------------
// ¥ DSException - exception class that wraps a tDirStatus result code.
//-----------------------------------------------------------------------------
class DSException : public std::runtime_error {
public:
typedef std::runtime_error inherited ;
DSException ( tDirStatus err ) ;
tDirStatus status ( void ) const { return mErr ; }
private:
tDirStatus mErr ;
char mErrStr [12] ;
} ;
#define throw_ds_error(err) throw DSException(err)
#else /* __EXCEPTIONS */
//-----------------------------------------------------------------------------
// ¥ DSException - with exceptions disabled, this is dummy code.
//-----------------------------------------------------------------------------
class DSException {
public:
DSException ( tDirStatus ) { }
} ;
// Define away the throw spec.
#define throw(spec)
#define throw_ds_error(err)
#endif /* __EXCEPTIONS */
} // namespace DirectoryServices
#endif /* _CDirService_h */

View file

@ -0,0 +1,94 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
/*
File: DSBuffer.cpp
Contains: Class implementation for Open Directory buffers
(wraps tDataBufferPtr)
Created By: chris jalbert
Created: 28 November 2000
*/
// ANSI / POSIX headers
// STL and Std C++ Library Headers
#include <stdexcept> // for standard exceptions
// Framework Headers
#include <DirectoryService/DirServices.h>
// Project Headers
#include "DSBuffer.h"
using namespace DirectoryServices ;
// ----------------------------------------------------------------------------
// ¥ DSBuffer Class Globals
// These private typedefs, globals, and functions are not declared statically
// in the class definition because I want to hide the implementation details
// and reduce unrelated dependencies in the class header.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ¥ DSBuffer Protected Instance Methods
// ----------------------------------------------------------------------------
#pragma mark **** DSBuffer Protected Instance Methods ****
// ----------------------------------------------------------------------------
// ¥ÊGrow
// All memory management (even in the c'tors) are handled in this method.
// An inNewSize value of 0 implies the use of the default buffer size!
// To leave the buffer alone, call with an argument value of 1.
// ----------------------------------------------------------------------------
tDataBufferPtr DSBuffer::grow ( size_t inNewSize )
{
if (!inNewSize)
inNewSize = kDefaultSize ;
if (mBuffer && (inNewSize <= mBuffer->fBufferSize))
return mBuffer ;
register size_t ulTemp = 16 ;
if (inNewSize == kDefaultSize)
ulTemp = inNewSize ;
else
for ( ; ulTemp < inNewSize ; ulTemp <<= 1) ;
register tDataBufferPtr bufNew = ::dsDataBufferAllocate (mDirRef, ulTemp) ;
if (!bufNew)
throw_ds_error (eDSAllocationFailed) ;
if (mBuffer && (ulTemp = mBuffer->fBufferLength))
std::memcpy (bufNew->fBufferData, mBuffer->fBufferData, ulTemp) ;
else
ulTemp = 0 ;
bufNew->fBufferLength = ulTemp ;
::dsDataBufferDeAllocate (mDirRef, mBuffer) ;
return (mBuffer = bufNew) ;
}

View file

@ -0,0 +1,125 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
/*
File: DSBuffer.h
Contains: Class definition for Open Directory buffers
(wraps tDataBufferPtr)
Created By: chris jalbert
Created: 26 July 2000
*/
#ifndef _DSBuffer_h
#define _DSBuffer_h
// Framework Headers
#include <DirectoryService/DirServicesTypes.h>
#include <DirectoryService/DirServicesUtils.h>
// Project Headers
#include "CDirService.h"
namespace DirectoryServices {
//-----------------------------------------------------------------------------
// ¥ DSBuffer - a wrapper for tDataBufferPtr.
// This should be considered a private class, primarily used by DSNode.
// All methods except Grow() are inlined for performance reasons (sorry).
//-----------------------------------------------------------------------------
class DSBuffer
{
public:
/**** Typedefs, enums, and constants. ****/
enum { kDefaultSize = 128 } ;
public:
/**** Instance methods. ****/
// ctor and dtor.
DSBuffer ( tDirReference inDirRef = 0,
size_t inBufferSize = kDefaultSize ) throw (DSException)
: mDirRef (inDirRef), mBuffer (0)
{ if (!grow (inBufferSize)) throw_ds_error (eDSAllocationFailed) ; }
~DSBuffer ( void ) throw ()
{ if (mBuffer) ::dsDataBufferDeAllocate (mDirRef, mBuffer) ; }
// Inline accessors.
size_t capacity ( void ) const throw ()
{ return (size_t) mBuffer->fBufferSize ; }
size_t size ( void ) const throw ()
{ return (size_t) mBuffer->fBufferSize ; }
size_t length ( void ) const throw ()
{ return (size_t) mBuffer->fBufferLength ; }
const char *c_str ( void ) const throw ()
{ return (const char *) mBuffer->fBufferData ; }
const void *data ( void ) const throw ()
{ return (const void *) mBuffer->fBufferData ; }
// Inline setters.
void clear ( void ) throw ()
{ mBuffer->fBufferLength = 0 ; }
void resize ( size_t inLength ) throw (DSException)
{ if (inLength > mBuffer->fBufferSize)
throw_ds_error (eDSBufferTooSmall) ;
mBuffer->fBufferLength = inLength ; }
void set ( const char *inString ) throw (DSException)
{ clear () ; append (inString) ; }
void set ( const void *inData, size_t inLength ) throw (DSException)
{ clear () ; append (inData, inLength) ; }
void append ( const char *inString ) throw (DSException)
{ append ((const void *) inString, 1 + strlen (inString)) ; }
void append ( const void *inData, size_t inLength ) throw (DSException)
{ grow (mBuffer->fBufferLength + inLength) ;
char *cpBuf = mBuffer->fBufferData + mBuffer->fBufferLength ;
std::memcpy (cpBuf, inData, inLength) ;
mBuffer->fBufferLength += inLength ; }
// Casting operators.
tDataBufferPtr operator->() throw ()
{ return mBuffer ; }
operator tDataBufferPtr() const throw ()
{ return mBuffer ; }
operator const char*() const throw ()
{ return this->c_str () ; }
operator const void*() const throw ()
{ return this->data () ; }
protected:
/**** Instance methods accessible only to class and subclasses. ****/
tDataBufferPtr grow ( size_t inNewSize ) throw (DSException) ;
/**** Instance data. ****/
tDirReference mDirRef ;
tDataBufferPtr mBuffer ;
} ;
} // namespace DirectoryServices
#endif /* _DSBuffer_h */

View file

@ -0,0 +1,140 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
/*
File: DSDataList.h
Contains: Class definition for Open Directory data list
(wraps tDataListPtr)
Created By: chris jalbert
Created: 26 July 2000
*/
#ifndef _DSDataList_h
#define _DSDataList_h
// ANSI / POSIX Headers
#include <stdarg.h> // for varargs stuff
#include <string.h> // for memset()
// STL and Std C++ Library Headers
#include <memory> // for auto_ptr<>
// Framework Headers
#include <DirectoryService/DirServicesTypes.h>
#include <DirectoryService/DirServicesUtils.h>
// Project Headers
#include "DSDataNode.h"
namespace DirectoryServices {
//-----------------------------------------------------------------------------
// ¥ DSDataList - simple wrapper for tDataBufferPtr.
// This should be considered a private class, primarily used by DSNode.
// All methods are inlined for performance reasons (sorry).
// Logically, a tDataList is a collection of tDataNode's, so this
// implementation offers GetCount() and operator[](u_long) methods.
//-----------------------------------------------------------------------------
class DSDataList
{
public:
/**** Instance methods. ****/
// ctor and dtor.
/* Not used anywhere and conflicts with next ctor, which is more useful.
DSDataList ( tDirReference inDirRef,
const char *inString, ... ) throw (DSException)
: mDirRef (inDirRef)
{ va_list args ; va_start (args, inString) ;
std::memset (&mList, 0, sizeof (mList)) ;
tDirStatus nError = ::dsBuildListFromStringsAllocV (
inDirRef, &mList, inString, args) ;
va_end (args) ;
if (nError) throw_ds_error (nError) ; }
*/
DSDataList ( tDirReference inDirRef,
const char *inPath ) throw (DSException)
: mDirRef (inDirRef)
{ std::memset (&mList, 0, sizeof (mList)) ;
tDirStatus nError = ::dsBuildListFromPathAlloc (inDirRef, &mList, inPath, "/") ;
if (nError) throw_ds_error (nError) ; }
DSDataList ( const DSDataList& inOrg ) throw (DSException)
: mDirRef (inOrg.mDirRef)
{ tDataList *dlp = ::dsDataListCopyList (inOrg.mDirRef, &inOrg.mList) ;
if (!dlp) throw_ds_error (eDSAllocationFailed) ;
mList = *dlp ; std::free (dlp) ; }
// The following constructor changes the ownership of the list buffer!
DSDataList ( tDirReference inDirRef,
tDataListPtr inList = 0 ) throw (DSException)
: mDirRef (inDirRef)
{ if (inList) {
mList = *inList ; std::memset (inList, 0, sizeof (mList)) ;
} else std::memset (&mList, 0, sizeof (mList)) ; }
~DSDataList ( void ) throw ()
{ ::dsDataListDeallocate (mDirRef, &mList) ; }
// Inline accessors.
UInt32 count ( void ) const throw ()
{ return ::dsDataListGetNodeCount (&mList) ; }
size_t length ( void ) const throw ()
{ return (size_t) ::dsGetDataLength (&mList) ; }
// GetPath()'s return value will be freed when it goes out of scope.
// If it is important, COPY IT to another auto_ptr (which will
// properly invalidate the original).
std::auto_ptr<const char> path ( const char *inSep = "/" ) const
{ return std::auto_ptr<const char> (::dsGetPathFromList (mDirRef,
&mList, inSep)) ; }
// Casting operators.
operator tDataListPtr() throw ()
{ return &mList ; }
operator const tDataList*() const throw ()
{ return &mList ; }
DSDataNode* operator[] ( UInt32 inIndex ) const throw (DSException)
{ tDataNodePtr dnTemp ;
tDirStatus nError = ::dsDataListGetNodeAlloc (
mDirRef, &mList, inIndex, &dnTemp) ;
if (nError) throw_ds_error (nError) ;
return new DSDataNode (mDirRef, dnTemp) ; }
// Setters.
void append ( const char *inString ) throw (DSException)
{ tDirStatus nError = ::dsAppendStringToListAlloc (
mDirRef, &mList, inString) ;
if (nError) throw_ds_error (nError) ; }
protected:
/**** Instance data. ****/
tDirReference mDirRef ;
tDataList mList ;
} ;
} // namespace DirectoryServices
#endif /* _DSDataList_h */

View file

@ -0,0 +1,118 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
/*
File: DSDataNode.h
Contains: Class definition for Open Directory data node
(wraps tDataNodePtr)
Created By: chris jalbert
Created: 26 July 2000
*/
#ifndef _DSDataNode_h
#define _DSDataNode_h
// Framework Headers
#include <DirectoryService/DirServicesTypes.h>
#include <DirectoryService/DirServicesUtils.h>
// Project Headers
#include "CDirService.h"
namespace DirectoryServices {
//-----------------------------------------------------------------------------
// ¥ DSDataNode - simple wrapper for tDataBufferPtr.
// This should be considered a private class, primarily used by DSNode.
// All methods are inlined for performance reasons (sorry).
// tDataNode's are identical to tDataBuffer's in implementation, however,
// nodes are treated as opaque objects with DS accessor functions. As a
// result, DSDataNode is not a subclass of DSBuffer.
//-----------------------------------------------------------------------------
class DSDataNode
{
public:
/**** Instance methods. ****/
// ctor and dtor.
DSDataNode ( tDirReference inDirRef,
size_t inBufSize,
size_t inBufUsed,
const void *inData ) throw (DSException)
: mDirRef (inDirRef),
mNode (::dsDataNodeAllocateBlock (inDirRef,
(UInt32) inBufSize, (UInt32) inBufUsed,
(void *) inData))
{ if (!mNode) throw_ds_error (eDSAllocationFailed) ; }
DSDataNode ( tDirReference inDirRef,
const char *inString ) throw (DSException)
: mDirRef (inDirRef),
mNode (::dsDataNodeAllocateString (inDirRef, inString))
{ if (!mNode) throw_ds_error (eDSAllocationFailed) ; }
// Used by DSDataList
DSDataNode ( tDirReference inDirRef,
tDataNode *inNode ) throw (DSException)
: mDirRef (inDirRef), mNode (inNode)
{ if (!mNode) throw_ds_error (eDSAllocationFailed) ; }
// Something of a "copy" constructor
DSDataNode ( tDirReference inDirRef,
const tDataNode *inNode ) throw (DSException)
: mDirRef (inDirRef),
mNode (::dsDataNodeAllocateBlock (inDirRef,
inNode->fBufferSize, inNode->fBufferLength,
(void *) inNode->fBufferData))
{ if (!mNode) throw_ds_error (eDSAllocationFailed) ; }
~DSDataNode ( void ) throw ()
{ if (mNode) ::dsDataNodeDeAllocate (mDirRef, mNode) ; }
// Inline accessors.
size_t capacity ( void ) const throw ()
{ return (size_t) ::dsDataNodeGetSize (mNode) ; }
size_t size ( void ) const throw ()
{ return (size_t) ::dsDataNodeGetSize (mNode) ; }
size_t length ( void ) const throw ()
{ return (size_t) ::dsDataNodeGetLength (mNode) ; }
void resize ( size_t inLength ) throw (DSException)
{ tDirStatus nError = ::dsDataNodeSetLength (mNode, inLength) ;
if (nError) throw_ds_error (nError) ; }
// Casting operators.
operator tDataNodePtr() const throw ()
{ return mNode ; }
protected:
/**** Instance data. ****/
tDirReference mDirRef ;
tDataNodePtr mNode ;
} ;
} // namespace DirectoryServices
#endif /* _DSDataNode_h */