Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
23 KiB

  1. // =========================================================================== // UAMUtils.cp � 1997 Microsoft Corp. All rights reserved. // =========================================================================== // General utilities used by the Microsoft User Authentication Method. // // =========================================================================== #ifdef UAM_TARGET_CARBON #include <Carbon/Carbon.h> #include <CoreServices/CoreServices.h> #else #include <OpenTransport.h> #include <OpenTptLinks.h> #include <OpenTptConfig.h> #endif #include <String.h> #include <stdio.h> #include <ctype.h> #include <macstrsafe.h> #include "UAMUtils.h" #include "UAMNetwork.h" #include "UAMDialogs.h" #include "UAMDebug.h" // --------------------------------------------------------------------------- // � UAM_CToPStr() // --------------------------------------------------------------------------- // In carbon, c2pstr is not supported. Roll our own. // // This should usually be called using the _c2pstr macro. StringPtr UAM_CToPStr(char* ioStr) { if (ioStr != nil) { UInt8 theLen = strlen(ioStr); BlockMoveData(ioStr, ioStr+1, theLen); ioStr[0] = (char)theLen; } return((StringPtr)ioStr); } // --------------------------------------------------------------------------- // � UAM_PToCStr() // --------------------------------------------------------------------------- // In carbon, p2cstr is not supported. Roll our own. // // This should usually be called using the _p2cstr macro. char* UAM_PToCStr(StringPtr ioStr) { if (ioStr != nil) { UInt8 theLen = PSTR_LENGTH(ioStr); BlockMoveData(ioStr+1, ioStr, theLen); ioStr[theLen] = 0; } return((char*)ioStr); } // --------------------------------------------------------------------------- // � UAM_PStrCopy() // --------------------------------------------------------------------------- // Custom routine for copying pascal style strings. Copies inSrcString into // inDestString. // void UAM_PStrCopy(const Str255 inSrcString, StringPtr inDestString, SInt16 inMaxLength) { // //01.16.02: Add check for string length. Default to 256 bytes max length. // Size theAmountToCopy = PSTR_LENGTH(inSrcString) + 1; theAmountToCopy = (theAmountToCopy > inMaxLength) ? inMaxLength : theAmountToCopy; BlockMove(inSrcString, inDestString, theAmountToCopy); inDestString[0] = inSrcString[0]; } // --------------------------------------------------------------------------- // � UAM_AppendPStr() // --------------------------------------------------------------------------- // Custom routine for appending one pascal style string to another. // inAppendStr in pasted to the end of inBase. inDestSize if the maximum size // the new string can be. void UAM_AppendPStr(Str255 inBase, const Str255 inAppendStr, short inDestSize) { short charsToCopy = inAppendStr[0]; if ((inBase[0] + charsToCopy) > (inDestSize - 1)) { charsToCopy = inDestSize - 1 - inBase[0]; } BlockMove(inAppendStr + 1, inBase + inBase[0] + 1, charsToCopy); inBase[0] += charsToCopy; } #pragma mark- // --------------------------------------------------------------------------- // � UAM_GetUserName() // --------------------------------------------------------------------------- // Returns the default user name as set in the Sharing Setup/File Sharing // dialogs. This would also be considered the old 'Chooser' name. void UAM_GetUserName(StringPtr outUserName) { StringHandle theString = NULL; outUserName[0] = 0; theString = GetString(STR_ChooserUserName); if (theString != NULL) { UAM_PStrCopy(*theString, outUserName); } } // --------------------------------------------------------------------------- // � UAM_GetWorkStationName() // --------------------------------------------------------------------------- // Returns the workstation name as set in the Sharing Setup/File Sharing // dialogs. void UAM_GetWorkStationName(Str255 outWSName) { StringHandle theString = NULL; Str255 theAddress; // //We assume failure here, if it fails, the user hasn't entered //a