xref: /onnv-gate/usr/src/cmd/format/io.h (revision 7563:84ec90ffc3f7)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7563SPrasad.Singamsetty@Sun.COM  * Common Development and Distribution License (the "License").
6*7563SPrasad.Singamsetty@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*7563SPrasad.Singamsetty@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_IO_H
270Sstevel@tonic-gate #define	_IO_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #ifdef	__cplusplus
300Sstevel@tonic-gate extern "C" {
310Sstevel@tonic-gate #endif
320Sstevel@tonic-gate 
330Sstevel@tonic-gate 
340Sstevel@tonic-gate /*
350Sstevel@tonic-gate  * Bounds structure for integer and disk input.
360Sstevel@tonic-gate  */
370Sstevel@tonic-gate struct bounds {
380Sstevel@tonic-gate 	diskaddr_t	lower;
390Sstevel@tonic-gate 	diskaddr_t	upper;
400Sstevel@tonic-gate };
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * List of strings with arbitrary matching values
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate typedef struct slist {
460Sstevel@tonic-gate 	char	*str;
470Sstevel@tonic-gate 	char	*help;
480Sstevel@tonic-gate 	int	value;
490Sstevel@tonic-gate } slist_t;
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  * Input structure for current partition information
530Sstevel@tonic-gate  */
540Sstevel@tonic-gate typedef struct partition_defaults {
55*7563SPrasad.Singamsetty@Sun.COM 	uint_t start_cyl;
56*7563SPrasad.Singamsetty@Sun.COM 	uint_t deflt_size;
570Sstevel@tonic-gate } part_deflt_t;
580Sstevel@tonic-gate 
590Sstevel@tonic-gate typedef struct efi_defaults {
600Sstevel@tonic-gate 	uint64_t	start_sector;
610Sstevel@tonic-gate 	uint64_t	end_sector;
620Sstevel@tonic-gate } efi_deflt_t;
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /*
650Sstevel@tonic-gate  * Input parameter can be any one of these types.
660Sstevel@tonic-gate  */
670Sstevel@tonic-gate typedef union input_param {
680Sstevel@tonic-gate 	struct slist	*io_slist;
690Sstevel@tonic-gate 	char		**io_charlist;
700Sstevel@tonic-gate 	struct bounds	io_bounds;
710Sstevel@tonic-gate } u_ioparam_t;
720Sstevel@tonic-gate 
730Sstevel@tonic-gate /*
740Sstevel@tonic-gate  * These declarations define the legal input types.
750Sstevel@tonic-gate  */
760Sstevel@tonic-gate #define	FIO_BN		0		/* block number */
770Sstevel@tonic-gate #define	FIO_INT		1		/* integer input */
780Sstevel@tonic-gate #define	FIO_CSTR	2		/* closed string - exact match */
790Sstevel@tonic-gate #define	FIO_MSTR	3		/* matched string, with abbreviations */
800Sstevel@tonic-gate #define	FIO_OSTR	4		/* open string - anything's legal */
810Sstevel@tonic-gate #define	FIO_BLNK	5		/* blank line */
820Sstevel@tonic-gate #define	FIO_SLIST	6		/* one string out of a list, abbr. */
830Sstevel@tonic-gate #define	FIO_CYL		7		/* nblocks, on cylinder boundary */
840Sstevel@tonic-gate #define	FIO_OPINT	8		/* optional integer input */
850Sstevel@tonic-gate #define	FIO_ECYL	9		/* allows end cylinder input */
860Sstevel@tonic-gate #define	FIO_INT64	10		/* Input for EFI partitions */
870Sstevel@tonic-gate #define	FIO_EFI		11		/* Input EFI part size	*/
880Sstevel@tonic-gate 
890Sstevel@tonic-gate /*
900Sstevel@tonic-gate  * Miscellaneous definitions.
910Sstevel@tonic-gate  */
920Sstevel@tonic-gate #define	TOKEN_SIZE	36			/* max length of a token */
930Sstevel@tonic-gate typedef	char TOKEN[TOKEN_SIZE+1];		/* token type */
940Sstevel@tonic-gate #define	DATA_INPUT	0			/* 2 modes of input */
950Sstevel@tonic-gate #define	CMD_INPUT	1
960Sstevel@tonic-gate #define	WILD_STRING	"$"			/* wildcard character */
970Sstevel@tonic-gate #define	COMMENT_CHAR	'#'			/* comment character */
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate /*
1010Sstevel@tonic-gate  *	Prototypes for ANSI C
1020Sstevel@tonic-gate  */
1030Sstevel@tonic-gate char	*gettoken(char *inbuf);
1040Sstevel@tonic-gate void	clean_token(char *cleantoken, char *token);
1050Sstevel@tonic-gate int	geti(char *str, int *iptr, int *wild);
1060Sstevel@tonic-gate uint64_t	input(int, char *, int, u_ioparam_t *, int *, int);
1070Sstevel@tonic-gate int	find_value(slist_t *slist, char *match_str, int *match_value);
1080Sstevel@tonic-gate char	*find_string(slist_t *slist, int match_value);
1090Sstevel@tonic-gate void	fmt_print(char *format, ...);
1100Sstevel@tonic-gate void	nolog_print(char *format, ...);
1110Sstevel@tonic-gate void	log_print(char *format, ...);
1120Sstevel@tonic-gate void	err_print(char *format, ...);
1130Sstevel@tonic-gate void	print_buf(char *buf, int nbytes);
1140Sstevel@tonic-gate void	pr_diskline(struct disk_info *disk, int num);
1150Sstevel@tonic-gate void	pr_dblock(void (*func)(char *, ...), diskaddr_t bn);
1160Sstevel@tonic-gate int	sup_gettoken(char *buf);
1170Sstevel@tonic-gate void	sup_pushtoken(char *token_buf, int token_type);
1180Sstevel@tonic-gate void	get_inputline(char *, int);
1190Sstevel@tonic-gate int	istokenpresent(void);
1201383Spr131582 int	execute_shell(char *, size_t);
1210Sstevel@tonic-gate void	print_efi_string(char *vendor, char *product, char *revision,
1220Sstevel@tonic-gate     uint64_t capacity);
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate  * Most recent token type
1260Sstevel@tonic-gate  */
1270Sstevel@tonic-gate extern	int	last_token_type;
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate #ifdef	__cplusplus
1300Sstevel@tonic-gate }
1310Sstevel@tonic-gate #endif
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate #endif	/* _IO_H */
134