celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [37/46] celix git commit: CELIX-417: Initial refactoring for CMake usage
Date Mon, 20 Nov 2017 20:33:34 GMT
http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/deployment_admin/src/unzip.h
----------------------------------------------------------------------
diff --git a/deployment_admin/src/unzip.h b/deployment_admin/src/unzip.h
new file mode 100644
index 0000000..3183968
--- /dev/null
+++ b/deployment_admin/src/unzip.h
@@ -0,0 +1,437 @@
+/* unzip.h -- IO for uncompress .zip files using zlib
+   Version 1.1, February 14h, 2010
+   part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
+
+         Modifications of Unzip for Zip64
+         Copyright (C) 2007-2008 Even Rouault
+
+         Modifications for Zip64 support on both zip and unzip
+         Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
+
+         For more info read MiniZip_info.txt
+
+         ---------------------------------------------------------------------------------
+
+        Condition of use and distribution are the same than zlib :
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  ---------------------------------------------------------------------------------
+
+        Changes
+
+        See header of unzip64.c
+
+*/
+
+#ifndef _unz64_H
+#define _unz64_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _ZLIB_H
+#include "zlib.h"
+#endif
+
+#ifndef  _ZLIBIOAPI_H
+#include "ioapi.h"
+#endif
+
+#ifdef HAVE_BZIP2
+#include "bzlib.h"
+#endif
+
+#define Z_BZIP2ED 12
+
+#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
+/* like the STRICT of WIN32, we define a pointer that cannot be converted
+    from (void*) without cast */
+typedef struct TagunzFile__ { int unused; } unzFile__;
+typedef unzFile__ *unzFile;
+#else
+typedef voidp unzFile;
+#endif
+
+
+#define UNZ_OK                          (0)
+#define UNZ_END_OF_LIST_OF_FILE         (-100)
+#define UNZ_ERRNO                       (Z_ERRNO)
+#define UNZ_EOF                         (0)
+#define UNZ_PARAMERROR                  (-102)
+#define UNZ_BADZIPFILE                  (-103)
+#define UNZ_INTERNALERROR               (-104)
+#define UNZ_CRCERROR                    (-105)
+
+/* tm_unz contain date/time info */
+typedef struct tm_unz_s
+{
+    uInt tm_sec;            /* seconds after the minute - [0,59] */
+    uInt tm_min;            /* minutes after the hour - [0,59] */
+    uInt tm_hour;           /* hours since midnight - [0,23] */
+    uInt tm_mday;           /* day of the month - [1,31] */
+    uInt tm_mon;            /* months since January - [0,11] */
+    uInt tm_year;           /* years - [1980..2044] */
+} tm_unz;
+
+/* unz_global_info structure contain global data about the ZIPfile
+   These data comes from the end of central dir */
+typedef struct unz_global_info64_s
+{
+    ZPOS64_T number_entry;         /* total number of entries in
+                                     the central dir on this disk */
+    uLong size_comment;         /* size of the global comment of the zipfile */
+} unz_global_info64;
+
+typedef struct unz_global_info_s
+{
+    uLong number_entry;         /* total number of entries in
+                                     the central dir on this disk */
+    uLong size_comment;         /* size of the global comment of the zipfile */
+} unz_global_info;
+
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_info64_s
+{
+    uLong version;              /* version made by                 2 bytes */
+    uLong version_needed;       /* version needed to extract       2 bytes */
+    uLong flag;                 /* general purpose bit flag        2 bytes */
+    uLong compression_method;   /* compression method              2 bytes */
+    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
+    uLong crc;                  /* crc-32                          4 bytes */
+    ZPOS64_T compressed_size;   /* compressed size                 8 bytes */
+    ZPOS64_T uncompressed_size; /* uncompressed size               8 bytes */
+    uLong size_filename;        /* filename length                 2 bytes */
+    uLong size_file_extra;      /* extra field length              2 bytes */
+    uLong size_file_comment;    /* file comment length             2 bytes */
+
+    uLong disk_num_start;       /* disk number start               2 bytes */
+    uLong internal_fa;          /* internal file attributes        2 bytes */
+    uLong external_fa;          /* external file attributes        4 bytes */
+
+    tm_unz tmu_date;
+} unz_file_info64;
+
+typedef struct unz_file_info_s
+{
+    uLong version;              /* version made by                 2 bytes */
+    uLong version_needed;       /* version needed to extract       2 bytes */
+    uLong flag;                 /* general purpose bit flag        2 bytes */
+    uLong compression_method;   /* compression method              2 bytes */
+    uLong dosDate;              /* last mod file date in Dos fmt   4 bytes */
+    uLong crc;                  /* crc-32                          4 bytes */
+    uLong compressed_size;      /* compressed size                 4 bytes */
+    uLong uncompressed_size;    /* uncompressed size               4 bytes */
+    uLong size_filename;        /* filename length                 2 bytes */
+    uLong size_file_extra;      /* extra field length              2 bytes */
+    uLong size_file_comment;    /* file comment length             2 bytes */
+
+    uLong disk_num_start;       /* disk number start               2 bytes */
+    uLong internal_fa;          /* internal file attributes        2 bytes */
+    uLong external_fa;          /* external file attributes        4 bytes */
+
+    tm_unz tmu_date;
+} unz_file_info;
+
+extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
+                                                 const char* fileName2,
+                                                 int iCaseSensitivity));
+/*
+   Compare two filename (fileName1,fileName2).
+   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
+   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
+                                or strcasecmp)
+   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
+    (like 1 on Unix, 2 on Windows)
+*/
+
+
+extern unzFile ZEXPORT unzOpen OF((const char *path));
+extern unzFile ZEXPORT unzOpen64 OF((const void *path));
+/*
+  Open a Zip file. path contain the full pathname (by example,
+     on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
+     "zlib/zlib113.zip".
+     If the zipfile cannot be opened (file don't exist or in not valid), the
+       return value is NULL.
+     Else, the return value is a unzFile Handle, usable with other function
+       of this unzip package.
+     the "64" function take a const void* pointer, because the path is just the
+       value passed to the open64_file_func callback.
+     Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path
+       is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char*
+       does not describe the reality
+*/
+
+
+extern unzFile ZEXPORT unzOpen2 OF((const char *path,
+                                    zlib_filefunc_def* pzlib_filefunc_def));
+/*
+   Open a Zip file, like unzOpen, but provide a set of file low level API
+      for read/write the zip file (see ioapi.h)
+*/
+
+extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
+                                    zlib_filefunc64_def* pzlib_filefunc_def));
+/*
+   Open a Zip file, like unz64Open, but provide a set of file low level API
+      for read/write the zip file (see ioapi.h)
+*/
+
+extern int ZEXPORT unzClose OF((unzFile file));
+/*
+  Close a ZipFile opened with unzipOpen.
+  If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
+    these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+  return UNZ_OK if there is no problem. */
+
+extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
+                                        unz_global_info *pglobal_info));
+
+extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
+                                        unz_global_info64 *pglobal_info));
+/*
+  Write info about the ZipFile in the *pglobal_info structure.
+  No preparation of the structure is needed
+  return UNZ_OK if there is no problem. */
+
+
+extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
+                                           char *szComment,
+                                           uLong uSizeBuf));
+/*
+  Get the global comment string of the ZipFile, in the szComment buffer.
+  uSizeBuf is the size of the szComment buffer.
+  return the number of byte copied or an error code <0
+*/
+
+
+/***************************************************************************/
+/* Unzip package allow you browse the directory of the zipfile */
+
+extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
+/*
+  Set the current file of the zipfile to the first file.
+  return UNZ_OK if there is no problem
+*/
+
+extern int ZEXPORT unzGoToNextFile OF((unzFile file));
+/*
+  Set the current file of the zipfile to the next file.
+  return UNZ_OK if there is no problem
+  return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
+*/
+
+extern int ZEXPORT unzLocateFile OF((unzFile file,
+                     const char *szFileName,
+                     int iCaseSensitivity));
+/*
+  Try locate the file szFileName in the zipfile.
+  For the iCaseSensitivity signification, see unzStringFileNameCompare
+
+  return value :
+  UNZ_OK if the file is found. It becomes the current file.
+  UNZ_END_OF_LIST_OF_FILE if the file is not found
+*/
+
+
+/* ****************************************** */
+/* Ryan supplied functions */
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_pos_s
+{
+    uLong pos_in_zip_directory;   /* offset in zip file directory */
+    uLong num_of_file;            /* # of file */
+} unz_file_pos;
+
+extern int ZEXPORT unzGetFilePos(
+    unzFile file,
+    unz_file_pos* file_pos);
+
+extern int ZEXPORT unzGoToFilePos(
+    unzFile file,
+    unz_file_pos* file_pos);
+
+typedef struct unz64_file_pos_s
+{
+    ZPOS64_T pos_in_zip_directory;   /* offset in zip file directory */
+    ZPOS64_T num_of_file;            /* # of file */
+} unz64_file_pos;
+
+extern int ZEXPORT unzGetFilePos64(
+    unzFile file,
+    unz64_file_pos* file_pos);
+
+extern int ZEXPORT unzGoToFilePos64(
+    unzFile file,
+    const unz64_file_pos* file_pos);
+
+/* ****************************************** */
+
+extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
+                         unz_file_info64 *pfile_info,
+                         char *szFileName,
+                         uLong fileNameBufferSize,
+                         void *extraField,
+                         uLong extraFieldBufferSize,
+                         char *szComment,
+                         uLong commentBufferSize));
+
+extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
+                         unz_file_info *pfile_info,
+                         char *szFileName,
+                         uLong fileNameBufferSize,
+                         void *extraField,
+                         uLong extraFieldBufferSize,
+                         char *szComment,
+                         uLong commentBufferSize));
+/*
+  Get Info about the current file
+  if pfile_info!=NULL, the *pfile_info structure will contain somes info about
+        the current file
+  if szFileName!=NULL, the filemane string will be copied in szFileName
+            (fileNameBufferSize is the size of the buffer)
+  if extraField!=NULL, the extra field information will be copied in extraField
+            (extraFieldBufferSize is the size of the buffer).
+            This is the Central-header version of the extra field
+  if szComment!=NULL, the comment string of the file will be copied in szComment
+            (commentBufferSize is the size of the buffer)
+*/
+
+
+/** Addition for GDAL : START */
+
+extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
+
+/** Addition for GDAL : END */
+
+
+/***************************************************************************/
+/* for reading the content of the current zipfile, you can open it, read data
+   from it, and close it (you can close it before reading all the file)
+   */
+
+extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
+/*
+  Open for reading data the current file in the zipfile.
+  If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
+                                                  const char* password));
+/*
+  Open for reading data the current file in the zipfile.
+  password is a crypting password
+  If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
+                                           int* method,
+                                           int* level,
+                                           int raw));
+/*
+  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+    if raw==1
+  *method will receive method of compression, *level will receive level of
+     compression
+  note : you can set level parameter as NULL (if you did not want known level,
+         but you CANNOT set method parameter as NULL
+*/
+
+extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
+                                           int* method,
+                                           int* level,
+                                           int raw,
+                                           const char* password));
+/*
+  Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+    if raw==1
+  *method will receive method of compression, *level will receive level of
+     compression
+  note : you can set level parameter as NULL (if you did not want known level,
+         but you CANNOT set method parameter as NULL
+*/
+
+
+extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
+/*
+  Close the file in zip opened with unzOpenCurrentFile
+  Return UNZ_CRCERROR if all the file was read but the CRC is not good
+*/
+
+extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
+                      voidp buf,
+                      unsigned len));
+/*
+  Read bytes from the current file (opened by unzOpenCurrentFile)
+  buf contain buffer where data must be copied
+  len the size of buf.
+
+  return the number of byte copied if somes bytes are copied
+  return 0 if the end of file was reached
+  return <0 with error code if there is an error
+    (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+*/
+
+extern z_off_t ZEXPORT unztell OF((unzFile file));
+
+extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
+/*
+  Give the current position in uncompressed data
+*/
+
+extern int ZEXPORT unzeof OF((unzFile file));
+/*
+  return 1 if the end of file was reached, 0 elsewhere
+*/
+
+extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
+                                             voidp buf,
+                                             unsigned len));
+/*
+  Read extra field from the current file (opened by unzOpenCurrentFile)
+  This is the local-header version of the extra field (sometimes, there is
+    more info in the local-header version than in the central-header)
+
+  if buf==NULL, it return the size of the local extra field
+
+  if buf!=NULL, len is the size of the buffer, the extra header is copied in
+    buf.
+  the return value is the number of bytes copied in buf, or (if <0)
+    the error code
+*/
+
+/***************************************************************************/
+
+/* Get the current file offset */
+extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file);
+extern uLong ZEXPORT unzGetOffset (unzFile file);
+
+/* Set the current file offset */
+extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos);
+extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _unz64_H */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/README.md
----------------------------------------------------------------------
diff --git a/device_access/README.md b/device_access/README.md
index d58601d..f0c7785 100644
--- a/device_access/README.md
+++ b/device_access/README.md
@@ -2,9 +2,16 @@
 
 The Device Access contains a for Celix adapted implementation of the OSGi Compendium Device Access Specification.
 
