Main Page | Data Structures | File List | Data Fields | Globals

givenClp.c

Go to the documentation of this file.
00001 /* just some information about this file */
00002 #define GIVENCLP_VERSION        "1.0.2"
00003 #define GIVENCLP_DATE   "29-Jan-2003"
00004 
00005 /* structures and typedefs */
00006 
00007 /** @file
00008 * @anchor GivenCommandLineParameters
00009 * Structure to store a simulated boolean value for all command line arguments.
00010 *
00011 * This structure provides a way to store simulated boolean values (@ref BOOLEAN_TRUE or @ref
00012 * BOOLEAN_FALSE) for all command line arguments. It is used to store the information whether a
00013 * specific command line argument is given or not. All values are set to @ref BOOLEAN_FALSE during
00014 * the creation of the structure via @ref GivenClp_create.
00015 *
00016 * The structure is created with @ref GivenClp_create, destroyed with @ref GivenClp_destroy and
00017 * displayed with @ref GivenClp_display. With @ref GivenClp_setOption and @ref GivenClp_getOption
00018 * the values of the individual members of the structure @ref GivenCommandLineParameters could be
00019 * set or gotten.
00020 *
00021 * <B>Description of the members:</B><BR><BR>
00022 *       @c oOptionGiven - indicates whether the @c o option is given at the command line<BR>
00023 * @c rOptionGiven - indicates whether the @c r option is given at the command line<BR>
00024 * @author Uli Fechner
00025 * @version 13/05/2003 - Uli Fechner - v1.0.0 - initial release
00026 * @version 01/09/2003 - Uli Fechner - v1.0.1 - .adjusted according to the needs of retroflux
00027 * @version 29/01/2004 - Tina Grabowski - v1.0.2 - added the @c member sOptionGiven; corresponding
00028 *                       changes in @ref GivenClp_create, @ref GivenClp_display, @ref
00029 *                       GivenClp_setOption and @ref GivenClp_getOption
00030 * @@code
00031 */
00032 typedef struct
00033 {
00034         int oOptionGiven;
00035         int rOptionGiven;
00036         int fOptionGiven;
00037         int sOptionGiven;
00038 } GivenCommandLineParameters;
00039 /** @endcode */
00040 
00041 /** A pointer to structure @ref GivenCommandLineParameters is assigned the name @c Given_CLP_Ptr. */
00042 typedef GivenCommandLineParameters* Given_CLP_Ptr;
00043 
00044 /* function prototypes */
00045 
00046 Given_CLP_Ptr GivenClp_create( void );
00047 
00048 void GivenClp_destroy( Given_CLP_Ptr givenClpPtr );
00049 
00050 void GivenClp_display( const Given_CLP_Ptr givenClpPtr, FILE* outputStream );
00051 
00052 void GivenClp_setOption( const Given_CLP_Ptr givenClpPtr, const int option, const int boolean_value );
00053 
00054 int GivenClp_getOption( const Given_CLP_Ptr givenClpPtr, const int option );
00055 
00056 /* functions */
00057 
00058 /** Creates a @ref GivenCommandLineParameters structure.
00059 *
00060 * The structure @ref GivenCommandLineParameters is created. The memory of the structure is allocated
00061 * automatically. The values of all members are set to @ref BOOLEAN_FALSE.
00062 * @retval Given_CLP_Ptr pointer on the newly created structure @ref GivenCommandLineParameters
00063 * @author Uli Fechner
00064 * @version 13/05/2003 - Uli Fechner - initial release
00065 * @version 24/11/2003 - Uli Fechner - adjusted according to the needs of retroflux
00066 * @version 29/01/2004 - Tina Grabowski - added support for the member @c sOptionGiven
00067 */
00068 Given_CLP_Ptr GivenClp_create( void )
00069 {
00070         Given_CLP_Ptr givenClpPtr;
00071         if( !( givenClpPtr = calloc( 1, sizeof( GivenCommandLineParameters ) ) ) )
00072                 MemoryError( "givenClpPtr", "GivenClp_create" );
00073         
00074         givenClpPtr->oOptionGiven = BOOLEAN_FALSE;
00075         givenClpPtr->rOptionGiven = BOOLEAN_FALSE;
00076         givenClpPtr->fOptionGiven = BOOLEAN_FALSE;
00077         givenClpPtr->sOptionGiven = BOOLEAN_FALSE;
00078         
00079         return givenClpPtr;
00080 }
00081 
00082 /** Destroys a @ref GivenCommandLineParameters structure.
00083 *
00084 * The structure @ref GivenCommandLineParameters the pointer @c givenClpPtr refers to is destroyed. The
00085 * allocated memory of the structure is automatically freed.
00086 *
00087 * @param givenClpPtr pointer on the structure @ref GivenCommandLineParameters that should be destroyed
00088 * @author Uli Fechner
00089 * @version 13/05/2003 - Uli Fechner - initial release
00090 */
00091 void GivenClp_destroy( Given_CLP_Ptr givenClpPtr )
00092 {
00093         if( givenClpPtr != NULL )
00094                 free( givenClpPtr );
00095         else
00096         {
00097                 fprintf( stderr, "\n\nERROR: Function 'GivenClp_destroy' could not destroy a structure\n" );
00098                 fprintf( stderr, "'GivenCommandLineParameters' that has not been created before!\n" );
00099                 AbortProgram;
00100         }
00101 }
00102 
00103 /** Displays a @ref GivenCommandLineParameters structure.
00104 *
00105 * The structure @ref GivenCommandLineParameters the pointer @c givenClpPtr refers to is displayed
00106 * on the FILE* @c outputStream.
00107 *
00108 * @param givenClpPtr pointer on the structure @ref GivenCommandLineParameters that should be displayed
00109 * @param outputStream FILE* on the stream the output should be sent to
00110 * @author Uli Fechner
00111 * @version 13/05/2003 - Uli Fechner - initial release
00112 * @version 24/11/2003 - Uli Fechner - adjusted according to the needs of retroflux
00113 * @version 29/01/2004 - Tina Grabowski - added support for the member @c sOptionGiven
00114 */
00115 void GivenClp_display( const Given_CLP_Ptr givenClpPtr, FILE* outputStream )
00116 {
00117         fprintf( outputStream, "oOptionGiven = %d\n", givenClpPtr->oOptionGiven );
00118         fprintf( outputStream, "rOptionGiven = %d\n", givenClpPtr->rOptionGiven );
00119         fprintf( outputStream, "fOptionGiven = %d\n", givenClpPtr->fOptionGiven );
00120         fprintf( outputStream, "sOptionGiven = %d\n", givenClpPtr->sOptionGiven );
00121 }
00122 
00123 /** The option @c option of a @ref GivenCommandLineParameters structure is set to @c boolean_value.
00124 *
00125 * The parameter @c boolean_value could either have the value @ref BOOLEAN_TRUE or @ref BOOLEAN_FALSE.
00126 *
00127 * @param givenClpPtr pointer on the structure @ref GivenCommandLineParameters
00128 * @param option character of the option to be set (o, r)
00129 * @param boolean_value one of the two defines @ref BOOLEAN_TRUE or @ref BOOLEAN_FALSE
00130 * @author Uli Fechner
00131 * @version 13/05/2003 - Uli Fechner - initial release
00132 * @version 24/11/2003 - Uli Fechner - adjusted according to the needs of retroflux
00133 * @version 29/01/2004 - Tina Grabowski - added support for the member @c sOptionGiven
00134 */
00135 void GivenClp_setOption( const Given_CLP_Ptr givenClpPtr, const int option, const int boolean_value )
00136 {
00137         switch( option )
00138         {
00139         case 'o':
00140                 givenClpPtr->oOptionGiven = boolean_value;
00141                 break;
00142         case 'r':
00143                 givenClpPtr->rOptionGiven = boolean_value;
00144                 break;
00145         case 'f':
00146                 givenClpPtr->fOptionGiven = boolean_value;
00147                 break;
00148         case 's':
00149                 givenClpPtr->sOptionGiven = boolean_value;
00150                 break;
00151         default:
00152                 fprintf(stderr, "\n\nERROR: Function 'GivenClp_setOption' recieved wrong argument 'option'.\n" );
00153                 fprintf(stderr, "'%c' is not a valid argument for this function!\n", option );
00154                 AbortProgram;
00155                 break;
00156         }
00157 }
00158 
00159 /** The current value of option @c option of a @ref GivenCommandLineParameters structure is returned.
00160 *
00161 * The return value @c boolean_value could either have the value @ref BOOLEAN_TRUE or @ref BOOLEAN_FALSE.
00162 *
00163 * @param givenClpPtr pointer on the structure @ref GivenCommandLineParameters
00164 * @param option character of the option to be set (o, r)
00165 * @retval int one of the two defines @ref BOOLEAN_TRUE or @ref BOOLEAN_FALSE
00166 * @author Uli Fechner
00167 * @version 13/05/2003 - Uli Fechner - initial release
00168 * @version 24/11/2003 - Uli Fechner - adjusted according to the needs of retroflux
00169 * @version 29/01/2004 - Tina Grabowski - added support for the member @c sOptionGiven
00170 */
00171 int GivenClp_getOption( const Given_CLP_Ptr givenClpPtr, const int option )
00172 {
00173         switch( option )
00174         {
00175         case 'o':
00176                 return givenClpPtr->oOptionGiven;
00177                 break;
00178         case 'r':
00179                 return givenClpPtr->rOptionGiven;
00180                 break;
00181         case 'f':
00182                 return givenClpPtr->fOptionGiven;
00183                 break;
00184         case 's':
00185                 return givenClpPtr->sOptionGiven;
00186                 break;
00187         default:
00188                 fprintf(stderr, "\n\nERROR: Function 'GivenClp_getOption' recieved wrong argument 'option'.\n" );
00189                 fprintf(stderr, "'%c' is not a valid argument for this function.\n", option );
00190                 AbortProgram;
00191                 break;
00192         }
00193 }

Generated on Tue Nov 9 16:27:11 2004 for retroflux by doxygen 1.3.6