/*
 *   Copyright (c) 1996 David Parsons. All rights reserved.
 *   
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *  3. All advertising materials mentioning features or use of this
 *     software must display the following acknowledgement:
 *     
 *   This product includes software developed by David Parsons
 *   (orc@pell.chi.il.us)
 *
 *  4. My name may not be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *     
 *  THIS SOFTWARE IS PROVIDED BY DAVID PARSONS ``AS IS'' AND ANY
 *  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 *  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
 *  PARSONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 *  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 *  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 *  THE POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef INSTALLER_UTIL_D
#define INSTALLER_UTIL_D

#include <unistd.h>
#include <ndialog.h>
#include <stdarg.h>

#include "part.h"
#include "constants.h"

extern int needtopartition;
extern void *mdesc;		/* install media descriptor */

void describe(char *myname, char *description);
void spawn(int dienow, char *title, char *pgm, ...);
void run(int dienow, char *pgm, ...);
pid_t syslogger();
void stfu();
void falloverdead();
void die(char *reason, ...);
void Error(char *fmt, ...);
int checkfor(char *device, char *description, void (*fail)(char *, ...));
void copyfile(char *from, char *to, int extraflags);
void copykernel();
extern int sniff();
void give_inventory(void **mdescp);
extern char *Size(unsigned long size);

extern LIA disklist;
extern LIA get_disk_list(int diskC);
extern void get_par_list(LIA, int*, struct raw_par**);
extern void get_disk_par(char*, int*, struct raw_par**);

extern int okaydone(void*,void*);

extern int mountpar(int autodisk);
void unfslist(struct raw_par *p);
int dopartition(char *device, int isroot, int withdosC);
int makemountdir(char *dir);
int checkDevList(char *dev, char *mount);
void addDevToList(char *,char *,enum partype,int,int);
void sortDevList();

void addToMenu(char *item, char *desc, char ***menu, int *nrmenu);
void deleteMenu(char **menu, int nrmenu);


void start_gpm();		/* start GPM with current mouse parms */
void stop_gpm();		/* stop a GPM started by start_gpm */
void mouse_reset();		/* restart dialog with the current mouse */

pid_t mini_init();		/* start a bunch of processes and keep */
				/* them running */
extern pid_t mini_init_pid;	/* process id of above */
extern char *av0;

#if 0
#define INSTALLER	"Mastodon"
#else
#define INSTALLER	0
#endif
#define	SWAPMEGS	128


int howtoinstall(int withdosC);	/* ask about how we're going to install */
				/* the system */

/*
 * Installation methods, from howtoinstall()
 */

#define WITHDOS		0	/* Standard installation, preserving C: */
#define STANDARD	1	/* Standard installation, blowing away C: */
#define CUSTOM		2	/* Custom installation */
#define CUSTOM_AUTOROOT	3	/* Custom installation, but with the root */
				/* disk autoconfigured */
#define CUSTOM_AUTODOS	4	/* Custom installation, but preserving C: */

/*
 * Vermin
 */
char *detectPS2Mouse();		/* detect a PS2 mouse and return the port it's
				 * attached to.
				 */
int detectSerialMouse(char*);	/* try to detect a mouse on a given port */
void write_mouse_conf(int, char*);	/* write the mouse configuration */

/*
 * Mice that we know about
 */
#define NO_MOUSE	0
#define MS_MOUSE	1
#define LOGITECH_MOUSE	2
#define PS2_MOUSE	3

extern int   mousetype;		/* what type of mouse do we have? */
extern char *mousedev;		/* and where did we detect it? */
extern char *mousenames[];	/* what these mice are called */
extern char *gpmnames[];	/* and what gpm knows them as */
extern int   mouse_was_reset;	/* flag for reset_mouse */

extern unsigned long int memsize;	/* how much memory did Linux detect? */
extern unsigned int total_memory;	/* how much memory did the user specify? */

char *__progname;		/* aka argv[0] */

/*
 * Disks
 */
struct idiskinfo {
    char *device;
    int  flags;
#define	ID_EXIST	(1<<0)		/* does this exist? */
#define ID_CHECKED	(1<<1)		/* have we checked this out? */
#define	ID_SCSI		(1<<2)		/* is this scsi or ide? */
#define	ID_CDROM	(1<<3)		/* is this removable m? */
#define	ID_BOOTABLE	(1<<4)		/* can we boot off this? */
#define ID_REMOVABLE	(1<<5)		/* removable media? */
    unsigned long size;			/* how big is it? */
    int order;				/* which order is it */
};

extern struct idiskinfo Disk[];		/* table of disks we might have */
extern int              NrDisk;		/* how many disks in the table */
extern struct idiskinfo *InstallMedia;	/* table of CDs, zip drives, etc */
extern int		NrMedia;	/* # of CDs, zip drives, etc */

extern int		nrdisks;	/* how many disks do we have? */
extern struct par *	mountpoints;	/* desired mountable partitions */
extern int		nrmountpoints;	/* how many of them? */
extern int		diskC;		/* pointer to first disk */
extern unsigned long	diskCsize;	/* diskC size in Kbytes */
extern int		withdosC;	/* install with C: being a dos disk */

extern void domount(int);
extern void dounmount();
extern void progress_message(int, char*, ...);

/*
 * pcmcia card services
 */
int start_pcmcia();


#endif/*INSTALLER_UTIL_D*/
