bug #42100, Carbon compatibility. r=gordon, saari, pinkerton, sfraser NSPRPUB_CLIENT_BRANCH
authorbeard%netscape.com
Tue, 20 Jun 2000 23:03:43 +0000
branchNSPRPUB_CLIENT_BRANCH
changeset 1426 8e19b8106d38e498d051a62d018aa0da703391df
parent 1416 e8f9045d6f6267ffdf6743ebdd1f1c703105148f
child 1427 34e09ee292164170d928b37ac0cc2667083f5d15
push idunknown
push userunknown
push dateunknown
reviewersgordon, saari, pinkerton, sfraser
bugs42100
bug #42100, Carbon compatibility. r=gordon, saari, pinkerton, sfraser
pr/src/md/mac/macdll.c
pr/src/md/mac/macsockotpt.c
pr/src/md/mac/mdmac.c
--- a/pr/src/md/mac/macdll.c
+++ b/pr/src/md/mac/macdll.c
@@ -533,16 +533,18 @@ OSErr NSLoadIndexedFragment(const FSSpec
 	if (fragNameBlock)
 	{
 		UInt32 nameLen = strlen(fragNameBlock);
 		if (nameLen > 63)
 			nameLen = 63;
 		BlockMoveData(fragNameBlock, &fragName[1], nameLen);
 		fragName[0] = nameLen;
 	}
+	
+	// DebugStr(fragName);
 
 	err = GetDiskFragment(fileSpec, fragOffset, fragLength, fragName, 
 					kLoadCFrag, outConnectionID, &main, errName);
 	if (err != noErr)
 	{
 		free(fragNameBlock);
 		return err;
 	}
--- a/pr/src/md/mac/macsockotpt.c
+++ b/pr/src/md/mac/macsockotpt.c
@@ -49,45 +49,41 @@ static struct {
 	InetSvcRef  serviceRef;
 	PRThread *  thread;
 	void *      cookie;
 } dnsContext;
 
 static PRBool gOTInitialized;
 
 static pascal void  DNSNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie);
-static pascal void  NotifierRoutine(void * contextPtr, OTEventCode code, 
-            OTResult result, void * cookie);
+static pascal void  NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie);
+static pascal void  RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie);
 
 static PRBool GetState(PRFileDesc *fd, PRBool *readReady, PRBool *writeReady, PRBool *exceptReady);
 
 extern void WaitOnThisThread(PRThread *thread, PRIntervalTime timeout);
 extern void DoneWaitingOnThisThread(PRThread *thread);
 
 #if TARGET_CARBON
 OTClientContextPtr  clientContext = NULL;
 
-OTNotifyUPP	DNSNotifierRoutineUPP;
-OTNotifyUPP notifierRoutineUPP;
-
-#define DNS_NOTIFIER_ROUTINE	DNSNotifierRoutineUPP
-#define NOTIFIER_ROUTINE		notifierRoutineUPP
-#define INIT_OPEN_TRANSPORT()	InitOpenTransport(clientContext, kInitOTForExtensionMask)
-#define OT_OPEN_INTERNET_SERVICES(config, flags, err)	OTOpenInternetServices(config, flags, err, clientContext)
-#define OT_OPEN_ENDPOINT(config, flags, info, err)		OTOpenEndpoint(config, flags, info, err, clientContext)
+#define INIT_OPEN_TRANSPORT()	InitOpenTransportInContext(kInitOTForExtensionMask, &clientContext)
+#define OT_OPEN_INTERNET_SERVICES(config, flags, err)	OTOpenInternetServicesInContext(config, flags, err, clientContext)
+#define OT_OPEN_ENDPOINT(config, flags, info, err)		OTOpenEndpointInContext(config, flags, info, err, clientContext)
 
 #else
 
-#define DNS_NOTIFIER_ROUTINE	DNSNotifierRoutine
-#define NOTIFIER_ROUTINE		NotifierRoutine
 #define INIT_OPEN_TRANSPORT()	InitOpenTransport()
 #define OT_OPEN_INTERNET_SERVICES(config, flags, err)	OTOpenInternetServices(config, flags, err)
 #define OT_OPEN_ENDPOINT(config, flags, info, err)		OTOpenEndpoint(config, flags, info, err)
 #endif /* TARGET_CARBON */
 
