history.cxx File Reference

#include "compat.h"
#include "sys.h"
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <string>
#include <fstream>
#include "histedit.h"

Go to the source code of this file.

Classes

struct  HistoryFcns_t
struct  HEntry_t
struct  History_t

Defines

#define HNEXT(h, ev)   (*(h)->fNext)((h)->fRef, ev)
#define HFIRST(h, ev)   (*(h)->fFirst)((h)->fRef, ev)
#define HPREV(h, ev)   (*(h)->fPrev)((h)->fRef, ev)
#define HLAST(h, ev)   (*(h)->fLast)((h)->fRef, ev)
#define HCURR(h, ev)   (*(h)->fCurr)((h)->fRef, ev)
#define HSET(h, ev, n)   (*(h)->fSet)((h)->fRef, ev, n)
#define HCLEAR(h, ev)   (*(h)->fClear)((h)->fRef, ev)
#define HENTER(h, ev, str)   (*(h)->fEnter)((h)->fRef, ev, str)
#define HADD(h, ev, str)   (*(h)->fAdd)((h)->fRef, ev, str)
#define h_malloc(a)   malloc(a)
#define h_realloc(a, b)   realloc((a), (b))
#define h_free(a)   free(a)
#define history_def_setsize(p, num)   (void) (((History_t*) p)->fMax = (num))
#define history_def_getsize(p)   (((History_t*) p)->fCur)
#define he_strerror(code)   he_errlist[code]
#define he_seterrev(evp, code)
#define _HE_OK   0
#define _HE_UNKNOWN   1
#define _HE_MALLOC_FAILED   2
#define _HE_FIRST_NOTFOUND   3
#define _HE_LAST_NOTFOUND   4
#define _HE_EMPTY_LIST   5
#define _HE_END_REACHED   6
#define _HE_START_REACHED   7
#define _HE_CURR_INVALID   8
#define _HE_NOT_FOUND   9
#define _HE_HIST_READ   10
#define _HE_HIST_WRITE   11
#define _HE_PARAM_MISSING   12
#define _HE_SIZE_NEGATIVE   13
#define _HE_NOT_ALLOWED   14
#define _HE_BAD_PARAM   15

Typedefs

typedef int(*) HistoryGFun_t (ptr_t, HistEvent_t *)
typedef int(*) HistoryEFun_t (ptr_t, HistEvent_t *, const char *)
typedef void(*) HistoryVFun_t (ptr_t, HistEvent_t *)
typedef int(*) HistorySFun_t (ptr_t, HistEvent_t *, const int)

Functions

el_private int history_setsize (HistoryFcns_t *, HistEvent_t *, int)
el_private int history_getsize (HistoryFcns_t *, HistEvent_t *)
el_private int history_set_fun (HistoryFcns_t *, HistoryFcns_t *)
el_private int history_load (HistoryFcns_t *, const char *)
el_private int history_save (HistoryFcns_t *, const char *)
el_private int history_prev_event (HistoryFcns_t *, HistEvent_t *, int)
el_private int history_next_event (HistoryFcns_t *, HistEvent_t *, int)
el_private int history_next_string (HistoryFcns_t *, HistEvent_t *, const char *)
el_private int history_prev_string (HistoryFcns_t *, HistEvent_t *, const char *)
el_private int history_def_first (ptr_t, HistEvent_t *)
el_private int history_def_last (ptr_t, HistEvent_t *)
el_private int history_def_next (ptr_t, HistEvent_t *)
el_private int history_def_prev (ptr_t, HistEvent_t *)
el_private int history_def_curr (ptr_t, HistEvent_t *)
el_private int history_def_set (ptr_t, HistEvent_t *, const int n)
el_private int history_def_enter (ptr_t, HistEvent_t *, const char *)
el_private int history_def_add (ptr_t, HistEvent_t *, const char *)
el_private void history_def_init (ptr_t *, HistEvent_t *, int)
el_private void history_def_clear (ptr_t, HistEvent_t *)
el_private int history_def_insert (History_t *, HistEvent_t *, const char *)
el_private void history_def_delete (History_t *, HistEvent_t *, HEntry_t *)
el_public HistoryFcns_thistory_init (void)
el_public void history_end (HistoryFcns_t *h)
int history (HistoryFcns_t *h, HistEvent_t *ev, int fun,...)

Variables

static const char *const he_errlist []


Define Documentation

#define _HE_BAD_PARAM   15

Definition at line 186 of file history.cxx.

Referenced by history_setsize().

#define _HE_CURR_INVALID   8

Definition at line 179 of file history.cxx.

Referenced by history_def_curr().

#define _HE_EMPTY_LIST   5

