Revision e8a3f5ba
| b/gr-run-waveform/test_xyzzy.cc | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2004 Free Software Foundation, Inc. |
|
| 4 |
* |
|
| 5 |
* This file is part of GNU Radio |
|
| 6 |
* |
|
| 7 |
* GNU Radio is free software; you can redistribute it and/or modify |
|
| 8 |
* it under the terms of the GNU General Public License as published by |
|
| 9 |
* the Free Software Foundation; either version 3, or (at your option) |
|
| 10 |
* any later version. |
|
| 11 |
* |
|
| 12 |
* GNU Radio is distributed in the hope that it will be useful, |
|
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 |
* GNU General Public License for more details. |
|
| 16 |
* |
|
| 17 |
* You should have received a copy of the GNU General Public License |
|
| 18 |
* along with GNU Radio; see the file COPYING. If not, write to |
|
| 19 |
* the Free Software Foundation, Inc., 51 Franklin Street, |
|
| 20 |
* Boston, MA 02110-1301, USA. |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
#include <cstdio> |
|
| 24 |
#include <cstdlib> |
|
| 25 |
#include <string> |
|
| 26 |
#include <iostream> |
|
| 27 |
#include <fstream> |
|
| 28 |
#include <libguile.h> |
|
| 29 |
|
|
| 30 |
// Include our definitions |
|
| 31 |
#include "xyzzy.h" |
|
| 32 |
|
|
| 33 |
using namespace std; |
|
| 34 |
|
|
| 35 |
int |
|
| 36 |
main(int argc, char *argv[]) |
|
| 37 |
{
|
|
| 38 |
|
|
| 39 |
// Initialize with the data file produced by gen-xyzzy. |
|
| 40 |
// bool init() |
|
| 41 |
// bool init(const std::string &file) |
|
| 42 |
// Does a file with name 'filename' exist in magic filesystem? |
|
| 43 |
// bool file_exists(handle, const std::string &filespec); |
|
| 44 |
// bool file_exists(const std::string &filespec) |
|
| 45 |
|
|
| 46 |
// Return a C port that will read the file contents |
|
| 47 |
// SCM make_read_only_port(handle, const std::string &filespec) |
|
| 48 |
// SCM make_read_only_port(const std::string &filespec) |
|
| 49 |
|
|
| 50 |
} |
|
| b/gr-run-waveform/xyzzy.cc | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2004 Free Software Foundation, Inc. |
|
| 4 |
* |
|
| 5 |
* This file is part of GNU Radio |
|
| 6 |
* |
|
| 7 |
* GNU Radio is free software; you can redistribute it and/or modify |
|
| 8 |
* it under the terms of the GNU General Public License as published by |
|
| 9 |
* the Free Software Foundation; either version 3, or (at your option) |
|
| 10 |
* any later version. |
|
| 11 |
* |
|
| 12 |
* GNU Radio is distributed in the hope that it will be useful, |
|
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 |
* GNU General Public License for more details. |
|
| 16 |
* |
|
| 17 |
* You should have received a copy of the GNU General Public License |
|
| 18 |
* along with GNU Radio; see the file COPYING. If not, write to |
|
| 19 |
* the Free Software Foundation, Inc., 51 Franklin Street, |
|
| 20 |
* Boston, MA 02110-1301, USA. |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
#include <cstdio> |
|
| 24 |
#include <cstdlib> |
|
| 25 |
#include <string> |
|
| 26 |
#include <iostream> |
|
| 27 |
#include <fstream> |
|
| 28 |
#include <libguile.h> |
|
| 29 |
|
|
| 30 |
// Include our definitions |
|
| 31 |
#include "xyzzy.h" |
|
| 32 |
|
|
| 33 |
using namespace std; |
|
| 34 |
|
|
| 35 |
typedef void* handle_t; |
|
| 36 |
|
|
| 37 |
handle_t datafile; |
|
| 38 |
|
|
| 39 |
|
|
| 40 |
// Initialize with the data file produced by gen-xyzzy. |
|
| 41 |
bool init() |
|
| 42 |
{
|
|
| 43 |
string filespec = PKGLIBDIR; |
|
| 44 |
filespec += '/'; |
|
| 45 |
filespec += "filesystem.dat"; |
|
| 46 |
return init(filespec); |
|
| 47 |
}; |
|
| 48 |
|
|
| 49 |
bool init(const std::string &file) |
|
| 50 |
{
|
|
| 51 |
return false; |
|
| 52 |
}; |
|
| 53 |
|
|
| 54 |
// Does a file with name 'filename' exist in magic filesystem? |
|
| 55 |
// bool file_exists(handle, const std::string &filespec); |
|
| 56 |
bool |
|
| 57 |
file_exists(const std::string &filespec) |
|
| 58 |
{
|
|
| 59 |
// datafile |
|
| 60 |
} |
|
| 61 |
|
|
| 62 |
// Return a C port that will read the file contents |
|
| 63 |
// SCM make_read_only_port(handle, const std::string &filespec) |
|
| 64 |
SCM |
|
| 65 |
make_read_only_port(const std::string &filespec) |
|
| 66 |
{
|
|
| 67 |
// datafile |
|
| 68 |
} |
|
| b/gr-run-waveform/xyzzy.h | ||
|---|---|---|
| 1 |
/* -*- c++ -*- */ |
|
| 2 |
/* |
|
| 3 |
* Copyright 2004 Free Software Foundation, Inc. |
|
| 4 |
* |
|
| 5 |
* This file is part of GNU Radio |
|
| 6 |
* |
|
| 7 |
* GNU Radio is free software; you can redistribute it and/or modify |
|
| 8 |
* it under the terms of the GNU General Public License as published by |
|
| 9 |
* the Free Software Foundation; either version 3, or (at your option) |
|
| 10 |
* any later version. |
|
| 11 |
* |
|
| 12 |
* GNU Radio is distributed in the hope that it will be useful, |
|
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 15 |
* GNU General Public License for more details. |
|
| 16 |
* |
|
| 17 |
* You should have received a copy of the GNU General Public License |
|
| 18 |
* along with GNU Radio; see the file COPYING. If not, write to |
|
| 19 |
* the Free Software Foundation, Inc., 51 Franklin Street, |
|
| 20 |
* Boston, MA 02110-1301, USA. |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
#ifndef _XYZZY_H_ |
|
| 24 |
#define _XYZZY_H_ 1 |
|
| 25 |
|
|
| 26 |
#include <cstdio> |
|
| 27 |
#include <cstdlib> |
|
| 28 |
#include <string> |
|
| 29 |
#include <iostream> |
|
| 30 |
#include <fstream> |
|
| 31 |
|
|
| 32 |
#include <libguile.h> |
|
| 33 |
|
|
| 34 |
using namespace std; |
|
| 35 |
|
|
| 36 |
// - Special case filenames that start with /-xyzzy-/... and search for |
|
| 37 |
// and load them using the single file. We'd stick "/-zyzzy-" first |
|
| 38 |
// in the default load-path. |
|
| 39 |
|
|
| 40 |
// - Create a C read-only "port" that "reads" from the string in the file. |
|
| 41 |
// (See guile docs on creating new kinds of ports) |
|
| 42 |
|
|
| 43 |
// - Override the default implementation of "primitive-load" and "%search-load-path" |
|
| 44 |
// to make that happen. See load.c in the guile source code. Figure |
|
| 45 |
// out how to get the override done before guile is fully |
|
| 46 |
// initialized. (Guile loads ice-9/boot9.scm to start itself up. We'd |
|
| 47 |
// need to redirect before then.) |
|
| 48 |
|
|
| 49 |
struct header {
|
|
| 50 |
char magic[8]; |
|
| 51 |
|
|
| 52 |
uint32_t offset_to_directory; // byte offset from start of file |
|
| 53 |
uint32_t size_of_directory; // bytes |
|
| 54 |
uint32_t number_of_dir_entries; |
|
| 55 |
|
|
| 56 |
uint32_t offset_to_strings; // byte offset from start of file |
|
| 57 |
uint32_t size_of_strings; // bytes |
|
| 58 |
}; |
|
| 59 |
|
|
| 60 |
struct directory_entry {
|
|
| 61 |
uint32_t offset_to_name; // from start of strings |
|
| 62 |
uint32_t offset_to_contents; // from start of strings |
|
| 63 |
}; |
|
| 64 |
|
|
| 65 |
// Each string starts with a uint32_t length, followed by length bytes. |
|
| 66 |
// There is no trailing \0 in the string. |
|
| 67 |
struct string_entry {
|
|
| 68 |
uint32_t length; |
|
| 69 |
unsigned char c[1]; // 0 is nicer, but not portable. |
|
| 70 |
}; |
|
| 71 |
|
|
| 72 |
// Initialize with the data file produced by gen-xyzzy. |
|
| 73 |
bool init(const std::string &filespec); |
|
| 74 |
bool init(); |
|
| 75 |
|
|
| 76 |
// Does a file with name 'filename' exist in magic filesystem? |
|
| 77 |
bool file_exists(const std::string &filespec); |
|
| 78 |
|
|
| 79 |
// Return a C port that will read the file contents |
|
| 80 |
SCM make_read_only_port(const std::string &filespec); |
|
| 81 |
|
|
| 82 |
#endif // _XYZZY_H_ 1 |
|
Also available in: Unified diff