/* $NetBSD: hist.h,v 1.23 2017/09/01 10:19:10 christos Exp $ */12/*-3* Copyright (c) 1992, 19934* The Regents of the University of California. All rights reserved.5*6* This code is derived from software contributed to Berkeley by7* Christos Zoulas of Cornell University.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions and the following disclaimer.14* 2. Redistributions in binary form must reproduce the above copyright15* notice, this list of conditions and the following disclaimer in the16* documentation and/or other materials provided with the distribution.17* 3. Neither the name of the University nor the names of its contributors18* may be used to endorse or promote products derived from this software19* without specific prior written permission.20*21* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND22* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE25* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31* SUCH DAMAGE.32*33* @(#)hist.h 8.1 (Berkeley) 6/4/9334*/3536/*37* el.hist.c: History functions38*/39#ifndef _h_el_hist40#define _h_el_hist4142typedef int (*hist_fun_t)(void *, HistEventW *, int, ...);4344typedef struct el_history_t {45wchar_t *buf; /* The history buffer */46size_t sz; /* Size of history buffer */47wchar_t *last; /* The last character */48int eventno; /* Event we are looking for */49void *ref; /* Argument for history fcns */50hist_fun_t fun; /* Event access */51HistEventW ev; /* Event cookie */52} el_history_t;5354#define HIST_FUN_INTERNAL(el, fn, arg) \55((((*(el)->el_history.fun) ((el)->el_history.ref, &(el)->el_history.ev, \56fn, arg)) == -1) ? NULL : (el)->el_history.ev.str)57#define HIST_FUN(el, fn, arg) \58(((el)->el_flags & NARROW_HISTORY) ? hist_convert(el, fn, arg) : \59HIST_FUN_INTERNAL(el, fn, arg))6061#define HIST_NEXT(el) HIST_FUN(el, H_NEXT, NULL)62#define HIST_FIRST(el) HIST_FUN(el, H_FIRST, NULL)63#define HIST_LAST(el) HIST_FUN(el, H_LAST, NULL)64#define HIST_PREV(el) HIST_FUN(el, H_PREV, NULL)65#define HIST_SET(el, num) HIST_FUN(el, H_SET, num)66#define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname)67#define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname)68#define HIST_SAVE_FP(el, fp) HIST_FUN(el, H_SAVE_FP, fp)69#define HIST_NSAVE_FP(el, n, fp) HIST_FUN(el, H_NSAVE_FP, n, fp)7071libedit_private int hist_init(EditLine *);72libedit_private void hist_end(EditLine *);73libedit_private el_action_t hist_get(EditLine *);74libedit_private int hist_set(EditLine *, hist_fun_t, void *);75libedit_private int hist_command(EditLine *, int, const wchar_t **);76libedit_private int hist_enlargebuf(EditLine *, size_t, size_t);77libedit_private wchar_t *hist_convert(EditLine *, int, void *);7879#endif /* _h_el_hist */808182