/*  This file is part of lsnet. 

    Lsnet is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Lsnet is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with lsnet.  If not, see <http://www.gnu.org/licenses/>.
*/

#define SIZE 255

int webdir() {
        FILE* fp;
	//char str[SIZE];
	//char str1[20] = "";
        int count = 0;
	int count2 = 0;
        //char *cpu = "cpu";
	//char *mem = "mem";
	//char *net = "net";
	//printf( "TEST\n");
	//printf( "%s\n", frequencytype );
	//printf( "TEST\n");
        char buf[SIZE];
	char temp[10];
	//char webpath[50];
        //int line = 0;
	//char *test;
        if( ( fp = fopen( "/etc/lsnet.conf", "r" ) ) == NULL ) {
                fprintf( stderr, "Error opening file.\n" );
                exit( 1 );
        }
	//int i = strcmp( frequencytype, cpu );
	//int j = strcmp( frequencytype, mem);
	//int k = strcmp( frequencytype, net);
	//printf( "I:%d J:%d K:%d\n", i, j ,k );
	//if (i == 0)
	//{
		memset ((void*) webpath, '\0', sizeof (webpath));
		memset ((void*) temp, '\0', sizeof (temp));
		//strcpy(webpath, "0");
        	while( fgets(buf, sizeof(buf), fp) != NULL)
        	{
			if (buf[count] == 'W'){
				if (buf[count+1] == 'E'){
					if (buf[count+2] == 'B'){
						if (buf[count+3] == 'D'){ 
							if (buf[count+4] == 'I')
							{
								temp[0]=buf[8];
								strcpy(webpath, temp);
								for (count2 = 9; count2 <= strlen(buf) && buf[count2] != '\n' ; count2++)
								{
									temp[0]=buf[count2]; 
									temp[1]=0; 
									strcat(webpath,temp);
								} 
							}
						}
					}
				}
			}
		}
	//}

        fclose( fp );
	//count = atoi(frequencystring);
	//printf( "%s\n", webpath );

	return (0);
}
