DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Dumitrescu, Cristian" <cristian.dumitrescu@intel.com>
To: Rich Lane <rich.lane@bigswitch.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v4] cfgfile: support looking up sections by index
Date: Fri, 19 Feb 2016 15:18:41 +0000	[thread overview]
Message-ID: <3EB4FA525960D640B5BDFFD6A3D8912647953788@IRSMSX108.ger.corp.intel.com> (raw)
In-Reply-To: <1455663517-55095-1-git-send-email-rlane@bigswitch.com>



> -----Original Message-----
> From: Rich Lane [mailto:rich.lane@bigswitch.com]
> Sent: Tuesday, February 16, 2016 10:59 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; Panu Matilainen
> <pmatilai@redhat.com>
> Subject: [PATCH v4] cfgfile: support looking up sections by index
> 
> This is useful when sections have duplicate names.
> 
> Signed-off-by: Rich Lane <rlane@bigswitch.com>
> ---
> v3->v4:
> - Added section name return value.
> - Updated API docs for other functions.
> v2->v3
> - Added check for index < 0.
> v1->v2:
> - Added new symbol to version script.
> 
>  lib/librte_cfgfile/rte_cfgfile.c           | 18 ++++++++++++++
>  lib/librte_cfgfile/rte_cfgfile.h           | 39
> ++++++++++++++++++++++++++++++
>  lib/librte_cfgfile/rte_cfgfile_version.map |  6 +++++
>  3 files changed, 63 insertions(+)
> 
> diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
> index a677dad..c086fc5 100644
> --- a/lib/librte_cfgfile/rte_cfgfile.c
> +++ b/lib/librte_cfgfile/rte_cfgfile.c
> @@ -333,6 +333,24 @@ rte_cfgfile_section_entries(struct rte_cfgfile *cfg,
> const char *sectionname,
>  	return i;
>  }
> 
> +int
> +rte_cfgfile_section_entries_by_index(struct rte_cfgfile *cfg, int index,
> +		struct rte_cfgfile_entry *entries, int max_entries,
> +		char *sectionname)

To be inline with the other API functions, can we please place the sectionname parameter after cfg and index and before entries and max_entries (be the 3rd parameter). Thanks!

> +{
> +	int i;
> +	const struct rte_cfgfile_section *sect;
> +
> +	if (index < 0 || index >= cfg->num_sections)
> +		return -1;
> +
> +	sect = cfg->sections[index];
> +	snprintf(sectionname, CFG_NAME_LEN, "%s", sect->name);
> +	for (i = 0; i < max_entries && i < sect->num_entries; i++)
> +		entries[i] = *sect->entries[i];
> +	return i;
> +}
> +
>  const char *
>  rte_cfgfile_get_entry(struct rte_cfgfile *cfg, const char *sectionname,
>  		const char *entryname)
> diff --git a/lib/librte_cfgfile/rte_cfgfile.h b/lib/librte_cfgfile/rte_cfgfile.h
> index d443782..67c9f6c 100644
> --- a/lib/librte_cfgfile/rte_cfgfile.h
> +++ b/lib/librte_cfgfile/rte_cfgfile.h
> @@ -126,6 +126,9 @@ int rte_cfgfile_has_section(struct rte_cfgfile *cfg,
> const char *sectionname);
>  /**
>  * Get number of entries in given config file section
>  *
> +* If multiple sections have the given name this function operates on the
> +* first one.
> +*
>  * @param cfg
>  *   Config file
>  * @param sectionname
> @@ -138,6 +141,9 @@ int rte_cfgfile_section_num_entries(struct rte_cfgfile
> *cfg,
> 
>  /** Get section entries as key-value pairs
>  *
> +* If multiple sections have the given name this function operates on the
> +* first one.
> +*
>  * @param cfg
>  *   Config file
>  * @param sectionname
> @@ -155,8 +161,38 @@ int rte_cfgfile_section_entries(struct rte_cfgfile
> *cfg,
>  	struct rte_cfgfile_entry *entries,
>  	int max_entries);
> 
> +/** Get section entries as key-value pairs
> +*
> +* The index of a section is the same as the index of its name in the
> +* result of rte_cfgfile_sections. This API can be used when there are
> +* multiple sections with the same name.
> +*
> +* @param cfg
> +*   Config file
> +* @param index
> +*   Section index
> +* @param entries
> +*   Pre-allocated array of at least max_entries entries where the section
> +*   entries are stored as key-value pair after successful invocation
> +* @param max_entries
> +*   Maximum number of section entries to be stored in entries array
> +* @param sectionname
> +*   Pre-allocated string of at least CFG_NAME_LEN characters where the
> +*   section name is stored after successful invocation.
> +* @return
> +*   Number of entries populated on success, negative error code otherwise
> +*/
> +int rte_cfgfile_section_entries_by_index(struct rte_cfgfile *cfg,
> +	int index,
> +	struct rte_cfgfile_entry *entries,
> +	int max_entries,
> +	char *sectionname);
> +
>  /** Get value of the named entry in named config file section
>  *
> +* If multiple sections have the given name this function operates on the
> +* first one.
> +*
>  * @param cfg
>  *   Config file
>  * @param sectionname
> @@ -172,6 +208,9 @@ const char *rte_cfgfile_get_entry(struct rte_cfgfile
> *cfg,
> 
>  /** Check if given entry exists in named config file section
>  *
> +* If multiple sections have the given name this function operates on the
> +* first one.
> +*
>  * @param cfg
>  *   Config file
>  * @param sectionname
> diff --git a/lib/librte_cfgfile/rte_cfgfile_version.map
> b/lib/librte_cfgfile/rte_cfgfile_version.map
> index bf6c6fd..f6a27a9 100644
> --- a/lib/librte_cfgfile/rte_cfgfile_version.map
> +++ b/lib/librte_cfgfile/rte_cfgfile_version.map
> @@ -13,3 +13,9 @@ DPDK_2.0 {
> 
>  	local: *;
>  };
> +
> +DPDK_2.3 {
> +	global:
> +
> +	rte_cfgfile_section_entries_by_index;
> +} DPDK_2.0;
> --
> 1.9.1

  reply	other threads:[~2016-02-19 15:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-17  3:58 [dpdk-dev] [PATCH] " Rich Lane
2016-01-18 12:58 ` Panu Matilainen
2016-01-19  4:41 ` [dpdk-dev] [PATCH v2] " Rich Lane
2016-01-21  7:42   ` Panu Matilainen
2016-02-02 15:10   ` Dumitrescu, Cristian
2016-02-10 19:13     ` Rich Lane
2016-02-10 19:12   ` [dpdk-dev] [PATCH v3] " Rich Lane
2016-02-16 20:48     ` Dumitrescu, Cristian
2016-02-16 22:58     ` [dpdk-dev] [PATCH v4] " Rich Lane
2016-02-19 15:18       ` Dumitrescu, Cristian [this message]
2016-02-22 20:30       ` [dpdk-dev] [PATCH v5] " Rich Lane
2016-02-23  0:12         ` Dumitrescu, Cristian
2016-02-25 20:43         ` [dpdk-dev] [PATCH v6] " Rich Lane
2016-02-25 20:49           ` Dumitrescu, Cristian
2016-02-29 10:29             ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3EB4FA525960D640B5BDFFD6A3D8912647953788@IRSMSX108.ger.corp.intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=rich.lane@bigswitch.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).