/*static char *SCCSID = "@(#)ldefs.h	6.2 91/09/08";*/
/*static char *SCCSID = "@(#)ldefs.h	6.2 91/09/08";*/
/***	LDEFS.H - Definitions of numeric values and simple types.
 *
 *	Format
 *	Michael Walma
 *	Copyright March 1988, Microsoft Corp.
 *	March 28 1988
 *
 *	Modification History:
 */

#define PAWc	hotfix_to_1sector
#define INCL_DOSERRORS

#include <os2def.h>
#include <bse.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <malloc.h>
#include <comsub.h>
#include <defs.h>
#include <gdata.h>
#include <pr_com.h>
#include <basemid.h>
#include <stduip.h>

/*
 * Error codes used by exit_error().
 */

#define ARG_ERROR		0
#define OPEN_ERROR		1
#define FORMAT_ERROR		2
#define INSTALL_ERROR		3
#define INFO_ERROR		4
#define INSUFFICENT_MEM 	5
#define INTERNAL_ERROR		6
#define IS_FLOPPY_ERROR 	7
#define DRIVE_REQD_ERROR	8
#define TWO_DRIVES_ERROR	9
#define WRONG_LABEL_ERROR	10
#define TOO_MANY_MOUNTS_ERROR	11

/*
 * Program return codes (passed to exit()).
 *
 * Codes are:
 *	SUCCESS_CODE	-- formatting completed OK.
 *	TERMINATE_CODE	-- the user typed Ctrl-Break while formatting.
 *	ERROR_CODE	-- an error occurred, or the user did not give
 *			   the previous volume label as a "password".
 *	NOTHANKS_CODE	-- the user said "no, don't format" in response to
 *			   the "data will be destroyed" warning.
 */

#define SUCCESS_CODE	0
#define TERMINATE_CODE	3
#define ERROR_CODE	4
#define NOTHANKS_CODE	5

/*
 * The maximum legal error code.
 */

#define MAX_ERROR_CODE	11

/*
 * Definitions for setting device parameters.  REVERT is used to get
 * device information from the media.  CHANGE is used to set parameters
 * to a block of supplied information.
 */

#define SET_REVERT	0x00
#define SET_CHANGE	0x02

/*
 * Number of bitmap pointers in an indirect block
 */

#define MAPS_PER_INDIRECT	((SPB) * (SECSIZE) / sizeof (ULONG))

/*
 * Used in formatting IOCTL.
 */

#define BYTES_PER_SECTOR_CODE	2
#define PERCENT_RES		1

/*
 * Boot record signature.
 */

#define SIGNATURE_VAL	0xaa55U

/*
 * JMP instruction to boot code.  Necessary for the OS to recognize the disk.
 */

#define JMP_STRING	"\x0eb\x029\x090"

/*
 * First part of boot record Boot_OEM string.
 */

#define VERSION_PREFIX		"OS2 "

/*
 * Code for hard disk returned by get parameters IOCTL.
 */

#define HARD_DISK	5

/*
 * Codes used in boot record.
 */

#define FIXED		0x80
#define REMOVABLE	0x00

/*
 * Boot signatures in boot record.
 */

#ifdef	V12
#define NEW_BOOT	41
#else
#define NEW_BOOT	40
#endif

/*
 * The attribute flag for a directory entry which points to a subdirectory.
 * Used when building the "." and ".." entries in the root directory.
 */

#define dir_attr	0x10

/*
 * Macros used to deallocate normal and huge pointers.
 */

#define FREE_HUGE(p) if (p) hfree (p);
#define FREE_BLOCK(p) if (p) free (p);

/*
 * Maximum number of characters in a volume label.
 */

#define VOL_LABEL_SIZE	11

/*
 * Partition table ID for IFS partitions.
 */

#define F12_PART	1
#define F16_PART	4
#define BIG_PART	6
#define IFS_PART	7

/*
 * Pipe Manager Macros
 *
 */

#define SYSTEM_MSG	    SUI_MSGTYPE_SYSTEM_MESSAGE
#define PERCENT_DONE_MSG    SUI_MSGTYPE_PERCENT_DONE
#define END_OF_DATA_MSG     SUI_MSGTYPE_END_OF_DATA

extern void FMT_COMPUTMSG (              //PCR PM FRONT END
  USHORT  msgtype,                       //PCR PM FRONT END
  CHAR    **ivtable,                     //PCR PM FRONT END
  USHORT  ivcount,                       //PCR PM FRONT END
  USHORT  message_number,                //PCR PM FRONT END
  CHAR    *message_file_name,            //PCR PM FRONT END
  USHORT  device_type,                   //PCR PM FRONT END
  USHORT  response_type,                 //PCR PM FRONT END
  CHAR    *key_buff,                     //PCR PM FRONT END
  USHORT  key_buff_len);                 //PCR PM FRONT END


