1171bb95eSnicm /* 2171bb95eSnicm * Copyright 2014 Garrett D'Amore <garrett@damore.org> 3171bb95eSnicm * 4171bb95eSnicm * This file is made available under the terms of the Less License. 5171bb95eSnicm */ 6171bb95eSnicm 7171bb95eSnicm #include <regex.h> 8171bb95eSnicm 9171bb95eSnicm struct mlist; 10171bb95eSnicm struct loption; 11171bb95eSnicm 12532ff29fSmmcc void *ecalloc(int, unsigned int); 13532ff29fSmmcc char *easprintf(const char *, ...); 14532ff29fSmmcc char *estrdup(const char *); 15532ff29fSmmcc char *skipsp(char *); 16532ff29fSmmcc int sprefix(char *, char *, int); 17532ff29fSmmcc void quit(int); 18532ff29fSmmcc void raw_mode(int); 19532ff29fSmmcc char *special_key_str(int); 20532ff29fSmmcc void get_term(void); 21532ff29fSmmcc void init(void); 22532ff29fSmmcc void deinit(void); 23532ff29fSmmcc void home(void); 24532ff29fSmmcc void add_line(void); 25532ff29fSmmcc void lower_left(void); 26532ff29fSmmcc void line_left(void); 27532ff29fSmmcc void goto_line(int); 28532ff29fSmmcc void vbell(void); 29532ff29fSmmcc void ring_bell(void); 30532ff29fSmmcc void do_clear(void); 31532ff29fSmmcc void clear_eol(void); 32532ff29fSmmcc void clear_bot(void); 33532ff29fSmmcc void at_enter(int); 34532ff29fSmmcc void at_exit(void); 35532ff29fSmmcc void at_switch(int); 36532ff29fSmmcc int is_at_equiv(int, int); 37532ff29fSmmcc int apply_at_specials(int); 38532ff29fSmmcc void putbs(void); 39532ff29fSmmcc void match_brac(int, int, int, int); 40532ff29fSmmcc int ch_get(void); 41532ff29fSmmcc void ch_ungetchar(int); 42532ff29fSmmcc void end_logfile(void); 43532ff29fSmmcc void sync_logfile(void); 44532ff29fSmmcc int ch_seek(off_t); 45532ff29fSmmcc int ch_end_seek(void); 46532ff29fSmmcc int ch_beg_seek(void); 47532ff29fSmmcc off_t ch_length(void); 48532ff29fSmmcc off_t ch_tell(void); 49532ff29fSmmcc int ch_forw_get(void); 50532ff29fSmmcc int ch_back_get(void); 51532ff29fSmmcc void ch_setbufspace(int); 52532ff29fSmmcc void ch_flush(void); 53532ff29fSmmcc int seekable(int); 54532ff29fSmmcc void ch_set_eof(void); 55532ff29fSmmcc void ch_init(int, int); 56532ff29fSmmcc void ch_close(void); 57532ff29fSmmcc int ch_getflags(void); 58*323f1f59Sschwarze int mbtowc_left(wchar_t *, const char *, size_t); 59532ff29fSmmcc void init_charset(void); 60532ff29fSmmcc char *prchar(LWCHAR); 61532ff29fSmmcc char *prutfchar(LWCHAR); 62532ff29fSmmcc int utf_len(char); 63532ff29fSmmcc int is_utf8_well_formed(const char *); 64532ff29fSmmcc LWCHAR step_char(char **, int, char *); 65532ff29fSmmcc int is_composing_char(LWCHAR); 66532ff29fSmmcc int is_ubin_char(LWCHAR); 67532ff29fSmmcc int is_wide_char(LWCHAR); 68532ff29fSmmcc void cmd_reset(void); 69532ff29fSmmcc void clear_cmd(void); 70532ff29fSmmcc void cmd_putstr(char *); 71532ff29fSmmcc int len_cmdbuf(void); 72532ff29fSmmcc void set_mlist(void *, int); 73532ff29fSmmcc void cmd_addhist(struct mlist *, const char *); 74532ff29fSmmcc void cmd_accept(void); 75532ff29fSmmcc int cmd_char(int); 76532ff29fSmmcc off_t cmd_int(long *); 77532ff29fSmmcc char *get_cmdbuf(void); 78532ff29fSmmcc char *cmd_lastpattern(void); 79532ff29fSmmcc void init_cmdhist(void); 80532ff29fSmmcc void save_cmdhist(void); 81532ff29fSmmcc int in_mca(void); 82532ff29fSmmcc void dispversion(void); 83532ff29fSmmcc int getcc(void); 84532ff29fSmmcc void ungetcc(int); 85532ff29fSmmcc void ungetsc(char *); 86532ff29fSmmcc void commands(void); 87532ff29fSmmcc int cvt_length(int); 88532ff29fSmmcc int *cvt_alloc_chpos(int); 89532ff29fSmmcc void cvt_text(char *, char *, int *, int *, int); 90532ff29fSmmcc void init_cmds(void); 91532ff29fSmmcc void add_fcmd_table(char *, int); 92532ff29fSmmcc void add_ecmd_table(char *, int); 93532ff29fSmmcc int fcmd_decode(const char *, char **); 94532ff29fSmmcc int ecmd_decode(const char *, char **); 95532ff29fSmmcc char *lgetenv(char *); 96532ff29fSmmcc int lesskey(char *, int); 97532ff29fSmmcc void add_hometable(char *, char *, int); 98532ff29fSmmcc int editchar(int, int); 99532ff29fSmmcc void init_textlist(struct textlist *, char *); 100532ff29fSmmcc char *forw_textlist(struct textlist *, char *); 101532ff29fSmmcc char *back_textlist(struct textlist *, char *); 102532ff29fSmmcc int edit(char *); 103532ff29fSmmcc int edit_ifile(IFILE); 104532ff29fSmmcc int edit_list(char *); 105532ff29fSmmcc int edit_first(void); 106532ff29fSmmcc int edit_last(void); 107532ff29fSmmcc int edit_next(int); 108532ff29fSmmcc int edit_prev(int); 109532ff29fSmmcc int edit_index(int); 110532ff29fSmmcc IFILE save_curr_ifile(void); 111532ff29fSmmcc void unsave_ifile(IFILE); 112532ff29fSmmcc void reedit_ifile(IFILE); 113532ff29fSmmcc void reopen_curr_ifile(void); 114532ff29fSmmcc int edit_stdin(void); 115532ff29fSmmcc void cat_file(void); 116532ff29fSmmcc void use_logfile(char *); 117532ff29fSmmcc char *shell_unquote(char *); 118532ff29fSmmcc char *get_meta_escape(void); 119532ff29fSmmcc char *shell_quote(const char *); 120532ff29fSmmcc char *homefile(char *); 121532ff29fSmmcc char *fexpand(char *); 122532ff29fSmmcc char *fcomplete(char *); 123532ff29fSmmcc int bin_file(int f); 124532ff29fSmmcc char *lglob(char *); 125532ff29fSmmcc int is_dir(char *); 126532ff29fSmmcc char *bad_file(char *); 127532ff29fSmmcc off_t filesize(int); 128532ff29fSmmcc char *last_component(char *); 129532ff29fSmmcc int eof_displayed(void); 130532ff29fSmmcc int entire_file_displayed(void); 131532ff29fSmmcc void squish_check(void); 132532ff29fSmmcc void forw(int, off_t, int, int, int); 133532ff29fSmmcc void back(int, off_t, int, int); 134532ff29fSmmcc void forward(int, int, int); 135532ff29fSmmcc void backward(int, int, int); 136532ff29fSmmcc int get_back_scroll(void); 137532ff29fSmmcc void del_ifile(IFILE); 138532ff29fSmmcc IFILE next_ifile(IFILE); 139532ff29fSmmcc IFILE prev_ifile(IFILE); 140532ff29fSmmcc IFILE getoff_ifile(IFILE); 141532ff29fSmmcc int nifile(void); 142532ff29fSmmcc IFILE get_ifile(char *, IFILE); 143532ff29fSmmcc char *get_filename(IFILE); 144532ff29fSmmcc int get_index(IFILE); 145532ff29fSmmcc void store_pos(IFILE, struct scrpos *); 146532ff29fSmmcc void get_pos(IFILE, struct scrpos *); 147532ff29fSmmcc int opened(IFILE); 148532ff29fSmmcc void hold_ifile(IFILE, int); 149532ff29fSmmcc int held_ifile(IFILE); 150532ff29fSmmcc void set_open(IFILE); 151532ff29fSmmcc void *get_filestate(IFILE); 152532ff29fSmmcc void set_filestate(IFILE, void *); 153532ff29fSmmcc off_t forw_line(off_t); 154532ff29fSmmcc off_t back_line(off_t); 155532ff29fSmmcc void set_attnpos(off_t); 156532ff29fSmmcc void jump_forw(void); 157532ff29fSmmcc void jump_back(off_t); 158532ff29fSmmcc void repaint(void); 159532ff29fSmmcc void jump_percent(int, long); 160532ff29fSmmcc void jump_line_loc(off_t, int); 161532ff29fSmmcc void jump_loc(off_t, int); 162532ff29fSmmcc void init_line(void); 163532ff29fSmmcc void prewind(void); 164532ff29fSmmcc void plinenum(off_t); 165532ff29fSmmcc void pshift_all(void); 166532ff29fSmmcc int is_ansi_middle(LWCHAR); 167532ff29fSmmcc int pappend(char, off_t); 168532ff29fSmmcc int pflushmbc(void); 169532ff29fSmmcc void pdone(int, int); 170532ff29fSmmcc void set_status_col(char); 171532ff29fSmmcc int gline(int, int *); 172532ff29fSmmcc void null_line(void); 173532ff29fSmmcc off_t forw_raw_line(off_t, char **, int *); 174532ff29fSmmcc off_t back_raw_line(off_t, char **, int *); 175532ff29fSmmcc void clr_linenum(void); 176532ff29fSmmcc void add_lnum(off_t, off_t); 177532ff29fSmmcc off_t find_linenum(off_t); 178532ff29fSmmcc off_t find_pos(off_t); 179532ff29fSmmcc off_t currline(int); 180532ff29fSmmcc void lsystem(const char *, const char *); 181532ff29fSmmcc int pipe_mark(int, char *); 182532ff29fSmmcc void init_mark(void); 183532ff29fSmmcc int badmark(int); 184532ff29fSmmcc void setmark(int); 185532ff29fSmmcc void lastmark(void); 186532ff29fSmmcc void gomark(int); 187532ff29fSmmcc off_t markpos(int); 188532ff29fSmmcc void unmark(IFILE); 189532ff29fSmmcc void opt_o(int, char *); 190532ff29fSmmcc void opt__O(int, char *); 191532ff29fSmmcc void opt_j(int, char *); 192532ff29fSmmcc void calc_jump_sline(void); 193532ff29fSmmcc void opt_shift(int, char *); 194532ff29fSmmcc void calc_shift_count(void); 195532ff29fSmmcc void opt_k(int, char *); 196532ff29fSmmcc void opt_t(int, char *); 197532ff29fSmmcc void opt__T(int, char *); 198532ff29fSmmcc void opt_p(int, char *); 199532ff29fSmmcc void opt__P(int, char *); 200532ff29fSmmcc void opt_b(int, char *); 201532ff29fSmmcc void opt_i(int, char *); 202532ff29fSmmcc void opt__V(int, char *); 203532ff29fSmmcc void opt_x(int, char *); 204532ff29fSmmcc void opt_quote(int, char *); 205532ff29fSmmcc void opt_query(int, char *); 206532ff29fSmmcc int get_swindow(void); 207532ff29fSmmcc char *propt(int); 208745ece38Skrw void scan_option(char *, int); 209532ff29fSmmcc void toggle_option(struct loption *, int, char *, int); 210532ff29fSmmcc int opt_has_param(struct loption *); 211532ff29fSmmcc char *opt_prompt(struct loption *); 212532ff29fSmmcc int isoptpending(void); 213532ff29fSmmcc void nopendopt(void); 214532ff29fSmmcc int getnum(char **, char *, int *); 215532ff29fSmmcc long getfraction(char **, char *, int *); 216532ff29fSmmcc int get_quit_at_eof(void); 217532ff29fSmmcc void init_option(void); 218532ff29fSmmcc struct loption *findopt(int); 219532ff29fSmmcc struct loption *findopt_name(char **, char **, int *); 220532ff29fSmmcc int iread(int, unsigned char *, unsigned int); 221532ff29fSmmcc char *errno_message(char *); 222532ff29fSmmcc int percentage(off_t, off_t); 223532ff29fSmmcc off_t percent_pos(off_t, int, long); 224532ff29fSmmcc void put_line(void); 225532ff29fSmmcc void flush(int); 226532ff29fSmmcc int putchr(int); 227532ff29fSmmcc void putstr(const char *); 228532ff29fSmmcc void get_return(void); 229532ff29fSmmcc void error(const char *, PARG *); 230532ff29fSmmcc void ierror(const char *, PARG *); 231532ff29fSmmcc int query(const char *, PARG *); 232532ff29fSmmcc int compile_pattern(char *, int, regex_t **); 233532ff29fSmmcc void uncompile_pattern(regex_t **); 234532ff29fSmmcc int match_pattern(void *, char *, char *, int, char **, char **, 235171bb95eSnicm int, int); 236532ff29fSmmcc off_t position(int); 237532ff29fSmmcc void add_forw_pos(off_t); 238532ff29fSmmcc void add_back_pos(off_t); 239532ff29fSmmcc void pos_clear(void); 240532ff29fSmmcc void pos_init(void); 241532ff29fSmmcc int onscreen(off_t); 242532ff29fSmmcc int empty_screen(void); 243532ff29fSmmcc int empty_lines(int, int); 244532ff29fSmmcc void get_scrpos(struct scrpos *); 245532ff29fSmmcc int adjsline(int); 246532ff29fSmmcc void init_prompt(void); 247532ff29fSmmcc char *pr_expand(const char *, int); 248532ff29fSmmcc char *eq_message(void); 249532ff29fSmmcc char *prompt_string(void); 250532ff29fSmmcc char *wait_message(void); 251532ff29fSmmcc void init_search(void); 252532ff29fSmmcc void repaint_hilite(int); 253532ff29fSmmcc void clear_attn(void); 254532ff29fSmmcc void undo_search(void); 255532ff29fSmmcc void clr_hilite(void); 256532ff29fSmmcc int is_filtered(off_t); 257532ff29fSmmcc int is_hilited(off_t, off_t, int, int *); 258532ff29fSmmcc void chg_caseless(void); 259532ff29fSmmcc void chg_hilite(void); 260532ff29fSmmcc int search(int, char *, int); 261532ff29fSmmcc void prep_hilite(off_t, off_t, int); 262532ff29fSmmcc void set_filter_pattern(char *, int); 263532ff29fSmmcc int is_filtering(void); 264532ff29fSmmcc void sigwinch(int); 265532ff29fSmmcc void init_signals(int); 266532ff29fSmmcc void psignals(void); 267532ff29fSmmcc void cleantags(void); 268532ff29fSmmcc void findtag(char *); 269532ff29fSmmcc off_t tagsearch(void); 270532ff29fSmmcc char *nexttag(int); 271532ff29fSmmcc char *prevtag(int); 272532ff29fSmmcc int ntags(void); 273532ff29fSmmcc int curr_tag(void); 274532ff29fSmmcc int edit_tagfile(void); 275532ff29fSmmcc void open_getchr(void); 276532ff29fSmmcc int getchr(void); 277532ff29fSmmcc void *lsignal(int, void (*)(int)); 278532ff29fSmmcc char *helpfile(void); 279