1/**
2 * \file
3 * \brief Argument processing for distributed services
4 */
5
6/*
7 * Copyright (c) 2010-2011, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef __ARGS_H__
16#define __ARGS_H__
17
18/**
19 * \struct args
20 * \brief generic distributed service arguments passed to a dispatcher
21 */
22struct dist_args {
23    char *path;			/*< pathname of the service to start */
24    coreid_t *cores;		/*< list of cores to run on */
25    int cores_len;		/*< lenght of list */
26    //    coreid_t *exclude;		/*< list core to explicitly *not* run on */
27    //    int exclude_len;		/*< length of list */
28    int num_cores;		/*< total number of cores to use */
29    //    bool all_cores;		/*< run on all available cores */
30    bool master;		/*< this dispatcher is the master */
31};
32
33/**
34 * \brief Process and return the generic distributed service command-line
35 *        arguments.
36 *
37 * The generic distributed service command-line arguments are processed, and
38 * appropriate values set in the return struct.  In particular, this procedire
39 * creates and returns a list of cores to start the service on based on the
40 * arguments and possibly querying the SKB.
41 *
42 * After processing argc and argv are modified so that argv points to all
43 * un-recognised arguments. In this way, service-specific arguments can still
44 * be processed separately.
45 *
46 * @param argc a pointer to argc as passed to main(). argc will be modified.
47 * @param argv argv as passed to main(). argv will be modified.
48 * @return A struct containing the values of the processed arguments.  The list
49 *         elements of the struct are malloced (and so must be freed by the
50 *         caller), but the path element is not.
51 */
52struct dist_args process_dist_args(int *argc, char **argv[]);
53
54/**
55 * \brief Convert an array of coreids into a string representation of the list.
56 *
57 *	  The string looks like: "1,2,3,".  This function mallocs the memory
58 *        for the string. The calelr is therefore responsible for freeing it.
59 *
60 * @param list the list to convert.
61 * @param l_len the number of elements in the list.
62 * @return The string representation of the list. This function mallocs the
63 *         memory for the string. The caller is therefore responsible for
64 *         freeing it.
65 */
66char *list_to_string(coreid_t list[], size_t l_len);
67
68#endif
69
70