Definition at line 176 of file history.cxx.

Referenced by history_def_curr(), history_def_next(), history_def_prev(), and history_def_set().

#define _HE_END_REACHED   6

Definition at line 177 of file history.cxx.

Referenced by history_def_next(), and history_def_prev().

#define _HE_FIRST_NOTFOUND   3

Definition at line 174 of file history.cxx.

Referenced by history_def_first().

#define _HE_HIST_READ   10

Definition at line 181 of file history.cxx.

Referenced by history().

#define _HE_HIST_WRITE   11

Definition at line 182 of file history.cxx.

Referenced by history().

#define _HE_LAST_NOTFOUND   4

Definition at line 175 of file history.cxx.

Referenced by history_def_last().

#define _HE_MALLOC_FAILED   2

Definition at line 173 of file history.cxx.

Referenced by history_def_add(), and history_def_insert().

#define _HE_NOT_ALLOWED   14

Definition at line 185 of file history.cxx.

Referenced by history_getsize(), and history_setsize().

#define _HE_NOT_FOUND   9

Definition at line 180 of file history.cxx.

Referenced by history_def_set(), history_next_event(), history_next_string(), history_prev_event(), and history_prev_string().

#define _HE_OK   0

Definition at line 171 of file history.cxx.

Referenced by history().

#define _HE_PARAM_MISSING   12

Definition at line 183 of file history.cxx.

Referenced by history().

#define _HE_SIZE_NEGATIVE   13

Definition at line 184 of file history.cxx.

Referenced by history_getsize().

#define _HE_START_REACHED   7

Definition at line 178 of file history.cxx.

Referenced by history_def_prev().

#define _HE_UNKNOWN   1

Definition at line 172 of file history.cxx.

Referenced by history().

#define h_free (  )     free(a)

Definition at line 96 of file history.cxx.

Referenced by history_def_add(), and history_def_delete().

#define h_malloc (  )     malloc(a)

Definition at line 94 of file history.cxx.

Referenced by history_def_add(), history_def_init(), history_def_insert(), and history_init().

#define h_realloc ( a,
b   )     realloc((a), (b))

Definition at line 95 of file history.cxx.

#define HADD ( h,
ev,
str   )     (*(h)->fAdd)((h)->fRef, ev, str)

Definition at line 92 of file history.cxx.

Referenced by history().

#define HCLEAR ( h,
ev   )     (*(h)->fClear)((h)->fRef, ev)

Definition at line 90 of file history.cxx.

Referenced by history().

#define HCURR ( h,
ev   )     (*(h)->fCurr)((h)->fRef, ev)

Definition at line 88 of file history.cxx.

Referenced by history(), history_next_event(), history_next_string(), history_prev_event(), and history_prev_string().

#define he_seterrev ( evp,
code   ) 

Value:

{ \
   evp->fNum = code; \
   evp->fStr = he_strerror(code); \
}

Definition at line 146 of file history.cxx.

Referenced by history(), history_def_add(), history_def_curr(), history_def_first(), history_def_insert(), history_def_last(), history_def_next(), history_def_prev(), history_def_set(), history_getsize(), history_next_event(), history_next_string(), history_prev_event(), history_prev_string(), and history_setsize().

#define he_strerror ( code   )     he_errlist[code]

Definition at line 145 of file history.cxx.

#define HENTER ( h,
ev,
str   )     (*(h)->fEnter)((h)->fRef, ev, str)

Definition at line 91 of file history.cxx.

Referenced by history(), and history_load().

#define HFIRST ( h,
ev   )     (*(h)->fFirst)((h)->fRef, ev)

Definition at line 85 of file history.cxx.

Referenced by history(), and history_save().

#define history_def_getsize ( p   )     (((History_t*) p)->fCur)

Definition at line 143 of file history.cxx.

Referenced by history_getsize().

#define history_def_setsize ( p,
num   )     (void) (((History_t*) p)->fMax = (num))

Definition at line 142 of file history.cxx.

Referenced by history_setsize().

#define HLAST ( h,
ev   )     (*(h)->fLast)((h)->fRef, ev)

Definition at line 87 of file history.cxx.

Referenced by history().

#define HNEXT ( h,
ev   )     (*(h)->fNext)((h)->fRef, ev)

Definition at line 84 of file history.cxx.

Referenced by history(), history_next_event(), and history_prev_string().

#define HPREV ( h,
ev   )     (*(h)->fPrev)((h)->fRef, ev)

Definition at line 86 of file history.cxx.

Referenced by history(), history_next_string(), and history_prev_event().

#define HSET ( h,
ev,
n   )     (*(h)->fSet)((h)->fRef, ev, n)

