summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-03-10 23:52:51 -0400
committerTom Rondeau <trondeau@vt.edu>2013-03-10 23:52:51 -0400
commit294a6fd3b811703329eb15ed91d848c65cc6700e (patch)
treeb422709c45c6bd8a67255d1c55f0cc34604e5bfc /gnuradio-core/src/lib
parent5a3f0062fa438875b68191363d4ff78ccd07d0c9 (diff)
blocks: removing file_sink/source file_descriptor_sink/source form core and moved all refs to gr-blocks.
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/io/CMakeLists.txt5
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc87
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_sink.h59
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_sink.i35
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_source.cc151
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_source.h68
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_source.i35
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink.cc84
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink.h58
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink.i45
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.cc125
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.h75
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.i51
-rw-r--r--gnuradio-core/src/lib/io/gr_file_source.cc192
-rw-r--r--gnuradio-core/src/lib/io/gr_file_source.h107
-rw-r--r--gnuradio-core/src/lib/io/gr_file_source.i45
-rw-r--r--gnuradio-core/src/lib/io/io.i9
-rw-r--r--gnuradio-core/src/lib/runtime/gr_top_block.h2
18 files changed, 1 insertions, 1232 deletions
diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt
index 7d1572ca70..afd1d46b3e 100644
--- a/gnuradio-core/src/lib/io/CMakeLists.txt
+++ b/gnuradio-core/src/lib/io/CMakeLists.txt
@@ -78,11 +78,6 @@ endif(ENABLE_PYTHON)
# Handle triple-threat files that have cc, h, and i
########################################################################
set(gr_core_io_triple_threats
- gr_file_sink
- gr_file_sink_base
- gr_file_source
- gr_file_descriptor_sink
- gr_file_descriptor_source
microtune_xxxx_eval_board
microtune_4702_eval_board
microtune_4937_eval_board
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc
deleted file mode 100644
index 099d46dbd0..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2010 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gr_file_descriptor_sink.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <stdio.h>
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
-gr_file_descriptor_sink::gr_file_descriptor_sink (size_t itemsize, int fd)
- : gr_sync_block ("file_descriptor_sink",
- gr_make_io_signature (1, 1, itemsize),
- gr_make_io_signature (0, 0, 0)),
- d_itemsize (itemsize), d_fd (fd)
-{
-}
-
-gr_file_descriptor_sink_sptr
-gr_make_file_descriptor_sink (size_t itemsize, int fd)
-{
- return gnuradio::get_initial_sptr(new gr_file_descriptor_sink (itemsize, fd));
-}
-
-gr_file_descriptor_sink::~gr_file_descriptor_sink ()
-{
- close (d_fd);
-}
-
-int
-gr_file_descriptor_sink::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *inbuf = (char *) input_items[0];
- unsigned long byte_size = noutput_items * d_itemsize;
-
- while (byte_size > 0){
- ssize_t r;
-
- r = write (d_fd, inbuf, byte_size);
- if (r == -1){
- if (errno == EINTR)
- continue;
- else {
- perror ("gr_file_descriptor_sink");
- return -1; // indicate we're done
- }
- }
- else {
- byte_size -= r;
- inbuf += r;
- }
- }
-
- return noutput_items;
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h
deleted file mode 100644
index 3b1c1167f7..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- 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 INCLUDED_GR_FILE_DESCRIPTOR_SINK_H
-#define INCLUDED_GR_FILE_DESCRIPTOR_SINK_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-
-class gr_file_descriptor_sink;
-typedef boost::shared_ptr<gr_file_descriptor_sink> gr_file_descriptor_sink_sptr;
-
-GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd);
-
-/*!
- * \brief Write stream to file descriptor.
- * \ingroup sink_blk
- */
-
-class GR_CORE_API gr_file_descriptor_sink : public gr_sync_block
-{
- friend GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd);
-
- private:
- size_t d_itemsize;
- int d_fd;
-
- protected:
- gr_file_descriptor_sink (size_t itemsize, int fd);
-
- public:
- ~gr_file_descriptor_sink ();
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-
-#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SINK_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i
deleted file mode 100644
index 2c256e44d1..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,file_descriptor_sink)
-
-gr_file_descriptor_sink_sptr
-gr_make_file_descriptor_sink (size_t itemsize, int fd);
-
-class gr_file_descriptor_sink : public gr_sync_block
-{
- protected:
- gr_file_descriptor_sink (size_t itemsize, int fd);
-
- public:
- ~gr_file_descriptor_sink ();
-};
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc b/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc
deleted file mode 100644
index a63abf96b7..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc
+++ /dev/null
@@ -1,151 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2005 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gr_file_descriptor_source.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <stdio.h>
-#include <string.h>
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
-gr_file_descriptor_source::gr_file_descriptor_source (size_t itemsize,
- int fd,
- bool repeat)
- : gr_sync_block ("file_descriptor_source",
- gr_make_io_signature (0, 0, 0),
- gr_make_io_signature (1, 1, itemsize)),
- d_itemsize (itemsize), d_fd (fd), d_repeat (repeat),
- d_residue (new unsigned char[itemsize]), d_residue_len (0)
-{
-}
-
-// public constructor that returns a shared_ptr
-
-gr_file_descriptor_source_sptr
-gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat)
-{
- return gr_file_descriptor_source_sptr (
- new gr_file_descriptor_source (itemsize, fd, repeat));
-}
-
-gr_file_descriptor_source::~gr_file_descriptor_source ()
-{
- close (d_fd);
- delete [] d_residue;
-}
-
-int
-gr_file_descriptor_source::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- assert (noutput_items > 0);
-
- char *o = (char *) output_items[0];
- int nread = 0;
-
- while (1){
- int r = read_items (o, noutput_items - nread);
- if (r == -1){
- if (errno == EINTR)
- continue;
- else {
- perror ("file_descriptor_source[read]");
- return -1;
- }
- }
- else if (r == 0){ // end of file
- if (!d_repeat)
- break;
- else {
- flush_residue ();
- if (lseek (d_fd, 0, SEEK_SET) == -1){
- perror ("file_descriptor_source[lseek]");
- return -1;
- }
- }
- }
- else {
- o += r * d_itemsize;
- nread += r;
- break;
- }
- }
-
- if (nread == 0) // EOF
- return -1;
-
- return nread;
-}
-
-int
-gr_file_descriptor_source::read_items (char *buf, int nitems)
-{
- assert (nitems > 0);
- assert (d_residue_len < d_itemsize);
-
- int nbytes_read = 0;
-
- if (d_residue_len > 0){
- memcpy (buf, d_residue, d_residue_len);
- nbytes_read = d_residue_len;
- d_residue_len = 0;
- }
-
- int r = read (d_fd, buf + nbytes_read, nitems * d_itemsize - nbytes_read);
- if (r <= 0){
- handle_residue (buf, nbytes_read);
- return r;
- }
-
- r = handle_residue (buf, r + nbytes_read);
-
- if (r == 0) // block until we get something
- return read_items (buf, nitems);
-
- return r;
-}
-
-int
-gr_file_descriptor_source::handle_residue (char *buf, int nbytes_read)
-{
- assert (nbytes_read >= 0);
- int nitems_read = nbytes_read / d_itemsize;
- d_residue_len = nbytes_read % d_itemsize;
- if (d_residue_len > 0){
- // fprintf (stderr, "handle_residue: %d\n", d_residue_len);
- memcpy (d_residue, buf + nbytes_read - d_residue_len, d_residue_len);
- }
- return nitems_read;
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h b/gnuradio-core/src/lib/io/gr_file_descriptor_source.h
deleted file mode 100644
index ebabd81eda..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- 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 INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H
-#define INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-
-class gr_file_descriptor_source;
-typedef boost::shared_ptr<gr_file_descriptor_source> gr_file_descriptor_source_sptr;
-
-GR_CORE_API gr_file_descriptor_source_sptr
-gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat = false);
-
-/*!
- * \brief Read stream from file descriptor.
- * \ingroup source_blk
- */
-
-class GR_CORE_API gr_file_descriptor_source : public gr_sync_block
-{
- friend GR_CORE_API gr_file_descriptor_source_sptr
- gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat);
- private:
- size_t d_itemsize;
- int d_fd;
- bool d_repeat;
-
- unsigned char *d_residue;
- unsigned long d_residue_len;
-
- protected:
- gr_file_descriptor_source (size_t itemsize, int fd, bool repeat);
-
- int read_items (char *buf, int nitems);
- int handle_residue (char *buf, int nbytes_read);
- void flush_residue () { d_residue_len = 0; }
-
-
- public:
- ~gr_file_descriptor_source ();
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.i b/gnuradio-core/src/lib/io/gr_file_descriptor_source.i
deleted file mode 100644
index 3ca0825225..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.i
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,file_descriptor_source)
-
-gr_file_descriptor_source_sptr
-gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat=false);
-
-class gr_file_descriptor_source : public gr_sync_block
-{
- protected:
- gr_file_descriptor_source (size_t itemsize, int fd, bool repeat);
-
- public:
- ~gr_file_descriptor_source ();
-};
diff --git a/gnuradio-core/src/lib/io/gr_file_sink.cc b/gnuradio-core/src/lib/io/gr_file_sink.cc
deleted file mode 100644
index 10c8360cb6..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2006,2007,2010 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gr_file_sink.h>
-#include <gr_io_signature.h>
-#include <stdexcept>
-
-
-gr_file_sink_sptr
-gr_make_file_sink (size_t itemsize, const char *filename)
-{
- return gnuradio::get_initial_sptr(new gr_file_sink (itemsize, filename));
-}
-
-gr_file_sink::gr_file_sink(size_t itemsize, const char *filename)
- : gr_sync_block ("file_sink",
- gr_make_io_signature(1, 1, itemsize),
- gr_make_io_signature(0, 0, 0)),
- gr_file_sink_base(filename, true),
- d_itemsize(itemsize)
-{
-}
-
-gr_file_sink::~gr_file_sink ()
-{
-}
-
-int
-gr_file_sink::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *inbuf = (char*)input_items[0];
- int nwritten = 0;
-
- do_update(); // update d_fp is reqd
-
- if(!d_fp)
- return noutput_items; // drop output on the floor
-
- while(nwritten < noutput_items) {
- int count = fwrite(inbuf, d_itemsize, noutput_items - nwritten, d_fp);
- if(count == 0) {
- if(ferror(d_fp)) {
- std::stringstream s;
- s << "file_sink write failed with error " << fileno(d_fp) << std::endl;
- throw std::runtime_error(s.str());
- }
- else { // is EOF
- break;
- }
- }
- nwritten += count;
- inbuf += count * d_itemsize;
- }
-
- if(d_unbuffered)
- fflush (d_fp);
-
- return nwritten;
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_sink.h b/gnuradio-core/src/lib/io/gr_file_sink.h
deleted file mode 100644
index e40ec9ab8d..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2007 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 INCLUDED_GR_FILE_SINK_H
-#define INCLUDED_GR_FILE_SINK_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_file_sink_base.h>
-
-class gr_file_sink;
-typedef boost::shared_ptr<gr_file_sink> gr_file_sink_sptr;
-
-GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename);
-
-/*!
- * \brief Write stream to file.
- * \ingroup sink_blk
- */
-
-class GR_CORE_API gr_file_sink : public gr_sync_block, public gr_file_sink_base
-{
- friend GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename);
-
- private:
- size_t d_itemsize;
-
- protected:
- gr_file_sink(size_t itemsize, const char *filename);
-
- public:
- ~gr_file_sink();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_GR_FILE_SINK_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_sink.i b/gnuradio-core/src/lib/io/gr_file_sink.i
deleted file mode 100644
index 47ab9e9649..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink.i
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,file_sink)
-
-gr_file_sink_sptr
-gr_make_file_sink (size_t itemsize, const char *filename);
-
-class gr_file_sink : public gr_sync_block, public gr_file_sink_base
-{
- protected:
- gr_file_sink (size_t itemsize, const char *filename);
-
- public:
- ~gr_file_sink ();
-
- /*!
- * \brief open filename and begin output to it.
- */
- bool open(const char *filename);
-
- /*!
- * \brief close current output file.
- */
- void close();
-};
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.cc b/gnuradio-core/src/lib/io/gr_file_sink_base.cc
deleted file mode 100644
index d0aca418e7..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2006,2007,2009 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gr_file_sink_base.h>
-#include <cstdio>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <stdio.h>
-#include <gruel/thread.h>
-
-// win32 (mingw/msvc) specific
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
-#else
-#define OUR_O_BINARY 0
-#endif
-
-// should be handled via configure
-#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
-#else
-#define OUR_O_LARGEFILE 0
-#endif
-
-gr_file_sink_base::gr_file_sink_base(const char *filename, bool is_binary)
- : d_fp(0), d_new_fp(0), d_updated(false), d_is_binary(is_binary)
-{
- if (!open(filename))
- throw std::runtime_error ("can't open file");
-}
-
-gr_file_sink_base::~gr_file_sink_base ()
-{
- close();
- if (d_fp){
- fclose(d_fp);
- d_fp = 0;
- }
-}
-
-bool
-gr_file_sink_base::open(const char *filename)
-{
- gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function
-
- // we use the open system call to get access to the O_LARGEFILE flag.
- int fd;
- if ((fd = ::open (filename,
- O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY,
- 0664)) < 0){
- perror (filename);
- return false;
- }
- if (d_new_fp){ // if we've already got a new one open, close it
- fclose(d_new_fp);
- d_new_fp = 0;
- }
-
- if ((d_new_fp = fdopen (fd, d_is_binary ? "wb" : "w")) == NULL){
- perror (filename);
- ::close(fd); // don't leak file descriptor if fdopen fails.
- }
-
- d_updated = true;
- return d_new_fp != 0;
-}
-
-void
-gr_file_sink_base::close()
-{
- gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function
-
- if (d_new_fp){
- fclose(d_new_fp);
- d_new_fp = 0;
- }
- d_updated = true;
-}
-
-void
-gr_file_sink_base::do_update()
-{
- if (d_updated){
- gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block
- if (d_fp)
- fclose(d_fp);
- d_fp = d_new_fp; // install new file pointer
- d_new_fp = 0;
- d_updated = false;
- }
-}
-
-void
-gr_file_sink_base::set_unbuffered(bool unbuffered)
-{
- d_unbuffered = unbuffered;
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h
deleted file mode 100644
index 8a70cee768..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2007,2008 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 INCLUDED_GR_FILE_SINK_BASE_H
-#define INCLUDED_GR_FILE_SINK_BASE_H
-
-#include <gr_core_api.h>
-#include <boost/thread.hpp>
-#include <cstdio>
-
-/*!
- * \brief Common base class for file sinks
- */
-class GR_CORE_API gr_file_sink_base
-{
- protected:
- FILE *d_fp; // current FILE pointer
- FILE *d_new_fp; // new FILE pointer
- bool d_updated; // is there a new FILE pointer?
- bool d_is_binary;
- boost::mutex d_mutex;
- bool d_unbuffered;
-
- protected:
- gr_file_sink_base(const char *filename, bool is_binary);
-
- public:
- ~gr_file_sink_base();
-
- /*!
- * \brief Open filename and begin output to it.
- */
- bool open(const char *filename);
-
- /*!
- * \brief Close current output file.
- *
- * Closes current output file and ignores any output until
- * open is called to connect to another file.
- */
- void close();
-
- /*!
- * \brief if we've had an update, do it now.
- */
- void do_update();
-
-
- /*!
- * \brief turn on unbuffered writes for slower outputs
- */
- void set_unbuffered(bool unbuffered);
-};
-
-
-#endif /* INCLUDED_GR_FILE_SINK_BASE_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.i b/gnuradio-core/src/lib/io/gr_file_sink_base.i
deleted file mode 100644
index 993dba2770..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.i
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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 this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-class gr_file_sink_base
-{
- protected:
- gr_file_sink_base(const char *filename, bool is_binary);
-
- public:
- ~gr_file_sink_base();
-
- /*!
- * \brief Open filename and begin output to it.
- */
- bool open(const char *filename);
-
- /*!
- * \brief Close current output file.
- *
- * Closes current output file and ignores any output until
- * open is called to connect to another file.
- */
- void close();
-
- /*!
- * \brief if we've had an update, do it now.
- */
- void do_update();
-
- /*!
- *\brief turn on unbuffered mode for slow outputs
- */
- void set_unbuffered(bool unbuffered);
-};
diff --git a/gnuradio-core/src/lib/io/gr_file_source.cc b/gnuradio-core/src/lib/io/gr_file_source.cc
deleted file mode 100644
index 6da7abac21..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_source.cc
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2010 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gruel/thread.h>
-#include <gr_file_source.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <stdio.h>
-
-// win32 (mingw/msvc) specific
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
-#else
-#define OUR_O_BINARY 0
-#endif
-// should be handled via configure
-#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
-#else
-#define OUR_O_LARGEFILE 0
-#endif
-
-gr_file_source::gr_file_source(size_t itemsize, const char *filename, bool repeat)
- : gr_sync_block("file_source",
- gr_make_io_signature (0, 0, 0),
- gr_make_io_signature (1, 1, itemsize)),
- d_itemsize(itemsize), d_fp(0), d_new_fp (0), d_repeat(repeat),
- d_updated(false)
-{
- open(filename, repeat);
-}
-
-// public constructor that returns a shared_ptr
-
-gr_file_source_sptr
-gr_make_file_source (size_t itemsize, const char *filename, bool repeat)
-{
- return gnuradio::get_initial_sptr(new gr_file_source (itemsize, filename, repeat));
-}
-
-gr_file_source::~gr_file_source ()
-{
- close();
- if(d_fp) {
- fclose(d_fp);
- d_fp = 0;
- }
-}
-
-int
-gr_file_source::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *o = (char *) output_items[0];
- int i;
- int size = noutput_items;
-
- do_update(); // update d_fp is reqd
- if(d_fp == NULL)
- throw std::runtime_error("work with file not open");
-
- gruel::scoped_lock lock(fp_mutex); // hold for the rest of this function
- while (size) {
- i = fread(o, d_itemsize, size, (FILE *) d_fp);
-
- size -= i;
- o += i * d_itemsize;
-
- if (size == 0) // done
- break;
-
- if (i > 0) // short read, try again
- continue;
-
- // We got a zero from fread. This is either EOF or error. In
- // any event, if we're in repeat mode, seek back to the beginning
- // of the file and try again, else break
-
- if (!d_repeat)
- break;
-
- if (fseek ((FILE *) d_fp, 0, SEEK_SET) == -1) {
- std::stringstream s;
- s << "[" << __FILE__ << "]" << " fseek failed" << std::endl;
- throw std::runtime_error(s.str());
- }
- }
-
- if (size > 0){ // EOF or error
- if (size == noutput_items) // we didn't read anything; say we're done
- return -1;
- return noutput_items - size; // else return partial result
- }
-
- return noutput_items;
-}
-
-bool
-gr_file_source::seek (long seek_point, int whence)
-{
- // obtain exclusive access for duration of this function
- gruel::scoped_lock lock(fp_mutex);
- return fseek((FILE *) d_fp, seek_point * d_itemsize, whence) == 0;
-}
-
-void
-gr_file_source::open(const char *filename, bool repeat)
-{
- // obtain exclusive access for duration of this function
- gruel::scoped_lock lock(fp_mutex);
-
- int fd;
-
- // we use "open" to use to the O_LARGEFILE flag
- if((fd = ::open(filename, O_RDONLY | OUR_O_LARGEFILE | OUR_O_BINARY)) < 0) {
- perror(filename);
- throw std::runtime_error("can't open file");
- }
-
- if(d_new_fp) {
- fclose(d_new_fp);
- d_new_fp = 0;
- }
-
- if((d_new_fp = fdopen (fd, "rb")) == NULL) {
- perror(filename);
- ::close(fd); // don't leak file descriptor if fdopen fails
- throw std::runtime_error("can't open file");
- }
-
- d_updated = true;
- d_repeat = repeat;
-}
-
-void
-gr_file_source::close()
-{
- // obtain exclusive access for duration of this function
- gruel::scoped_lock lock(fp_mutex);
-
- if(d_new_fp != NULL) {
- fclose(d_new_fp);
- d_new_fp = NULL;
- }
- d_updated = true;
-}
-
-void
-gr_file_source::do_update()
-{
- if(d_updated) {
- gruel::scoped_lock lock(fp_mutex); // hold while in scope
-
- if(d_fp)
- fclose(d_fp);
-
- d_fp = d_new_fp; // install new file pointer
- d_new_fp = 0;
- d_updated = false;
- }
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_source.h b/gnuradio-core/src/lib/io/gr_file_source.h
deleted file mode 100644
index 0478fba04b..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_source.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- 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 INCLUDED_GR_FILE_SOURCE_H
-#define INCLUDED_GR_FILE_SOURCE_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <boost/thread/mutex.hpp>
-
-class gr_file_source;
-typedef boost::shared_ptr<gr_file_source> gr_file_source_sptr;
-
-GR_CORE_API gr_file_source_sptr
-gr_make_file_source (size_t itemsize, const char *filename, bool repeat = false);
-
-/*!
- * \brief Read stream from file
- * \ingroup source_blk
- */
-
-class GR_CORE_API gr_file_source : public gr_sync_block
-{
- private:
- size_t d_itemsize;
- FILE *d_fp;
- FILE *d_new_fp;
- bool d_repeat;
- bool d_updated;
-
- protected:
- gr_file_source(size_t itemsize, const char *filename, bool repeat);
-
- void do_update();
-
- boost::mutex fp_mutex;
-
- public:
- /*!
- * \brief Create a file source.
- *
- * Opens \p filename as a source of items into a flowgraph. The data
- * is expected to be in binary format, item after item. The \p
- * itemsize of the block determines the conversion from bits to
- * items.
- *
- * If \p repeat is turned on, the file will repeat the file after
- * it's reached the end.
- *
- * \param itemsize the size of each item in the file, in bytes
- * \param filename name of the file to source from
- * \param repeat repeat file from start
- */
- friend GR_CORE_API gr_file_source_sptr
- gr_make_file_source(size_t itemsize,
- const char *filename,
- bool repeat);
-
- ~gr_file_source();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
- /*!
- * \brief Seek file to \p seek_point relative to \p whence
- *
- * \param seek_point sample offset in file
- * \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek)
- */
- bool seek(long seek_point, int whence);
-
- /*!
- * \brief Opens a new file.
- *
- * \param filename name of the file to source from
- * \param repeat repeat file from start
- */
- void open(const char *filename, bool repeat);
-
- /*!
- * \brief Close the file handle.
- */
- void close();
-
-};
-
-#endif /* INCLUDED_GR_FILE_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_source.i b/gnuradio-core/src/lib/io/gr_file_source.i
deleted file mode 100644
index e71cef0d14..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_source.i
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- 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.
- */
-
-
-%constant int SEEK_SET = 0; /* Seek from beginning of file. */
-%constant int SEEK_CUR = 1; /* Seek from current position. */
-%constant int SEEK_END = 2; /* Seek from end of file. */
-
-
-GR_SWIG_BLOCK_MAGIC(gr,file_source)
-
-gr_file_source_sptr
-gr_make_file_source (size_t itemsize, const char *filename, bool repeat=false);
-
-class gr_file_source : public gr_sync_block
-{
- protected:
- gr_file_source (size_t itemsize, const char *filename, bool repeat);
-
- public:
- ~gr_file_source ();
-
- bool seek (long seek_point, int whence);
- void open (const char *filename, bool repeat);
- void close();
-};
diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i
index b1fcde6d15..5cbb8620a3 100644
--- a/gnuradio-core/src/lib/io/io.i
+++ b/gnuradio-core/src/lib/io/io.i
@@ -26,10 +26,6 @@
#include "config.h"
#endif
-#include <gr_file_sink.h>
-#include <gr_file_source.h>
-#include <gr_file_descriptor_sink.h>
-#include <gr_file_descriptor_source.h>
#include <gr_histo_sink_f.h>
#include <microtune_4702_eval_board.h>
#include <microtune_4937_eval_board.h>
@@ -41,11 +37,6 @@
#include <gr_udp_source.h>
%}
-%include "gr_file_sink_base.i"
-%include "gr_file_sink.i"
-%include "gr_file_source.i"
-%include "gr_file_descriptor_sink.i"
-%include "gr_file_descriptor_source.i"
%include "gr_histo_sink.i"
%include "microtune_xxxx_eval_board.i"
%include "microtune_4702_eval_board.i"
diff --git a/gnuradio-core/src/lib/runtime/gr_top_block.h b/gnuradio-core/src/lib/runtime/gr_top_block.h
index cb99752f37..694e9575b4 100644
--- a/gnuradio-core/src/lib/runtime/gr_top_block.h
+++ b/gnuradio-core/src/lib/runtime/gr_top_block.h
@@ -83,7 +83,7 @@ public:
/*!
* Wait for a flowgraph to complete. Flowgraphs complete when
* either (1) all blocks indicate that they are done (typically only
- * when using gr.file_source, or gr.head, or (2) after stop() has been
+ * when using blocks.file_source, or gr.head, or (2) after stop() has been
* called to request shutdown. Calling wait on a top_block that is
* not running IS NOT an error (wait returns w/o blocking).
*/