sade.h revision 8405
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last attempt in the `sysinstall' line, the next
5 * generation being slated to essentially a complete rewrite.
6 *
7 * $Id: sysinstall.h,v 1.14 1995/05/08 21:39:40 jkh Exp $
8 *
9 * Copyright (c) 1995
10 *	Jordan Hubbard.  All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer,
17 *    verbatim and that no modifications are made prior to this
18 *    point in the file.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 *    notice, this list of conditions and the following disclaimer in the
21 *    documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 *    must display the following acknowledgement:
24 *	This product includes software developed by Jordan Hubbard
25 *	for the FreeBSD Project.
26 * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
27 *    endorse or promote products derived from this software without specific
28 *    prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED.  IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 */
43
44#ifndef _SYSINSTALL_H_INCLUDE
45#define _SYSINSTALL_H_INCLUDE
46
47#include <stdio.h>
48#include <stdlib.h>
49#include <string.h>
50#include <unistd.h>
51#include <dialog.h>
52#include "libdisk.h"
53#include "dist.h"
54
55/*** Defines ***/
56
57/* Bitfields for menu options */
58#define DMENU_NORMAL_TYPE	0x1	/* Normal dialog menu		*/
59#define DMENU_RADIO_TYPE	0x2	/* Radio dialog menu		*/
60#define DMENU_MULTIPLE_TYPE	0x4	/* Multiple choice menu		*/
61#define DMENU_SELECTION_RETURNS	0x8	/* Select item then exit	*/
62#define DMENU_CALL_FIRST	0x10	/* In multiple, use one handler */
63
64/* variable limits */
65#define VAR_NAME_MAX		128
66#define VAR_VALUE_MAX		1024
67
68/* device limits */
69#define DEV_NAME_MAX		128
70
71
72/*** Types ***/
73typedef unsigned int Boolean;
74
75typedef enum {
76    DMENU_SHELL_ESCAPE,			/* Fork a shell			*/
77    DMENU_DISPLAY_FILE,			/* Display a file's contents	*/
78    DMENU_SUBMENU,			/* Recurse into another menu	*/
79    DMENU_SYSTEM_COMMAND,		/* Run shell commmand		*/
80    DMENU_SYSTEM_COMMAND_BOX,		/* Same as above, but in prgbox	*/
81    DMENU_SET_VARIABLE,			/* Set an environment/system var */
82    DMENU_SET_FLAG,			/* Set flag in an unsigned int	*/
83    DMENU_CALL,				/* Call back a C function	*/
84    DMENU_CANCEL,			/* Cancel out of this menu	*/
85    DMENU_NOP,				/* Do nothing special for item	*/
86} DMenuItemType;
87
88typedef struct _dmenuItem {
89    char *title;			/* Our title			*/
90    char *prompt;			/* Our prompt			*/
91    DMenuItemType type;			/* What type of item we are	*/
92    void *ptr;				/* Generic data ptr		*/
93    u_long parm;			/* Parameter for above		*/
94    Boolean disabled;			/* Are we temporarily disabled?	*/
95} DMenuItem;
96
97typedef struct _dmenu {
98    unsigned int options;		/* What sort of menu we are	*/
99    char *title;			/* Our title			*/
100    char *prompt;			/* Our prompt			*/
101    char *helpline;			/* Line of help at bottom	*/
102    char *helpfile;			/* Help file for "F1"		*/
103    DMenuItem items[0];			/* Array of menu items		*/
104} DMenu;
105
106/* A sysconfig variable */
107typedef struct _variable {
108    struct _variable *next;
109    char name[VAR_NAME_MAX];
110    char value[VAR_VALUE_MAX];
111} Variable;
112
113typedef enum {
114    DEVICE_TYPE_NONE,
115    DEVICE_TYPE_DISK,
116    DEVICE_TYPE_FLOPPY,
117    DEVICE_TYPE_NETWORK,
118    DEVICE_TYPE_CDROM,
119    DEVICE_TYPE_TAPE,
120    DEVICE_TYPE_SERIAL,
121    DEVICE_TYPE_PARALLEL,
122    DEVICE_TYPE_ANY,
123} DeviceType;
124
125/* A "device" from sysinstall's point of view */
126typedef struct _device {
127    char name[DEV_NAME_MAX];
128    DeviceType type;
129} Device;
130
131/* Some internal representations of partitions */
132typedef enum {
133    PART_NONE,
134    PART_SLICE,
135    PART_SWAP,
136    PART_FILESYSTEM
137} PartType;
138
139/* The longest newfs command we'll hand to system() */
140#define NEWFS_CMD_MAX	256
141
142typedef struct _part_info {
143    Boolean newfs;
144    char mountpoint[FILENAME_MAX];
145    char newfs_cmd[NEWFS_CMD_MAX];
146} PartInfo;
147
148
149/*** Externs ***/
150extern int		CpioFD;	  /* The file descriptor for our CPIO floppy */
151extern int		DebugFD;  /* Where diagnostic output goes	*/
152extern Boolean		OnCDROM;  /* Are we running off of a CDROM?	*/
153extern Boolean		OnSerial; /* Are we on a serial console?	*/
154extern Boolean		SystemWasInstalled; /* Did we install it?       */
155extern Boolean		DialogActive; /* Is the dialog() stuff up?	*/
156extern Boolean		ColorDisplay; /* Are we on a color display?     */
157extern Boolean		OnVTY;    /* On a syscons VTY?			*/
158extern Variable		*VarHead; /* The head of the variable chain	*/
159extern unsigned int	Dists;    /* Which distributions we want        */
160extern unsigned int	SrcDists; /* Which src distributions we want    */
161extern unsigned int	XF86Dists;/* Which XFree86 dists we want	*/
162extern unsigned int	XF86ServerDists; /* The XFree86 servers we want */
163extern unsigned int	XF86FontDists; /* The XFree86 fonts we want     */
164extern struct disk	*Disks[]; /* The disks we're working on		*/
165
166/*** Prototypes ***/
167
168/* command.c */
169extern void	command_clear(void);
170extern void	command_sort(void);
171extern void	command_execute(void);
172extern void	command_add(char *key, char *fmt, ...);
173
174/* decode.c */
175extern DMenuItem *decode(DMenu *menu, char *name);
176extern Boolean	dispatch(DMenuItem *tmp, char *name);
177extern Boolean	decode_and_dispatch_multiple(DMenu *menu, char *names);
178
179/* devices.c */
180extern struct disk	*device_slice_disk(struct disk *d);
181extern DMenu *device_create_disk_menu(DMenu *menu, Device **rdevs, int (*hook)());
182
183/* disks.c */
184extern void	partition_disks(void);
185extern int	write_disks(void);
186extern void	make_filesystems(void);
187extern void	cpio_extract(void);
188extern void	extract_dists(void);
189extern void	install_configuration_files(void);
190extern void	do_final_setup(void);
191
192/* dist.c */
193extern int	distSetDeveloper(char *str);
194extern int	distSetXDeveloper(char *str);
195extern int	distSetUser(char *str);
196extern int	distSetXUser(char *str);
197extern int	distSetMinimum(char *str);
198extern int	distSetEverything(char *str);
199extern int	distSetSrc(char *str);
200extern void	distExtractAll(void);
201
202/* dmenu.c */
203extern void	dmenuOpen(DMenu *menu, int *choice, int *scroll,
204			  int *curr, int *max);
205
206/* globals.c */
207extern void	globalsInit(void);
208
209/* install.c */
210extern int	installCustom(char *str);
211extern int	installExpress(char *str);
212extern int	installMaint(char *str);
213
214/* lang.c */
215extern void	lang_set_Danish(char *str);
216extern void	lang_set_Dutch(char *str);
217extern void	lang_set_English(char *str);
218extern void	lang_set_French(char *str);
219extern void	lang_set_German(char *str);
220extern void	lang_set_Italian(char *str);
221extern void	lang_set_Japanese(char *str);
222extern void	lang_set_Norwegian(char *str);
223extern void	lang_set_Russian(char *str);
224extern void	lang_set_Spanish(char *str);
225extern void	lang_set_Swedish(char *str);
226
227/* makedevs.c (auto-generated) */
228extern const char	termcap_vt100[];
229extern const char	termcap_cons25[];
230extern const char	termcap_cons25_m[];
231extern const char	termcap_cons25r[];
232extern const char	termcap_cons25r_m[];
233extern const char	termcap_cons25l1[];
234extern const char	termcap_cons25l1_m[];
235extern const u_char	font_iso_8x14[];
236extern const u_char	font_cp850_8x14[];
237extern const u_char	font_koi8_r_8x14[];
238extern const u_char	koi8_r2cp866[];
239
240/* media.c */
241extern int	mediaSetCDROM(char *str);
242extern int	mediaSetFloppy(char *str);
243extern int	mediaSetDOS(char *str);
244extern int	mediaSetTape(char *str);
245extern int	mediaSetFTP(char *str);
246extern int	mediaSetFS(char *str);
247
248/* misc.c */
249extern Boolean	file_readable(char *fname);
250extern Boolean	file_executable(char *fname);
251extern char	*string_concat(char *p1, char *p2);
252extern char	*string_prune(char *str);
253extern char	*string_skipwhite(char *str);
254extern void	safe_free(void *ptr);
255extern void	*safe_malloc(size_t size);
256extern void	*safe_realloc(void *orig, size_t size);
257extern char	**item_add(char **list, char *item, int *curr, int *max);
258extern char	**item_add_pair(char **list, char *item1, char *item2,
259				int *curr, int *max);
260extern void	items_free(char **list, int *curr, int *max);
261
262/* msg.c */
263extern void	msgInfo(char *fmt, ...);
264extern void	msgYap(char *fmt, ...);
265extern void	msgWarn(char *fmt, ...);
266extern void	msgDebug(char *fmt, ...);
267extern void	msgError(char *fmt, ...);
268extern void	msgFatal(char *fmt, ...);
269extern void	msgConfirm(char *fmt, ...);
270extern void	msgNotify(char *fmt, ...);
271extern int	msgYesNo(char *fmt, ...);
272extern char	*msgGetInput(char *buf, char *fmt, ...);
273
274/* system.c */
275extern void	systemInitialize(int argc, char **argv);
276extern void	systemShutdown(void);
277extern void	systemWelcome(void);
278extern int	systemExecute(char *cmd);
279extern int	systemShellEscape(void);
280extern int	systemDisplayFile(char *file);
281extern char	*systemHelpFile(char *file, char *buf);
282extern void	systemChangeFont(const u_char font[]);
283extern void	systemChangeLang(char *lang);
284extern void	systemChangeTerminal(char *color, const u_char c_termcap[],
285				     char *mono, const u_char m_termcap[]);
286extern void	systemChangeScreenmap(const u_char newmap[]);
287extern int	vsystem(char *fmt, ...);
288
289/* termcap.c */
290extern int	set_termcap(void);
291
292/* variables.c */
293extern void	variable_set(char *var);
294extern void	variable_set2(char *name, char *value);
295
296/* wizard.c */
297extern void	slice_wizard(struct disk *d);
298
299#endif
300/* _SYSINSTALL_H_INCLUDE */
301