Skip to contentSkip to conversation

Add a new "ini" command

PATCH Superseded Joe Hershberger 6 participants 10 messages Aug 17, 2012 – Oct 5, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add a new "ini" command

This allows you to read ini-formatted data from anywhere and then import one of the sections into the environment

This is based on rev 16 at http://code.google.com/p/inih/

---
 common/Makefile  |   1 +
 common/cmd_ini.c | 256 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 257 insertions(+)
 create mode 100644 common/cmd_ini.c
common/Makefile +1 -0
index 3d62775..e296368 100644
@@ -100,6 +100,7 @@ COBJS-$(CONFIG_CMD_GPIO) += cmd_gpio.o
 COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o
 COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o
 COBJS-$(CONFIG_CMD_IMMAP) += cmd_immap.o
+COBJS-$(CONFIG_CMD_INI) += cmd_ini.o
 COBJS-$(CONFIG_CMD_IRQ) += cmd_irq.o
 COBJS-$(CONFIG_CMD_ITEST) += cmd_itest.o
 COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o
common/cmd_ini.c new file +256 -0

256 lines not on this page · raw message

Signature · 1 line
1.7.11.5
#1 lore raw

PATCH 1/1 Add a new "ini" command

Quoted 4 lines · On Friday 17 August 2012 16:56:57 Joe Hershberger wrote:

This allows you to read ini-formatted data from anywhere and then import one of the sections into the environment

This is based on rev 16 at http://code.google.com/p/inih/

document it in top level README ?

common/cmd_ini.c

Quoted 4 lines
common/cmd_ini.c new file +1 -0
 
