include/hbuf.h
changeset 79 05328c643696
equal deleted inserted replaced
78:1253cacc0f21 79:05328c643696
       
     1 #ifndef __HBUF_H__
       
     2 #define __HBUF_H__ 1
       
     3 
       
     4 #include <time.h>
       
     5 #include <glib.h>
       
     6 
       
     7 // With current implementation a message must fit in a hbuf block,
       
     8 // so we shouldn't choose a too small size.
       
     9 #define HBB_BLOCKSIZE   8192    // > 20 please
       
    10 
       
    11 // Flags:
       
    12 // - ALLOC: the ptr data has been allocated, it can be freed
       
    13 // - PERSISTENT: this is a new history line
       
    14 #define HBB_FLAG_ALLOC      1
       
    15 #define HBB_FLAG_PERSISTENT 2
       
    16 
       
    17 #define HBB_PREFIX_IN         (1U<<0)
       
    18 #define HBB_PREFIX_OUT        (1U<<1)
       
    19 #define HBB_PREFIX_STATUS     (1U<<2)
       
    20 #define HBB_PREFIX_AUTH       (1U<<3)
       
    21 #define HBB_PREFIX_INFO       (1U<<4)
       
    22 #define HBB_PREFIX_ERR        (1U<<5)
       
    23 #define HBB_PREFIX_NOFLAG     (1U<<6)
       
    24 #define HBB_PREFIX_HLIGHT_OUT (1U<<7)
       
    25 #define HBB_PREFIX_HLIGHT     (1U<<8)
       
    26 #define HBB_PREFIX_NONE       (1U<<9)
       
    27 #define HBB_PREFIX_SPECIAL    (1U<<10)
       
    28 #define HBB_PREFIX_PGPCRYPT   (1U<<11)
       
    29 #define HBB_PREFIX_OTRCRYPT   (1U<<12)
       
    30 #define HBB_PREFIX_CONT       (1U<<13)
       
    31 #define HBB_PREFIX_RECEIPT    (1U<<14)
       
    32 
       
    33 typedef struct {
       
    34   time_t timestamp;
       
    35   guint flags;
       
    36   unsigned mucnicklen;
       
    37   char *text;
       
    38 } hbb_line;
       
    39 
       
    40 void hbuf_add_line(GList **p_hbuf, const char *text, time_t timestamp,
       
    41         guint prefix_flags, guint width, guint maxhbufblocks,
       
    42         unsigned mucnicklen, gpointer xep184);
       
    43 void hbuf_free(GList **p_hbuf);
       
    44 void hbuf_rebuild(GList **p_hbuf, unsigned int width);
       
    45 GList *hbuf_previous_persistent(GList *l_line);
       
    46 
       
    47 hbb_line **hbuf_get_lines(GList *hbuf, unsigned int n);
       
    48 GList *hbuf_search(GList *hbuf, int direction, const char *string);
       
    49 GList *hbuf_jump_date(GList *hbuf, time_t t);
       
    50 GList *hbuf_jump_percent(GList *hbuf, int pc);
       
    51 gboolean hbuf_remove_receipt(GList *hbuf, gpointer xep184);
       
    52 
       
    53 void hbuf_dump_to_file(GList *hbuf, const char *filename);
       
    54 
       
    55 guint hbuf_get_blocks_number(GList *p_hbuf);
       
    56 
       
    57 #endif /* __HBUF_H__ */
       
    58 
       
    59 /* vim: set expandtab cindent cinoptions=>2\:2(0:  For Vim users... */