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.1"
00003 #define GIVENCLP_DATE   "09-JUN-2004"
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 09/06/2004 - Uli Fechner - v1.0.1 - adjusted according to the needs of countSmarts
00027 * @@code
00028 */
00029 typedef struct
00030 {
00031         int oOptionGiven;
00032         int sOptionGiven;
00033         int mOptionGiven;
00034         int uOptionGiven;
00035 } GivenCommandLineParameters;
00036 /** @endcode */
00037 
00038 /** A pointer to structure @ref GivenCommandLineParameters is assigned the name @c Given_CLP_Ptr. */
00039 typedef GivenCommandLineParameters* Given_CLP_Ptr;
00040 
00041 /* function prototypes */
00042 
00043 Given_CLP_Ptr GivenClp_create( void );
00044 
00045 void GivenClp_destroy( Given_CLP_Ptr givenClpPtr );
00046 
00047 void GivenClp_display( const Given_CLP_Ptr givenClpPtr, FILE* outputStream );
00048 
00049 void GivenClp_setOption( const Given_CLP_Ptr givenClpPtr, const int option, const int boolean_value );
00050 
00051 int GivenClp_getOption( const Given_CLP_Ptr givenClpPtr, const int option );
00052 
00053 /* functions */
00054 
00055 /** Creates a @ref GivenCommandLineParameters structure.
00056 *
00057 * The structure @ref GivenCommandLineParameters is created. The memory of the structure is allocated
00058 * automatically. The values of all members are set to @ref BOOLEAN_FALSE.
00059 * @retval Given_CLP_Ptr pointer on the newly created structure @ref GivenCommandLineParameters
00060 * @author Uli Fechner
00061 * @version 13/05/2003 - Uli Fechner - initial release
00062 * @version 09/06/2004 - Uli Fechner - adjusted according to the needs of countSmarts
00063 */
00064 Given_CLP_Ptr GivenClp_create( void )
00065 {
00066         Given_CLP_Ptr givenClpPtr;
00067         if( !( givenClpPtr = calloc( 1, sizeof( GivenCommandLineParameters ) ) ) )
00068                 MemoryError( "givenClpPtr", "GivenClp_create" );
00069         
00070         givenClpPtr->oOptionGiven = BOOLEAN_FALSE;
00071         givenClpPtr->sOptionGiven = BOOLEAN_FALSE;
00072         givenClpPtr->mOptionGiven = BOOLEAN_FALSE;
00073         givenClpPtr->uOptionGiven = BOOLEAN_FALSE;
00074         
00075         return givenClpPtr;
00076 }
00077 
00078 /** Destroys a @ref GivenCommandLineParameters structure.
00079 *
00080 * The structure @ref GivenCommandLineParameters the pointer @c givenClpPtr refers to is destroyed. The
00081 * allocated memory of the structure is automatically freed.
00082 *
00083 * @param givenClpPtr pointer on the structure @ref GivenCommandLineParameters that should be destroyed
00084 * @author Uli Fechner
00085 * @version 13/05/2003 - Uli Fechner - initial release
00086 */
00087 void GivenClp_destroy( Given_CLP_Ptr givenClpPtr )
00088 {
00089         if( givenClpPtr != NULL )
00090                 free( givenClpPtr );
00091         else
00092         {
00093                 fprintf( stderr, "\n\nERROR: Function 'GivenClp_destroy' could not destroy a structure\n" );
00094                 fprintf( stderr, "'GivenCommandLineParameters' that has not been created before!\n" );
00095                 AbortProgram;
00096         }
00097 }
00098 
00099 /** Displays a @ref GivenCommandLineParameters structure.
00100 *
00101 * The structure @ref GivenCommandLineParameters the pointer @c givenClpPtr refers to is displayed
00102 * on the FILE* @c outputStream.
00103 *
00104 * @param givenClpPtr pointer on the structure @ref GivenCommandLineParameters that should be displayed
00105 * @param outputStream FILE* on the stream the output should be sent to
00106 * @author Uli Fechner
00107 * @version 13/05/2003 - Uli Fechner - initial release
00108 * @version 09/06/2004 - Uli Fechner - adjusted according to the needs of countSmarts
00109 */
00110 void GivenClp_display( const Given_CLP_Ptr givenClpPtr, FILE* outputStream )
00111 {
00112         fprintf( outputStream, "oOptionGiven = %d\n", givenClpPtr->oOptionGiven );
00113         fprintf( outputStream, "sOptionGiven = %d\n", givenClpPtr->sOptionGiven );
00114         fprintf( outputStream, "mOptionGiven = %d\n", givenClpPtr->mOptionGiven );
00115         fprintf( outputStream, "uOptionGiven = %d\n", givenClpPtr->uOptionGiven );
00116 }
00117 
00118 /** The option @c option of a @ref GivenCommandLineParameters structure is set to @c boolean_value.
00119 *
00120 * The parameter @c boolean_value could either have the value @ref BOOLEAN_TRUE or @ref BOOLEAN_FALSE.
00121 *
00122 * @param givenClpPtr pointer on the structure @ref GivenCommandLineParameters
00123 * @param option character of the option to be set (o, r)
00124 * @param boolean_value one of the two defines @ref BOOLEAN_TRUE or @ref BOOLEAN_FALSE
00125 * @author Uli Fechner
00126 * @version 13/05/2003 - Uli Fechner - initial release
00127 * @version 09/06/2004 - Uli Fechner - adjusted according to the needs of countSmarts
00128 */
00129 void GivenClp_setOption( const Given_CLP_Ptr givenClpPtr, const int option, const int boolean_value )
00130 {
00131         switch( option )
00132         {
00133         case 'o':
00134                 givenClpPtr->oOptionGiven = boolean_value;
00135                 break;
00136         case 's':
00137                 givenClpPtr->sOptionGiven = boolean_value;
00138                 break;
00139         case 'm':
00140                 givenClpPtr->mOptionGiven = boolean_value;
00141                 break;
00142         case 'u':
00143                 givenClpPtr->uOptionGiven = boolean_value;
00144                 break;
00145         default:
00146                 fprintf(stderr, "\n\nERROR: Function 'GivenClp_setOption' recieved wrong argument 'option'.\n" );
00147                 fprintf(stderr, "'%c' is not a valid argument for this function!\n", option );
00148                 AbortProgram;
00149                 break;
00150         }
00151 }
00152 
00153 /** The current value of option @c option of a @ref GivenCommandLineParameters structure is returned.
00154 *
00155 * The return value @c boolean_value could either have the value @ref BOOLEAN_TRUE or @ref BOOLEAN_FALSE.
00156 *
00157 * @param givenClpPtr pointer on the structure @ref GivenCommandLineParameters
00158 * @param option character of the option to be set (o, r)
00159 * @retval int one of the two defines @ref BOOLEAN_TRUE or @ref BOOLEAN_FALSE
00160 * @author Uli Fechner
00161 * @version 13/05/2003 - Uli Fechner - initial release
00162 * @version 09/06/2004 - Uli Fechner - adjusted according to the needs of countSmarts
00163 */
00164 int GivenClp_getOption( const Given_CLP_Ptr givenClpPtr, const int option )
00165 {
00166         switch( option )
00167         {
00168         case 'o':
00169                 return givenClpPtr->oOptionGiven;
00170                 break;
00171         case 's':
00172                 return givenClpPtr->sOptionGiven;
00173                 break;
00174         case 'm':
00175                 return givenClpPtr->mOptionGiven;
00176                 break;
00177         case 'u':
00178                 return givenClpPtr->uOptionGiven;
00179                 break;
00180         default:
00181                 fprintf(stderr, "\n\nERROR: Function 'GivenClp_getOption' recieved wrong argument 'option'.\n" );
00182                 fprintf(stderr, "'%c' is not a valid argument for this function.\n", option );
00183                 AbortProgram;
00184                 break;
00185         }
00186 }

Generated on Mon Nov 8 16:04:06 2004 for countSmarts by doxygen 1.3.6