DragonFly kernel List (threaded) for 2007-08
DragonFly BSD
DragonFly kernel List (threaded) for 2007-08
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[no subject]


Date:

> <46B90B0B.2040704@199technologies.org> <46B91EDC.4080904@199technologies.org>
From: "Simon 'corecode' Schubert" <corecode@fs.ei.tum.de>
Subject: Re: vkernel.conf ?
Date: Wed, 08 Aug 2007 09:00:12 +0200
BestServHost: crater.dragonflybsd.org
List-Post: <mailto:kernel@crater.dragonflybsd.org>
List-Subscribe: <mailto:kernel-request@crater.dragonflybsd.org?body=subscribe>
List-Unsubscribe: <mailto:kernel-request@crater.dragonflybsd.org?body=unsubscribe>
List-Help: <mailto:kernel-request@crater.dragonflybsd.org?body=help>
List-Owner: <mailto:owner-kernel@crater.dragonflybsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
In-Reply-To: <46B91EDC.4080904@199technologies.org>
Sender: kernel-errors@crater.dragonflybsd.org
Errors-To: kernel-errors@crater.dragonflybsd.org
Lines: 52
NNTP-Posting-Host: 216.240.41.25
X-Trace: 1186557146 crater_reader.dragonflybsd.org 808 216.240.41.25
Xref: crater_reader.dragonflybsd.org dragonfly.kernel:11403

Chris Turner wrote:
[some ini parsers]

> thoughts?

could we PLEASE get over this?  nobody needs sections for now!  so this is the code we can use directly in vkernel (untested, off head):

FILE *conff;
char line[1000];

conff = fopen(confname, "r");
if (conff == NULL)
	err(1, "open config `%s'", confname);

while (fgets(line, sizeof(line), conff) != NULL) {
	char *key, *val;

	key = line + strspn(line, " \t");
	if (*key == '#')
		continue;

	val = strchr(key, '=');
	if (val == NULL)
		val = "1";	/* or error out */
	else
		*val = 0;

	/* Eat whitespace */
	val = val + strspn(val, " \t");
	while (*key != 0 && strchr(" \t", key[strlen(key) - 1]) != NULL)
		key[strlen(key) - 1] = 0;
	while (*val != 0 && strchr(" \t", val[strlen(val) - 1]) != NULL)
		val[strlen(val) - 1] = 0;

	if (*key == NULL)
		continue;

	if (strcmp(key, "memory") == 0) {
		/* ... */
	} /* etc */
}

fclose(conff);

cheers
  simon

-- 
Serve - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /"\
Work - Mac      +++  space for low ��� NOW!1  +++      Campaign     \ /
Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]