// =========================================================================== // UAMUtils.h © 1997 Microsoft Corp. All rights reserved. // =========================================================================== #pragma once #include "ClientUAM.h" #define PSTR_DEFAULT_WORKSTATION_NAME "\pMacintosh" #define STR_ChooserUserName -16096 //User name set in sharing setup #define STR_Sys7WorkStationName -16413 //Workstation (computer) name set in sharing setup #define PSTR_LENGTH(s) s[0] // //This macro "does the right thing" when calling any callback functions. The method //for calling these fuctions is different depending on what platform we're building //for. // #if defined(UAM_TARGET_PPC) && !defined(UAM_TARGET_CARBON) #define UAM_CALLBACK_ONEPARAM(procPtr, procInfo, param) \ CallUniversalProc(procPtr, procInfo, param) #define UAM_CALLBACK_TWOPARAM(procPtr, procInfo, param1, param2) \ CallUniversalProc(procPtr, procInfo, param1, param2) #define UAM_CALLBACK_THREEPARAM(procPtr, procInfo, param1, param2, param3) \ CallUniversalProc(procPtr, procInfo, param1, param2, param3) #else //Must be Carbon PPC or 68K #define UAM_CALLBACK_ONEPARAM(procPtr, procInfo, param) \ procPtr(param) #define UAM_CALLBACK_TWOPARAM(procPtr, procInfo, param1, param2) \ procPtr(param1, param2) #define UAM_CALLBACK_THREEPARAM(procPtr, procInfo, param1, param2, param3) \ procPtr(param1, param2, param3) #endif // //In carbon, c2pstr and p2cstr are not defined. So these macros help //us go between carbon and Mac68K. // #ifdef UAM_TARGET_CARBON #define _c2pstr(c) UAM_CToPStr(c) #define _p2cstr(p) UAM_PToCStr(p) #else #define _c2pstr(c) c2pstr(c) #define _p2cstr(p) p2cstr(p) #endif // //Some help with the differences in OT from Classic to Carbon // #ifdef UAM_TARGET_CARBON #define UAMInitOpenTransport(flags,cntx) InitOpenTransportInContext(flags, cntx); #define UAMCloseOpenTransport(cntx) CloseOpenTransportInContext(cntx); #define UAMOTOpenEndpoint(config,oflag,info,err) OTOpenEndpointInContext(config,oflag,info,err,NULL); #else #define UAMInitOpenTransport(flags,cntx) InitOpenTransport(); #define UAMCloseOpenTransport(cntx) CloseOpenTransport(); #define UAMOTOpenEndpoint(config,oflag,info,err) OTOpenEndpoint(config,oflag,info,err); #endif #define _min(a,b) (((a) < (b)) ? (a) : (b)) #define _max(a,b) (((a) > (b)) ? (a) : (b)) // //Help with bitmaps... // #define BIT_0 0x1 #define BIT_1 0x2 #define BIT_2 0x4 #define BIT_3 0x8 #define BIT_4 0x10 #define BIT_5 0x20 #define BIT_6 0x40 #define BIT_7 0x80 #define BIT_8 0x100 // //Some keycodes in keymap form // #define KEY_Shift 0x38 #define KEY_Command 0x37 #define KEY_Option 0x3A #define KEY_Control 0x3B // //Event key code types. // #define UAMKey_Home 0x01 #define UAMKey_Enter 0x03 #define UAMKey_End 0x04 #define UAMKey_PageUp 0x0B #define UAMKey_PageDown 0x0C #define UAMKey_BackDel 0x08 #define UAMKey_Tab 0x09 #define UAMKey_Escape 0x1b #define UAMKey_Left 0x1c #define UAMKey_Right 0x1d #define UAMKey_Up 0x1e #define UAMKey_Down 0x1f #define UAMKey_Return 0x0d #define UAMKey_Space 0x20 #define UAMKey_FirstExtended 0x80 #define UAMKey_FwdDel 0x7f #define UAMKey_Period '.' // //Struct for accessing server info after a ASPGetStatus call. This is the //header information provided from the call. See Inside Appletalk p. 13-95/97 // typedef struct { short machineTypeOffset; short afpVersionOffset; short supportedUAMOffset; short volumeIconOffset; short serverFlags; }ServerInfoReplyBlock, *ServerInfoReplyBlockP; #ifdef UAM_TARGET_CARBON struct AFPSrvrInfo { short fMachineOffset; short fVerCountOffset; short fUAMCountOffset; short fIconOffset; short fFlags; unsigned char fSrvrName[2]; }; typedef struct AFPSrvrInfo AFPSrvrInfo; #endif // //Enums for supported UAMs on the server. // enum { kGuestSupported = 0x1, kClearTxtSupported = 0x2, kMSUAMSupported = 0x4, kMSUAM_V2_Supported = 0x8, kMSUAM_V3_Supported = 0x10 }; // //Returns TRUE if the server we're authenticating with only //supports v2. // #define SUPPORTS_MS20_ONLY(bits) (((bits & kMSUAM_V2_Supported)!=0) && ((bits & kMSUAM_V3_Supported)==0)) // //Help with types... // typedef long Int32; typedef short Int16; struct Address8022 { OTAddressType fAddrFamily; UInt8 fHWAddr[k48BitAddrLength]; UInt16 fSAP; UInt8 fSNAP[k8022SNAPLength]; }; #define OT_SUCCESS(c) (((c) >= 0) ? true : false) // //Prototypes for utility functions live here. // StringPtr UAM_CToPStr(char* ioStr); char* UAM_PToCStr(StringPtr ioStr); void UAM_PStrCopy(const Str255 inSrcString, StringPtr inDestString, SInt16 inMaxLength = sizeof(Str255)); void UAM_AppendPStr(Str255 inBase, const Str255 inAppendStr, short inDestSize); void UAM_GetUserName(StringPtr outUserName); void UAM_GetWorkStationName(Str255 outWSName); Boolean UAM_AFPClientSupportsOurUAM(void); void UAM_VersionString(Str32 outVersionString); void UAM_GetAFPVersionString(AFPSrvrInfo *inInfo, ClientUAMCallbackRec *inCallbacks, Str32 ioAFPVersion, Str32 ioDefaultUserName ); Boolean UAM_VerifyServerInfo( AFPSrvrInfo* inReplyInfo ); void UAM_GetSupportedUAMS(UAMArgs* inUAMArgs, StringPtr inAFPVersion, long *ioSupported); Boolean UAM_FindStringInBuffer(StringPtr inString, StringPtr inBuffer, short inBufferSize); short UAM_AppleShareVersion(short *upperWord); Boolean UAM_KeyDown(Int16 inKeycode); Boolean UAM_ExtractDomainName(char* inUserName, char* outDomainName, SInt16 cbDomainName); Boolean UAM_ExtractUserName(char* inUserName, char* outUserName, SInt16 cbOutUserName); OSStatus UAM_GetEthernetAddress(Str255 outAddress);