[Arakhnę-Dev] [104] Bug fix: force to define __WINDOWS__ macro according to the compiler' s macros dedicated to the type of operating system.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 104
Author:   galland
Date:     2009-12-24 00:12:49 +0100 (Thu, 24 Dec 2009)
Log Message:
-----------
Bug fix: force to define __WINDOWS__ macro according to the compiler's macros dedicated to the type of operating system.

Modified Paths:
--------------
    trunk/arakhneVmutils/native/josuuid/src/main/native/josuuid.cpp
    trunk/arakhneVmutils/native/josuuid/src/main/native/josuuid.h
    trunk/arakhneVmutils/native/josuuid/src/main/native/winos.cpp
    trunk/arakhneVmutils/native/josuuid/src/main/native/winos.h

Added Paths:
-----------
    trunk/arakhneVmutils/native/josuuid/src/main/native/osmacro.h

Modified: trunk/arakhneVmutils/native/josuuid/src/main/native/josuuid.cpp
===================================================================
--- trunk/arakhneVmutils/native/josuuid/src/main/native/josuuid.cpp	2009-12-23 23:12:05 UTC (rev 103)
+++ trunk/arakhneVmutils/native/josuuid/src/main/native/josuuid.cpp	2009-12-23 23:12:49 UTC (rev 104)
@@ -28,6 +28,8 @@
 #include <string.h>
 #include <ctype.h>
 
+#include "osmacro.h"
+
 #ifdef __WINDOWS__
 # include <windows.h>
 # include "winos.h"

Modified: trunk/arakhneVmutils/native/josuuid/src/main/native/josuuid.h
===================================================================
--- trunk/arakhneVmutils/native/josuuid/src/main/native/josuuid.h	2009-12-23 23:12:05 UTC (rev 103)
+++ trunk/arakhneVmutils/native/josuuid/src/main/native/josuuid.h	2009-12-23 23:12:49 UTC (rev 104)
@@ -1,7 +1,7 @@
 /* 
  * $Id$
  * 
- * Copyright (C) 2005-2008 St&eacute;phane GALLAND
+ * Copyright (C) 2005-2009 St&eacute;phane GALLAND
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,8 @@
 #ifndef __JOSUUID_H__
 #  define __JOSUUID_H__
 
+#  include "osmacro.h"
+
 /* Replies the serial number of the system */
 char* getOSSerial();
 

Added: trunk/arakhneVmutils/native/josuuid/src/main/native/osmacro.h
===================================================================
--- trunk/arakhneVmutils/native/josuuid/src/main/native/osmacro.h	                        (rev 0)
+++ trunk/arakhneVmutils/native/josuuid/src/main/native/osmacro.h	2009-12-23 23:12:49 UTC (rev 104)
@@ -0,0 +1,33 @@
+/* 
+ * $Id$
+ * 
+ * Copyright (C) 2009 St&eacute;phane GALLAND
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * This program is free software; you can redistribute it and/or modify
+ */
+ 
+#ifndef __OSMACRO_H__
+#  define __OSMACRO_H__
+
+#  if defined(WINDOWS) || defined(WIN32) || defined(WIN64) || defined(WINNT)
+#    define __WINDOWS__
+#    undef __UNIX__
+#  else
+#    define __UNIX__
+#    undef __WINDOWS__
+#  endif
+
+#endif /* __OSMACRO_H__ */

Modified: trunk/arakhneVmutils/native/josuuid/src/main/native/winos.cpp
===================================================================
--- trunk/arakhneVmutils/native/josuuid/src/main/native/winos.cpp	2009-12-23 23:12:05 UTC (rev 103)
+++ trunk/arakhneVmutils/native/josuuid/src/main/native/winos.cpp	2009-12-23 23:12:49 UTC (rev 104)
@@ -1,7 +1,7 @@
 /* 
  * $Id$
  * 
- * Copyright (C) 2005-2008 St&eacute;phane GALLAND
+ * Copyright (C) 2005-2009 St&eacute;phane GALLAND
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -19,11 +19,15 @@
  * This program is free software; you can redistribute it and/or modify
  */
  
