add config

This commit is contained in:
Jonathan Santis 2024-09-11 10:14:55 +02:00
parent 39b0ed19ae
commit c06d9ea962
3 changed files with 44 additions and 0 deletions

5
config Normal file
View File

@ -0,0 +1,5 @@
/systemd/blalbla/1
/systemd/blalbla/2
/systemd/blalbla/3
/systemd/blalbla/4
/systemd/blalbla/5

37
config.c Normal file
View File

@ -0,0 +1,37 @@
#include"config.h"
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
int loadConfig(char *file, char **str_entry,int size)
{
int i=0;
bool terminate=false;
FILE *f_config;
printf("opening config file\n");
f_config = fopen("config","r");
if(f_config != NULL)
{
for(i=0;i<size & terminate==false;i++)
{
printf("for loop:%d",i);
if(fgets(str_entry[i],10,f_config)!=NULL)
{
puts(str_entry[i]);
}
else
{
terminate = true;
fclose(f_config);
}
i++;
}
}
else
{
fprintf(stderr,"error opening file");
}
return 0;
}

2
config.h Normal file
View File

@ -0,0 +1,2 @@
int loadConfig(char *file, char **str_entry,int size);