[CCE]
[COPYING]
[DECIMALS]
+ [DIRECTORY]
+ [ENVIRONMENT]
[FORMAT]
[LENGTH]
[MXERRS]
[MXLOOPS]
[MXWARNS]
[SCOMPRESSION]
+ [TEMPDIR]
[UNDEFINED]
+ [VERSION]
[WARRANTY]
[WEIGHT]
[WIDTH]
Show all settings.
@item CC
Show all custom currency settings (CCA through CCE).
+@item DIRECTORY
+Shows the current working directory.
+@item ENVIRONMENT
+Shows the operating system details.
+@item TEMPDIR
+Shows the path of the directory where temporary files will be stored.
+@item VERSION
+Shows the version of this installation of PSPP.
@item WARRANTY
Show details of the lack of warranty for PSPP.
-@item COPYING
+@item COPYING / LICENSE
Display the terms of PSPP's copyright licence (@pxref{License}).
@end table
#include <errno.h>
#include <stdlib.h>
#include <time.h>
+#include <unistd.h>
#include "data/data-in.h"
#include "data/data-out.h"
#include "language/lexer/lexer.h"
#include "libpspp/compiler.h"
#include "libpspp/copyleft.h"
+#include "libpspp/temp-file.h"
+#include "libpspp/version.h"
#include "libpspp/float-format.h"
#include "libpspp/i18n.h"
#include "libpspp/integer-format.h"
return xasprintf ("%d", settings_get_viewwidth ());
}
+static char *
+show_current_directory (const struct dataset *ds UNUSED)
+{
+ char *buf = NULL;
+ char *wd = NULL;
+ size_t len = 256;
+
+ do
+ {
+ len <<= 1;
+ buf = xrealloc (buf, len);
+ }
+ while (NULL == (wd = getcwd (buf, len)));
+
+ return wd;
+}
+
+static char *
+show_tempdir (const struct dataset *ds UNUSED)
+{
+ return strdup (temp_dir_name ());
+}
+
+static char *
+show_version (const struct dataset *ds UNUSED)
+{
+ return strdup (version);
+}
+
+static char *
+show_system (const struct dataset *ds UNUSED)
+{
+ return strdup (host_system);
+}
+
struct show_sbc
{
const char *name;
{"CCD", show_ccd},
{"CCE", show_cce},
{"DECIMALS", show_decimals},
+ {"DIRECTORY", show_current_directory},
+ {"ENVIRONMENT", show_system},
{"ERRORS", show_errors},
{"FORMAT", show_format},
{"LENGTH", show_length},
{"RIB", show_rib},
{"RRB", show_rrb},
{"SCOMPRESSION", show_scompression},
+ {"TEMPDIR", show_tempdir},
{"UNDEFINED", show_undefined},
+ {"VERSION", show_version},
{"WEIGHT", show_weight},
{"WIB", show_wib},
{"WRB", show_wrb},
fputs (copyleft, stdout);
}
+
int
cmd_show (struct lexer *lexer, struct dataset *ds)
{
show_all_cc (ds);
else if (lex_match_id (lexer, "WARRANTY"))
show_warranty (ds);
- else if (lex_match_id (lexer, "COPYING"))
+ else if (lex_match_id (lexer, "COPYING") || lex_match_id (lexer, "LICENSE"))
show_copying (ds);
else if (lex_token (lexer) == T_ID)
{
*/
+static void cleanup (void);
static struct temp_dir *temp_dir;
struct hmapx map;
temp_dir = create_temp_dir ("pspp", NULL, true);
}
+static void
+initialise (void)
+{
+ if (temp_dir == NULL)
+ {
+ setup ();
+ if (temp_dir == NULL)
+ return ;
+ atexit (cleanup);
+ }
+}
+
+
+const char *
+temp_dir_name (void)
+{
+ initialise ();
+
+ if (temp_dir)
+ return temp_dir->dir_name;
+
+ return NULL;
+}
+
static void
cleanup (void)
{
char *file_name;
FILE *stream;
+ initialise ();
if (temp_dir == NULL)
- {
- setup ();
- if (temp_dir == NULL)
- return NULL;
- atexit (cleanup);
- }
+ return NULL;
file_name = xasprintf ("%s/%d", temp_dir->dir_name, idx++);
register_temp_file (temp_dir, file_name);