eudora-mac/networksetuplibrary.c

1 line
30 KiB
C
Raw Normal View History

2018-05-23 09:59:15 +00:00
/* 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 "networksetuplibrary.h" #define FILENUM 122 /* Copyright (c) 1999 by Qualcomm, Inc. */ /************************************************************************ * Functions to use Apple's Network Setup Library included with Mac OS * 8.5 and beyond. The library is used to determine the TCP/IP connection * method, as well as read in ARA PPP dialing preferences. ************************************************************************/ #pragma segment TcpTrans // TCP/IP Will Dial Result Codes enum { kNSHTCPDialUnknown = 0, kNSHTCPDialTCPDisabled, kNSHTCPDialYes, kNSHTCPDialNo }; // Globals to keep track of NS Library database Boolean gNSLValid = false; MNSDatabadeRef gRef; // // Network Setup Library prototypes // // General Boolean RemoteVersionAcceptable(UInt32 version); #ifdef USE_NETWORK_SETUP short SysVersForNSL(void); Boolean IsNSBroken(void); OSErr GetCurrentPortNameFromDatabase(char *portNameLong, char *portName, Boolean *enabled); OSErr ReEnableNSLibrary(void); OSErr FindNSLibrary(short vRef, long dirId, FSSpecPtr spec); // OT/PPP and MacSLIP cooperation static OSStatus GetDialingInfoFromRemoteEntity(const MNSDatabadeRef *ref, const CfgEntityRef *entityID, Boolean *redial, unsigned long *numRedials, unsigned long *delay); static OSStatus GetPortNameFromTCPEntity(const MNSDatabadeRef *ref, const CfgEntityRef *entityID, unsigned char *longPortName, char *portName, Boolean *enabled); static OSStatus FindCurrentConnection(const MNSDatabadeRef *ref, OSType protocol, CfgEntityRef *currentEntity); #endif //USE_NETWORK_SETUP // TCPWillDial static OSStatus NSHTCPWillDial(UInt32 *willDial); static OSStatus GetTCPInfo(Boolean *enabled, unsigned char *portNameLong, char *portName); static OSStatus GetPortNameFromTCPPrefs(Ptr buffer, SInt32 prefSize, char *portName); static void UnpackTCPPrefs(Ptr *buffer, NSHTCPv4ConfigurationDigest *configurationDigest); /********************************************************************************* * UseNetworkSetup - return true if the Network Setup Library is to be used. *********************************************************************************/ Boolean UseNetworkSetup(void) { Boolean useIt = false; #ifdef USE_NETWORK_SETUP // NS Library must be used if the OS version is greater than 8.6 if (SysVersForNSL() > 0x0860) { if (IsNetworkSetupAvailable()) { useIt = true; gMissingNSLib = false; // the Netw