1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 04:30:33 +00:00

Search for system-wide volk_gnsssdr_config file

This commit is contained in:
Carles Fernandez 2019-05-29 15:56:12 +02:00
parent 80f6cf417b
commit fb350e788b
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -19,6 +19,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(_MSC_VER)
#include <io.h>
#define access _access
#define F_OK 0
#else
#include <unistd.h>
#endif
#include <volk_gnsssdr/volk_gnsssdr_prefs.h>
@ -38,16 +45,42 @@ void volk_gnsssdr_get_config_path(char *path)
return;
}
if (home == NULL) home = getenv("HOME");
if (home == NULL) home = getenv("APPDATA");
if (home == NULL)
// check for user-local config file
home = getenv("HOME");
if (home != NULL)
{
strncpy(path, home, 512);
strcat(path, suffix);
if (access(path, F_OK) != -1)
{
return;
}
}
// check for config file in APPDATA (Windows)
home = getenv("APPDATA");
if (home != NULL)
{
strncpy(path, home, 512);
strcat(path, suffix);
if (access(path, F_OK) != -1)
{
return;
}
}
// check for system-wide config file
if (access("/etc/volk_gnsssdr/volk_gnsssdr_config", F_OK) != -1)
{
strncpy(path, "/etc", 512);
strcat(path, suffix2);
return;
}
path[0] = 0;
return;
}
strncpy(path, home, 512);
strcat(path, suffix);
}
size_t volk_gnsssdr_load_preferences(volk_gnsssdr_arch_pref_t **prefs_res)
{