home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
700-799
/
ff713.lha
/
free
/
source
/
free.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-19
|
4KB
|
123 lines
/***************************************************************************
* free.h: Header file with definitions.
*
* Part of...
*
* FREE: Display free space on your disk volumes.
* Author: Daniel J Barrett, barrett@cs.umass.edu.
*
* This program is Freely Distributable. Make all the copies you want
* and give them away. Use this code in any way you like.
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <functions.h>
/* Macros dealing with environment variables. */
#define ENV_SEPARATOR ","
#define ENV_VARIABLE "FREE_DRIVES"
#define ENV_NAME_LENGTH 256
#define VOLUME_END_CHAR ':'
#define DEFAULT_VOLUMES_OLD "RAD:,DF0:,DF1:" /* For ADos 1.3 only. */
/* Macros dealing with output. */
#define HI_ON "\x9b" "2m" /* Turn on highlighting. */
#define HI_OFF "\x9b" "22m" /* Turn off highlighting. */
#define NONE "--" /* Drive is empty. */
#define NO_DRIVE (-1L) /* Volume does not exist. */
/* Macros representing default and maximum sizes of things. */
#define DEFAULT_MEMORY_LIMIT BUFSIZ /* Memory allocated for output. */
#define DEFAULT_SPACING 10 /* Space to print free memory. */
#define DEFAULT_NAME_LEN 4 /* Default length of a volume name. */
#define MAX_NAME_LEN 255 /* Maximum length of a volume name. */
/* Macros for MakeFormatString(). */
#define CR 1 /* Print a carriage return. */
#define NO_CR 0 /* Do not print a carriage return. */
#define FORMAT_LENGTH 100 /* Space to store a format string. */
/* Macros for command-line options. */
#define FLAG_BLOCKS (1 )
#define FLAG_REQUESTORS (1 << 1)
#define FLAG_MALLOC (1 << 2)
#define FLAG_VOLUME_NAME_LEN (1 << 3)
#define OPT_BLOCKS 'b'
#define OPT_VOLUME_NAME_LEN 'l'
#define OPT_REQUESTORS 'r'
#define OPT_MALLOC 'm'
#define OPT_UNKNOWN '?'
#define HELP_ARG "?"
/* Human-readable names for our error codes. */
#define NO_ERROR 0
#define ERROR_TOO_SMALL 1
#define ERROR_CANT_MALLOC 2
#define ERROR_FORMAT_STRING 3
#define ERROR_IMPOSSIBLE 4
#define ERROR_INFO 5
#define ERROR_DOSLIST 6
typedef int ERROR;
/* Miscellaneous macros. */
#define EQUAL !strcmp
/* Our global variables. */
long flags; /* Bit mask for user's options. */
int memSize; /* Maximum number of bytes in the output. */
int volumeNameLen; /* Length of longest volume name. */
/* Defines, global variables, and function prototype for getopt(). */
#define OPTSTRING "bl:rm:"
extern char *optarg;
extern int optind, opterr, optopt;
int getopt(int argc, char *argv[], const char *optString);
/* Function prototypes, in alphabetical order. */
long AvailSpace(struct FileLock *disk);
void CheckVolumeNameLen(int *nameLen);
int Concat(char s1[], char s2[]);
void DisableRequestors(void);
void DoFree(int argc, char *argv[]);
void DoNormalDrive(char *volume, char out[]);
void EnableRequestors(void);
void ErrorMsg(ERROR err);
void ExitCleanly(ERROR error, int code);
void FreeFromArgs(char *argv[], long chip, long fast);
void FreeUsingDosList(long chipRam, long fastRam);
void FreeUsingEnv(long chip, long fast);
char * GetEnv(char *envVariable);
void GetFreeRam(long *chipRam, long *fastRam);
long GetMem(char *drive);
int GetOptions(int argc, char *argv[]);
void InitializeGlobals(void);
void MakeFormatString(char *volume, char format[], char d_or_s, int cr);
char * MakeOutArray(void);
void ShowFree(char *volume, long chipRam, long fastRam, char out[]);
void ShowFreeRam(long chip, long fast, char out[]);
int StrCaseCmp(char *s1, char *s2);
char * TheEnvValue(BPTR fileh);
void Usage(char *prog);
int ValidDriveName(char *drive);