-###### Properties
+## Properties
     DRIVER_LOCATOR_PATH     Path to the directory containing the driver bundles, defaults to "drivers".
                             The Driver Locator uses this path to find drivers.
 
-###### CMake option
+## CMake option
     BUILD_DEVICE_ACCESS=ON
+
+## Using info
+
+If the Celix Device Access is installed The `FindCelix.cmake` will set:
+ - The `Celix::device_access_api` interface (i.e. headers only) library target
+ - The `Celix::device_manager` bundle target
+ - The `Celix::driver_locator` bundle target
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/device_access/device_access/CMakeLists.txt b/device_access/device_access/CMakeLists.txt
index 9668156..5f19293 100644
--- a/device_access/device_access/CMakeLists.txt
+++ b/device_access/device_access/CMakeLists.txt
@@ -15,39 +15,37 @@
 # specific language governing permissions and limitations
 # under the License.
 
+
+add_library(device_access_api INTERFACE)
+target_include_directories(device_access_api INTERFACE include)
+
 add_bundle(device_manager
 	SYMBOLIC_NAME "apache_celix_device_manager"
 	VERSION "0.0.2"
 	NAME "Apache Celix Device Access Device Manager"
 	SOURCES
-		private/src/activator
-		private/src/driver_attributes
-		private/src/device_manager
-		private/src/driver_loader
-		private/src/driver_matcher
-
-		${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
-
-		private/include/device_manager.h
-		private/include/driver_attributes.h
-		private/include/driver_loader.h
-		private/include/driver_matcher.h
+		src/activator
+		src/driver_attributes
+		src/device_manager
+		src/driver_loader
+		src/driver_matcher
 )
+target_link_libraries(device_manager PRIVATE Celix::log_helper)
 
 install_bundle(device_manager
 	HEADERS
-		public/include/device.h
-		public/include/driver_locator.h
-		public/include/driver_selector.h
-		public/include/driver.h
-		public/include/match.h
+		include/device.h
+		include/driver_locator.h
+		include/driver_selector.h
+		include/driver.h
+		include/match.h
 )
+target_include_directories(device_manager PRIVATE src)
+target_link_libraries(device_manager PRIVATE device_access_api)
 
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
 include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
 
-include_directories("public/include")
-include_directories("private/include")
+#Setup target aliases to match external usage
+add_library(Celix::device_access_api ALIAS device_access_api)
+add_library(Celix::device_manager ALIAS device_manager)
 
-target_link_libraries(device_manager celix_framework celix_utils)

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/device.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/device.h b/device_access/device_access/include/device.h
new file mode 100644
index 0000000..28032ba
--- /dev/null
+++ b/device_access/device_access/include/device.h
@@ -0,0 +1,47 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * device.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DEVICE_H_
+#define DEVICE_H_
+
+#include "celix_errno.h"
+
+#define OSGI_DEVICEACCESS_DEVICE_CATEGORY	"DEVICE_CATEGORY"
+#define OSGI_DEVICEACCESS_DEVICE_SERIAL	"DEVICE_SERIAL"
+
+#define OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME "device"
+
+static const int OSGI_DEVICEACCESS_DEVICE_MATCH_NONE	= 0;
+
+typedef struct device * device_pt;
+
+struct device_service {
+	device_pt device;
+	celix_status_t (*noDriverFound)(device_pt device);
+};
+
+typedef struct device_service * device_service_pt;
+
+#endif /* DEVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/driver.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/driver.h b/device_access/device_access/include/driver.h
new file mode 100644
index 0000000..7e70e06
--- /dev/null
+++ b/device_access/device_access/include/driver.h
@@ -0,0 +1,45 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * driver.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_H_
+#define DRIVER_H_
+
+#include "celix_errno.h"
+#include "service_reference.h"
+
+#define OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME "driver"
+
+#define OSGI_DEVICEACCESS_DRIVER_ID "DRIVER_ID"
+
+struct driver_service {
+	void *driver;
+	celix_status_t (*attach)(void *driver, service_reference_pt reference, char **result);
+	celix_status_t (*match)(void *driver, service_reference_pt reference, int *value);
+};
+
+typedef struct driver_service *driver_service_pt;
+
+
+#endif /* DRIVER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/driver_locator.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/driver_locator.h b/device_access/device_access/include/driver_locator.h
new file mode 100644
index 0000000..405e33a
--- /dev/null
+++ b/device_access/device_access/include/driver_locator.h
@@ -0,0 +1,46 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * driver_locator.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_LOCATOR_H_
+#define DRIVER_LOCATOR_H_
+
+#include "celix_errno.h"
+#include "properties.h"
+#include "array_list.h"
+
+#define OSGI_DEVICEACCESS_DRIVER_LOCATOR_SERVICE_NAME "driver_locator"
+
+typedef struct driver_locator *driver_locator_pt;
+
+struct driver_locator_service {
+	driver_locator_pt locator;
+	celix_status_t(*findDrivers)(driver_locator_pt loc, properties_pt props, array_list_pt *drivers);
+	celix_status_t(*loadDriver)(driver_locator_pt loc, char *id, char **driver);
+};
+
+typedef struct driver_locator_service *driver_locator_service_pt;
+
+
+#endif /* DRIVER_LOCATOR_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/driver_selector.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/driver_selector.h b/device_access/device_access/include/driver_selector.h
new file mode 100644
index 0000000..a088d05
--- /dev/null
+++ b/device_access/device_access/include/driver_selector.h
@@ -0,0 +1,41 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * driver_selector.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef DRIVER_SELECTOR_H_
+#define DRIVER_SELECTOR_H_
+
+#define OSGI_DEVICEACCESS_DRIVER_SELECTOR_SERVICE_NAME "driver_selector"
+
+typedef struct driver_selector *driver_selector_pt;
+
+struct driver_selector_service {
+	driver_selector_pt selector;
+	celix_status_t (*driverSelector_select)(driver_selector_pt selector, service_reference_pt reference, array_list_pt matches, int *select);
+};
+
+typedef struct driver_selector_service *driver_selector_service_pt;
+
+
+#endif /* DRIVER_SELECTOR_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/include/match.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/include/match.h b/device_access/device_access/include/match.h
new file mode 100644
index 0000000..dd8906d
--- /dev/null
+++ b/device_access/device_access/include/match.h
@@ -0,0 +1,38 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * match.h
+ *
+ *  \date       Jun 20, 2011
+ *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#ifndef MATCH_H_
+#define MATCH_H_
+
+#include <service_reference.h>
+
+struct match {
+	service_reference_pt reference;
+	int matchValue;
+};
+
+typedef struct match *match_pt;
+
+#endif /* MATCH_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/include/device_manager.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/include/device_manager.h b/device_access/device_access/private/include/device_manager.h
deleted file mode 100644
index 00a4f2c..0000000
--- a/device_access/device_access/private/include/device_manager.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * device_manager.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DEVICE_MANAGER_H_
-#define DEVICE_MANAGER_H_
-
-#include "log_helper.h"
-
-#include "driver_loader.h"
-
-typedef struct device_manager *device_manager_pt;
-
-celix_status_t deviceManager_create(bundle_context_pt context, log_helper_pt logHelper, device_manager_pt *manager);
-celix_status_t deviceManager_destroy(device_manager_pt manager);
-
-celix_status_t deviceManager_matchAttachDriver(device_manager_pt manager, driver_loader_pt loader,
-			array_list_pt driverIds, array_list_pt included, array_list_pt excluded, void *service, service_reference_pt reference);
-celix_status_t deviceManager_noDriverFound(device_manager_pt manager, void *service, service_reference_pt reference);
-
-celix_status_t deviceManager_locatorAdded(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_locatorModified(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_locatorRemoved(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_deviceAdded(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_deviceModified(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_deviceRemoved(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_driverAdded(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_driverModified(void * handle, service_reference_pt ref, void * service);
-celix_status_t deviceManager_driverRemoved(void * handle, service_reference_pt ref, void * service);
-
-celix_status_t deviceManager_getBundleContext(device_manager_pt manager, bundle_context_pt *context);
-
-// celix_status_t deviceManager_match(device_manager_pt manager, ...);
-
-#endif /* DEVICE_MANAGER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/include/driver_attributes.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/include/driver_attributes.h b/device_access/device_access/private/include/driver_attributes.h
deleted file mode 100644
index bdb12a2..0000000
--- a/device_access/device_access/private/include/driver_attributes.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * driver_attributes.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_ATTRIBUTES_H_
-#define DRIVER_ATTRIBUTES_H_
-
-#include "driver.h"
-
-typedef struct driver_attributes *driver_attributes_pt;
-
-celix_status_t driverAttributes_create(service_reference_pt reference, driver_service_pt driver, driver_attributes_pt *attributes);
-celix_status_t driverAttributes_destroy(driver_attributes_pt attributes);
-
-celix_status_t driverAttributes_getReference(driver_attributes_pt driverAttributes, service_reference_pt *reference);
-celix_status_t driverAttributes_getDriverId(driver_attributes_pt driverAttributes, char **driverId);
-
-celix_status_t driverAttributes_match(driver_attributes_pt driverAttributes, service_reference_pt reference, int *match);
-celix_status_t driverAttributes_attach(driver_attributes_pt driverAttributes, service_reference_pt reference, char **attach);
-
-celix_status_t driverAttributes_isInUse(driver_attributes_pt driverAttributes, bool *inUse);
-
-celix_status_t driverAttributes_tryUninstall(driver_attributes_pt driverAttributes);
-
-#endif /* DRIVER_ATTRIBUTES_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/include/driver_loader.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/include/driver_loader.h b/device_access/device_access/private/include/driver_loader.h
deleted file mode 100644
index fde9c88..0000000
--- a/device_access/device_access/private/include/driver_loader.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * driver_loader.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_LOADER_H_
-#define DRIVER_LOADER_H_
-
-#include "driver_locator.h"
-#include "driver_attributes.h"
-
-#define DRIVER_LOCATION_PREFIX "_DD_"
-
-typedef struct driver_loader *driver_loader_pt;
-
-celix_status_t driverLoader_create(bundle_context_pt context, driver_loader_pt *loader);
-celix_status_t driverLoader_destroy(driver_loader_pt *loader);
-
-celix_status_t driverLoader_findDrivers(driver_loader_pt loader, array_list_pt locators, properties_pt properties, array_list_pt *driversIds);
-celix_status_t driverLoader_findDriversForLocator(driver_loader_pt loader, driver_locator_service_pt locator, properties_pt properties, array_list_pt *driversIds);
-
-celix_status_t driverLoader_loadDrivers(driver_loader_pt loader, array_list_pt locators, array_list_pt driverIds, array_list_pt *references);
-celix_status_t driverLoader_loadDriver(driver_loader_pt loader, array_list_pt locators, char *driverId, array_list_pt *references);
-celix_status_t driverLoader_loadDriverForLocator(driver_loader_pt loader, driver_locator_service_pt locator, char *driverId, array_list_pt *references);
-
-celix_status_t driverLoader_unloadDrivers(driver_loader_pt loader, driver_attributes_pt finalDriver);
-
-#endif /* DRIVER_LOADER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/include/driver_matcher.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/include/driver_matcher.h b/device_access/device_access/private/include/driver_matcher.h
deleted file mode 100644
index d6cdb22..0000000
--- a/device_access/device_access/private/include/driver_matcher.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * driver_matcher.h
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#ifndef DRIVER_MATCHER_H_
-#define DRIVER_MATCHER_H_
-
-#include "match.h"
-#include "driver_selector.h"
-#include "driver_attributes.h"
-
-typedef struct driver_matcher *driver_matcher_pt;
-
-celix_status_t driverMatcher_create(bundle_context_pt context, driver_matcher_pt *matcher);
-celix_status_t driverMatcher_destroy(driver_matcher_pt *matcher);
-
-celix_status_t driverMatcher_add(driver_matcher_pt matcher, int match, driver_attributes_pt attributes);
-
-celix_status_t driverMatcher_getBestMatch(driver_matcher_pt matcher, service_reference_pt reference, match_pt *match);
-
-#endif /* DRIVER_MATCHER_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/activator.c b/device_access/device_access/private/src/activator.c
deleted file mode 100755
index 007e725..0000000
--- a/device_access/device_access/private/src/activator.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include <bundle_activator.h>
-#include <bundle_context.h>
-#include <celixbool.h>
-#include <service_tracker.h>
-
-#include "driver_locator.h"
-#include "device_manager.h"
-#include "log_service.h"
-#include "log_helper.h"
-
-struct device_manager_bundle_instance {
-	log_helper_pt loghelper;
-	bundle_context_pt context;
-	device_manager_pt deviceManager;
-	service_tracker_pt driverLocatorTracker;
-	service_tracker_pt driverTracker;
-	service_tracker_pt deviceTracker;
-};
-
-typedef struct device_manager_bundle_instance *device_manager_bundle_instance_pt;
-
-static celix_status_t deviceManagerBundle_createDriverLocatorTracker(device_manager_bundle_instance_pt bundleData);
-static celix_status_t deviceManagerBundle_createDriverTracker(device_manager_bundle_instance_pt bundleData);
-static celix_status_t deviceManagerBundle_createDeviceTracker(device_manager_bundle_instance_pt bundleData);
-
-celix_status_t addingService_dummy_func(void * handle, service_reference_pt reference, void **service) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_pt dm = handle;
-	bundle_context_pt context = NULL;
-	status = deviceManager_getBundleContext(dm, &context);
-	if (status == CELIX_SUCCESS) {
-		status = bundleContext_getService(context, reference, service);
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_bundle_instance_pt bi = calloc(1, sizeof(struct device_manager_bundle_instance));
-	if (bi == NULL) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*userData) = bi;
-		bi->context = context;
-
-		logHelper_create(context, &bi->loghelper);
-		logHelper_start(bi->loghelper);
-
-		status = deviceManager_create(context, bi->loghelper, &bi->deviceManager);
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_bundle_instance_pt bundleData = userData;
-
-	status = deviceManagerBundle_createDriverLocatorTracker(bundleData);
-	if (status == CELIX_SUCCESS) {
-		status = deviceManagerBundle_createDriverTracker(bundleData);
-		if (status == CELIX_SUCCESS) {
-				status = deviceManagerBundle_createDeviceTracker(bundleData);
-				if (status == CELIX_SUCCESS) {
-					status = serviceTracker_open(bundleData->driverLocatorTracker);
-					if (status == CELIX_SUCCESS) {
-						status = serviceTracker_open(bundleData->driverTracker);
-						if (status == CELIX_SUCCESS) {
-							status = serviceTracker_open(bundleData->deviceTracker);
-						}
-					}
-				}
-		}
-	}
-
-	if (status != CELIX_SUCCESS) {
-		logHelper_log(bundleData->loghelper, OSGI_LOGSERVICE_ERROR, "DEVICE_MANAGER: Error while starting bundle got error num %d", status);
-	}
-
-	logHelper_log(bundleData->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Started");
-
-	return status;
-}
-
-static celix_status_t deviceManagerBundle_createDriverLocatorTracker(device_manager_bundle_instance_pt bundleData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_tracker_customizer_pt customizer = NULL;
-
-	status = serviceTrackerCustomizer_create(bundleData->deviceManager, addingService_dummy_func,
-			deviceManager_locatorAdded, deviceManager_locatorModified, deviceManager_locatorRemoved, &customizer);
-
-	if (status == CELIX_SUCCESS) {
-		service_tracker_pt tracker = NULL;
-		status = serviceTracker_create(bundleData->context, "driver_locator", customizer, &tracker);
-		if (status == CELIX_SUCCESS) {
-			bundleData->driverLocatorTracker=tracker;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-static celix_status_t deviceManagerBundle_createDriverTracker(device_manager_bundle_instance_pt bundleData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_tracker_customizer_pt customizer = NULL;
-
-	status = serviceTrackerCustomizer_create(bundleData->deviceManager, addingService_dummy_func,
-			deviceManager_driverAdded, deviceManager_driverModified, deviceManager_driverRemoved, &customizer);
-
-	if (status == CELIX_SUCCESS) {
-		service_tracker_pt tracker = NULL;
-		status = serviceTracker_createWithFilter(bundleData->context, "(objectClass=driver)", customizer, &tracker);
-		if (status == CELIX_SUCCESS) {
-			bundleData->driverTracker=tracker;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-static celix_status_t deviceManagerBundle_createDeviceTracker(device_manager_bundle_instance_pt bundleData) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_tracker_customizer_pt customizer = NULL;
-
-	status = serviceTrackerCustomizer_create(bundleData->deviceManager, addingService_dummy_func,
-			deviceManager_deviceAdded, deviceManager_deviceModified, deviceManager_deviceRemoved, &customizer);
-
-	if (status == CELIX_SUCCESS) {
-		service_tracker_pt tracker = NULL;
-		status = serviceTracker_createWithFilter(bundleData->context, "(|(objectClass=device)(DEVICE_CATEGORY=*))", customizer, &tracker);
-		if (status == CELIX_SUCCESS) {
-			bundleData->deviceTracker=tracker;
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-	return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_bundle_instance_pt bundleData = userData;
-//	status = serviceTracker_close(bundleData->driverLocatorTracker);
-	if (status == CELIX_SUCCESS) {
-		status = serviceTracker_close(bundleData->driverTracker);
-		if (status == CELIX_SUCCESS) {
-			status = serviceTracker_close(bundleData->deviceTracker);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_bundle_instance_pt bundleData = userData;
-	status = deviceManager_destroy(bundleData->deviceManager);
-
-	logHelper_stop(bundleData->loghelper);
-	logHelper_destroy(&bundleData->loghelper);
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/device_manager.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/device_manager.c b/device_access/device_access/private/src/device_manager.c
deleted file mode 100644
index 6e7cfd9..0000000
--- a/device_access/device_access/private/src/device_manager.c
+++ /dev/null
@@ -1,570 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * device_manager.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <constants.h>
-#include <string.h>
-
-#include "device_manager.h"
-#include "driver_locator.h"
-#include "driver_matcher.h"
-#include "driver_attributes.h"
-#include "driver_loader.h"
-#include "driver.h"
-#include "device.h"
-#include "log_service.h"
-
-
-#include <bundle.h>
-#include <module.h>
-#include <array_list.h>
-#include <service_registry.h>
-#include <service_reference.h>
-
-struct device_manager {
-	bundle_context_pt context;
-	hash_map_pt devices;
-	hash_map_pt drivers;
-	array_list_pt locators;
-	driver_selector_service_pt selector;
-	log_helper_pt loghelper;
-};
-
-static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, service_reference_pt ref, void *service);
-static celix_status_t deviceManager_getIdleDevices(device_manager_pt manager, array_list_pt *idleDevices);
-static celix_status_t deviceManager_isDriverBundle(device_manager_pt manager, bundle_pt bundle, bool *isDriver);
-
-celix_status_t deviceManager_create(bundle_context_pt context, log_helper_pt logHelper, device_manager_pt *manager) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*manager = calloc(1, sizeof(**manager));
-	if (!*manager) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*manager)->context = context;
-		(*manager)->devices = NULL;
-		(*manager)->drivers = NULL;
-		(*manager)->locators = NULL;
-		(*manager)->selector = NULL;
-
-		(*manager)->devices = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
-		(*manager)->drivers = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
-
-		(*manager)->loghelper = logHelper;
-
-		status = arrayList_create(&(*manager)->locators);
-
-		logHelper_log((*manager)->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Initialized");
-	}
-
-
-	return status;
-}
-
-celix_status_t deviceManager_destroy(device_manager_pt manager) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Stop");
-
-	hashMap_destroy(manager->devices, false, false);
-	hashMap_destroy(manager->drivers, false, false);
-	arrayList_destroy(manager->locators);
-
-	return status;
-}
-
-celix_status_t deviceManager_selectorAdded(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add selector");
-
-	manager->selector = (driver_selector_service_pt) service;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_selectorModified(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify selector");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_selectorRemoved(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove selector");
-	manager->selector = NULL;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_locatorAdded(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add locator");
-	arrayList_add(manager->locators, service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_locatorModified(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify locator");
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_locatorRemoved(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove locator");
-	arrayList_removeElement(manager->locators, service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_deviceAdded(void * handle, service_reference_pt ref, void * service) {
-	celix_status_t status = CELIX_SUCCESS;
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add device");
-	status = deviceManager_attachAlgorithm(manager, ref, service);
-
-	return status;
-}
-
-static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, service_reference_pt ref, void *service) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	driver_loader_pt loader = NULL;
-	status = driverLoader_create(manager->context, &loader);
-	if (status == CELIX_SUCCESS) {
-		array_list_pt included = NULL;
-		array_list_pt excluded = NULL;
-
-		array_list_pt driverIds = NULL;
-
-		hashMap_put(manager->devices, ref, service);
-
-		status = arrayList_create(&included);
-		if (status == CELIX_SUCCESS) {
-			status = arrayList_create(&excluded);
-			if (status == CELIX_SUCCESS) {
-				properties_pt properties = properties_create();
-
-				unsigned int size = 0;
-				char **keys;
-
-				serviceReference_getPropertyKeys(ref, &keys, &size);
-				for (int i = 0; i < size; i++) {
-					char* key = keys[i];
-					const char* value = NULL;
-					serviceReference_getProperty(ref, key, &value);
-					properties_set(properties, key, value);
-				}
-
-				status = driverLoader_findDrivers(loader, manager->locators, properties, &driverIds);
-				if (status == CELIX_SUCCESS) {
-					hash_map_iterator_pt iter = hashMapIterator_create(manager->drivers);
-					while (hashMapIterator_hasNext(iter)) {
-						driver_attributes_pt driverAttributes = hashMapIterator_nextValue(iter);
-						arrayList_add(included, driverAttributes);
-
-						// Each driver that already is installed can be removed from the list
-						char *id = NULL;
-						celix_status_t substatus = driverAttributes_getDriverId(driverAttributes, &id);
-						if (substatus == CELIX_SUCCESS) {
-							// arrayList_removeElement(driverIds, id);
-							array_list_iterator_pt idsIter = arrayListIterator_create(driverIds);
-							while (arrayListIterator_hasNext(idsIter)) {
-								char *value = arrayListIterator_next(idsIter);
-								if (strcmp(value, id) == 0) {
-									arrayListIterator_remove(idsIter);
-								}
-							}
-							arrayListIterator_destroy(idsIter);
-						}
-						if(id != NULL){
-							free(id);
-						}
-					}
-					hashMapIterator_destroy(iter);
-
-					status = deviceManager_matchAttachDriver(manager, loader, driverIds, included, excluded, service, ref);
-
-				}
-				arrayList_destroy(driverIds);
-				properties_destroy(properties);
-				arrayList_destroy(excluded);
-			}
-			arrayList_destroy(included);
-		}
-
-	}
-
-	driverLoader_destroy(&loader);
-	return status;
-}
-
-celix_status_t deviceManager_matchAttachDriver(device_manager_pt manager, driver_loader_pt loader,
-		array_list_pt driverIds, array_list_pt included, array_list_pt excluded, void *service, service_reference_pt reference) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt references = NULL;
-
-	int i;
-	for (i = 0; i < arrayList_size(excluded); i++) {
-		void *exclude = arrayList_get(excluded, i);
-		arrayList_removeElement(included, exclude);
-	}
-
-	for (i = 0; i < arrayList_size(driverIds); i++) {
-		char *id = arrayList_get(driverIds, i);
-		logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Driver found: %s", id);
-	}
-
-	status = driverLoader_loadDrivers(loader, manager->locators, driverIds, &references);
-	if (status == CELIX_SUCCESS) {
-		for (i = 0; i < arrayList_size(references); i++) {
-			service_reference_pt reference = arrayList_get(references, i);
-			driver_attributes_pt attributes = hashMap_get(manager->drivers, reference);
-			if (attributes != NULL) {
-				arrayList_add(included, attributes);
-			}
-		}
-
-		driver_matcher_pt matcher = NULL;
-		status = driverMatcher_create(manager->context, &matcher);
-		if (status == CELIX_SUCCESS) {
-			for (i = 0; i < arrayList_size(included); i++) {
-				driver_attributes_pt attributes = arrayList_get(included, i);
-
-				int match = 0;
-				celix_status_t substatus = driverAttributes_match(attributes, reference, &match);
-				if (substatus == CELIX_SUCCESS) {
-					logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "DEVICE_MANAGER: Found match: %d", match);
-					if (match <= OSGI_DEVICEACCESS_DEVICE_MATCH_NONE) {
-						continue;
-					}
-					driverMatcher_add(matcher, match, attributes);
-				} else {
-					// Ignore
-				}
-			}
-
-			match_pt match = NULL;
-			status = driverMatcher_getBestMatch(matcher, reference, &match);
-			if (status == CELIX_SUCCESS) {
-				if (match == NULL) {
-					status = deviceManager_noDriverFound(manager, service, reference);
-				} else {
-                    driver_attributes_pt finalAttributes = hashMap_get(manager->drivers, match->reference);
-                    if (finalAttributes == NULL) {
-                        status = deviceManager_noDriverFound(manager, service, reference);
-                    } else {
-                        char *newDriverId = NULL;
-                        status = driverAttributes_attach(finalAttributes, reference, &newDriverId);
-                        if (status == CELIX_SUCCESS) {
-                            if (newDriverId != NULL) {
-                                array_list_pt ids = NULL;
-                                arrayList_create(&ids);
-                                arrayList_add(ids, newDriverId);
-                                arrayList_add(excluded, finalAttributes);
-                                status = deviceManager_matchAttachDriver(manager, loader,
-                                        ids, included, excluded, service, reference);
-                            } else {
-                                // Attached, unload unused drivers
-                                status = driverLoader_unloadDrivers(loader, finalAttributes);
-                            }
-                        }
-					}
-				}
-			}
-		}
-
-		driverMatcher_destroy(&matcher);
-
-	}
-
-	if (references != NULL) {
-		arrayList_destroy(references);
-	}
-
-	return status;
-}
-
-celix_status_t deviceManager_noDriverFound(device_manager_pt manager, void *service, service_reference_pt reference) {
-	celix_status_t status = CELIX_SUCCESS;
-    const char* objectClass = NULL;
-    serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &objectClass);
-    if (strcmp(objectClass, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME) == 0) {
-        device_service_pt device = service;
-        status = device->noDriverFound(device->device);
-    }
-	return status;
-}
-
-celix_status_t deviceManager_deviceModified(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify device");
-	// #TODO the device properties could be changed
-	//hashMap_put(manager->devices, ref, service);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_deviceRemoved(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove device");
-	hashMap_remove(manager->devices, ref);
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_driverAdded(void * handle, service_reference_pt ref, void * service) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Add driver");
-	driver_attributes_pt attributes = NULL;
-
-	status = driverAttributes_create(ref, service, &attributes);
-	if (status == CELIX_SUCCESS) {
-		hashMap_put(manager->drivers, ref, attributes);
-	}
-	else{
-		driverAttributes_destroy(attributes);
-	}
-	return status;
-}
-
-celix_status_t deviceManager_driverModified(void * handle, service_reference_pt ref, void * service) {
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Modify driver");
-	// #TODO the driver properties could be changed?
-	return CELIX_SUCCESS;
-}
-
-celix_status_t deviceManager_driverRemoved(void * handle, service_reference_pt ref, void * service) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	device_manager_pt manager = handle;
-	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Remove driver");
-
-	hashMap_remove(manager->drivers, ref);
-
-	array_list_pt idleDevices = NULL;
-	status = deviceManager_getIdleDevices(manager, &idleDevices);
-	if (status == CELIX_SUCCESS) {
-		int i;
-		for (i = 0; i < arrayList_size(idleDevices); i++) {
-			celix_status_t forStatus = CELIX_SUCCESS;
-			service_reference_pt ref = arrayList_get(idleDevices, i);
-			const char *bsn = NULL;
-			bundle_pt bundle = NULL;
-			forStatus = serviceReference_getBundle(ref, &bundle);
-			if (forStatus == CELIX_SUCCESS) {
-				module_pt module = NULL;
-				forStatus = bundle_getCurrentModule(bundle, &module);
-				if (forStatus == CELIX_SUCCESS) {
-					forStatus = module_getSymbolicName(module, &bsn);
-					if (forStatus == CELIX_SUCCESS) {
-						logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: IDLE: %s", bsn);
-						// #TODO attachDriver (idle device)
-						// #TODO this can result in a loop?
-						//		Locate and install a driver
-						//		Let the match fail, the device is idle
-						//		The driver is removed, idle check is performed
-						//		Attach is tried again
-						//		.. loop ..
-						void *device = hashMap_get(manager->devices, ref);
-						forStatus = deviceManager_attachAlgorithm(manager, ref, device);
-					}
-				}
-			}
-
-			if (forStatus != CELIX_SUCCESS) {
-				break; //Got error, stop loop and return status
-			}
-		}
-
-
-		hash_map_iterator_pt iter = hashMapIterator_create(manager->drivers);
-		while (hashMapIterator_hasNext(iter)) {
-			hashMapIterator_nextValue(iter);
-//			driver_attributes_pt da = hashMapIterator_nextValue(iter);
-//			driverAttributes_tryUninstall(da);
-		}
-		hashMapIterator_destroy(iter);
-	}
-
-	if (idleDevices != NULL) {
-		arrayList_destroy(idleDevices);
-	}
-
-	return status;
-}
-
-
-celix_status_t deviceManager_getIdleDevices(device_manager_pt manager, array_list_pt *idleDevices) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = arrayList_create(idleDevices);
-	if (status == CELIX_SUCCESS) {
-		hash_map_iterator_pt iter = hashMapIterator_create(manager->devices);
-		while (hashMapIterator_hasNext(iter)) {
-			celix_status_t substatus = CELIX_SUCCESS;
-			service_reference_pt ref = hashMapIterator_nextKey(iter);
-			const char *bsn = NULL;
-			module_pt module = NULL;
-			bundle_pt bundle = NULL;
-			substatus = serviceReference_getBundle(ref, &bundle);
-			if (substatus == CELIX_SUCCESS) {
-				substatus = bundle_getCurrentModule(bundle, &module);
-				if (substatus == CELIX_SUCCESS) {
-					substatus = module_getSymbolicName(module, &bsn);
-					if (substatus == CELIX_SUCCESS) {
-						logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Check idle device: %s", bsn);
-						array_list_pt bundles = NULL;
-						substatus = serviceReference_getUsingBundles(ref, &bundles);
-						if (substatus == CELIX_SUCCESS) {
-							bool inUse = false;
-							int i;
-							for (i = 0; i < arrayList_size(bundles); i++) {
-								bundle_pt bundle = arrayList_get(bundles, i);
-								bool isDriver;
-								celix_status_t sstatus = deviceManager_isDriverBundle(manager, bundle, &isDriver);
-								if (sstatus == CELIX_SUCCESS) {
-									if (isDriver) {
-										const char *bsn = NULL;
-										module_pt module = NULL;
-										bundle_getCurrentModule(bundle, &module);
-										module_getSymbolicName(module, &bsn);
-
-										logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Not idle, used by driver: %s", bsn);
-
-										inUse = true;
-										break;
-									}
-								}
-							}
-
-							if (!inUse) {
-								arrayList_add(*idleDevices, ref);
-							}
-						}
-
-						if(bundles!=NULL){
-							arrayList_destroy(bundles);
-						}
-					}
-				}
-			}
-		}
-		hashMapIterator_destroy(iter);
-	}
-
-	return status;
-}
-
-//TODO examply for discussion only, remove after discussion
-#define DO_IF_SUCCESS(status, call_func) ((status) == CELIX_SUCCESS) ? (call_func) : (status)
-celix_status_t deviceManager_getIdleDevices_exmaple(device_manager_pt manager, array_list_pt *idleDevices) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = arrayList_create(idleDevices);
-	if (status == CELIX_SUCCESS) {
-		hash_map_iterator_pt iter = hashMapIterator_create(manager->devices);
-		while (hashMapIterator_hasNext(iter)) {
-			celix_status_t substatus = CELIX_SUCCESS;
-			service_reference_pt ref = hashMapIterator_nextKey(iter);
-			const char *bsn = NULL;
-			module_pt module = NULL;
-			bundle_pt bundle = NULL;
-			array_list_pt bundles = NULL;
-			substatus = serviceReference_getBundle(ref, &bundle);
-			substatus = DO_IF_SUCCESS(substatus, bundle_getCurrentModule(bundle, &module));
-			substatus = DO_IF_SUCCESS(substatus, module_getSymbolicName(module, &bsn));
-			substatus = DO_IF_SUCCESS(substatus, serviceReference_getUsingBundles(ref, &bundles));
-
-			if (substatus == CELIX_SUCCESS) {
-				logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Check idle device: %s", bsn);
-				bool inUse = false;
-				int i;
-				for (i = 0; i < arrayList_size(bundles); i++) {
-					bundle_pt bundle = arrayList_get(bundles, i);
-					bool isDriver;
-					celix_status_t sstatus = deviceManager_isDriverBundle(manager, bundle, &isDriver);
-					if (sstatus == CELIX_SUCCESS) {
-						if (isDriver) {
-							const char *bsn = NULL;
-							module_pt module = NULL;
-							bundle_getCurrentModule(bundle, &module);
-							module_getSymbolicName(module, &bsn);
-
-							logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Not idle, used by driver: %s", bsn);
-
-							inUse = true;
-							break;
-						}
-					}
-				}
-
-				if (!inUse) {
-					arrayList_add(*idleDevices, ref);
-				}
-			}
-		}
-		hashMapIterator_destroy(iter);
-	}
-	return status;
-}
-
-celix_status_t deviceManager_isDriverBundle(device_manager_pt manager, bundle_pt bundle, bool *isDriver) {
-	celix_status_t status = CELIX_SUCCESS;
-	(*isDriver) = false;
-
-	array_list_pt refs = NULL;
-		status = bundle_getRegisteredServices(bundle, &refs);
-		if (status == CELIX_SUCCESS) {
-			if (refs != NULL) {
-				int i;
-				for (i = 0; i < arrayList_size(refs); i++) {
-					service_reference_pt ref = arrayList_get(refs, i);
-                    const char* object = NULL;
-                    serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &object);
-                    if (strcmp(object, "driver") == 0) {
-                        *isDriver = true;
-                        break;
-                    }
-				}
-				arrayList_destroy(refs);
-			}
-		}
-
-	return status;
-}
-
-
-celix_status_t deviceManager_getBundleContext(device_manager_pt manager, bundle_context_pt *context) {
-	celix_status_t status = CELIX_SUCCESS;
-	if (manager->context != NULL) {
-		(*context) = manager->context;
-	} else {
-		status = CELIX_INVALID_BUNDLE_CONTEXT;
-	}
-	return status;
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/driver_attributes.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/driver_attributes.c b/device_access/device_access/private/src/driver_attributes.c
deleted file mode 100644
index 5ac7fda..0000000
--- a/device_access/device_access/private/src/driver_attributes.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * driver_attributes.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "driver_attributes.h"
-#include "bundle.h"
-#include "celixbool.h"
-#include "driver_loader.h"
-#include "device.h"
-#include "constants.h"
-
-struct driver_attributes {
-	bundle_pt bundle;
-	service_reference_pt reference;
-	driver_service_pt driver;
-	bool dynamic;
-};
-
-celix_status_t driverAttributes_create(service_reference_pt reference, driver_service_pt driver, driver_attributes_pt *attributes) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*attributes = calloc(1, sizeof(**attributes));
-	if (!*attributes) {
-		status = CELIX_ENOMEM;
-	} else {
-		bundle_pt bundle = NULL;
-		bundle_archive_pt bundleArchive = NULL;
-		status = serviceReference_getBundle(reference, &bundle);
-
-		if (status == CELIX_SUCCESS) {
-			status = bundle_getArchive(bundle, &bundleArchive);
-
-			if (status == CELIX_SUCCESS) {
-				(*attributes)->reference = reference;
-				(*attributes)->driver = driver;
-				(*attributes)->bundle = bundle;
-
-				const char *location;
-				status = bundleArchive_getLocation(bundleArchive, &location);
-				if (status == CELIX_SUCCESS) {
-					(*attributes)->dynamic = strncmp(location, DRIVER_LOCATION_PREFIX, 4) == 0 ? true : false;
-				}
-
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverAttributes_destroy(driver_attributes_pt attributes){
-	if(attributes != NULL){
-		free(attributes);
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t driverAttributes_getReference(driver_attributes_pt driverAttributes, service_reference_pt *reference) {
-	*reference = driverAttributes->reference;
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t driverAttributes_getDriverId(driver_attributes_pt driverAttributes, char **driverId) {
-	celix_status_t status = CELIX_SUCCESS;
-
-    const char* id_prop = NULL;
-    status = serviceReference_getProperty(driverAttributes->reference, "DRIVER_ID", &id_prop);
-    if (status == CELIX_SUCCESS) {
-        if (!id_prop) {
-            status = CELIX_ENOMEM;
-        } else {
-            *driverId = strdup(id_prop);
-
-            if (*driverId == NULL) {
-                status = CELIX_ENOMEM;
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverAttributes_match(driver_attributes_pt driverAttributes, service_reference_pt reference, int *match) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = driverAttributes->driver->match(driverAttributes->driver->driver, reference, match);
-
-	return status;
-}
-
-celix_status_t driverAttributes_isInUse(driver_attributes_pt driverAttributes, bool *inUse) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt references = NULL;
-	status = bundle_getServicesInUse(driverAttributes->bundle, &references);
-	if (status == CELIX_SUCCESS) {
-		if (references == NULL || arrayList_size(references) == 0) {
-			*inUse = false;
-		} else {
-			int i;
-			for (i = 0; i < arrayList_size(references); i++) {
-				service_reference_pt ref = arrayList_get(references, i);
-				const char *object = NULL;
-				status = serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &object);
-
-				if (status == CELIX_SUCCESS) {
-					const char* category = NULL;
-					status = serviceReference_getProperty(ref, "DEVICE_CATEGORY", &category);
-
-					if (status == CELIX_SUCCESS) {
-						if ((object != NULL && strcmp(object, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME) == 0) || (category != NULL)) {
-							*inUse = true;
-						}
-					}
-				}
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverAttributes_attach(driver_attributes_pt driverAttributes, service_reference_pt reference, char **attach) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = driverAttributes->driver->attach(driverAttributes->driver->driver, reference, attach);
-
-	return status;
-}
-
-celix_status_t driverAttributes_tryUninstall(driver_attributes_pt driverAttributes) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	bool inUse = false;
-
-	status = driverAttributes_isInUse(driverAttributes, &inUse);
-	if (status == CELIX_SUCCESS) {
-		if (!inUse && driverAttributes->dynamic) {
-			status = bundle_uninstall(driverAttributes->bundle);
-		}
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/driver_loader.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/driver_loader.c b/device_access/device_access/private/src/driver_loader.c
deleted file mode 100644
index c4caa65..0000000
--- a/device_access/device_access/private/src/driver_loader.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * driver_loader.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "driver_loader.h"
-#include "bundle_context.h"
-#include "bundle.h"
-
-struct driver_loader {
-	bundle_context_pt context;
-	array_list_pt loadedDrivers;
-};
-
-celix_status_t driverLoader_create(bundle_context_pt context, driver_loader_pt *loader) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*loader = calloc(1, sizeof(**loader));
-	if (!*loader) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*loader)->context = context;
-		(*loader)->loadedDrivers = NULL;
-		status = arrayList_create(&(*loader)->loadedDrivers);
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_destroy(driver_loader_pt *loader) {
-	if((*loader) != NULL){
-		arrayList_destroy((*loader)->loadedDrivers);
-		free((*loader));
-		(*loader)=NULL;
-	}
-	return CELIX_SUCCESS;
-}
-
-celix_status_t driverLoader_findDrivers(driver_loader_pt loader, array_list_pt locators, properties_pt properties, array_list_pt *driversIds) {
-	celix_status_t status = CELIX_SUCCESS;
-	arrayList_create(driversIds);
-
-	int i;
-	for (i = 0; i < arrayList_size(locators); i++) {
-		array_list_pt drivers;
-		driver_locator_service_pt locator = arrayList_get(locators, i);
-
-		status = driverLoader_findDriversForLocator(loader, locator, properties, &drivers);
-		if (status == CELIX_SUCCESS) {
-			arrayList_addAll(*driversIds, drivers);
-		}
-		arrayList_destroy(drivers);
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_findDriversForLocator(driver_loader_pt loader, driver_locator_service_pt locator, properties_pt properties, array_list_pt *driversIds) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	status = locator->findDrivers(locator->locator, properties, driversIds);
-
-	return status;
-}
-
-celix_status_t driverLoader_loadDrivers(driver_loader_pt loader, array_list_pt locators, array_list_pt driverIds, array_list_pt *references) {
-	celix_status_t status = CELIX_SUCCESS;
-	status = arrayList_create(references);
-	if (status == CELIX_SUCCESS) {
-		int i;
-		for (i = 0; i < arrayList_size(driverIds); i++) {
-			array_list_pt refs = NULL;
-			char *id = arrayList_get(driverIds, i);
-
-			status = driverLoader_loadDriver(loader, locators, id, &refs);
-			if (status == CELIX_SUCCESS) {
-				arrayList_addAll(*references, refs);
-			}
-			if (refs != NULL) {
-				arrayList_destroy(refs);
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_loadDriver(driver_loader_pt loader, array_list_pt locators, char *driverId, array_list_pt *references) {
-	celix_status_t status = CELIX_SUCCESS;
-	status = arrayList_create(references);
-	if (status == CELIX_SUCCESS) {
-		int i;
-		for (i = 0; i < arrayList_size(locators); i++) {
-			array_list_pt refs = NULL;
-			driver_locator_service_pt locator = arrayList_get(locators, i);
-
-			status = driverLoader_loadDriverForLocator(loader, locator, driverId, &refs);
-			if (status == CELIX_SUCCESS) {
-				arrayList_addAll(*references, refs);
-			}
-
-			if (refs != NULL) {
-				arrayList_destroy(refs);
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_loadDriverForLocator(driver_loader_pt loader, driver_locator_service_pt locator, char *driverId, array_list_pt *references) {
-	celix_status_t status = CELIX_SUCCESS;
-	//The list is created in the bundle_getRegisteredServices chain
-	//arrayList_create(references);
-
-	char *filename = NULL;
-	status = locator->loadDriver(locator->locator, driverId, &filename);
-	if (status == CELIX_SUCCESS) {
-		bundle_pt bundle = NULL;
-		int length = strlen(DRIVER_LOCATION_PREFIX) + strlen(driverId);
-		char location[length+2];
-		snprintf(location, length+2, "%s%s", DRIVER_LOCATION_PREFIX, driverId);
-		status = bundleContext_installBundle2(loader->context, location, filename, &bundle);
-		if (status == CELIX_SUCCESS) {
-			status = bundle_start(bundle);
-			if (status == CELIX_SUCCESS) {
-				status = bundle_getRegisteredServices(bundle, references);
-				if (status == CELIX_SUCCESS) {
-					arrayList_addAll(loader->loadedDrivers, *references);
-				}
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverLoader_unloadDrivers(driver_loader_pt loader, driver_attributes_pt finalDriver) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	service_reference_pt finalReference = NULL;
-	if (finalDriver != NULL) {
-		status = driverAttributes_getReference(finalDriver, &finalReference);
-	}
-	if (status == CELIX_SUCCESS) {
-		int i;
-		for (i = 0; i < arrayList_size(loader->loadedDrivers); i++) {
-			service_reference_pt reference = arrayList_get(loader->loadedDrivers, i);
-			bool equal = false;
-			status = serviceReference_equals(reference, finalReference, &equal);
-			if (status == CELIX_SUCCESS && !equal) {
-				bundle_pt bundle = NULL;
-				status = serviceReference_getBundle(reference, &bundle);
-				if (status == CELIX_SUCCESS) {
-					bundle_uninstall(bundle); // Ignore status
-				}
-			}
-		}
-	}
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/device_access/device_access/private/src/driver_matcher.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/driver_matcher.c b/device_access/device_access/private/src/driver_matcher.c
deleted file mode 100644
index c7597d3..0000000
--- a/device_access/device_access/private/src/driver_matcher.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * driver_matcher.c
- *
- *  \date       Jun 20, 2011
- *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-#include <stdlib.h>
-
-#include "hash_map.h"
-#include "constants.h"
-
-#include "driver_matcher.h"
-#include "log_helper.h"
-#include "log_service.h"
-
-
-struct driver_matcher {
-	hash_map_pt attributes;
-	array_list_pt matches;
-	log_helper_pt loghelper;
-
-	bundle_context_pt context;
-};
-
-typedef struct match_key {
-	int matchValue;
-}*match_key_t;
-
-static celix_status_t driverMatcher_get(driver_matcher_pt matcher, int key, array_list_pt *attributesV);
-static celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, match_pt *match);
-
-unsigned int driverMatcher_matchKeyHash(const void* match_key) {
-	match_key_t key = (match_key_t) match_key;
-
-	return key->matchValue;
-}
-
-int driverMatcher_matchKeyEquals(const void* key, const void* toCompare) {
-	return ((match_key_t) key)->matchValue == ((match_key_t) toCompare)->matchValue;
-}
-
-celix_status_t driverMatcher_create(bundle_context_pt context, driver_matcher_pt *matcher) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*matcher = calloc(1, sizeof(**matcher));
-	if (!*matcher) {
-		status = CELIX_ENOMEM;
-	} else {
-		(*matcher)->matches = NULL;
-		(*matcher)->context = context;
-		(*matcher)->attributes = hashMap_create(driverMatcher_matchKeyHash, NULL, driverMatcher_matchKeyEquals, NULL);
-
-		arrayList_create(&(*matcher)->matches);
-
-		if(logHelper_create(context, &(*matcher)->loghelper) == CELIX_SUCCESS) {
-			logHelper_start((*matcher)->loghelper);
-		}
-
-	}
-
-	return status;
-}
-
-celix_status_t driverMatcher_destroy(driver_matcher_pt *matcher) {
-
-	if((*matcher) != NULL){
-
-		int i = 0;
-
-		for(;i<arrayList_size((*matcher)->matches);i++){
-			free(arrayList_get((*matcher)->matches,i));
-		}
-		arrayList_destroy((*matcher)->matches);
-
-		hash_map_iterator_pt iter = hashMapIterator_create((*matcher)->attributes);
-		while (hashMapIterator_hasNext(iter)) {
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-			match_key_t match = (match_key_t)hashMapEntry_getKey(entry);
-			array_list_pt list = (array_list_pt)hashMapEntry_getValue(entry);
-			free(match);
-			if (list != NULL) {
-				arrayList_destroy(list);
-			}
-		}
-		hashMapIterator_destroy(iter);
-		hashMap_destroy((*matcher)->attributes, false, false);
-
-		logHelper_stop((*matcher)->loghelper);
-		logHelper_destroy(&(*matcher)->loghelper);
-
-		free(*matcher);
-	}
-
-	return CELIX_SUCCESS;
-}
-
-celix_status_t driverMatcher_add(driver_matcher_pt matcher, int matchValue, driver_attributes_pt attributes) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	array_list_pt da = NULL;
-	status = driverMatcher_get(matcher, matchValue, &da);
-	if (status == CELIX_SUCCESS) {
-		arrayList_add(da, attributes);
-
-		match_pt match = NULL;
-		match = calloc(1, sizeof(*match));
-		if (!match) {
-			status = CELIX_ENOMEM;
-		} else {
-			match->matchValue = matchValue;
-			match->reference = NULL;
-			driverAttributes_getReference(attributes, &match->reference);
-			arrayList_add(matcher->matches, match);
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverMatcher_get(driver_matcher_pt matcher, int key, array_list_pt *attributes) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	match_key_t matchKeyS = calloc(1, sizeof(*matchKeyS));
-	matchKeyS->matchValue = key;
-
-	*attributes = hashMap_get(matcher->attributes, matchKeyS);
-	if (*attributes == NULL) {
-		arrayList_create(attributes);
-		match_key_t matchKey = calloc(1, sizeof(*matchKey));
-		matchKey->matchValue = key;
-		hashMap_put(matcher->attributes, matchKey, *attributes);
-	}
-
-	free(matchKeyS);
-
-	return status;
-}
-
-celix_status_t driverMatcher_getBestMatch(driver_matcher_pt matcher, service_reference_pt reference, match_pt *match) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (*match != NULL) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	} else {
-		service_reference_pt selectorRef = NULL;
-		status = bundleContext_getServiceReference(matcher->context, OSGI_DEVICEACCESS_DRIVER_SELECTOR_SERVICE_NAME, &selectorRef);
-		if (status == CELIX_SUCCESS) {
-			int index = -1;
-			if (selectorRef != NULL) {
-				driver_selector_service_pt selector = NULL;
-				status = bundleContext_getService(matcher->context, selectorRef, (void **) &selector);
-				if (status == CELIX_SUCCESS) {
-					if (selector != NULL) {
-						int size = -1;
-						status = selector->driverSelector_select(selector->selector, reference, matcher->matches, &index);
-						if (status == CELIX_SUCCESS) {
-							size = arrayList_size(matcher->matches);
-							if (index != -1 && index >= 0 && index < size) {
-								*match = arrayList_get(matcher->matches, index);
-							}
-						}
-					}
-				}
-			}
-			if (status == CELIX_SUCCESS && *match == NULL) {
-				status = driverMatcher_getBestMatchInternal(matcher, match);
-			}
-		}
-	}
-
-	return status;
-}
-
-celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, match_pt *match) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!hashMap_isEmpty(matcher->attributes)) {
-		match_key_t matchKey = NULL;
-		hash_map_iterator_pt iter = hashMapIterator_create(matcher->attributes);
-		while (hashMapIterator_hasNext(iter)) {
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-			match_key_t key = hashMapEntry_getKey(entry);
-			if (matchKey == NULL || matchKey->matchValue < key->matchValue) {
-				matchKey = key;
-			}
-		}
-		hashMapIterator_destroy(iter);
-
-		array_list_pt das = hashMap_get(matcher->attributes, matchKey);
-		service_reference_pt best = NULL;
-		int i;
-		for (i = 0; i < arrayList_size(das); i++) {
-			driver_attributes_pt attributes = arrayList_get(das, i);
-			service_reference_pt reference = NULL;
-
-			celix_status_t substatus = driverAttributes_getReference(attributes, &reference);
-			if (substatus == CELIX_SUCCESS) {
-				if (best != NULL) {
-					const char* rank1Str;
-					const char* rank2Str;
-					int rank1, rank2;
-
-					rank1Str = "0";
-					rank2Str = "0";
-
-					logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare ranking");
-
-					serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank1Str);
-					serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank2Str);
-
-					rank1 = atoi(rank1Str);
-					rank2 = atoi(rank2Str);
-
-					if (rank1 != rank2) {
-						if (rank1 > rank2) {
-							best = reference;
-						}
-					} else {
-						const char* id1Str;
-						const char* id2Str;
-						long id1, id2;
-
-						id1Str = NULL;
-						id2Str = NULL;
-
-						logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare id's");
-
-						serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &id1Str);
-						serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &id2Str);
-
-						id1 = atol(id1Str);
-						id2 = atol(id2Str);
-
-						if (id1 < id2) {
-							best = reference;
-						}
-					}
-				} else {
-					best = reference;
-				}
-			}
-
-		}
-
-		*match = calloc(1, sizeof(**match));
-		if (!*match) {
-			status = CELIX_ENOMEM;
-		} else {
-			(*match)->matchValue = matchKey->matchValue;
-			(*match)->reference = best;
-		}
-	}
-
-	return status;
-}


Mime
View raw message