+int do_ini(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

static

Quoted 4 lines
common/cmd_ini.c new file +4 -0
+{
+	const char *section;
+	char *file_address;
+	size_t file_size;

common/cmd_ini.c line 239

Quoted 10 lines
common/cmd_ini.c new file +10 -0
+
+	if (argc == 1)
+		return CMD_RET_USAGE;
+
+	section = argv[1];
+	if (argc < 3)
+		file_address = (char *)simple_strtoul(getenv("loadaddr"),
+			NULL, 16);
+	else
+		file_address = (char *)simple_strtoul(argv[2], NULL, 16);

file_address = (char *)simple_strtoul(argc < 3 ? getenv("loadaddr") : argv[2],

	NULL, 16);

common/cmd_ini.c line 244

Quoted 5 lines
common/cmd_ini.c new file +5 -0
+	if (argc < 4)
+		file_size = (size_t)simple_strtoul(getenv("filesize"),
+			NULL, 16);
+	else
+		file_size = (size_t)simple_strtoul(argv[3], NULL, 16);

same here

common/cmd_ini.c line 250

Quoted 5 lines
common/cmd_ini.c new file +5 -0
+	ini_parse(file_address, file_size, ini_handler, (void *)section);
+
+	/* success */
+	return 0;
+}

return ini_parse() ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120817/7b44cbb0/attachment.pgp>

#2 lore raw

PATCH v2 1/1 Add a new "ini" command

In reply to Joe Hershberger

This allows you to read ini-formatted data from anywhere and then import one of the sections into the environment

This is based on rev 16 at http://code.google.com/p/inih/

---
Changes in v2:
- Documented in README
- Made all functions static
- Changed if statments to ternary operator selected parameters
- Return any errors from ini_parse() to the shell

 README           |   1 +
 common/Makefile  |   1 +
 common/cmd_ini.c | 247 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 249 insertions(+)
 create mode 100644 common/cmd_ini.c
README +1 -0
index af76b0c..dfa4f6b 100644
@@ -814,6 +814,7 @@ The following options need to be configured:
 		CONFIG_CMD_IMLS		  List all found images
 		CONFIG_CMD_IMMAP	* IMMR dump support
 		CONFIG_CMD_IMPORTENV	* import an environment
+		CONFIG_CMD_INI		* import data from an ini file into the env
 		CONFIG_CMD_IRQ		* irqinfo
 		CONFIG_CMD_ITEST	  Integer/string test of 2 values
 		CONFIG_CMD_JFFS2	* JFFS2 Support
common/Makefile +1 -0
index 125b2be..92e06de 100644
@@ -107,6 +107,7 @@ COBJS-$(CONFIG_CMD_GPIO) += cmd_gpio.o
 COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o
 COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o
 COBJS-$(CONFIG_CMD_IMMAP) += cmd_immap.o
+COBJS-$(CONFIG_CMD_INI) += cmd_ini.o
 COBJS-$(CONFIG_CMD_IRQ) += cmd_irq.o
 COBJS-$(CONFIG_CMD_ITEST) += cmd_itest.o
 COBJS-$(CONFIG_CMD_JFFS2) += cmd_jffs2.o
common/cmd_ini.c new file +247 -0

247 lines not on this page · raw message

Signature · 1 line
1.7.11.5
#3 lore raw

PATCH v2 1/1 Add a new "ini" command

Quoted 6 lines · Joe Hershberger

This allows you to read ini-formatted data from anywhere and then import one of the sections into the environment

This is based on rev 16 at http://code.google.com/p/inih/

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121003/d77e4848/attachment.pgp>
#4 lore raw

PATCH v2 1/1 Add a new "ini" command

In reply to Joe Hershberger
Quoted 18 lines · Joe Hershberger

This allows you to read ini-formatted data from anywhere and then import one of the sections into the environment

This is based on rev 16 at http://code.google.com/p/inih/

---
Changes in v2:
- Documented in README
- Made all functions static
- Changed if statments to ternary operator selected parameters
- Return any errors from ini_parse() to the shell

 README           |   1 +
 common/Makefile  |   1 +
 common/cmd_ini.c | 247 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 249 insertions(+)
 create mode 100644 common/cmd_ini.c

[...]

common/cmd_ini.c line 7

Quoted 13 lines
common/cmd_ini.c new file +7 -0
new file mode 100644
index 0000000..652e4f6
@@ -0,0 +1,247 @@
+/*
+ * inih -- simple .INI file parser
+ *
+ * inih is released under the New BSD license (see LICENSE.txt). Go to the
+ * project home page for more info:
+ *
+ * http://code.google.com/p/inih/

Hmmm, I'm wondering, is it the appropriate license for U-Boot code?

[...]

Signature · 2 lines
Regards,
Igor.
#5 lore raw

PATCH 1/1 Improve license declaration for cmd_ini.h

Instead of referenceing the source webpage (which can change) include the license in the source file.

---
 common/cmd_ini.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
common/cmd_ini.c +30 -2
index 652e4f6..74481cb 100644
@@ -1,9 +1,37 @@
 /*
  * inih -- simple .INI file parser
  *
- * inih is released under the New BSD license (see LICENSE.txt). Go to the
- * project home page for more info:
+ * Copyright (c) 2009, Brush Technology
+ * Copyright (c) 2012:
+ *              Joe Hershberger, National Instruments, joe.hershberger at ni.com
+ * All rights reserved.
  *
+ * The "inih" library is distributed under the following license, which is
+ * derived from and very similar to the 3-clause BSD license:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Brush Technology nor the names of its contributors
+ *       may be used to endorse or promote products derived from this software
+ *       without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Go to the project home page for more info:
  * http://code.google.com/p/inih/
  */
 
Signature · 1 line
1.7.11.5
#6 lore raw

PATCH 1/1 Improve license declaration for cmd_ini.h

Hi Joe,

Quoted 45 lines · Joe Hershberger

Instead of referenceing the source webpage (which can change) include the license in the source file.

---
 common/cmd_ini.c | 32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
common/cmd_ini.c +22 -2
index 652e4f6..74481cb 100644
@@ -1,9 +1,37 @@
 /*
  * inih -- simple .INI file parser
  *
- * inih is released under the New BSD license (see LICENSE.txt). Go to the
- * project home page for more info:
+ * Copyright (c) 2009, Brush Technology
+ * Copyright (c) 2012:
+ *              Joe Hershberger, National Instruments, joe.hershberger at ni.com
+ * All rights reserved.
  *
+ * The "inih" library is distributed under the following license, which is
+ * derived from and very similar to the 3-clause BSD license:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Brush Technology nor the names of its contributors
+ *       may be used to endorse or promote products derived from this software
+ *       without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY

common/cmd_ini.c line 36

Quoted 10 lines
common/cmd_ini.c +8 -0
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Go to the project home page for more info:
  * http://code.google.com/p/inih/
  */

Open question: does this solve worries about the licence compatibility?

Amicalement,

Signature · 1 line
Albert.
#7 lore raw

PATCH 1/1 Improve license declaration for cmd_ini.h

Dear Albert ARIBAUD,

Quoted 2 lines · In message <20121005192613.1420e39b@lilith> you wrote:

Open question: does this solve worries about the licence compatibility?

Not really; assuming that the previous version meant the 3-clause BSD license (which it most probably did) there have never been any real problems; at least http://directory.fsf.org/wiki/License:BSD_3Clause
says this is a GPL compatible license.

This patch tries to fix some ambiguities (to the extend we poor engineers are able to deal with legal texts).

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
An armed society is a polite society.
#8 lore raw

PATCH 1/1 Improve license declaration for cmd_ini.h

In reply to Joe Hershberger

Dear Joe Hershberger,

Quoted 2 lines · In message <[email protected]> you wrote:

Instead of referenceing the source webpage (which can change) include the license in the source file.

Thanks.

common/cmd_ini.c line 7

Quoted 12 lines
common/cmd_ini.c +4 -2
@@ -1,9 +1,37 @@
 /*
  * inih -- simple .INI file parser
  *
- * inih is released under the New BSD license (see LICENSE.txt). Go to the
- * project home page for more info:
+ * Copyright (c) 2009, Brush Technology
+ * Copyright (c) 2012:
+ *              Joe Hershberger, National Instruments, joe.hershberger at ni.com
+ * All rights reserved.

I'd prefer if you left out this "All rights reserved." But then,
there seems to be agreement amongt those to interpret such legal texts that this is a void staement anyway, so here is my

even if you leave it in.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
######## This message was made from 100% recycled electrons. ########
#9 lore raw

PATCH 1/1 Improve license declaration for cmd_ini.h

In reply to Joe Hershberger
Quoted 8 lines · Joe Hershberger

Instead of referenceing the source webpage (which can change) include the license in the source file.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121005/3bf47d85/attachment.pgp>