# sample_cluster_parse_opts

Parse the application's `argv[]` argument list and set cluster parameters accordingly.

### For an overview see page Samples Helper Functions in C

### Prototype

        MCO_RET sample_open_database( /*IN*/ int argc,
                        /*IN*/ char * argv[],
                        /*OUT*/ mco_cluster_params_t *cl_params,
                        /*OUT*/ mco_cluster_node_params_t *node_params,
                        /*IN*/ uint2 max_nodenum )

### Arguments

argc | The count of application command line arguments
argv | The array of application command line arguments
cl_params | A pointer to the `mco_cluster_params_t` struct to initialize
node_params | A pointer to the `mco_cluster_node_params_t` struct to initialize
max_nodenum | The maximum node id for the cluster

### Description

This function provides a simple method for initializing cluster parameters from the application's command line arguments. It parses the list of arguments and sets the appropriate ``mco_cluster_params_t`` and `mco_cluster_node_params_t` elements.

### Return Codes

MCO_S_OK | The database was successfully created
MCO_E_ILLEGAL_PARAM | The specified arguments are inconsistent or invalid

### Example

        #include <common.h>
        #include <commoncl.h>
        ...

        int main(int argc, char* argv[])
        {
            MCO_RET rc;
            sample_memory_t dbmem;

            mco_runtime_start();
            mco_cluster_init();

            /* initialize and customize the cluster parameters */
            mco_cluster_params_init(&cl_params);

            if (! sample_cluster_parse_opts(argc - 1, argv + 1, &cl_params, node_params, MCO_MAX_CLUSTER_SIZE))
            {
                printf("Usage : \n\t%s [CLUSTER_OPTIONS] [<n_nodes>] <node_id>\nwhere node_id from 0 to (n_nodes - 1)\n", argv[0]);
                return 1;
            }
            sample_cluster_print_params(&cl_params);
            ...
        }