/*
 * Copyright (C) 2003 Luca Marzario
 * This is Free Software; see GPL.txt for details
 *
 * This is a simple string search in a file, used to check if a 
 * configuration option has been enabled
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argn, char* argv[])
{

   FILE *p_file;
   int ret, ok = 0;
   char str[40], conf[40];

   if (argn < 3)
   {
	   printf("usage: %s config_file_name config_option_string\n\n", argv[0]);
	   printf("example: %s /usr/src/linux/.config CONFIG_X86\n", argv[0]);
	   exit(-1);
   }
   if ((p_file = fopen(argv[1], "r")) == NULL)
   {
       printf("Couldn't open file %s!\n", argv[1]);
       exit(-1);
   }
   sprintf(conf, "%s=y", argv[2]);
   while (((ret = fscanf (p_file, "%s", str)) != 0) && (ret != EOF)) {
           if (!strcmp(str, conf)) {
                   ok = 1;
		   break;
           }
   }
   fclose(p_file);
   return !ok;
}

