/*************************************************************************** * free.h: Header file with definitions. * * Part of... * * FREE: Display free space on your disk volumes. * Author: Daniel Jay Barrett, barrett@cs.jhu.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 #include #include #include #include #include #include #include #include /* 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 "RAD:,DF0:,DF1:" /* Macros dealing with output. */ #define HI_ON "\033[33m" /* Turn on highlighting. */ #define HI_OFF "\033[0m" /* Turn off highlighting. */ #define NONE "--" /* Drive is empty. */ #define NO_DRIVE (-1L) /* Volume does not exist. */ #define VERSION "1.01" /* Version of this program. */ /* 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 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(struct Process **proc, APTR *oldWindowPtr); void DoFree(int argc, char *argv[], char **out); void DoNormalDrive(char *volume, char out[]); void EnableRequestors(struct Process *proc, APTR oldWindowPtr); void ErrorMsg(ERROR err); void ExitCleanly(char *arr, ERROR error, int code); void FreeFromArgs(char *argv[], long chip, long fast, char out[]); void FreeUsingEnv(long chip, long fast, char out[]); 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);