Definition at line 89 of file history.cxx.

Referenced by history().


Typedef Documentation

typedef int(*) HistoryEFun_t(ptr_t, HistEvent_t *, const char *)

Definition at line 67 of file history.cxx.

typedef int(*) HistoryGFun_t(ptr_t, HistEvent_t *)

Definition at line 66 of file history.cxx.

typedef int(*) HistorySFun_t(ptr_t, HistEvent_t *, const int)

Definition at line 69 of file history.cxx.

typedef void(*) HistoryVFun_t(ptr_t, HistEvent_t *)

Definition at line 68 of file history.cxx.


Function Documentation

int history ( HistoryFcns_t h,
HistEvent_t ev,
int  fun,
  ... 
)

Definition at line 716 of file history.cxx.

References _HE_HIST_READ, _HE_HIST_WRITE, _HE_OK, _HE_PARAM_MISSING, _HE_UNKNOWN, HistoryFcns_t::fAdd, HistoryFcns_t::fClear, HistoryFcns_t::fCurr, HistoryFcns_t::fEnter, HistoryFcns_t::fFirst, HistoryFcns_t::fLast, HistoryFcns_t::fNext, HistEvent_t::fNum, HistoryFcns_t::fPrev, HistoryFcns_t::fRef, HistoryFcns_t::fSet, h, H_ADD, H_APPEND, H_CLEAR, H_CURR, H_END, H_ENTER, H_FIRST, H_FUNC, H_GETSIZE, H_LAST, H_LOAD, H_NEXT, H_NEXT_EVENT, H_NEXT_STR, H_PREV, H_PREV_EVENT, H_PREV_STR, H_SAVE, H_SET, H_SETSIZE, HADD, HCLEAR, HCURR, he_seterrev, HENTER, HFIRST, history_end(), history_getsize(), history_load(), history_next_event(), history_next_string(), history_prev_event(), history_prev_string(), history_save(), history_set_fun(), history_setsize(), HLAST, HNEXT, HPREV, HSET, retval, and str.

Referenced by _history_search_gen(), _move_history(), add_history(), clear_history(), history_get(), history_search_pos(), history_set_pos(), history_total_bytes(), read_history(), readline(), rl_initialize(), stifle_history(), unstifle_history(), where_history(), and write_history().

el_private int history_def_add ( ptr_t  ,
HistEvent_t ,
const char *   
)

Definition at line 332 of file history.cxx.

References _HE_MALLOC_FAILED, h, h_free, h_malloc, he_seterrev, history_def_enter(), len, s, size_t, strlcat(), strlcpy(), and void.

Referenced by history_init(), and history_set_fun().

el_private void history_def_clear ( ptr_t  ,
HistEvent_t  
)

Definition at line 451 of file history.cxx.

References h, and history_def_delete().

Referenced by history_end(), history_init(), and history_set_fun().

el_private int history_def_curr ( ptr_t  ,
HistEvent_t  
)

Definition at line 283 of file history.cxx.

References _HE_CURR_INVALID, _HE_EMPTY_LIST, h, and he_seterrev.

Referenced by history_init(), and history_set_fun().

el_private void history_def_delete ( History_t ,
HistEvent_t ,
HEntry_t  
)

Definition at line 362 of file history.cxx.

References h, h_free, and hp.

Referenced by history_def_clear(), and history_def_enter().

el_private int history_def_enter ( ptr_t  ,
HistEvent_t ,
const char *   
)

Definition at line 406 of file history.cxx.

References h, history_def_delete(), and history_def_insert().

Referenced by history_def_add(), history_init(), and history_set_fun().

el_private int history_def_first ( ptr_t  ,
HistEvent_t  
)

Definition at line 192 of file history.cxx.

References _HE_FIRST_NOTFOUND, h, and he_seterrev.

Referenced by history_init(), and history_set_fun().

el_private void history_def_init ( ptr_t ,
HistEvent_t ,
int   
)

Definition at line 430 of file history.cxx.

References h, h_malloc, and NULL.

Referenced by history_init(), and history_set_fun().

el_private int history_def_insert ( History_t ,
HistEvent_t ,
const char *   
)

Definition at line 379 of file history.cxx.

References _HE_MALLOC_FAILED, h, h_malloc, and he_seterrev.

Referenced by history_def_enter().

el_private int history_def_last ( ptr_t  ,
HistEvent_t  
)

Definition at line 212 of file history.cxx.

References _HE_LAST_NOTFOUND, h, and he_seterrev.

Referenced by history_init(), and history_set_fun().

el_private int history_def_next ( ptr_t  ,
HistEvent_t  
)

Definition at line 232 of file history.cxx.

