sade.h revision 8722
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.29 1995/05/24 01:27:14 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	/* The maximum length of a device name	*/
70#define DEV_MAX			200	/* The maximum number of devices we'll deal with */
71#define INTERFACE_MAX		50	/* Maximum number of network interfaces we'll deal with */
72
73/*
74 * I make some pretty gross assumptions about having a max of 50 chunks
75 * total - 8 slices and 42 partitions.  I can't easily display many more
76 * than that on the screen at once!
77 *
78 * For 2.1 I'll revisit this and try to make it more dynamic, but since
79 * this will catch 99.99% of all possible cases, I'm not too worried.
80 */
81#define MAX_CHUNKS	50
82
83/* Internal flag variables */
84#define DISK_PARTITIONED	"_diskPartitioned"
85#define DISK_LABELLED		"_diskLabelled"
86#define RUNNING_ON_ROOT		"_runningOnRoot"
87#define TCP_CONFIGURED		"_tcpConfigured"
88#define NO_CONFIRMATION		"_noConfirmation"
89
90#define VAR_HOSTNAME		"hostname"
91#define VAR_DOMAINNAME		"domainname"
92#define VAR_NAMESERVER		"nameserver"
93#define VAR_GATEWAY		"gateway"
94
95#define VAR_IFCONFIG		"ifconfig_"
96
97/* The help file for the TCP/IP setup screen */
98#define TCP_HELPFILE		"tcp.hlp"
99
100/*** Types ***/
101typedef unsigned int Boolean;
102typedef struct disk Disk;
103typedef struct chunk Chunk;
104
105typedef enum {
106    DMENU_SHELL_ESCAPE,			/* Fork a shell			*/
107    DMENU_DISPLAY_FILE,			/* Display a file's contents	*/
108    DMENU_SUBMENU,			/* Recurse into another menu	*/
109    DMENU_SYSTEM_COMMAND,		/* Run shell commmand		*/
110    DMENU_SYSTEM_COMMAND_BOX,		/* Same as above, but in prgbox	*/
111    DMENU_SET_VARIABLE,			/* Set an environment/system var */
112    DMENU_SET_FLAG,			/* Set flag in an unsigned int	*/
113    DMENU_CALL,				/* Call back a C function	*/
114    DMENU_CANCEL,			/* Cancel out of this menu	*/
115    DMENU_NOP,				/* Do nothing special for item	*/
116} DMenuItemType;
117
118typedef struct _dmenuItem {
119    char *title;			/* Our title			*/
120    char *prompt;			/* Our prompt			*/
121    DMenuItemType type;			/* What type of item we are	*/
122    void *ptr;				/* Generic data ptr		*/
123    u_long parm;			/* Parameter for above		*/
124    Boolean disabled;			/* Are we temporarily disabled?	*/
125} DMenuItem;
126
127typedef struct _dmenu {
128    unsigned int options;		/* What sort of menu we are	*/
129    char *title;			/* Our title			*/
130    char *prompt;			/* Our prompt			*/
131    char *helpline;			/* Line of help at bottom	*/
132    char *helpfile;			/* Help file for "F1"		*/
133    DMenuItem items[0];			/* Array of menu items		*/
134} DMenu;
135
136/* A sysconfig variable */
137typedef struct _variable {
138    struct _variable *next;
139    char name[VAR_NAME_MAX];
140    char value[VAR_VALUE_MAX];
141} Variable;
142
143typedef enum {
144    DEVICE_TYPE_NONE,
145    DEVICE_TYPE_DISK,
146    DEVICE_TYPE_FLOPPY,
147    DEVICE_TYPE_NETWORK,
148    DEVICE_TYPE_CDROM,
149    DEVICE_TYPE_TAPE,
150    DEVICE_TYPE_DOS,
151    DEVICE_TYPE_ANY,
152} DeviceType;
153
154/* A "device" from sysinstall's point of view */
155typedef struct _device {
156    char name[DEV_NAME_MAX];
157    char *description;
158    char *devname;
159    DeviceType type;
160    Boolean enabled;
161    Boolean (*init)(struct _device *);
162    int (*get)(char *fname);
163    Boolean (*close)(struct _device *, int fd);
164    void (*shutdown)(struct _device *);
165    void *private;
166} Device;
167
168/* Some internal representations of partitions */
169typedef enum {
170    PART_NONE,
171    PART_SLICE,
172    PART_SWAP,
173    PART_FILESYSTEM,
174    PART_FAT,
175} PartType;
176
177/* The longest newfs command we'll hand to system() */
178#define NEWFS_CMD_MAX	256
179
180typedef struct _part_info {
181    Boolean newfs;
182    char mountpoint[FILENAME_MAX];
183    char newfs_cmd[NEWFS_CMD_MAX];
184} PartInfo;
185
186typedef int (*commandFunc)(char *key, void *data);
187
188
189/*** Externs ***/
190extern int		CpioFD;			/* The file descriptor for our CPIO floppy	*/
191extern int		DebugFD;		/* Where diagnostic output goes			*/
192extern Boolean		OnCDROM;		/* Are we running off of a CDROM?		*/
193extern Boolean		OnSerial;		/* Are we on a serial console?			*/
194extern Boolean		SystemWasInstalled;	/* Did we install it?				*/
195extern Boolean		DialogActive;		/* Is the dialog() stuff up?			*/
196extern Boolean		ColorDisplay;		/* Are we on a color display?			*/
197extern Boolean		OnVTY;			/* On a syscons VTY?				*/
198extern Variable		*VarHead;		/* The head of the variable chain		*/
199extern Device		*mediaDevice;		/* Where we're getting our distribution from	*/
200extern unsigned int	Dists;			/* Which distributions we want			*/
201extern unsigned int	SrcDists;		/* Which src distributions we want		*/
202extern unsigned int	XF86Dists;		/* Which XFree86 dists we want			*/
203extern unsigned int	XF86ServerDists;	/* The XFree86 servers we want			*/
204extern unsigned int	XF86FontDists;		/* The XFree86 fonts we want			*/
205
206extern DMenu		MenuInitial;		/* Initial installation menu			*/
207extern DMenu		MenuMBRType;		/* Type of MBR to write on the disk		*/
208extern DMenu		MenuConfigure;		/* Final configuration menu			*/
209extern DMenu		MenuDocumentation;	/* Documentation menu				*/
210extern DMenu		MenuOptions;		/* Installation options				*/
211extern DMenu		MenuOptionsLanguage;	/* Language options menu			*/
212extern DMenu		MenuOptionsFTP;		/* FTP options menu				*/
213extern DMenu		MenuMedia;		/* Media type menu				*/
214extern DMenu		MenuMediaCDROM;		/* CDROM media menu				*/
215extern DMenu		MenuMediaDOS;		/* DOS media menu				*/
216extern DMenu		MenuMediaFloppy;	/* Floppy media menu				*/
217extern DMenu		MenuMediaFTP;		/* FTP media menu				*/
218extern DMenu		MenuMediaTape;		/* Tape media menu				*/
219extern DMenu		MenuNetworkDevice;	/* Network device menu				*/
220extern DMenu		MenuSyscons;		/* System console configuration menu		*/
221extern DMenu		MenuInstall;		/* Installation menu				*/
222extern DMenu		MenuInstallType;	/* Installation type menu			*/
223extern DMenu		MenuDistributions;	/* Distribution menu				*/
224extern DMenu		MenuSrcDistributions;	/* Source distribution menu			*/
225extern DMenu		MenuXF86;		/* XFree86 main menu				*/
226extern DMenu		MenuXF86Select;		/* XFree86 distribution selection menu		*/
227extern DMenu		MenuXF86SelectCore;	/* XFree86 core distribution menu		*/
228extern DMenu		MenuXF86SelectServer;	/* XFree86 server distribution menu		*/
229extern DMenu		MenuXF86SelectFonts;	/* XFree86 font selection menu			*/
230extern DMenu		MenuDiskDevices;	/* Disk devices menu				*/
231
232
233/*** Prototypes ***/
234
235/* command.c */
236extern void	command_clear(void);
237extern void	command_sort(void);
238extern void	command_execute(void);
239extern void	command_shell_add(char *key, char *fmt, ...);
240extern void	command_func_add(char *key, commandFunc func, void *data);
241
242/* config.c */
243extern void	configFstab(void);
244extern void	configSysconfig(void);
245extern void	configResolv(void);
246extern int	configPorts(char *str);
247extern int	configPackages(char *str);
248extern int	configSaverTimeout(char *str);
249
250/* decode.c */
251extern DMenuItem *decode(DMenu *menu, char *name);
252extern Boolean	dispatch(DMenuItem *tmp, char *name);
253extern Boolean	decode_and_dispatch_multiple(DMenu *menu, char *names);
254
255/* devices.c */
256extern DMenu	*deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)());
257extern void	deviceGetAll(void);
258extern Device	**deviceFind(char *name, DeviceType type);
259extern int	deviceCount(Device **devs);
260extern Device	*new_device(char *name);
261extern Device	*deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
262				Boolean (*init)(Device *mediadev), int (*get)(char *distname),
263				Boolean (*close)(Device *mediadev, int fd), void (*shutDown)(Device *mediadev),
264				void *private);
265
266/* disks.c */
267extern int	diskPartitionEditor(char *unused);
268
269/* dist.c */
270extern int	distSetDeveloper(char *str);
271extern int	distSetXDeveloper(char *str);
272extern int	distSetUser(char *str);
273extern int	distSetXUser(char *str);
274extern int	distSetMinimum(char *str);
275extern int	distSetEverything(char *str);
276extern int	distSetSrc(char *str);
277extern void	distExtractAll(void);
278
279/* dmenu.c */
280extern void	dmenuOpen(DMenu *menu, int *choice, int *scroll,
281			  int *curr, int *max);
282extern void	dmenuOpenSimple(DMenu *menu);
283
284/* globals.c */
285extern void	globalsInit(void);
286
287/* install.c */
288extern int	installCommit(char *str);
289
290/* lang.c */
291extern void	lang_set_Danish(char *str);
292extern void	lang_set_Dutch(char *str);
293extern void	lang_set_English(char *str);
294extern void	lang_set_French(char *str);
295extern void	lang_set_German(char *str);
296extern void	lang_set_Italian(char *str);
297extern void	lang_set_Japanese(char *str);
298extern void	lang_set_Norwegian(char *str);
299extern void	lang_set_Russian(char *str);
300extern void	lang_set_Spanish(char *str);
301extern void	lang_set_Swedish(char *str);
302
303/* label.c */
304extern int	diskLabelEditor(char *str);
305
306/* makedevs.c (auto-generated) */
307extern const char	termcap_vt100[];
308extern const char	termcap_cons25[];
309extern const char	termcap_cons25_m[];
310extern const char	termcap_cons25r[];
311extern const char	termcap_cons25r_m[];
312extern const char	termcap_cons25l1[];
313extern const char	termcap_cons25l1_m[];
314extern const u_char	font_iso_8x16[];
315extern const u_char	font_cp850_8x16[];
316extern const u_char	font_cp866_8x16[];
317extern const u_char	koi8_r2cp866[];
318extern u_char		default_scrnmap[];
319
320/* media.c */
321extern int	mediaSetCDROM(char *str);
322extern int	mediaSetFloppy(char *str);
323extern int	mediaSetDOS(char *str);
324extern int	mediaSetTape(char *str);
325extern int	mediaSetFTP(char *str);
326extern int	mediaSetFS(char *str);
327extern Boolean	mediaGetType(void);
328extern Boolean	mediaExtractDist(char *distname, char *dir, int fd);
329extern Boolean	mediaVerify(void);
330
331/* media_strategy.c */
332extern Boolean	mediaInitCDROM(Device *dev);
333extern Boolean	mediaInitDOS(Device *dev);
334extern Boolean	mediaInitFloppy(Device *dev);
335extern Boolean	mediaInitFTP(Device *dev);
336extern Boolean	mediaInitNetwork(Device *dev);
337extern Boolean	mediaInitTape(Device *dev);
338extern Boolean	mediaInitUFS(Device *dev);
339extern int	mediaGetCDROM(char *dist);
340extern int	mediaGetDOS(char *dist);
341extern int	mediaGetFloppy(char *dist);
342extern int	mediaGetFTP(char *dist);
343extern int	mediaGetTape(char *dist);
344extern int	mediaGetUFS(char *dist);
345extern void	mediaShutdownCDROM(Device *dev);
346extern void	mediaShutdownDOS(Device *dev);
347extern void	mediaShutdownFTP(Device *dev);
348extern void	mediaShutdownFloppy(Device *dev);
349extern void	mediaShutdownNetwork(Device *dev);
350extern void	mediaShutdownTape(Device *dev);
351
352/* misc.c */
353extern Boolean	file_readable(char *fname);
354extern Boolean	file_executable(char *fname);
355extern char	*string_concat(char *p1, char *p2);
356extern char	*string_prune(char *str);
357extern char	*string_skipwhite(char *str);
358extern void	safe_free(void *ptr);
359extern void	*safe_malloc(size_t size);
360extern void	*safe_realloc(void *orig, size_t size);
361extern char	**item_add(char **list, char *item, int *curr, int *max);
362extern char	**item_add_pair(char **list, char *item1, char *item2,
363				int *curr, int *max);
364extern void	items_free(char **list, int *curr, int *max);
365extern int	Mkdir(char *, void *data);
366extern int	Mount(char *, void *data);
367
368/* msg.c */
369extern void	msgInfo(char *fmt, ...);
370extern void	msgYap(char *fmt, ...);
371extern void	msgWarn(char *fmt, ...);
372extern void	msgDebug(char *fmt, ...);
373extern void	msgError(char *fmt, ...);
374extern void	msgFatal(char *fmt, ...);
375extern void	msgConfirm(char *fmt, ...);
376extern void	msgNotify(char *fmt, ...);
377extern void	msgWeHaveOutput(char *fmt, ...);
378extern int	msgYesNo(char *fmt, ...);
379extern char	*msgGetInput(char *buf, char *fmt, ...);
380
381/* system.c */
382extern void	systemInitialize(int argc, char **argv);
383extern void	systemShutdown(void);
384extern void	systemWelcome(void);
385extern int	systemExecute(char *cmd);
386extern int	systemShellEscape(void);
387extern int	systemDisplayFile(char *file);
388extern char	*systemHelpFile(char *file, char *buf);
389extern void	systemChangeFont(const u_char font[]);
390extern void	systemChangeLang(char *lang);
391extern void	systemChangeTerminal(char *color, const u_char c_termcap[],
392				     char *mono, const u_char m_termcap[]);
393extern void	systemChangeScreenmap(const u_char newmap[]);
394extern int	vsystem(char *fmt, ...);
395
396/* tcpip.c */
397extern int	tcpOpenDialog(char *);
398extern Device	*tcpDeviceSelect(void);
399extern Boolean	tcpStartPPP(void);
400
401/* termcap.c */
402extern int	set_termcap(void);
403
404/* variables.c */
405extern void	variable_set(char *var);
406extern void	variable_set2(char *name, char *value);
407
408/* wizard.c */
409extern void	slice_wizard(Disk *d);
410
411#endif
412/* _SYSINSTALL_H_INCLUDE */
413