Author: abroekhuis
Date: Tue Oct  1 11:43:57 2013
New Revision: 1528049

URL: http://svn.apache.org/r1528049
Log:
CELIX-28: Updated error codes. Used only part of the patch. Updated the 
strerror method to be similar to the strerror method of APR.

Modified:
    
incubator/celix/trunk/device_access/example/base_driver/private/src/activator.c
    
incubator/celix/trunk/device_access/example/consuming_driver/private/src/activator.c
    
incubator/celix/trunk/device_access/example/refining_driver/private/src/activator.c
    incubator/celix/trunk/examples/whiteboard/publisherA/private/src/activator.c
    incubator/celix/trunk/framework/private/src/celix_errorcodes.c
    incubator/celix/trunk/framework/public/include/celix_errno.h

Modified: 
incubator/celix/trunk/device_access/example/base_driver/private/src/activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/device_access/example/base_driver/private/src/activator.c?rev=1528049&r1=1528048&r2=1528049&view=diff
==============================================================================
--- 
incubator/celix/trunk/device_access/example/base_driver/private/src/activator.c 
(original)
+++ 
incubator/celix/trunk/device_access/example/base_driver/private/src/activator.c 
Tue Oct  1 11:43:57 2013
@@ -92,8 +92,9 @@ static celix_status_t bundleActivator_re
        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));
+                               serial, celix_strerror(status, error, 256));
        }
        return status;
 }
@@ -120,8 +121,9 @@ celix_status_t bundleActivator_stop(void
                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));
+                       fprintf(stderr, "Cannot unregister service. Got error 
%s\n", celix_strerror(unregStatus, error, 256));
                } else {
                        printf("BASE_DRIVER: unregistered base device 
service\n");
                }

Modified: 
incubator/celix/trunk/device_access/example/consuming_driver/private/src/activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/device_access/example/consuming_driver/private/src/activator.c?rev=1528049&r1=1528048&r2=1528049&view=diff
==============================================================================
--- 
incubator/celix/trunk/device_access/example/consuming_driver/private/src/activator.c
 (original)
+++ 
incubator/celix/trunk/device_access/example/consuming_driver/private/src/activator.c
 Tue Oct  1 11:43:57 2013
@@ -82,7 +82,8 @@ celix_status_t bundleActivator_start(voi
        if (status == CELIX_SUCCESS) {
                printf("CONSUMING_DRIVER: registered driver service.\n");
        } else {
-               printf("CONSUMING_DRIVER: Could not register driver service. 
Get error %s\n", celix_strerror(status));
+               char error[256];
+               printf("CONSUMING_DRIVER: Could not register driver service. 
Get error %s\n", celix_strerror(status, error, 256));
        }
 
        return status;

Modified: 
incubator/celix/trunk/device_access/example/refining_driver/private/src/activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/device_access/example/refining_driver/private/src/activator.c?rev=1528049&r1=1528048&r2=1528049&view=diff
==============================================================================
--- 
incubator/celix/trunk/device_access/example/refining_driver/private/src/activator.c
 (original)
+++ 
incubator/celix/trunk/device_access/example/refining_driver/private/src/activator.c
 Tue Oct  1 11:43:57 2013
@@ -82,7 +82,8 @@ celix_status_t bundleActivator_start(voi
        if (status == CELIX_SUCCESS) {
                printf("REFINING_DRIVER: registered driver service.\n");
        } else {
-               printf("REFINING_DRIVER: Could not register driver service. Get 
error %s\n", celix_strerror(status));
+               char error[256];
+               printf("REFINING_DRIVER: Could not register driver service. Get 
error %s\n", celix_strerror(status, error, 256));
        }
 
        return status;

Modified: 
incubator/celix/trunk/examples/whiteboard/publisherA/private/src/activator.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/publisherA/private/src/activator.c?rev=1528049&r1=1528048&r2=1528049&view=diff
==============================================================================
--- 
incubator/celix/trunk/examples/whiteboard/publisherA/private/src/activator.c 
(original)
+++ 
incubator/celix/trunk/examples/whiteboard/publisherA/private/src/activator.c 
Tue Oct  1 11:43:57 2013
@@ -68,7 +68,8 @@ celix_status_t bundleActivator_start(voi
 
         status = bundleContext_registerService(context, PUBLISHER_NAME, 
data->ps, props, &data->reg);
         if (status != CELIX_SUCCESS) {
-               printf("Error: %s\n", celix_strerror(status));
+               char error[256];
+               printf("Error: %s\n", celix_strerror(status, error, 256));
         }
     } else {
         status = CELIX_BUNDLE_EXCEPTION;

Modified: incubator/celix/trunk/framework/private/src/celix_errorcodes.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/celix_errorcodes.c?rev=1528049&r1=1528048&r2=1528049&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/celix_errorcodes.c (original)
+++ incubator/celix/trunk/framework/private/src/celix_errorcodes.c Tue Oct  1 
11:43:57 2013
@@ -23,23 +23,38 @@
  *  \author            <a href="mailto:[email protected]";>Apache 
Celix Project Team</a>
  *  \copyright Apache License, Version 2.0
  */
+#include <apr_strings.h>
+
 #include "celix_errno.h"
 
 static char *celix_error_string(celix_status_t statcode) {
-    switch (statcode) {
-    case CELIX_ENOMEM:
-        return "Out off memory";
-    case CELIX_ILLEGAL_ARGUMENT:
-        return "Illegal argument";
-    }
+       switch (statcode) {
+       case CELIX_BUNDLE_EXCEPTION:
+               return "Bundle exception";
+       case CELIX_INVALID_BUNDLE_CONTEXT:
+               return "Invalid bundle context";
+       case CELIX_ILLEGAL_ARGUMENT:
+               return "Illegal argument";
+       case CELIX_INVALID_SYNTAX:
+               return "Invalid syntax";
+       case CELIX_FRAMEWORK_SHUTDOWN:
+               return "Framework shutdown";
+       case CELIX_ILLEGAL_STATE:
+               return "Illegal state";
+       case CELIX_FRAMEWORK_EXCEPTION:
+               return "Framework exception";
+       case CELIX_FILE_IO_EXCEPTION:
+               return "File I/O exception";
+       }
        return "Unkown code";
 }
 
-char *celix_strerror(celix_status_t errorcode)
-{
+char *celix_strerror(celix_status_t errorcode, char *buffer, size_t 
bufferSize) {
     if (errorcode < CELIX_START_ERROR) {
-        return "No message";
+       return apr_strerror(errorcode, buffer, bufferSize);
     } else {
-        return celix_error_string(errorcode);
+       char * str = celix_error_string(errorcode);
+       apr_cpystrn(buffer, str, bufferSize);
+        return buffer;
     }
 }

Modified: incubator/celix/trunk/framework/public/include/celix_errno.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/celix_errno.h?rev=1528049&r1=1528048&r2=1528049&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/celix_errno.h (original)
+++ incubator/celix/trunk/framework/public/include/celix_errno.h Tue Oct  1 
11:43:57 2013
@@ -57,7 +57,7 @@ typedef apr_status_t celix_status_t;
  * Return a readable string for the given error code.
  *
  */
-FRAMEWORK_EXPORT char *celix_strerror(celix_status_t errorcode);
+FRAMEWORK_EXPORT char *celix_strerror(celix_status_t errorcode, char *buffer, 
size_t bufferSize);
 
 /*!
  * Error code indicating successful execution of the function.


Reply via email to