G:/ScriptBasic/source/commands/environ.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../command.h"

Go to the source code of this file.

Defines

#define MAX_ENVIRV_LEN   256

Functions

 if (memory_IsUndef(Op1))
 if (TYPE(Op1)==VTYPE_LONG)
 memcpy (STRINGVALUE(RESULT), s, sLen)
 if (pEo->CmdLineArgument==NULL)
 memcpy (STRINGVALUE(RESULT), pEo->CmdLineArgument, q)

Variables

char ** _environ
NODE nItem
VARIABLE Op1
char * s
char buffer [MAX_ENVIRV_LEN]
size_t sLen
char ** EnvironmentPointer
long index
char *(* EnvirFunc )(void *, char *, long)
 USE_CALLER_MORTALS
 nItem = PARAMETERLIST
 Op1 = _EVALUATEEXPRESSION(CAR(nItem))
 ASSERTOKE
 EnvirFunc = pEo->fpEnvirFunction
 RESULT = NEWMORTALSTRING(sLen)
END int q
 USE_CALLER_MORTALS
 RESULT = NEWMORTALSTRING(q=strlen(pEo->CmdLineArgument))


Define Documentation

#define MAX_ENVIRV_LEN   256
 

Definition at line 76 of file environ.c.


Function Documentation

if pEo->  CmdLineArgument = NULL  ) 
 

Definition at line 161 of file environ.c.

References NULL, and RETURN.

if TYPE(Op1 = = VTYPE_LONG  ) 
 

Definition at line 96 of file environ.c.

References _environ, EnvirFunc, LONGVALUE(), NULL, pEo, RESULT, and RETURN.

if memory_IsUndef(Op1  ) 
 

Definition at line 90 of file environ.c.

References NULL, RESULT, and RETURN.

Referenced by allocset(), besFUNCTION(), p_b_cclass(), p_b_coll_elem(), regatoi(), and regerror().

