You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2005/10/10 13:27:42 UTC

svn commit: r312619 - in /webservices/axis2/trunk/c: include/axis2_log.h modules/common/src/axis2_log.c modules/common/test/main.c

Author: samisa
Date: Mon Oct 10 04:27:28 2005
New Revision: 312619

URL: http://svn.apache.org/viewcvs?rev=312619&view=rev
Log:
Added the log to be included in envioronment

Added:
    webservices/axis2/trunk/c/include/axis2_log.h
    webservices/axis2/trunk/c/modules/common/src/axis2_log.c
Modified:
    webservices/axis2/trunk/c/modules/common/test/main.c

Added: webservices/axis2/trunk/c/include/axis2_log.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_log.h?rev=312619&view=auto
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_log.h (added)
+++ webservices/axis2/trunk/c/include/axis2_log.h Mon Oct 10 04:27:28 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 AXIS2_LOG_H
+#define AXIS2_LOG_H
+
+#include <axis2_allocator.h>
+
+typedef enum axis2_log_levels
+{
+    AXIS2_LOG_DEBUG = 0,
+    AXIS2_LOG_INFO,
+    AXIS2_LOG_WARNING,
+    AXIS2_LOG_ERROR,
+    AXIS2_LOG_CRITICAL
+} axis2_log_levels_t;
+
+struct axis2_log;
+struct axis2_log_ops;
+
+typedef struct axis2_log_ops {
+    int (*write)(const void *buffer, size_t count);
+} axis2_log_ops_t;
+
+typedef struct axis2_log {
+    struct axis2_log_ops *ops;
+    axis2_log_levels_t level;
+    int enabled; /*boolean*/
+} axis2_log_t;
+
+axis2_log_t *axis2_log_create(axis2_allocator_t* allocator, axis2_log_ops_t* operations);
+
+#define axis2_log_write(log, buffer, count) ((log)->ops->write(buffer, count))
+
+
+#endif /* AXIS2_LOG_H */

Added: webservices/axis2/trunk/c/modules/common/src/axis2_log.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/common/src/axis2_log.c?rev=312619&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/common/src/axis2_log.c (added)
+++ webservices/axis2/trunk/c/modules/common/src/axis2_log.c Mon Oct 10 04:27:28 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+#include <axis2_log.h>
+#include <stdio.h>
+
+int axis2_log_ops_write(const void *buffer, size_t count);
+
+axis2_log_t *axis2_log_create(axis2_allocator_t* allocator, axis2_log_ops_t* operations)
+{
+    if (!allocator)
+        return NULL;
+
+    axis2_log_t *log = (axis2_log_t*)axis2_malloc(allocator, sizeof(axis2_log_t));
+
+    if (!log)
+        return NULL;
+    
+    if (operations)
+        log->ops = operations;
+    else
+    {
+        log->ops = (axis2_log_ops_t*)axis2_malloc(allocator, sizeof(axis2_log_ops_t));
+
+        if (!log->ops)
+        {
+            axis2_free(allocator, log);
+            return NULL;
+        }
+        
+        log->ops->write = axis2_log_ops_write;
+    }
+    
+    return log;
+}
+
+int axis2_log_ops_write(const void *buffer, size_t count)
+{
+    if (!buffer)
+        return -1;
+    
+    int i =0;
+    for(i = 0; i < count; i++)
+        fprintf(stderr, "%c", ((axis2_char*)buffer)[i]);
+    printf("\n");
+    return 0;
+}
+

Modified: webservices/axis2/trunk/c/modules/common/test/main.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/common/test/main.c?rev=312619&r1=312618&r2=312619&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/common/test/main.c (original)
+++ webservices/axis2/trunk/c/modules/common/test/main.c Mon Oct 10 04:27:28 2005
@@ -5,8 +5,9 @@
 {
     char buff[10];
     axis2_allocator_t *allocator = axis2_allocator_init(NULL);
-    axis2_environment_t *env = axis2_environment_create(allocator, NULL, NULL);
+    axis2_environment_t *env = axis2_environment_create(allocator, NULL, NULL, NULL);
     axis2_stream_read(env->stream, buff, 10);
     axis2_stream_write(env->stream, buff, 10);
+    axis2_log_write(env->log, buff, 10);
     return 0;
 }