References _HE_EMPTY_LIST, _HE_END_REACHED, h, and he_seterrev.

Referenced by history_end(), history_getsize(), history_init(), history_set_fun(), and history_setsize().

el_private int history_def_prev ( ptr_t  ,
HistEvent_t  
)

Definition at line 257 of file history.cxx.

References _HE_EMPTY_LIST, _HE_END_REACHED, _HE_START_REACHED, h, and he_seterrev.

Referenced by history_init(), and history_set_fun().

el_private int history_def_set ( ptr_t  ,
HistEvent_t ,
const int  n 
)

Definition at line 303 of file history.cxx.

References _HE_EMPTY_LIST, _HE_NOT_FOUND, h, and he_seterrev.

Referenced by history_init(), and history_set_fun().

el_public void history_end ( HistoryFcns_t h  ) 

Definition at line 491 of file history.cxx.

References h, history_def_clear(), and history_def_next().

Referenced by history(), rl_cleanup_after_signal(), and rl_initialize().

el_private int history_getsize ( HistoryFcns_t ,
HistEvent_t  
)

Definition at line 523 of file history.cxx.

References _HE_NOT_ALLOWED, _HE_SIZE_NEGATIVE, HistEvent_t::fNum, h, he_seterrev, history_def_getsize, history_def_next(), and retval.

Referenced by history().

el_public HistoryFcns_t* history_init ( void   ) 

Definition at line 467 of file history.cxx.

References h, h_malloc, history_def_add(), history_def_clear(), history_def_curr(), history_def_enter(), history_def_first(), history_def_init(), history_def_last(), history_def_next(), history_def_prev(), and history_def_set().

Referenced by rl_initialize().

el_private int history_load ( HistoryFcns_t ,
const char *   
)

Definition at line 590 of file history.cxx.

References getline(), h, HENTER, i, and line.

Referenced by history().

el_private int history_next_event ( HistoryFcns_t ,
HistEvent_t ,
int   
)

Definition at line 660 of file history.cxx.

References _HE_NOT_FOUND, HistEvent_t::fNum, h, HCURR, he_seterrev, HNEXT, and retval.

Referenced by history().

el_private int history_next_string ( HistoryFcns_t ,
HistEvent_t ,
const char *   
)

Definition at line 697 of file history.cxx.

References _HE_NOT_FOUND, HistEvent_t::fStr, h, HCURR, he_seterrev, HPREV, len, retval, and size_t.

Referenced by history().

el_private int history_prev_event ( HistoryFcns_t ,
HistEvent_t ,
int   
)

Definition at line 642 of file history.cxx.

References _HE_NOT_FOUND, HistEvent_t::fNum, h, HCURR, he_seterrev, HPREV, and retval.

Referenced by history().

el_private int history_prev_string ( HistoryFcns_t ,
HistEvent_t ,
const char *   
)

Definition at line 678 of file history.cxx.

References _HE_NOT_FOUND, HistEvent_t::fStr, h, HCURR, he_seterrev, HNEXT, len, retval, and size_t.

Referenced by history().

el_private int history_save ( HistoryFcns_t ,
const char *   
)

Definition at line 612 of file history.cxx.

References fchmod(), fclose(), fopen, fp, fprintf(), HistEvent_t::fStr, h, HFIRST, i, NULL, S_IRUSR, S_IWUSR, and void.

Referenced by history().

el_private int history_set_fun ( HistoryFcns_t ,
HistoryFcns_t  
)

Definition at line 545 of file history.cxx.

References h, history_def_add(), history_def_clear(), history_def_curr(), history_def_enter(), history_def_first(), history_def_init(), history_def_last(), history_def_next(), history_def_prev(), history_def_set(), nh, and NULL.

Referenced by history().

el_private int history_setsize ( HistoryFcns_t ,
HistEvent_t ,
int   
)

Definition at line 504 of file history.cxx.

References _HE_BAD_PARAM, _HE_NOT_ALLOWED, h, he_seterrev, history_def_next(), and history_def_setsize.

Referenced by history().


Variable Documentation

const char* const he_errlist[] [static]

Initial value:

 {
   "OK",
   "unknown error",
   "malloc() failed",
   "first event not found",
   "last event not found",
   "empty list",
   "no next event",
   "no previous event",
   "current event is invalid",
   "event not found",
   "can't read history from file",
   "can't write history",
   "required parameter(s) not supplied",
   "history size negative",
   "function not allowed with other history-functions-set the default",
   "bad parameters"
}

Definition at line 152 of file history.cxx.


Generated on Tue Jul 5 15:57:24 2011 for ROOT_528-00b_version by  doxygen 1.5.1