~ubuntu-branches/ubuntu/intrepid/raidutils/intrepid

« back to all changes in this revision

Viewing changes to raidutil/parser.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Barak Pearlmutter
  • Date: 2004-05-18 11:33:42 UTC
  • Revision ID: james.westby@ubuntu.com-20040518113342-tyqavmso5q351xi2
Tags: upstream-0.0.4
ImportĀ upstreamĀ versionĀ 0.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 1996-2004, Adaptec Corporation
 
2
 * All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions are met:
 
6
 *
 
7
 * - Redistributions of source code must retain the above copyright notice, this
 
8
 *   list of conditions and the following disclaimer.
 
9
 * - Redistributions in binary form must reproduce the above copyright notice,
 
10
 *   this list of conditions and the following disclaimer in the documentation
 
11
 *   and/or other materials provided with the distribution.
 
12
 * - Neither the name of the Adaptec Corporation nor the names of its
 
13
 *   contributors may be used to endorse or promote products derived from this
 
14
 *   software without specific prior written permission.
 
15
 *
 
16
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
17
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
18
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
19
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
20
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
21
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
22
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
23
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
24
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
25
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
26
 * POSSIBILITY OF SUCH DAMAGE.
 
27
 */
 
28
 
 
29
#ifndef PARSER_HPP
 
30
#define PARSER_HPP
 
31
 
 
32
/****************************************************************************
 
33
*
 
34
* Created:  7/20/98
 
35
*
 
36
*****************************************************************************
 
37
*
 
38
* File Name:            Parser.hpp
 
39
* Module:
 
40
* Contributors:         Lee Page
 
41
* Description:          This class is an object factory that accepts a command-line string
 
42
                                        in.  Then it creates a an array of objects, one per command.
 
43
                                        This array can then be fetched and executed.
 
44
* Version Control:
 
45
*
 
46
* $Revision: 9 $
 
47
* $NoKeywords: $
 
48
* $Log: $
 
49
*****************************************************************************/
 
50
 
 
51
/*** INCLUDES ***/
 
52
#include "cmdlist.hpp"
 
53
#include "creatrad.hpp"
 
54
#include "scsilist.hpp"
 
55
#include "intlist.hpp"
 
56
/*** CONSTANTS ***/
 
57
/*** TYPES ***/
 
58
/*** STATIC DATA ***/
 
59
/*** MACROS ***/
 
60
/*** PROTOTYPES ***/
 
61
/*** FUNCTIONS ***/
 
62
class Parser
 
63
        {
 
64
        public:
 
65
                Parser(
 
66
                        char    *command_Line,
 
67
                        bool    *quiet_Mode_Ptr         // A pointer to the quiet mode boolean
 
68
                        );
 
69
                virtual ~Parser();
 
70
 
 
71
                Command_List    &get_Command_List();
 
72
 
 
73
        private:
 
74
/*              static const unsigned long      RAID_0_DEFAULT_STRIPE_SIZE;
 
75
                static const unsigned long      RAID_1_DEFAULT_STRIPE_SIZE;
 
76
                static const unsigned long      RAID_5_DEFAULT_STRIPE_SIZE;
 
77
*/              static const unsigned long      BLOCK_SIZE;
 
78
                // a structure used in the retrieving of a constant associated with a string.
 
79
                struct str_to_Const_Struct
 
80
                        {
 
81
                        char    *str;           // this is the string that is associated with the
 
82
                                                                // constant
 
83
                        int             constant;
 
84
                        };
 
85
                char            *Extract_Command( char *this_Commands_Text, char *buffer );
 
86
                char            *Extract_Word( char *str, char *word );
 
87
      char     *TranslateNext (char *str, int *retVal);
 
88
                char            *Skip_White( char *str );
 
89
                char            *Skip_Non_White( char *str );
 
90
                char            *Skip_Non_Word( char *str );
 
91
                char            *Skip_Word( char *str );
 
92
                static void     To_Lower( char *str );
 
93
                static int      StrICmp(
 
94
                                                const char *str1,
 
95
                                                const char *str2
 
96
                                                );
 
97
                void    Reset_Params_to_Defaults();
 
98
                void    Error_in_Parsing(
 
99
                                        char    *error_Str,
 
100
                                        char    *this_Command_Line
 
101
                                        );
 
102
                int     Str_to_Constant(
 
103
                                char                            *str_to_Match,  // this is the string the user supplies
 
104
                                str_to_Const_Struct *str_to_Const       // this is an array in which we have
 
105
                                                                                                        // to match the string the user supplies
 
106
                                );
 
107
                Int_List        *Get_Int_List(
 
108
                                                        char    *int_Str,                               // pointer to a list of comma
 
109
                                                                                                                        // delimited constants
 
110
                                                        char    **end_Ptr,                              // this will be set to point
 
111
                                                                                                                        // to the end of the parsed list
 
112
                                                        char    *this_Commands_Text,    // this is the whole command,
 
113
                                                                                                                        // used to create a context-based
 
114
                                                                                                                        // error string when the command fails
 
115
                                                        bool    *done                                   // set true when an error is
 
116
                                                                                                                        // detected
 
117
                                                        );
 
118
                char *                  Get_Address(
 
119
                                                        char    *address_Str,                   // pointer to an address
 
120
                                                        SCSI_Address * component
 
121
                                                );
 
122
                SCSI_Addr_List  *Get_Address_List(
 
123
                                                        char    *address_Str,                   // pointer to a list of comma
 
124
                                                                                                                        // delimited constants
 
125
                                                        char    **end_Ptr,                              // this will be set to point
 
126
                                                                                                                        // to the end of the parsed list
 
127
                                                        char    *this_Commands_Text,    // this is the whole command,
 
128
                                                                                                                        // used to create a context-based
 
129
                                                                                                                        // error string when the command fails
 
130
                                                        bool    *done                                   // set true when an error is
 
131
                                                                                                                        // detected
 
132
                                                        );
 
133
 
 
134
 
 
135
                Command_List    *cmd_List;
 
136
                bool                    *quiet_Mode;
 
137
                // the "..._Specified" bool is intended to aid in parameter checking to make
 
138
                // sure that mandatory parameters are used, else the command invocation fails.
 
139
                struct Parameters
 
140
                        {
 
141
                        bool                                    hba_Num_Specified;
 
142
                        int                                             hba_Num;
 
143
 
 
144
                        bool                                    hba_Bus_Specified;
 
145
                        int                                             hba_Bus;
 
146
 
 
147
                        bool                                    unix_Style_Hba_Num_Specified;
 
148
                        char                                    *unix_Style_Hba_Num;
 
149
 
 
150
                        bool                                    raid_Type_Specified;
 
151
                        Create_Raid::Raid_Type  raid_Type;
 
152
 
 
153
                        bool                                    stripe_Size_Specified;
 
154
                        unsigned long               stripe_Size;
 
155
 
 
156
                        bool                                    task_Rate_Specified;
 
157
                        int                                             task_Rate;
 
158
 
 
159
                        // this is 1024 x 1024
 
160
                        bool                                    logical_Drive_Capacity_in_Megs_Specified;
 
161
                        unsigned long                   logical_Drive_Capacity_in_Megs;
 
162
 
 
163
                        Int_List                                *logical_Drive_Number;
 
164
                        } params;
 
165
        };
 
166
 
 
167
#endif
 
168
/*** END OF FILE ***/