reading the kernel configuration using libkconfig.so

From: Alexander Bierbrauer (nomore_at_pr0n-tv.net)
Date: 07/13/04


Date: 13 Jul 2004 10:42:43 -0700

Hey there,

I've started to code a tool for exporting the kernel configuration to
a HTML file (inkl trees and so on). I've read qconf.cc gconf.c from
/usr/src/linux/sripts/kconfig.

So far, so good.. the code compiles without any hassles... but I'm
getting the following messages when I want to run my program (e.g. in
/home/nomore/dev/lktexporter):

Code:

bash-2.05b$ ./lktexporter
/usr/src/linux/.config:4: syntax error, unexpected T_WORD
/usr/src/linux/.config:9: syntax error
/usr/src/linux/.config:12: syntax error, unexpected T_WORD
/usr/src/linux/.config:17: syntax error
/usr/src/linux/.config:20: syntax error, unexpected T_WORD
/usr/src/linux/.config:40: syntax error
/usr/src/linux/.config:43: syntax error, unexpected T_WORD
/usr/src/linux/.config:50: syntax error
/usr/src/linux/.config:53: syntax error, unexpected T_WORD
/usr/src/linux/.config:111: syntax error
/usr/src/linux/.config:115: syntax error, unexpected T_WORD
/usr/src/linux/.config:124: syntax error
/usr/src/linux/.config:127: syntax error, unexpected T_WORD
/usr/src/linux/.config:131: syntax error
/usr/src/linux/.config:134: syntax error, unexpected T_WORD
/usr/src/linux/.config:155: syntax error
/usr/src/linux/.config:163: syntax error, unexpected T_WORD

the first lines of the example config
Code:

#
# Automatically generated make config: don't edit
#
CONFIG_X86=y
CONFIG_MMU=y
CONFIG_UID16=y
CONFIG_GENERIC_ISA_DMA=y

#
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y
CONFIG_CLEAN_COMPILE=y
CONFIG_STANDALONE=y
CONFIG_BROKEN_ON_SMP=y

#
# General setup
#
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
# CONFIG_POSIX_MQUEUE is not set
# CONFIG_BSD_PROCESS_ACCT is not set
CONFIG_SYSCTL=y

I don't know what I'm doing wrong.. and can't see the differnece
between my code and the ones from the kernel config tools.

Here's my code so far:
Code:

#define LKC_DIRECT_LINK

#include <stdlib.h>
#include "lkc.h"

void fixup_rootmenu(struct menu *menu)
{
   struct menu *child;
   static int menu_cnt = 0;

   menu->flags |= MENU_ROOT;
   for (child = menu->list; child; child = child->next) {
      if (child->prompt && child->prompt->type == P_MENU) {
         menu_cnt++;
         fixup_rootmenu(child);
         menu_cnt--;
      } else if (!menu_cnt)
         fixup_rootmenu(child);
   }
}

void exportConfig(struct menu *menu)
{
   struct symbol *sym;
   struct property *prop;
   struct menu *child,*current;
   enum prop_type ptype;

   if (menu == &rootmenu) {
      current = &rootmenu;
   }

   //going through the complete list
   for (child = menu->list; child; child = child->next)
   {
      prop = child->prompt;
      sym = child->sym;
      ptype = prop ? prop->type : P_UNKNOWN;

      printf("prompt: %s\n",menu_get_prompt(child));
   }
}

int main(int argc,char **argv)
{
   #ifndef LKC_DIRECT_LINK
   kconfig_load();
   #endif

   //reading the kernel configuration
   conf_parse("/usr/src/linux/.config");
   fixup_rootmenu(&rootmenu);
   if(conf_read(NULL))
   {
      printf("unable to load linux kernel configuration\n");
      return 1;
   }

   exportConfig(&rootmenu);

   return 0;
}

Does anyone know what's going wrong ?? Or knows a better place to ask
?? Do I have to post to the linux kernel ml ? Are these questions
welcome there ?? .... Confused I'm so confused Laughing

any help is great !

alex