This library contains functions to read information from the program environment (such as the GEM desktop and similar applications), or to write them; in addition they can take on the launch of other GEM programs. The following routines are available for this:
• shel_envrn | Obtains value of environment variable |
• shel_find | Searches for a file |
• shel_get | Reads from the environment buffer |
• shel_help | Outputs Help-texts |
• shel_put | Writes to the environment buffer |
• shel_rdef | Inquires the default program |
• shel_read | Reads command line parameters |
• shel_wdef | Sets the default program |
• shel_write | Launches application |
• x_shel_get | Read information from GENEVA.CNF |
• x_shel_put | Write information to GENEVA.CNF |
Note: Here special merit has been earned by shel_write, which as of AES Version 4.0 (or MagiC 3) has made many other useful things available, such as Shutdown of the system, resolution changes, AES broadcasting etc.
See also: About the AES Style guidelines
Name: | »Shell environment« - Obtains value of environmental
variables.
| ||||||||
Opcode: | 125
| ||||||||
Syntax: | int16_t shel_envrn ( int8_t **sh_epvalue, int8_t *sh_eparm );
| ||||||||
Description: | The call shel_envrn searches the current environment string to
find the value of a specific environmental variable of the AES. The
following apply:
Example: If the current environment is, say: 'PATH=C:\;D:\;E:\' then calling shel_envrn with sh_eparm pointing to the string 'PATH=' would set the pointer pointed to by sh_epvalue to the start of the string 'C:\;D:\;E:\'. Note that the character string pointed to by sh_eparm should include the name of the variable and the 'equals' sign. Note: To change the AES environment, one should hook into the exec_os vector, which is also used to launch GEM. In the called routine, the basepage pointer lies on the stack (as in a program). In this basepage one can then simply enter a pointer to the new environment. But a word of warning: In AES versions lower than 1.4, only the first 50 bytes will be adopted; also these only accept semicolons as separators between multiple 'PATH=' arguments, while later versions accept commas as well. Another tip: If the pointer returned for 'PATH=' points to a NULLbyte, one should increase it by the value 1 to get the correct result. | ||||||||
Return value: | The function always returns a value of 1.
| ||||||||
Availability: | All AES versions.
| ||||||||
Group: | Shell library
| ||||||||
See also: | Binding
|
C: | int16_t shel_envrn ( int8_t **sh_epvalue, int8_t *sh_eparm );
| |||||||||||||||||||||||||||
Binding: |
int16_t shel_envrn (int8_t **sh_epvalue, int8_t *sh_eparm) { addr_in[0] = sh_epvalue; addr_in[1] = sh_eparm; return ( crys_if(125) ); } | |||||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell find« - Find a file.
|
Opcode: | 124
|
Syntax: | int16_t shel_find ( int8_t *sh_fpbuff );
|
Description: | The call shel_find searches for a file in certain directories.
The parameter sh_fpbuff contains the name of the file searched
for. On returning from the call, the full access path to the file will
be stored in this buffer, which should be at least 128 characters
long.
Note: The file will be searched for in the following directories:
The function is also used by rsrc_load to localize the resource file. |
Return value: | A value of 0 signals that the specified file was not found.
|
Availability: | All AES versions.
|
Group: | Shell library
|
See also: | Binding shel_envrn
|
C: | int16_t shel_find ( int8_t *sh_fpbuff );
| ||||||||||||||||||||||||
Binding: |
int16_t shel_find (int8_t *sh_fpbuff) { addr_in[0] = sh_fpbuff; return ( crys_if(124) ); } | ||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell get« - Read from the GEM environment buffer.
| ||||||||
Opcode: | 122
| ||||||||
Syntax: | int16_t shel_get ( int8_t *sh_gaddr, uint16_t sh_glen );
| ||||||||
Description: | The call shel_get serves for reading characters from the
internal environment storage buffer of the AES. The following
apply:
Note: The desktop uses this buffer to store the DESKTOP.INF or NEWDESK.INF file. Although the format of these files is not officially documented, a current description can be found in newdesk.hyp. Under MagiC, at the start of the AES all data are copied into the buffer that lies after the line '#_CTR' in MAGX.INF. Since MagiC 3, the permissible length of the buffer lies between 4192 and 65534 bytes. The presence of the additional features can be ascertained with a call of appl_getinfo (opcode 6). | ||||||||
Return value: | An error has arisen only if the value 0 is returned.
| ||||||||
Availability: | All AES versions.
| ||||||||
Group: | Shell library
| ||||||||
See also: | Binding shel_put
|
C: | int16_t shel_get ( int8_t *sh_gaddr, uint16_t sh_glen );
| |||||||||||||||||||||||||||
Binding: |
int16_t shel_get (int8_t *sh_gaddr, uint16_t sh_glen) { int_in[0] = sh_glen; addr_in[0] = sh_gaddr; return ( crys_if(122) ); } | |||||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell help« - Output of Help-texts.
|
Opcode: | 128
|
Syntax: | int16_t shel_help ( int16_t sh_hmode, int8_t *sh_hfile, int8_t
*sh_hkey);
|
Description: | The call shel_help serves for outputting Help-texts (online
help) via a help server.
At a call of shel_help with a file having an extension, N.AES checks whether a help server for this extension has been defined (with 'helpserver'). If a suitable server is found, a check is made whether this is active already (as a desk accessory or application launched in parallel). If that is the case, then the server is sent the message VA_START with the arguments specified in sh_hfile and sh_hkey as a command line. If the server is not active, then it will be launched automatically if a path was specified for it in its definition with 'helpserver'. As a command line the arguments specified in sh_hfile and sh_hkey will be passed. |
Return value: | An error has arisen only if the value 0 is returned.
|
Availability: | The presence of this function can be ascertained with a call of
appl_getinfo (opcode 65).
Besides N.AES, there is a TSR which makes this function available on other systems as well. |
Group: | Shell library
|
See also: | Binding
|
C: | int16_t shel_help ( int16_t sh_hmode, int8_t *sh_hfile, int8_t
*sh_hkey);
| ||||||||||||||||||||||||||||||
Binding: |
int16_t shel_help ( int16_t sh_hmode, int8_t *sh_hfile, int8_t *sh_hkey) { int_in[0] = sh_hmode; addr_in[0] = sh_hfile; addr_in[1] = sh_hkey; crys_if(128); return = int_out[0]; } | ||||||||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell put« - Writes to the GEM environment buffer.
| ||||||
Opcode: | 123
| ||||||
Syntax: | int16_t shel_put ( int8_t *sh_paddr, uint16_t sh_plen );
| ||||||
Description: | The call shel_put copies information to the environment shell
buffer of the AES. The following apply:
Note: The desktop uses this buffer to store the DESKTOP.INF or NEWDESK.INF file. Although the format of these files is not officially documented, a current description can be found in newdesk.hyp. The permissible length of the buffer lies since MagiC 3 between 4192 and 65534 bytes, while in very old TOS versions it was restricted to 1024 bytes. Prior to AES version 4.0 this function would only copy as many bytes as would fit into the current buffer. As of version 4.0, the AES will dynamically allocate more memory as needed (up to 32767 bytes) for the shell buffer. | ||||||
Return value: | An error has arisen only if the value 0 is returned.
| ||||||
Availability: | All AES versions.
| ||||||
Group: | Shell library
| ||||||
See also: | Binding shel_get shel_envrn shel_find
|
C: | int16_t shel_put ( int8_t *sh_paddr, uint16_t sh_plen );
| |||||||||||||||||||||||||||
Binding: |
int16_t shel_put (int8_t *sh_paddr, uint16_t sh_plen) { int_in[0] = sh_plen; addr_in[0] = sh_paddr; return ( crys_if(123) ); } | |||||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell read default« - Inquire the default program.
| ||||||
Opcode: | 126
| ||||||
Syntax: | void shel_rdef ( int8_t *lpcmd, int8_t *lpdir );
| ||||||
Description: | The call shel_rdef permits inquiring the program to be launched
at the termination of the current one (the desktop, as a rule). The
following apply:
| ||||||
Return value: | The function does not return a result.
The binding form N.AES have a return value. If successful it return 1, otherwise 0. | ||||||
Availability: | Under PC-GEM, the function is available as of version 2.0;
otherwise in KAOS 1.4.2, MagiC and N.AES. The presence of this
function can be ascertained with appl_getinfo (opcode 5).
| ||||||
Group: | Shell library
| ||||||
See also: | Binding shel_wdef MagiC
|
C: | void shel_rdef ( int8_t *lpcmd, int8_t *lpdir );
| ||||||||||||||||||||||||
Binding: |
int16_t shel_rdef (int8_t *lpcmd, int8_t *lpdir) { addr_in[0] = lpcmd; addr_in[1] = lpdir; crys_if(126); } | ||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell read« - Read command line parameters of the
application.
| ||||||||
Opcode: | 120
| ||||||||
Syntax: | int16_t shel_read ( int8_t *sh_rpcmd, int8_t *sh_rptail );
| ||||||||
Description: | The call shel_read obtains the name and the command line tail
with which an application was launched. The following apply:
Note: The function only works correctly if the application was launched with shel_write. In case of doubt, therefore, one should fall back to the values from the basepage. | ||||||||
Return value: | An error has arisen only if the value 0 is returned.
| ||||||||
Availability: | All AES versions.
| ||||||||
Group: | Shell library
| ||||||||
See also: | Binding shel_write Pexec
|
C: | int16_t shel_read ( int8_t *sh_rpcmd, int8_t *sh_rptail );
| |||||||||||||||||||||||||||
Binding: |
int16_t shel_read (int8_t *sh_rpcmd, int8_t *sh_rptail) { addr_in[0] = sh_rpcmd; addr_in[1] = sh_rptail; return ( crys_if(120) ); } | |||||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell write default« - Set the default program.
|
Opcode: | 127
|
Syntax: | void shel_wdef( int8_t *lpcmd, int8_t *lpdir );
|
Description: | The call shel_wdef allows setting the application that is to be
regarded as the default program (normally the desktop).
Note for MagiC: If the parameters lpcmd and lpdir are empty strings, then MAGXDESK will be reinstalled. An alternative desktop simply makes a shel_write call at launch, and then terminates itself with Pterm0; it receives from MagiC a command line (SHELTAIL), which can be obtained with shel_read. If the shell returns a negative error-code, then MAGXDESK will be activated. Note for N.AES: If the parameters lpcmd and/or lpdir are empty strings or NULL, then the 'shell' application specified in N_AES.CNF will be launched. |
Return value: | The function does not return a result.
The binding form N.AES have a return value, which is always 1. |
Availability: | Under PC-GEM, the function is available as of version 2.0;
otherwise in KAOS 1.4.2, MagiC and N.AES. The presence of this
function can be ascertained with appl_getinfo (opcode 5).
|
Group: | Shell library
|
See also: | Binding shel_rdef MagiC
|
C: | void shel_wdef( int8_t *lpcmd, int8_t *lpdir );
| ||||||||||||||||||||||||
Binding: |
void shel_wdef(int8_t *lpcmd, int8_t *lpdir) { addr_in[0] = lpcmd; addr_in[1] = lpdir; crys_if(127); } | ||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell write« - Launch another application.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Opcode: | 121
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Syntax: | int16_t shel_write ( int16_t sh_wdoex, int16_t sh_wisgr,
int16_t sh_wiscr, int8_t *sh_wpcmd, int8_t *sh_wptail );
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description: | The call shel_write permits launching another program. As of
AES version 4.0 this function was expanded greatly, so now one can
also perform tasks such as the Shutdown of the system, changing screen
resolution, AES broadcasting and a number of other functions.
The parameter sh_wdoex determines the action to be performed, the remaining parameters depend in essence on sh_wdoex. The following apply:
In the parameters sh_wpcmd and sh_wptail one should pass the filename of the program to be launched and a pointer to the command line tail respectively. The default directory will be chosen as the directory that contains the program to be launched (Exception: extended mode with bit 10 set - see below). The function returns the AES ID of the launched process. A value of 0 in this connection denotes that an error has occurred. With the parameter sh_wiscr one can specify whether parameters via ARGV should be passed to the launched program. The following apply: sh_wiscr = 0: Do not use ARGV procedure sh_wiscr = 1: Use ARGV procedure Under MagiC, on the other hand, one can specify whether a program is to be started in single-mode (or in parallel). The following apply: sh_wiscr = 100: Execute program in parallel The new application inherits all standard paths and files from the current application. An error-code is returned only in case of memory shortage during the installation; a notification at the termination of the new application (death-of-child) does not exist (*). sh_wiscr = 101: Execute program in single-mode This mode corresponds to sh_wiscr with the value 1, except that before the program is called all applications apart from those with ID 0 and ID 1 (SCRENMGR) are frozen. Those applications will be thawed out again at the termination of the program, as long as that does not make a new shel_write call of a single-mode character. The exact recipe for the single-mode is:
One should also note that as of MagiC 2, in single-mode the current paths of the caller are passed to the parent and with that to the new program. The caller's paths are destroyed subsequently, though this is not critical as the program will normally follow shel_write with a Pterm call (*). In extended mode one can further specify the launching of programs via the special bits of the parameter sh_wdoex. The low byte stays untouched here, and for the high byte the following apply:
In this extended mode, the parameter sh_wpcmd is taken as a pointer to a SHELW structure. Each of the above-named bits is assigned a member of that structure which is valid when the corresponding bit is set. The set of values is allocated as follows:
Note: The elements [1], [2] and [3] are ignored up to MagiC 3; element [1] however is supported from MagiC 4 onwards. The default directory is set much simpler under MagiC, as the new program inherits all paths on all drives from the calling program. Geneva can only set bit 8. Note: In MagiC 6, the user id and group id fields have a different meaning. In newer AES versions the following additional modes are available:
Note: As of MagiC 3, the following specialities are available:
The presence of the additional features can be inquired with appl_getinfo (opcode 10). The shel_write opcodes marked with (*) are at present available only in MagiC. Warning: If one launches a new AES process under Single- TOS with shel_write, then this will be launched only after the termination of the running process. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Return value: | An error has arisen only if the value 0 is returned.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Availability: | All AES versions.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Group: | Shell library
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
See also: | Binding Shutdown mechanism Threads in MagiC
|
C: | int16_t shel_write ( int16_t sh_wdoex, int16_t sh_wisgr,
int16_t sh_wiscr, int8_t *sh_wpcmd, int8_t *sh_wptail );
| ||||||||||||||||||||||||||||||||||||
Binding: |
int16_t shel_write (int16_t sh_wdoex, int16_t sh_wisgr, int16_t sh_wiscr, int8_t *sh_wpcmd, int8_t *sh_wptail) { int_in[0] = sh_wdoex; int_in[1] = sh_wisgr; int_in[2] = sh_wiscr; addr_in[0] = sh_wpcmd; addr_in[1] = sh_wptail; return ( crys_if(121) ); } | ||||||||||||||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell get« - Read information from GENEVA.CNF.
| ||||||||||
Opcode: | 29057
| ||||||||||
Syntax: | int16_t x_shel_get ( int16_t mode, int16_t length, int8_t *buf
);
| ||||||||||
Description: |
This function will cause Geneva to either re-read all of its own internal settings, or read the settings from an outside program's portion of GENEVA.CNF. When mode is X_SHLOADSAVE (-1), Geneva will re-read all of its internal settings. The length and buf parameters are not used in this mode. The Task Manager's "Load Settings" option uses this. In order to read its own settings, a program must begin by using mode X_SHOPEN (0) to open GENEVA.CNF. The name passed in buf can contain any character (including uppercase and punctuation) except the [ or ] characters. The length parameter is not used in this mode. If the X_SHOPEN was successful, the program can then make repeated calls using the X_SHACCESS (1) mode. Here, length specifies the maximum number of bytes to read into the string buffer buf. The x_sscanf function is very helpful for retreiving formatted data that has been read with x_shel_get. If an error occurs at any time during the open or read phases (or if the program's section of GENEVA.CNF ends), the file is automatically closed. If a program wants to end the reading sooner, it must use mode X_SHCLOSE (2) to close the file. Otherwise, any future attempts to read from the file will fail. Example: int sh_error( int err ) { switch(err) { case -2: Cconws( "Disk error" ); return 1; case -1: Cconws( "GENEVA.CNF is already in use by another program" ); return 1; case 0: Cconws( "Read failed unexpectedly" ); return 1; default: return 0; } } main() { char buffer[100]; int version, number1, number2; if( !sh_error( x_shel_get(X_SHOPEN,0,"My Program") ) ) if( !sh_error( x_shel_get(X_SHACCESS,sizeof(buffer),buffer) ) ) { x_sscanf( buffer, "%v", &version ); if( version != 0x200 ) { Cconws( "Not compatible with version 2.0!" ); x_shel_get( X_SHCLOSE, 0, 0L ); return; } if( !sh_error( x_shel_get(X_SHACCESS,sizeof(buffer), buffer) ) ) x_sscanf( buffer, "%x %d", number1, number2 ); x_shel_get( X_SHCLOSE, 0, 0L ); } } | ||||||||||
Return value: |
| ||||||||||
Availability: | The function is only available under Geneva.
| ||||||||||
Group: | Shell library
| ||||||||||
See also: | Binding
|
C: | int16_t x_shel_get ( int16_t mode, int16_t length, int8_t *buf
);
| ||||||||||||||||||||||||||||||
Binding: |
int16_t x_shel_get ( int16_t mode, int16_t length, int8_t *buf ) { int_in[0] = mode; int_in[1] = length; addr_in[0] = buf; crys_if(29057); return ( int_out[0] ); } | ||||||||||||||||||||||||||||||
GEM-Arrays: |
|
Name: | »Shell put« - Save a program's own settings, or Geneva's
settings, to GENEVA.CNF.
| ||||||||||||||||
Opcode: | 29058
| ||||||||||||||||
Syntax: | int16_t x_shel_put ( int16_t mode, int8_t *buf );
| ||||||||||||||||
Description: |
When mode is X_SHLOADSAVE (-1), Geneva will save all of its internal settings. The length and buf parameters are not used in this mode. The Task Manager's Save Settings option uses this. In order to save its own settings, a program must begin by using mode X_SHOPEN (0) to open GENEVA.CNF. The name passed in buf can contain any character (including uppercase and punctuation) except the [ or ] characterli The length parameter is not used in this mode. If the X_SHOPEN was successful, the program can then make repeated calls using the X_SHACCESS (1) mode. Here, buf points to a null-terminated string to write. The string should be no more than 80 characters of readable text, and must not include the [ or ] characters. If the firss character of the string is a semi-colon ";", it will be treated as a comment when read by x_shel_get. The x_sprintf function is very helpful for formatting data for x_shel_put; If an error occurs at any time during the open or write phases the file is automatically closed. If no errors occur, the program must use mode X_SHCLOSE (2) to close the file. Otherwise, any future attempts to write to the file will fail. | ||||||||||||||||
Return value: |
| ||||||||||||||||
Availability: | The function is only available under Geneva.
| ||||||||||||||||
Group: | Shell library
| ||||||||||||||||
See also: | Binding
|
C: | int16_t x_shel_put ( int16_t mode, int8_t *buf );
| |||||||||||||||||||||||||||
Binding: |
int16_t x_shel_put ( int16_t mode, int8_t *buf ) { int_in[0] = mode; addr_in[0] = buf; crys_if(29058); return ( int_out[0] ); } | |||||||||||||||||||||||||||
GEM-Arrays: |
|