+#include "osmacro.h"
+ 
 #ifdef DEBUG
 # warning THE LIBRARY IS COMPILED WITH DEBUG INFORMATION
 #endif
 
-#ifdef __WINDOWS__
+#ifndef __WINDOWS__
+# error You may use Windows compiler
+#endif
 
 #include <windows.h>
 #include <winreg.h>
@@ -80,12 +84,12 @@
 } 
 
 /* Read the value of a registrery value */
-BOOL readRegistry(CHAR* key, CHAR* valueName, BYTE** data, DWORD* size) {
+BOOL readRegistry(const CHAR* key, const CHAR* valueName, BYTE** data, DWORD* size) {
 	return readRegistryI(key,valueName,data,size,1);
 }
 
 /* Read the value of a registrery value */
-BOOL readRegistryI(CHAR* key, CHAR* valueName, BYTE** data, DWORD* size, BYTE allocationFactor) {
+BOOL readRegistryI(const CHAR* key, const CHAR* valueName, BYTE** data, DWORD* size, BYTE allocationFactor) {
 	HKEY hKey = NULL;  // registry handle, kept open between calls
 	LONG ret;
 
@@ -144,15 +148,15 @@
 
 	CHAR* reg_path;  	
 	if ((version >=WNT_FIRST) && (version <= WNT_LAST))
-		reg_path = "Software\\Microsoft\\Windows NT\\CurrentVersion";
+		reg_path = (CHAR*)("Software\\Microsoft\\Windows NT\\CurrentVersion");
 	else
-	    reg_path = "Software\\Microsoft\\Windows\\CurrentVersion";
+	    reg_path = (CHAR*)("Software\\Microsoft\\Windows\\CurrentVersion");
   	
   	DWORD size = 0;
   	BYTE* data = NULL;
   	if (!readRegistryI(reg_path, "ProductId", &data, &size, allocationFactor)) {
   		if ((version >=WNT_FIRST) && (version <= WNT_LAST)) {
-	    	reg_path = "Software\\Microsoft\\Windows\\CurrentVersion";
+	    	reg_path = (CHAR*)("Software\\Microsoft\\Windows\\CurrentVersion");
 	    	if (!readRegistryI(reg_path, "ProductId", &data, &size, allocationFactor))
 	    		return false;
   		}
@@ -172,5 +176,3 @@
   	
   	return true;
 }
-
-#endif

Modified: trunk/arakhneVmutils/native/josuuid/src/main/native/winos.h
===================================================================
--- trunk/arakhneVmutils/native/josuuid/src/main/native/winos.h	2009-12-23 23:12:05 UTC (rev 103)
+++ trunk/arakhneVmutils/native/josuuid/src/main/native/winos.h	2009-12-23 23:12:49 UTC (rev 104)
@@ -1,7 +1,7 @@
 /* 
  * $Id$
  * 
- * Copyright (C) 2005-2008 St&eacute;phane GALLAND
+ * Copyright (C) 2005-2009 St&eacute;phane GALLAND
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,8 @@
 #ifndef __WINOS_H__
 #  define __WINOS_H__
 
+#  include "osmacro.h"
+
 #  define W9XFIRST    1
 #  define W95         1
 #  define W95SP1      2
@@ -59,10 +61,10 @@
 BOOL getWindowsVersion(DWORD *version);
 
 /* Read the value of a registrery value */
-BOOL readRegistry(CHAR* key, CHAR* valueName, BYTE** data, DWORD* size);
+BOOL readRegistry(const CHAR* key, const CHAR* valueName, BYTE** data, DWORD* size);
 
 /* Read the value of a registrery value */
-BOOL readRegistryI(CHAR* key, CHAR* valueName, BYTE** data, DWORD* size, BYTE allocationFactor);
+BOOL readRegistryI(const CHAR* key, const CHAR* valueName, BYTE** data, DWORD* size, BYTE allocationFactor);
 
 /* Replies the serial number of the system */
 BOOL getWindowsSerial(BYTE** serial, DWORD* serialSize);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/