7e582cb4af03c0c80a359948ead1441d41631faa
[pspp-builds.git] / src / language / utilities / echo.c
1 /* PSPP - computes sample statistics. -*-c-*-
2
3    Copyright (C) 2005 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #include <config.h>
21 #include <libpspp/message.h>
22 #include <libpspp/alloc.h>
23 #include <libpspp/str.h>
24 #include <language/lexer/lexer.h>
25 #include <language/command.h>
26 #include <output/table.h>
27 #include <output/manager.h>
28
29 /* Echos a string to the output stream */
30 int
31 cmd_echo (struct lexer *lexer, struct dataset *ds UNUSED)
32 {
33   struct tab_table *tab;
34
35   if (lex_token (lexer) != T_STRING)
36     return CMD_FAILURE;
37
38   tab = tab_create(1, 1, 0);
39
40   tab_dim (tab, tab_natural_dimensions);
41   tab_flags (tab, SOMF_NO_TITLE );
42
43   tab_text(tab, 0, 0, 0, ds_cstr (lex_tokstr (lexer)));
44
45   tab_submit(tab);
46
47   return CMD_SUCCESS;
48 }