sade.h revision 8363
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.13 1995/05/08 10:20:56 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_NONE, 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 DEVICE_TYPE_ANY, 165} DeviceType; 166 167/* A "device" from sysinstall's point of view */ 168typedef struct _device { 169 char name[DEV_NAME_MAX]; 170 DeviceType type; 171} Device; 172 173/* Some internal representations of partitions */ 174typedef enum { 175 PART_NONE, 176 PART_SLICE, 177 PART_SWAP, 178 PART_FILESYSTEM 179} PartType; 180 181/* The longest newfs command we'll hand to system() */ 182#define NEWFS_CMD_MAX 256 183 184typedef struct _part_info { 185 Boolean newfs; 186 char mountpoint[FILENAME_MAX]; 187 char newfs_cmd[NEWFS_CMD_MAX]; 188} PartInfo; 189 190 191/*** Externs ***/ 192extern int CpioFD; /* The file descriptor for our CPIO floppy */ 193extern int DebugFD; /* Where diagnostic output goes */ 194extern Boolean OnCDROM; /* Are we running off of a CDROM? */ 195extern Boolean OnSerial; /* Are we on a serial console? */ 196extern Boolean SystemWasInstalled; /* Did we install it? */ 197extern Boolean DialogActive; /* Is the dialog() stuff up? */ 198extern Boolean ColorDisplay; /* Are we on a color display? */ 199extern Boolean OnVTY; /* On a syscons VTY? */ 200extern Variable *VarHead; /* The head of the variable chain */ 201extern unsigned int Dists; /* Which distributions we want */ 202extern unsigned int SrcDists; /* Which src distributions we want */ 203extern struct disk *Disks[]; /* The disks we're working on */ 204 205/*** Prototypes ***/ 206 207/* command.c */ 208extern void command_clear(void); 209extern void command_sort(void); 210extern void command_execute(void); 211extern void command_add(char *key, char *fmt, ...); 212 213/* devices.c */ 214extern struct disk *device_slice_disk(struct disk *d); 215extern DMenu *device_create_disk_menu(DMenu *menu, Device **rdevs, int (*hook)()); 216 217/* disks.c */ 218extern void partition_disks(void); 219extern int write_disks(void); 220extern void make_filesystems(void); 221extern void cpio_extract(void); 222extern void extract_dists(void); 223extern void install_configuration_files(void); 224extern void do_final_setup(void); 225 226/* dist.c */ 227extern int distSetDeveloper(char *str); 228extern int distSetXDeveloper(char *str); 229extern int distSetUser(char *str); 230extern int distSetXUser(char *str); 231extern int distSetMinimum(char *str); 232extern int distSetEverything(char *str); 233 234/* dmenu.c */ 235extern void dmenuOpen(DMenu *menu, int *choice, int *scroll, 236 int *curr, int *max); 237 238/* globals.c */ 239extern void globalsInit(void); 240 241/* install.c */ 242extern int installCustom(char *str); 243extern int installExpress(char *str); 244extern int installMaint(char *str); 245 246/* lang.c */ 247extern void lang_set_Danish(char *str); 248extern void lang_set_Dutch(char *str); 249extern void lang_set_English(char *str); 250extern void lang_set_French(char *str); 251extern void lang_set_German(char *str); 252extern void lang_set_Italian(char *str); 253extern void lang_set_Japanese(char *str); 254extern void lang_set_Norwegian(char *str); 255extern void lang_set_Russian(char *str); 256extern void lang_set_Spanish(char *str); 257extern void lang_set_Swedish(char *str); 258 259/* makedevs.c (auto-generated) */ 260extern const char termcap_vt100[]; 261extern const char termcap_cons25[]; 262extern const char termcap_cons25_m[]; 263extern const char termcap_cons25r[]; 264extern const char termcap_cons25r_m[]; 265extern const char termcap_cons25l1[]; 266extern const char termcap_cons25l1_m[]; 267extern const u_char font_iso_8x14[]; 268extern const u_char font_cp850_8x14[]; 269extern const u_char font_koi8_r_8x14[]; 270extern const u_char koi8_r2cp866[]; 271 272/* media.c */ 273extern int mediaSetCDROM(char *str); 274extern int mediaSetFloppy(char *str); 275extern int mediaSetDOS(char *str); 276extern int mediaSetTape(char *str); 277extern int mediaSetFTP(char *str); 278extern int mediaSetFS(char *str); 279 280/* misc.c */ 281extern Boolean file_readable(char *fname); 282extern Boolean file_executable(char *fname); 283extern char *string_concat(char *p1, char *p2); 284extern char *string_prune(char *str); 285extern char *string_skipwhite(char *str); 286extern void safe_free(void *ptr); 287extern void *safe_malloc(size_t size); 288extern void *safe_realloc(void *orig, size_t size); 289extern char **item_add(char **list, char *item, int *curr, int *max); 290extern char **item_add_pair(char **list, char *item1, char *item2, 291 int *curr, int *max); 292extern void items_free(char **list, int *curr, int *max); 293 294/* msg.c */ 295extern void msgInfo(char *fmt, ...); 296extern void msgYap(char *fmt, ...); 297extern void msgWarn(char *fmt, ...); 298extern void msgDebug(char *fmt, ...); 299extern void msgError(char *fmt, ...); 300extern void msgFatal(char *fmt, ...); 301extern void msgConfirm(char *fmt, ...); 302extern void msgNotify(char *fmt, ...); 303extern int msgYesNo(char *fmt, ...); 304extern char *msgGetInput(char *buf, char *fmt, ...); 305 306/* system.c */ 307extern void systemInitialize(int argc, char **argv); 308extern void systemShutdown(void); 309extern void systemWelcome(void); 310extern int systemExecute(char *cmd); 311extern int systemShellEscape(void); 312extern int systemDisplayFile(char *file); 313extern char *systemHelpFile(char *file, char *buf); 314extern void systemChangeFont(const u_char font[]); 315extern void systemChangeLang(char *lang); 316extern void systemChangeTerminal(char *color, const u_char c_termcap[], 317 char *mono, const u_char m_termcap[]); 318extern void systemChangeScreenmap(const u_char newmap[]); 319extern int vsystem(char *fmt, ...); 320 321/* termcap.c */ 322extern int set_termcap(void); 323 324/* variables.c */ 325extern void variable_set(char *var); 326extern void variable_set2(char *name, char *value); 327 328/* wizard.c */ 329extern void slice_wizard(struct disk *d); 330 331#endif 332/* _SYSINSTALL_H_INCLUDE */ 333