memcpy STRINGVALUE(RESULT ,
pEo->  CmdLineArgument,
q 
 

memcpy STRINGVALUE(RESULT ,
s  ,
sLen 
 

Referenced by _GetData(), AllocFileName(), AllocUserFunction(), app(), basext_GetArgsF(), besFUNCTION(), buffercollect(), build_GetExeCodeOffset(), build_MagicCode(), build_SaveECode(), build_StringIndex(), cgi_FillSymbolAndFile(), cgi_GetGetParameters(), cgi_GetMultipartParameters(), cgi_GetPostParameters(), cgi_ResizeBuffer(), cgi_ResizeThisBuffer(), CHECK_OPTION(), collect_dirs(), CreateJunction(), dupl(), dynlolib_GetFunctionByName(), ex_IsCommandThis(), ex_Tag(), execute_Convert2String(), execute_CopyCommandTable(), execute_Evaluate(), fork(), GuardThread(), handle_GetHandle(), HitHandler(), if(), lex_StoreCharacter(), main(), match_InitSets(), memory_CopyArray(), memory_DupVar(), modu_UnloadAllModules(), modu_UnloadModule(), printChar(), ReadFileLine(), ReadSocketLine(), scriba_CallArg(), scriba_CallArgEx(), scriba_InheritBinaryProgram(), scriba_NewSbArgs(), scriba_NewSbBytes(), scriba_NewSbString(), scriba_SetVariable(), serconv(), storech(), switch(), unserconv(), and while().


Variable Documentation

char** _environ
 

Definition at line 95 of file stndlone.c.

Referenced by if().

ASSERTOKE
 

Definition at line 88 of file environ.c.

Referenced by COMMAND_EXTERNAL(), COMMAND_FUNCTIONARG(), if(), and while().

char buffer[MAX_ENVIRV_LEN]
 

Definition at line 77 of file environ.c.

Referenced by _State(), execute_Convert2String(), and file_deltree().

EnvirFunc = pEo->fpEnvirFunction
 

Definition at line 95 of file environ.c.

char*(* EnvirFunc)(void *, char *, long)
 

Definition at line 81 of file environ.c.

Referenced by if().

char** EnvironmentPointer
 

Definition at line 79 of file environ.c.

long index
 

Definition at line 80 of file environ.c.

Referenced by getoptt(), JokerMatch(), match_ModifySet(), match_parameter(), match_size(), MD5Final(), and MD5Update().

nItem = PARAMETERLIST
 

Definition at line 86 of file environ.c.

NODE nItem
 

ENVIRON =section misc =title ENVIRON("envsymbol") or ENVIRON(n) =display ENVIRON()

This function returns the value of an environment variable. Environment variables are string values associated to names that are provided by the executing environment for the programs. The executing environment is usually the operating system, but it can also be the Web server in CGI programs that alters the environment variables provided by the surrounding operating system specifying extra values.

This function can be used to get the string of an environment variable in case the program knows the name of the variable or to list all the environment variables one by one.

If the environment variable name is known then the name as a string has to be passed to this function as argument. In this case the return value is the value of the environment variable.

If the program wants to list all the environment variables the argument to the function T<ENVIRON> can be an integer number T<n>. In this case the function returns a string containing the name and the value joined by a T<=> sign of the T<n>-th environment variable. The numbering starts with T<n=0>.

If the argument value is integer and is out of the range of the possible environment variable ordinal numbers (negative or larger or equal to the number of the available environment variables) then the function returns T<undef>.

If the argument to the function is T<undef> then the function also returns the T<undef> value.

Note that ScriptBasic provides an easy way for the embedding applications to redefine the underlying function that returns the environment variable. Thus an embedding application can "fool" a BASIC program providing its own environment variable. For example the Eszter SB Application Engine provides an alternative environment variable reading function and thus BASIC applications can read the environment using the function T<ENVIRON> as if the program was running in a real CGI environment.

=details

The following sample code prints all environment variables:

=verbatim i=0 do e$ = environ(i) if IsDefined(e$) then print e$ print endif i = i + 1 loop while IsDefined(e$) =noverbatim

Definition at line 74 of file environ.c.

Referenced by COMMAND_EXTERNAL(), COMMAND_FUNCTIONARG(), execute_ExecuteFunction(), and hook_CallScribaFunction().

Op1 = _EVALUATEEXPRESSION(CAR(nItem))
 

Definition at line 87 of file environ.c.

VARIABLE Op1
 

Definition at line 75 of file environ.c.

Referenced by if().

END int q
 

COMMANDF =section misc =title COMMAND() =display COMMAND()

This function returns the command line arguments of the program in a single string. This does not include the name of the interpreter and the name of the BASIC program, only the arguments that are to be passed to the BASIC program. For example the program started as

=verbatim # scriba test_command.sb arg1 arg2 arg3 =noverbatim

will see T<"arg1 arg2 arg3"> string as the return value of the function T<COMMAND()>.

Definition at line 156 of file environ.c.

Referenced by __InsertImage(), __RemoveImage(), _ex_PopLabel(), _ex_pprint(), _GetData(), alloc_Merge(), besFUNCTION(), besVERSION_NEGOTIATE(), build_Build_r(), c_char_code(), c_char_downcase(), c_char_upcase(), c_code_char(), c_nth(), c_nthcdr(), c_readlist(), cft_ReadTextConfig(), epreproc(), ex_Expression_i(), ex_ExpressionList(), ex_IsCommandCALL(), ex_IsCommandOPEN(), ex_LeftValue(), ex_LeftValueList(), ex_pprint(), ex_Tag(), handle_DestroyHandleArray(), handle_FreeHandle(), handle_GetHandle(), handle_GetPointer(), lex_RemoveComments(), main(), memory_ReleaseVariable(), reader_IncreaseBuffer(), reader_RelateFile(), release_list(), scriba_GetCacheFileName(), and StringClose().

RESULT = NEWMORTALSTRING(q=strlen(pEo->CmdLineArgument))
 

Definition at line 166 of file environ.c.

RESULT = NEWMORTALSTRING(sLen)
 

Definition at line 131 of file environ.c.

Referenced by besCOMMAND(), besFUNCTION(), and if().

char* s
 

Definition at line 77 of file environ.c.

Referenced by __pprint(), _GetParam(), AppInit(), AppStart(), basext_GetArgsF(), build_MagicCode(), build_SaveCCode(), cft_GetConfigFileName(), cgi_FillSymbolAndFile(), cgi_GetGetParameters(), cgi_GetMultipartParameters(), cgi_GetPostParameters(), cgi_ReadHttpRequest(), cgi_ResizeBuffer(), cgi_ResizeThisBuffer(), DeleteFromPath(), DeleteFromPathEx(), doinsert(), DumpTree(), dynlolib_LoadLibrary(), epreproc(), ex_IsSymbolValidLval(), ex_Tag(), execute_Convert2Double(), execute_Convert2Long(), execute_Evaluate(), execute_GetDoubleValue(), execute_GetLongValue(), execute_IsStringInteger(), file_deltree(), file_MakeDirectory(), file_mkdir(), file_remove(), file_rmdir(), findmust(), ftp_report(), FtpProc(), GetExtensionVersion(), HandleHttpHit(), httpd_report(), HttpExtensionProc(), HttpProc(), if(), InstallScriptBasic(), ipreproc_LoadInternalPreprocessor(), lex_ReadInput(), lex_StoreCharacter(), main(), match_parameter(), modu_LoadModule(), modu_Preload(), MyFiles(), MyInput(), pfEnv(), pluscount(), prepare_directory(), reader_IncreaseBuffer(), reader_LoadPreprocessors(), reader_ProcessIncludeFiles(), reader_RelateFile(), ReadFileLine(), ReadSocketLine(), regerror(), scriba_CallArg(), scriba_GetCacheFileName(), scriba_NewSbArgs(), SPrintVarByName(), and SPrintVariable().

size_t sLen
 

Definition at line 78 of file environ.c.

Referenced by ex_IsCommandOPEN(), ex_IsCommandThis(), execute_Convert2Double(), execute_Convert2Long(), execute_GetDoubleValue(), execute_GetLongValue(), execute_IsStringInteger(), and while().

USE_CALLER_MORTALS
 

Definition at line 159 of file environ.c.

USE_CALLER_MORTALS
 

Definition at line 83 of file environ.c.


Generated on Sun Mar 12 23:56:32 2006 for ScriptBasic by  doxygen 1.4.6-NO