end of day

This commit is contained in:
Jonathan Santis 2024-09-16 13:10:54 +02:00
parent 72d3e85b3d
commit bc85d7da5b

View File

@ -12,19 +12,37 @@ int loadConfig(char *str_file, char **str_entry,int size)
printf("\nopening config file\n"); printf("\nopening config file\n");
f_config = fopen(str_file,"r"); f_config = fopen(str_file,"r");
if(f_config != NULL) if(f_config != NULL)
{
while(fgets(temp_str,256,f_config)!=NULL)
{
temp_str[strcspn(temp_str,"\n")]=0;
printf("while\n");
if(strcmp(temp_str,"[Host]")==0)
{ {
if(fgets(temp_str,256,f_config)!=NULL) if(fgets(temp_str,256,f_config)!=NULL)
{ {
if char host[256];
char *ptr_host = strrchr(temp_str,'=')+1;
strncpy(host,ptr_host,256);
printf("my host is:%s\n",host);
}
}
else if(strcmp(temp_str,"[Services]")==0)
{
for(i=0;i<size;i++) for(i=0;i<size;i++)
{ {
printf("for loop:%d\n",i); printf("for loop:%d\n",i);
if(fgets(temp_str,256,f_config)!=NULL) if(fgets(temp_str,256,f_config)!=NULL)
{
if(strchr(temp_str,'[')==NULL)
{ {
temp_str[strcspn(temp_str,"\n")]=0; temp_str[strcspn(temp_str,"\n")]=0;
str_entry[i]=strdup(temp_str); str_entry[i]=strdup(temp_str);
printf("module path:%s",str_entry[i]); printf("module path:%s",str_entry[i]);
}else
{
break;
}
} }
else else
{ {
@ -32,6 +50,8 @@ int loadConfig(char *str_file, char **str_entry,int size)
fclose(f_config); fclose(f_config);
} }
} }
}
}
} }
else else
{ {