home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / Chapter9 / cmd32 / Globals.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-29  |  7.6 KB  |  355 lines

  1. /****************************************************************/
  2. /*                                */
  3. /*                globals.h                */
  4. /*                                */
  5. /*           Global data structures and declarations        */
  6. /*                                */
  7. /*             Copyright (c) 2000            */
  8. /*               Pasquale J. Villani            */
  9. /*            All Rights Reserved            */
  10. /*                                */
  11. /* This file is part of CMD32.                    */
  12. /*                                */
  13. /* CMD32 is free software; you can redistribute it and/or    */
  14. /* modify it under the terms of the GNU General Public License    */
  15. /* as published by the Free Software Foundation; either version    */
  16. /* 2, or (at your option) any later version.            */
  17. /*                                */
  18. /* CMD32 is distributed in the hope that it will be useful, but    */
  19. /* WITHOUT ANY WARRANTY; without even the implied warranty of    */
  20. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See    */
  21. /* the GNU General Public License for more details.        */
  22. /*                                */
  23. /* You should have received a copy of the GNU General Public    */
  24. /* License along with CMD32; see the file COPYING.  If not,    */
  25. /* write to the Free Software Foundation, 675 Mass Ave,        */
  26. /* Cambridge, MA 02139, USA.                    */
  27. /****************************************************************/
  28.  
  29. /* $Logfile$ */
  30.  
  31. /* $Log$
  32.  */
  33. /* $EndLog$ */
  34.  
  35. #ifndef _GLOBALS_H
  36. #define _GLOBALS_H
  37.  
  38. #ifdef MAIN
  39. # ifdef VERSION_STRINGS
  40. static BYTE *Globals_hRcsId = "$Header$";
  41. # endif
  42. #endif
  43.  
  44. /*                                    */
  45. /* Convience switch for maintaining variables in a single location    */
  46. /*                                    */
  47. #ifdef MAIN
  48. #define GLOBAL
  49. #else
  50. #define GLOBAL extern
  51. #endif
  52.  
  53. /*                                    */
  54. /* Convience definitions of TRUE and FALSE                */
  55. /*                                    */
  56. #ifndef TRUE
  57. #define TRUE (1)
  58. #endif
  59. #ifndef FALSE
  60. #define FALSE (0)
  61. #endif
  62. #ifndef FOREVER
  63. #define FOREVER while(1)
  64. #endif
  65.  
  66. /*                                    */
  67. /* Constants and macros                            */
  68. /*                                    */
  69. /* Defaults and limits - System wide                    */
  70. #define    NFILES        16        /* number of files in table    */
  71. #define    NDEVS        4        /* number of supported devices    */
  72. #define NAMEMAX        256        /* Maximum size of a name        */
  73.  
  74. /* 0 = CON, standard input, can be redirected                */
  75. /* 1 = CON, standard output, can be redirected                */
  76. /* 2 = CON, standard error                        */
  77. /* 3 = AUX, auxiliary                            */
  78. /* 4 = PRN, list device                            */
  79. /* 5 = 1st user file ...                        */
  80. #define    STDIN        0
  81. #define    STDOUT        1
  82. #define    STDERR        2
  83. #define    STDAUX        3
  84. #define    STDPRN        4
  85.  
  86. #define MAX_CMDLINE    128
  87. #define MAX_LABELS    20
  88. #define NPARAMS        16
  89. #define LABELSIZE     9
  90. #define ENV_DEFAULT    256
  91.  
  92. /* some defines for protability from ASCII                */
  93. #define ESC_CHAR    0x1b
  94.  
  95. typedef struct
  96. {
  97.     BYTE    lb_name[LABELSIZE];
  98.     LONG    lb_posit;
  99. } symbol;
  100.  
  101. GLOBAL symbol labels[MAX_LABELS];
  102.  
  103.  
  104. GLOBAL    HANDLE
  105.     hHeap;
  106.  
  107.  
  108. GLOBAL    INT
  109.     default_drive,        /* The current selected drive        */
  110.     label_cnt,        /* Number of labels found        */
  111.     shift_offset,        /* To determine %1 if shift was called     */
  112.     EnvSize;        /* Startup environment size        */
  113.  
  114.  
  115. GLOBAL    BYTE
  116.     szDfltPrompt[MAX_CMDLINE],     /* generates "No Path"        */
  117.     szDfltPath[MAX_CMDLINE],
  118.     szPrompt[MAX_CMDLINE],
  119.     *pszPath,
  120.     *pszPrompt,
  121.     switchchar,
  122.     *tail,
  123.     szCmdLine[MAX_CMDLINE],
  124.     args[NPARAMS][MAX_CMDLINE],
  125.     posparam[NPARAMS][MAX_CMDLINE];
  126.  
  127. GLOBAL BOOL
  128.     at_FLAG,        /* @ at beginning of command line    */
  129.     batch_FLAG,
  130.     echo_FLAG,
  131.     dosoptplus;        /* TRUE if more non-white in tail    */
  132.  
  133. GLOBAL HANDLE
  134.     hStdout,
  135.     hStdin,
  136.     hStderr;
  137. GLOBAL HANDLE
  138.     hInput,
  139.     hOutput;
  140.  
  141.  
  142. GLOBAL BYTE *dflt_pr_string
  143. #ifdef MAIN
  144.  =
  145. # ifdef SHWR
  146.     "[Shareware CMD32] $p$g ";
  147. # else
  148.     "$p$g ";
  149. # endif
  150. #else
  151.  ;
  152. #endif
  153.  
  154. #define ANNOUNCE "\nCMD32 Command Shell\n%s"
  155.  
  156. GLOBAL BYTE *copyright
  157. #ifdef MAIN
  158. ="(C) Copyright 2000\n\
  159. Pasquale J. Villani\nAll Rights Reserved\n";
  160. #else
  161. ;
  162. #endif
  163.  
  164. GLOBAL BYTE *Cmd32Version
  165. #ifdef MAIN
  166. ="CMD32 Version %d.%d.%d\n";
  167. #else
  168. ;
  169. #endif
  170.  
  171. /* Error messages                            */
  172.  
  173. #define MAX_ERR_STR_LEN        50    /* Maximum length of %s     */
  174. #define MAX_ERR_MESS_LEN    80    /* Maximum length fixed message    */
  175.  
  176. GLOBAL BYTE
  177.     *error_mess_str;
  178.  
  179. GLOBAL    INT
  180.     rtn_errlvl;    /* error level returned from external command    */
  181.  
  182. enum error_mess {
  183.     ACCESS_DENIED = 0,
  184.     BAD_CMD_FILE_NAME,
  185.     BAD_CMD_INTERPRETER,
  186.     BOOT_ERROR,
  187.     CANNOT_REMOVE,
  188.     CANNOT_DELETE,
  189.     CANNOT_FIND_SYS_FILES,
  190.     CANNOT_LOAD_COMMAND,
  191.     CANNOT_READ_FAT,
  192.     INV_NUM_PARAMS,
  193.     INV_PARAM,
  194.     INV_PARAM_COMBO,
  195.     CURRENT_DRIVE_NUM,
  196.     INV_DRIVE,
  197.     INV_COMMAND,
  198.     INV_CMD,
  199.     INV_DIR,
  200.     INV_TIME,
  201.     INV_DATE,
  202.     INV_DISK_CHANGE,
  203.     INV_FILE,
  204.     INV_FUNCTION_PARAM,
  205.     INV_PARTITION,
  206.     INV_PATH,
  207.     INV_SWITCH,
  208.     INV_SYNTAX,
  209.     NOT_DIR,
  210.     NOT_EMPTY_DIR,
  211.     INV_KEYWORD,
  212.     DATA_ERR,
  213.     EXEC_ERR,
  214.     OS_ERR,
  215.     READ_DIR_ERR,
  216.     READ_SYS_ERR,
  217.     WRITE_DEVICE_ERR,
  218.     EXEC_FAIL,
  219.     BAD_FAT,
  220.     FILE_ON_ITSELF,
  221.     FILE_CREATE_ERR,
  222.     FILE_NOT_FOUND,
  223.     GEN_FAIL,
  224.     DOS_VER,
  225.     INSUFF_DISK,
  226.     INSUFF_MEM,
  227.     FILE_PIPE_ERR,
  228.     INTERNAL_ERR,
  229.     MALLOC_ERR,
  230.     ON_OFF,
  231.     NO_FIXED_DISK,
  232.     NO_DIR_ROOM,
  233.     NON_SYS_DISK,
  234.     OUT_ENV_SPACE,
  235.     PARAM_FORMAT,
  236.     PARAM_NOT_ALLOWED,
  237.     PARAM_RANGE_ERR,
  238.     PARAM_NOT_COMPAT,
  239.     PARSE_ERR,
  240.     PATH_NOT_FOUND,
  241.     PRINTER_ERR,
  242.     PROG_TOO_BIG,
  243.     READ_FAULT,
  244.     REQ_PARAM,
  245.     PARAM_TWICE,
  246.     SECTOR_NOT,
  247.     SEEK_ERR,
  248.     SHARE_ERR,
  249.     SEARCH_DIR_ERR,
  250.     SYNTAX_ERR,
  251.     TOO_FILES_OPEN,
  252.     TOO_MANY_PARAMS,
  253.     TOO_MANY_REDIRECTS,
  254.     PARENT_ABORT,
  255.     UNREC_CMD_CONFIG,
  256.     UNRECOV_W_R,
  257.     WRITE_FAULT,
  258.     WRITE,
  259.     INV_LABEL,
  260.     LABEL_NOT_FOUND,
  261.     DUP_FILE,
  262.     CANNOT_RESTORE
  263. }; /* end error message enum */
  264.  
  265. GLOBAL BYTE *error_messages[]
  266. #ifdef MAIN
  267.     = {
  268.     "Access denied",
  269.     "Bad command or file name",
  270.     "Bad or missing command interpreter",
  271.     "Boot error",
  272.     "Cannot remove \"%s\"",
  273.     "Cannot delete \"%s\"",
  274.     "Cannot find system files", 
  275.     "Cannot load command,system halted",
  276.     "Cannot read file allocation table",
  277.     "Invalid number of parameters",
  278.     "Invalid parameter(s)",
  279.     "Invalid parameter combination",
  280.     "Current drive is no longer valid",
  281.     "Invalid drive specification",
  282.     "Invalid command.com",
  283.     "Invalid command name",
  284.     "Invalid directory",
  285.     "Invalid time parameter",
  286.     "Invalid date parameter",
  287.     "Invalid disk change",
  288.     "Invalid file name",
  289.     "Invalid function parameter",
  290.     "Invalid partion table",
  291.     "Invalid path",
  292.     "Invalid switch - %s",
  293.     "Invalid syntax",
  294.     "Not directory",
  295.     "Directory not empty",
  296.     "Invalid keyword",
  297.     "Data error",
  298.     "Error in exec file",
  299.     "Error loading operating system",
  300.     "Error reading directory",
  301.     "Error reading system file",
  302.     "Error writing to device",
  303.     "Exec failure",
  304.     "File allocation table bad",
  305.     "File cannot not be copied onto itself",
  306.     "File creation error - \"%s\"",
  307.     "File not found",
  308.     "General failure",
  309.     "Incorrect Windows version",
  310.     "Insufficient disk space",
  311.     "Insufficient memory",
  312.     "Intermediate file error during pipe",
  313.     "Internal error",
  314.     "Memory allocation error",
  315.     "Must specify ON or OFF",
  316.     "No fixed disks present",
  317.     "No room in directory",
  318.     "Non-system disk or disk error",
  319.     "Out of environment space",
  320.     "Parameter format not correct",
  321.     "Parameter value not allowed",
  322.     "Parameter value not in allowed range",
  323.     "Parameter not compatible",
  324.     "Parse error",
  325.     "Path not found",
  326.     "Printer error",
  327.     "Program too big to fit in memory",
  328.     "Read fault error",
  329.     "Required parameter missing",
  330.     "Same parameter entered twice",
  331.     "Sector not found",
  332.     "Seek error",
  333.     "Sharing violation",
  334.     "Specified command search directory bad",
  335.     "Syntax error",
  336.     "Too many files open",
  337.     "Too many parameters",
  338.     "Too many redirections",
  339.     "Top level process aborted, cannot continue",
  340.     "Unrecognized command in config.sys",
  341.     "Unrecoverable read or write error",
  342.     "Write fault error",
  343.     "Write protection error",
  344.     "Invalid label",
  345.     "Label not found",
  346.     "Duplicate file name or file not found",
  347.     "Cannot restore standard input/output"
  348. };
  349. #else
  350.     ;
  351. #endif
  352.  
  353.  
  354. #endif _GLOBALS_H
  355.