queueing done
This commit is contained in:
parent
7a245f05cb
commit
80ee17692a
6 changed files with 32 additions and 37 deletions
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
#include "spho/data.h"
|
#include "spho/data.h"
|
||||||
|
|
||||||
|
#define SPHO_ERR_BUF_LEN 2048
|
||||||
|
#define SPHO_ERR_FILEBUF_LEN 128
|
||||||
|
|
||||||
struct spho_ctx {
|
struct spho_ctx {
|
||||||
int err;
|
int err;
|
||||||
int err_info;
|
int err_info;
|
||||||
|
@ -20,6 +23,6 @@ struct spho_ctx {
|
||||||
|
|
||||||
struct spho_ctx *spho_ctx_create(void);
|
struct spho_ctx *spho_ctx_create(void);
|
||||||
void spho_ctx_destroy(struct spho_ctx *);
|
void spho_ctx_destroy(struct spho_ctx *);
|
||||||
char *spho_ctx_strerror(struct spho_ctx *);
|
const char *spho_ctx_strerror(struct spho_ctx *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,13 +24,13 @@ struct spho_nom_le {
|
||||||
SLIST_ENTRY(spho_nom_le) next;
|
SLIST_ENTRY(spho_nom_le) next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct spho_const_le {
|
struct spho_cnst_le {
|
||||||
struct spho_cnst cnst;
|
struct spho_cnst cnst;
|
||||||
SLIST_ENTRY(spho_const_le) next;
|
SLIST_ENTRY(spho_cnst_le) next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SLIST_HEAD(spho_nom_l, spho_nom_le);
|
SLIST_HEAD(spho_nom_l, spho_nom_le);
|
||||||
SLIST_HEAD(spho_const_l, spho_const_le);
|
SLIST_HEAD(spho_const_l, spho_cnst_le);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
ctx->err_info = errno; \
|
ctx->err_info = errno; \
|
||||||
snprintf(ctx->filebuf, sizeof(ctx->filebuf), "%s", \
|
snprintf(ctx->filebuf, sizeof(ctx->filebuf), "%s", \
|
||||||
__FILE__); \
|
__FILE__); \
|
||||||
|
ctx->filebuf[sizeof(ctx->filebuf) - 1] = '\0'; \
|
||||||
ctx->errline = __LINE__; \
|
ctx->errline = __LINE__; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
|
@ -7,26 +7,4 @@
|
||||||
|
|
||||||
#include "spho/data.h"
|
#include "spho/data.h"
|
||||||
|
|
||||||
#define SPHO_ERR_BUF_LEN 2048
|
|
||||||
#define SPHO_ERR_FILEBUF_LEN 128
|
|
||||||
|
|
||||||
struct spho_ctx {
|
|
||||||
int err;
|
|
||||||
int err_info;
|
|
||||||
|
|
||||||
struct spho_nom_l noms;
|
|
||||||
struct spho_const_l cnsts;
|
|
||||||
|
|
||||||
#ifdef SPHO_DEBUG
|
|
||||||
char filebuf[SPHO_ERR_FILEBUF_LEN];
|
|
||||||
int errline;
|
|
||||||
#else
|
|
||||||
char errbuf[SPHO_ERR_BUF_LEN];
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
struct spho_ctx *spho_ctx_create(void);
|
|
||||||
void spho_ctx_destroy(struct spho_ctx *);
|
|
||||||
char *spho_ctx_strerror(struct spho_ctx *);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
|
@ -1,15 +1,18 @@
|
||||||
|
#include <sys/queue.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "spho/err.h"
|
||||||
#include "spho/ctx.h"
|
#include "spho/ctx.h"
|
||||||
|
|
||||||
static const char *spho_ctx_sys_strerror(struct spho_ctx *);
|
static const char *spho_ctx_sys_strerror(struct spho_ctx *);
|
||||||
static const char *spho_ctx_intern_strerror(struct spho_ctx *);
|
static const char *spho_ctx_intern_strerror(struct spho_ctx *);
|
||||||
|
|
||||||
struct spho_err {
|
struct spho_err {
|
||||||
int num;
|
int err;
|
||||||
char *msg;
|
const char *msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct spho_err spho_errmsgs[] = {
|
struct spho_err spho_errmsgs[] = {
|
||||||
|
@ -43,15 +46,15 @@ spho_ctx_destroy(struct spho_ctx *ctx)
|
||||||
|
|
||||||
SPHO_PRECOND(ctx != NULL);
|
SPHO_PRECOND(ctx != NULL);
|
||||||
|
|
||||||
while (! SLIST_EMPTY(&c->noms)) {
|
while (! SLIST_EMPTY(&ctx->noms)) {
|
||||||
nom = SLIST_FIRST(&c->noms);
|
nom = SLIST_FIRST(&ctx->noms);
|
||||||
SLIST_REMOVE_HEAD(&c->noms, next);
|
SLIST_REMOVE_HEAD(&ctx->noms, next);
|
||||||
free(nom);
|
free(nom);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (! SLIST_EMPTY(&c->cnsts)) {
|
while (! SLIST_EMPTY(&ctx->cnsts)) {
|
||||||
cnst = SLIST_FIRST(&c->cnsts);
|
cnst = SLIST_FIRST(&ctx->cnsts);
|
||||||
SLIST_REMOVE_HEAD(&c->cnsts, next);
|
SLIST_REMOVE_HEAD(&ctx->cnsts, next);
|
||||||
free(cnst);
|
free(cnst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,8 +63,8 @@ spho_ctx_destroy(struct spho_ctx *ctx)
|
||||||
const char *
|
const char *
|
||||||
spho_ctx_strerror(struct spho_ctx *ctx)
|
spho_ctx_strerror(struct spho_ctx *ctx)
|
||||||
{
|
{
|
||||||
char *msg;
|
|
||||||
int res;
|
int res;
|
||||||
|
const char *msg;
|
||||||
|
|
||||||
SPHO_PRECOND(ctx != NULL);
|
SPHO_PRECOND(ctx != NULL);
|
||||||
|
|
||||||
|
@ -81,6 +84,10 @@ spho_ctx_strerror(struct spho_ctx *ctx)
|
||||||
static const char *
|
static const char *
|
||||||
spho_ctx_sys_strerror(struct spho_ctx *ctx)
|
spho_ctx_sys_strerror(struct spho_ctx *ctx)
|
||||||
{
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
SPHO_POSTCOND(ctx != NULL);
|
||||||
|
|
||||||
#ifdef SPHO_DEBUG
|
#ifdef SPHO_DEBUG
|
||||||
res = snprintf(ctx->errbuf, sizeof(ctx->errbuf),
|
res = snprintf(ctx->errbuf, sizeof(ctx->errbuf),
|
||||||
"%s:%d:spho_syserr:%s (%d)", ctx->filebuf, ctx->errline,
|
"%s:%d:spho_syserr:%s (%d)", ctx->filebuf, ctx->errline,
|
||||||
|
@ -89,8 +96,8 @@ spho_ctx_sys_strerror(struct spho_ctx *ctx)
|
||||||
ctx->errbuf[sizeof(ctx->errbuf) - 1] = '\0';
|
ctx->errbuf[sizeof(ctx->errbuf) - 1] = '\0';
|
||||||
#else
|
#else
|
||||||
res = snprintf(ctx->errbuf, sizeof(ctx->errbuf),
|
res = snprintf(ctx->errbuf, sizeof(ctx->errbuf),
|
||||||
"spho_syserr:%s (%d)", ctx->filebuf, ctx->errline,
|
"spho_syserr:%s (%d)", strerror(ctx->err_info),
|
||||||
strerror(ctx->err_info), ctx->err_info);
|
ctx->err_info);
|
||||||
if (res >= sizeof(ctx->errbuf))
|
if (res >= sizeof(ctx->errbuf))
|
||||||
ctx->errbuf[sizeof(ctx->errbuf) - 1] = '\0';
|
ctx->errbuf[sizeof(ctx->errbuf) - 1] = '\0';
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue