Check-in Number:
|
1251 | |
Date: |
2001-Nov-04 14:55:06 (local)
2001-Nov-04 13:55:06 (UTC) |
User: | rse |
Branch: | |
Comment: |
code cleanups |
Tickets: |
|
Inspections: |
|
Files: |
|
ossp-pkg/l2/l2_channel.c 1.22 -> 1.23
--- l2_channel.c 2001/11/04 13:21:17 1.22
+++ l2_channel.c 2001/11/04 13:55:06 1.23
@@ -24,15 +24,12 @@
** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
-** l2_channel.c: channel handling
+** l2_channel.c: channel object
**
*/
-#include "l2.h"
#include "l2_p.h"
-#include <string.h>
-
/*
* A channel is the central object for a logging stream. It is
* implemented by a framework (the code implemented here) which provides
|
|
ossp-pkg/l2/l2_env.c 1.1 -> 1.2
--- l2_env.c 2001/11/04 13:21:17 1.1
+++ l2_env.c 2001/11/04 13:55:06 1.2
@@ -24,30 +24,36 @@
** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
-** l2_env.c: environment
-**
+** l2_env.c: environment object
*/
-#include "l2.h"
#include "l2_p.h"
/* create environment object */
-l2_result_t l2_env_create(l2_env_t **env)
+l2_result_t l2_env_create(l2_env_t **envp)
{
+ l2_env_t *env;
int i;
+
+ /* argument sanity check */
+ if (envp == NULL)
+ return L2_ERR_ARG;
- /* allocate env structure */
- if (((*env) = (l2_env_t *)malloc(sizeof(l2_env_t))) == NULL)
+ /* allocate environment structure */
+ if ((env = (l2_env_t *)malloc(sizeof(l2_env_t))) == NULL)
return L2_ERR_SYS;
- /* initialize env structure */
- (*env)->rvErrorInfo = L2_OK;
- (*env)->szErrorInfo[0] = '\0';
- (*env)->szError[0] = '\0';
- (*env)->levelmask = L2_LEVEL_ALL;
- (*env)->flushmask = L2_LEVEL_NONE;
+ /* initialize environment structure */
+ env->rvErrorInfo = L2_OK;
+ env->szErrorInfo[0] = '\0';
+ env->szError[0] = '\0';
+ env->levelmask = L2_LEVEL_ALL;
+ env->flushmask = L2_LEVEL_NONE;
for (i = 0; i < L2_MAX_FORMATTERS; i++)
- (*env)->formatters[i].cb = NULL;
+ env->formatters[i].cb = NULL;
+
+ /* pass new object to caller */
+ (*envp) = env;
return L2_OK;
}
@@ -96,13 +102,14 @@
return L2_ERR_MEM;
/* attach formatter to env */
- env->formatters[i].id = id;
- env->formatters[i].ctx = ctx;
- env->formatters[i].cb = cb;
+ env->formatters[i].id = id;
+ env->formatters[i].ctx = ctx;
+ env->formatters[i].cb = cb;
return L2_OK;
}
+/* remember additional error information */
l2_result_t l2_env_errorinfo(l2_env_t *env, l2_result_t rv, const char *fmt, ...)
{
va_list ap;
@@ -120,6 +127,7 @@
return L2_OK;
}
+/* retrieve string description of error result code */
char *l2_env_strerror(l2_env_t *env, l2_result_t rv)
{
char *sz;
|
|
ossp-pkg/l2/l2_p.h 1.28 -> 1.29
--- l2_p.h 2001/11/04 13:46:25 1.28
+++ l2_p.h 2001/11/04 13:55:06 1.29
@@ -32,6 +32,7 @@
/* include standard headers */
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
/* include private headers */
@@ -65,14 +66,17 @@
if (expr) \
cu(value)
+/* some hard-coded sizes :-( */
#define L2_MAX_MSGSIZE 4096
#define L2_MAX_FORMATTERS 128
+/* internal channel state */
typedef enum {
L2_CHSTATE_CREATED,
L2_CHSTATE_OPENED
} l2_chstate_t;
+/* channel object structure */
struct l2_channel_st {
l2_env_t *env;
l2_chstate_t state;
@@ -85,12 +89,14 @@
unsigned int flushmask;
};
+/* formatter entry structure */
typedef struct {
l2_formatter_t cb;
void *ctx;
char id;
} l2_formatter_entry_t;
+/* environment object structure */
struct l2_env_st {
unsigned int levelmask;
unsigned int flushmask;
|
|