MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / rig_settings_get_path

Function rig_settings_get_path

src/settings.c:1026–1085  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1024char settings_file[4096];
1025
1026HAMLIB_EXPORT(int) rig_settings_get_path(char *path, int pathlen)
1027{
1028 char cwd[4096];
1029
1030 if (getcwd(cwd, 4096) == NULL)
1031 {
1032 rig_debug(RIG_DEBUG_ERR, "%s: getcwd: %s\n", __func__, strerror(errno));
1033 return -RIG_EINTERNAL;
1034 }
1035
1036#ifdef APPLE
1037//#include "TargetConditionals.h"
1038#ifdef TARGET_OS_IPHONE
1039// iOS
1040#elif TARGET_IPHONE_SIMULATOR
1041// iOS Simulator
1042#elif TARGET_OS_MAC
1043// Other kinds of Mac OS
1044#else
1045// Unsupported platform
1046#endif
1047#endif
1048
1049 const char *xdgpath = getenv("XDG_CONFIG_HOME");
1050 char *home = getenv("HOME");
1051
1052 if (home == NULL)
1053 {
1054 home = getenv("HOMEPATH");
1055 }
1056
1057 if (home == NULL)
1058 {
1059 home = "?HOME";
1060 }
1061
1062 // cppcheck-suppress nullPointerRedundantCheck
1063 snprintf(path, pathlen, "%s/.config", home);
1064
1065 if (xdgpath)
1066 {
1067 snprintf(path, pathlen - 1, "%s/%s", xdgpath, HAMLIB_SETTINGS_FILE);
1068 }
1069 else if (home && access(path, F_OK) != -1)
1070 {
1071 snprintf(path, pathlen - 1, "%s/.config/%s", home, HAMLIB_SETTINGS_FILE);
1072 }
1073 else if (home)
1074 {
1075 // we add a leading period to hide the file
1076 snprintf(path, pathlen - 1, "%s/.%s", home, HAMLIB_SETTINGS_FILE);
1077 }
1078 else
1079 {
1080 snprintf(path, pathlen - 1, ".%s", HAMLIB_SETTINGS_FILE);
1081 }
1082
1083 rig_debug(RIG_DEBUG_TRACE, "%s: path=%s\n", __func__, path);

Callers 2

rig_settings_saveFunction · 0.85
rig_settings_load_allFunction · 0.85

Calls 1

rig_debugFunction · 0.85

Tested by

no test coverage detected