2012-07-23 21:31:53 +00:00
|
|
|
/*
|
2021-04-19 01:15:19 +00:00
|
|
|
* Copyright (C) 1984-2021 Mark Nudelman
|
2012-07-23 21:31:53 +00:00
|
|
|
*
|
|
|
|
* You may distribute under the terms of either the GNU General Public
|
|
|
|
* License or the Less License, as specified in the README file.
|
|
|
|
*
|
|
|
|
* For more information, see the README file.
|
|
|
|
*/
|
2000-05-22 09:53:22 +00:00
|
|
|
|
2021-07-18 05:00:54 +00:00
|
|
|
#include "xbuf.h"
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Format of a lesskey file:
|
|
|
|
*
|
2021-04-19 01:15:19 +00:00
|
|
|
* LESSKEY_MAGIC (4 bytes)
|
|
|
|
* sections...
|
|
|
|
* END_LESSKEY_MAGIC (4 bytes)
|
2000-05-22 09:53:22 +00:00
|
|
|
*
|
|
|
|
* Each section is:
|
|
|
|
*
|
2021-04-19 01:15:19 +00:00
|
|
|
* section_MAGIC (1 byte)
|
|
|
|
* section_length (2 bytes)
|
|
|
|
* key table (section_length bytes)
|
2000-05-22 09:53:22 +00:00
|
|
|
*/
|
2021-04-19 01:15:19 +00:00
|
|
|
#define C0_LESSKEY_MAGIC '\0'
|
|
|
|
#define C1_LESSKEY_MAGIC 'M'
|
|
|
|
#define C2_LESSKEY_MAGIC '+'
|
|
|
|
#define C3_LESSKEY_MAGIC 'G'
|
2000-05-22 09:53:22 +00:00
|
|
|
|
2021-04-19 01:15:19 +00:00
|
|
|
#define CMD_SECTION 'c'
|
|
|
|
#define EDIT_SECTION 'e'
|
|
|
|
#define VAR_SECTION 'v'
|
|
|
|
#define END_SECTION 'x'
|
2000-05-22 09:53:22 +00:00
|
|
|
|
2021-04-19 01:15:19 +00:00
|
|
|
#define C0_END_LESSKEY_MAGIC 'E'
|
|
|
|
#define C1_END_LESSKEY_MAGIC 'n'
|
|
|
|
#define C2_END_LESSKEY_MAGIC 'd'
|
2000-05-22 09:53:22 +00:00
|
|
|
|
|
|
|
/* */
|
2021-04-19 01:15:19 +00:00
|
|
|
#define KRADIX 64
|
2021-07-18 05:00:54 +00:00
|
|
|
|
|
|
|
struct lesskey_cmdname
|
|
|
|
{
|
|
|
|
char *cn_name;
|
|
|
|
int cn_action;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lesskey_table
|
|
|
|
{
|
|
|
|
struct lesskey_cmdname *names;
|
|
|
|
struct xbuffer buf;
|
|
|
|
int is_var;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lesskey_tables
|
|
|
|
{
|
|
|
|
struct lesskey_table *currtable;
|
|
|
|
struct lesskey_table cmdtable;
|
|
|
|
struct lesskey_table edittable;
|
|
|
|
struct lesskey_table vartable;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int parse_lesskey(char *infile, struct lesskey_tables *tables);
|