Commit 6428b71b authored by jehan's avatar jehan

rename bctoolbox_ to bctbx_

parent e654c008
This diff is collapsed.
......@@ -16,8 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BCTOOLBOX_LIST_H_
#define BCTOOLBOX_LIST_H_
#ifndef BCTBX_LIST_H_
#define BCTBX_LIST_H_
#include "bctoolbox/port.h"
......@@ -25,43 +25,47 @@
extern "C"{
#endif
typedef struct _bctoolbox_list bctoolbox_list_t;
typedef struct _bctbx_list {
struct _bctbx_list *next;
struct _bctbx_list *prev;
void *data;
} bctbx_list_t;
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_append(bctoolbox_list_t * elem, void * data);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_prepend(bctoolbox_list_t * elem, void * data);
BCTOOLBOX_PUBLIC bctoolbox_list_t* bctoolbox_list_prepend_link(bctoolbox_list_t* elem, bctoolbox_list_t *new_elem);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_last_elem(const bctoolbox_list_t *l);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_first_elem(const bctoolbox_list_t *l);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_free(bctoolbox_list_t * elem);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_concat(bctoolbox_list_t * first, bctoolbox_list_t * second);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_remove(bctoolbox_list_t * first, void *data);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_pop_front(bctoolbox_list_t *list, void **front_data);
BCTOOLBOX_PUBLIC int bctoolbox_list_size(const bctoolbox_list_t * first);
BCTOOLBOX_PUBLIC void bctoolbox_list_for_each(const bctoolbox_list_t * list, void (*func)(void *));
BCTOOLBOX_PUBLIC void bctoolbox_list_for_each2(const bctoolbox_list_t * list, void (*func)(void *, void *), void *user_data);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_remove_link(bctoolbox_list_t * list, bctoolbox_list_t * elem);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_delete_link(bctoolbox_list_t * list, bctoolbox_list_t * elem);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_find(bctoolbox_list_t * list, void *data);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_free(bctoolbox_list_t *list);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_append(bctbx_list_t * elem, void * data);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_prepend(bctbx_list_t * elem, void * data);
BCTBX_PUBLIC bctbx_list_t* bctbx_list_prepend_link(bctbx_list_t* elem, bctbx_list_t *new_elem);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_last_elem(const bctbx_list_t *l);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_first_elem(const bctbx_list_t *l);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_free(bctbx_list_t * elem);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_concat(bctbx_list_t * first, bctbx_list_t * second);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_remove(bctbx_list_t * first, void *data);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_pop_front(bctbx_list_t *list, void **front_data);
BCTBX_PUBLIC int bctbx_list_size(const bctbx_list_t * first);
BCTBX_PUBLIC void bctbx_list_for_each(const bctbx_list_t * list, void (*func)(void *));
BCTBX_PUBLIC void bctbx_list_for_each2(const bctbx_list_t * list, void (*func)(void *, void *), void *user_data);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_remove_link(bctbx_list_t * list, bctbx_list_t * elem);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_delete_link(bctbx_list_t * list, bctbx_list_t * elem);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_find(bctbx_list_t * list, void *data);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_free(bctbx_list_t *list);
/*frees list elements and associated data, using the supplied function pointer*/
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_free_with_data(bctoolbox_list_t *list, void (*freefunc)(void*));
BCTBX_PUBLIC bctbx_list_t * bctbx_list_free_with_data(bctbx_list_t *list, void (*freefunc)(void*));
typedef int (*bctoolbox_compare_func)(const void *, const void*);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_find_custom(const bctoolbox_list_t * list, bctoolbox_compare_func cmp, const void *user_data);
BCTOOLBOX_PUBLIC void * bctoolbox_list_nth_data(const bctoolbox_list_t * list, int index);
BCTOOLBOX_PUBLIC int bctoolbox_list_position(const bctoolbox_list_t * list, bctoolbox_list_t * elem);
BCTOOLBOX_PUBLIC int bctoolbox_list_index(const bctoolbox_list_t * list, void *data);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_insert_sorted(bctoolbox_list_t * list, void *data, bctoolbox_compare_func cmp);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_insert(bctoolbox_list_t * list, bctoolbox_list_t * before, void *data);
BCTOOLBOX_PUBLIC bctoolbox_list_t * bctoolbox_list_copy(const bctoolbox_list_t * list);
typedef int (*bctbx_compare_func)(const void *, const void*);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_find_custom(const bctbx_list_t * list, bctbx_compare_func cmp, const void *user_data);
BCTBX_PUBLIC void * bctbx_list_nth_data(const bctbx_list_t * list, int index);
BCTBX_PUBLIC int bctbx_list_position(const bctbx_list_t * list, bctbx_list_t * elem);
BCTBX_PUBLIC int bctbx_list_index(const bctbx_list_t * list, void *data);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_insert_sorted(bctbx_list_t * list, void *data, bctbx_compare_func cmp);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_insert(bctbx_list_t * list, bctbx_list_t * before, void *data);
BCTBX_PUBLIC bctbx_list_t * bctbx_list_copy(const bctbx_list_t * list);
/*copy list elements and associated data, using the supplied function pointer*/
BCTOOLBOX_PUBLIC bctoolbox_list_t* bctoolbox_list_copy_with_data(const bctoolbox_list_t* list, void* (*copyfunc)(void*));
BCTBX_PUBLIC bctbx_list_t* bctbx_list_copy_with_data(const bctbx_list_t* list, void* (*copyfunc)(void*));
BCTOOLBOX_PUBLIC bctoolbox_list_t* bctoolbox_list_next(const bctoolbox_list_t *elem);
BCTOOLBOX_PUBLIC void* bctoolbox_list_get_data(const bctoolbox_list_t *elem);
BCTBX_PUBLIC bctbx_list_t* bctbx_list_next(const bctbx_list_t *elem);
BCTBX_PUBLIC void* bctbx_list_get_data(const bctbx_list_t *elem);
#ifdef __cplusplus
}
#endif
#endif /* BCTOOLBOX_LIST_H_ */
#endif /* BCTLBX_LIST_H_ */
......@@ -23,13 +23,13 @@
*
**/
#ifndef BCTOOLBOX_LOGGING_H
#define BCTOOLBOX_LOGGING_H
#ifndef BCTBX_LOGGING_H
#define BCTBX_LOGGING_H
#include <bctoolbox/port.h>
#ifndef BCTOOLBOX_LOG_DOMAIN
#define BCTOOLBOX_LOG_DOMAIN NULL
#ifndef BCTBX_LOG_DOMAIN
#define BCTBX_LOG_DOMAIN NULL
#endif
#ifdef __cplusplus
......@@ -38,48 +38,48 @@ extern "C"
#endif
typedef enum {
BCTOOLBOX_DEBUG=1,
BCTOOLBOX_TRACE=1<<1,
BCTOOLBOX_MESSAGE=1<<2,
BCTOOLBOX_WARNING=1<<3,
BCTOOLBOX_ERROR=1<<4,
BCTOOLBOX_FATAL=1<<5,
BCTOOLBOX_LOGLEV_END=1<<6
} BctoolboxLogLevel;
BCTBX_LOG_DEBUG=1,
BCTBX_LOG_TRACE=1<<1,
BCTBX_LOG_MESSAGE=1<<2,
BCTBX_LOG_WARNING=1<<3,
BCTBX_LOG_ERROR=1<<4,
BCTBX_LOG_FATAL=1<<5,
BCTBX_LOG_LOGLEV_END=1<<6
} BctbxLogLevel;
typedef void (*BctoolboxLogFunc)(const char *domain, BctoolboxLogLevel lev, const char *fmt, va_list args);
typedef void (*BctoolboxLogFunc)(const char *domain, BctbxLogLevel lev, const char *fmt, va_list args);
BCTOOLBOX_PUBLIC void bctoolbox_set_log_file(FILE *file);
BCTOOLBOX_PUBLIC void bctoolbox_set_log_handler(BctoolboxLogFunc func);
BCTOOLBOX_PUBLIC BctoolboxLogFunc bctoolbox_get_log_handler(void);
BCTBX_PUBLIC void bctbx_set_log_file(FILE *file);
BCTBX_PUBLIC void bctbx_set_log_handler(BctoolboxLogFunc func);
BCTBX_PUBLIC BctoolboxLogFunc bctbx_get_log_handler(void);
BCTOOLBOX_PUBLIC void bctoolbox_logv_out(const char *domain, BctoolboxLogLevel level, const char *fmt, va_list args);
BCTBX_PUBLIC void bctbx_logv_out(const char *domain, BctbxLogLevel level, const char *fmt, va_list args);
#define bctoolbox_log_level_enabled(domain, level) (bctoolbox_get_log_level_mask(domain) & (level))
#define bctbx_log_level_enabled(domain, level) (bctbx_get_log_level_mask(domain) & (level))
BCTOOLBOX_PUBLIC void bctoolbox_logv(const char *domain, BctoolboxLogLevel level, const char *fmt, va_list args);
BCTBX_PUBLIC void bctbx_logv(const char *domain, BctbxLogLevel level, const char *fmt, va_list args);
/**
* Flushes the log output queue.
* WARNING: Must be called from the thread that has been defined with bctoolbox_set_log_thread_id().
* WARNING: Must be called from the thread that has been defined with bctbx_set_log_thread_id().
*/
BCTOOLBOX_PUBLIC void bctoolbox_logv_flush(void);
BCTBX_PUBLIC void bctbx_logv_flush(void);
/**
* Activate all log level greater or equal than specified level argument.
**/
BCTOOLBOX_PUBLIC void bctoolbox_set_log_level(const char *domain, BctoolboxLogLevel level);
BCTBX_PUBLIC void bctbx_set_log_level(const char *domain, BctbxLogLevel level);
BCTOOLBOX_PUBLIC void bctoolbox_set_log_level_mask(const char *domain, int levelmask);
BCTOOLBOX_PUBLIC unsigned int bctoolbox_get_log_level_mask(const char *domain);
BCTBX_PUBLIC void bctbx_set_log_level_mask(const char *domain, int levelmask);
BCTBX_PUBLIC unsigned int bctbx_get_log_level_mask(const char *domain);
/**
* Tell oRTP the id of the thread used to output the logs.
* This is meant to output all the logs from the same thread to prevent deadlock problems at the application level.
* @param[in] thread_id The id of the thread that will output the logs (can be obtained using bctoolbox_thread_self()).
* @param[in] thread_id The id of the thread that will output the logs (can be obtained using bctbx_thread_self()).
*/
BCTOOLBOX_PUBLIC void bctoolbox_set_log_thread_id(unsigned long thread_id);
BCTBX_PUBLIC void bctbx_set_log_thread_id(unsigned long thread_id);
#ifdef __GNUC__
#define CHECK_FORMAT_ARGS(m,n) __attribute__((format(printf,m,n)))
......@@ -90,72 +90,72 @@ BCTOOLBOX_PUBLIC void bctoolbox_set_log_thread_id(unsigned long thread_id);
/*in case of compile with -g static inline can produce this type of warning*/
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
#ifdef BCTOOLBOX_DEBUG_MODE
static BCTOOLBOX_INLINE void CHECK_FORMAT_ARGS(1,2) bctoolbox_debug(const char *fmt,...)
#ifdef BCTBX_DEBUG_MODE
static BCTBX_INLINE void CHECK_FORMAT_ARGS(1,2) bctbx_debug(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
bctoolbox_logv(BCTOOLBOX_LOG_DOMAIN, BCTOOLBOX_DEBUG, fmt, args);
bctbx_logv(BCTBX_LOG_DOMAIN, BCTBX_DEBUG, fmt, args);
va_end (args);
}
#else
#define bctoolbox_debug(...)
#define bctbx_debug(...)
#endif
#ifdef BCTOOLBOX_NOMESSAGE_MODE
#ifdef BCTBX_NOMESSAGE_MODE
#define bctoolbox_log(...)
#define bctoolbox_message(...)
#define bctoolbox_warning(...)
#define bctbx_log(...)
#define bctbx_message(...)
#define bctbx_warning(...)
#else
static BCTOOLBOX_INLINE void bctoolbox_log(const char* domain, BctoolboxLogLevel lev, const char *fmt,...) {
static BCTBX_INLINE void bctbx_log(const char* domain, BctbxLogLevel lev, const char *fmt,...) {
va_list args;
va_start (args, fmt);
bctoolbox_logv(domain, lev, fmt, args);
bctbx_logv(domain, lev, fmt, args);
va_end (args);
}
static BCTOOLBOX_INLINE void CHECK_FORMAT_ARGS(1,2) bctoolbox_message(const char *fmt,...)
static BCTBX_INLINE void CHECK_FORMAT_ARGS(1,2) bctbx_message(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
bctoolbox_logv(BCTOOLBOX_LOG_DOMAIN, BCTOOLBOX_MESSAGE, fmt, args);
bctbx_logv(BCTBX_LOG_DOMAIN, BCTBX_LOG_MESSAGE, fmt, args);
va_end (args);
}
static BCTOOLBOX_INLINE void CHECK_FORMAT_ARGS(1,2) bctoolbox_warning(const char *fmt,...)
static BCTBX_INLINE void CHECK_FORMAT_ARGS(1,2) bctbx_warning(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
bctoolbox_logv(BCTOOLBOX_LOG_DOMAIN, BCTOOLBOX_WARNING, fmt, args);
bctbx_logv(BCTBX_LOG_DOMAIN, BCTBX_LOG_WARNING, fmt, args);
va_end (args);
}
#endif
static BCTOOLBOX_INLINE void CHECK_FORMAT_ARGS(1,2) bctoolbox_error(const char *fmt,...)
static BCTBX_INLINE void CHECK_FORMAT_ARGS(1,2) bctbx_error(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
bctoolbox_logv(BCTOOLBOX_LOG_DOMAIN, BCTOOLBOX_ERROR, fmt, args);
bctbx_logv(BCTBX_LOG_DOMAIN, BCTBX_LOG_ERROR, fmt, args);
va_end (args);
}
static BCTOOLBOX_INLINE void CHECK_FORMAT_ARGS(1,2) bctoolbox_fatal(const char *fmt,...)
static BCTBX_INLINE void CHECK_FORMAT_ARGS(1,2) bctbx_fatal(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
bctoolbox_logv(BCTOOLBOX_LOG_DOMAIN, BCTOOLBOX_FATAL, fmt, args);
bctbx_logv(BCTBX_LOG_DOMAIN, BCTBX_LOG_FATAL, fmt, args);
va_end (args);
}
#ifdef __QNX__
void bctoolbox_qnx_log_handler(const char *domain, BctoolboxLogLevel lev, const char *fmt, va_list args);
void bctbx_qnx_log_handler(const char *domain, BctbxLogLevel lev, const char *fmt, va_list args);
#endif
......@@ -212,12 +212,12 @@ namespace bctoolbox {
struct pumpstream : public std::ostringstream {
const std::string mDomain;
const BctoolboxLogLevel level;
pumpstream(std::string domain, BctoolboxLogLevel l) : mDomain(domain), level(l) {
const BctbxLogLevel level;
pumpstream(std::string domain, BctbxLogLevel l) : mDomain(domain), level(l) {
}
~pumpstream() {
bctoolbox_log(mDomain.c_str(), level, "%s", str().c_str());
bctbx_log(mDomain.c_str(), level, "%s", str().c_str());
}
};
......@@ -228,15 +228,15 @@ struct pumpstream : public std::ostringstream {
//}
//#endif
#define BCTOOLBOX_SLOG(domain, thelevel) \
#define BCTBX_SLOG(domain, thelevel) \
\
if (bctoolbox_log_level_enabled((domain), (thelevel))) \
if (bctbx_log_level_enabled((domain), (thelevel))) \
pumpstream((domain),(thelevel))
#define BCTOOLBOX_SLOGD(DOMAIN) BCTOOLBOX_SLOG(DOMAIN, BCTOOLBOX_DEBUG)
#define BCTOOLBOX_SLOGI(DOMAIN) BCTOOLBOX_SLOG((DOMAIN), (BCTOOLBOX_MESSAGE))
#define BCTOOLBOX_SLOGW(DOMAIN) BCTOOLBOX_SLOG(DOMAIN, BCTOOLBOX_WARNING)
#define BCTOOLBOX_SLOGE(DOMAIN) BCTOOLBOX_SLOG(DOMAIN, BCTOOLBOX_ERROR)
#define BCTBX_SLOGD(DOMAIN) BCTBX_SLOG(DOMAIN, BCTBX_LOG_DEBUG)
#define BCTBX_SLOGI(DOMAIN) BCTBX_SLOG((DOMAIN), (BCTBX_LOG_MESSAGE))
#define BCTBX_SLOGW(DOMAIN) BCTBX_SLOG(DOMAIN, BCTBX_LOG_WARNING)
#define BCTBX_SLOGE(DOMAIN) BCTBX_SLOG(DOMAIN, BCTBX_LOG_ERROR)
#endif
......
......@@ -16,8 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BCTOOLBOX_MMAP_H_
#define BCTOOLBOX_MMAP_H_
#ifndef BCTBX_MMAP_H_
#define BCTBX_MMAP_H_
#include "bctoolbox/list.h"
#include "bctoolbox/port.h"
......@@ -25,56 +25,56 @@
extern "C"{
#endif
typedef struct _bctoolbox_map_t bctoolbox_map_t;
typedef struct _bctoolbox_pair_t bctoolbox_pair_t;
typedef struct _bctoolbox_iterator_t bctoolbox_iterator_t;
typedef struct _bctbx_map_t bctbx_map_t;
typedef struct _bctbx_pair_t bctbx_pair_t;
typedef struct _bctbx_iterator_t bctbx_iterator_t;
typedef struct _bctoolbox_mmap_ullong_t bctoolbox_mmap_ullong_t;
typedef struct _bctbx_mmap_ullong_t bctbx_mmap_ullong_t;
/*map*/
BCTOOLBOX_PUBLIC bctoolbox_map_t *bctoolbox_mmap_ullong_new(void);
BCTOOLBOX_PUBLIC void bctoolbox_mmap_ullong_delete(bctoolbox_map_t *mmap);
BCTOOLBOX_PUBLIC void bctoolbox_map_insert(bctoolbox_map_t *map,const bctoolbox_pair_t *pair);
BCTBX_PUBLIC bctbx_map_t *bctbx_mmap_ullong_new(void);
BCTBX_PUBLIC void bctbx_mmap_ullong_delete(bctbx_map_t *mmap);
BCTBX_PUBLIC void bctbx_map_insert(bctbx_map_t *map,const bctbx_pair_t *pair);
/*same as insert, but also deleting pair*/
BCTOOLBOX_PUBLIC void bctoolbox_map_insert_and_delete(bctoolbox_map_t *map,bctoolbox_pair_t *pair);
BCTBX_PUBLIC void bctbx_map_insert_and_delete(bctbx_map_t *map,bctbx_pair_t *pair);
/*same as insert and deleting pair with a newly allocated it returned */
BCTOOLBOX_PUBLIC bctoolbox_iterator_t * bctoolbox_map_insert_and_delete_with_returned_it(bctoolbox_map_t *map,bctoolbox_pair_t *pair);
BCTBX_PUBLIC bctbx_iterator_t * bctbx_map_insert_and_delete_with_returned_it(bctbx_map_t *map,bctbx_pair_t *pair);
/*at return, it point to the next element*/
BCTOOLBOX_PUBLIC bctoolbox_iterator_t *bctoolbox_map_erase(bctoolbox_map_t *map,bctoolbox_iterator_t *it);
BCTBX_PUBLIC bctbx_iterator_t *bctbx_map_erase(bctbx_map_t *map,bctbx_iterator_t *it);
/*return a new allocated iterator*/
BCTOOLBOX_PUBLIC bctoolbox_iterator_t *bctoolbox_map_begin(const bctoolbox_map_t *map);
BCTBX_PUBLIC bctbx_iterator_t *bctbx_map_begin(const bctbx_map_t *map);
/*return a new allocated iterator*/
BCTOOLBOX_PUBLIC bctoolbox_iterator_t *bctoolbox_map_end(const bctoolbox_map_t *map);
BCTBX_PUBLIC bctbx_iterator_t *bctbx_map_end(const bctbx_map_t *map);
/*return a new allocated iterator or null*/
BCTOOLBOX_PUBLIC bctoolbox_iterator_t * bctoolbox_map_find_custom(bctoolbox_map_t *map, bctoolbox_compare_func compare_func, const void *user_data);
BCTBX_PUBLIC bctbx_iterator_t * bctbx_map_find_custom(bctbx_map_t *map, bctbx_compare_func compare_func, const void *user_data);
BCTOOLBOX_PUBLIC size_t bctoolbox_map_size(const bctoolbox_map_t *map);
BCTBX_PUBLIC size_t bctbx_map_size(const bctbx_map_t *map);
/*iterator*/
BCTOOLBOX_PUBLIC bctoolbox_pair_t *bctoolbox_iterator_get_pair(const bctoolbox_iterator_t *it);
BCTBX_PUBLIC bctbx_pair_t *bctbx_iterator_get_pair(const bctbx_iterator_t *it);
/*return same pointer but pointing to next*/
BCTOOLBOX_PUBLIC bctoolbox_iterator_t *bctoolbox_iterator_get_next(bctoolbox_iterator_t *it);
BCTOOLBOX_PUBLIC bool_t bctoolbox_iterator_equals(const bctoolbox_iterator_t *a,const bctoolbox_iterator_t *b);
BCTBX_PUBLIC bctbx_iterator_t *bctbx_iterator_get_next(bctbx_iterator_t *it);
BCTBX_PUBLIC bool_t bctbx_iterator_equals(const bctbx_iterator_t *a,const bctbx_iterator_t *b);
BCTOOLBOX_PUBLIC void bctoolbox_iterator_delete(bctoolbox_iterator_t *it);
BCTBX_PUBLIC void bctbx_iterator_delete(bctbx_iterator_t *it);
/*pair*/
typedef struct _bctoolbox_pair_ullong_t bctoolbox_pair_ullong_t; /*inherite from bctoolbox_pair_t*/
BCTOOLBOX_PUBLIC bctoolbox_pair_ullong_t * bctoolbox_pair_ullong_new(unsigned long long key,void *value);
typedef struct _bctbx_pair_ullong_t bctbx_pair_ullong_t; /*inherite from bctbx_pair_t*/
BCTBX_PUBLIC bctbx_pair_ullong_t * bctbx_pair_ullong_new(unsigned long long key,void *value);
BCTOOLBOX_PUBLIC void* bctoolbox_pair_get_second(const bctoolbox_pair_t * pair);
BCTOOLBOX_PUBLIC const unsigned long long bctoolbox_pair_ullong_get_first(const bctoolbox_pair_ullong_t * pair);
BCTOOLBOX_PUBLIC void bctoolbox_pair_delete(bctoolbox_pair_t * pair);
BCTBX_PUBLIC void* bctbx_pair_get_second(const bctbx_pair_t * pair);
BCTBX_PUBLIC const unsigned long long bctbx_pair_ullong_get_first(const bctbx_pair_ullong_t * pair);
BCTBX_PUBLIC void bctbx_pair_delete(bctbx_pair_t * pair);
#ifdef __cplusplus
}
#endif
#endif /* BCTOOLBOX_LIST_H_ */
#endif /* BCTBX_LIST_H_ */
This diff is collapsed.
This diff is collapsed.
......@@ -26,105 +26,105 @@ typedef std::multimap<unsigned long long, void*> mmap_ullong_t;
typedef mmap_ullong_t::value_type pair_ullong_t;
extern "C" bctoolbox_map_t *bctoolbox_mmap_ullong_new(void) {
return (bctoolbox_map_t *) new mmap_ullong_t();
extern "C" bctbx_map_t *bctbx_mmap_ullong_new(void) {
return (bctbx_map_t *) new mmap_ullong_t();
}
extern "C" void bctoolbox_mmap_ullong_delete(bctoolbox_map_t *mmap) {
extern "C" void bctbx_mmap_ullong_delete(bctbx_map_t *mmap) {
delete (mmap_ullong_t *)mmap;
}
static bctoolbox_iterator_t * bctoolbox_map_insert_base(bctoolbox_map_t *map,const bctoolbox_pair_t *pair,bool_t returns_it) {
static bctbx_iterator_t * bctbx_map_insert_base(bctbx_map_t *map,const bctbx_pair_t *pair,bool_t returns_it) {
mmap_ullong_t::iterator it;
if (typeid((pair_ullong_t*)pair) != typeid(pair_ullong_t*)) {
BCTOOLBOX_SLOGE(LOG_DOMAIN) << "Cannot insert pair ["<< pair << "] on map [" << map <<"] , wrong type";
BCTBX_SLOGE(LOG_DOMAIN) << "Cannot insert pair ["<< pair << "] on map [" << map <<"] , wrong type";
return NULL;
} else {
it = ((mmap_ullong_t *)map)->insert(*((pair_ullong_t*)pair));
}
if (returns_it) {
return (bctoolbox_iterator_t *) new mmap_ullong_t::iterator(it);
return (bctbx_iterator_t *) new mmap_ullong_t::iterator(it);
} else
return NULL;
}
extern "C" void bctoolbox_map_insert(bctoolbox_map_t *map,const bctoolbox_pair_t *pair) {
bctoolbox_map_insert_base(map,pair,FALSE);
extern "C" void bctbx_map_insert(bctbx_map_t *map,const bctbx_pair_t *pair) {
bctbx_map_insert_base(map,pair,FALSE);
}
extern "C" void bctoolbox_map_insert_and_delete(bctoolbox_map_t *map, bctoolbox_pair_t *pair) {
bctoolbox_map_insert(map,pair);
bctoolbox_pair_delete(pair);
extern "C" void bctbx_map_insert_and_delete(bctbx_map_t *map, bctbx_pair_t *pair) {
bctbx_map_insert(map,pair);
bctbx_pair_delete(pair);
}
extern "C" bctoolbox_iterator_t * bctoolbox_map_insert_and_delete_with_returned_it(bctoolbox_map_t *map, bctoolbox_pair_t *pair) {
bctoolbox_iterator_t * it = bctoolbox_map_insert_base(map,pair,TRUE);
bctoolbox_pair_delete(pair);
extern "C" bctbx_iterator_t * bctbx_map_insert_and_delete_with_returned_it(bctbx_map_t *map, bctbx_pair_t *pair) {
bctbx_iterator_t * it = bctbx_map_insert_base(map,pair,TRUE);
bctbx_pair_delete(pair);
return it;
}
extern "C" bctoolbox_iterator_t *bctoolbox_map_erase(bctoolbox_map_t *map,bctoolbox_iterator_t *it) {
//bctoolbox_iterator_t * next = (bctoolbox_iterator_t *) new mmap_ullong_t::iterator((*(mmap_ullong_t::iterator*)it));
//next = bctoolbox_iterator_get_next(next);
extern "C" bctbx_iterator_t *bctbx_map_erase(bctbx_map_t *map,bctbx_iterator_t *it) {
//bctbx_iterator_t * next = (bctbx_iterator_t *) new mmap_ullong_t::iterator((*(mmap_ullong_t::iterator*)it));
//next = bctbx_iterator_get_next(next);
((mmap_ullong_t *)map)->erase((*(mmap_ullong_t::iterator*)it)++);
//bctoolbox_iterator_delete(it);
//bctbx_iterator_delete(it);
return it;
}
extern "C" bctoolbox_iterator_t *bctoolbox_map_begin(const bctoolbox_map_t *map) {
return (bctoolbox_iterator_t *) new mmap_ullong_t::iterator(((mmap_ullong_t *)map)->begin());
extern "C" bctbx_iterator_t *bctbx_map_begin(const bctbx_map_t *map) {
return (bctbx_iterator_t *) new mmap_ullong_t::iterator(((mmap_ullong_t *)map)->begin());
}
extern "C" bctoolbox_iterator_t * bctoolbox_map_end(const bctoolbox_map_t *map) {
return (bctoolbox_iterator_t *) new mmap_ullong_t::iterator(((mmap_ullong_t *)map)->end());
extern "C" bctbx_iterator_t * bctbx_map_end(const bctbx_map_t *map) {
return (bctbx_iterator_t *) new mmap_ullong_t::iterator(((mmap_ullong_t *)map)->end());
}
/*iterator*/
extern "C" bctoolbox_pair_t *bctoolbox_iterator_get_pair(const bctoolbox_iterator_t *it) {
return (bctoolbox_pair_t *)&(**((mmap_ullong_t::iterator*)it));
extern "C" bctbx_pair_t *bctbx_iterator_get_pair(const bctbx_iterator_t *it) {
return (bctbx_pair_t *)&(**((mmap_ullong_t::iterator*)it));
}
extern "C" bctoolbox_iterator_t *bctoolbox_iterator_get_next(bctoolbox_iterator_t *it) {
extern "C" bctbx_iterator_t *bctbx_iterator_get_next(bctbx_iterator_t *it) {
((mmap_ullong_t::iterator*)it)->operator++();
return it;
}
extern "C" bctoolbox_iterator_t *bctoolbox_iterator_get_next_and_delete(bctoolbox_iterator_t *it) {
bctoolbox_iterator_t * next = bctoolbox_iterator_get_next(it);
bctoolbox_iterator_delete(it);
extern "C" bctbx_iterator_t *bctbx_iterator_get_next_and_delete(bctbx_iterator_t *it) {
bctbx_iterator_t * next = bctbx_iterator_get_next(it);
bctbx_iterator_delete(it);
return next;
}
extern "C" bool_t bctoolbox_iterator_equals(const bctoolbox_iterator_t *a,const bctoolbox_iterator_t *b) {
extern "C" bool_t bctbx_iterator_equals(const bctbx_iterator_t *a,const bctbx_iterator_t *b) {
return *(mmap_ullong_t::iterator*)a == *(mmap_ullong_t::iterator*)b;
}
extern "C" void bctoolbox_iterator_delete(bctoolbox_iterator_t *it) {
extern "C" void bctbx_iterator_delete(bctbx_iterator_t *it) {
delete ((mmap_ullong_t::iterator*)it);
}
/*pair*/
extern "C" bctoolbox_pair_ullong_t * bctoolbox_pair_ullong_new(unsigned long long key,void *value) {
return (bctoolbox_pair_ullong_t *) new pair_ullong_t(key,value);
extern "C" bctbx_pair_ullong_t * bctbx_pair_ullong_new(unsigned long long key,void *value) {
return (bctbx_pair_ullong_t *) new pair_ullong_t(key,value);
}
extern "C" const unsigned long long bctoolbox_pair_ullong_get_first(const bctoolbox_pair_ullong_t * pair) {
extern "C" const unsigned long long bctbx_pair_ullong_get_first(const bctbx_pair_ullong_t * pair) {
return ((pair_ullong_t*)pair)->first;
}
extern "C" void* bctoolbox_pair_get_second(const bctoolbox_pair_t * pair) {
extern "C" void* bctbx_pair_get_second(const bctbx_pair_t * pair) {
return ((pair_ullong_t*)pair)->second;
}
extern "C" void bctoolbox_pair_delete(bctoolbox_pair_t * pair) {
extern "C" void bctbx_pair_delete(bctbx_pair_t * pair) {
delete ((pair_ullong_t*)pair);
}
extern "C" bctoolbox_iterator_t * bctoolbox_map_find_custom(bctoolbox_map_t *map, bctoolbox_compare_func compare_func, const void *user_data) {
bctoolbox_iterator_t * end = bctoolbox_map_end(map);
extern "C" bctbx_iterator_t * bctbx_map_find_custom(bctbx_map_t *map, bctbx_compare_func compare_func, const void *user_data) {
bctbx_iterator_t * end = bctbx_map_end(map);
for(bctoolbox_iterator_t * it = bctoolbox_map_begin(map);!bctoolbox_iterator_equals(it,end);) {
if (compare_func(bctoolbox_pair_get_second(bctoolbox_iterator_get_pair(it)),user_data)==0) {
bctoolbox_iterator_delete(end);
for(bctbx_iterator_t * it = bctbx_map_begin(map);!bctbx_iterator_equals(it,end);) {
if (compare_func(bctbx_pair_get_second(bctbx_iterator_get_pair(it)),user_data)==0) {
bctbx_iterator_delete(end);
return it;
} else {
it = bctoolbox_iterator_get_next(it);
it = bctbx_iterator_get_next(it);
}
}
bctoolbox_iterator_delete(end);
bctbx_iterator_delete(end);
return NULL;
}
extern "C" size_t bctoolbox_map_size(const bctoolbox_map_t *map) {
extern "C" size_t bctbx_map_size(const bctbx_map_t *map) {
return ((mmap_ullong_t *)map)->size();
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -31,18 +31,18 @@ static void log_handler(int lev, const char *fmt, va_list args) {
#else
va_list cap;
va_copy(cap,args);
vfprintf(lev == BCTOOLBOX_ERROR ? stderr : stdout, fmt, cap);
fprintf(lev == BCTOOLBOX_ERROR ? stderr : stdout, "\n");
vfprintf(lev == BCTBX_LOG_ERROR ? stderr : stdout, fmt, cap);
fprintf(lev == BCTBX_LOG_ERROR ? stderr : stdout, "\n");
va_end(cap);
#endif
if (log_file){
bctoolbox_logv(log_domain,lev, fmt, args);
bctbx_logv(log_domain,lev, fmt, args);
}
}
void bctoolbox_tester_init(void(*ftester_printf)(int level, const char *fmt, va_list args)) {
bc_tester_init(log_handler,BCTOOLBOX_ERROR, 0,NULL);
bc_tester_init(log_handler,BCTBX_LOG_ERROR, 0,NULL);
bc_tester_add_suite(&containers_test_suite);
}
......@@ -59,11 +59,11 @@ int bctoolbox_tester_set_log_file(const char *filename) {
}
log_file = fopen(filename, "w");
if (!log_file) {
bctoolbox_error("Cannot open file [%s] for writing logs because [%s]", filename, strerror(errno));
bctbx_error("Cannot open file [%s] for writing logs because [%s]", filename, strerror(errno));
return -1;
}
bctoolbox_message("Redirecting traces to file [%s]", filename);
bctoolbox_set_log_file(log_file);
bctbx_message("Redirecting traces to file [%s]", filename);
bctbx_set_log_file(log_file);
return 0;
}
......@@ -84,9 +84,10 @@ int main (int argc, char *argv[]) {
for(i=1;i<argc;++i){
if (strcmp(argv[i],"--verbose")==0){
bctoolbox_set_log_level(log_domain, BCTOOLBOX_DEBUG);
bctbx_set_log_level(log_domain, BCTBX_LOG_DEBUG);
bctbx_set_log_level(BCTBX_LOG_DOMAIN,BCTBX_LOG_DEBUG);
} else if (strcmp(argv[i],"--silent")==0){
bctoolbox_set_log_level(log_domain, BCTOOLBOX_FATAL);
bctbx_set_log_level(log_domain, BCTBX_LOG_FATAL);
} else if (strcmp(argv[i],"--log-file")==0){
CHECK_ARG("--log-file", ++i, argc);
if (bctoolbox_tester_set_log_file(argv[i]) < 0) return -2;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment