home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff388.lzh / Free / free.h < prev    next >
C/C++ Source or Header  |  1990-10-23  |  4KB  |  121 lines

  1. /***************************************************************************
  2.  * free.h:    Header file with definitions.
  3.  *
  4.  * Part of...
  5.  *
  6.  *    FREE:    Display free space on your disk volumes.
  7.  *        Author:  Daniel Jay Barrett, barrett@cs.jhu.edu.
  8.  *
  9.  * This program is Freely Distributable.  Make all the copies you want
  10.  * and give them away.  Use this code in any way you like.
  11. ***************************************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <ctype.h>
  17. #include <libraries/dos.h>
  18. #include <libraries/dosextens.h>
  19. #include <exec/types.h>
  20. #include <exec/memory.h>
  21. #include <functions.h>
  22.  
  23.  
  24. /* Macros dealing with environment variables. */
  25.  
  26. #define    ENV_SEPARATOR        ","
  27. #define ENV_VARIABLE        "FREE_DRIVES"
  28. #define    ENV_NAME_LENGTH        256
  29. #define    VOLUME_END_CHAR        ':'
  30. #define    DEFAULT_VOLUMES        "RAD:,DF0:,DF1:"
  31.  
  32. /* Macros dealing with output. */
  33.  
  34. #define    HI_ON            "\033[33m"    /* Turn on highlighting. */
  35. #define    HI_OFF            "\033[0m"    /* Turn off highlighting. */
  36. #define    NONE            "--"        /* Drive is empty. */
  37. #define    NO_DRIVE        (-1L)        /* Volume does not exist. */
  38. #define    VERSION            "1.01"        /* Version of this program. */
  39.  
  40. /* Macros representing default and maximum sizes of things. */
  41.  
  42. #define    DEFAULT_MEMORY_LIMIT    BUFSIZ    /* Memory allocated for output. */
  43. #define    DEFAULT_SPACING        10    /* Space to print free memory. */
  44. #define    DEFAULT_NAME_LEN    4    /* Default length of a volume name. */
  45. #define MAX_NAME_LEN        255    /* Maximum length of a volume name. */
  46.  
  47. /* Macros for MakeFormatString(). */
  48.  
  49. #define    CR            1    /* Print a carriage return. */
  50. #define    NO_CR            0    /* Do not print a carriage return. */
  51. #define    FORMAT_LENGTH        100    /* Space to store a format string. */
  52.  
  53. /* Macros for command-line options. */
  54.  
  55. #define    FLAG_BLOCKS        (1     )
  56. #define    FLAG_REQUESTORS        (1 << 1)
  57. #define    FLAG_MALLOC        (1 << 2)
  58. #define    FLAG_VOLUME_NAME_LEN    (1 << 3)
  59.  
  60. #define    OPT_BLOCKS        'b'
  61. #define    OPT_VOLUME_NAME_LEN    'l'
  62. #define    OPT_REQUESTORS        'r'
  63. #define    OPT_MALLOC        'm'
  64. #define    OPT_UNKNOWN        '?'
  65.  
  66. #define    HELP_ARG        "?"
  67.  
  68. /* Human-readable names for our error codes. */
  69.  
  70. #define    NO_ERROR        0
  71. #define    ERROR_TOO_SMALL        1
  72. #define    ERROR_CANT_MALLOC    2
  73. #define    ERROR_FORMAT_STRING    3
  74. #define    ERROR_IMPOSSIBLE    4
  75.  
  76. typedef    int ERROR;
  77.  
  78. /* Miscellaneous macros. */
  79.  
  80. #define    EQUAL            !strcmp
  81.  
  82. /* Our global variables. */
  83.  
  84. long    flags;            /* Bit mask for user's options. */
  85. int    memSize;        /* Maximum number of bytes in the output. */
  86. int    volumeNameLen;        /* Length of longest volume name. */
  87.  
  88. /* Defines, global variables, and function prototype for getopt(). */
  89.  
  90. #define    OPTSTRING        "bl:rm:"
  91. extern char *optarg;
  92. extern int optind, opterr, optopt;
  93. int getopt(int argc, char *argv[], const char *optString);
  94.  
  95. /* Function prototypes, in alphabetical order. */
  96.  
  97. long    AvailSpace(struct FileLock *disk);    
  98. void    CheckVolumeNameLen(int *nameLen);
  99. int    Concat(char s1[], char s2[]);
  100. void    DisableRequestors(struct Process **proc, APTR *oldWindowPtr);
  101. void    DoFree(int argc, char *argv[], char **out);
  102. void    DoNormalDrive(char *volume, char out[]);
  103. void    EnableRequestors(struct Process *proc, APTR oldWindowPtr);
  104. void    ErrorMsg(ERROR err);
  105. void    ExitCleanly(char *arr, ERROR error, int code);
  106. void    FreeFromArgs(char *argv[], long chip, long fast, char out[]);
  107. void    FreeUsingEnv(long chip, long fast, char out[]);
  108. char *    GetEnv(char *envVariable);
  109. void    GetFreeRam(long *chipRam, long *fastRam);
  110. long    GetMem(char *drive);
  111. int    GetOptions(int argc, char *argv[]);
  112. void    InitializeGlobals(void);
  113. void    MakeFormatString(char *volume, char format[], char d_or_s, int cr);
  114. char *    MakeOutArray(void);
  115. void    ShowFree(char *volume, long chipRam, long fastRam, char out[]);
  116. void    ShowFreeRam(long chip, long fast, char out[]);
  117. int    StrCaseCmp(char *s1, char *s2);
  118. char *    TheEnvValue(BPTR fileh);
  119. void    Usage(char *prog);
  120. int    ValidDriveName(char *drive);
  121.