sade.h revision 8302
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.5 1995/05/04 03:51:22 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/* handy */
113#define ONE_MEG			1048576
114
115
116/*** Types ***/
117typedef unsigned int Boolean;
118
119typedef enum {
120    DMENU_SHELL_ESCAPE,			/* Fork a shell			*/
121    DMENU_DISPLAY_FILE,			/* Display a file's contents	*/
122    DMENU_SUBMENU,			/* Recurse into another menu	*/
123    DMENU_SYSTEM_COMMAND,		/* Run shell commmand		*/
124    DMENU_SYSTEM_COMMAND_BOX,		/* Same as above, but in prgbox	*/
125    DMENU_SET_VARIABLE,			/* Set an environment/system var */
126    DMENU_CALL,				/* Call back a C function	*/
127    DMENU_CANCEL,			/* Cancel out of this menu	*/
128    DMENU_NOP,				/* Do nothing special for item	*/
129} DMenuItemType;
130
131typedef struct _dmenuItem {
132    char *title;			/* Our title			*/
133    char *prompt;			/* Our prompt			*/
134    DMenuItemType type;			/* What type of item we are	*/
135    void *ptr;				/* Generic data ptr		*/
136    Boolean disabled;			/* Are we temporarily disabled?	*/
137} DMenuItem;
138
139typedef struct _dmenu {
140    unsigned int options;		/* What sort of menu we are	*/
141    char *title;			/* Our title			*/
142    char *prompt;			/* Our prompt			*/
143    char *helpline;			/* Line of help at bottom	*/
144    char *helpfile;			/* Help file for "F1"		*/
145    DMenuItem items[0];			/* Array of menu items		*/
146} DMenu;
147
148/* A sysconfig variable */
149typedef struct _variable {
150    struct _variable *next;
151    char name[VAR_NAME_MAX];
152    char value[VAR_VALUE_MAX];
153} Variable;
154
155typedef enum {
156    DEVICE_TYPE_ANY,
157    DEVICE_TYPE_DISK,
158    DEVICE_TYPE_FLOPPY,
159    DEVICE_TYPE_NETWORK,
160    DEVICE_TYPE_CDROM,
161    DEVICE_TYPE_TAPE,
162    DEVICE_TYPE_SERIAL,
163    DEVICE_TYPE_PARALLEL,
164} DeviceType;
165
166/* A "device" from sysinstall's point of view */
167typedef struct _device {
168    char name[DEV_NAME_MAX];
169    DeviceType type;
170} Device;
171
172
173/*** Externs ***/
174extern int		CpioFD;	  /* The file descriptor for our CPIO floppy */
175extern int		DebugFD;  /* Where diagnostic output goes	*/
176extern Boolean		OnCDROM;  /* Are we running off of a CDROM?	*/
177extern Boolean		OnSerial; /* Are we on a serial console?	*/
178extern Boolean		SystemWasInstalled; /* Did we install it?       */
179extern Boolean		DialogActive; /* Is the dialog() stuff up?	*/
180extern Boolean		ColorDisplay; /* Are we on a color display?     */
181extern Boolean		OnVTY;    /* On a syscons VTY?			*/
182extern Variable		*VarHead; /* The head of the variable chain	*/
183extern unsigned int	Dists;    /* Which distributions we want        */
184extern unsigned int	SrcDists; /* Which src distributions we want    */
185
186
187/*** Prototypes ***/
188
189/* globals.c */
190extern void	globalsInit(void);
191
192/* install.c */
193extern int	installCustom(char *str);
194extern int	installExpress(char *str);
195extern int	installMaint(char *str);
196
197/* dist.c */
198extern int	distSetDeveloper(char *str);
199extern int	distSetXDeveloper(char *str);
200extern int	distSetUser(char *str);
201extern int	distSetXUser(char *str);
202extern int	distSetMinimum(char *str);
203extern int	distSetEverything(char *str);
204
205/* system.c */
206extern void	systemInitialize(int argc, char **argv);
207extern void	systemShutdown(void);
208extern void	systemWelcome(void);
209extern int	systemExecute(char *cmd);
210extern int	systemShellEscape(void);
211extern int	systemDisplayFile(char *file);
212extern char	*systemHelpFile(char *file, char *buf);
213extern void	systemChangeFont(const u_char font[]);
214extern void	systemChangeLang(char *lang);
215extern void	systemChangeTerminal(char *color, const u_char c_termcap[],
216				     char *mono, const u_char m_termcap[]);
217extern void	systemChangeScreenmap(const u_char newmap[]);
218
219/* disks.c */
220extern void	partition_disks(struct disk **disks);
221extern int	write_disks(struct disk **disks);
222extern void	make_filesystems(struct disk **disks);
223extern void	cpio_extract(struct disk **disks);
224extern void	extract_dists(struct disk **disks);
225extern void	do_final_setup(struct disk **disks);
226
227/* dmenu.c */
228extern void	dmenuOpen(DMenu *menu, int *choice, int *scroll,
229			  int *curr, int *max);
230
231/* misc.c */
232extern Boolean	file_readable(char *fname);
233extern Boolean	file_executable(char *fname);
234extern char	*string_concat(char *p1, char *p2);
235extern char	*string_prune(char *str);
236extern char	*string_skipwhite(char *str);
237extern void	safe_free(void *ptr);
238extern void	*safe_malloc(size_t size);
239extern char	**item_add(char **list, char *item, int *curr, int *max);
240extern char	**item_add_pair(char **list, char *item1, char *item2,
241				int *curr, int *max);
242extern void	items_free(char **list, int *curr, int *max);
243
244/* termcap.c */
245extern int	set_termcap(void);
246
247/* msg.c */
248extern void	msgInfo(char *fmt, ...);
249extern void	msgYap(char *fmt, ...);
250extern void	msgWarn(char *fmt, ...);
251extern void	msgError(char *fmt, ...);
252extern void	msgFatal(char *fmt, ...);
253extern void	msgConfirm(char *fmt, ...);
254extern int	msgYesNo(char *fmt, ...);
255extern char	*msgGetInput(char *buf, char *fmt, ...);
256
257/* media.c */
258extern int	mediaSetCDROM(char *str);
259extern int	mediaSetFloppy(char *str);
260extern int	mediaSetDOS(char *str);
261extern int	mediaSetTape(char *str);
262extern int	mediaSetFTP(char *str);
263extern int	mediaSetFS(char *str);
264
265/* devices.c */
266extern Device	*device_get_all(DeviceType type, int *ndevs);
267extern struct disk *device_slice_disk(struct disk *d);
268extern DMenu	*device_create_disk_menu(DMenu *menu, Device **rdevs,
269					 int (*func)());
270
271/* variables.c */
272extern void	variable_set(char *var);
273extern void	variable_set2(char *name, char *value);
274
275/* lang.c */
276extern void	lang_set_Danish(char *str);
277extern void	lang_set_Dutch(char *str);
278extern void	lang_set_English(char *str);
279extern void	lang_set_French(char *str);
280extern void	lang_set_German(char *str);
281extern void	lang_set_Italian(char *str);
282extern void	lang_set_Japanese(char *str);
283extern void	lang_set_Norwegian(char *str);
284extern void	lang_set_Russian(char *str);
285extern void	lang_set_Spanish(char *str);
286extern void	lang_set_Swedish(char *str);
287
288/* makedevs.c (auto-generated) */
289extern const char termcap_vt100[];
290extern const char termcap_cons25[];
291extern const char termcap_cons25_m[];
292extern const char termcap_cons25r[];
293extern const char termcap_cons25r_m[];
294extern const char termcap_cons25l1[];
295extern const char termcap_cons25l1_m[];
296extern const u_char font_iso_8x14[];
297extern const u_char font_cp850_8x14[];
298extern const u_char font_koi8_r_8x14[];
299extern const u_char koi8_r2cp866[];
300
301/* wizard.c */
302extern void	slice_wizard(struct disk *d);
303
304#endif
305/* _SYSINSTALL_H_INCLUDE */
306