sysinstall.h revision 8549
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.15 1995/05/10 07:45:00 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/* Internal flag variables */ 75#define DISK_PARTITIONED "_diskPartitioned" 76#define DISK_LABELLED "_diskLabelled" 77#define TCP_CONFIGURED "_tcpConfigured" 78#define NO_CONFIRMATION "_noConfirmation" 79#define MEDIA_DEVICE "mediaDevice" 80#define MEDIA_TYPE "mediaType" 81 82#define VAR_HOSTNAME "hostname" 83#define VAR_DOMAINNAME "domainname" 84#define VAR_IPADDR "ip_addr" 85#define VAR_NAMESERVER "nameserver" 86 87#define VAR_IFCONFIG_ARGS "if_flags" 88#define VAR_NETMASK "netmask" 89#define VAR_GATEWAY "gateway" 90 91 92/*** Types ***/ 93typedef unsigned int Boolean; 94typedef struct disk Disk; 95typedef struct chunk Chunk; 96 97typedef enum { 98 DMENU_SHELL_ESCAPE, /* Fork a shell */ 99 DMENU_DISPLAY_FILE, /* Display a file's contents */ 100 DMENU_SUBMENU, /* Recurse into another menu */ 101 DMENU_SYSTEM_COMMAND, /* Run shell commmand */ 102 DMENU_SYSTEM_COMMAND_BOX, /* Same as above, but in prgbox */ 103 DMENU_SET_VARIABLE, /* Set an environment/system var */ 104 DMENU_SET_FLAG, /* Set flag in an unsigned int */ 105 DMENU_CALL, /* Call back a C function */ 106 DMENU_CANCEL, /* Cancel out of this menu */ 107 DMENU_NOP, /* Do nothing special for item */ 108} DMenuItemType; 109 110typedef struct _dmenuItem { 111 char *title; /* Our title */ 112 char *prompt; /* Our prompt */ 113 DMenuItemType type; /* What type of item we are */ 114 void *ptr; /* Generic data ptr */ 115 u_long parm; /* Parameter for above */ 116 Boolean disabled; /* Are we temporarily disabled? */ 117} DMenuItem; 118 119typedef struct _dmenu { 120 unsigned int options; /* What sort of menu we are */ 121 char *title; /* Our title */ 122 char *prompt; /* Our prompt */ 123 char *helpline; /* Line of help at bottom */ 124 char *helpfile; /* Help file for "F1" */ 125 DMenuItem items[0]; /* Array of menu items */ 126} DMenu; 127 128/* A sysconfig variable */ 129typedef struct _variable { 130 struct _variable *next; 131 char name[VAR_NAME_MAX]; 132 char value[VAR_VALUE_MAX]; 133} Variable; 134 135typedef enum { 136 DEVICE_TYPE_NONE, 137 DEVICE_TYPE_DISK, 138 DEVICE_TYPE_FLOPPY, 139 DEVICE_TYPE_NETWORK, 140 DEVICE_TYPE_CDROM, 141 DEVICE_TYPE_TAPE, 142 DEVICE_TYPE_ANY, 143} DeviceType; 144 145/* A "device" from sysinstall's point of view */ 146typedef struct _device { 147 char name[DEV_NAME_MAX]; 148 DeviceType type; 149 Boolean enabled; 150 int (*deviceInit)(void); 151 int (*deviceGet)(char *fname); 152 int (*deviceClose)(void); 153 void *devicePrivate; 154} Device; 155 156/* Some internal representations of partitions */ 157typedef enum { 158 PART_NONE, 159 PART_SLICE, 160 PART_SWAP, 161 PART_FILESYSTEM, 162 PART_FAT, 163} PartType; 164 165/* The longest newfs command we'll hand to system() */ 166#define NEWFS_CMD_MAX 256 167 168typedef struct _part_info { 169 Boolean newfs; 170 char mountpoint[FILENAME_MAX]; 171 char newfs_cmd[NEWFS_CMD_MAX]; 172} PartInfo; 173 174typedef int (*commandFunc)(char *key, void *data); 175 176 177/*** Externs ***/ 178extern int CpioFD; /* The file descriptor for our CPIO floppy */ 179extern int DebugFD; /* Where diagnostic output goes */ 180extern Boolean OnCDROM; /* Are we running off of a CDROM? */ 181extern Boolean OnSerial; /* Are we on a serial console? */ 182extern Boolean SystemWasInstalled; /* Did we install it? */ 183extern Boolean DialogActive; /* Is the dialog() stuff up? */ 184extern Boolean ColorDisplay; /* Are we on a color display? */ 185extern Boolean OnVTY; /* On a syscons VTY? */ 186extern Variable *VarHead; /* The head of the variable chain */ 187extern unsigned int Dists; /* Which distributions we want */ 188extern unsigned int SrcDists; /* Which src distributions we want */ 189extern unsigned int XF86Dists;/* Which XFree86 dists we want */ 190extern unsigned int XF86ServerDists; /* The XFree86 servers we want */ 191extern unsigned int XF86FontDists; /* The XFree86 fonts we want */ 192extern Device *Devices[]; /* The devices we have to work with */ 193 194/*** Prototypes ***/ 195 196/* command.c */ 197extern void command_clear(void); 198extern void command_sort(void); 199extern void command_execute(void); 200extern void command_shell_add(char *key, char *fmt, ...); 201extern void command_func_add(char *key, commandFunc func, void *data); 202 203/* decode.c */ 204extern DMenuItem *decode(DMenu *menu, char *name); 205extern Boolean dispatch(DMenuItem *tmp, char *name); 206extern Boolean decode_and_dispatch_multiple(DMenu *menu, char *names); 207 208/* devices.c */ 209extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)()); 210extern Device *deviceGetInfo(DeviceType which); 211 212/* disks.c */ 213extern int diskPartitionEditor(Disk *disk); 214 215/* dist.c */ 216extern int distSetDeveloper(char *str); 217extern int distSetXDeveloper(char *str); 218extern int distSetUser(char *str); 219extern int distSetXUser(char *str); 220extern int distSetMinimum(char *str); 221extern int distSetEverything(char *str); 222extern int distSetSrc(char *str); 223extern void distExtractAll(void); 224 225/* dmenu.c */ 226extern void dmenuOpen(DMenu *menu, int *choice, int *scroll, 227 int *curr, int *max); 228extern void dmenuOpenSimple(DMenu *menu); 229 230/* globals.c */ 231extern void globalsInit(void); 232 233/* install.c */ 234extern int installCustom(char *str); 235extern int installExpress(char *str); 236extern int installMaint(char *str); 237 238/* lang.c */ 239extern void lang_set_Danish(char *str); 240extern void lang_set_Dutch(char *str); 241extern void lang_set_English(char *str); 242extern void lang_set_French(char *str); 243extern void lang_set_German(char *str); 244extern void lang_set_Italian(char *str); 245extern void lang_set_Japanese(char *str); 246extern void lang_set_Norwegian(char *str); 247extern void lang_set_Russian(char *str); 248extern void lang_set_Spanish(char *str); 249extern void lang_set_Swedish(char *str); 250 251/* label.c */ 252extern void diskLabelEditor(char *str); 253 254/* makedevs.c (auto-generated) */ 255extern const char termcap_vt100[]; 256extern const char termcap_cons25[]; 257extern const char termcap_cons25_m[]; 258extern const char termcap_cons25r[]; 259extern const char termcap_cons25r_m[]; 260extern const char termcap_cons25l1[]; 261extern const char termcap_cons25l1_m[]; 262extern const u_char font_iso_8x14[]; 263extern const u_char font_cp850_8x14[]; 264extern const u_char font_koi8_r_8x14[]; 265extern const u_char koi8_r2cp866[]; 266 267/* media.c */ 268extern int mediaSetCDROM(char *str); 269extern int mediaSetFloppy(char *str); 270extern int mediaSetDOS(char *str); 271extern int mediaSetTape(char *str); 272extern int mediaSetFTP(char *str); 273extern int mediaSetFS(char *str); 274 275/* misc.c */ 276extern Boolean file_readable(char *fname); 277extern Boolean file_executable(char *fname); 278extern char *string_concat(char *p1, char *p2); 279extern char *string_prune(char *str); 280extern char *string_skipwhite(char *str); 281extern void safe_free(void *ptr); 282extern void *safe_malloc(size_t size); 283extern void *safe_realloc(void *orig, size_t size); 284extern char **item_add(char **list, char *item, int *curr, int *max); 285extern char **item_add_pair(char **list, char *item1, char *item2, 286 int *curr, int *max); 287extern void items_free(char **list, int *curr, int *max); 288 289/* msg.c */ 290extern void msgInfo(char *fmt, ...); 291extern void msgYap(char *fmt, ...); 292extern void msgWarn(char *fmt, ...); 293extern void msgDebug(char *fmt, ...); 294extern void msgError(char *fmt, ...); 295extern void msgFatal(char *fmt, ...); 296extern void msgConfirm(char *fmt, ...); 297extern void msgNotify(char *fmt, ...); 298extern int msgYesNo(char *fmt, ...); 299extern char *msgGetInput(char *buf, char *fmt, ...); 300 301/* system.c */ 302extern void systemInitialize(int argc, char **argv); 303extern void systemShutdown(void); 304extern void systemWelcome(void); 305extern int systemExecute(char *cmd); 306extern int systemShellEscape(void); 307extern int systemDisplayFile(char *file); 308extern char *systemHelpFile(char *file, char *buf); 309extern void systemChangeFont(const u_char font[]); 310extern void systemChangeLang(char *lang); 311extern void systemChangeTerminal(char *color, const u_char c_termcap[], 312 char *mono, const u_char m_termcap[]); 313extern void systemChangeScreenmap(const u_char newmap[]); 314extern int vsystem(char *fmt, ...); 315 316/* termcap.c */ 317extern int set_termcap(void); 318 319/* variables.c */ 320extern void variable_set(char *var); 321extern void variable_set2(char *name, char *value); 322 323/* wizard.c */ 324extern void slice_wizard(Disk *d); 325 326#endif 327/* _SYSINSTALL_H_INCLUDE */ 328