xref: /netbsd-src/external/bsd/less/dist/lesskey.h (revision 838f5788460f0f133b15d706e644d692a9d4d6ec)
1*838f5788Ssimonb /*	$NetBSD: lesskey.h,v 1.4 2023/10/06 05:49:49 simonb Exp $	*/
220006a0bStron 
320006a0bStron /*
4*838f5788Ssimonb  * Copyright (C) 1984-2023  Mark Nudelman
520006a0bStron  *
620006a0bStron  * You may distribute under the terms of either the GNU General Public
720006a0bStron  * License or the Less License, as specified in the README file.
820006a0bStron  *
9ec18bca0Stron  * For more information, see the README file.
1020006a0bStron  */
1120006a0bStron 
12*838f5788Ssimonb #include "xbuf.h"
1320006a0bStron 
1420006a0bStron /*
1520006a0bStron  * Format of a lesskey file:
1620006a0bStron  *
1720006a0bStron  *      LESSKEY_MAGIC (4 bytes)
1820006a0bStron  *       sections...
1920006a0bStron  *      END_LESSKEY_MAGIC (4 bytes)
2020006a0bStron  *
2120006a0bStron  * Each section is:
2220006a0bStron  *
2320006a0bStron  *      section_MAGIC (1 byte)
2420006a0bStron  *      section_length (2 bytes)
2520006a0bStron  *      key table (section_length bytes)
2620006a0bStron  */
2720006a0bStron #define C0_LESSKEY_MAGIC        '\0'
2820006a0bStron #define C1_LESSKEY_MAGIC        'M'
2920006a0bStron #define C2_LESSKEY_MAGIC        '+'
3020006a0bStron #define C3_LESSKEY_MAGIC        'G'
3120006a0bStron 
3220006a0bStron #define CMD_SECTION             'c'
3320006a0bStron #define EDIT_SECTION            'e'
3420006a0bStron #define VAR_SECTION             'v'
3520006a0bStron #define END_SECTION             'x'
3620006a0bStron 
3720006a0bStron #define C0_END_LESSKEY_MAGIC    'E'
3820006a0bStron #define C1_END_LESSKEY_MAGIC    'n'
3920006a0bStron #define C2_END_LESSKEY_MAGIC    'd'
4020006a0bStron 
4120006a0bStron /* */
4220006a0bStron #define KRADIX          64
43*838f5788Ssimonb 
44*838f5788Ssimonb struct lesskey_cmdname
45*838f5788Ssimonb {
46*838f5788Ssimonb 	char *cn_name;
47*838f5788Ssimonb 	int cn_action;
48*838f5788Ssimonb };
49*838f5788Ssimonb 
50*838f5788Ssimonb struct lesskey_table
51*838f5788Ssimonb {
52*838f5788Ssimonb 	struct lesskey_cmdname *names;
53*838f5788Ssimonb 	struct xbuffer buf;
54*838f5788Ssimonb 	int is_var;
55*838f5788Ssimonb };
56*838f5788Ssimonb 
57*838f5788Ssimonb struct lesskey_tables
58*838f5788Ssimonb {
59*838f5788Ssimonb 	struct lesskey_table *currtable;
60*838f5788Ssimonb 	struct lesskey_table cmdtable;
61*838f5788Ssimonb 	struct lesskey_table edittable;
62*838f5788Ssimonb 	struct lesskey_table vartable;
63*838f5788Ssimonb };
64*838f5788Ssimonb 
65*838f5788Ssimonb extern int parse_lesskey(char *infile, struct lesskey_tables *tables);
66