[14] | 1 | /**CFile*********************************************************************** |
---|
| 2 | |
---|
| 3 | FileName [tst.c] |
---|
| 4 | |
---|
| 5 | PackageName [tst] |
---|
| 6 | |
---|
| 7 | Synopsis [Test package initialization, ending, and the command test.] |
---|
| 8 | |
---|
| 9 | Author [Originated from SIS.] |
---|
| 10 | |
---|
| 11 | Copyright [Copyright (c) 1994-1996 The Regents of the Univ. of California. |
---|
| 12 | All rights reserved. |
---|
| 13 | |
---|
| 14 | Permission is hereby granted, without written agreement and without license |
---|
| 15 | or royalty fees, to use, copy, modify, and distribute this software and its |
---|
| 16 | documentation for any purpose, provided that the above copyright notice and |
---|
| 17 | the following two paragraphs appear in all copies of this software. |
---|
| 18 | |
---|
| 19 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR |
---|
| 20 | DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT |
---|
| 21 | OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF |
---|
| 22 | CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 23 | |
---|
| 24 | THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, |
---|
| 25 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
---|
| 26 | FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN |
---|
| 27 | "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE |
---|
| 28 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.] |
---|
| 29 | |
---|
| 30 | ******************************************************************************/ |
---|
| 31 | |
---|
| 32 | #include "tstInt.h" |
---|
| 33 | |
---|
| 34 | static char rcsid[] UNUSED = "$Id: tst.c,v 1.6 2002/09/10 06:14:37 fabio Exp $"; |
---|
| 35 | |
---|
| 36 | /*---------------------------------------------------------------------------*/ |
---|
| 37 | /* Constant declarations */ |
---|
| 38 | /*---------------------------------------------------------------------------*/ |
---|
| 39 | |
---|
| 40 | /*---------------------------------------------------------------------------*/ |
---|
| 41 | /* Structure declarations */ |
---|
| 42 | /*---------------------------------------------------------------------------*/ |
---|
| 43 | |
---|
| 44 | /*---------------------------------------------------------------------------*/ |
---|
| 45 | /* Type declarations */ |
---|
| 46 | /*---------------------------------------------------------------------------*/ |
---|
| 47 | |
---|
| 48 | /*---------------------------------------------------------------------------*/ |
---|
| 49 | /* Variable declarations */ |
---|
| 50 | /*---------------------------------------------------------------------------*/ |
---|
| 51 | |
---|
| 52 | /*---------------------------------------------------------------------------*/ |
---|
| 53 | /* Macro declarations */ |
---|
| 54 | /*---------------------------------------------------------------------------*/ |
---|
| 55 | |
---|
| 56 | /**AutomaticStart*************************************************************/ |
---|
| 57 | |
---|
| 58 | /*---------------------------------------------------------------------------*/ |
---|
| 59 | /* Static function prototypes */ |
---|
| 60 | /*---------------------------------------------------------------------------*/ |
---|
| 61 | |
---|
| 62 | static int CommandTest(Hrc_Manager_t ** hmgr, int argc, char ** argv); |
---|
| 63 | |
---|
| 64 | /**AutomaticEnd***************************************************************/ |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | /*---------------------------------------------------------------------------*/ |
---|
| 68 | /* Definition of exported functions */ |
---|
| 69 | /*---------------------------------------------------------------------------*/ |
---|
| 70 | |
---|
| 71 | /**Function******************************************************************** |
---|
| 72 | |
---|
| 73 | Synopsis [Initializes the test package.] |
---|
| 74 | |
---|
| 75 | SideEffects [] |
---|
| 76 | |
---|
| 77 | SeeAlso [Tst_End] |
---|
| 78 | |
---|
| 79 | ******************************************************************************/ |
---|
| 80 | void |
---|
| 81 | Tst_Init(void) |
---|
| 82 | { |
---|
| 83 | /* |
---|
| 84 | * Add a command to the global command table. By using the leading |
---|
| 85 | * underscore, the command will be listed under "help -a" but not "help". |
---|
| 86 | */ |
---|
| 87 | Cmd_CommandAdd("_tst_test", CommandTest, /* doesn't changes_network */ 0); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | /**Function******************************************************************** |
---|
| 92 | |
---|
| 93 | Synopsis [Ends the test package.] |
---|
| 94 | |
---|
| 95 | SideEffects [] |
---|
| 96 | |
---|
| 97 | SeeAlso [Tst_Init] |
---|
| 98 | |
---|
| 99 | ******************************************************************************/ |
---|
| 100 | void |
---|
| 101 | Tst_End(void) |
---|
| 102 | { |
---|
| 103 | /* |
---|
| 104 | * For example, free any global memory (if any) which the test package is |
---|
| 105 | * responsible for. |
---|
| 106 | */ |
---|
| 107 | } |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | /*---------------------------------------------------------------------------*/ |
---|
| 111 | /* Definition of internal functions */ |
---|
| 112 | /*---------------------------------------------------------------------------*/ |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | /*---------------------------------------------------------------------------*/ |
---|
| 116 | /* Definition of static functions */ |
---|
| 117 | /*---------------------------------------------------------------------------*/ |
---|
| 118 | |
---|
| 119 | /**Function******************************************************************** |
---|
| 120 | |
---|
| 121 | Synopsis [Implements the _tst_test command.] |
---|
| 122 | |
---|
| 123 | CommandName [_tst_test] |
---|
| 124 | |
---|
| 125 | CommandSynopsis [template for implementing commands] |
---|
| 126 | |
---|
| 127 | CommandArguments [\[-h\] \[-v\]] |
---|
| 128 | |
---|
| 129 | CommandDescription [This command does nothing useful. It merely serves as a |
---|
| 130 | template for the implementation of new commands.<p> |
---|
| 131 | |
---|
| 132 | Command options:<p> |
---|
| 133 | |
---|
| 134 | <dl> |
---|
| 135 | <dt> -h |
---|
| 136 | <dd> Print the command usage. |
---|
| 137 | </dl> |
---|
| 138 | |
---|
| 139 | <dt> -v |
---|
| 140 | <dd> Verbose mode. |
---|
| 141 | </dl> |
---|
| 142 | ] |
---|
| 143 | |
---|
| 144 | SideEffects [] |
---|
| 145 | |
---|
| 146 | ******************************************************************************/ |
---|
| 147 | static int |
---|
| 148 | CommandTest( |
---|
| 149 | Hrc_Manager_t ** hmgr, |
---|
| 150 | int argc, |
---|
| 151 | char ** argv) |
---|
| 152 | { |
---|
| 153 | int c; |
---|
| 154 | int verbose = 0; /* default value */ |
---|
| 155 | |
---|
| 156 | /* |
---|
| 157 | * Parse command line options. |
---|
| 158 | */ |
---|
| 159 | util_getopt_reset(); |
---|
| 160 | while ((c = util_getopt(argc, argv, "vh")) != EOF) { |
---|
| 161 | switch(c) { |
---|
| 162 | case 'v': |
---|
| 163 | verbose = 1; |
---|
| 164 | break; |
---|
| 165 | case 'h': |
---|
| 166 | goto usage; |
---|
| 167 | default: |
---|
| 168 | goto usage; |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | if (verbose) { |
---|
| 173 | (void) fprintf(vis_stdout, "The _tst_test command does nothing useful.\n"); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | return 0; /* normal exit */ |
---|
| 177 | |
---|
| 178 | usage: |
---|
| 179 | (void) fprintf(vis_stderr, "usage: _tst_test [-h] [-v]\n"); |
---|
| 180 | (void) fprintf(vis_stderr, " -h\t\tprint the command usage\n"); |
---|
| 181 | (void) fprintf(vis_stderr, " -v\t\tverbose\n"); |
---|
| 182 | return 1; /* error exit */ |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | |
---|
| 186 | |
---|
| 187 | |
---|