diff options
author | Rob Savoye <rob@welcomehome.org> | 2010-11-26 10:30:40 -0700 |
---|---|---|
committer | Rob Savoye <rob@welcomehome.org> | 2010-11-26 10:30:40 -0700 |
commit | e8a3f5bacd2d7b662e43be4bee0189d91465281b (patch) | |
tree | 80563ae25859be78a7f953759e7c09486ac89ae6 /gr-run-waveform | |
parent | 06f49339578b048b6a2f9d892ba61081e96a4186 (diff) |
start adding code to handle the filesystem data file
Diffstat (limited to 'gr-run-waveform')
-rw-r--r-- | gr-run-waveform/test_xyzzy.cc | 50 | ||||
-rw-r--r-- | gr-run-waveform/xyzzy.cc | 68 | ||||
-rw-r--r-- | gr-run-waveform/xyzzy.h | 82 |
3 files changed, 200 insertions, 0 deletions
diff --git a/gr-run-waveform/test_xyzzy.cc b/gr-run-waveform/test_xyzzy.cc new file mode 100644 index 0000000000..b629e20f6c --- /dev/null +++ b/gr-run-waveform/test_xyzzy.cc @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <cstdio> +#include <cstdlib> +#include <string> +#include <iostream> +#include <fstream> +#include <libguile.h> + +// Include our definitions +#include "xyzzy.h" + +using namespace std; + +int +main(int argc, char *argv[]) +{ + +// Initialize with the data file produced by gen-xyzzy. +// bool init() +// bool init(const std::string &file) +// Does a file with name 'filename' exist in magic filesystem? +// bool file_exists(handle, const std::string &filespec); +// bool file_exists(const std::string &filespec) + +// Return a C port that will read the file contents +// SCM make_read_only_port(handle, const std::string &filespec) +// SCM make_read_only_port(const std::string &filespec) + +} diff --git a/gr-run-waveform/xyzzy.cc b/gr-run-waveform/xyzzy.cc new file mode 100644 index 0000000000..a54947c510 --- /dev/null +++ b/gr-run-waveform/xyzzy.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#include <cstdio> +#include <cstdlib> +#include <string> +#include <iostream> +#include <fstream> +#include <libguile.h> + +// Include our definitions +#include "xyzzy.h" + +using namespace std; + +typedef void* handle_t; + +handle_t datafile; + + +// Initialize with the data file produced by gen-xyzzy. +bool init() +{ + string filespec = PKGLIBDIR; + filespec += '/'; + filespec += "filesystem.dat"; + return init(filespec); +}; + +bool init(const std::string &file) +{ + return false; +}; + +// Does a file with name 'filename' exist in magic filesystem? +// bool file_exists(handle, const std::string &filespec); +bool +file_exists(const std::string &filespec) +{ +// datafile +} + +// Return a C port that will read the file contents +// SCM make_read_only_port(handle, const std::string &filespec) +SCM +make_read_only_port(const std::string &filespec) +{ +// datafile +} diff --git a/gr-run-waveform/xyzzy.h b/gr-run-waveform/xyzzy.h new file mode 100644 index 0000000000..024c9f963f --- /dev/null +++ b/gr-run-waveform/xyzzy.h @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _XYZZY_H_ +#define _XYZZY_H_ 1 + +#include <cstdio> +#include <cstdlib> +#include <string> +#include <iostream> +#include <fstream> + +#include <libguile.h> + +using namespace std; + +// - Special case filenames that start with /-xyzzy-/... and search for +// and load them using the single file. We'd stick "/-zyzzy-" first +// in the default load-path. + +// - Create a C read-only "port" that "reads" from the string in the file. +// (See guile docs on creating new kinds of ports) + +// - Override the default implementation of "primitive-load" and "%search-load-path" +// to make that happen. See load.c in the guile source code. Figure +// out how to get the override done before guile is fully +// initialized. (Guile loads ice-9/boot9.scm to start itself up. We'd +// need to redirect before then.) + +struct header { + char magic[8]; + + uint32_t offset_to_directory; // byte offset from start of file + uint32_t size_of_directory; // bytes + uint32_t number_of_dir_entries; + + uint32_t offset_to_strings; // byte offset from start of file + uint32_t size_of_strings; // bytes +}; + +struct directory_entry { + uint32_t offset_to_name; // from start of strings + uint32_t offset_to_contents; // from start of strings +}; + +// Each string starts with a uint32_t length, followed by length bytes. +// There is no trailing \0 in the string. +struct string_entry { + uint32_t length; + unsigned char c[1]; // 0 is nicer, but not portable. +}; + +// Initialize with the data file produced by gen-xyzzy. +bool init(const std::string &filespec); +bool init(); + +// Does a file with name 'filename' exist in magic filesystem? +bool file_exists(const std::string &filespec); + +// Return a C port that will read the file contents +SCM make_read_only_port(const std::string &filespec); + +#endif // _XYZZY_H_ 1 |