mirror of
https://github.com/rkd77/elinks.git
synced 2025-06-30 22:19:29 -04:00
[curl] check_bottom_halves in check_multi_info
Also sample ELOG
This commit is contained in:
parent
73fff45f01
commit
f44f8be07d
@ -131,7 +131,6 @@ read_bookmarks_default(FILE *f)
|
|||||||
|
|
||||||
struct write_bookmarks_default
|
struct write_bookmarks_default
|
||||||
{
|
{
|
||||||
ELOG
|
|
||||||
struct secure_save_info *ssi;
|
struct secure_save_info *ssi;
|
||||||
int save_folder_state;
|
int save_folder_state;
|
||||||
int codepage;
|
int codepage;
|
||||||
|
14
src/elinks.h
14
src/elinks.h
@ -39,6 +39,20 @@
|
|||||||
#define C_(str) (char *)((str))
|
#define C_(str) (char *)((str))
|
||||||
|
|
||||||
#define ELOG
|
#define ELOG
|
||||||
|
#if 0
|
||||||
|
#define ELOG2 do { \
|
||||||
|
char outstr[200]; \
|
||||||
|
time_t t; \
|
||||||
|
struct tm *tmp; \
|
||||||
|
t = time(NULL); \
|
||||||
|
tmp = localtime(&t); \
|
||||||
|
if (tmp != NULL) { \
|
||||||
|
if (strftime(outstr, sizeof(outstr), "%F-%T", tmp) != 0) { \
|
||||||
|
fprintf(stderr, "%s %s\n", outstr, __FUNCTION__); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_OS_DOS
|
#ifdef CONFIG_OS_DOS
|
||||||
#define loop_select(a, b, c, d, e) dos_select(a, b, c, d, e, 1)
|
#define loop_select(a, b, c, d, e) dos_select(a, b, c, d, e, 1)
|
||||||
|
@ -90,7 +90,6 @@
|
|||||||
/* Information associated with a specific easy handle */
|
/* Information associated with a specific easy handle */
|
||||||
typedef struct _ConnInfo
|
typedef struct _ConnInfo
|
||||||
{
|
{
|
||||||
ELOG
|
|
||||||
CURL *easy;
|
CURL *easy;
|
||||||
char *url;
|
char *url;
|
||||||
GlobalInfo *global;
|
GlobalInfo *global;
|
||||||
@ -100,7 +99,6 @@ typedef struct _ConnInfo
|
|||||||
/* Information associated with a specific socket */
|
/* Information associated with a specific socket */
|
||||||
typedef struct _SockInfo
|
typedef struct _SockInfo
|
||||||
{
|
{
|
||||||
ELOG
|
|
||||||
curl_socket_t sockfd;
|
curl_socket_t sockfd;
|
||||||
CURL *easy;
|
CURL *easy;
|
||||||
int action;
|
int action;
|
||||||
|
@ -119,7 +119,6 @@ check_timers(timeval_T *last_time)
|
|||||||
#endif
|
#endif
|
||||||
check_bottom_halves();
|
check_bottom_halves();
|
||||||
}
|
}
|
||||||
|
|
||||||
timeval_copy(last_time, &now);
|
timeval_copy(last_time, &now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,6 +578,7 @@ check_multi_info(GlobalInfo *g)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
check_bottom_halves();
|
||||||
#if 0
|
#if 0
|
||||||
if (g->still_running == 0 && g->stopped) {
|
if (g->still_running == 0 && g->stopped) {
|
||||||
event_base_loopbreak(g->evbase);
|
event_base_loopbreak(g->evbase);
|
||||||
|
@ -99,11 +99,11 @@ parse_day(const char **date_p, char *end)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
parse_time(const char **time, struct tm *tm, char *end)
|
parse_time(const char **time2, struct tm *tm, char *end)
|
||||||
{
|
{
|
||||||
ELOG
|
ELOG
|
||||||
unsigned char h1, h2, m1, m2;
|
unsigned char h1, h2, m1, m2;
|
||||||
const char *date = *time;
|
const char *date = *time2;
|
||||||
|
|
||||||
#define check_time(tm) \
|
#define check_time(tm) \
|
||||||
((tm)->tm_hour <= 23 && (tm)->tm_min <= 59 && (tm)->tm_sec <= 59)
|
((tm)->tm_hour <= 23 && (tm)->tm_min <= 59 && (tm)->tm_sec <= 59)
|
||||||
@ -126,7 +126,7 @@ parse_time(const char **time, struct tm *tm, char *end)
|
|||||||
|
|
||||||
/* Eat :SS or [PA]M or nothing */
|
/* Eat :SS or [PA]M or nothing */
|
||||||
if (end && date + 2 >= end) {
|
if (end && date + 2 >= end) {
|
||||||
*time = date;
|
*time2 = date;
|
||||||
return check_time(tm);
|
return check_time(tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ parse_time(const char **time, struct tm *tm, char *end)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*time = date;
|
*time2 = date;
|
||||||
|
|
||||||
return check_time(tm);
|
return check_time(tm);
|
||||||
}
|
}
|
||||||
|
@ -493,7 +493,7 @@ set_screen_dirty_image(struct terminal_screen *screen, int from, int to)
|
|||||||
static void
|
static void
|
||||||
set_screen_driver_opt(struct screen_driver *driver, struct option *term_spec)
|
set_screen_driver_opt(struct screen_driver *driver, struct option *term_spec)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
const int cp = get_opt_codepage_tree(term_spec, "charset", NULL);
|
const int cp = get_opt_codepage_tree(term_spec, "charset", NULL);
|
||||||
int utf8_io = get_opt_bool_tree(term_spec, "utf_8_io", NULL);
|
int utf8_io = get_opt_bool_tree(term_spec, "utf_8_io", NULL);
|
||||||
|
|
||||||
@ -603,7 +603,7 @@ static int
|
|||||||
screen_driver_change_hook(struct session *ses, struct option *term_spec,
|
screen_driver_change_hook(struct session *ses, struct option *term_spec,
|
||||||
struct option *changed)
|
struct option *changed)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
term_mode_type_T type = get_opt_int_tree(term_spec, "type", NULL);
|
term_mode_type_T type = get_opt_int_tree(term_spec, "type", NULL);
|
||||||
struct screen_driver *driver;
|
struct screen_driver *driver;
|
||||||
const char *name = term_spec->name;
|
const char *name = term_spec->name;
|
||||||
@ -620,7 +620,7 @@ screen_driver_change_hook(struct session *ses, struct option *term_spec,
|
|||||||
static inline struct screen_driver *
|
static inline struct screen_driver *
|
||||||
add_screen_driver(term_mode_type_T type, struct terminal *term, int env_len)
|
add_screen_driver(term_mode_type_T type, struct terminal *term, int env_len)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct screen_driver *driver;
|
struct screen_driver *driver;
|
||||||
|
|
||||||
/* One byte is reserved for name in struct screen_driver. */
|
/* One byte is reserved for name in struct screen_driver. */
|
||||||
@ -646,7 +646,7 @@ add_screen_driver(term_mode_type_T type, struct terminal *term, int env_len)
|
|||||||
static inline struct screen_driver *
|
static inline struct screen_driver *
|
||||||
get_screen_driver(struct terminal *term)
|
get_screen_driver(struct terminal *term)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
term_mode_type_T type = get_opt_int_tree(term->spec, "type", NULL);
|
term_mode_type_T type = get_opt_int_tree(term->spec, "type", NULL);
|
||||||
const char *name = term->spec->name;
|
const char *name = term->spec->name;
|
||||||
int len = strlen(name);
|
int len = strlen(name);
|
||||||
@ -673,7 +673,7 @@ get_screen_driver(struct terminal *term)
|
|||||||
void
|
void
|
||||||
done_screen_drivers(struct module *xxx)
|
done_screen_drivers(struct module *xxx)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
free_list(active_screen_drivers);
|
free_list(active_screen_drivers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,7 +683,7 @@ done_screen_drivers(struct module *xxx)
|
|||||||
struct string *
|
struct string *
|
||||||
add_cursor_move_to_string(struct string *screen, int y, int x)
|
add_cursor_move_to_string(struct string *screen, int y, int x)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
#ifdef CONFIG_TERMINFO
|
#ifdef CONFIG_TERMINFO
|
||||||
if (get_cmd_opt_bool("terminfo")) {
|
if (get_cmd_opt_bool("terminfo")) {
|
||||||
const char *aa = terminfo_cursor_address(y-1, x-1);
|
const char *aa = terminfo_cursor_address(y-1, x-1);
|
||||||
@ -735,35 +735,35 @@ struct screen_state {
|
|||||||
static inline int
|
static inline int
|
||||||
compare_color_true(unsigned char *a, unsigned char *b)
|
compare_color_true(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
return !memcmp(a, b, 6);
|
return !memcmp(a, b, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
compare_bg_color_true(unsigned char *a, unsigned char *b)
|
compare_bg_color_true(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
return (a[3] == b[3] && a[4] == b[4] && a[5] == b[5]);
|
return (a[3] == b[3] && a[4] == b[4] && a[5] == b[5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
compare_fg_color_true(unsigned char *a, unsigned char *b)
|
compare_fg_color_true(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
return (a[0] == b[0] && a[1] == b[1] && a[2] == b[2]);
|
return (a[0] == b[0] && a[1] == b[1] && a[2] == b[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
copy_color_true(unsigned char *a, unsigned char *b)
|
copy_color_true(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
memcpy(a, b, 6);
|
memcpy(a, b, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
background_is_black(unsigned char *a)
|
background_is_black(unsigned char *a)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
static unsigned char b[6] = {0, 0, 0, 0, 0, 0};
|
static unsigned char b[6] = {0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
return compare_bg_color_true(a, b);
|
return compare_bg_color_true(a, b);
|
||||||
@ -774,28 +774,28 @@ background_is_black(unsigned char *a)
|
|||||||
static inline int
|
static inline int
|
||||||
compare_color_256(unsigned char *a, unsigned char *b)
|
compare_color_256(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
return (a[0] == b[0] && a[1] == b[1]);
|
return (a[0] == b[0] && a[1] == b[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
compare_bg_color_256(unsigned char *a, unsigned char *b)
|
compare_bg_color_256(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
return (a[1] == b[1]);
|
return (a[1] == b[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
compare_fg_color_256(unsigned char *a, unsigned char *b)
|
compare_fg_color_256(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
return (a[0] == b[0]);
|
return (a[0] == b[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
copy_color_256(unsigned char *a, unsigned char *b)
|
copy_color_256(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
a[0] = b[0];
|
a[0] = b[0];
|
||||||
a[1] = b[1];
|
a[1] = b[1];
|
||||||
}
|
}
|
||||||
@ -804,28 +804,28 @@ copy_color_256(unsigned char *a, unsigned char *b)
|
|||||||
static inline int
|
static inline int
|
||||||
compare_color_16(unsigned char *a, unsigned char *b)
|
compare_color_16(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
return (a[0] == b[0]);
|
return (a[0] == b[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
compare_bg_color_16(unsigned char *a, unsigned char *b)
|
compare_bg_color_16(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
return (TERM_COLOR_BACKGROUND_16(a) == TERM_COLOR_BACKGROUND_16(b));
|
return (TERM_COLOR_BACKGROUND_16(a) == TERM_COLOR_BACKGROUND_16(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
compare_fg_color_16(unsigned char *a, unsigned char *b)
|
compare_fg_color_16(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
return (TERM_COLOR_FOREGROUND_16(a) == TERM_COLOR_FOREGROUND_16(b));
|
return (TERM_COLOR_FOREGROUND_16(a) == TERM_COLOR_FOREGROUND_16(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
copy_color_16(unsigned char *a, unsigned char *b)
|
copy_color_16(unsigned char *a, unsigned char *b)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
a[0] = b[0];
|
a[0] = b[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -839,7 +839,7 @@ add_char_data(struct string *screen, struct screen_driver *driver,
|
|||||||
unsigned char data, unsigned char border)
|
unsigned char data, unsigned char border)
|
||||||
#endif /* !CONFIG_UTF8 */
|
#endif /* !CONFIG_UTF8 */
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
/* charset use_utf8_io border data add_to_string
|
/* charset use_utf8_io border data add_to_string
|
||||||
* ------- ----------- ------ ---------------- ----------------
|
* ------- ----------- ------ ---------------- ----------------
|
||||||
* unibyte 0 0 terminal unibyte terminal unibyte
|
* unibyte 0 0 terminal unibyte terminal unibyte
|
||||||
@ -890,7 +890,7 @@ static inline void
|
|||||||
add_char16(struct string *screen, struct screen_driver *driver,
|
add_char16(struct string *screen, struct screen_driver *driver,
|
||||||
struct screen_char *ch, struct screen_state *state)
|
struct screen_char *ch, struct screen_state *state)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
unsigned char border = (ch->attr & SCREEN_ATTR_FRAME);
|
unsigned char border = (ch->attr & SCREEN_ATTR_FRAME);
|
||||||
unsigned char italic = (ch->attr & SCREEN_ATTR_ITALIC);
|
unsigned char italic = (ch->attr & SCREEN_ATTR_ITALIC);
|
||||||
unsigned char underline = (ch->attr & SCREEN_ATTR_UNDERLINE);
|
unsigned char underline = (ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||||
@ -1070,7 +1070,7 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
|||||||
static inline void
|
static inline void
|
||||||
add_char_color(struct string *screen, const struct string *seq, unsigned char color)
|
add_char_color(struct string *screen, const struct string *seq, unsigned char color)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
char color_buf[3];
|
char color_buf[3];
|
||||||
char *color_pos = color_buf;
|
char *color_pos = color_buf;
|
||||||
int seq_pos = 0;
|
int seq_pos = 0;
|
||||||
@ -1123,7 +1123,7 @@ static inline void
|
|||||||
add_char256(struct string *screen, struct screen_driver *driver,
|
add_char256(struct string *screen, struct screen_driver *driver,
|
||||||
struct screen_char *ch, struct screen_state *state)
|
struct screen_char *ch, struct screen_state *state)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
unsigned char attr_delta = (ch->attr ^ state->attr);
|
unsigned char attr_delta = (ch->attr ^ state->attr);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -1262,7 +1262,7 @@ static const struct string color_true_seqs[] = {
|
|||||||
static inline void
|
static inline void
|
||||||
add_char_true_color(struct string *screen, const struct string *seq, unsigned char *colors)
|
add_char_true_color(struct string *screen, const struct string *seq, unsigned char *colors)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
char color_buf[3];
|
char color_buf[3];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1312,7 +1312,7 @@ static inline void
|
|||||||
add_char_true(struct string *screen, struct screen_driver *driver,
|
add_char_true(struct string *screen, struct screen_driver *driver,
|
||||||
struct screen_char *ch, struct screen_state *state)
|
struct screen_char *ch, struct screen_state *state)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
unsigned char attr_delta = (ch->attr ^ state->attr);
|
unsigned char attr_delta = (ch->attr ^ state->attr);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -1508,7 +1508,7 @@ add_char_true(struct string *screen, struct screen_driver *driver,
|
|||||||
void
|
void
|
||||||
redraw_screen(struct terminal *term)
|
redraw_screen(struct terminal *term)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct screen_driver *driver;
|
struct screen_driver *driver;
|
||||||
struct string image;
|
struct string image;
|
||||||
struct screen_state state = INIT_SCREEN_STATE;
|
struct screen_state state = INIT_SCREEN_STATE;
|
||||||
@ -1596,7 +1596,7 @@ redraw_screen(struct terminal *term)
|
|||||||
void
|
void
|
||||||
erase_screen(struct terminal *term)
|
erase_screen(struct terminal *term)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
if (term->master) {
|
if (term->master) {
|
||||||
if (is_blocked()) return;
|
if (is_blocked()) return;
|
||||||
want_draw();
|
want_draw();
|
||||||
@ -1615,7 +1615,7 @@ erase_screen(struct terminal *term)
|
|||||||
void
|
void
|
||||||
beep_terminal(struct terminal *term)
|
beep_terminal(struct terminal *term)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
#ifdef CONFIG_OS_WIN32
|
#ifdef CONFIG_OS_WIN32
|
||||||
MessageBeep(MB_ICONEXCLAMATION);
|
MessageBeep(MB_ICONEXCLAMATION);
|
||||||
#else
|
#else
|
||||||
@ -1626,7 +1626,7 @@ beep_terminal(struct terminal *term)
|
|||||||
struct terminal_screen *
|
struct terminal_screen *
|
||||||
init_screen(void)
|
init_screen(void)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct terminal_screen *screen;
|
struct terminal_screen *screen;
|
||||||
|
|
||||||
screen = (struct terminal_screen *)mem_calloc(1, sizeof(*screen));
|
screen = (struct terminal_screen *)mem_calloc(1, sizeof(*screen));
|
||||||
@ -1644,7 +1644,7 @@ init_screen(void)
|
|||||||
void
|
void
|
||||||
resize_screen(struct terminal *term, int width, int height)
|
resize_screen(struct terminal *term, int width, int height)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct terminal_screen *screen;
|
struct terminal_screen *screen;
|
||||||
struct screen_char *image;
|
struct screen_char *image;
|
||||||
size_t size, bsize;
|
size_t size, bsize;
|
||||||
@ -1689,7 +1689,7 @@ resize_screen(struct terminal *term, int width, int height)
|
|||||||
void
|
void
|
||||||
done_screen(struct terminal_screen *screen)
|
done_screen(struct terminal_screen *screen)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
mem_free_if(screen->image);
|
mem_free_if(screen->image);
|
||||||
mem_free(screen->dirty);
|
mem_free(screen->dirty);
|
||||||
mem_free(screen->dirty_image);
|
mem_free(screen->dirty_image);
|
||||||
|
@ -221,7 +221,7 @@ struct fastfind_info {
|
|||||||
static void
|
static void
|
||||||
FF_DBG_search_stats(struct fastfind_info *info, int key_len)
|
FF_DBG_search_stats(struct fastfind_info *info, int key_len)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
info->debug.searches++;
|
info->debug.searches++;
|
||||||
info->debug.total_key_len += key_len;
|
info->debug.total_key_len += key_len;
|
||||||
info->debug.teststmp = info->debug.tests;
|
info->debug.teststmp = info->debug.tests;
|
||||||
@ -232,7 +232,7 @@ FF_DBG_search_stats(struct fastfind_info *info, int key_len)
|
|||||||
static void
|
static void
|
||||||
FF_DBG_dump_stats(struct fastfind_info *info)
|
FF_DBG_dump_stats(struct fastfind_info *info)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
fprintf(stderr, "------ FastFind Statistics ------\n");
|
fprintf(stderr, "------ FastFind Statistics ------\n");
|
||||||
fprintf(stderr, "Comment : %s\n", info->debug.comment);
|
fprintf(stderr, "Comment : %s\n", info->debug.comment);
|
||||||
fprintf(stderr, "Case-aware : %s\n", info->case_aware ? "yes" : "no");
|
fprintf(stderr, "Case-aware : %s\n", info->case_aware ? "yes" : "no");
|
||||||
@ -289,7 +289,7 @@ FF_DBG_dump_stats(struct fastfind_info *info)
|
|||||||
static struct fastfind_info *
|
static struct fastfind_info *
|
||||||
init_fastfind(struct fastfind_index *index, fastfind_flags_T flags)
|
init_fastfind(struct fastfind_index *index, fastfind_flags_T flags)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct fastfind_info *info = (struct fastfind_info *)mem_calloc(1, sizeof(*info));
|
struct fastfind_info *info = (struct fastfind_info *)mem_calloc(1, sizeof(*info));
|
||||||
|
|
||||||
index->handle = info;
|
index->handle = info;
|
||||||
@ -310,7 +310,7 @@ init_fastfind(struct fastfind_index *index, fastfind_flags_T flags)
|
|||||||
static int
|
static int
|
||||||
alloc_ff_data(struct fastfind_info *info)
|
alloc_ff_data(struct fastfind_info *info)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct ff_data *data;
|
struct ff_data *data;
|
||||||
|
|
||||||
assert(info->count < FF_MAX_KEYS);
|
assert(info->count < FF_MAX_KEYS);
|
||||||
@ -331,7 +331,7 @@ alloc_ff_data(struct fastfind_info *info)
|
|||||||
static void
|
static void
|
||||||
add_to_ff_data(void *p, int key_len, struct fastfind_info *info)
|
add_to_ff_data(void *p, int key_len, struct fastfind_info *info)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct ff_data *data = &info->data[info->pointers_count++];
|
struct ff_data *data = &info->data[info->pointers_count++];
|
||||||
|
|
||||||
/* Record new pointer and key len, used in search */
|
/* Record new pointer and key len, used in search */
|
||||||
@ -343,7 +343,7 @@ add_to_ff_data(void *p, int key_len, struct fastfind_info *info)
|
|||||||
static int
|
static int
|
||||||
alloc_leafset(struct fastfind_info *info)
|
alloc_leafset(struct fastfind_info *info)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct ff_node **leafsets;
|
struct ff_node **leafsets;
|
||||||
struct ff_node *leafset;
|
struct ff_node *leafset;
|
||||||
|
|
||||||
@ -372,7 +372,7 @@ alloc_leafset(struct fastfind_info *info)
|
|||||||
static inline int
|
static inline int
|
||||||
char2idx(unsigned char c, struct fastfind_info *info)
|
char2idx(unsigned char c, struct fastfind_info *info)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
char *idx = (char *)memchr(info->uniq_chars, c, info->uniq_chars_count);
|
char *idx = (char *)memchr(info->uniq_chars, c, info->uniq_chars_count);
|
||||||
|
|
||||||
if (idx) return (idx - info->uniq_chars);
|
if (idx) return (idx - info->uniq_chars);
|
||||||
@ -383,7 +383,7 @@ char2idx(unsigned char c, struct fastfind_info *info)
|
|||||||
static inline void
|
static inline void
|
||||||
init_idxtab(struct fastfind_info *info)
|
init_idxtab(struct fastfind_info *info)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < FF_MAX_CHARS; i++)
|
for (i = 0; i < FF_MAX_CHARS; i++)
|
||||||
@ -394,7 +394,7 @@ static inline void
|
|||||||
compress_node(struct ff_node *leafset, struct fastfind_info *info,
|
compress_node(struct ff_node *leafset, struct fastfind_info *info,
|
||||||
int i, int pos)
|
int i, int pos)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct ff_node_c *new_ = (struct ff_node_c *)mem_alloc(sizeof(*new_));
|
struct ff_node_c *new_ = (struct ff_node_c *)mem_alloc(sizeof(*new_));
|
||||||
|
|
||||||
if (!new_) return;
|
if (!new_) return;
|
||||||
@ -414,7 +414,7 @@ compress_node(struct ff_node *leafset, struct fastfind_info *info,
|
|||||||
static void
|
static void
|
||||||
compress_tree(struct ff_node *leafset, struct fastfind_info *info)
|
compress_tree(struct ff_node *leafset, struct fastfind_info *info)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int i;
|
int i;
|
||||||
@ -452,7 +452,7 @@ compress_tree(struct ff_node *leafset, struct fastfind_info *info)
|
|||||||
struct fastfind_index *
|
struct fastfind_index *
|
||||||
fastfind_index(struct fastfind_index *index, fastfind_flags_T flags)
|
fastfind_index(struct fastfind_index *index, fastfind_flags_T flags)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct fastfind_key_value *p;
|
struct fastfind_key_value *p;
|
||||||
struct fastfind_info *info;
|
struct fastfind_info *info;
|
||||||
|
|
||||||
@ -607,7 +607,7 @@ void *
|
|||||||
fastfind_search(struct fastfind_index *index,
|
fastfind_search(struct fastfind_index *index,
|
||||||
const char *key, int key_len)
|
const char *key, int key_len)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct ff_node *current;
|
struct ff_node *current;
|
||||||
struct fastfind_info *info;
|
struct fastfind_info *info;
|
||||||
|
|
||||||
@ -650,7 +650,7 @@ fastfind_search(struct fastfind_index *index,
|
|||||||
void
|
void
|
||||||
fastfind_done(struct fastfind_index *index)
|
fastfind_done(struct fastfind_index *index)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
struct fastfind_info *info;
|
struct fastfind_info *info;
|
||||||
|
|
||||||
assert(index);
|
assert(index);
|
||||||
@ -757,7 +757,7 @@ struct list *internal_pointer;
|
|||||||
void
|
void
|
||||||
reset_list(void)
|
reset_list(void)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
internal_pointer = list;
|
internal_pointer = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,7 +768,7 @@ reset_list(void)
|
|||||||
struct fastfind_key_value *
|
struct fastfind_key_value *
|
||||||
next_in_list(void)
|
next_in_list(void)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
static struct fastfind_key_value kv;
|
static struct fastfind_key_value kv;
|
||||||
|
|
||||||
if (!internal_pointer->tag) return NULL;
|
if (!internal_pointer->tag) return NULL;
|
||||||
@ -787,7 +787,7 @@ static struct fastfind_index ff_index
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
char *key = argv[1];
|
char *key = argv[1];
|
||||||
struct list *result;
|
struct list *result;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ static int alloc_try = 0;
|
|||||||
static int
|
static int
|
||||||
patience(const char *of)
|
patience(const char *of)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
++alloc_try;
|
++alloc_try;
|
||||||
if (alloc_try < ALLOC_MAXTRIES) {
|
if (alloc_try < ALLOC_MAXTRIES) {
|
||||||
ERROR("Out of memory (%s returned NULL): retry #%d/%d, "
|
ERROR("Out of memory (%s returned NULL): retry #%d/%d, "
|
||||||
@ -55,7 +55,7 @@ patience(const char *of)
|
|||||||
void *
|
void *
|
||||||
mem_alloc(size_t size)
|
mem_alloc(size_t size)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
if (size)
|
if (size)
|
||||||
do {
|
do {
|
||||||
void *p = malloc(size);
|
void *p = malloc(size);
|
||||||
@ -68,7 +68,7 @@ mem_alloc(size_t size)
|
|||||||
void *
|
void *
|
||||||
mem_calloc(size_t count, size_t eltsize)
|
mem_calloc(size_t count, size_t eltsize)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
if (eltsize && count)
|
if (eltsize && count)
|
||||||
do {
|
do {
|
||||||
void *p = calloc(count, eltsize);
|
void *p = calloc(count, eltsize);
|
||||||
@ -81,7 +81,7 @@ mem_calloc(size_t count, size_t eltsize)
|
|||||||
void
|
void
|
||||||
mem_free(void *p)
|
mem_free(void *p)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
if (!p) {
|
if (!p) {
|
||||||
INTERNAL("mem_free(NULL)");
|
INTERNAL("mem_free(NULL)");
|
||||||
return;
|
return;
|
||||||
@ -92,7 +92,7 @@ mem_free(void *p)
|
|||||||
void *
|
void *
|
||||||
mem_realloc(void *p, size_t size)
|
mem_realloc(void *p, size_t size)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
if (!p) return mem_alloc(size);
|
if (!p) return mem_alloc(size);
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
@ -124,7 +124,7 @@ static int page_size;
|
|||||||
static size_t
|
static size_t
|
||||||
round_size(size_t size)
|
round_size(size_t size)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
#ifdef HAVE_SC_PAGE_SIZE
|
#ifdef HAVE_SC_PAGE_SIZE
|
||||||
if (!page_size) page_size = sysconf(_SC_PAGE_SIZE);
|
if (!page_size) page_size = sysconf(_SC_PAGE_SIZE);
|
||||||
#endif
|
#endif
|
||||||
@ -140,7 +140,7 @@ round_size(size_t size)
|
|||||||
void *
|
void *
|
||||||
mem_mmap_alloc(size_t size)
|
mem_mmap_alloc(size_t size)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
if (size) {
|
if (size) {
|
||||||
void *p = mmap(NULL, round_size(size), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
|
void *p = mmap(NULL, round_size(size), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ mem_mmap_alloc(size_t size)
|
|||||||
void
|
void
|
||||||
mem_mmap_free(void *p, size_t size)
|
mem_mmap_free(void *p, size_t size)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
if (!p) {
|
if (!p) {
|
||||||
INTERNAL("mem_mmap_free(NULL)");
|
INTERNAL("mem_mmap_free(NULL)");
|
||||||
return;
|
return;
|
||||||
@ -166,7 +166,7 @@ mem_mmap_free(void *p, size_t size)
|
|||||||
void *
|
void *
|
||||||
mem_mmap_realloc(void *p, size_t old_size, size_t new_size)
|
mem_mmap_realloc(void *p, size_t old_size, size_t new_size)
|
||||||
{
|
{
|
||||||
ELOG
|
//ELOG
|
||||||
if (!p) return mem_mmap_alloc(new_size);
|
if (!p) return mem_mmap_alloc(new_size);
|
||||||
|
|
||||||
if (round_size(old_size) == round_size(new_size))
|
if (round_size(old_size) == round_size(new_size))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user