- Timestamp:
- Aug 16, 2001, 8:13:24 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/capi2032/capi2032.cpp
r4507 r6550 1 /* $Id: capi2032.cpp,v 1. 5 2000-10-21 09:24:03sandervl Exp $ */1 /* $Id: capi2032.cpp,v 1.6 2001-08-16 18:13:24 sandervl Exp $ */ 2 2 3 3 /* … … 53 53 maxBDataBlocks, maxBDataLen, pApplID ); 54 54 55 SetFS(sel);56 55 if( dwResult ) 57 56 { 58 57 dprintf((" failed (%X)!\n", dwResult )); 58 SetFS(sel); 59 59 return(0x1108); 60 60 } 61 61 dprintf((" successfull (ApplID: %d)\n", *pApplID )); 62 62 63 // create named semaphore if neccessary 64 if( !hEvent ) 65 { 66 // create named semaphore with Application ID as last character sequenz 67 sprintf( szSemName, "\\SEM32\\CAPI2032\\SEM%d" , *pApplID ); 68 rc = DosCreateEventSem( szSemName, &hEvent, DC_SEM_SHARED, FALSE ); 69 if( rc ) 70 { 71 dprintf((" failed (DosCreateEventSem): %d!\n",rc)); 72 return 0x1108; // OS ressource error (error class 0x11..) 73 } 74 dprintf((" ok (DosCreateEventSem): hEvent:%d %s!\n", hEvent, szSemName)); 75 76 dwResult = CAPI_SET_SIGNAL( *pApplID, hEvent ); 77 if( dwResult ) 78 { 79 dprintf((" failed (CAPI_SET_SIGNAL: %X)!\n", dwResult)); 80 return 0x1108; // OS ressource error (error class 0x11..) 81 } 82 } 63 // create named semaphore with Application ID as last character sequenz 64 rc = DosCreateEventSem( szSemName, &hEvent, DC_SEM_SHARED, FALSE ); 65 if( rc ) 66 { 67 dprintf((" failed (DosCreateEventSem): %d!\n",rc)); 68 SetFS(sel); 69 return 0x1108; // OS ressource error (error class 0x11..) 70 } 71 dprintf((" ok (DosCreateEventSem): hEvent:%d %s!\n", hEvent, szSemName)); 72 73 dwResult = CAPI_SET_SIGNAL( *pApplID, hEvent ); 74 if( dwResult ) 75 { 76 dprintf((" failed (CAPI_SET_SIGNAL: %X)!\n", dwResult)); 77 SetFS(sel); 78 return 0x1108; // OS ressource error (error class 0x11..) 79 } 80 81 SetFS(sel); 83 82 return dwResult; 84 83 } … … 97 96 dprintf(("CAPI2032: CAPI_RELEASE (ApplID: %d)\n", ApplID)); 98 97 99 // open semaphore 98 // open semaphore ( get the event Handle ) 100 99 sprintf( szSemName, "\\SEM32\\CAPI2032\\SEM%d" , ApplID ); 100 101 // enter critical section, so no other thread can access the sem 102 DosEnterCritSec(); 103 // open semaphore to get the event handle 101 104 rc = DosOpenEventSem( szSemName, &hEvent ); 102 105 if(rc) … … 104 107 dprintf((" failed (DosOpenEventSem) rc: %d!\n",rc)); 105 108 } 109 // close semaphore, this will decrement the open count 110 DosCloseEventSem( hEvent ); 111 106 112 // cleanup 107 113 if( hEvent ) 108 114 { 109 115 dprintf(("(DosCloseEventSem) hEvent:%d %s!\n",hEvent, szSemName)); 116 // final cleanup semaphore. 110 117 rc = DosCloseEventSem( hEvent ); 111 hEvent = NULLHANDLE;112 118 if(rc) 113 119 { 114 120 dprintf((" failed (DosCloseEventSem) rc: %d!\n",rc)); 115 121 } 116 } 122 123 } 124 DosExitCritSec(); 125 117 126 dwResult = CAPI_RELEASE( ApplID ); 118 127 … … 171 180 dprintf(("CAPI2032: CAPI_WAIT_FOR_SIGNAL (ApplID: %d)", ApplID)); 172 181 173 // open semaphore174 182 sprintf( szSemName, "\\SEM32\\CAPI2032\\SEM%d" , ApplID ); 183 184 // enter critical section, so no other thread can access the sem 185 DosEnterCritSec(); 186 // open semaphore to get the event handle 175 187 rc = DosOpenEventSem( szSemName, &hEvent ); 176 188 if(rc) 177 189 { 190 DosExitCritSec(); 178 191 dprintf((" failed (DosOpenEventSem) rc: %d!\n",rc)); 179 192 return 0x1101; 180 193 } 194 // close semaphore 195 DosCloseEventSem( hEvent ); 196 DosExitCritSec(); 181 197 182 198 // wait for event
Note:
See TracChangeset
for help on using the changeset viewer.