/*
 * General Public License (GPL) v2
 *
 * This program 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 2 of
 * the License, or (at your option) any later version.
 *
 * This program 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 this program; if not,
 * write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Copyright 2007 jjmora@arrakis.es.  http://jjmora.es All rights reserved.
 * Use is subject to license terms.
*/

/*
 * Version 0.1.1
*/

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


void init_sysc(char sct[][20]){
int fd;
char cad;
char sysc[80],sysn[80];
int name;

name=1;
sysc[0]=NULL;
sysn[0]=NULL;

fd=open("/etc/name_to_sysnum",O_RDONLY);

if(fd<0)
	{
	printf("\nError: leyendo el fichero /etc/name_to_sysnum \n ");
	exit(0);
	}


while(read(fd,&cad,1))
	{

	if(cad=='\t')
		{
	name=0;
	}
if (cad=='\n')
	{
	/*
	*printf("\n Linea sysc:%s  sysn:%d",sysc,atoi(sysn));
	*/
	sprintf(sct[atoi(sysn)],"%s",sysc);	
	sysc[0]=NULL;
	sysn[0]=NULL;
	name=1;
	}
	else
	{
	if(name==1)
		sprintf(sysc,"%s%c",sysc,cad);	
		else
		sprintf(sysn,"%s%c",sysn,cad);	
			
	}

}

close(fd);


}

