xref: /titanic_53/usr/src/cmd/format/io.h (revision f1c6055664f25a6d7ed49ff77e06f939954a8e48)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*f1c60556Spr131582  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_IO_H
287c478bd9Sstevel@tonic-gate #define	_IO_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * Bounds structure for integer and disk input.
397c478bd9Sstevel@tonic-gate  */
407c478bd9Sstevel@tonic-gate struct bounds {
417c478bd9Sstevel@tonic-gate 	diskaddr_t	lower;
427c478bd9Sstevel@tonic-gate 	diskaddr_t	upper;
437c478bd9Sstevel@tonic-gate };
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * List of strings with arbitrary matching values
477c478bd9Sstevel@tonic-gate  */
487c478bd9Sstevel@tonic-gate typedef struct slist {
497c478bd9Sstevel@tonic-gate 	char	*str;
507c478bd9Sstevel@tonic-gate 	char	*help;
517c478bd9Sstevel@tonic-gate 	int	value;
527c478bd9Sstevel@tonic-gate } slist_t;
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /*
557c478bd9Sstevel@tonic-gate  * Input structure for current partition information
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate typedef struct partition_defaults {
587c478bd9Sstevel@tonic-gate 	int start_cyl;
597c478bd9Sstevel@tonic-gate 	int deflt_size;
607c478bd9Sstevel@tonic-gate } part_deflt_t;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate typedef struct efi_defaults {
637c478bd9Sstevel@tonic-gate 	uint64_t	start_sector;
647c478bd9Sstevel@tonic-gate 	uint64_t	end_sector;
657c478bd9Sstevel@tonic-gate } efi_deflt_t;
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * Input parameter can be any one of these types.
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate typedef union input_param {
717c478bd9Sstevel@tonic-gate 	struct slist	*io_slist;
727c478bd9Sstevel@tonic-gate 	char		**io_charlist;
737c478bd9Sstevel@tonic-gate 	struct bounds	io_bounds;
747c478bd9Sstevel@tonic-gate } u_ioparam_t;
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate  * These declarations define the legal input types.
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate #define	FIO_BN		0		/* block number */
807c478bd9Sstevel@tonic-gate #define	FIO_INT		1		/* integer input */
817c478bd9Sstevel@tonic-gate #define	FIO_CSTR	2		/* closed string - exact match */
827c478bd9Sstevel@tonic-gate #define	FIO_MSTR	3		/* matched string, with abbreviations */
837c478bd9Sstevel@tonic-gate #define	FIO_OSTR	4		/* open string - anything's legal */
847c478bd9Sstevel@tonic-gate #define	FIO_BLNK	5		/* blank line */
857c478bd9Sstevel@tonic-gate #define	FIO_SLIST	6		/* one string out of a list, abbr. */
867c478bd9Sstevel@tonic-gate #define	FIO_CYL		7		/* nblocks, on cylinder boundary */
877c478bd9Sstevel@tonic-gate #define	FIO_OPINT	8		/* optional integer input */
887c478bd9Sstevel@tonic-gate #define	FIO_ECYL	9		/* allows end cylinder input */
897c478bd9Sstevel@tonic-gate #define	FIO_INT64	10		/* Input for EFI partitions */
907c478bd9Sstevel@tonic-gate #define	FIO_EFI		11		/* Input EFI part size	*/
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  * Miscellaneous definitions.
947c478bd9Sstevel@tonic-gate  */
957c478bd9Sstevel@tonic-gate #define	TOKEN_SIZE	36			/* max length of a token */
967c478bd9Sstevel@tonic-gate typedef	char TOKEN[TOKEN_SIZE+1];		/* token type */
977c478bd9Sstevel@tonic-gate #define	DATA_INPUT	0			/* 2 modes of input */
987c478bd9Sstevel@tonic-gate #define	CMD_INPUT	1
997c478bd9Sstevel@tonic-gate #define	WILD_STRING	"$"			/* wildcard character */
1007c478bd9Sstevel@tonic-gate #define	COMMENT_CHAR	'#'			/* comment character */
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /*
1047c478bd9Sstevel@tonic-gate  *	Prototypes for ANSI C
1057c478bd9Sstevel@tonic-gate  */
1067c478bd9Sstevel@tonic-gate char	*gettoken(char *inbuf);
1077c478bd9Sstevel@tonic-gate void	clean_token(char *cleantoken, char *token);
1087c478bd9Sstevel@tonic-gate int	geti(char *str, int *iptr, int *wild);
1097c478bd9Sstevel@tonic-gate uint64_t	input(int, char *, int, u_ioparam_t *, int *, int);
1107c478bd9Sstevel@tonic-gate int	find_value(slist_t *slist, char *match_str, int *match_value);
1117c478bd9Sstevel@tonic-gate char	*find_string(slist_t *slist, int match_value);
1127c478bd9Sstevel@tonic-gate void	fmt_print(char *format, ...);
1137c478bd9Sstevel@tonic-gate void	nolog_print(char *format, ...);
1147c478bd9Sstevel@tonic-gate void	log_print(char *format, ...);
1157c478bd9Sstevel@tonic-gate void	err_print(char *format, ...);
1167c478bd9Sstevel@tonic-gate void	print_buf(char *buf, int nbytes);
1177c478bd9Sstevel@tonic-gate void	pr_diskline(struct disk_info *disk, int num);
1187c478bd9Sstevel@tonic-gate void	pr_dblock(void (*func)(char *, ...), diskaddr_t bn);
1197c478bd9Sstevel@tonic-gate int	sup_gettoken(char *buf);
1207c478bd9Sstevel@tonic-gate void	sup_pushtoken(char *token_buf, int token_type);
1217c478bd9Sstevel@tonic-gate void	get_inputline(char *, int);
1227c478bd9Sstevel@tonic-gate int	istokenpresent(void);
123*f1c60556Spr131582 int	execute_shell(char *, size_t);
1247c478bd9Sstevel@tonic-gate void	print_efi_string(char *vendor, char *product, char *revision,
1257c478bd9Sstevel@tonic-gate     uint64_t capacity);
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate /*
1287c478bd9Sstevel@tonic-gate  * Most recent token type
1297c478bd9Sstevel@tonic-gate  */
1307c478bd9Sstevel@tonic-gate extern	int	last_token_type;
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1337c478bd9Sstevel@tonic-gate }
1347c478bd9Sstevel@tonic-gate #endif
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate #endif	/* _IO_H */
137