http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/device_access/src/driver_matcher.h ---------------------------------------------------------------------- diff --git a/device_access/device_access/src/driver_matcher.h b/device_access/device_access/src/driver_matcher.h deleted file mode 100644 index d6cdb22..0000000 --- a/device_access/device_access/src/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:d...@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/3bce889b/device_access/driver_locator/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/device_access/driver_locator/CMakeLists.txt b/device_access/driver_locator/CMakeLists.txt deleted file mode 100644 index 464ccbf..0000000 --- a/device_access/driver_locator/CMakeLists.txt +++ /dev/null @@ -1,32 +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. - -add_celix_bundle(driver_locator - SYMBOLIC_NAME "apache_celix_driver_locator" - VERSION "0.0.2" - NAME "Apache Celix Device Access Driver Locator" - SOURCES - src/activator - src/driver_locator -) - -target_include_directories(driver_locator PRIVATE src) -target_link_libraries(driver_locator PRIVATE Celix::device_access_api) - -#Setup target aliases to match external usage -install_celix_bundle(driver_locator EPXORT celix COMPONENT device_access) -add_library(Celix::driver_locator ALIAS driver_locator) http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/driver_locator/src/activator.c ---------------------------------------------------------------------- diff --git a/device_access/driver_locator/src/activator.c b/device_access/driver_locator/src/activator.c deleted file mode 100644 index abc60c5..0000000 --- a/device_access/driver_locator/src/activator.c +++ /dev/null @@ -1,89 +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:d...@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 "driver_locator_private.h" - -static const char *DEFAULT_LOCATOR_PATH = "drivers"; - -struct bundle_instance { - driver_locator_service_pt service; - driver_locator_pt locator; - service_registration_pt locatorRegistration; -}; - -typedef struct bundle_instance *bundle_instance_pt; - -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { - celix_status_t status = CELIX_SUCCESS; - (*userData) = calloc(1, sizeof(struct bundle_instance)); - if ( (*userData) == NULL ){ - status = CELIX_ENOMEM; - } - return status; -} - -celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { - celix_status_t status = CELIX_SUCCESS; - bundle_instance_pt bi = (bundle_instance_pt)userData; - - bi->service = calloc(1, sizeof(*(bi->service))); - bi->locator = calloc(1, sizeof(*(bi->locator))); - if(bi->service != NULL && bi->locator != NULL){ - bi->service->findDrivers = driverLocator_findDrivers; - bi->service->loadDriver = driverLocator_loadDriver; - - bi->service->locator = bi->locator; - bi->locator->drivers = NULL; - arrayList_create(&bi->locator->drivers); - bundleContext_getProperty(context, "DRIVER_LOCATOR_PATH", (const char**)&bi->locator->path); - if (bi->locator->path == NULL ) { - bi->locator->path = (char *)DEFAULT_LOCATOR_PATH; - } - status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_LOCATOR_SERVICE_NAME, bi->service, NULL, &bi->locatorRegistration); - } - else{ - if(bi->service!=NULL) free(bi->service); - if(bi->locator!=NULL) free(bi->locator); - status = CELIX_ENOMEM; - } - - return status; -} - -celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) { - celix_status_t status = CELIX_SUCCESS; - bundle_instance_pt bi = (bundle_instance_pt)userData; - serviceRegistration_unregister(bi->locatorRegistration); - arrayList_destroy(bi->locator->drivers); - return status; -} - -celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { - return CELIX_SUCCESS; -} http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/driver_locator/src/driver_locator.c ---------------------------------------------------------------------- diff --git a/device_access/driver_locator/src/driver_locator.c b/device_access/driver_locator/src/driver_locator.c deleted file mode 100644 index 9c360bf..0000000 --- a/device_access/driver_locator/src/driver_locator.c +++ /dev/null @@ -1,91 +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_locator.c - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <dirent.h> - -#include "driver_locator_private.h" -#include "device.h" - -celix_status_t driverLocator_findDrivers(driver_locator_pt locator, properties_pt props, array_list_pt *drivers) { - celix_status_t status = CELIX_SUCCESS; - - const char* category = properties_get(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY); - - status = arrayList_create(drivers); - if (status == CELIX_SUCCESS) { - DIR *dir; - dir = opendir(locator->path); - if (!dir) { - status = CELIX_FILE_IO_EXCEPTION; - } else { - struct dirent *dp; - while ((dp = readdir(dir)) != NULL) { - char str1[256], str2[256], str3[256]; - if (sscanf(dp->d_name, "%[^_]_%[^.].%s", str1, str2, str3) == 3 && - strcmp(str1, category) == 0 && - strcmp(str3, "zip") == 0) { - int length = strlen(str1) + strlen(str2) + 2; - char driver[length]; - snprintf(driver, length, "%s_%s", str1, str2); - arrayList_add(*drivers, strdup(driver)); - } - } - closedir(dir); - } - } - return status; -} - -celix_status_t driverLocator_loadDriver(driver_locator_pt locator, char *id, char **stream) { - celix_status_t status = CELIX_SUCCESS; - *stream = NULL; - - DIR *dir; - dir = opendir(locator->path); - if (!dir) { - status = CELIX_FILE_IO_EXCEPTION; - } else { - struct dirent *dp; - while ((dp = readdir(dir)) != NULL) { - char str1[256], str2[256]; - if (sscanf(dp->d_name, "%[^.].%s", str1, str2) == 2 && - strcmp(str1, id) == 0 && - strcmp(str2, "zip") == 0) { - int length = strlen(locator->path) + strlen(dp->d_name) + 2; - char stream_str[length]; - snprintf(stream_str, length, "%s/%s", locator->path, dp->d_name); - *stream = strdup(stream_str); - break; - } - } - closedir(dir); - } - - return status; -} - http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/driver_locator/src/driver_locator_private.h ---------------------------------------------------------------------- diff --git a/device_access/driver_locator/src/driver_locator_private.h b/device_access/driver_locator/src/driver_locator_private.h deleted file mode 100644 index bf6dcbf..0000000 --- a/device_access/driver_locator/src/driver_locator_private.h +++ /dev/null @@ -1,39 +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_locator_private.h - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#ifndef DRIVER_LOCATOR_PRIVATE_H_ -#define DRIVER_LOCATOR_PRIVATE_H_ - -#include "driver_locator.h" - -struct driver_locator { - char *path; - array_list_pt drivers; -}; - -celix_status_t driverLocator_findDrivers(driver_locator_pt locator, properties_pt props, array_list_pt *drivers); -celix_status_t driverLocator_loadDriver(driver_locator_pt locator, char *id, char **driver); - -#endif /* DRIVER_LOCATOR_PRIVATE_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/device_access/example/CMakeLists.txt b/device_access/example/CMakeLists.txt deleted file mode 100644 index 5deaf85..0000000 --- a/device_access/example/CMakeLists.txt +++ /dev/null @@ -1,32 +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. - -celix_subproject(DEVICE_ACCESS_EXAMPLE "Option to enable building the Device Access example bundles" OFF DEPS LAUNCHER LOG_SERVICE shell_pt shell_tui) -if(DEVICE_ACCESS_EXAMPLE) - add_subdirectory(base_driver) - add_subdirectory(consuming_driver) - add_subdirectory(refining_driver) - - add_celix_container(device_access_example - BUNDLES Celix::device_manager Celix::driver_locator Celix::shell Celix::shell_tui log_service base_driver - ) - - celix_container_bundles_dir(device_access_example - DIR_NAME "drivers" - BUNDLES word_consumingdriver char_refiningdriver - ) -endif(DEVICE_ACCESS_EXAMPLE) http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/base_driver/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/device_access/example/base_driver/CMakeLists.txt b/device_access/example/base_driver/CMakeLists.txt deleted file mode 100644 index 9b61853..0000000 --- a/device_access/example/base_driver/CMakeLists.txt +++ /dev/null @@ -1,28 +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. - -add_celix_bundle(base_driver - SYMBOLIC_NAME "apache_celix_base_driver_example" - VERSION "0.0.1" - NAME "Apache Celix Device Access Base Driver Example" - SOURCES - src/activator - src/base_driver -) -target_include_directories(base_driver PRIVATE src) -target_include_directories(base_driver PUBLIC include) -target_link_libraries(base_driver PRIVATE Celix::device_access_api) http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/base_driver/README.txt ---------------------------------------------------------------------- diff --git a/device_access/example/base_driver/README.txt b/device_access/example/base_driver/README.txt deleted file mode 100644 index 4ff2190..0000000 --- a/device_access/example/base_driver/README.txt +++ /dev/null @@ -1,23 +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. - -The base driver is "special" driver that will not be loaded by the device manager. -Normally the device manager will load drivers if it find device which are idle... But before that can happen -at least one device should exists. This is the role of a base driver and it should function like a "normal" OSGi -bundle which registers a device service. - -In this example the base driver will provide two device service with a DEVICE_CATEGORY of "char". \ No newline at end of file http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/base_driver/include/base_driver_device.h ---------------------------------------------------------------------- diff --git a/device_access/example/base_driver/include/base_driver_device.h b/device_access/example/base_driver/include/base_driver_device.h deleted file mode 100644 index 78c4f46..0000000 --- a/device_access/example/base_driver/include/base_driver_device.h +++ /dev/null @@ -1,44 +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. - */ -/* - * base_driver_device.h - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#ifndef BASE_DRIVER_DEVICE_H_ -#define BASE_DRIVER_DEVICE_H_ - -#include "device.h" - -#define BASE_DRIVER_SERVICE_NAME "base_driver_device_service" -#define BASE_DRIVER_DEVICE_CATEGORY "char" - -typedef struct base_driver_device *base_driver_device_pt; - -struct base_driver_device_service { - struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/ - base_driver_device_pt baseDriverDevice; - celix_status_t (*getNextChar)(base_driver_device_pt baseDriverDevice, char *c); -}; - -typedef struct base_driver_device_service * base_driver_device_service_pt; - -#endif /* BASE_DRIVER_DEVICE_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/base_driver/src/activator.c ---------------------------------------------------------------------- diff --git a/device_access/example/base_driver/src/activator.c b/device_access/example/base_driver/src/activator.c deleted file mode 100644 index a6b9d62..0000000 --- a/device_access/example/base_driver/src/activator.c +++ /dev/null @@ -1,140 +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:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#include <stdlib.h> - -#include <celix_errno.h> -#include <bundle_activator.h> -#include <bundle_context.h> -#include <celixbool.h> -#include <device.h> - -#include "base_driver_private.h" -#include "base_driver_device.h" - -struct base_driver_bundle_instance { - bundle_context_pt context; - array_list_pt serviceRegistrations; -}; - -typedef struct base_driver_bundle_instance *base_driver_bundle_instance_pt; - -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { - printf("BASE_DRIVER: creating bundle\n"); - celix_status_t status = CELIX_SUCCESS; - base_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance)); - if (instance != NULL) { - instance->context = context; - status = arrayList_create(&instance->serviceRegistrations); - if (status == CELIX_SUCCESS) { - (*userData) = instance; - } - } else { - status = CELIX_ENOMEM; - } - return status; -} - -static celix_status_t bundleActivator_registerBaseDriverDevice(base_driver_bundle_instance_pt bi, char *serial) { - celix_status_t status = CELIX_SUCCESS; - base_driver_device_pt device = NULL; - base_driver_device_service_pt service = NULL; - status = baseDriver_create(&device); - if (status == CELIX_SUCCESS) { - status = baseDriver_createService(device, &service); - if (status == CELIX_SUCCESS) { - properties_pt props = properties_create(); - properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, BASE_DRIVER_DEVICE_CATEGORY); - properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial); - service_registration_pt service_registration = NULL; - status = bundleContext_registerService(bi->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &service_registration); - if (status == CELIX_SUCCESS) { - arrayList_add(bi->serviceRegistrations, service_registration); - } - else{ - properties_destroy(props); - } - } - } - - if (status == CELIX_SUCCESS) { - printf("BASE_DRIVER: Successfully registered device service with serial %s.\n", serial); - } else { - char error[256]; - printf("BASE_DRIVER: Unsuccessfully registered device service with serial %s. Got error: %s\n", - serial, celix_strerror(status, error, 256)); - if(service != NULL){ - baseDriver_destroyService(service); - } - if(device != NULL){ - baseDriver_destroy(device); - } - } - return status; -} - -celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { - printf("BASE_DRIVER: starting bundle\n"); - celix_status_t status = CELIX_SUCCESS; - base_driver_bundle_instance_pt bundleInstance = userData; - status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0001"); -// if (status == CELIX_SUCCESS) { -// status = bundleActivator_registerBaseDriverDevice(bundleInstance, "0002"); -// } - return status; -} - -celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) { - printf("BASE_DRIVER: stopping bundle\n"); - celix_status_t status = CELIX_SUCCESS; - base_driver_bundle_instance_pt bundleInstance = userData; - - array_list_iterator_pt iterator = arrayListIterator_create(bundleInstance->serviceRegistrations); - while (arrayListIterator_hasNext(iterator)) { - service_registration_pt reg = arrayListIterator_next(iterator); - printf("BASE_DRIVER: unregistering service\n"); - celix_status_t unregStatus = serviceRegistration_unregister(reg); - if (unregStatus != CELIX_SUCCESS) { - char error[256]; - status = CELIX_ILLEGAL_STATE; - fprintf(stderr, "Cannot unregister service. Got error %s\n", celix_strerror(unregStatus, error, 256)); - } else { - printf("BASE_DRIVER: unregistered base device service\n"); - } - } - arrayListIterator_destroy(iterator); - - return status; -} - -celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { - printf("BASE_DRIVER: destroying bundle\n"); - celix_status_t status = CELIX_SUCCESS; - base_driver_bundle_instance_pt bundleInstance = userData; - - arrayList_destroy(bundleInstance->serviceRegistrations); - return status; -} - http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/base_driver/src/base_driver.c ---------------------------------------------------------------------- diff --git a/device_access/example/base_driver/src/base_driver.c b/device_access/example/base_driver/src/base_driver.c deleted file mode 100644 index a48c7de..0000000 --- a/device_access/example/base_driver/src/base_driver.c +++ /dev/null @@ -1,111 +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. - */ -/* - * base_driver.c - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#include <stdlib.h> -#include <string.h> -#include <celix_errno.h> -#include <bundle_activator.h> -#include <bundle_context.h> -#include <celixbool.h> -#include <device.h> - -#include "base_driver_device.h" -#include "base_driver_private.h" - -static const char * INPUT_STRING = "Lorem ipsum dolor sit amet consectetur adipiscing elit "; - -struct device { - /*NOTE: for this example we use a empty device structure*/ -}; - -struct base_driver_device { - device_pt device; - char *input; - int inputLength; - int currentChar; -}; - -celix_status_t baseDriver_noDriverFound(device_pt device) { - printf("BASE_DRIVER: No driver found\n"); - return CELIX_SUCCESS; -} - -celix_status_t baseDriver_create(base_driver_device_pt *baseDriverDevice) { - celix_status_t status = CELIX_SUCCESS; - (*baseDriverDevice) = calloc(1, sizeof(struct base_driver_device)); - if (*baseDriverDevice != NULL) { - (*baseDriverDevice)->currentChar = 0; - (*baseDriverDevice)->input = (char *)INPUT_STRING; - (*baseDriverDevice)->inputLength=strlen(INPUT_STRING); - (*baseDriverDevice)->device = calloc(1, sizeof(*(*baseDriverDevice)->device)); - if ((*baseDriverDevice)->device == NULL) { - status = CELIX_ENOMEM; - } - } else { - status = CELIX_ENOMEM; - } - return status; -} - -celix_status_t baseDriver_createService(base_driver_device_pt baseDriverDevice, base_driver_device_service_pt *service) { - celix_status_t status = CELIX_SUCCESS; - (*service) = calloc(1, sizeof(struct base_driver_device_service)); - if ((*service) != NULL) { - (*service)->deviceService.noDriverFound = baseDriver_noDriverFound; - (*service)->deviceService.device = baseDriverDevice->device; - (*service)->getNextChar=baseDriver_getNextChar; - (*service)->baseDriverDevice = baseDriverDevice; - } else { - status = CELIX_ENOMEM; - } - return status; -} - -celix_status_t baseDriver_getNextChar(base_driver_device_pt device, char *c) { - (*c) = device->input[device->currentChar]; - device->currentChar+=1; - if (device->currentChar >= device->inputLength) { - device->currentChar = 0; - } - return CELIX_SUCCESS; -} - -celix_status_t baseDriver_destroy(base_driver_device_pt device){ - if(device != NULL){ - if(device->device != NULL){ - free(device->device); - } - free(device); - } - return CELIX_SUCCESS; -} - -celix_status_t baseDriver_destroyService(base_driver_device_service_pt service){ - if(service != NULL){ - free(service); - } - - return CELIX_SUCCESS; -} http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/base_driver/src/base_driver_private.h ---------------------------------------------------------------------- diff --git a/device_access/example/base_driver/src/base_driver_private.h b/device_access/example/base_driver/src/base_driver_private.h deleted file mode 100644 index 3ee5814..0000000 --- a/device_access/example/base_driver/src/base_driver_private.h +++ /dev/null @@ -1,41 +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. - */ -/* - * base_driver_private.h - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#ifndef BASE_DRIVER_PRIVATE_H_ -#define BASE_DRIVER_PRIVATE_H_ - -#include "base_driver_device.h" - -celix_status_t baseDriver_create(base_driver_device_pt *service); -celix_status_t baseDriver_createService(base_driver_device_pt device, base_driver_device_service_pt *service); - -celix_status_t baseDriver_noDriverFound(device_pt device); - -celix_status_t baseDriver_getNextChar(base_driver_device_pt service, char *c); - -celix_status_t baseDriver_destroy(base_driver_device_pt device); -celix_status_t baseDriver_destroyService(base_driver_device_service_pt service); - -#endif /* BASE_DRIVER_PRIVATE_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/consuming_driver/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/device_access/example/consuming_driver/CMakeLists.txt b/device_access/example/consuming_driver/CMakeLists.txt deleted file mode 100644 index 3f6730e..0000000 --- a/device_access/example/consuming_driver/CMakeLists.txt +++ /dev/null @@ -1,29 +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. - -add_celix_bundle(word_consumingdriver - SYMBOLIC_NAME "apache_celix_word_consuming_driver_example" - VERSION "0.0.1" - NAME "Apache Celix Device Access Word Consuming Driver Example" - SOURCES - src/activator - src/consuming_driver -) - -target_include_directories(word_consumingdriver PRIVATE src) - -target_link_libraries(word_consumingdriver PRIVATE Celix::device_access_api base_driver char_refiningdriver) http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/consuming_driver/README.txt ---------------------------------------------------------------------- diff --git a/device_access/example/consuming_driver/README.txt b/device_access/example/consuming_driver/README.txt deleted file mode 100644 index 769d60f..0000000 --- a/device_access/example/consuming_driver/README.txt +++ /dev/null @@ -1,23 +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. - - -A consuming driver will be able to attach to certain device services, -but will not - in contrast with a refining driver - publish device services. - -In this example the consuming driver will look for "word" services and will print the result a few times. - http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/consuming_driver/src/activator.c ---------------------------------------------------------------------- diff --git a/device_access/example/consuming_driver/src/activator.c b/device_access/example/consuming_driver/src/activator.c deleted file mode 100644 index 2004657..0000000 --- a/device_access/example/consuming_driver/src/activator.c +++ /dev/null @@ -1,104 +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:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#include <stdlib.h> - -#include <celix_errno.h> -#include <bundle_activator.h> -#include <bundle_context.h> -#include <celixbool.h> -#include <device.h> - -#include "consuming_driver_private.h" - -struct consuming_driver_bundle_instance { - bundle_context_pt context; - service_registration_pt registration; -}; - -typedef struct consuming_driver_bundle_instance *consuming_driver_bundle_instance_pt; - -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { - printf("CONSUMING_DRIVER: creating bundle\n"); - celix_status_t status = CELIX_SUCCESS; - consuming_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance)); - if (instance != NULL) { - instance->context = context; - instance->registration = NULL; - (*userData) = instance; - } else { - status = CELIX_ENOMEM; - } - return status; -} - -celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { - printf("CONSUMING_DRIVER: starting bundle\n"); - celix_status_t status = CELIX_SUCCESS; - consuming_driver_bundle_instance_pt bi = userData; - - consuming_driver_pt driver = NULL; - status = consumingDriver_create(context, &driver); - if (status == CELIX_SUCCESS) { - driver_service_pt service = NULL; - status = consumingDriver_createService(driver, &service); - if (status == CELIX_SUCCESS) { - properties_pt props = properties_create(); - properties_set(props, "DRIVER_ID", CONSUMING_DRIVER_ID); - status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration); - } - } - - if (status == CELIX_SUCCESS) { - printf("CONSUMING_DRIVER: registered driver service.\n"); - } else { - char error[256]; - printf("CONSUMING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256)); - } - - return status; -} - -celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) { - printf("CONSUMING_DRIVER: stopping bundle\n"); - celix_status_t status = CELIX_SUCCESS; - consuming_driver_bundle_instance_pt bi = userData; - - if (bi->registration != NULL) { - serviceRegistration_unregister(bi->registration); - printf("CONSUMING_DRIVER: unregistered driver service\n"); - } - - return status; -} - -celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { - printf("CONSUMING_DRIVER: destroying bundle\n"); - celix_status_t status = CELIX_SUCCESS; - return status; -} - - - http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/consuming_driver/src/consuming_driver.c ---------------------------------------------------------------------- diff --git a/device_access/example/consuming_driver/src/consuming_driver.c b/device_access/example/consuming_driver/src/consuming_driver.c deleted file mode 100644 index 9106dbd..0000000 --- a/device_access/example/consuming_driver/src/consuming_driver.c +++ /dev/null @@ -1,125 +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. - */ -/* - * consuming_driver.c - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#include <stdlib.h> -#include <string.h> - -#include <device.h> -#include <service_tracker.h> -#include <service_reference.h> - -#include "celixbool.h" -#include "consuming_driver_private.h" -#include "refining_driver_device.h" - - -struct consuming_driver { - bundle_context_pt context; - array_list_pt references; -}; - -celix_status_t consumingDriver_destroy(consuming_driver_pt driver) { - printf("CONSUMING_DRIVER: cleanup\n"); - if (driver->references != NULL) { - array_list_iterator_pt iterator = arrayListIterator_create(driver->references); - while (arrayListIterator_hasNext(iterator)) { - service_reference_pt reference = arrayListIterator_next(iterator); - bool result; - bundleContext_ungetService(driver->context, reference, &result); - } - arrayListIterator_destroy(iterator); - - arrayList_destroy(driver->references); - driver->references=NULL; - } - - - return CELIX_SUCCESS; -} - -celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver) { - celix_status_t status = CELIX_SUCCESS; - (*driver) = calloc(1, sizeof(**driver)); - if ((*driver) != NULL) { - (*driver)->context=context; - (*driver)->references=NULL; - - status = arrayList_create(&(*driver)->references); - } else { - status = CELIX_ENOMEM; - } - return status; -} - -celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service) { - celix_status_t status = CELIX_SUCCESS; - (*service) = calloc(1, sizeof(**service)); - if ((*service) != NULL) { - (*service)->driver = driver; - (*service)->attach = consumingDriver_attach; - (*service)->match = consumingDriver_match; - } else { - status = CELIX_ENOMEM; - } - return status; -} - -celix_status_t consumingDriver_attach(void * driverHandler, service_reference_pt reference, char **result) { - printf("CONSUMING_DRIVER: attached called\n"); - celix_status_t status = CELIX_SUCCESS; - consuming_driver_pt driver = driverHandler; - (*result) = NULL; - refining_driver_device_service_pt device_service = NULL; - - status = bundleContext_getService(driver->context, reference, (void **)&device_service); - if (status == CELIX_SUCCESS) { - arrayList_add(driver->references, reference); - //consume the device - for (int i=0; i<15; i++) { - char *str = NULL; - device_service->getNextWord(device_service->refiningDriverDevice, &str); - printf("CONSUMING_DEVICE: Word Device result is %s\n", str); - } - } - return status; -} - -celix_status_t consumingDriver_match(void *driverHandler, service_reference_pt reference, int *value) { - printf("CONSUMING_DRIVER: match called\n"); - int match=0; - celix_status_t status = CELIX_SUCCESS; - - const char* category = NULL; - status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category); - if (status == CELIX_SUCCESS) { - if (strcmp(category, REFINING_DRIVER_DEVICE_CATEGORY) == 0) { - match = 10; - } - } - - (*value) = match; - return status; -} - http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/consuming_driver/src/consuming_driver_private.h ---------------------------------------------------------------------- diff --git a/device_access/example/consuming_driver/src/consuming_driver_private.h b/device_access/example/consuming_driver/src/consuming_driver_private.h deleted file mode 100644 index 261bb52..0000000 --- a/device_access/example/consuming_driver/src/consuming_driver_private.h +++ /dev/null @@ -1,43 +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. - */ -/* - * consuming_driver_private.h - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#ifndef CONSUMING_DRIVER_PRIVATE_H_ -#define CONSUMING_DRIVER_PRIVATE_H_ - -#include <celix_errno.h> -#include <service_reference.h> -#include <driver.h> - -#define CONSUMING_DRIVER_ID "CONSUMING_DRIVER" - -typedef struct consuming_driver *consuming_driver_pt; - -celix_status_t consumingDriver_create(bundle_context_pt context, consuming_driver_pt *driver); -celix_status_t consumingDriver_createService(consuming_driver_pt driver, driver_service_pt *service); - -celix_status_t consumingDriver_attach(void *driver, service_reference_pt reference, char **result); -celix_status_t consumingDriver_match(void *driver, service_reference_pt reference, int *value); - -#endif /* CONSUMING_DRIVER_PRIVATE_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/refining_driver/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/device_access/example/refining_driver/CMakeLists.txt b/device_access/example/refining_driver/CMakeLists.txt deleted file mode 100644 index ba0469c..0000000 --- a/device_access/example/refining_driver/CMakeLists.txt +++ /dev/null @@ -1,29 +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. - -add_celix_bundle(char_refiningdriver - SYMBOLIC_NAME "apache_celix_char_refining_driver_example" - NAME "Apache Celix Device Access Char Refining Driver Example" - VERSION "0.0.1" - SOURCES - src/activator - src/refining_driver -) - -target_include_directories(char_refiningdriver PRIVATE src) -target_include_directories(char_refiningdriver PUBLIC include) -target_link_libraries(char_refiningdriver PRIVATE Celix::device_access_api base_driver) http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/refining_driver/README.txt ---------------------------------------------------------------------- diff --git a/device_access/example/refining_driver/README.txt b/device_access/example/refining_driver/README.txt deleted file mode 100644 index d8697af..0000000 --- a/device_access/example/refining_driver/README.txt +++ /dev/null @@ -1,22 +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. - -A refining driver is a driver which is able to attache to certained device services and -as result publishes differerent - refined - device services. -This example will attach to device services with a "char" device category and publish -- for every char device services found - a "word" device services. - http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/refining_driver/include/refining_driver_device.h ---------------------------------------------------------------------- diff --git a/device_access/example/refining_driver/include/refining_driver_device.h b/device_access/example/refining_driver/include/refining_driver_device.h deleted file mode 100644 index 728725e..0000000 --- a/device_access/example/refining_driver/include/refining_driver_device.h +++ /dev/null @@ -1,45 +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. - */ -/* - * refining_driver_device.h - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#ifndef REFINING_DRIVER_DEVICE_H_ -#define REFINING_DRIVER_DEVICE_H_ - -#include "device.h" - -#define REFINING_DRIVER_SERVICE_NAME "refining_driver_device_service" -#define REFINING_DRIVER_DEVICE_CATEGORY "word" -#define REFINING_DRIVER_DEVICE_SERVIC_NAME "refining_driver_device" - -typedef struct refining_driver_device *refining_driver_device_pt; - -struct refining_driver_device_service { - struct device_service deviceService; /*NOTE: base_driver_device_service is a device_service.*/ - refining_driver_device_pt refiningDriverDevice; - celix_status_t (*getNextWord)(refining_driver_device_pt refiningDriverDevice, char **c); -}; - -typedef struct refining_driver_device_service * refining_driver_device_service_pt; - -#endif /* REFINING_DRIVER_DEVICE_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/refining_driver/src/activator.c ---------------------------------------------------------------------- diff --git a/device_access/example/refining_driver/src/activator.c b/device_access/example/refining_driver/src/activator.c deleted file mode 100644 index 233b150..0000000 --- a/device_access/example/refining_driver/src/activator.c +++ /dev/null @@ -1,104 +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:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#include <stdlib.h> - -#include <celix_errno.h> -#include <bundle_activator.h> -#include <bundle_context.h> -#include <celixbool.h> -#include <device.h> - -#include "refining_driver_private.h" - -struct refining_driver_bundle_instance { - bundle_context_pt context; - service_registration_pt registration; -}; - -typedef struct refining_driver_bundle_instance *refining_driver_bundle_instance_pt; - -celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { - printf("REFINING_DRIVER: creating bundle\n"); - celix_status_t status = CELIX_SUCCESS; - refining_driver_bundle_instance_pt instance = calloc(1, sizeof(*instance)); - if (instance != NULL) { - instance->context = context; - instance->registration = NULL; - (*userData) = instance; - } else { - status = CELIX_ENOMEM; - } - return status; -} - -celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { - printf("REFINING_DRIVER: starting bundle\n"); - celix_status_t status = CELIX_SUCCESS; - refining_driver_bundle_instance_pt bi = userData; - - refining_driver_pt driver = NULL; - status = refiningDriver_create(context, &driver); - if (status == CELIX_SUCCESS) { - driver_service_pt service = NULL; - status = refiningDriver_createService(driver, &service); - if (status == CELIX_SUCCESS) { - properties_pt props = properties_create(); - properties_set(props, "DRIVER_ID", REFINING_DRIVER_ID); - status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration); - } - } - - if (status == CELIX_SUCCESS) { - printf("REFINING_DRIVER: registered driver service.\n"); - } else { - char error[256]; - printf("REFINING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256)); - } - - return status; -} - -celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) { - printf("REFINING_DRIVER: stopping bundle\n"); - celix_status_t status = CELIX_SUCCESS; - refining_driver_bundle_instance_pt bi = userData; - - if (bi->registration != NULL) { - serviceRegistration_unregister(bi->registration); - printf("REFINING_DRIVER: unregistered driver service\n"); - } - - return status; -} - -celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) { - printf("REFINING_DRIVER: destroying bundle\n"); - celix_status_t status = CELIX_SUCCESS; - return status; -} - - - http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/refining_driver/src/refining_driver.c ---------------------------------------------------------------------- diff --git a/device_access/example/refining_driver/src/refining_driver.c b/device_access/example/refining_driver/src/refining_driver.c deleted file mode 100644 index 404bc42..0000000 --- a/device_access/example/refining_driver/src/refining_driver.c +++ /dev/null @@ -1,281 +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. - */ -/* - * refining_driver.c - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#include <stdlib.h> -#include <string.h> - -#include <device.h> -#include <bundle_context.h> -#include <service_event.h> - -#include "refining_driver_private.h" -#include "base_driver_device.h" - -static const int MAX_BUFF_SIZE = 1024; - -struct refining_driver { - device_pt device; - bundle_context_pt context; - int deviceCount; - array_list_pt devices; -}; - -struct device { - /*NOTE: for this example we use a empty device structure*/ -}; - -struct refining_driver_device { - device_pt device; - base_driver_device_service_pt baseDriverDeviceService; - refining_driver_pt driver; - service_reference_pt baseServiceReference; - service_registration_pt deviceRegistration; - service_listener_pt listener; -}; - -celix_status_t refiningDriver_destroy(refining_driver_pt driver) { - if (driver != NULL) { - if (driver->devices != NULL) { - arrayList_destroy(driver->devices); - driver->devices=NULL; - } - } - return CELIX_SUCCESS; -} - -celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver) { - celix_status_t status = CELIX_SUCCESS; - (*driver) = calloc(1, sizeof(**driver)); - if ((*driver) != NULL) { - (*driver)->context=context; - (*driver)->deviceCount=0; - (*driver)->device = calloc(1, sizeof(*(*driver)->device)); - (*driver)->devices=NULL; - status = arrayList_create(&(*driver)->devices); - } else { - status = CELIX_ENOMEM; - } - return status; -} - -celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service) { - celix_status_t status = CELIX_SUCCESS; - (*service) = calloc(1, sizeof(**service)); - if ((*service) != NULL) { - (*service)->driver = driver; - (*service)->attach = refiningDriver_attach; - (*service)->match = refiningDriver_match; - } else { - status = CELIX_ENOMEM; - } - return status; -} - -static celix_status_t refiningDriver_stopDevice(refining_driver_device_pt device) { - printf("REFINING_DRIVER: stopping device, parent device is unregistered\n"); - celix_status_t status = CELIX_SUCCESS; - - if (device->deviceRegistration != NULL) { - status = serviceRegistration_unregister(device->deviceRegistration); - if (status == CELIX_SUCCESS) { - printf("unregistered refining device\n"); - } - } - - arrayList_removeElement(device->driver->devices, device); - return status; -} - - -static celix_status_t refiningDriver_serviceChanged(service_listener_pt listener, service_event_pt event) { - celix_status_t status = CELIX_SUCCESS; - refining_driver_device_pt device = listener->handle; - if (event->type == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) { - bool equal = false; - status = serviceReference_equals(device->baseServiceReference, event->reference, &equal); - if (status == CELIX_SUCCESS && equal) { - refiningDriver_stopDevice(device); - } - } - return status; -} - -celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device) { - return CELIX_SUCCESS; -} - -celix_status_t refining_driver_cleanup_device(refining_driver_device_pt handler) { - celix_status_t status = CELIX_SUCCESS;; - refining_driver_device_pt device = handler; - if (device != NULL) { - if (device->listener != NULL) { - bundleContext_removeServiceListener(device->driver->context, device->listener); - } - } - return status; -} - -celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseService, refining_driver_device_pt *device) { - celix_status_t status = CELIX_SUCCESS; - - (*device) = calloc(1, sizeof(**device)); - if ((*device) != NULL) { - (*device)->driver=driver; - (*device)->baseDriverDeviceService=baseService; - (*device)->baseServiceReference=reference; - (*device)->deviceRegistration=NULL; - (*device)->listener=NULL; - - service_listener_pt listener = calloc(1, sizeof(*listener)); - listener->handle=(void *)(*device); - listener->serviceChanged=(celix_status_t (*)(void * listener, service_event_pt event))refiningDriver_serviceChanged; - bundleContext_addServiceListener(driver->context, listener, NULL); - (*device)->listener=listener; - - arrayList_add(driver->devices, (*device)); - } else { - status = CELIX_ENOMEM; - } - - return status; -} - - -static celix_status_t refiningDriver_registerDevice(refining_driver_pt driver, refining_driver_device_pt device, char *serial) { - celix_status_t status = CELIX_SUCCESS; - refining_driver_device_service_pt service = NULL; - status = refiningDriverDevice_createService(device, &service); - properties_pt props = properties_create(); - - if (status == CELIX_SUCCESS) { - properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, REFINING_DRIVER_DEVICE_CATEGORY); - properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial); - status = bundleContext_registerService(driver->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &device->deviceRegistration); - } - - if (status == CELIX_SUCCESS) { - printf("REFINING_DRIVER: registered refining device with serial %s\n", serial); - } - else{ - properties_destroy(props); - refiningDriverDevice_destroyService(service); - } - return status; -} - -celix_status_t refiningDriver_attach(void * driverHandler, service_reference_pt reference, char **result) { - printf("REFINING_DRIVER: attached called\n"); - celix_status_t status = CELIX_SUCCESS; - refining_driver_pt driver = driverHandler; - (*result) = NULL; - base_driver_device_service_pt device_service = NULL; - status = bundleContext_getService(driver->context, reference, (void **)&device_service); - if (status == CELIX_SUCCESS) { - refining_driver_device_pt refiningDevice = NULL; - status = refiningDriver_createDevice(driver, reference, device_service, &refiningDevice); - if (status == CELIX_SUCCESS) { - driver->deviceCount+=1; - char serial[5]; - sprintf(serial, "%4i", driver->deviceCount); - status = refiningDriver_registerDevice(driver, refiningDevice, serial); - } - } - return status; -} - -celix_status_t refiningDriver_match(void *driverHandler, service_reference_pt reference, int *value) { - printf("REFINING_DRIVER: match called\n"); - int match = 0; - celix_status_t status = CELIX_SUCCESS; - - const char* category = NULL; - status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category); - if (status == CELIX_SUCCESS) { - if (strcmp(category, BASE_DRIVER_DEVICE_CATEGORY) == 0) { - match = 10; - } - } - - (*value) = match; - return status; -} - -celix_status_t refiningDriverDevice_createService(refining_driver_device_pt device, refining_driver_device_service_pt *service) { - celix_status_t status = CELIX_SUCCESS; - (*service) = calloc(1, sizeof(**service)); - if ((*service) != NULL) { - (*service)->deviceService.device=calloc(1, sizeof(*(*service)->deviceService.device)); - if ((*service)->deviceService.device != NULL) { - (*service)->deviceService.noDriverFound=refiningDriverDevice_noDriverFound; - (*service)->refiningDriverDevice=device; - (*service)->getNextWord=refiningDriverDevice_getNextWord; - } else { - status = CELIX_ENOMEM; - } - } else { - status = CELIX_ENOMEM; - } - return status; -} - -celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service){ - if(service != NULL){ - if(service->deviceService.device != NULL){ - free(service->deviceService.device); - } - free(service); - } - return CELIX_SUCCESS; -} - -celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word) { - celix_status_t status = CELIX_SUCCESS; - base_driver_device_pt baseDevice = refiningDriverDevice->baseDriverDeviceService->baseDriverDevice; - char buff[MAX_BUFF_SIZE]; - int i=0; - status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]); - while (buff[i] != ' ' && i < (MAX_BUFF_SIZE-1) && status == CELIX_SUCCESS) { - i+=1; - status = refiningDriverDevice->baseDriverDeviceService->getNextChar(baseDevice, &buff[i]); - } - if (status == CELIX_SUCCESS) { - buff[i] = '\0'; - char *copy = calloc(1, (i+1)); - if (copy != NULL) { - strcpy(copy, buff); - (*word)=copy; - } else { - status = CELIX_ENOMEM; - } - } - - return status; -} - -celix_status_t refiningDriverDevice_noDriverFound(device_pt device) { - printf("REFINING_DRIVER: no driver found"); - return CELIX_SUCCESS; -} - http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/device_access/example/refining_driver/src/refining_driver_private.h ---------------------------------------------------------------------- diff --git a/device_access/example/refining_driver/src/refining_driver_private.h b/device_access/example/refining_driver/src/refining_driver_private.h deleted file mode 100644 index 37f15a5..0000000 --- a/device_access/example/refining_driver/src/refining_driver_private.h +++ /dev/null @@ -1,58 +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. - */ -/* - * refining_driver_private.h - * - * \date Jun 20, 2011 - * \author <a href="mailto:d...@celix.apache.org">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ -#ifndef REFINING_DRIVER_PRIVATE_H_ -#define REFINING_DRIVER_PRIVATE_H_ - -#include <celix_errno.h> -#include <service_reference.h> -#include <driver.h> - -#include "refining_driver_device.h" -#include "base_driver_device.h" - -#define REFINING_DRIVER_ID "REFINING_DRIVER" - -typedef struct refining_driver *refining_driver_pt; - -celix_status_t refiningDriver_create(bundle_context_pt context, refining_driver_pt *driver); -celix_status_t refiningDriver_destroy(refining_driver_pt driver); - -celix_status_t refiningDriver_createService(refining_driver_pt driver, driver_service_pt *service); - -celix_status_t refiningDriver_createDevice(refining_driver_pt driver, service_reference_pt reference, base_driver_device_service_pt baseDevice, refining_driver_device_pt *device); -celix_status_t refiningDriver_destroyDevice(refining_driver_device_pt device); - - -celix_status_t refiningDriver_attach(void *driver, service_reference_pt reference, char **result); -celix_status_t refiningDriver_match(void *driver, service_reference_pt reference, int *value); - - -celix_status_t refiningDriverDevice_noDriverFound(device_pt device); -celix_status_t refiningDriverDevice_createService(refining_driver_device_pt, refining_driver_device_service_pt *service); -celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service); -celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word); - -#endif /* REFINING_DRIVER_PRIVATE_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/dfi/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/dfi/CMakeLists.txt b/dfi/CMakeLists.txt deleted file mode 100644 index 08f373f..0000000 --- a/dfi/CMakeLists.txt +++ /dev/null @@ -1,83 +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. - -find_package(FFI REQUIRED) -find_package(Jansson REQUIRED) - -set(SOURCES - src/dyn_common.c - src/dyn_type.c - src/dyn_function.c - src/dyn_interface.c - src/dyn_message.c - src/json_serializer.c - src/json_rpc.c -) - -add_library(dfi SHARED ${SOURCES}) -set_target_properties(dfi PROPERTIES OUTPUT_NAME "celix_dfi") -target_include_directories(dfi PUBLIC - $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include> - $<INSTALL_INTERFACE:include/celix/dfi> -) - -#TODO JANNSON should be public, but this only really works if JANSSON is a imported target -#So make FindJansson deliver targets -target_include_directories(dfi SYSTEM PRIVATE - ${JANSSON_INCLUDE_DIRS} -) -target_include_directories(dfi PRIVATE src) -target_include_directories(dfi SYSTEM PRIVATE ${FFI_INCLUDE_DIRS}) -target_link_libraries(dfi PRIVATE ${JANSSON_LIBRARY}) -target_link_libraries(dfi PRIVATE Celix::utils ${FFI_LIBRARIES}) -set_target_properties(dfi PROPERTIES "SOVERSION" 1) - -install(TARGETS dfi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dfi) -install(DIRECTORY include/ DESTINATION include/celix/dfi COMPONENT dfi) - -#Alias setup to match external usage -add_library(Celix::dfi ALIAS dfi) - -if (ENABLE_TESTING) - find_package(CppUTest REQUIRED) - - include_directories(${CPPUTEST_INCLUDE_DIR}) - - SET(CMAKE_SKIP_BUILD_RPATH FALSE) #TODO needed? - SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) #TODO needed? - SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/dfi" "${PROJECT_BINARY_DIR}/utils") - - add_executable(test_dfi - test/dyn_type_tests.cpp - test/dyn_function_tests.cpp - test/dyn_closure_tests.cpp - test/dyn_interface_tests.cpp - test/dyn_message_tests.cpp - test/json_serializer_tests.cpp - test/json_rpc_tests.cpp - test/run_tests.cpp - ) - target_link_libraries(test_dfi PRIVATE Celix::dfi Celix::utils ${FFI_LIBRARIES} ${CPPUTEST_LIBRARY}) - target_include_directories(test_dfi PRIVATE ${FFI_INCLUDE_DIRS}) - - file(COPY ${CMAKE_CURRENT_LIST_DIR}/test/schemas DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - file(COPY ${CMAKE_CURRENT_LIST_DIR}/test/descriptors DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - - add_test(NAME run_test_dfi COMMAND test_dfi) - SETUP_TARGET_FOR_COVERAGE(test_dfi_cov test_dfi ${CMAKE_BINARY_DIR}/coverage/test_dfi/test_dfi) -endif(ENABLE_TESTING) - http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/dfi/include/dfi_log_util.h ---------------------------------------------------------------------- diff --git a/dfi/include/dfi_log_util.h b/dfi/include/dfi_log_util.h deleted file mode 100644 index 2bcd8fa..0000000 --- a/dfi/include/dfi_log_util.h +++ /dev/null @@ -1,63 +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. - */ -#ifndef _DFI_LOG_UTIL_H_ -#define _DFI_LOG_UTIL_H_ - -typedef void (*logf_ft)(void *handle, int level, const char *file, int line, const char *format, ...); - -#define DFI_SETUP_LOG_HEADER(cmp) \ - void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel); - -#define DFI_SETUP_LOG(cmp) \ - static logf_ft g_logf = NULL; \ - static void *g_logHandle = NULL; \ - static int g_currentLogLevel = 1; \ - \ - void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel) { \ - g_currentLogLevel = currentLogLevel; \ - g_logHandle = handle; \ - g_logf = logf; \ - } - -#define LOG_LVL_ERROR 1 -#define LOG_LVL_WARNING 2 -#define LOG_LVL_INFO 3 -#define LOG_LVL_DEBUG 4 - -#define LOG_ERROR(msg, ...) \ - if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_ERROR) { \ - g_logf(g_logHandle, LOG_LVL_ERROR, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \ - } - -#define LOG_WARNING(msg, ...) \ - if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_WARNING) { \ - g_logf(g_logHandle, LOG_LVL_WARNING, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \ - } - -#define LOG_INFO(msg, ...) \ - if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_INFO) { \ - g_logf(g_logHandle, LOG_LVL_INFO, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \ - } - -#define LOG_DEBUG(msg, ...) \ - if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_DEBUG) { \ - g_logf(g_logHandle, LOG_LVL_DEBUG, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \ - } - -#endif http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/dfi/include/dyn_common.h ---------------------------------------------------------------------- diff --git a/dfi/include/dyn_common.h b/dfi/include/dyn_common.h deleted file mode 100644 index 6ec236f..0000000 --- a/dfi/include/dyn_common.h +++ /dev/null @@ -1,47 +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. - */ -#ifndef _DYN_COMMON_H_ -#define _DYN_COMMON_H_ - -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <sys/queue.h> - -#include "dfi_log_util.h" - -//logging -DFI_SETUP_LOG_HEADER(dynCommon); - -TAILQ_HEAD(namvals_head, namval_entry); - -struct namval_entry { - char *name; - char *value; - TAILQ_ENTRY(namval_entry) entries; -}; - -int dynCommon_parseName(FILE *stream, char **result); -int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result); -int dynCommon_parseNameValue(FILE *stream, char **name, char **value); -int dynCommon_eatChar(FILE *stream, int c); - -void dynCommon_clearNamValHead(struct namvals_head *head); - -#endif http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/dfi/include/dyn_function.h ---------------------------------------------------------------------- diff --git a/dfi/include/dyn_function.h b/dfi/include/dyn_function.h deleted file mode 100644 index 7f5cd57..0000000 --- a/dfi/include/dyn_function.h +++ /dev/null @@ -1,60 +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. - */ -#ifndef __DYN_FUNCTION_H_ -#define __DYN_FUNCTION_H_ - -#include "dyn_type.h" -#include "dfi_log_util.h" - -/** - * Uses the following schema - * (Name)([Type]*)Type - * - * Dyn fynction argument meta (am) as meta info, with the following possible values - * am=handle #void pointer for the handle - * am=pre #output pointer with memory preallocated - * am=out #output pointer - */ - -typedef struct _dyn_function_type dyn_function_type; - -DFI_SETUP_LOG_HEADER(dynFunction); - -enum dyn_function_argument_meta { - DYN_FUNCTION_ARGUMENT_META__STD = 0, - DYN_FUNCTION_ARGUMENT_META__HANDLE = 1, - DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT = 2, - DYN_FUNCTION_ARGUMENT_META__OUTPUT = 3 -}; - -int dynFunction_parse(FILE *descriptorStream, struct types_head *refTypes, dyn_function_type **dynFunc); -int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **dynFunc); - -int dynFunction_nrOfArguments(dyn_function_type *dynFunc); -dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr); -enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr); -dyn_type * dynFunction_returnType(dyn_function_type *dynFunction); - -void dynFunction_destroy(dyn_function_type *dynFunc); -int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues); - -int dynFunction_createClosure(dyn_function_type *func, void (*bind)(void *, void **, void*), void *userData, void(**fn)(void)); -int dynFunction_getFnPointer(dyn_function_type *func, void (**fn)(void)); - -#endif http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/dfi/include/dyn_interface.h ---------------------------------------------------------------------- diff --git a/dfi/include/dyn_interface.h b/dfi/include/dyn_interface.h deleted file mode 100644 index 54bf41c..0000000 --- a/dfi/include/dyn_interface.h +++ /dev/null @@ -1,66 +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. - */ -#ifndef __DYN_INTERFACE_H_ -#define __DYN_INTERFACE_H_ - -#include "dyn_common.h" -#include "dyn_type.h" -#include "dyn_function.h" -#include "dfi_log_util.h" - -#include "version.h" - -DFI_SETUP_LOG_HEADER(dynInterface); - -/* Description string - * - * Descriptor (interface) = HeaderSection AnnotationSection TypesSection MethodsSection - * - * HeaderSection= - * ':header\n' [NameValue]* - * ':annotations\n' [NameValue]* - * ':types\n' [TypeIdValue]* - * ':methods\n' [MethodIdValue] - * - */ -typedef struct _dyn_interface_type dyn_interface_type; - -TAILQ_HEAD(methods_head, method_entry); -struct method_entry { - int index; - char *id; - char *name; - dyn_function_type *dynFunc; - - TAILQ_ENTRY(method_entry) entries; -}; - -int dynInterface_parse(FILE *descriptor, dyn_interface_type **out); -void dynInterface_destroy(dyn_interface_type *intf); - -int dynInterface_getName(dyn_interface_type *intf, char **name); -int dynInterface_getVersion(dyn_interface_type *intf, version_pt* version); -int dynInterface_getVersionString(dyn_interface_type *intf, char **version); -int dynInterface_getHeaderEntry(dyn_interface_type *intf, const char *name, char **value); -int dynInterface_getAnnotationEntry(dyn_interface_type *intf, const char *name, char **value); -int dynInterface_methods(dyn_interface_type *intf, struct methods_head **list); -int dynInterface_nrOfMethods(dyn_interface_type *intf); - - -#endif http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/dfi/include/dyn_message.h ---------------------------------------------------------------------- diff --git a/dfi/include/dyn_message.h b/dfi/include/dyn_message.h deleted file mode 100644 index d1c8dd7..0000000 --- a/dfi/include/dyn_message.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. - */ -#ifndef __DYN_MESSAGE_H_ -#define __DYN_MESSAGE_H_ - -#include "dyn_common.h" -#include "dyn_type.h" -#include "dfi_log_util.h" - -#include "version.h" - -DFI_SETUP_LOG_HEADER(dynMessage); - -/* Description string - * - * Descriptor (message) = HeaderSection AnnotationSection TypesSection MessageSection - * - * HeaderSection= - * ':header\n' [NameValue]* - * ':annotations\n' [NameValue]* - * ':types\n' [TypeIdValue]* - * ':message\n' [MessageIdValue] - * - */ -typedef struct _dyn_message_type dyn_message_type; - - -int dynMessage_parse(FILE *descriptor, dyn_message_type **out); -void dynMessage_destroy(dyn_message_type *msg); - -int dynMessage_getName(dyn_message_type *msg, char **name); -int dynMessage_getVersion(dyn_message_type *msg, version_pt* version); -int dynMessage_getVersionString(dyn_message_type *msg, char **version); -int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value); -int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value); -int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type); - - - -#endif http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/dfi/include/dyn_type.h ---------------------------------------------------------------------- diff --git a/dfi/include/dyn_type.h b/dfi/include/dyn_type.h deleted file mode 100644 index 554966a..0000000 --- a/dfi/include/dyn_type.h +++ /dev/null @@ -1,155 +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. - */ - -#ifndef _DYN_TYPE_H_ -#define _DYN_TYPE_H_ - -#include <stdio.h> -#include <sys/queue.h> -#include <stdbool.h> - -#include <stdint.h> - -#include "dfi_log_util.h" - -#if defined(BSD) || defined(__APPLE__) || defined(__ANDROID__) -#include "memstream/open_memstream.h" -#include "memstream/fmemopen.h" -#endif - -/* Description string - * - * Type = [TypeDef]* (MetaInfo)* (SimpleType | ComplexType | SequenceType | TypedPointer | PointerReference ) [TypeDef]* - * Name = alpha[(alpha|numeric)*] - * SPACE = ' ' - * - * SimplesTypes (based on java bytecode method signatures) - * //Java based: - * B char - * C (not supported) - * D double - * F float - * I int32_t - * J int64_t - * S int16_t - * V void - * Z boolean - * //Extended - * b unsigned char - * i uint32_t - * j uint62_t - * s uint64_t - * P untyped pointer (void *) - * t char* string - * N native int - * - * ComplexTypes (Struct) - * {[Type]+ [(Name)(SPACE)]+} - * - * ReferenceByValue - * l(name); - * - * PointerReference -> note shortcut for *l(name); - * L(Name); - * - * TypeDef - * T(Name)=Type; - * - * SequenceType - * [(Type) - * - * TypedPointer - * *(Type) - * - * MetaInfo TODO - * #Name=Value; - * - * - * - * examples - * "{DDII a b c d}" -> struct { double a; double b; int c; int d; }; - * "{DD{FF c1 c2} a b c}" -> struct { double a; double b; struct c { float c1; float c2; }; }; - * - * - */ - -#define DYN_TYPE_INVALID 0 -#define DYN_TYPE_SIMPLE 1 -#define DYN_TYPE_COMPLEX 2 -#define DYN_TYPE_SEQUENCE 3 -#define DYN_TYPE_TYPED_POINTER 4 -#define DYN_TYPE_TEXT 5 -#define DYN_TYPE_REF 6 - -typedef struct _dyn_type dyn_type; - -TAILQ_HEAD(types_head, type_entry); -struct type_entry { - dyn_type *type; - TAILQ_ENTRY(type_entry) entries; -}; - -TAILQ_HEAD(complex_type_entries_head, complex_type_entry); -struct complex_type_entry { - dyn_type *type; - char *name; - TAILQ_ENTRY(complex_type_entry) entries; -}; - -//logging -DFI_SETUP_LOG_HEADER(dynType); - -//generic -int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *refTypes, dyn_type **type); -int dynType_parseWithStr(const char *descriptor, const char *name, struct types_head *refTypes, dyn_type **type); -void dynType_destroy(dyn_type *type); - -int dynType_alloc(dyn_type *type, void **bufLoc); -void dynType_free(dyn_type *type, void *loc); - -void dynType_print(dyn_type *type, FILE *stream); -size_t dynType_size(dyn_type *type); -int dynType_type(dyn_type *type); -int dynType_descriptorType(dyn_type *type); -const char * dynType_getMetaInfo(dyn_type *type, const char *name); - -//complexType -int dynType_complex_indexForName(dyn_type *type, const char *name); -int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **subType); -int dynType_complex_setValueAt(dyn_type *type, int index, void *inst, void *in); -int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **valLoc); -int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries); - -//sequence -int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap); -int dynType_sequence_locForIndex(dyn_type *type, void *seqLoc, int index, void **valLoc); -int dynType_sequence_increaseLengthAndReturnLastLoc(dyn_type *type, void *seqLoc, void **valLoc); -dyn_type * dynType_sequence_itemType(dyn_type *type); -uint32_t dynType_sequence_length(void *seqLoc); - -//typed pointer -int dynType_typedPointer_getTypedType(dyn_type *type, dyn_type **typedType); - -//text -int dynType_text_allocAndInit(dyn_type *type, void *textLoc, const char *value); - -//simple -void dynType_simple_setValue(dyn_type *type, void *inst, void *in); - -#endif http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/dfi/include/json_rpc.h ---------------------------------------------------------------------- diff --git a/dfi/include/json_rpc.h b/dfi/include/json_rpc.h deleted file mode 100644 index 1cc1464..0000000 --- a/dfi/include/json_rpc.h +++ /dev/null @@ -1,37 +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. - */ -#ifndef __JSON_RPC_H_ -#define __JSON_RPC_H_ - -#include <jansson.h> -#include "dfi_log_util.h" -#include "dyn_type.h" -#include "dyn_function.h" -#include "dyn_interface.h" - -//logging -DFI_SETUP_LOG_HEADER(jsonRpc); - -int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, char **out); - - -int jsonRpc_prepareInvokeRequest(dyn_function_type *func, const char *id, void *args[], char **out); -int jsonRpc_handleReply(dyn_function_type *func, const char *reply, void *args[]); - -#endif