summaryrefslogtreecommitdiff
path: root/gr-run-waveform
diff options
context:
space:
mode:
authorRob Savoye2010-11-25 12:45:33 -0700
committerRob Savoye2010-11-25 12:45:33 -0700
commit3a344433295b769d820e88332659dfe067e24819 (patch)
treeef8b03e046f79a6786a7b06f8e12e6e2b473b016 /gr-run-waveform
parent71d5503d70e10fde8db0ddebe4451d52b6cb0bb5 (diff)
downloadgnuradio-3a344433295b769d820e88332659dfe067e24819.tar.gz
gnuradio-3a344433295b769d820e88332659dfe067e24819.tar.bz2
gnuradio-3a344433295b769d820e88332659dfe067e24819.zip
read in a scheme source file that defines a function and execute it.
Diffstat (limited to 'gr-run-waveform')
-rw-r--r--gr-run-waveform/run_waveform.cc38
1 files changed, 37 insertions, 1 deletions
diff --git a/gr-run-waveform/run_waveform.cc b/gr-run-waveform/run_waveform.cc
index 2d430766c..f9d85ec92 100644
--- a/gr-run-waveform/run_waveform.cc
+++ b/gr-run-waveform/run_waveform.cc
@@ -22,25 +22,61 @@
#include <cstdio>
#include <cstdlib>
+#include <string>
+#include <iostream>
+#include <fstream>
#include <libguile.h>
+using namespace std;
+
+static std::string filename = "hello.scm";
+
static SCM
load_waveform (void)
{
- return SCM_BOOL_F;
+ ifstream in;
+ string filespec = SRCDIR;
+ filespec += '/';
+ filespec += filename;
+
+ in.open(filespec.c_str());
+ if (!in) {
+ cerr << ("run_waveform: couldn't open data file: ") << filespec << endl;
+ return SCM_BOOL_F;
+ }
+
+ // Read in the file one line at a time, and accumulate it into
+ // a big string that'll hold the entire file.
+ string line;
+ string file;
+ while (std::getline(in, line)) {
+ file += line;
+ cerr << line << endl;
+ }
+
+ // Evaluate the file
+ scm_c_eval_string(file.c_str());
+
+ in.close();
+
+ scm_c_eval_string("(hello-world)");
+
+ return SCM_BOOL_T;
}
static void
inner_main (void *data, int argc, char **argv)
{
scm_c_define_gsubr ("load-waveform", 0, 0, 0, load_waveform);
+
scm_shell (argc, argv);
}
int
main(int argc, char *argv[])
{
+
scm_boot_guile (argc, argv, inner_main, 0);
return 0; // never reached