looking for more project ideas

David Collier-Brown davec-b at rogers.com
Mon May 1 18:54:15 GMT 2006


Gerald (Jerry) Carter wrote:
> We have as one project "Solve the parameter bloat problem" :-)
> I'm thinking that maybe this type of consistency checking
> could be one of the requirements for a new system.  Every band
> aid that we apply to the current systems seems to be too
> intrinsically tied to loadparm.c and the parser.  The consistency
> checks should be logically independent I think.
> 
> I'm not completely convinced 'm right on this one though.
> Just sort of a knee jerk reaction.

	I think reexamining the problem is A Good Idea.

	
	Let me propose that the structure turn into
	a loop which reads the line, expands any
	variables into a buffer and calls a back-end
	that doesn't have to parse anything. Then the
	same back end can use different front ends

	Perhaps the file parser might look like

	while (getline(line, size, fd) != EOF) {
		if ((name = getname(buffer) == NULL) {
			complain("no option, line);
			continue;
		}
		if (section_name(name)) {
			crosscheck_old_section(s);
			s = start_new_section(name);
			continue
		}
		if ((value = parseval(p+2, buffer)) != NULL) {
			complain("no value", line);
			continue;
		}
		else if ((rc = add_option(s,name,value,errstr)) != 0) {
			switch (rc) {
			case 1: warning(errstr);
				break;
			case 2: error(errstr);
				break;
			case 3: horrible, can't continue
				fatal(errstr);
				exit(3);
			}
		}
	}

	A parser for something else could use the same add_option()
	and logic

--dave		
-- 
David Collier-Brown,         | Always do right. This will gratify
System Programmer and Author | some people and astonish the rest
davecb at spamcop.net           |                      -- Mark Twain
(416) 223-5943


More information about the samba-technical mailing list