Re: Automatic Configuration of a Kernel

Ahmad Reza Cheraghi
2005-09-15T20:58:44Z

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

--- Daniel Thaler <thalerd@in.tum.de> wrote:

> Lee Revell wrote:
> > Why does this have to be in the kernel again?
> Isn't this exactly what
> > you get with a fully modular config and hotplug?
>
> It doesn't go in the kernel. If I understand
> correctly, it's a script that is
> invoked by 'make autoconfig'. Note that I didn't
> read the patch, because it's a
> .tgz on a website and I couldn't be bothered to
> download it.

Since im a new Bee, I didn't know that I patched
shouldnt be tgz. So here is a new patch as URL and
attachment.
The URL :
www.energyparty.de/ahmad/autoconfig.patch

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[-- Attachment #2: 1146041466-autoconfig.patch --]
[-- Type: application/octet-stream, Size: 71135 bytes --]

diff -urN linux.org/Documentation/autoconf.txt linux-2.6.13/Documentation/autoconf.txt
--- linux.org/Documentation/autoconf.txt 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/Documentation/autoconf.txt 2005-09-15 15:36:35.000000000 +0200
@@ -0,0 +1,161 @@
+
+Constist:
+********
+
+The Linux Auto-Config consist of Files, auto_conf.c, an upgraded conf.c and Makefile, a directory
+(rules) which contains a rules_list and the scripts, and a xmlparser written by Tim Hockin.
+
+
+
+
+How does it work:
+*****************
+
+The trick of all is a framworking program, that means adding binaries or scripts without
+touching the real program. The program starts like if you are starting a make config, but at that point
+where it wants an input from you, the function auto_conf gets called with that option-question
+as a parameter. We are comparing this option with in a list manual-written
+Kconfig option. Each of those options in the list has its own script which will be
+executed in parallel by accordance. For putting an option in the rules_list you need
+the Option and a script that does the work for the option and then gives a value
+to the stout. This value will be redirected through a pipe to our main program which will
+write the config-name for the option into the .config file.
+
+
+
+
+How to add a rule:
+*******************
+
+
+The basic of the script is that it must give an answer to stdout.
+Since the rules_list is written in xml there are some conditions for adding rules.
+To add a rule (for the specified option), you have to know first the option name
+and the name of the menu that contains it.
+The easiest way, to do this, is to run make menuconfig, and see in which menu or submenu your option belongs to.
+Each of those has its own XML-Tag:
+
+
+<rules>: beginnging of the list.
+
+ :
+ Has the attribute "name" and "must_have". In attribute "name" the name of the menu should be written.
+ Attribute "must_have" shows the min. number of option, that in a menu should be choosen for a proper Kernel.
+ can contains options or submenus(the same as ).
+
+ rule
+ In the attribut name the option name should be written. And the contain of the Option Tag
+ is the name of rule that belongs to that option.
+
+example:
+
+<rules>
+
+ egrep1.pm "Network|Ethernet"
+
+ yes1.pm
+ yes1.pm
+
+
+</rules>
+
+
+How to make a rule
+*******************
+
+A rule can be either a script or binary or... The main job is to
+give out an answer to stout for the actually option-question, it doesn't matter
+how.
+
+We have three types of answer:
+
+sym-answers: either y, n, m or \n.
+
+string-answer: can be maximal 128 characters
+
+option-answer: By the manual configuration normally you have to type an number
+ but a rule for an option should give out an y, if it want to be choosen.
+
+
+
+
+
+For example: the option is "Networking Support"
+ the program looks in the our list (which is called rules_list)
+ to find the "Networking Support" and if this option is in there,
+ a certain script (which we call it a rule) will be executed.
+ In this example the script name is hw_grep1.pm which
+ reads a given Parameter and searches for this Parameter,
+ lspci and dmesg with the help of grep. In this Case the Parameter
+ will be "Ethernet|Network".
+
+ hw_grep1.pm:
+
+ $found='';
+ $found=`lspci | grep "@ARGV"`;
+ if($found ne '') {
+ print("y\n");
+ }
+ else {
+ $found=`grep -E "@ARGV" /var/log/dmesg `;
+ if($found ne ''){
+ print("y\n");
+ }
+ else {
+ print("n\n");
+ }
+ }
+ 1;
+
+
+
+
+
+ This script checks if there is an Ethernet or
+ a Network card on the target System.
+ If it is true, it gives in this case a 'y' to stdout.
+ And for some options there can't be any script-rules, for instance software such as FTP or TCPIP etc...,
+ those question either get answered as 'build in' or as 'module'.
+ !! the answers must always have a '\n' at the end
+
+The rule-binary should be copied in the directory <KERNELVERSION>/scripts/kconfig/rules/
+
+
+
+Messages:
+*******************
+
+When the amount of needed Options in some menus are not choosen,
+messages will be given out in the stdout, at the end of the configuration.
+Containig Name of the menus.
+
+This can be happen:
+
+1. if for some options they rules are not applied. The reason for that is for some Hardware Option there is no rule.
+
+2. if your System doesn't support the Hardware i.e. you don't have an ethernet Card.
+
+In this case either your upgrade the autoconfig with rules or your contact me.
+
+If you are getting messages please include the following information:
+
+1. a copy of your lspci, /proc/cpuinfo and /var/log/dmesg
+
+2. a copy of your messages
+
+
+
+TO DO:
+*******************
+
+1. The Framework has to be extend for the Systems that aren't supported.
+
+2 .A way to ask for the Hardware-Devices directly from the I/O.
+
+
+Contact:
+*******************
+
+Suggestion and comments are welcome.
+
+Email: Ahmad Reza Cheraghi <a_r_cheraghi@yahoo.com>
diff -urN linux.org/scripts/kconfig/auto_conf.c linux-2.6.13/scripts/kconfig/auto_conf.c
--- linux.org/scripts/kconfig/auto_conf.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/auto_conf.c 2005-09-15 15:39:40.000000000 +0200
@@ -0,0 +1,302 @@
+/**************************************************************************************
+* *
+* auto_conf.c: Framework for autogeneration a Kernel Configuration *
+* *
+* This project was done in the Niederrhein University of Applied Sciences *
+* *
+* Copyright (C) 2005 Ahmad Reza Cheraghi <a_r_cheraghi@yahoo.com> *
+* This is free software, see GNU General Public License 2 for details. *
+* *
+* *
+* This Framework autogenerate a Configuration based on the given rules *
+* It does not guaranty that a Kernel can work after this generation since *
+* it is in his test-stage. *
+* *
+* *
+* Report errors, bugs, additions, wishes and comments to me: *
+* <a_r_cheraghi@yahoo.com> *
+* *
+* For futher information please refer to the README.txt *
+* *
+* *
+**************************************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#include "xmlparser.h"
+
+static struct xml_element *ret;
+signed char answerbuf[128];
+int error_flag = 0;
+
+static int reading_xml_tree(struct xml_element* element, const char * option);
+
+enum {
+ read_tree,
+ check_tree
+} tree_mode = read_tree;
+
+
+
+/************************************************************************
+ * exec_rule() *
+ * *
+ * calls a child process, that redirect stout to the pipe *
+ * and execute the rule-script throught the Unix Process *
+ * system(). *
+ * The parent reads from the pipe, and copied in the variable *
+ * answer. *
+ ***********************************************************************/
+
+static int exec_rule(const char* rule)
+{
+ int pd[2];
+ pid_t childpid;
+ char directory[128];
+
+ /*
+ * reading the dirctory where the rules are
+ */
+ strncpy(directory,"scripts/kconfig/rules/", 128);
+
+ strcat(directory, rule);
+
+ pipe(pd);
+
+ if (( childpid = fork() ) == 0) {
+ dup2(pd[1], STDOUT_FILENO);
+
+ close(pd[0]);
+ close(pd[1]);
+ /*
+ * calling the rule
+ */
+ system(directory);
+ exit(0);
+ }
+ close(pd[1]);
+ /*
+ * waiting for the child process to complete
+ */
+ while ( wait ((int *) 0) != childpid)
+ continue;
+ /*
+ * reading from the pipe, that is the answer from the rule
+ */
+ read( pd[0], answerbuf, 128 );
+ close(pd[0]);
+ return 0;
+}
+
+
+/************************************************************************
+* get_rule() *
+* *
+* compares the option from the rules_list with the actual *
+* option, if they are the same, the rule that is containing *
+* int the list will be read and give to the function exec_rule *
+* *
+* After that, it will be checked if the answer is positive and it *
+* so and if the menu has a priority for arising the must_have *
+* counter. *
+* *
+***********************************************************************/
+
+static int get_rule (struct xml_element* child, const char * option)
+{
+ struct xml_prop *attribute;
+ char content[128];
+ attribute = NULL;
+
+ attribute = get_next_attribute(child, attribute);
+
+ if (attribute==NULL) {
+ return 0;
+ }
+
+ if (strcmp(get_attribute_name(attribute),"name") != 0) {
+ printf("error in rules_list by Tag \n");
+ exit(1);
+ }
+ /*
+ * comparing actual option with attribute
+ */
+ if (( strcmp(get_attribute_value(attribute),option)) != 0) {
+ return 0;
+ }
+
+ /*
+ * reading in the rule(script-)-namei from list
+ */
+ strcpy(content, get_element_content(child));
+ /*
+ * executing the script
+ */
+ exec_rule(content);
+ if (child->parent->m_h_prior == 1) {
+ /*
+ * if answer is positive
+ */
+ if(answerbuf[0] == 'y' && answerbuf[1] == '\n') {
+ /*
+ * then arise the must_have
+ * counter
+ */
+ child->parent->m_h_cnt++;
+ }
+ }
+ return 0;
+}
+
+
+/************************************************************************
+* init_must_have() *
+* *
+* if there is any must_have attribute in the tag *
+* it will be initialised, here. *
+* *
+***********************************************************************/
+
+
+
+static int init_must_have(struct xml_element* child){
+
+ struct xml_prop *attribute;
+ attribute = NULL;
+ while ( (attribute = get_next_attribute(child, attribute))) {
+ if (strcmp(get_attribute_name(attribute),"must_have") == 0) {
+ if ( child->m_h_prior != 1) {
+ child->m_h_prior = 1;
+ if (attribute->prev) {
+ strncpy(child->option_name,
+ get_attribute_value(attribute->prev)
+ ,128);
+ } else {
+ printf("error in"
+ "rules_list by Tag \n");
+ exit(1);
+ }
+ child->m_h_value =
+ atoi(get_attribute_value(attribute));
+ child->m_h_cnt = 0;
+ }
+ }
+ }
+ return 0;
+}
+
+
+/************************************************************************
+* reading_xml_tag() *
+* *
+* This function reads the needed xml tags, they are the *
+* and tag. *
+* *
+***********************************************************************/
+
+
+static int reading_xml_tag(struct xml_element* child, const char * option)
+{
+ switch (tree_mode) {
+ case read_tree:
+ if (strcmp(get_element_name(child), "menu") == 0) {
+ init_must_have(child);
+ } else if ((strcmp(get_element_name(child), "option")) == 0) {
+ get_rule(child, option);
+ }
+ break;
+
+ case check_tree:
+ if (strcmp(get_element_name(child), "menu") == 0) {
+ if (child->m_h_prior==0) {
+ return 0;
+ }
+ if ((child->m_h_cnt) < (child->m_h_value) ) {
+ error_flag = 1;
+ printf("\n\n*********************error**"
+ "*******************\n");
+ printf("from %i needed options are %i"
+ " choosen in menu \" %s \"\n"
+ , child->m_h_value,child->m_h_cnt,
+ child->option_name);
+ }
+ }
+ break;
+ }
+ return 0;
+}
+
+
+/************************************************************************
+* reading_xml_tree() *
+* *
+* the xml list is copied in struct variable, which conist of *
+* childs and nodes. *
+* The reading of this variable will be done by recursive *
+* calling the raeding_xml_tree() *
+* *
+***********************************************************************/
+
+
+int
+reading_xml_tree(struct xml_element* element, const char * option)
+{
+ struct xml_element *child;
+ child = NULL;
+ /*
+ * Asking for a child
+ */
+ if((child = get_first_child(element))) {
+ reading_xml_tag(child, option);
+ reading_xml_tree(child, option);
+ }
+
+ if( (child = get_next_node(element)) ) {
+ reading_xml_tag(child, option);
+ reading_xml_tree(child, option);
+ }
+ return 0;
+}
+
+
+int
+auto_conf(char *option, char answer[128])
+{
+ static int flag = 0;
+ struct xml_buffer buffer;
+ tree_mode = read_tree;
+ answerbuf[0] = '\n';
+ answerbuf[1] = 0;
+ answerbuf[2] = 0;
+
+ if (flag == 0) {
+ buffer = load_xml_file("scripts/kconfig/rules/rules_list.xml");
+ if ( xml_parse_buffer(buffer, &ret) ) {
+ printf("error by parsing \n");
+ }
+ free(buffer.text);
+ flag = 1;
+ }
+ reading_xml_tree(ret, option);
+ strncpy(answer,answerbuf,128);
+ printf("%s", answer);
+ return 0;
+}
+
+void must_have(void)
+{
+ tree_mode = check_tree;
+ reading_xml_tree(ret, NULL);
+ if(error_flag)
+ printf("\nIf messages are shown above it is not guarantied\n"
+ "that the Kernel will work properly after installing\n"
+ "or your System does't support the above HW\n "
+ "for further help please refer to the Documentation/autoconf.txt\n");
+}
diff -urN linux.org/scripts/kconfig/conf.c linux-2.6.13/scripts/kconfig/conf.c
--- linux.org/scripts/kconfig/conf.c 2005-08-29 01:41:01.000000000 +0200
+++ linux-2.6.13/scripts/kconfig/conf.c 2005-09-06 11:07:42.000000000 +0200
@@ -12,7 +12,8 @@

#define LKC_DIRECT_LINK
#include "lkc.h"
-
+int auto_conf(const char *option, char line[128]);
+void must_have(void);
static void conf(struct menu *menu);
static void check_conf(struct menu *menu);

@@ -24,21 +25,22 @@
set_yes,
set_mod,
set_no,
- set_random
+ set_random,
+ set_auto
} input_mode = ask_all;
char *defconfig_file;

