<commit_before>/*****************************************************************************

The source code of the Parasol project is made publicly available under the
terms described in the LICENSE.TXT file that is distributed with this package.
Please refer to it for further information on licensing.

******************************************************************************

This version of the Parasol launcher is intended for use from the command-line
only.

*****************************************************************************/

#include <parasol/main.h>
#include <startup.h>
#include <parasol/modules/core.h>
#include <string.h>

#include "common.h"

CSTRING ProgName      = "Parasol";
CSTRING ProgAuthor    = "<NAME>";
CSTRING ProgDate      = "April 2017";
CSTRING ProgCopyright = "Copyright <NAME> © 2000-2017";
LONG   ProgDebug = 0;
FLOAT  ProgCoreVersion = VER_CORE;

extern struct CoreBase *CoreBase;

static OBJECTID glTargetID = 0;
static OBJECTID glSystemPointerID;
static CSTRING *glArgs = NULL;
static STRING glAllow = NULL;
static BYTE glSandbox = FALSE;
static BYTE glRelaunched = FALSE;
static OBJECTPTR glTask = NULL;
static OBJECTPTR glScript = NULL;
static BYTE glTime = FALSE;
static LONG glWinHandle = 0;
static STRING glProcedure = NULL;
static STRING glTargetFile = NULL;
static LONG glWidth = 0;
static LONG glHeight = 0;

static ERROR prep_environment(LONG, LONG, LONG);
static ERROR exec_source(CSTRING, LONG, CSTRING);

static const char glHelp[] = {
"This command-line program can execute scripts and PARC files developed for the Parasol framework.  The\n\
Fluid scripting language (.fluid files) are supported in the default distribution.  Quick start:\n\
\n\
   parasol-cmd [args] [script.ext] arg1 arg2 ...\n\
\n\
The following parameters can be used when executing script files:\n\
\n\
 --procedure [n] The name of a procedure to execute.\n\
 --target    [n] The name of an existing object that the script will target for hosting.  Used in multi-tasking\n\
                 environments.\n\
 --program       Treat the script like a program.  The process will enter message handling mode if execution succeeds.\n\
 --time          Print the amount of time that it took to execute the program.\n\
 --sandbox       Applies the PARC sand-boxing feature when executing scripts.\n\
 --allow         For sand-boxed execution, specifies additional access rights and limitations.\n\
\n\
 --debug         Activates run-time debug messages.\n\
 --errors        Activates run-time error messages.\n"
};

//****************************************************************************

#include "exec.cpp"

//****************************************************************************
// Process arguments

static ERROR process_args(void)
{
   CSTRING *args;
   LONG i, j;

   if ((!GetPointer(glTask, FID_Parameters, &args)) AND (args)) {
      for (i=0; args[i]; i++) {
         if (!StrMatch(args[i], "--help")) {
            // Print help for the user
            print(glHelp);
            return ERR_Terminate;
         }
         else if (!StrMatch(args[i], "--verify")) {
            // Special internal function that checks that the installation is valid, returning 1 if checks pass.

            static CSTRING modules[] = { // These modules must be present for an installation to be valid.
               "display", "document", "fluid", "font", "http", "jpeg", "json", "network", "parc",
               "picture", "surface", "svg", "vector", "widget", "window", "xml"<commit_msg>Corrected --debug and --errors parameter references in parasol-cmd help.<commit_after>/*****************************************************************************

The source code of the Parasol project is made publicly available under the
terms described in the LICENSE.TXT file that is distributed with this package.
Please refer to it for further information on licensing.

******************************************************************************

This version of the Parasol launcher is intended for use from the command-line
only.

*****************************************************************************/

#include <parasol/main.h>
#include <startup.h>
#include <parasol/modules/core.h>
#include <string.h>

#include "common.h"

CSTRING ProgName      = "Parasol";
CSTRING ProgAuthor    = "<NAME>";
CSTRING ProgDate      = "April 2017";
CSTRING ProgCopyright = "Copyright <NAME> © 2000-2017";
LONG   ProgDebug = 0;
FLOAT  ProgCoreVersion = VER_CORE;

extern struct CoreBase *CoreBase;

static OBJECTID glTargetID = 0;
static OBJECTID glSystemPointerID;
static CSTRING *glArgs = NULL;
static STRING glAllow = NULL;
static BYTE glSandbox = FALSE;
static BYTE glRelaunched = FALSE;
static OBJECTPTR glTask = NULL;
static OBJECTPTR glScript = NULL;
static BYTE glTime = FALSE;
static LONG glWinHandle = 0;
static STRING glProcedure = NULL;
static STRING glTargetFile = NULL;
static LONG glWidth = 0;
static LONG glHeight = 0;

static ERROR prep_environment(LONG, LONG, LONG);
static ERROR exec_source(CSTRING, LONG, CSTRING);

static const char glHelp[] = {
"This command-line program can execute scripts and PARC files developed for the Parasol framework.  The\n\
Fluid scripting language (.fluid files) are supported in the default distribution.  Quick start:\n\
\n\
   parasol-cmd [args] [script.ext] arg1 arg2 ...\n\
\n\
The following parameters can be used when executing script files:\n\
\n\
 --procedure [n] The name of a procedure to execute.\n\
 --target    [n] The name of an existing object that the script will target for hosting.  Used in multi-tasking\n\
                 environments.\n\
 --program       Treat the script like a program.  The process will enter message handling mode if execution succeeds.\n\
 --time          Print the amount of time that it took to execute the program.\n\
 --sandbox       Applies the PARC sand-boxing feature when executing scripts.\n\
 --allow         For sand-boxed execution, specifies additional access rights and limitations.\n\
\n\
 --log-info      Activates run-time log messages at INFO level.\n\
 --log-error     Activates run-time log messages at ERROR level.\n"
};

//****************************************************************************

#include "exec.cpp"

//****************************************************************************
// Process arguments

static ERROR process_args(void)
{
   CSTRING *args;
   LONG i, j;

   if ((!GetPointer(glTask, FID_Parameters, &args)) AND (args)) {
      for (i=0; args[i]; i++) {
         if (!StrMatch(args[i], "--help")) {
            // Print help for the user
            print(glHelp);
            return ERR_Terminate;
         }
         else if (!StrMatch(args[i], "--verify")) {
            // Special internal function that checks that the installation is valid, returning 1 if checks pass.

            static CSTRING modules[] = { // These modules must be present for an installation to be valid.
               "display", "document", "fluid", "font", "http", "jpeg", "json", "network", "parc",
               "picture", "surface", "svg", "vector", "widget", "window", "xml"
{'fraction_non_alphanumeric': 0.19921656407386681, 'fraction_numerical': 0.0058757694459988805, 'mean_word_length': 3.6512687052700064, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1336138', 'n_tokens_mistral': 1960, 'n_tokens_neox': 1842, 'n_words': 755}