windows-nt/Source/XPSP1/NT/net/sfm/uam/uam5src/uamsrc/uamutils.c

1 line
9.8 KiB
C
Raw Permalink Normal View History

2020-09-26 03:20:57 -05:00
// =========================================================================== // UAMUtils.cp <09> 1997 Microsoft Corp. All rights reserved. // =========================================================================== // General utilities used by the Microsoft User Authentication Method. // // =========================================================================== #include <Errors.h> #include <String.h> #include <stdio.h> #include "UAMDebug.h" #include "UAMUtils.h" #include "UAMNetwork.h" #include "UAMDialogs.h" // --------------------------------------------------------------------------- // <09> UAM_PStrCopy() // --------------------------------------------------------------------------- // Custom routine for copying pascal style strings. Copies inSrcString into // inDestString. Careful here since this routine doesn't know how long a // string can be, don't copy a 255 byte string into a 32 byte string. BOOM! void UAM_PStrCopy(const StringPtr inSrcString, StringPtr inDestString) { Assert_(inSrcString != NULL); Assert_(inDestString != NULL); BlockMove(inSrcString, inDestString, inSrcString[0] + 1); inDestString[0] = inSrcString[0]; } // --------------------------------------------------------------------------- // <09> 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) { Assert_(inBase != NULL); Assert_(inAppendStr != NULL); Assert_(inDestSize > 0); 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- // --------------------------------------------------------------------------- // <09> UAM_FrontWindowRect() // --------------------------------------------------------------------------- // Returns the rect of the front-most window is global coordinates. void UAM_FrontWindowRect(Rect *outWindowRect) { WindowPtr theWindow = FrontWindow(); Point thePoint; Rect theRect; theRect = theWindow->portRect; thePoint.h = theWindow->portRect.left; thePoint.v = theWindow->portRect.top; LocalToGlobal(&thePoint); theRect.left = thePoint.h; theRect.top = thePoint.v; thePoint.h = theWindow->portRect.right; thePoint.v = theWindow->portRect.bottom; LocalToGlobal(&thePoint); theRect.right = thePoint.h; theRect.bottom = thePoint.v; *outWindowRect = theRect; } // --------------------------------------------------------------------------- // <09> 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); } } // --------------------------------------------------------------------------- // <09> UAM_GetWorkStationName() // --------------------------------------------------------------------------- // Returns the workstation name as set in the Sharing Setup/File Sharing // dialogs. void UAM_GetWorkStationName(Str255 outWSName) { StringHandle theString = NULL; outWSName[0] = 0; theString = GetString(STR_Sys7WorkStationName); if (theString != NULL) { HLock((Handle)theString); UAM_PStrCopy(*theString, outWSName); HUnlock((Handle)theString); } } // --------------------------------------------------------------------------- // <09> UAM_AFPClientSupportsOurUAM // --------------------------------------------------------------------------- // Returns TRUE if the client we're on is running AppleShare