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