From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0042.outbound.protection.outlook.com [104.47.41.42]) by dpdk.org (Postfix) with ESMTP id DA54F695D for ; Thu, 27 Apr 2017 08:52:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=B5hAWXZEerJiGmLDHdvRvqT65KeAeWEc3zxDy77QZiQ=; b=Pur2vHydlsJYnb1LhlbpFMQoOUptQOodC05bPyol1Zxvt611RlPbc9qfGAWPXy/Wnx0OQPZzXRQ+LbPBvITgPwxSamVClcYnEdWLqJ5+fUvdC3pbuBfc8IUJ6YKXITjD8GZMbDuhetNKKQhfJ20rSmrT0LPzzrrV+hhZnnraqwU= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from prathyusha-Precision-Tower-5810.caveonetworks.com (111.93.218.67) by SN1PR0701MB2110.namprd07.prod.outlook.com (10.163.133.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13; Thu, 27 Apr 2017 06:52:19 +0000 From: Guduri Prathyusha To: cristian.dumitrescu@intel.com Cc: dev@dpdk.org, Guduri Prathyusha Date: Thu, 27 Apr 2017 12:21:40 +0530 Message-Id: <1493275900-4728-1-git-send-email-gprathyusha@caviumnetworks.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: PN1PR01CA0089.INDPRD01.PROD.OUTLOOK.COM (10.174.144.157) To SN1PR0701MB2110.namprd07.prod.outlook.com (10.163.133.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e06a3b81-a06d-4940-0809-08d48d39f3de X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:SN1PR0701MB2110; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB2110; 3:scXjYR4otjKMs3N64mATC9qk3CALHIxQ1RgRh3AP6eAGvoiC24O6eNucpr96qNTtPwBa/2uIiob0Ltvc0edvadLvFPiRM6IMOL2NfC/BAScIILJSI0LqvNf5WxWpxq9RQRURNJQYLvz6lzl0Nd7+QihgGVfIjjmL/OnJ334XOOz6ncrqhpYBf7L5AIO4CU/FSCISFauq3m6UIN7JL5pCjFzsVwm9HDr1qUpLnGzJFL9alC9VxzgzxwktKOQA+bFchSyXvl/62AazAk3wLg7Kqm623kfHgmOljpd91CRQAv80ERjdVgYOaj+7x85bt36K8ynI4CVVZEEK4mYYeCOYUg==; 25:/c1vOwV8uNqmO8WmudPioNTy8Ddil8//EVu6aTU6cvs1of+EnQsptBJCSUNo4SvOW/x/Nv6U1HOH+NcYu6eahg+O8a1E/1tsu1V4F/kfzAMkQ9vfZbZl7cObmec04UvbvDENmPnK+seR+Nhka/aMxujaPywnHym/J4n3Pxl2KvUdeqspysWTUAhDxv5YiwqwT2BLSI2DKZP79xJ5ZqlkHqZboHIdQryY+uaM/hveZURcTFktUXqZhfWbSt2/SPWUTBPav58LMVllIjpWMj0B85AIq4tCbZ500fv+Sp37K2ac4s/QlTnMSiea6GLoVSuXL3TEc1nqOQAllDTh2bz3q/4ALX/6XCc5sXdIbu37NlKQ22eBNBX/l0PxijuRJo0BYYfE85bmwxA5rxnRunuBOEKX/g7DUUw1WF5iRQKX/4ExwiT34O7pEcLkPMEWMTAkKEGywSTA7ldMhpuG0OHIxg== X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB2110; 31:qjTirTboDJV3HDT2agRYbJh6H9I4I5cp0n7tTS2si5y6I7tu+VW5NaC6l2zvNAojV4bBGGVj5KfDy4PxD25veeeEMyH5FdyEkBaje6evyoMY3x8JYhC2CDchnE4rHREZqxOP34je0Y1IZ+kc6HcQDJqTf8m1U+DCHC0QQdwnznkiJxqenWZhjGt9WXNwqwAc0W691GemVRpDK/FgXwuN0VhEvHMsmk0I9BIPXSm74Gk=; 20:2wffvBngZ0SiQwIVSQFyLkdfrKL+h0ey17GXNR81CXhru6c9gxIN6VN0BwM2gwZY+wqbtD1mUAkLygOLZvcO5vurdmZD6QQCa+2osT0X5xl1nozjUNF00S9lVfCZlBCmC3AO/jixaKJciJZ/P9wAiqhQQqtneUTjw9muw8l6Nku62pPZ5pn5KP+GW4HP0nKwxVumAJ52QqfgQjzPu93JPlIlTmjZpivpWXS8qzI70ehG5xl/zQ8yIYIGeWGkhwnBH6KE7+a+b1Gmk7yg6slU/DGEMjIFTroz23nrFhdZMxmHrhrXz3iPUWCrpCNLx2ZjR/4zXfLPFghJyJvuOnZS0VbWcKKyXzYuGCvWBirwlfjIuEX20lF1IbU1eP6nvQsorz/OI/zVzhMuvhgKS+Sh8u4kdcdoApDoGUfqWCIdyZ4VZJ0PrewWKmJMn/X7T05tZW8doqZkSjlzkKIjfsGNyC9aiBvCebOMJu84mKPEf1yA79PzdrHCAX2AWNbaxmagzcQfZsLwG7W2pxuGXY3f5LbiS1GIjs1Kk54Fggfdomqod7b/9k6u9rDxMxDbw1VSMa9rMdjoAEowvxygwEAxeYz9IborjuNk/jBmg2GZ+XA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(10201501046)(3002001)(6041248)(20161123560025)(20161123555025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(6072148); SRVR:SN1PR0701MB2110; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0701MB2110; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB2110; 4:wAvGGBZcCPAN/ts0zTR1VN+QDHdqnJB1w+B6rvJzcUunvAVL1GAMRjCOLMo+HQQzViMUrY5gb2eZOj21QR6ThATqjSvpCA0H/OY37+HY3lTjO+fMsI+pvIdObtG+2/ClawWVIpyRjhnRaTqKwhMTLTMalx1jH7YyqKdGTCeJoXvlnhEEIy/6Vy+ukQ0amxZK6trTpz6UUq6Qmxje5no49AQ21m/JOSGL9Ed/fl0VnCuyMH1JOcr36zskRLM43pqVayaup+SDswKy8xlHLmav99xl3EOQ586JFZ26msoymQJ8WRmoPCxHlALu5BWdMPIL75ir3OLBGZP8oFIJOIae58Sj4RbFqCqMlB1esUe4I/vBEnblPG9wW+D8hiW4JN+fVJGWr5OxbbsL2aReZDjORy93rFzuOdbT/v5psIw0MG6IwK0jjVO3/mg+/LB7w/+Nrbhm1G0hySp+FpqnUIQHAR1XhZpv9iqcNtXqKELxKOgabPeGshXM8gxGXXW5hqtZq90+K8IlTWXhWNdUWdz65/BIYXtSFysuMSe4mmq3Fzh61yuTXD9lt2jZBwCC7/aJNFYXNnX0tQukSzwV+TnxH0iAPxXjuQH7WXkib9ocEn012aEEfqy1MFXYEYTgT/NU+Vf+ir2G2CTBjqtGqBtaVqjaxj3fBtSQk1um8/v+vZXFaH67AIgWvuHsiWWfghMZ X-Forefront-PRVS: 029097202E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39840400002)(39450400003)(39410400002)(39400400002)(39850400002)(2351001)(7736002)(66066001)(36756003)(33646002)(5660300001)(5003940100001)(50466002)(5009440100003)(305945005)(2906002)(6116002)(3846002)(2361001)(47776003)(53936002)(107886003)(48376002)(53416004)(42186005)(50986999)(6512007)(6506006)(189998001)(110136004)(6486002)(38730400002)(4326008)(6916009)(42882006)(6666003)(25786009)(50226002)(81166006)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0701MB2110; H:prathyusha-Precision-Tower-5810.caveonetworks.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0701MB2110; 23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pj9dId1yo3096ONHwHK99zM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB2110; 7:JkbuFwrZsIseQZZUTAJL55N/EvV6xQGxIBMtJoSID/bmQ0DBbyDA15bUEPHwKp/qMNmfi1wKWWnFxYoPU0FWOyVKzCYlkMe9qOIKDmiDGLFxf8r7UfihiNGuEm7Omjb0rtLSkWP2f/8EbcH7s4FuV4eRRLAQLiyWYKi9fp6Zra05VAfbH28iN5Bhy/7tCUNOs/+LFuFtZMvh04dAuL8K+b+i6d48BvS6HHAUUtKzUxqHMdkiWR7zpxPmRPCdoHd7xSoQCAO0KTUXFxoW+YwRfKP0q9ic5mifoiAQEUfFfREnYNkL/XBikP+MEP2oz2KUaFYUdwXSLrt1V8ZDMxp7bQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2017 06:52:19.5707 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0701MB2110 Subject: [dpdk-dev] [PATCH] librte_cfgfile: add section num entries by index X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Apr 2017 06:52:24 -0000 rte_cfgfile_section_num_entries_by_index() is added to get the number of entries of a section when multiple sections of the same name are present. Signed-off-by: Guduri Prathyusha --- lib/librte_cfgfile/rte_cfgfile.c | 13 +++++++++++++ lib/librte_cfgfile/rte_cfgfile.h | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c index b54a523..2588093 100644 --- a/lib/librte_cfgfile/rte_cfgfile.c +++ b/lib/librte_cfgfile/rte_cfgfile.c @@ -408,7 +408,20 @@ int rte_cfgfile_close(struct rte_cfgfile *cfg) return s->num_entries; } +int +rte_cfgfile_section_num_entries_by_index(struct rte_cfgfile *cfg, + char *sectionname, int index) +{ + 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); + + return sect->num_entries; +} int rte_cfgfile_section_entries(struct rte_cfgfile *cfg, const char *sectionname, struct rte_cfgfile_entry *entries, int max_entries) diff --git a/lib/librte_cfgfile/rte_cfgfile.h b/lib/librte_cfgfile/rte_cfgfile.h index fa10d40..35dc419 100644 --- a/lib/librte_cfgfile/rte_cfgfile.h +++ b/lib/librte_cfgfile/rte_cfgfile.h @@ -184,6 +184,26 @@ int rte_cfgfile_section_num_entries(struct rte_cfgfile *cfg, const char *sectionname); /** +* Get number of entries in given config file section +* +* 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 sectionname +* Section name +* @param index +* Section index +* @return +* Number of entries in section on success, -1 otherwise +*/ +int rte_cfgfile_section_num_entries_by_index(struct rte_cfgfile *cfg, + char *sectionname, + int index); + +/** * Get section entries as key-value pairs * * If multiple sections have the given name this function operates on the -- 1.7.9.5