/*
 * Message ID numbers for all messages produced by FORMAT.  These are
 * for messages defined in FORMAT.MSG -- they do not match messages in
 * OSO001.MSG (the system message file).
 */

#define MSGFILENAME		"OSO001.MSG"		/* Msg File Name    */
#define FMT_ARG_ERROR_STR	MSG_HPFS_FORMAT_PARM_ERROR	/* "Argument error" */
#define FMT_OPEN_ERROR_STR	MSG_HPFS_DISK_ALREADY_INUSE	/* "Open error" */
#define FMT_FORMAT_ERROR_STR	MSG_HPFS_CANNOT_FORMAT_DISK	/* "Format error" */
#define FMT_INSTALL_ERROR_STR	MSG_HPFS_CANNOT_COPY_SYS_DATA	/* "Error installing file system" */
#define FMT_INFO_ERROR_STR	MSG_HPFS_FORMAT_NOT_DONE	/* "Info error" */
#define FMT_INSUFF_MEM_STR	MSG_HPFS_FMT_NOT_ENOUGH_MEM	/* "Insufficent memory" */
#define FMT_OS_ERROR_STR	MSG_HPFS_FORMAT_NOT_DONE	/* "Error in OS" */
#define FMT_FLOPPY_ERROR_STR	MSG_HPFS_SPECIFY_FIXDSK 	/* "...no removable media" */
#define FMT_DRIVE_REQD_STR	MSG_HPFS_SPECIFY_DRIVE_LETTER	/* "Drive name required" */
#define FMT_TWO_DRIVES_STR	MSG_HPFS_SPECIFY_ONE_DRIVE	/* "Specify only one drive letter" */
#define FMT_UNKNOWN_ERROR_STR	MSG_HPFS_UNKNOWN_ERR_NO_FORMAT	/* "Unknown error" */
#define FMT_ILLEGAL_ARG_STR	MSG_HPFS_FORMAT_PARM_ERROR	/* "Illegal argument" */
#define FMT_WRONG_LABEL_STR	MSG_HPFS_WRONG_VOLUME_LABEL	/* "Incorrect volume label entered" */

/*  BUGBUG--where's this equate?  */
/*  #define FMT_TOO_MANY_MOUNTS_STR MSG_HPFS_FMAT_TOO_MANY_DRS	 */
#define FMT_TOO_MANY_MOUNTS_STR 637	/* too many FORMAT commands already running executing...PTR B706510 */

#define FMT_USAGE_STR		MSG_HPFS_SYNTAX_HELP	/* "Usage..." */

#define FMT_FORMATTING_STR	MSG_HPFS_DISK_FORMATING /* "Formatting..." */
#define FMT_FORMAT_COMPL_STR	MSG_HPFS_FORMATTING_COMPLETE	/* "Format complete" */
#define FMT_BYTES_ON_DISK_STR	MSG_HPFS_TOTAL_DISK_SPACE	/* "nnnnnnnn bytes on disk" */
#define FMT_BAD_BYTES_STR	MSG_HPFS_BAD_BLOCKS		/* "nnnnnnnn bytes in bad blocks" */
#define FMT_BYTES_AVAIL_STR	MSG_HPFS_DISK_SPACE_AVAIL	/* "nnnnnnnn bytes available" */
#define FMT_PERCENT_DONE_STR	MSG_HPFS_SPACE_FORMATTED	/* "nn% of disk formatted" */

#define FMT_LABEL_PROMPT_STR	MSG_HPFS_TYPE_VOLUME_LABEL	/* "Enter volume label..." */

#define FMT_ILLEGAL_CHAR_STR	MSG_HPFS_INVALID_VOLUME_CHAR	/* "Illegal character" */
#define FMT_LABEL_TOO_LARGE_STR MSG_HPFS_VOL_LABEL_LONG 	/* "Label too large" */

#define FMT_REALLY_FORMAT_STR	MSG_HPFS_FORMAT_YES_NO		/* "Warning!  The data..." */
#define FMT_BAD_SYSTEM_BLOCK_STR MSG_HPFS_BAD_BLOCKS_CRIT_AREA	/* "Bad block in system area" */
#define FMT_CUR_LABEL_STR	MSG_HPFS_TYPE_CUR_VOLUME_LABEL	/* "Enter the current label..." */
#define FMT_HPFS_NOT_LOADED_STR MSG_HPFS_DRIVER_NOT_LOADED	/* "HPFS not loaded, can't format" */


/*  BUGBUG--where's this equate?  */
/* #define FMT_CANT_FIND_CONFIG_STR MSG_HPFS_CANNOT_ACCESS_CONFIG */
#define FMT_CANT_FIND_CONFIG_STR 630
