Compiles with tcc
FossilOrigin-Name: ec63b57d34761baede1254385a5abb4ed9d5f3becdbdab91ef596b4399d196fa
This commit is contained in:
parent
4b6897c983
commit
762ff8bce5
@ -19,7 +19,32 @@ endif
|
|||||||
|
|
||||||
|
|
||||||
ifndef ARCH
|
ifndef ARCH
|
||||||
ARCH = $(shell $(CC) -dumpmachine)
|
ARCH = $(shell uname -m)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(CC),clang)
|
||||||
|
LDFLAGS += -g -L/usr/local/lib
|
||||||
|
CFLAGS += -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -fPIC -g -O0 -D_REENTRANT -I /usr/local/include -I../
|
||||||
|
LD = gcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CC),gcc)
|
||||||
|
LDFLAGS += -g -L/usr/local/lib
|
||||||
|
CFLAGS += -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -fPIC -g -O0 -D_REENTRANT -I /usr/local/include -I../
|
||||||
|
LD = gcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CC),tcc)
|
||||||
|
LDFLAGS += -g -L/usr/local/lib
|
||||||
|
CFLAGS += -Wall -Wunusupported -Wimplicit-function-declaration -I /usr/local/include -I../
|
||||||
|
LD = tcc
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CFLAGS += -DWITH_IPV6 -DWITH_RMAC_SUPPORT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
include ../Macros.mak
|
|
||||||
include ../Config.mak
|
include ../Config.mak
|
||||||
include ../ACConfig.mak
|
include ../ACConfig.mak
|
||||||
-include ../Config.local.mak
|
-include ../Config.local.mak
|
||||||
|
-include ../ACConfig.local.mak
|
||||||
|
include ../Macros.mak
|
||||||
|
|
||||||
|
|
||||||
LIBARCHDIR=../../lib/$(ARCH)
|
LIBARCHDIR=../../lib/$(ARCH)
|
||||||
|
|
||||||
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib -L$(LIBARCHDIR)
|
LDFLAGS+=-g -L/usr/local/lib -L$(LIBARCHDIR)
|
||||||
CFLAGS += -W -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
|
CFLAGS += -W -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../ -DSYS_ARCH=\"${ARCH}\"
|
||||||
|
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ all: $(AC_NAME)
|
|||||||
|
|
||||||
$(AC_NAME): $(AC_OBJS)
|
$(AC_NAME): $(AC_OBJS)
|
||||||
# $(CC) $(AC_OBJS) ../mod/modload_ac.o -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
# $(CC) $(AC_OBJS) ../mod/modload_ac.o -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
||||||
$(CC) $(AC_OBJS) -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
$(LD) $(AC_OBJS) -o $(AC_NAME) $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@ -90,6 +91,6 @@ clean_deps:
|
|||||||
$(AC_DEPS)
|
$(AC_DEPS)
|
||||||
|
|
||||||
deps: $(AC_SRC)
|
deps: $(AC_SRC)
|
||||||
$(CC) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null
|
$(LD) -MD -E $(AC_SRCS) $(CFLAGS) >/dev/null
|
||||||
|
|
||||||
-include $(AC_DEPS)
|
-include $(AC_DEPS)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
include ../Macros.mak
|
|
||||||
include ../CWConfig.mak
|
include ../CWConfig.mak
|
||||||
-include ../Config.local.mak
|
-include ../Config.local.mak
|
||||||
|
include ../Macros.mak
|
||||||
|
|
||||||
|
|
||||||
LIBDIR := ../../lib
|
LIBDIR := ../../lib
|
||||||
@ -10,8 +10,6 @@ OBJDIR := ../../obj/cw/$(ARCH)
|
|||||||
SNAME := $(LIBARCHDIR)/libcw.a
|
SNAME := $(LIBARCHDIR)/libcw.a
|
||||||
DNAME := $(LIBARCHDIR)/libcw.so
|
DNAME := $(LIBARCHDIR)/libcw.so
|
||||||
|
|
||||||
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib
|
|
||||||
|
|
||||||
LIBS=
|
LIBS=
|
||||||
|
|
||||||
ifeq ($(WITH_OPENSSL),1)
|
ifeq ($(WITH_OPENSSL),1)
|
||||||
@ -40,24 +38,16 @@ endif
|
|||||||
|
|
||||||
SRC=$(wildcard *.c)
|
SRC=$(wildcard *.c)
|
||||||
OBJS=$(patsubst %.c,%.o,$(SRC))
|
OBJS=$(patsubst %.c,%.o,$(SRC))
|
||||||
#O:=$(OBJS);
|
|
||||||
|
|
||||||
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
|
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
|
||||||
|
|
||||||
|
|
||||||
all: $(SNAME) $(DNAME)
|
all: $(SNAME) $(DNAME)
|
||||||
|
|
||||||
|
|
||||||
#CFLAGS = -D_XOPEN_SOURCE=500 -std=c90 -pedantic -Wall -fPIC -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../
|
|
||||||
CFLAGS = -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wall -fPIC -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include -I../
|
|
||||||
|
|
||||||
CFLAGS += $(GNUTLS_CFLAGS) \
|
CFLAGS += $(GNUTLS_CFLAGS) \
|
||||||
-DWITH_CW_LOG \
|
-DWITH_CW_LOG \
|
||||||
-DWITH_CW_LOG_DEBUG \
|
-DWITH_CW_LOG_DEBUG \
|
||||||
-DWITH_DTLS \
|
-DWITH_DTLS
|
||||||
$(XINCLUDE)\
|
|
||||||
-I $(OPENSSLINC)\
|
|
||||||
-Werror
|
|
||||||
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o:%.c
|
$(OBJDIR)/%.o:%.c
|
||||||
@ -65,15 +55,15 @@ $(OBJDIR)/%.o:%.c
|
|||||||
@echo " $(CC) "$<
|
@echo " $(CC) "$<
|
||||||
@$(CC) -c $(CFLAGS) $< -o $@
|
@$(CC) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
$(SNAME) : $(OBJS) $(MODOBJS)
|
$(SNAME) : $(OBJS)
|
||||||
@mkdir -p $(LIBARCHDIR)
|
@mkdir -p $(LIBARCHDIR)
|
||||||
@echo " AR $(SNAME)"
|
@echo " $(AR) $(SNAME)"
|
||||||
@$(AR) rcs $(SNAME) $(OBJS) $(MODOBJS)
|
@$(AR) rcs $(SNAME) $(OBJS)
|
||||||
|
|
||||||
$(DNAME) : $(OBJS) $(MODOBJS)
|
$(DNAME) : $(OBJS)
|
||||||
@mkdir -p $(LIBARCHDIR)
|
@mkdir -p $(LIBARCHDIR)
|
||||||
@echo " $(CC) $(DNAME)"
|
@echo " $(LD) $(DNAME)"
|
||||||
@$(CC) $(LDFLAGS) -shared -o $(DNAME) $(OBJS) $(MODOBJS) $(LIBS)
|
@$(LD) $(LDFLAGS) -shared -o $(DNAME) $(OBJS) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
SRCS = $(OBJS:.o=.c)
|
SRCS = $(OBJS:.o=.c)
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
* @file Debugging Functions
|
* @file Debugging Functions
|
||||||
* @brief Various debug functions.
|
* @brief Various debug functions.
|
||||||
*/
|
*/
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
@ -39,6 +40,8 @@
|
|||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "message_set.h"
|
#include "message_set.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@addtogroup DBG
|
*@addtogroup DBG
|
||||||
*@{
|
*@{
|
||||||
|
@ -19,19 +19,7 @@
|
|||||||
#define __CW_DTLS_H
|
#define __CW_DTLS_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "dtls_common.h"
|
||||||
#include "conn.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct dtls_ssl_cert
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
int type;
|
|
||||||
uint8_t * data;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern int dtls_bio_read(struct conn *conn, char *out, int maxlen);
|
|
||||||
extern int dtls_bio_write(struct conn * conn, const char *data, int len);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <gnutls/gnutls.h>
|
#include <gnutls/gnutls.h>
|
||||||
#include <gnutls/dtls.h>
|
#include <gnutls/dtls.h>
|
||||||
|
|
||||||
|
#include "dtls_common.h"
|
||||||
#include "dtls_gnutls.h"
|
#include "dtls_gnutls.h"
|
||||||
|
|
||||||
#include "conn.h"
|
#include "conn.h"
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
|
#include "dtls_common.h"
|
||||||
#include "dtls_gnutls.h"
|
#include "dtls_gnutls.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
|
#include "dtls_common.h"
|
||||||
#include "dtls_gnutls.h"
|
#include "dtls_gnutls.h"
|
||||||
|
|
||||||
const char *dtls_gnutls_get_cipher(struct conn *conn)
|
const char *dtls_gnutls_get_cipher(struct conn *conn)
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
|
158
src/cw/mbag.c
158
src/cw/mbag.c
@ -237,3 +237,161 @@ struct mbag_item *strmbag_item_create(mbag_t s, char *name)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int mbag_set(mbag_t t,mbag_item_t *is)
|
||||||
|
{
|
||||||
|
mavl_del(t,is);
|
||||||
|
mavl_add(t,is);
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct mbag_item *i = mavl_get(s, is);
|
||||||
|
if (i) {
|
||||||
|
mbag_del_data(i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
mavl_add(t,is);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
int mbag_set_byte(mbag_t s, const char *id, uint8_t byte)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->byte = byte;
|
||||||
|
i->type = &mbag_type_byte;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct mbag_item * mbag_set_word(mbag_t s, const char *id, uint16_t word)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->word = word;
|
||||||
|
i->type = &mbag_type_word;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct mbag_item * mbag_set_dword(mbag_t s, const char *id, uint32_t dword)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return NULL;
|
||||||
|
i->dword = dword;
|
||||||
|
i->type = &mtype_dword;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int mbag_i_set_mbag(mbag_t s, uint32_t id, mbag_t mbag)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_i_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->data = mbag;
|
||||||
|
i->type = &mbag_type_mbag;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mbag_set_mbag(mbag_t s, const char *id, mbag_t mbag)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->data = mbag;
|
||||||
|
i->type = &mbag_type_mbag;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mbag_set_data(mbag_t s, const char *id, const struct mbag_typedef *type, void *data)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->data = data;
|
||||||
|
i->type = type;
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id,
|
||||||
|
uint8_t * version, int len)
|
||||||
|
{
|
||||||
|
mbag_item_t *i = mbag_item_create(s, id);
|
||||||
|
if (!i)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
i->type = MBAG_VENDORSTR;
|
||||||
|
i->data = bstrv_create(vendor_id,version,len);
|
||||||
|
return i->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mbag_item_t *mbag_get(mbag_t s, const char *id)
|
||||||
|
{
|
||||||
|
mbag_item_t i;
|
||||||
|
i.id = id;
|
||||||
|
i.type=0;
|
||||||
|
return mavl_get(s, &i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mbag_item_t *mbag_i_get(mbag_t s, uint32_t id)
|
||||||
|
{
|
||||||
|
mbag_item_t i;
|
||||||
|
i.iid = id;
|
||||||
|
i.type=0;
|
||||||
|
return mavl_get(s, &i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void mbag_del(mbag_t s,const char *id)
|
||||||
|
{
|
||||||
|
mbag_item_t i;
|
||||||
|
i.id = id;
|
||||||
|
i.type=0;
|
||||||
|
mavl_del(s, &i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void * mbag_get_data(mbag_t s, const char *id, const struct mbag_typedef * type, void * def)
|
||||||
|
{
|
||||||
|
struct mbag_item *i = mbag_get(s, id);
|
||||||
|
if (!i)
|
||||||
|
return def;
|
||||||
|
if (i->type != type)
|
||||||
|
return def;
|
||||||
|
return i->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
144
src/cw/mbag.h
144
src/cw/mbag.h
@ -176,100 +176,15 @@ struct mbag_item *mbag_item_create(mbag_t s, const char *id);
|
|||||||
struct mbag_item *mbag_i_item_create(mbag_t s, uint32_t id);
|
struct mbag_item *mbag_i_item_create(mbag_t s, uint32_t id);
|
||||||
|
|
||||||
|
|
||||||
static inline int mbag_set(mbag_t t,mbag_item_t *is)
|
bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id,
|
||||||
{
|
uint8_t * version, int len);
|
||||||
mavl_del(t,is);
|
int mbag_set_data(mbag_t s, const char *id, const struct mbag_typedef *type, void *data);
|
||||||
mavl_add(t,is);
|
int mbag_set_mbag(mbag_t s, const char *id, mbag_t mbag);
|
||||||
return 1;
|
int mbag_i_set_mbag(mbag_t s, uint32_t id, mbag_t mbag);
|
||||||
|
struct mbag_item * mbag_set_dword(mbag_t s, const char *id, uint32_t dword);
|
||||||
/*
|
struct mbag_item * mbag_set_word(mbag_t s, const char *id, uint16_t word);
|
||||||
struct mbag_item *i = mavl_get(s, is);
|
int mbag_set_byte(mbag_t s, const char *id, uint8_t byte);
|
||||||
if (i) {
|
int mbag_set(mbag_t t,mbag_item_t *is);
|
||||||
mbag_del_data(i);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
mavl_add(t,is);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int mbag_set_byte(mbag_t s, const char *id, uint8_t byte)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->byte = byte;
|
|
||||||
i->type = &mbag_type_byte;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline struct mbag_item * mbag_set_word(mbag_t s, const char *id, uint16_t word)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->word = word;
|
|
||||||
i->type = &mbag_type_word;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline struct mbag_item * mbag_set_dword(mbag_t s, const char *id, uint32_t dword)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return NULL;
|
|
||||||
i->dword = dword;
|
|
||||||
i->type = &mtype_dword;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline int mbag_i_set_mbag(mbag_t s, uint32_t id, mbag_t mbag)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_i_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->data = mbag;
|
|
||||||
i->type = &mbag_type_mbag;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int mbag_set_mbag(mbag_t s, const char *id, mbag_t mbag)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->data = mbag;
|
|
||||||
i->type = &mbag_type_mbag;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int mbag_set_data(mbag_t s, const char *id, const struct mbag_typedef *type, void *data)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return 0;
|
|
||||||
i->data = data;
|
|
||||||
i->type = type;
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id,
|
|
||||||
uint8_t * version, int len)
|
|
||||||
{
|
|
||||||
mbag_item_t *i = mbag_item_create(s, id);
|
|
||||||
if (!i)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
i->type = MBAG_VENDORSTR;
|
|
||||||
i->data = bstrv_create(vendor_id,version,len);
|
|
||||||
return i->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mbag_item_t *mbag_item_new(mbagtype_t type);
|
mbag_item_t *mbag_item_new(mbagtype_t type);
|
||||||
@ -281,42 +196,19 @@ mbag_item_t *mbag_item_new(mbagtype_t type);
|
|||||||
#define mbag_set_bstr16(m,i,d) mbag_set_data(m,i,MBAG_BSTR16,d)
|
#define mbag_set_bstr16(m,i,d) mbag_set_data(m,i,MBAG_BSTR16,d)
|
||||||
|
|
||||||
|
|
||||||
static inline mbag_item_t *mbag_get(mbag_t s, const char *id)
|
|
||||||
{
|
|
||||||
mbag_item_t i;
|
|
||||||
i.id = id;
|
|
||||||
i.type=0;
|
|
||||||
return mavl_get(s, &i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline mbag_item_t *mbag_i_get(mbag_t s, uint32_t id)
|
|
||||||
{
|
|
||||||
mbag_item_t i;
|
|
||||||
i.iid = id;
|
|
||||||
i.type=0;
|
|
||||||
return mavl_get(s, &i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline void mbag_del(mbag_t s,const char *id)
|
void * mbag_get_data(mbag_t s, const char *id, const struct mbag_typedef * type, void * def);
|
||||||
{
|
void mbag_del(mbag_t s,const char *id);
|
||||||
mbag_item_t i;
|
mbag_item_t *mbag_i_get(mbag_t s, uint32_t id);
|
||||||
i.id = id;
|
mbag_item_t *mbag_get(mbag_t s, const char *id);
|
||||||
i.type=0;
|
|
||||||
mavl_del(s, &i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static inline void * mbag_get_data(mbag_t s, const char *id, const struct mbag_typedef * type, void * def)
|
|
||||||
{
|
|
||||||
struct mbag_item *i = mbag_get(s, id);
|
|
||||||
if (!i)
|
|
||||||
return def;
|
|
||||||
if (i->type != type)
|
|
||||||
return def;
|
|
||||||
return i->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define mbag_get_bstr(m,i,d) mbag_get_data(m,i,MBAG_BSTR,d)
|
#define mbag_get_bstr(m,i,d) mbag_get_data(m,i,MBAG_BSTR,d)
|
||||||
#define mbag_get_bstr16(m,i,d) mbag_get_data(m,i,MBAG_BSTR16,d)
|
#define mbag_get_bstr16(m,i,d) mbag_get_data(m,i,MBAG_BSTR16,d)
|
||||||
|
Loading…
Reference in New Issue
Block a user