From a1b9b5c16c53bedfe8ebab39055a36dee387a9a4 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 12 May 2011 15:07:31 -0700 Subject: Volk: forgot to add prefs.c/h to git... --- volk/lib/volk_prefs.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 volk/lib/volk_prefs.c (limited to 'volk/lib/volk_prefs.c') diff --git a/volk/lib/volk_prefs.c b/volk/lib/volk_prefs.c new file mode 100644 index 000000000..bd15c130e --- /dev/null +++ b/volk/lib/volk_prefs.c @@ -0,0 +1,49 @@ +#include +#include +#include +#include + +//#if defined(_WIN32) +//#include +//#endif + +void get_config_path(char *path) { + const char *suffix = "/.gnuradio/volk_config"; + strcpy(path, getenv("HOME")); + strcat(path, suffix); +} + +//passing by reference in C can suck my balls +int load_preferences(struct volk_arch_pref **prefs) { + FILE *config_file; + char path[512], line[512], function[128], arch[32]; + int n_arch_prefs = 0; + struct volk_arch_pref *t_pref; + + //get the config path + get_config_path(path); + config_file = fopen(path, "r"); + if(!config_file) return; //no prefs found + + while(fgets(line, 512, config_file) != NULL) { + if(sscanf(line, "%s %s", function, arch) == 2 && !strncmp(function, "volk_", 5)) { + n_arch_prefs++; + } + } + + //now allocate the memory required for volk_arch_prefs + (*prefs) = (struct volk_arch_pref *) malloc(n_arch_prefs * sizeof(struct volk_arch_pref)); + t_pref = (*prefs); + + //reset the file pointer and write the prefs into volk_arch_prefs + rewind(config_file); + while(fgets(line, 512, config_file) != NULL) { + if(sscanf(line, "%s %s", function, arch) == 2 && !strncmp(function, "volk_", 5)) { + strncpy(t_pref->name, function, 128); + strncpy(t_pref->arch, arch, 32); + t_pref++; + } + } + fclose(config_file); + return n_arch_prefs; +} -- cgit From b0e781a55387e02ef8126219ccfe8b3c48a838f5 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 12 May 2011 15:39:56 -0700 Subject: Volk: move configuration into ~/.volk instead of ~/.gnuradio, add ability to create dir in profiler if not exist --- volk/lib/volk_prefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'volk/lib/volk_prefs.c') diff --git a/volk/lib/volk_prefs.c b/volk/lib/volk_prefs.c index bd15c130e..ebfe3bc40 100644 --- a/volk/lib/volk_prefs.c +++ b/volk/lib/volk_prefs.c @@ -8,7 +8,7 @@ //#endif void get_config_path(char *path) { - const char *suffix = "/.gnuradio/volk_config"; + const char *suffix = "/.volk/volk_config"; strcpy(path, getenv("HOME")); strcat(path, suffix); } -- cgit From e8610bae2cf87440a1c836e3b72b45b60130df34 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Wed, 18 May 2011 18:10:59 -0700 Subject: volk: remove justifiable obscenity from volk_prefs.c --- volk/lib/volk_prefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'volk/lib/volk_prefs.c') diff --git a/volk/lib/volk_prefs.c b/volk/lib/volk_prefs.c index ebfe3bc40..9743c51d9 100644 --- a/volk/lib/volk_prefs.c +++ b/volk/lib/volk_prefs.c @@ -13,7 +13,7 @@ void get_config_path(char *path) { strcat(path, suffix); } -//passing by reference in C can suck my balls +//passing by reference in C can (***********) int load_preferences(struct volk_arch_pref **prefs) { FILE *config_file; char path[512], line[512], function[128], arch[32]; -- cgit From b835094682f214366f7b8c0220134817c4f34157 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 20 Jul 2011 17:36:08 -0700 Subject: volk: snagged the volk changes from cmake branch --- volk/lib/volk_prefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'volk/lib/volk_prefs.c') diff --git a/volk/lib/volk_prefs.c b/volk/lib/volk_prefs.c index 9743c51d9..b29d5fd87 100644 --- a/volk/lib/volk_prefs.c +++ b/volk/lib/volk_prefs.c @@ -23,7 +23,7 @@ int load_preferences(struct volk_arch_pref **prefs) { //get the config path get_config_path(path); config_file = fopen(path, "r"); - if(!config_file) return; //no prefs found + if(!config_file) return n_arch_prefs; //no prefs found while(fgets(line, 512, config_file) != NULL) { if(sscanf(line, "%s %s", function, arch) == 2 && !strncmp(function, "volk_", 5)) { -- cgit From d9226e09495586279a06ec0e0af41e8ac6990970 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 22 Mar 2012 12:38:20 -0700 Subject: volk: fix for load prefs (config path) 1) add APPDATA to search path for windows 2) graceful fail and env vars not defined --- volk/lib/volk_prefs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'volk/lib/volk_prefs.c') diff --git a/volk/lib/volk_prefs.c b/volk/lib/volk_prefs.c index b29d5fd87..7e705bed4 100644 --- a/volk/lib/volk_prefs.c +++ b/volk/lib/volk_prefs.c @@ -9,7 +9,14 @@ void get_config_path(char *path) { const char *suffix = "/.volk/volk_config"; - strcpy(path, getenv("HOME")); + char *home = NULL; + if (home == NULL) home = getenv("HOME"); + if (home == NULL) home = getenv("APPDATA"); + if (home == NULL){ + path = NULL; + return; + } + strcpy(path, home); strcat(path, suffix); } @@ -22,6 +29,7 @@ int load_preferences(struct volk_arch_pref **prefs) { //get the config path get_config_path(path); + if (path == NULL) return n_arch_prefs; //no prefs found config_file = fopen(path, "r"); if(!config_file) return n_arch_prefs; //no prefs found -- cgit From f919f9dcbb54a08e6e26d6c229ce92fb784fa1b2 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 13 Apr 2012 18:36:53 -0400 Subject: Removed whitespace and added dtools/bin/remove-whitespace as a tool to do this in the future. The sed script was provided by Moritz Fischer. --- volk/lib/volk_prefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'volk/lib/volk_prefs.c') diff --git a/volk/lib/volk_prefs.c b/volk/lib/volk_prefs.c index 7e705bed4..5e5c9dfff 100644 --- a/volk/lib/volk_prefs.c +++ b/volk/lib/volk_prefs.c @@ -26,7 +26,7 @@ int load_preferences(struct volk_arch_pref **prefs) { char path[512], line[512], function[128], arch[32]; int n_arch_prefs = 0; struct volk_arch_pref *t_pref; - + //get the config path get_config_path(path); if (path == NULL) return n_arch_prefs; //no prefs found -- cgit From e826097e09fdfb04d14bf87861646b88229db881 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 13 Jan 2013 13:51:46 -0800 Subject: gras: support changeset for 3.6.4 used volk from next branch cf5c930d89ac89ba5a0da4a616c88d3c37e018ae for grextras support (it uses the dispatcher) empty stubs for the gr_basic_block msg passing. This is going to be difficult to figure out. The alias stuff may or may not be related most qa pass, there seems to be some additional issues, will be working through them on futher commits Conflicts: gnuradio-core/CMakeLists.txt gnuradio-core/src/lib/runtime/CMakeLists.txt gnuradio-core/src/lib/runtime/gr_block.cc gnuradio-core/src/lib/runtime/gr_block.h gnuradio-core/src/lib/runtime/gr_hier_block2.h gnuradio-core/src/lib/runtime/gr_top_block.h gnuradio-core/src/python/gnuradio/gr/__init__.py gr-audio/examples/c++/CMakeLists.txt gr-fcd/examples/c++/CMakeLists.txt grc/python/Port.py --- volk/lib/volk_prefs.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'volk/lib/volk_prefs.c') diff --git a/volk/lib/volk_prefs.c b/volk/lib/volk_prefs.c index 5e5c9dfff..f787b5e2a 100644 --- a/volk/lib/volk_prefs.c +++ b/volk/lib/volk_prefs.c @@ -7,7 +7,8 @@ //#include //#endif -void get_config_path(char *path) { +void volk_get_config_path(char *path) +{ const char *suffix = "/.volk/volk_config"; char *home = NULL; if (home == NULL) home = getenv("HOME"); @@ -20,38 +21,30 @@ void get_config_path(char *path) { strcat(path, suffix); } -//passing by reference in C can (***********) -int load_preferences(struct volk_arch_pref **prefs) { +size_t volk_load_preferences(volk_arch_pref_t **prefs_res) +{ FILE *config_file; - char path[512], line[512], function[128], arch[32]; - int n_arch_prefs = 0; - struct volk_arch_pref *t_pref; + char path[512], line[512]; + size_t n_arch_prefs = 0; + volk_arch_pref_t *prefs = NULL; //get the config path - get_config_path(path); + volk_get_config_path(path); if (path == NULL) return n_arch_prefs; //no prefs found config_file = fopen(path, "r"); if(!config_file) return n_arch_prefs; //no prefs found - while(fgets(line, 512, config_file) != NULL) { - if(sscanf(line, "%s %s", function, arch) == 2 && !strncmp(function, "volk_", 5)) { - n_arch_prefs++; - } - } - - //now allocate the memory required for volk_arch_prefs - (*prefs) = (struct volk_arch_pref *) malloc(n_arch_prefs * sizeof(struct volk_arch_pref)); - t_pref = (*prefs); - //reset the file pointer and write the prefs into volk_arch_prefs - rewind(config_file); - while(fgets(line, 512, config_file) != NULL) { - if(sscanf(line, "%s %s", function, arch) == 2 && !strncmp(function, "volk_", 5)) { - strncpy(t_pref->name, function, 128); - strncpy(t_pref->arch, arch, 32); - t_pref++; + while(fgets(line, sizeof(line), config_file) != NULL) + { + prefs = (volk_arch_pref_t *) realloc(prefs, (n_arch_prefs+1) * sizeof(*prefs)); + volk_arch_pref_t *p = prefs + n_arch_prefs; + if(sscanf(line, "%s %s %s", p->name, p->impl_a, p->impl_u) == 3 && !strncmp(p->name, "volk_", 5)) + { + n_arch_prefs++; } } fclose(config_file); + *prefs_res = prefs; return n_arch_prefs; } -- cgit