sysinstall.h revision 8281
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.6 1995/05/04 19:48:17 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
54/*** Defines ***/
55
56/* Bitfields for menu options */
57#define DMENU_NORMAL_TYPE	0x1	/* Normal dialog menu		*/
58#define DMENU_RADIO_TYPE	0x2	/* Radio dialog menu		*/
59#define DMENU_MULTIPLE_TYPE	0x4	/* Multiple choice menu		*/
60#define DMENU_SELECTION_RETURNS	0x8	/* Select item then exit	*/
61
62/* Bitfields for distributions - hope we never have more than 32! :-) */
63#define DIST_BIN		0x1
64#define DIST_GAMES		0x2
65#define DIST_MANPAGES		0x4
66#define DIST_PROFLIBS		0x8
67#define DIST_DICT		0x10
68#define DIST_SRC		0x20
69#define DIST_DES		0x40
70#define DIST_COMPAT1X		0x80
71#define DIST_XFREE86		0x100
72#define DIST_ALL		0xFFF
73
74/* Canned distribution sets */
75#define _DIST_DEVELOPER \
76	(DIST_BIN | DIST_MANPAGES | DIST_DICT | DIST_PROFLIBS | DIST_SRC)
77
78#define _DIST_XDEVELOPER \
79	(_DIST_DEVELOPER | DIST_XFREE86)
80
81#define _DIST_USER \
82	(DIST_BIN | DIST_MANPAGES | DIST_DICT | DIST_COMPAT1X)
83
84#define _DIST_XUSER \
85	(_DIST_USER | DIST_XFREE86)
86
87
88/* Subtypes for SRC distribution */
89#define DIST_SRC_BASE		0x1
90#define DIST_SRC_GNU		0x2
91#define DIST_SRC_ETC		0x4
92#define DIST_SRC_GAMES		0x8
93#define DIST_SRC_INCLUDE	0x10
94#define DIST_SRC_LIB		0x20
95#define DIST_SRC_LIBEXEC	0x40
96#define DIST_SRC_LKM		0x80
97#define DIST_SRC_RELEASE	0x100
98#define DIST_SRC_SBIN		0x200
99#define DIST_SRC_SHARE		0x400
100#define DIST_SRC_SYS		0x800
101#define DIST_SRC_UBIN		0x1000
102#define DIST_SRC_USBIN		0x2000
103#define DIST_SRC_ALL		0xFFFF
104
105/* variable limits */
106#define VAR_NAME_MAX		128
107#define VAR_VALUE_MAX		1024
108
109/* device limits */
110#define DEV_NAME_MAX		128
111
112
113/*** Types ***/
114typedef unsigned int Boolean;
115
116typedef enum {
117    DMENU_SHELL_ESCAPE,			/* Fork a shell			*/
118    DMENU_DISPLAY_FILE,			/* Display a file's contents	*/
119    DMENU_SUBMENU,			/* Recurse into another menu	*/
120    DMENU_SYSTEM_COMMAND,		/* Run shell commmand		*/
121    DMENU_SYSTEM_COMMAND_BOX,		/* Same as above, but in prgbox	*/
122    DMENU_SET_VARIABLE,			/* Set an environment/system var */
123    DMENU_CALL,				/* Call back a C function	*/
124    DMENU_CANCEL,			/* Cancel out of this menu	*/
125    DMENU_NOP,				/* Do nothing special for item	*/
126} DMenuItemType;
127
128typedef struct _dmenuItem {
129    char *title;			/* Our title			*/
130    char *prompt;			/* Our prompt			*/
131    DMenuItemType type;			/* What type of item we are	*/
132    void *ptr;				/* Generic data ptr		*/
133    Boolean disabled;			/* Are we temporarily disabled?	*/
134} DMenuItem;
135
136typedef struct _dmenu {
137    unsigned int options;		/* What sort of menu we are	*/
138    char *title;			/* Our title			*/
139    char *prompt;			/* Our prompt			*/
140    char *helpline;			/* Line of help at bottom	*/
141    char *helpfile;			/* Help file for "F1"		*/
142    DMenuItem items[0];			/* Array of menu items		*/
143} DMenu;
144
145/* A sysconfig variable */
146typedef struct _variable {
147    struct _variable *next;
148    char name[VAR_NAME_MAX];
149    char value[VAR_VALUE_MAX];
150} Variable;
151
152typedef enum {
153    DEVICE_TYPE_ANY,
154    DEVICE_TYPE_DISK,
155    DEVICE_TYPE_FLOPPY,
156    DEVICE_TYPE_NETWORK,
157    DEVICE_TYPE_CDROM,
158    DEVICE_TYPE_TAPE,
159    DEVICE_TYPE_SERIAL,
160    DEVICE_TYPE_PARALLEL,
161} DeviceType;
162
163/* A "device" from sysinstall's point of view */
164typedef struct _device {
165    char name[DEV_NAME_MAX];
166    DeviceType type;
167} Device;
168
169
170/*** Externs ***/
171extern int		CpioFD;	  /* The file descriptor for our CPIO floppy */
172extern int		DebugFD;  /* Where diagnostic output goes	*/
173extern Boolean		OnCDROM;  /* Are we running off of a CDROM?	*/
174extern Boolean		OnSerial; /* Are we on a serial console?	*/
175extern Boolean		SystemWasInstalled; /* Did we install it?       */
176extern Boolean		DialogActive; /* Is the dialog() stuff up?	*/
177extern Variable		*VarHead; /* The head of the variable chain	*/
178extern unsigned int	Dists;    /* Which distributions we want        */
179extern unsigned int	SrcDists; /* Which src distributions we want    */
180
181
182/*** Prototypes ***/
183
184/* globals.c */
185extern void	globalsInit(void);
186
187/* install.c */
188extern int	installCustom(char *str);
189extern int	installExpress(char *str);
190extern int	installMaint(char *str);
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);
199
200/* system.c */
201extern void	systemInitialize(int argc, char **argv);
202extern void	systemShutdown(void);
203extern void	systemWelcome(void);
204extern int	systemExecute(char *cmd);
205extern int	systemShellEscape(void);
206extern int	systemDisplayFile(char *file);
207extern char	*systemHelpFile(char *file, char *buf);
208extern void	systemChangeFont(char *font);
209extern void	systemChangeLang(char *lang);
210extern void	systemChangeTerminal(char *color, char *mono);
211extern void	systemChangeScreenmap(char *newmap);
212
213/* disks.c */
214extern void	partition_disk(struct disk *disks);
215extern int	write_disks(struct disk **disks);
216extern void	make_filesystems(struct disk **disks);
217extern void	cpio_extract(struct disk **disks);
218extern void	extract_dists(struct disk **disks);
219extern void	do_final_setup(struct disk **disks);
220
221/* dmenu.c */
222extern void	dmenuOpen(DMenu *menu, int *choice, int *scroll,
223			  int *curr, int *max);
224
225/* misc.c */
226extern Boolean	file_readable(char *fname);
227extern Boolean	file_executable(char *fname);
228extern char	*string_concat(char *p1, char *p2);
229extern char	*string_prune(char *str);
230extern char	*string_skipwhite(char *str);
231extern void	safe_free(void *ptr);
232extern void	*safe_malloc(size_t size);
233extern char	**item_add(char **list, char *item, int *curr, int *max);
234extern char	**item_add_pair(char **list, char *item1, char *item2,
235				int *curr, int *max);
236extern void	items_free(char **list, int *curr, int *max);
237
238/* termcap.c */
239extern int	set_termcap(void);
240
241/* msg.c */
242extern void	msgInfo(char *fmt, ...);
243extern void	msgYap(char *fmt, ...);
244extern void	msgWarn(char *fmt, ...);
245extern void	msgError(char *fmt, ...);
246extern void	msgFatal(char *fmt, ...);
247extern void	msgConfirm(char *fmt, ...);
248extern int	msgYesNo(char *fmt, ...);
249extern char	*msgGetInput(char *buf, char *fmt, ...);
250
251/* media.c */
252extern int	mediaSetCDROM(char *str);
253extern int	mediaSetFloppy(char *str);
254extern int	mediaSetDOS(char *str);
255extern int	mediaSetTape(char *str);
256extern int	mediaSetFTP(char *str);
257extern int	mediaSetFS(char *str);
258
259/* devices.c */
260extern Device	*device_get_all(DeviceType type, int *ndevs);
261extern struct disk *device_slice_disk(struct disk *d);
262extern DMenu	*device_create_disk_menu(DMenu *menu, Device **rdevs,
263					 int (*func)());
264
265/* variables.c */
266extern void	variable_set(char *var);
267extern void	variable_set2(char *name, char *value);
268
269/* lang.c */
270extern void	lang_set_Danish(char *str);
271extern void	lang_set_Dutch(char *str);
272extern void	lang_set_English(char *str);
273extern void	lang_set_French(char *str);
274extern void	lang_set_German(char *str);
275extern void	lang_set_Italian(char *str);
276extern void	lang_set_Japanese(char *str);
277extern void	lang_set_Russian(char *str);
278extern void	lang_set_Spanish(char *str);
279extern void	lang_set_Swedish(char *str);
280
281/* wizard.c */
282extern void	slice_wizard(struct disk *d);
283
284#endif
285/* _SYSINSTALL_H_INCLUDE */
286