option.h revision 1.3
1/* $NetBSD: option.h,v 1.3 2011/07/03 20:14:13 tron Exp $ */ 2 3/* 4 * Copyright (C) 1984-2011 Mark Nudelman 5 * 6 * You may distribute under the terms of either the GNU General Public 7 * License or the Less License, as specified in the README file. 8 * 9 * For more information about less, or for information on how to 10 * contact the author, see the README file. 11 */ 12 13 14#define END_OPTION_STRING ('$') 15 16/* 17 * Types of options. 18 */ 19#define BOOL 01 /* Boolean option: 0 or 1 */ 20#define TRIPLE 02 /* Triple-valued option: 0, 1 or 2 */ 21#define NUMBER 04 /* Numeric option */ 22#define STRING 010 /* String-valued option */ 23#define NOVAR 020 /* No associated variable */ 24#define REPAINT 040 /* Repaint screen after toggling option */ 25#define NO_TOGGLE 0100 /* Option cannot be toggled with "-" cmd */ 26#define HL_REPAINT 0200 /* Repaint hilites after toggling option */ 27#define NO_QUERY 0400 /* Option cannot be queried with "_" cmd */ 28#define INIT_HANDLER 01000 /* Call option handler function at startup */ 29 30#define OTYPE (BOOL|TRIPLE|NUMBER|STRING|NOVAR) 31 32#define OLETTER_NONE '\1' /* Invalid option letter */ 33 34/* 35 * Argument to a handling function tells what type of activity: 36 */ 37#define INIT 0 /* Initialization (from command line) */ 38#define QUERY 1 /* Query (from _ or - command) */ 39#define TOGGLE 2 /* Change value (from - command) */ 40 41/* Flag to toggle_option to specify how to "toggle" */ 42#define OPT_NO_TOGGLE 0 43#define OPT_TOGGLE 1 44#define OPT_UNSET 2 45#define OPT_SET 3 46#define OPT_NO_PROMPT 0100 47 48/* Error code from findopt_name */ 49#define OPT_AMBIG 1 50 51struct optname 52{ 53 char *oname; /* Long (GNU-style) option name */ 54 struct optname *onext; /* List of synonymous option names */ 55}; 56 57#define OPTNAME_MAX 32 /* Max length of long option name */ 58 59struct loption 60{ 61 char oletter; /* The controlling letter (a-z) */ 62 struct optname *onames; /* Long (GNU-style) option name */ 63 int otype; /* Type of the option */ 64 int odefault; /* Default value */ 65 int *ovar; /* Pointer to the associated variable */ 66 void (*ofunc) /* Pointer to special handling function */ 67 __P((int, char *)); 68 char *odesc[3]; /* Description of each value */ 69}; 70 71