File:  [ELWIX - Embedded LightWeight unIX -] / embedtools / src / ube.c
Revision 1.1.2.2: download - view: text, annotated - select for diffs - revision graph
Tue Jan 28 08:28:18 2014 UTC (10 years, 4 months ago) by misho
Branches: tools2_0
add init

#include "global.h"
#include "ub_env.h"


int Verbose;
extern char compiled[], compiledby[], compilehost[];


static void
Usage()
{
	printf(	" -= U-Boot-Env =- Tool for u-boot-env nand map management\n"
		"=== %s === %s@%s ===\n\n"
		"  Syntax: ube [options] [set_value]\n"
		"\n"
		"\t-g <name>\tSet parameter to value\n"
		"\t-s <name>\tGet parameter value\n"
		"\t-v\t\tVerbose ...\n"
		"\n", compiled, compiledby, compilehost);
}

int
main(int argc, char **argv)
{
	char ch, mode = 0, szName[STRSIZ], szVal[STRSIZ] = { 0 };

	while ((ch = getopt(argc, argv, "hvg:s:")) != -1)
		switch (ch) {
			case 'g':
				mode = 1;
				strlcpy(szName, optarg, sizeof szName);
				break;
			case 's':
				mode = 2;
				strlcpy(szName, optarg, sizeof szName);
				break;
			case 'v':
				Verbose++;
				break;
			case 'h':
			default:
				Usage();
				return 1;
		}
	argc -= optind;
	argv += optind;
	if (mode == 2) {
	       	if (!argc) {
			Usage();
			return 1;
		} else
			strlcpy(szVal, *argv, sizeof szVal);
	}

	VERB(1) printf("u-boot-env: name=%s value=%s\n", szName, szVal);

	return 0;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>