| 
									
										
										
										
											2012-05-22 17:09:48 +00:00
										 |  |  | #include <QDebug>
 | 
					
						
							| 
									
										
										
										
											2013-07-19 00:44:48 +00:00
										 |  |  | #include <QString>
 | 
					
						
							|  |  |  | #include <QSharedMemory>
 | 
					
						
							| 
									
										
										
										
											2012-05-22 17:09:48 +00:00
										 |  |  | #include <QSystemSemaphore>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-17 20:29:55 +00:00
										 |  |  | #include "../commons.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-19 00:23:40 +00:00
										 |  |  | // Multiple instances: KK1D, 17 Jul 2013
 | 
					
						
							| 
									
										
										
										
											2013-07-19 00:44:48 +00:00
										 |  |  | QSharedMemory mem_jt9; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Semaphore not changed, as the acquire/release calls do not 
 | 
					
						
							|  |  |  | // appear to be used anywhere.  
 | 
					
						
							| 
									
										
										
										
											2012-11-21 17:42:53 +00:00
										 |  |  | QSystemSemaphore sem_jt9("sem_jt9", 1, QSystemSemaphore::Open); | 
					
						
							| 
									
										
										
										
											2012-05-22 17:09:48 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							| 
									
										
										
										
											2012-11-21 17:42:53 +00:00
										 |  |  |   bool attach_jt9_(); | 
					
						
							|  |  |  |   bool create_jt9_(int nsize); | 
					
						
							|  |  |  |   bool detach_jt9_(); | 
					
						
							|  |  |  |   bool lock_jt9_(); | 
					
						
							|  |  |  |   bool unlock_jt9_(); | 
					
						
							| 
									
										
										
										
											2015-12-17 20:29:55 +00:00
										 |  |  |   struct jt9com * address_jt9_(); | 
					
						
							| 
									
										
										
										
											2012-11-21 17:42:53 +00:00
										 |  |  |   int size_jt9_(); | 
					
						
							| 
									
										
										
										
											2013-07-19 00:44:48 +00:00
										 |  |  | // Multiple instances:  wrapper for QSharedMemory::setKey()
 | 
					
						
							|  |  |  |   bool setkey_jt9_(char* mykey, int mykey_len); | 
					
						
							| 
									
										
										
										
											2012-05-22 17:09:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-21 17:42:53 +00:00
										 |  |  |   bool acquire_jt9_(); | 
					
						
							|  |  |  |   bool release_jt9_(); | 
					
						
							| 
									
										
										
										
											2012-05-22 17:09:48 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-21 17:42:53 +00:00
										 |  |  | bool attach_jt9_() {return mem_jt9.attach();} | 
					
						
							|  |  |  | bool create_jt9_(int nsize) {return mem_jt9.create(nsize);} | 
					
						
							|  |  |  | bool detach_jt9_() {return mem_jt9.detach();} | 
					
						
							|  |  |  | bool lock_jt9_() {return mem_jt9.lock();} | 
					
						
							|  |  |  | bool unlock_jt9_() {return mem_jt9.unlock();} | 
					
						
							| 
									
										
										
										
											2015-12-17 20:29:55 +00:00
										 |  |  | struct jt9com * address_jt9_() {return reinterpret_cast<struct jt9com *>(mem_jt9.data());} | 
					
						
							| 
									
										
										
										
											2012-11-21 17:42:53 +00:00
										 |  |  | int size_jt9_() {return (int)mem_jt9.size();} | 
					
						
							| 
									
										
										
										
											2012-05-22 17:09:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-19 00:44:48 +00:00
										 |  |  | // Multiple instances:
 | 
					
						
							|  |  |  | bool setkey_jt9_(char* mykey, int mykey_len) { | 
					
						
							|  |  |  |    char *tempstr = (char *)calloc(mykey_len+1,1); | 
					
						
							|  |  |  |    memset(tempstr, 0, mykey_len+1); | 
					
						
							|  |  |  |    strncpy(tempstr, mykey, mykey_len); | 
					
						
							|  |  |  |    QString s1 = QString(QLatin1String(tempstr)); | 
					
						
							|  |  |  |    mem_jt9.setKey(s1); | 
					
						
							|  |  |  |    return true;} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-21 17:42:53 +00:00
										 |  |  | bool acquire_jt9_() {return sem_jt9.acquire();} | 
					
						
							|  |  |  | bool release_jt9_() {return sem_jt9.release();} |