1 line
40 KiB
C
1 line
40 KiB
C
|
/* Copyright (c) 2017, Computer History Museum
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted (subject to
the limitations in the disclaimer below) provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. */
#include "ldap.h"
#include "lber.h"
#include "dflutils.h"
#include "dflsuppl.h"
#include "ldaplibglue.h"
#include "ldaputils.h"
#define FILE_NUM 107
#pragma segment LDAPUtils
/* MJN *//* new file */
#pragma mark defines
#define ASYNC_LDAP_CALLS 1
#define LDAP_TEXT_ACCUM_CHUNK_SIZE 1024
#define LDAP_ATTR_LIST_GROW_SIZE 10
#define LDAP_ATTR_TRANSLATION_TABLE_ID 32767
#define LDAP_SERVER_LIST_ID 32767
#pragma mark enum constants
enum {
kLDAPOpenPreflightMemSize = 65536, /* 64K */
kLDAPSearchPreflightMemSize = 32768 /* 32K */
};
enum {
kLDAPErrTableRsrcType = 'LECT',
kLDAPErrTableRsrcID = 128
};
enum {
kMonitorLDAPCodeGrowMinSize = 131072 /* 128K */
};
enum {
kLDAPUserCancelCheckDelay = 15 /* in ticks */
};
#pragma mark typedefs
/* WARNING *//* the numbering of these items must match the ordering of items in the LDAP Atrribute lookup table resource */
typedef enum {
invalidAttr = 0,
commonNameAttr,
commonNameAttr2,
cityAttr,
stateAttr,
organizationAttr,
organizationalUnitAttr,
countryAttr,
streetAttr,
emailAttr,
emailAlt1Attr,
emailAlt2Attr,
lastNameAttr,
givenNameAttr,
webLookupURLAttr,
telephoneAttr
} LDAPAttrType;
typedef struct {
Handle dataHdl;
long physicalSize;
long logicalSize;
} LDAPTextAccumRec, *LDAPTextAccumPtr, **LDAPTextAccumHdl;
/* defined as struct timeval in ":ldap-3.3:libraries:macintosh:tcp:tcp.h";
the definition in "utime.mac.h" in the Metrowerks Standard Library headers is incompatible */
typedef struct LDAPTimeValRec {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
} LDAPTimeValRec, *LDAPTimeValPtr;
#pragma mark globals
static Boolean LDAPCodeLoaded = false;
static Boolean LDAPCodePurgeable = false;
static Boolean LDAPCanUseDFL = false;
static OSErr LDAPCanUseDFLErr = noErr;
static OSErr LDAPLibLoadErr = noErr;
static Str255 LDAPResultCountStr;
static Str255 LDAPResultErrStr;
static Str255 LDAPUserCanceledMsgStr;
Str255 LDAPDividerStr;
static long MinLDAPLabelLen;
/* FINISH *//* does this need to be here? */
#if GENERATING68KSEGLOAD
#pragma mpwc on
#endif
#ifdef LDAP_ENABLED
static void AppendPStr(Str255 targetStr, Str255 appendStr)
{
long len;
len = appendStr[0];
if (targetStr[0] + len > 255)
len = 255 - targetStr[0];
BlockMoveData(appendStr + 1, targetStr + targetStr[0] + 1, len);
targetStr[0] += len;
}
#endif //ifdef LDAP_ENABLED
#ifdef LDAP_ENABLED
static void AppendCStr(Str255 targ
|