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 >
C/C++ Source or Header  |  1992-08-19  |  4KB  |  123 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 J Barrett, barrett@cs.umass.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_OLD    "RAD:,DF0:,DF1:"  /* For ADos 1.3 only. */
  31.  
  32. /* Macros dealing with output. */
  33.  
  34. #define    HI_ON            "\x9b" "2m"    /* Turn on highlighting. */
  35. #define    HI_OFF            "\x9b" "22m"    /* Turn off highlighting. */
  36. #define    NONE            "--"        /* Drive is empty. */
  37. #define    NO_DRIVE        (-1L)        /* Volume does not exist. */
  38.  
  39. /* Macros representing default and maximum sizes of things. */
  40.  
  41. #define    DEFAULT_MEMORY_LIMIT    BUFSIZ    /* Memory allocated for output. */
  42. #define    DEFAULT_SPACING        10    /* Space to print free memory. */
  43. #define    DEFAULT_NAME_LEN    4    /* Default length of a volume name. */
  44. #define MAX_NAME_LEN        255    /* Maximum length of a volume name. */
  45.  
  46. /* Macros for MakeFormatString(). */
  47.  
  48. #define    CR            1    /* Print a carriage return. */
  49. #define    NO_CR            0    /* Do not print a carriage return. */
  50. #define    FORMAT_LENGTH        100    /* Space to store a format string. */
  51.  
  52. /* Macros for command-line options. */
  53.  
  54. #define    FLAG_BLOCKS        (1     )
  55. #define    FLAG_REQUESTORS        (1 << 1)
  56. #define    FLAG_MALLOC        (1 << 2)
  57. #define    FLAG_VOLUME_NAME_LEN    (1 << 3)
  58.  
  59. #define    OPT_BLOCKS        'b'
  60. #define    OPT_VOLUME_NAME_LEN    'l'
  61. #define    OPT_REQUESTORS        'r'
  62. #define    OPT_MALLOC        'm'
  63. #define    OPT_UNKNOWN        '?'
  64.  
  65. #define    HELP_ARG        "?"
  66.  
  67. /* Human-readable names for our error codes. */
  68.  
  69. #define    NO_ERROR        0
  70. #define    ERROR_TOO_SMALL        1
  71. #define    ERROR_CANT_MALLOC    2
  72. #define    ERROR_FORMAT_STRING    3
  73. #define    ERROR_IMPOSSIBLE    4
  74. #define    ERROR_INFO        5
  75. #define    ERROR_DOSLIST        6
  76.  
  77. typedef    int ERROR;
  78.  
  79. /* Miscellaneous macros. */
  80.  
  81. #define    EQUAL            !strcmp
  82.  
  83. /* Our global variables. */
  84.  
  85. long    flags;            /* Bit mask for user's options. */
  86. int    memSize;        /* Maximum number of bytes in the output. */
  87. int    volumeNameLen;        /* Length of longest volume name. */
  88.  
  89. /* Defines, global variables, and function prototype for getopt(). */
  90.  
  91. #define    OPTSTRING        "bl:rm:"
  92. extern char *optarg;
  93. extern int optind, opterr, optopt;
  94. int getopt(int argc, char *argv[], const char *optString);
  95.  
  96. /* Function prototypes, in alphabetical order. */
  97.  
  98. long    AvailSpace(struct FileLock *disk);    
  99. void    CheckVolumeNameLen(int *nameLen);
  100. int    Concat(char s1[], char s2[]);
  101. void    DisableRequestors(void);
  102. void    DoFree(int argc, char *argv[]);
  103. void    DoNormalDrive(char *volume, char out[]);
  104. void    EnableRequestors(void);
  105. void    ErrorMsg(ERROR err);
  106. void    ExitCleanly(ERROR error, int code);
  107. void    FreeFromArgs(char *argv[], long chip, long fast);
  108. void    FreeUsingDosList(long chipRam, long fastRam);
  109. void    FreeUsingEnv(long chip, long fast);
  110. char *    GetEnv(char *envVariable);
  111. void    GetFreeRam(long *chipRam, long *fastRam);
  112. long    GetMem(char *drive);
  113. int    GetOptions(int argc, char *argv[]);
  114. void    InitializeGlobals(void);
  115. void    MakeFormatString(char *volume, char format[], char d_or_s, int cr);
  116. char *    MakeOutArray(void);
  117. void    ShowFree(char *volume, long chipRam, long fastRam, char out[]);
  118. void    ShowFreeRam(long chip, long fast, char out[]);
  119. int    StrCaseCmp(char *s1, char *s2);
  120. char *    TheEnvValue(BPTR fileh);
  121. void    Usage(char *prog);
  122. int    ValidDriveName(char *drive);
  123.