+static OTNotifyUPP	DNSNotifierRoutineUPP;
+static OTNotifyUPP NotifierRoutineUPP;
+static OTNotifyUPP RawEndpointNotifierRoutineUPP;
 
 void _MD_InitNetAccess()
 {
     OSErr       err;
     OSStatus    errOT;
     PRBool      hasOTTCPIP = PR_FALSE;
     PRBool      hasOT = PR_FALSE;
     long        gestaltResult;
@@ -98,24 +94,19 @@ void _MD_InitNetAccess()
             hasOT = PR_TRUE;
     
     if (hasOT)
         if (gestaltResult & GESTALT_OPEN_TPT_TCP_PRESENT)
             hasOTTCPIP = PR_TRUE;
         
     PR_ASSERT(hasOTTCPIP == PR_TRUE);
 
-#if TARGET_CARBON
     DNSNotifierRoutineUPP	=  NewOTNotifyUPP(DNSNotifierRoutine);
-    notifierRoutineUPP		=  NewOTNotifyUPP(NotifierRoutine);
-
-    errOT = OTAllocClientContext((UInt32)0, &clientContext);
-    PR_ASSERT(err == kOTNoError);
-#endif
-
+    NotifierRoutineUPP		=  NewOTNotifyUPP(NotifierRoutine);
+    RawEndpointNotifierRoutineUPP = NewOTNotifyUPP(RawEndpointNotifierRoutine);
 
     errOT = INIT_OPEN_TRANSPORT();
     PR_ASSERT(err == kOTNoError);
 
 	dnsContext.lock = PR_NewLock();
 	PR_ASSERT(dnsContext.lock != NULL);
 
 	dnsContext.thread = _PR_MD_CURRENT_THREAD();
@@ -130,28 +121,28 @@ static void _MD_FinishInitNetAccess()
 {
     OSStatus    errOT;
 
     dnsContext.serviceRef = OT_OPEN_INTERNET_SERVICES(kDefaultInternetServicesPath, NULL, &errOT);
     if (errOT != kOTNoError) return;    /* no network -- oh well */
     PR_ASSERT((dnsContext.serviceRef != NULL) && (errOT == kOTNoError));
 
     /* Install notify function for DNR Address To String completion */
-    errOT = OTInstallNotifier(dnsContext.serviceRef, DNS_NOTIFIER_ROUTINE, &dnsContext);
+    errOT = OTInstallNotifier(dnsContext.serviceRef, DNSNotifierRoutineUPP, &dnsContext);
     PR_ASSERT(errOT == kOTNoError);
 
     /* Put us into async mode */
     errOT = OTSetAsynchronous(dnsContext.serviceRef);
     PR_ASSERT(errOT == kOTNoError);
     
     gOTInitialized = PR_TRUE;
 }
 
 
-pascal void  DNSNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
+static pascal void  DNSNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
 {
 #pragma unused(contextPtr)
     _PRCPU *    cpu    = _PR_MD_CURRENT_CPU(); 
 	
 	if (code == T_DNRSTRINGTOADDRCOMPLETE) {
 		dnsContext.thread->md.osErrCode = result;
 		dnsContext.cookie = cookie;
 		if (_PR_MD_GET_INTSOFF()) {
@@ -263,17 +254,17 @@ WakeUpNotifiedThread(PRThread *thread, O
 		}
 		DoneWaitingOnThisThread(thread);
 	}
 }
 
 // Notification routine
 // Async callback routine.
 // A5 is OK. Cannot allocate memory here
-pascal void  NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
+static pascal void  NotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
 {
 	PRFilePrivate *secret  = (PRFilePrivate *) contextPtr;
 	_MDFileDesc * md       = &(secret->md);
 	EndpointRef   endpoint = (EndpointRef)secret->md.osfd;
     PRThread *    thread   = NULL;
 	OSStatus      err;
 	OTResult	  resultOT;
     TDiscon		  discon;
@@ -1038,17 +1029,17 @@ typedef struct RawEndpointAndThread
 {
 	PRThread *  thread;
 	EndpointRef endpoint;
 } RawEndpointAndThread;
 
 // Notification routine for raw endpoints not yet attached to a PRFileDesc.
 // Async callback routine.
 // A5 is OK. Cannot allocate memory here
-pascal void  RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
+static pascal void  RawEndpointNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie)
 {
 	RawEndpointAndThread *endthr = (RawEndpointAndThread *) contextPtr;
     PRThread *    thread   = endthr->thread;
     EndpointRef * endpoint = endthr->endpoint;
     _PRCPU *      cpu      = _PR_MD_CURRENT_CPU(); 
 	OSStatus      err;
 	OTResult	  resultOT;
 
@@ -1195,17 +1186,17 @@ PRInt32 _MD_accept(PRFileDesc *fd, PRNet
     if (newosfd == -1)
         return -1;
             
 	// Attach the raw endpoint handler to this endpoint for now.
 	endthr = (RawEndpointAndThread *) PR_Malloc(sizeof(RawEndpointAndThread));
 	endthr->thread = me;
 	endthr->endpoint = (EndpointRef) newosfd;
 	
-	err = OTInstallNotifier((ProviderRef) newosfd, RawEndpointNotifierRoutine, endthr);
+	err = OTInstallNotifier((ProviderRef) newosfd, RawEndpointNotifierRoutineUPP, endthr);
     PR_ASSERT(err == kOTNoError);
     
 	err = OTSetAsynchronous((EndpointRef) newosfd);
 	PR_ASSERT(err == kOTNoError);
 
     // Bind to a local port; let the system assign it.
     bindAddr.inet.family = AF_INET;
     bindAddr.inet.port = bindAddr.inet.ip = 0;
@@ -1794,17 +1785,17 @@ void _MD_makenonblock(PRFileDesc *fd)
 	OSStatus	err;
 	
 	// Install fd->secret as the contextPtr for the Notifier function associated with this 
 	// endpoint. We use this instead of the fd itself because:
 	//            (a) in cases where you import I/O layers, the containing 
 	//                fd changes, but the secret structure does not;
 	//            (b) the notifier func refers only to the secret data structure
 	//                anyway.
-	err = OTInstallNotifier(endpointRef, NOTIFIER_ROUTINE, fd->secret);
+	err = OTInstallNotifier(endpointRef, NotifierRoutineUPP, fd->secret);
 	PR_ASSERT(err == kOTNoError);
 	
 	// Now that we have a NotifierRoutine installed, we can make the endpoint asynchronous
 	err = OTSetAsynchronous(endpointRef);
 	PR_ASSERT(err == kOTNoError);
 }
 
 
--- a/pr/src/md/mac/mdmac.c
+++ b/pr/src/md/mac/mdmac.c
@@ -339,17 +339,17 @@ void PR_InitMemory(void) {
 //	THIS IS *** VERY *** IMPORTANT... our CFM Termination proc.
 //	This allows us to deactivate our Time Mananger task even
 //	if we are not totally gracefully exited.  If this is not
 //	done then we will randomly crash at later times when the
 //	task is called after the app heap is gone.
 
 #if TARGET_CARBON
 extern OTClientContextPtr	clientContext;
-#define CLOSE_OPEN_TRANSPORT()	CloseOpenTransport(clientContext)
+#define CLOSE_OPEN_TRANSPORT()	CloseOpenTransportInContext(clientContext)
 
 #else
 
 #define CLOSE_OPEN_TRANSPORT()	CloseOpenTransport()
 #endif /* TARGET_CARBON */
 
 extern pascal void __NSTerminate(void);
 
@@ -734,16 +734,16 @@ extern long _MD_GetOSVersion(char *buf, 
 
 	return 0;
 }
 
 extern long _MD_GetArchitecture(char *buf, long count)
 {
 	long	len;
 	
-#if defined(GENERATINGPOWERPC) && GENERATINGPOWERPC	
+#if defined(TARGET_CPU_PPC) && TARGET_CPU_PPC	
 	len = PR_snprintf(buf, count, "PowerPC");
 #else
 	len = PR_snprintf(buf, count, "Motorola68k");
 #endif
 
 	return 0;
 }