sade.h revision 8208
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.3 1995/04/29 19:33:05 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/* variable limits */ 62#define VAR_NAME_MAX 128 63#define VAR_VALUE_MAX 1024 64 65/* device limits */ 66#define DEV_NAME_MAX 128 67 68 69/*** Types ***/ 70typedef unsigned int Boolean; 71 72typedef enum { 73 DMENU_SHELL_ESCAPE, /* Fork a shell */ 74 DMENU_DISPLAY_FILE, /* Display a file's contents */ 75 DMENU_SUBMENU, /* Recurse into another menu */ 76 DMENU_SYSTEM_COMMAND, /* Run shell commmand */ 77 DMENU_SYSTEM_COMMAND_BOX, /* Same as above, but in prgbox */ 78 DMENU_SET_VARIABLE, /* Set an environment/system var */ 79 DMENU_CALL, /* Call back a C function */ 80 DMENU_CANCEL, /* Cancel out of this menu */ 81 DMENU_NOP, /* Do nothing special for item */ 82} DMenuItemType; 83 84typedef struct _dmenuItem { 85 char *title; /* Our title */ 86 char *prompt; /* Our prompt */ 87 DMenuItemType type; /* What type of item we are */ 88 void *ptr; /* Generic data ptr */ 89 Boolean disabled; /* Are we temporarily disabled? */ 90} DMenuItem; 91 92typedef struct _dmenu { 93 unsigned int options; /* What sort of menu we are */ 94 char *title; /* Our title */ 95 char *prompt; /* Our prompt */ 96 char *helpline; /* Line of help at bottom */ 97 char *helpfile; /* Help file for "F1" */ 98 DMenuItem items[0]; /* Array of menu items */ 99} DMenu; 100 101/* A sysconfig variable */ 102typedef struct _variable { 103 struct _variable *next; 104 char name[VAR_NAME_MAX]; 105 char value[VAR_VALUE_MAX]; 106} Variable; 107 108typedef enum { 109 DEVICE_TYPE_ANY, 110 DEVICE_TYPE_DISK, 111 DEVICE_TYPE_FLOPPY, 112 DEVICE_TYPE_NETWORK, 113 DEVICE_TYPE_CDROM, 114 DEVICE_TYPE_TAPE, 115 DEVICE_TYPE_SERIAL, 116 DEVICE_TYPE_PARALLEL, 117} DeviceType; 118 119/* A "device" from sysinstall's point of view */ 120typedef struct _device { 121 char name[DEV_NAME_MAX]; 122 DeviceType type; 123} Device; 124 125 126/*** Externs ***/ 127extern int CpioFD; /* The file descriptor for our CPIO floppy */ 128extern int DebugFD; /* Where diagnostic output goes */ 129extern Boolean OnCDROM; /* Are we running off of a CDROM? */ 130extern Boolean OnSerial; /* Are we on a serial console? */ 131extern Boolean DialogActive; /* Is the dialog() stuff up? */ 132extern Variable *VarHead; /* The head of the variable chain */ 133 134/* All the menus to which forward references exist */ 135extern DMenu MenuDocumenation, MenuInitial, MenuLanguage; 136 137 138/*** Prototypes ***/ 139 140/* globals.c */ 141extern void globalsInit(void); 142 143/* install.c */ 144extern int installCustom(char *str); 145extern int installExpress(char *str); 146extern int installMaint(char *str); 147extern int installSetDeveloper(char *str); 148extern int installSetXDeveloper(char *str); 149extern int installSetUser(char *str); 150extern int installSetXUser(char *str); 151extern int installSetMinimum(char *str); 152extern int installSetEverything(char *str); 153 154/* system.c */ 155extern void systemInitialize(int argc, char **argv); 156extern void systemShutdown(void); 157extern void systemWelcome(void); 158extern int systemExecute(char *cmd); 159extern int systemShellEscape(void); 160extern int systemDisplayFile(char *file); 161extern char *systemHelpFile(char *file, char *buf); 162 163/* dmenu.c */ 164extern void dmenuOpen(DMenu *menu, int *choice, int *scroll, 165 int *curr, int *max); 166 167/* misc.c */ 168extern Boolean file_readable(char *fname); 169extern Boolean file_executable(char *fname); 170extern char *string_concat(char *p1, char *p2); 171extern char *string_prune(char *str); 172extern char *string_skipwhite(char *str); 173extern void safe_free(void *ptr); 174extern void *safe_malloc(size_t size); 175extern char **item_add(char **list, char *item, int *curr, int *max); 176extern char **item_add_pair(char **list, char *item1, char *item2, 177 int *curr, int *max); 178extern void items_free(char **list, int *curr, int *max); 179 180/* termcap.c */ 181extern int set_termcap(void); 182 183/* msg.c */ 184extern void msgInfo(char *fmt, ...); 185extern void msgWarn(char *fmt, ...); 186extern void msgError(char *fmt, ...); 187extern void msgFatal(char *fmt, ...); 188extern void msgConfirm(char *fmt, ...); 189extern int msgYesNo(char *fmt, ...); 190 191/* media.c */ 192extern int mediaSetCDROM(char *str); 193extern int mediaSetFloppy(char *str); 194extern int mediaSetDOS(char *str); 195extern int mediaSetTape(char *str); 196extern int mediaSetFTP(char *str); 197extern int mediaSetFS(char *str); 198 199/* devices.c */ 200extern Device *device_get_all(DeviceType type, int *ndevs); 201extern int device_slice_disk(char *disk); 202 203/* variables.c */ 204extern void variable_set(char *var); 205extern void variable_set2(char *name, char *value); 206 207#endif 208/* _SYSINSTALL_H_INCLUDE */ 209