static int indent = 1;
static int valid_stdin = 1;
static int conf_cnt;
-static char line[128];
+static signed char line[128];
static struct menu *rootEntry;

static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");

-static void strip(char *str)
+static void strip(signed char *str)
{
- char *p = str;
+ signed char *p = str;
int l;

while ((isspace(*p)))
@@ -63,7 +65,7 @@
}
}

-static void conf_askvalue(struct symbol *sym, const char *def)
+static void conf_askvalue(struct symbol *sym, const char *def, const char *option)
{
enum symbol_type type = sym_get_type(sym);
tristate val;
@@ -80,7 +82,6 @@
line[1] = 0;
return;
}
-
switch (input_mode) {
case ask_new:
case ask_silent:
@@ -89,6 +90,24 @@
return;
}
check_stdin();
+ case set_auto:
+ fflush(stdout);
+ auto_conf(option, line);
+ if(line[0]=='y'){
+ if (!(sym_tristate_within_range(sym, yes))){
+ line[0] = 'm';
+ line[1] = '\n';
+ line[2] = 0;
+ }
+ }
+ if(line[0]=='m'){
+ if (!(sym_tristate_within_range(sym, mod))){
+ line[0] = 'y';
+ line[1] = '\n';
+ line[2] = 0;
+ }
+ }
+ return;
case ask_all:
fflush(stdout);
fgets(line, 128, stdin);
@@ -169,7 +188,7 @@
def = sym_get_string_value(sym);
if (sym_get_string_value(sym))
printf("[%s] ", def);
- conf_askvalue(sym, def);
+ conf_askvalue(sym, def, menu_get_prompt(menu));
switch (line[0]) {
case '\n':
break;
@@ -226,9 +245,10 @@
if (sym->help)
printf("/?");
printf("] ");
- conf_askvalue(sym, sym_get_string_value(sym));
+ conf_askvalue(sym, sym_get_string_value(sym), menu_get_prompt(menu));
+ if(input_mode==set_auto)
+ line[1]=0;
strip(line);
-
switch (line[0]) {
case 'n':
case 'N':
@@ -326,6 +346,23 @@
if (!sym_has_value(child->sym))
printf(" (NEW)");
printf("\n");
+/***************{****************** NEW ***********************************************/
+#if 1
+ if(input_mode==set_auto){
+ auto_conf(menu_get_prompt(child), line);
+ if(line[0]=='y'){
+ sprintf(line, "%i", cnt);
+ break;
+ }
+ else {
+ line[0] = '\n';
+ line[1] = 0;
+ }
+ }
+#endif
+/*************************************************************************************/
+
+
}
printf("%*schoice", indent - 1, "");
if (cnt == 1) {
@@ -348,6 +385,7 @@
case ask_all:
fflush(stdout);
fgets(line, 128, stdin);
+ case set_auto:
strip(line);
if (line[0] == '?') {
printf("\n%s\n", menu->sym->help ?
@@ -484,7 +522,7 @@

int main(int ac, char **av)
{
- int i = 1;
+ int i = 1;
const char *name;
struct stat tmpstat;

@@ -493,6 +531,9 @@
case 'o':
input_mode = ask_new;
break;
+ case 'a':
+ input_mode = set_auto;
+ break;
case 's':
input_mode = ask_silent;
valid_stdin = isatty(0) && isatty(1) && isatty(2);
@@ -557,6 +598,7 @@
}
case ask_all:
case ask_new:
+ case set_auto:
conf_read(NULL);
break;
default:
@@ -566,7 +608,7 @@
if (input_mode != ask_silent) {
rootEntry = &rootmenu;
conf(&rootmenu);
- if (input_mode == ask_all) {
+ if (input_mode == ask_all || input_mode == set_auto) {
input_mode = ask_silent;
valid_stdin = 1;
}
@@ -575,6 +617,8 @@
conf_cnt = 0;
check_conf(&rootmenu);
} while (conf_cnt);
+ if(av[1][1]=='a')
+ must_have();
if (conf_write(NULL)) {
fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
return 1;
diff -urN linux.org/scripts/kconfig/Makefile linux-2.6.13/scripts/kconfig/Makefile
--- linux.org/scripts/kconfig/Makefile 2005-08-29 01:41:01.000000000 +0200
+++ linux-2.6.13/scripts/kconfig/Makefile 2005-09-06 11:07:42.000000000 +0200
@@ -2,7 +2,7 @@
# Kernel configuration targets
# These targets are used from top-level makefile

-.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
+.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig

xconfig: $(obj)/qconf
$< arch/$(ARCH)/Kconfig
@@ -17,19 +17,16 @@
config: $(obj)/conf
$< arch/$(ARCH)/Kconfig

+autoconfig: $(obj)/conf
+ @if [ -f .config ]; then rm .config; fi;
+ $< -a arch/$(ARCH)/Kconfig
+
oldconfig: $(obj)/conf
$< -o arch/$(ARCH)/Kconfig

silentoldconfig: $(obj)/conf
$< -s arch/$(ARCH)/Kconfig

-update-po-config: $(obj)/kxgettext
- xgettext --default-domain=linux \
- --add-comments --keyword=_ --keyword=N_ \
- --files-from=scripts/kconfig/POTFILES.in \
- -o scripts/kconfig/linux.pot
- scripts/kconfig/kxgettext arch/$(ARCH)/Kconfig >> scripts/kconfig/linux.pot
-
.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig

randconfig: $(obj)/conf
@@ -57,12 +54,10 @@

# Help text used by make help
help:
- @echo ' config - Update current config utilising a line-oriented program'
+ @echo ' oldconfig - Update current config utilising a line-oriented program'
@echo ' menuconfig - Update current config utilising a menu based program'
@echo ' xconfig - Update current config utilising a QT based front-end'
@echo ' gconfig - Update current config utilising a GTK based front-end'
- @echo ' oldconfig - Update current config utilising a provided .config as base'
- @echo ' randconfig - New config with random answer to all options'
@echo ' defconfig - New config with default answer to all options'
@echo ' allmodconfig - New config selecting modules when possible'
@echo ' allyesconfig - New config where all options are accepted with yes'
@@ -79,11 +74,9 @@
# Based on GTK which needs to be installed to compile it
# object files used by all kconfig flavours

-hostprogs-y := conf mconf qconf gconf kxgettext
-conf-objs := conf.o zconf.tab.o
+hostprogs-y := conf mconf qconf gconf
+conf-objs := conf.o auto_conf.o xmlparser.o xmlutil.o zconf.tab.o
mconf-objs := mconf.o zconf.tab.o
-kxgettext-objs := kxgettext.o zconf.tab.o
-
ifeq ($(MAKECMDGOALS),xconfig)
qconf-target := 1
endif
@@ -115,11 +108,7 @@
HOSTCFLAGS_gconf.o = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags` \
-D LKC_DIRECT_LINK

-$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o $(obj)/kxgettext: $(obj)/zconf.tab.h
-
-$(obj)/zconf.tab.h: $(src)/zconf.tab.h_shipped
-$(obj)/zconf.tab.c: $(src)/zconf.tab.c_shipped
-$(obj)/lex.zconf.c: $(src)/lex.zconf.c_shipped
+$(obj)/conf.o $(obj)/mconf.o $(obj)/qconf.o $(obj)/gconf.o: $(obj)/zconf.tab.h

$(obj)/qconf.o: $(obj)/.tmp_qtcheck

diff -urN linux.org/scripts/kconfig/rules/4gbmem.pm linux-2.6.13/scripts/kconfig/rules/4gbmem.pm
--- linux.org/scripts/kconfig/rules/4gbmem.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/4gbmem.pm 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+
+$mem_var=`cat /proc/meminfo | grep MemTotal`;
+chop($mem_var);
+$mem_var=~/['0-9']+/g;
+$mem_var=$&;
+
+if(4290000 < $mem_var && $mem_var < 640000000) {
+ print("y\n");
+}
+
+else {
+ print("n\n");
+}
diff -urN linux.org/scripts/kconfig/rules/arch.pm linux-2.6.13/scripts/kconfig/rules/arch.pm
--- linux.org/scripts/kconfig/rules/arch.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/arch.pm 2005-09-15 12:16:19.000000000 +0200
@@ -0,0 +1,9 @@
+#!/usr/bin/perl
+
+$test='';
+$test=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/`;
+chop($test);
+if($test eq "@ARGV"){ print("y\n");}
+else{print("n\n");}
+1;
+
diff -urN linux.org/scripts/kconfig/rules/cpugrep.pm linux-2.6.13/scripts/kconfig/rules/cpugrep.pm
--- linux.org/scripts/kconfig/rules/cpugrep.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/cpugrep.pm 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+#########################################################################
+# #
+# cpugrep can be used with a Parameter. #
+# It searches after the name of the cpu. #
+# If there is a success it gives a y to stout. #
+# #
+#########################################################################
+
+
+$found='';
+$found=`grep "@ARGV" /proc/cpuinfo`;
+
+if ($found ne '') {
+ print("y\n");
+}
+
+else {
+ print("n\n");
+}
+1;
+
diff -urN linux.org/scripts/kconfig/rules/getchar.pm linux-2.6.13/scripts/kconfig/rules/getchar.pm
--- linux.org/scripts/kconfig/rules/getchar.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/getchar.pm 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,3 @@
+#!/usr/bin/perl
+
+getc();
diff -urN linux.org/scripts/kconfig/rules/highmem.pm linux-2.6.13/scripts/kconfig/rules/highmem.pm
--- linux.org/scripts/kconfig/rules/highmem.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/highmem.pm 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+$mem_var=`cat /proc/meminfo | grep MemTotal`;
+chop($mem_var);
+$mem_var=~/['0-9']+/g;
+$mem_var=$&;
+
+if($mem_var > 640000000){
+ print("y\n");
+ }
+
+else{print("n\n");}
diff -urN linux.org/scripts/kconfig/rules/hw_egrep.pm linux-2.6.13/scripts/kconfig/rules/hw_egrep.pm
--- linux.org/scripts/kconfig/rules/hw_egrep.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/hw_egrep.pm 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+
+$found='';
+$found=`lspci | grep -E "@ARGV" `;
+if($found ne '') {
+ print("y\n");
+}
+else {
+ $found=`grep -E "@ARGV" /var/log/dmesg `;
+ if($found ne '') {
+ print("y\n");
+ }
+ else {
+ print("n\n");
+ }
+}
+1;
diff -urN linux.org/scripts/kconfig/rules/hw_grep.pm linux-2.6.13/scripts/kconfig/rules/hw_grep.pm
--- linux.org/scripts/kconfig/rules/hw_grep.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/hw_grep.pm 2005-09-15 12:16:09.000000000 +0200
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+#########################################################################
+# #
+# hw_grep can be used with a Parameter. #
+# It searches then in lspci after the Name of the Parameter #
+# If there is a success it gives a y to stout. #
+# #
+#########################################################################
+
+$found='';
+$found=`lspci | grep "@ARGV"`;
+if($found ne '') {
+ print("y\n");
+}
+else {
+ $found=`grep -E "@ARGV" /var/log/dmesg `;
+ if($found ne ''){
+ print("y\n");
+ }
+ else {
+ print("n\n");
+ }
+}
+1;
+
diff -urN linux.org/scripts/kconfig/rules/mod1.pm linux-2.6.13/scripts/kconfig/rules/mod1.pm
--- linux.org/scripts/kconfig/rules/mod1.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/mod1.pm 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,5 @@
+#!/usr/bin/perl
+
+
+print("m\n");
+
diff -urN linux.org/scripts/kconfig/rules/offhimem.pm linux-2.6.13/scripts/kconfig/rules/offhimem.pm
--- linux.org/scripts/kconfig/rules/offhimem.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/offhimem.pm 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+$mem_var=`cat /proc/meminfo | grep MemTotal`;
+chop($mem_var);
+$mem_var=~/['0-9']+/g;
+$mem_var=$&;
+
+if($mem_var < 4290000){
+ print("y\n");
+ }
+
+else{print("n\n");}
diff -urN linux.org/scripts/kconfig/rules/rules_list.xml linux-2.6.13/scripts/kconfig/rules/rules_list.xml
--- linux.org/scripts/kconfig/rules/rules_list.xml 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/rules_list.xml 2005-09-13 17:54:13.000000000 +0200
@@ -0,0 +1,301 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rules>
+
+ yes1.pm
+ yes1.pm
+
+
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+
+
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+
+
+
+ arch.pm i386
+
+
+ cpugrep.pm "Pentium(R) M"
+ cpugrep.pm "Athlon"
+ cpugrep.pm "Pentium(R) 4"
+
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ mod1.pm
+ yes1.pm
+
+ offhimem.pm
+ 4gbmem.pm
+ highmem.pm
+
+ yes1.pm
+
+
+ yes1.pm
+ yes1.pm
+ yes1.pm
+
+ PentiumM.pm
+ yes1.pm
+ yes1.pm
+ mod1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+
+
+ mod1.pm
+ yes1.pm
+ yes1.pm
+
+
+ yes1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ cpugrep.pm "Pentium(R) M"
+
+
+
+ hw_grep.pm "PCI bridge"
+ yes1.pm
+
+ mod1.pm
+ mod1.pm
+
+
+
+ yes1.pm
+ mod1.pm
+ mod1.pm
+
+
+
+ yes1.pm
+ yes1.pm
+ mod1.pm
+
+
+ hw_egrep.pm "ATA|ATAPI|MFM|RLL"
+ yes1.pm
+ hw_egrep.pm "ATA|IDE"
+ yes1.pm
+ yes1.pm
+ mod1.pm
+ yes1.pm
+ hw_egrep.pm "IDE|PCI"
+ hw_egrep.pm "IDE|PCI"
+ hw_grep.pm "PCI"
+ hw_egrep.pm "ICH"
+ hw_egrep.pm "VT82C*"
+
+
+ hw_grep.pm "FireWire (IEEE 1394)"
+ yes1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+
+
+ hw_egrep.pm "Network|Ethernet"
+
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ mod1.pm
+ yes1.pm
+ yes1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ yes1.pm
+ yes1.pm
+
+
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+
+
+ mod1.pm
+
+ hw_egrep.pm "Network|Ethernet"
+
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ hw_grep.pm "3Com"
+ mod1.pm
+ mod1.pm
+ hw_grep.pm "PRO/100"
+
+ hw_egrep.pm "RTL-8129|RTL-8130|RTL-8139"
+ hw_grep.pm "RTL-8139"
+ yes1.pm
+
+
+ hw_egrep.pm "Wireless|WLan|WLAN"
+ mod1.pm
+ mod1.pm
+ mod1.pm
+
+ mod1.pm
+ mod1.pm
+ yes1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+
+
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+
+
+ yes1.pm
+ hw_grep.pm "AGP"
+ hw_egrep.pm "Rage|Radeon|Banshee|Voodoo"
+ hw_grep.pm "Radeon"
+ hw_egrep.pm "*Force*"
+ hw_egrep.pm "830M|845G|852GM|855GM|865G"
+
+
+
+ mod1.pm
+
+
+ hw_grep.pm "VGA"
+ hw_grep.pm "Radeon"
+ hw_egrep.pm "830M|845G|852GM|855GM|865G"
+ hw_egrep.pm "Riva|GeForce"
+ yes1.pm
+
+ yes1.pm
+ yes1.pm
+
+
+ yes1.pm
+ yes1.pm
+
+
+
+ hw_grep.pm "audio"
+
+ hw_grep.pm "audio"
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+
+
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+
+
+ hw_egrep.pm "Intel|SiS|nVidia|AMD|ALi AC'97"
+
+ hw_egrep.pm "Ensoniq|AudioPCI"
+ hw_egrep.pm "Ensoniq|AudioPCI"
+
+
+
+ hw_grep.pm "USB"
+ yes1.pm
+ yes1.pm
+ hw_grep.pm "EHCI"
+ hw_grep.pm "UHCI"
+ yes1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ mod1.pm
+
+
+
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ yes1.pm
+
+ mod1.pm
+ yes1.pm
+ yes1.pm
+ mod1.pm
+
+
+ mod1.pm
+ mod1.pm
+
+
+ yes1.pm
+ yes1.pm
+
+
+ yes1.pm
+ yes1.pm
+ yes1.pm
+ <option name="NLS ISO 8859-15 (Latin 9; Western European Languages with Euro)"
+ >yes1.pm
+
+
+
+ yes1.pm
+ yes1.pm
+
+
+ yes1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+ mod1.pm
+
+
+ mod1.pm
+ mod1.pm
+
+</rules>
diff -urN linux.org/scripts/kconfig/rules/yes1.pm linux-2.6.13/scripts/kconfig/rules/yes1.pm
--- linux.org/scripts/kconfig/rules/yes1.pm 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/rules/yes1.pm 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,5 @@
+#!/usr/bin/perl
+
+
+print("yes\n");
+
diff -urN linux.org/scripts/kconfig/xmlparser.c linux-2.6.13/scripts/kconfig/xmlparser.c
--- linux.org/scripts/kconfig/xmlparser.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/xmlparser.c 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,919 @@
+/***************************************************************************
+ * *
+ * Simple XML Parser. *
+ * copyright (C) Tim Hockin <thockin@hockin.org> *
+ * *
+ * Heavily modified by *
+ * copyright (C) 2004, 2005 Michael Buesch <mbuesch@freenet.de> *
+ * *
+ * Released under the LGPL version 2.1 (http://www.gnu.org) *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version 2.1 *
+ * as published by the Free Software Foundation. *
+ * *
+ ***************************************************************************/
+
+#include "xmlparser.h"
+#include "xmlutil.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define XML_PAGE "<fieldbus name=Ahmad length=12><board type=INTEL>Asus</board><board><board device name>\
+ /dev/pbboard0</board device name></board></fieldbus>"
+
+
+#define STRING_CAP_STEP 100 /* byte */
+
+
+struct xml_context
+{
+ const char *buf;
+ size_t size;
+ size_t pos;
+ unsigned int lineno;
+};
+
+typedef enum xml_state
+{
+ ST_TAGSTART,
+ ST_START_STAG,
+ ST_STAG_NAME_DONE,
+ ST_PROPNAME,
+ ST_GETEQ,
+ ST_GOTEQ,
+ ST_PROPVAL,
+ ST_SQ_PROPVAL,
+ ST_POST_PROPVAL,
+ ST_END_SETAG,
+ ST_END_STAG,
+ ST_CONTENT,
+ ST_MAYBE_COMMENT,
+ ST_NEWTAG_START,
+ ST_START_ETAG,
+ ST_ETAG_NAME,
+ ST_END_ETAG
+} state_t;
+
+
+struct xml_element* get_first_child(struct xml_element *parent){
+
+ if(parent->first_child)
+ return parent->first_child;
+ return NULL;
+}
+
+struct xml_element* get_next_element(struct xml_element *element, struct xml_element *child){
+
+ if(child)
+ return child->next;
+
+ return NULL;
+
+}
+
+struct xml_element* get_next_node(struct xml_element *element){
+
+ if(element->next)
+ return element->next;
+ return NULL;
+
+}
+
+char * get_element_name(struct xml_element *element){
+
+ if(element->name)
+ return element->name->s;
+ return 0;
+}
+
+char * get_element_content(struct xml_element *element){
+
+ if(element->content)
+ return element->content->s;
+ return 0;
+}
+struct xml_prop *get_next_attribute( struct xml_element *element, struct xml_prop* attribute){
+ if(!element->first_prop)
+ return NULL;
+ if(attribute){
+ return attribute->next;}
+ else
+ return element->first_prop;
+}
+
+char *get_attribute_name(struct xml_prop* attribute){
+ if(attribute->name->s)
+ return attribute->name->s;
+ return NULL;
+}
+
+
+char *get_attribute_value(struct xml_prop* attribute){
+ return attribute->value->s;
+}
+
+struct xml_element *get_element_parent(struct xml_element *element){
+ if(element->parent)
+ return element->parent;
+ else return NULL;
+}
+
+
+
+
+static struct xml_string * alloc_xml_string(void)
+{
+ struct xml_string *s;
+
+ s = malloc(sizeof(*s));
+ if (!s) {
+ printf("Out of memory\n");
+ return 0;
+ }
+ s->s = malloc(STRING_CAP_STEP);
+ if (!s->s) {
+ printf("Out of memory\n");
+ free(s);
+ return 0;
+ }
+ s->s[0] = '\0';
+ s->size = 0;
+ s->_capacity = STRING_CAP_STEP;
+
+ return s;
+}
+
+static void free_xml_string(struct xml_string *s)
+{
+ if (!s)
+ return;
+ free(s->s);
+ free(s);
+}
+
+static int xml_string_append_c(struct xml_string *s, char c)
+{
+ if (s->size + 1 == s->_capacity) {
+ size_t new_cap;
+ char *new_buf;
+
+ new_cap = s->_capacity + STRING_CAP_STEP;
+ new_buf = realloc(s->s, new_cap);
+ if (!new_buf) {
+ printf("Out of memory\n");
+ return 1;
+ }
+ s->s = new_buf;
+ s->_capacity = new_cap;
+ }
+ s->size++;
+ s->s[s->size - 1] = c;
+ s->s[s->size] = '\0';
+ return 0;
+}
+
+static int xml_string_copy(struct xml_string *to, struct xml_string *from)
+{
+ if (from->size + 1 > to->_capacity) {
+ char *new_buf;
+
+ new_buf = realloc(to->s, from->size + 1);
+ if (!new_buf) {
+ printf("Out of memory\n");
+ return 1;
+ }
+ to->s = new_buf;
+ to->_capacity = from->size + 1;
+ }
+ memcpy(to->s, from->s, from->size + 1);
+ to->size = from->size;
+ return 0;
+}
+
+static void xml_string_clear(struct xml_string *s)
+{
+ s->size = 0;
+ /* We don't reset capacity here. */
+}
+
+static struct xml_prop * alloc_xml_prop(void)
+{
+ struct xml_prop *p;
+
+ p = malloc(sizeof(*p));
+ if (!p) {
+ printf("Out of memory\n");
+ return 0;
+ }
+ p->name = alloc_xml_string();
+ if (!p->name) {
+ free(p);
+ return 0;
+ }
+ p->value = alloc_xml_string();
+ if (!p->value) {
+ free_xml_string(p->name);
+ free(p);
+ return 0;
+ }
+ p->next = 0;
+ p->prev = 0;
+
+ return p;
+}
+
+static void free_xml_prop(struct xml_prop *p)
+{
+ if (!p)
+ return;
+ free_xml_string(p->value);
+ free_xml_string(p->name);
+ free(p);
+}
+
+static struct xml_element * alloc_xml_element(void)
+{
+ struct xml_element *e;
+
+ e = malloc(sizeof(*e));
+ if (!e) {
+ printf("Out of memory\n");
+ return 0;
+ }
+ e->name = alloc_xml_string();
+ if (!e->name) {
+ free(e);
+ return 0;
+ }
+ e->content = alloc_xml_string();
+ if (!e->content) {
+ free_xml_string(e->name);
+ free(e);
+ return 0;
+ }
+ e->first_prop = 0;
+ e->last_prop = 0;
+ e->first_child = 0;
+ e->last_child = 0;
+ e->next = 0;
+ e->prev = 0;
+ e->parent = 0;
+ return e;
+}
+
+void xml_free_element(struct xml_element *e)
+{
+ struct xml_element *child;
+ struct xml_prop *prop;
+
+ if (!e)
+ return;
+
+ child = e->first_child;
+ while (child) {
+ struct xml_element *del;
+
+ del = child;
+ child = child->next;
+ xml_free_element(del);
+ }
+
+ prop = e->first_prop;
+ while (prop) {
+ struct xml_prop *del;
+
+ del = prop;
+ prop = prop->next;
+ free_xml_prop(del);
+ }
+
+ free_xml_string(e->name);
+ free_xml_string(e->content);
+ free(e);
+}
+
+static void xml_element_append_child(struct xml_element *parent,
+ struct xml_element *child)
+{
+ child->next = 0;
+ child->prev = 0;
+ if (!parent->first_child)
+ parent->first_child = child;
+ if (parent->last_child) {
+ parent->last_child->next = child;
+ child->prev = parent->last_child;
+ }
+ parent->last_child = child;
+ child->parent=parent;
+}
+
+static void xml_element_append_prop(struct xml_element *e,
+ struct xml_prop *prop)
+{
+ prop->next = 0;
+ prop->prev = 0;
+ if (!e->first_prop)
+ e->first_prop = prop;
+ if (e->last_prop) {
+ e->last_prop->next = prop;
+ prop->prev = e->last_prop;
+ }
+ e->last_prop = prop;
+}
+
+static int is_name_start(char c)
+{
+ return (simple_isalpha(c) || c == '_' || c == ':');
+}
+
+static int is_name(char c)
+{
+ return (is_name_start(c) ||
+ simple_isdigit(c) ||
+ c == '.' ||
+ c == '-');
+}
+
+static int next_char(struct xml_context *ctx, char *c)
+{
+ if (ctx->pos == ctx->size){
+ return 0;}
+ *c = ctx->buf[ctx->pos];
+
+ if (*c == '\0'){
+ return 0;}
+ if (*c == '\n'){
+ ctx->lineno++;}
+ ctx->pos++;
+ return 1;
+}
+
+static void prolog(struct xml_context *ctx)
+{
+ char cur = ' ';
+ char prev = ' ';
+
+ while (next_char(ctx, &cur)) {
+ if (cur == '>' && prev == '?')
+ return;
+ prev = cur;
+ }
+}
+
+static void comment(struct xml_context *ctx)
+{
+ char cur = ' ';
+ char prev = ' ';
+ char prev2 = ' ';
+
+ while (next_char(ctx, &cur)) {
+ if (cur == '>' && prev == '-' && prev2 == '-')
+ return;
+ prev2 = prev;
+ prev = cur;
+ }
+}
+
+static char unescape(struct xml_context *ctx)
+{
+ char buf[16];
+ unsigned int i = 0;
+ const char *escapes[] = {
+ "lt;",
+ "gt;",
+ "amp;",
+ "apos;",
+ "quot;",
+ "nbsp;",
+ NULL
+ };
+ const char esc_vals[] = {
+ '<',
+ '>',
+ '&',
+ '\'',
+ '"',
+ ' ',
+ '\0'
+ };
+
+ /* we assume we got a '&' before we got here */
+ if (!next_char(ctx, buf + i)) {
+ printf("ERROR: premature EOF (line %d)\n", ctx->lineno);
+ return -1;
+ }
+ while ((buf[i] != ';') && (!simple_isspace(buf[i])) && (i < sizeof(buf)-1)) {
+ i++;
+ if (!next_char(ctx, buf + i)) {
+ printf("ERROR: premature EOF (line %d)\n", ctx->lineno);
+ return -1;
+ }
+ }
+ buf[i + 1] = '\0';
+
+ /* got an escape */
+ if (buf[i] == ';') {
+ i = 0;
+ /* got a &# style escape */
+ if (buf[0] == '#') {
+ char charesc = -1;
+ int base = 10;
+ i++;
+ if (simple_tolower(buf[i]) == 'x') {
+ base = 16;
+ i++;
+ }
+ while (buf[i] != ';') {
+ int decval;
+
+ /* convert buf[i]) */
+ if (simple_isdigit(buf[i])) {
+ decval = buf[i] - '0';
+ } else if (simple_isxdigit(buf[i])) {
+ decval = (simple_tolower(buf[i]) - 'a') + 10;
+ } else {
+ return -1;
+ }
+ charesc *= base;
+ charesc += decval;
+ }
+ return charesc;
+ }
+ /* got a 'normal' escape */
+ while (escapes[i]) {
+ if (!simple_strcasecmp(buf, escapes[i])) {
+ return esc_vals[i];
+ }
+ i++;
+ }
+ }
+
+ return -1;
+}
+
+static int add_content_char(struct xml_context *ctx,
+ struct xml_element *e,
+ char c)
+{
+ if (e->content->size == 0) {
+ /* This is the first phase of the content
+ * string whitespace cleanup.
+ * Second phase is in cleanup_string()
+ */
+ if (simple_isspace(c) || c == '\n'){
+
+ return 0;}
+ }
+ return xml_string_append_c(e->content, c);
+}
+
+static void cleanup_string(struct xml_string *s)
+{
+ size_t i;
+ char c;
+
+ /* This is the second phase of the content
+ * string whitespace cleanup.
+ * The first phase is in add_content_char()
+ */
+ if (s->size <= 0)
+ return;
+ i = s->size - 1;
+ do {
+ c = s->s[i];
+ } while ((simple_isspace(c) || c == '\n') && (i-- > 0));
+ s->size = i + 1;
+ s->s[s->size] = '\0';
+}
+
+struct xml_element * parse_element(struct xml_context *ctx, char first)
+{
+ char c;
+ state_t state = ST_TAGSTART;
+ struct xml_element *e = 0;
+ struct xml_prop *p = 0;
+ struct xml_element *ret = 0;
+ int flag=0;
+
+ struct xml_string *propname = 0;
+ struct xml_string *propval = 0;
+ struct xml_string *endname = 0;
+
+ ret = alloc_xml_element();
+ if (!ret)
+ goto out_fail;
+ propname = alloc_xml_string();
+ if (!propname)
+ goto out_fail;
+ propval = alloc_xml_string();
+ if (!propval)
+ goto out_fail;
+ endname = alloc_xml_string();
+ if (!endname)
+ goto out_fail;
+
+ /* we got a '<' */
+ if (is_name_start(first)) {
+ if (xml_string_append_c(ret->name, simple_tolower(first)))
+ goto out_fail;
+ state = ST_START_STAG;
+ } else
+ state = ST_TAGSTART;
+
+ while (next_char(ctx, &c)) {
+ switch (state) {
+ /* start */
+ case ST_TAGSTART:
+ if (simple_isspace(c)) {
+ /* state = CURRENT_STATE; */
+ } else if (is_name_start(c)) {
+ if (xml_string_append_c(ret->name, simple_tolower(c)))
+ goto out_fail;
+ state = ST_START_STAG;
+ } else
+ goto out_inval_char;
+ break;
+ /* we got the start of a keyword for an stag */
+ case ST_START_STAG:
+ if (is_name(c)) {
+ if (xml_string_append_c(ret->name, simple_tolower(c)))
+ goto out_fail;
+ /* state = CURRENT_STATE; */
+ } else if (simple_isspace(c))
+ state = ST_STAG_NAME_DONE;
+ else if (c == '>')
+ state = ST_END_STAG;
+ else if (c == '/')
+ state = ST_END_SETAG;
+ else
+ goto out_inval_char;
+ break;
+ /* keyword done - look for next prop or other */
+ case ST_STAG_NAME_DONE:
+ if (simple_isspace(c)) {
+ /* state = CURRENT_STATE; */
+ } else if (c == '>'){
+ state = ST_END_STAG;}
+ else if (c == '/')
+ state = ST_END_SETAG;
+ else if (is_name_start(c)) {
+ /* must be a propname */
+ if (xml_string_append_c(propname, simple_tolower(c)))
+ goto out_fail;
+ state = ST_PROPNAME;
+ } else
+ goto out_inval_char;
+ break;
+ /* found start of a propname */
+ case ST_PROPNAME:
+ if (is_name(c)) {
+ if (xml_string_append_c(propname, simple_tolower(c)))
+ goto out_fail;
+ /* state = CURRENT_STATE; */
+ } else if (c == '=')
+ state = ST_GOTEQ;
+ else if (simple_isspace(c))
+ state = ST_GETEQ;
+ else
+ goto out_inval_char;
+ break;
+ /* got propname, get '=' */
+ case ST_GETEQ:
+ if (simple_isspace(c)) {
+ /* state = CURRENT_STATE; */
+ } else if (c == '=')
+ state = ST_GOTEQ;
+ else
+ goto out_inval_char;
+ break;
+ /* got '=' - find propval */
+ case ST_GOTEQ:
+ if (simple_isspace(c)) {
+ /* state = CURRENT_STATE; */
+ } else if (c == '"')
+ state = ST_PROPVAL;
+ else if (c == '\'')
+ state = ST_SQ_PROPVAL;
+ else
+ goto out_inval_char;
+ break;
+ /* got a quoted propval */
+ case ST_PROPVAL:
+ if (c == '&') {
+ char lc = unescape(ctx);
+ if (lc > 0) {
+ if (xml_string_append_c(propval, lc))
+ goto out_fail;
+ }
+ } else if (c == '"') {
+ p = alloc_xml_prop();
+ if (!p)
+ goto out_fail;
+ if (xml_string_copy(p->name, propname))
+ goto out_fail;
+ if (xml_string_copy(p->value, propval))
+ goto out_fail;
+ xml_element_append_prop(ret, p);
+ p = 0;
+ xml_string_clear(propname);
+ xml_string_clear(propval);
+ state = ST_STAG_NAME_DONE;
+ } else if (c == '<')
+ goto out_inval_char;
+ else {
+ if (xml_string_append_c(propval, c))
+ goto out_fail;
+ /* state = CURRENT_STATE; */
+ }
+ break;
+ /* got a single-quoted propval */
+ case ST_SQ_PROPVAL:
+ if (c == '&') {
+ char lc = unescape(ctx);
+ if (lc > 0) {
+ if (xml_string_append_c(propval, lc))
+ goto out_fail;
+ }
+ } else if (c == '\'') {
+ p = alloc_xml_prop();
+ if (!p)
+ goto out_fail;
+ if (xml_string_copy(p->name, propname))
+ goto out_fail;
+ if (xml_string_copy(p->value, propval))
+ goto out_fail;
+ xml_element_append_prop(ret, p);
+ p = 0;
+ xml_string_clear(propname);
+ xml_string_clear(propval);
+ state = ST_STAG_NAME_DONE;
+ } else if (c == '<') {
+ /* spec says this is an error */
+ goto out_inval_char;
+ } else {
+ if (xml_string_append_c(propval, c))
+ goto out_fail;
+ /* state = CURRENT_STATE; */
+ }
+ break;
+ /* spec says we must have a space between props */
+ case ST_POST_PROPVAL:
+ if (simple_isspace(c))
+ state = ST_STAG_NAME_DONE;
+ else if (c == '>')
+ state = ST_END_STAG;
+ else if (c == '/')
+ state = ST_END_SETAG;
+ else
+ goto out_inval_char;
+ break;
+ /* got a '/', suggesting an empty element */
+ case ST_END_SETAG:
+ if (simple_isspace(c)) {
+ /* state = CURRENT_STATE; */
+ } else if (c == '>')
+ goto out_success;
+ else
+ goto out_inval_char;
+ break;
+ /* time to look for content */
+ case ST_END_STAG:
+ if (simple_isspace(c)) {
+ /* state = CURRENT_STATE; */
+ } else if (c == '&') {
+ char lc = unescape(ctx);
+ if (lc > 0) {
+ if (add_content_char(ctx, ret, lc))
+ goto out_fail;
+ }
+ state = ST_CONTENT;
+ } else if (c == '<'){
+ state = ST_MAYBE_COMMENT;}
+ else {
+ if (add_content_char(ctx, ret, c))
+ goto out_fail;
+ state = ST_CONTENT;
+ }
+ break;
+ /* processing content */
+ case ST_CONTENT:
+ if (simple_isspace(c)) {
+ if (add_content_char(ctx, ret, c)){
+ printf("element %s\n", get_element_name(ret) );
+ printf("fail2\n");
+ goto out_fail;}
+ /* state = CURRENT_STATE; */
+ }
+ else if (c == '<')
+ state = ST_MAYBE_COMMENT;
+ else if (c == '&') {
+ char lc = unescape(ctx);
+ if (lc > 0) {
+ if (add_content_char(ctx, ret, lc))
+ goto out_fail;
+ }
+ }
+ else {
+ if (add_content_char(ctx, ret, c)){
+ goto out_fail;}
+ /* state = CURRENT_STATE; */
+ }
+ break;
+ /* got a '<' - check for a comment */
+ case ST_MAYBE_COMMENT:
+ if (c == '!')
+ comment(ctx);
+ else if (simple_isspace(c))
+ state = ST_NEWTAG_START;
+ else if (c == '/')
+ state = ST_START_ETAG;
+ else {
+ e = parse_element(ctx, c);
+ if (!e)
+ goto out_fail;
+ xml_element_append_child(ret, e);
+ e = 0;
+ state = ST_CONTENT;
+ flag=1;
+ }
+ break;
+ /* got a '<' in content - figure it out */
+ case ST_NEWTAG_START:
+ if (simple_isspace(c)) {
+ /* state = CURRENT_STATE; */
+ } else if (c == '/')
+ state = ST_START_ETAG;
+ else {
+ e = parse_element(ctx, c);
+ if (!e)
+ goto out_fail;
+ xml_element_append_child(ret, e);
+ e = 0;
+ state = ST_CONTENT;
+ }
+ break;
+ /* got a </ */
+ case ST_START_ETAG:
+ if (simple_isspace(c)) {
+ /* state = CURRENT_STATE; */
+ } else if (is_name_start(c)) {
+ if (xml_string_append_c(endname, c))
+ goto out_fail;
+ state = ST_ETAG_NAME;
+ } else
+ goto out_inval_char;
+ break;
+ /* reading all of </name */
+ case ST_ETAG_NAME:
+ if (is_name(c)) {
+ if (xml_string_append_c(endname, c))
+ goto out_fail;
+ /* state = CURRENT_STATE; */
+ } else if (simple_isspace(c))
+ state = ST_END_ETAG;
+ else if (c == '>') {
+ if (ret->name->size == endname->size &&
+ simple_strncasecmp(ret->name->s, endname->s, endname->size) == 0) {
+ goto out_success;
+ } else {
+ /* not a match! */
+ printf("endname (%s) != element->name (%s)\n",
+ endname->s, ret->name->s);
+ state = ST_CONTENT;
+ xml_string_clear(endname);
+ }
+ } else
+ goto out_inval_char;
+ break;
+ /* just get '>' and wrap up */
+ case ST_END_ETAG:
+ if (simple_isspace(c)) {
+ /* state = CURRENT_STATE; */
+ } else if (c == '>') {
+ if (ret->name->size == endname->size &&
+ simple_strncasecmp(ret->name->s, endname->s, endname->size) == 0) {
+ goto out_success;
+ } else {
+ /* not a match! */
+ printf("endname (%s) != element->name (%s)\n",
+ endname->s, ret->name->s);
+ state = ST_CONTENT;
+ xml_string_clear(endname);
+ }
+ } else
+ goto out_inval_char;
+ break;
+ }
+ }
+ printf("ERROR: premature EOF (line %d)\n", ctx->lineno);
+ goto out_fail;
+
+out_inval_char:
+ printf("invalid char '%c' in state %d (line %d)\n",
+ c, state, ctx->lineno);
+out_fail:
+ xml_free_element(ret);
+ xml_free_element(e);
+ free_xml_prop(p);
+ free_xml_string(propname);
+ free_xml_string(propval);
+ free_xml_string(endname);
+ return 0;
+
+out_success:
+ free_xml_string(propname);
+ free_xml_string(propval);
+ free_xml_string(endname);
+ cleanup_string(ret->content);
+ return ret;
+}
+
+int xml_parse_buffer(struct xml_buffer buffer, struct xml_element **ret)
+{
+ struct xml_element *root;
+ struct xml_element *e;
+ struct xml_context ctx;
+ char c;
+ int can_prolog = 1;
+
+ root = alloc_xml_element();
+ strcpy(root->name->s, "root");
+ if (!root)
+ return 1;
+ ctx.buf = buffer.text;
+ ctx.size = buffer.text_size;
+ ctx.pos = 0;
+ ctx.lineno = 1;
+
+ while (next_char(&ctx, &c)) {
+ if (simple_isspace(c))
+ continue;
+ else if (c == '<') {
+ if (!next_char(&ctx, &c))
+ goto out_premat_eof;
+ /* handle a prolog ("<?") */
+ if (c == '?' && can_prolog) {
+ prolog(&ctx);
+ continue;
+ }
+ can_prolog = 0;
+
+ /* handle a comment ("<!") */
+ if (c == '!') {
+ comment(&ctx);
+ continue;
+ }
+
+ e = parse_element(&ctx, c);
+ if (!e)
+ goto out_fail;
+ xml_element_append_child(root, e);
+ } else
+ goto out_inval_char;
+ }
+ //printf("bla");
+ *ret = root;
+ return 0;
+
+out_premat_eof:
+ printf("ERROR: premature EOF (line %d)\n", ctx.lineno);
+ goto out_fail;
+
+out_inval_char:
+ printf("invalid char '%c' in state top (line %d)\n",
+ c, ctx.lineno);
+
+out_fail:
+ printf("out_fail\n");
+ xml_free_element(root);
+ return 1;
+}
+
+struct xml_buffer load_xml_file(char *source){
+
+ FILE *p_InText;
+ struct xml_buffer buffer;
+
+ p_InText = fopen (source , "r");
+
+ if (p_InText == NULL)
+ {
+ printf("Fehler beim lesen der Datei \n");
+ exit(1);
+ } /*End If */
+
+ else
+ {
+ fseek( p_InText, 0 , SEEK_END);
+ buffer.text_size = ftell(p_InText);
+ buffer.text = (char*) malloc(sizeof(char)*buffer.text_size);
+ rewind(p_InText);
+ fread(buffer.text, 1, buffer.text_size, p_InText);
+ return buffer;
+ } /* End else */
+
+}
+
+
diff -urN linux.org/scripts/kconfig/xmlparser.h linux-2.6.13/scripts/kconfig/xmlparser.h
--- linux.org/scripts/kconfig/xmlparser.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/xmlparser.h 2005-09-13 17:52:59.000000000 +0200
@@ -0,0 +1,76 @@
+/***************************************************************************
+ * *
+ * Simple XML Parser. *
+ * copyright (C) Tim Hockin <thockin@hockin.org> *
+ * *
+ * Heavily modified by *
+ * copyright (C) 2004, 2005 Michael Buesch <mbuesch@freenet.de> *
+ * *
+ * Released under the LGPL version 2.1 (http://www.gnu.org) *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU Lesser General Public License version 2.1 *
+ * as published by the Free Software Foundation. *
+ * *
+ ***************************************************************************/
+
+#ifndef PWMANAGER_DUMP_XMLPARSER_H_
+#define PWMANAGER_DUMP_XMLPARSER_H_
+
+#include <stddef.h>
+
+
+struct xml_string
+{
+ char *s;
+ size_t size;
+ /* internal: */
+ size_t _capacity;
+};
+
+struct xml_prop
+{
+ struct xml_string *name;
+ struct xml_string *value;
+
+ struct xml_prop *next;
+ struct xml_prop *prev;
+};
+
+struct xml_element
+{
+ struct xml_string *name;
+ struct xml_string *content;
+
+ struct xml_prop *first_prop;
+ struct xml_prop *last_prop;
+
+ struct xml_element *first_child;
+ struct xml_element *last_child;
+ struct xml_element *parent;
+ struct xml_element *next;
+ struct xml_element *prev;
+ char option_name[128];
+ int m_h_value;
+ int m_h_cnt;
+ int m_h_prior;
+};
+
+struct xml_buffer{
+ char *text;
+ size_t text_size;
+};
+
+int xml_parse_buffer(struct xml_buffer buffer, struct xml_element **ret);
+void xml_free_element(struct xml_element *e);
+
+struct xml_element* get_first_child(struct xml_element *parent);
+struct xml_element* get_next_node(struct xml_element *element);
+char * get_element_name(struct xml_element *element);
+char * get_element_content(struct xml_element *element);
+struct xml_prop *get_next_attribute( struct xml_element *element, struct xml_prop* attribute);
+char *get_attribute_name(struct xml_prop* attribute);
+char *get_attribute_value(struct xml_prop* attribute);
+struct xml_element *get_element_parent(struct xml_element *element);
+struct xml_buffer load_xml_file(char *source);
+
+#endif /* PWMANAGER_DUMP_XMLPARSER_H_ */
diff -urN linux.org/scripts/kconfig/xmlutil.c linux-2.6.13/scripts/kconfig/xmlutil.c
--- linux.org/scripts/kconfig/xmlutil.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/xmlutil.c 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,105 @@
+#include "xmlutil.h"
+
+int simple_isupper(int c)
+{
+ return (c >= 'A' && c <= 'Z');
+}
+
+int simple_islower(int c)
+{
+ return (c >= 'a' && c <= 'z');
+}
+
+int simple_isalpha(int c)
+{
+ return (simple_isupper(c) || simple_islower(c));
+}
+
+int simple_isdigit(int c)
+{
+ return (c >= '0' && c <= '9');
+}
+
+int simple_isdigit_string(const char *s)
+{
+ while (*s) {
+ if (!simple_isdigit(*s))
+ return 0;
+ s++;
+ }
+ return 1;
+}
+
+int simple_isspace(int c)
+{
+ switch (c) {
+ case ' ':
+ case '\f':
+ case '\n':
+ case '\r':
+ case '\t':
+ case '\v':
+ return 1;
+ }
+ return 0;
+}
+
+int simple_tolower(int c)
+{
+ if (!simple_isupper(c))
+ return c;
+ return (c - 'A' + 'a');
+}
+
+int simple_toupper(int c)
+{
+ if (!simple_islower(c))
+ return c;
+ return (c - 'a' + 'A');
+}
+
+int simple_isxdigit(int c)
+{
+ if (simple_isdigit(c))
+ return 1;
+ if (c >= 'A' && c <= 'F')
+ return 1;
+ if (c >= 'a' && c <= 'f')
+ return 1;
+ return 0;
+}
+
+int simple_strcasecmp(const char *s1, const char *s2)
+{
+ unsigned char *c1, *c2;
+
+ c1 = (unsigned char *)s1;
+ c2 = (unsigned char *)s2;
+ while (*c1 && *c2 &&
+ simple_tolower(*c1) == simple_tolower(*c2)) {
+ c1++;
+ c2++;
+ }
+
+ return *c1 - *c2;
+}
+
+int simple_strncasecmp(const char *s1, const char *s2, size_t n)
+{
+ unsigned char *c1, *c2;
+
+ if (n <= 0)
+ return 0;
+ c1 = (unsigned char *)s1;
+ c2 = (unsigned char *)s2;
+ while (*c1 && *c2 &&
+ simple_tolower(*c1) == simple_tolower(*c2)) {
+ n--;
+ if (n <= 0)
+ return 0;
+ c1++;
+ c2++;
+ }
+
+ return *c1 - *c2;
+}
diff -urN linux.org/scripts/kconfig/xmlutil.h linux-2.6.13/scripts/kconfig/xmlutil.h
--- linux.org/scripts/kconfig/xmlutil.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.13/scripts/kconfig/xmlutil.h 2005-09-06 11:07:42.000000000 +0200
@@ -0,0 +1,18 @@
+#ifndef PWMANAGER_DUMP_STRINGCASE_H_
+#define PWMANAGER_DUMP_STRINGCASE_H_
+
+#include <stddef.h>
+
+int simple_isupper(int c);
+int simple_islower(int c);
+int simple_isalpha(int c);
+int simple_isdigit(int c);
+int simple_isdigit_string(const char *s);
+int simple_isspace(int c);
+int simple_tolower(int c);
+int simple_toupper(int c);
+int simple_isxdigit(int c);
+int simple_strcasecmp(const char *s1, const char *s2);
+int simple_strncasecmp(const char *s1, const char *s2, size_t n);
+
+#endif /* PWMANAGER_DUMP_STRINGCASE_H_ */