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