GEMLIB
0.44.0
|
AES shell functions. More...
Macros | |
#define | shel_envrn(a, b) mt_shel_envrn(a,b,aes_global) |
#define | shel_find(a) mt_shel_find(a,aes_global) |
#define | shel_get(a, b) mt_shel_get(a,b,aes_global) |
#define | shel_help(a, b, c) mt_shel_help(a,b,c,aes_global) |
#define | shel_put(a, b) mt_shel_put(a,b,aes_global) |
#define | shel_rdef(a, b) mt_shel_rdef(a,b,aes_global) |
#define | shel_read(a, b) mt_shel_read(a,b,aes_global) |
#define | shel_wdef(a, b) mt_shel_wdef(a,b,aes_global) |
#define | shel_write(a, b, c, d, e) mt_shel_write(a,b,c,d,e,aes_global) |
Functions | |
short | mt_shel_envrn (char **result, const char *param, short *global_aes) |
short | mt_shel_find (char *buf, short *global_aes) |
short | mt_shel_get (char *Buf, short Len, short *global_aes) |
short | mt_shel_help (short sh_hmode, const char *sh_hfile, const char *sh_hkey, short *global_aes) |
short | mt_shel_put (const char *Buf, short Len, short *global_aes) |
short | mt_shel_rdef (char *lpcmd, char *lpdir, short *global_aes) |
short | mt_shel_read (char *Command, char *Tail, short *global_aes) |
short | mt_shel_wdef (const char *lpcmd, const char *lpdir, short *global_aes) |
short | mt_shel_write (short Exit, short Graphic, short Aes, void *Command, char *Tail, short *global_aes) |
AES shell functions.
The Shell Library contains several miscellaneous functions most often used by the GEM Desktop and other 'Desktop-like' applications. Other applications may, however, need specific functions of the Shell Library for various tasks.
#define shel_envrn | ( | a, | |
b | |||
) | mt_shel_envrn(a,b,aes_global) |
single-thread version of mt_shel_envrn()
#define shel_find | ( | a | ) | mt_shel_find(a,aes_global) |
single-thread version of mt_shel_find()
#define shel_get | ( | a, | |
b | |||
) | mt_shel_get(a,b,aes_global) |
single-thread version of mt_shel_get()
#define shel_help | ( | a, | |
b, | |||
c | |||
) | mt_shel_help(a,b,c,aes_global) |
single-thread version of mt_shel_help()
#define shel_put | ( | a, | |
b | |||
) | mt_shel_put(a,b,aes_global) |
single-thread version of mt_shel_put()
#define shel_rdef | ( | a, | |
b | |||
) | mt_shel_rdef(a,b,aes_global) |
single-thread version of mt_shel_rdef()
#define shel_read | ( | a, | |
b | |||
) | mt_shel_read(a,b,aes_global) |
single-thread version of mt_shel_read()
#define shel_wdef | ( | a, | |
b | |||
) | mt_shel_wdef(a,b,aes_global) |
single-thread version of mt_shel_wdef()
#define shel_write | ( | a, | |
b, | |||
c, | |||
d, | |||
e | |||
) | mt_shel_write(a,b,c,d,e,aes_global) |
single-thread version of mt_shel_write()
short mt_shel_envrn | ( | char ** | result, |
const char * | param, | ||
short * | global_aes | ||
) |
searches the current environment string for a specific variable.
result | points to a character pointer which will be filled in with the address of the first character in the environment string following the string given by param. If the string given by param is not found, value will be filled in with NULL. For instance, suppose the current environment looked like this: PATH=C:\;D:\;E:\ A call made to mt_shel_envrn() with param pointing to the string 'PATH=' would set the pointer pointed to by value to the string 'C:\;D:\;E:\' above. |
param | see above |
global_aes | global AES array |
AES versions prior to 1.4 only accepted semi-colons as separators between multiple 'PATH='
arguments. Newer versions accept commas as well.
The character string pointed to by name should include the name of the variable and the equals sign.
short mt_shel_find | ( | char * | buf, |
short * | global_aes | ||
) |
searches for a file along the AES's current path, any paths specified by the 'PATH' environmental variable, and the calling application's path.
buf | should point to a character buffer of at least 260 characters and contain the filename of the file to search for on entry. If the function was able to find the file, the buffer pointed to by buf will be filled in with the full pathname of the file upon return. |
global_aes | global AES array |
short mt_shel_get | ( | char * | Buf, |
short | Len, | ||
short * | global_aes | ||
) |
copies the contents of the AES's shell buffer (normally the 'DESKTOP.INF' or 'NEWDESK.INF' file) into the specified buffer.
Buf | points to a buffer at least... |
Len | ...bytes long into which the AES should copy the shell buffer into. |
global_aes | global AES array |
AES versions prior to version 1.4 had a shell buffer size of 1024 bytes. Versions 1.4 to 3.0 had a shell buffer size of 4192 bytes.
In AES versions 4.0 or greater the shell buffer is no longer of a fixed size. When mt_appl_getinfo() with parameter AES_INQUIRE indicates that this feature is supported, length can be specified as SHEL_BUFSIZE to return the size of the current shell buffer.
short mt_shel_help | ( | short | sh_hmode, |
const char * | sh_hfile, | ||
const char * | sh_hkey, | ||
short * | global_aes | ||
) |
Call the help server
sh_hmode | shall be SHP_HELP (only value handled at the moment) |
sh_hfile | Name of the help-file. if sh_hfile has an extension (for example 'test.hyp' ), then on the basis of the extension ( .hyp in the example), the appropriate server in the list of the Helpserver is invoqued.if sh_hfile has no extension (for example 'test' ), then the first server defined in the CNF file of the Helpservers is invoqued. |
sh_hkey | Keyword, to which an assistance text is to be spent, or ZERO. |
global_aes | global AES array |
When the suitable help-server is found, then it is examined whether this is already active (as Accessory or also as concurrently started application). If this is the case, then the VA_START message is sent with sh_hfile and sh_hkey as arguments for command line. Otherwise, the suitable server is started with sh_hfile and sh_hkey parameters.
short mt_shel_put | ( | const char * | Buf, |
short | Len, | ||
short * | global_aes | ||
) |
copies information into the AES's shell buffer.
Buf | points to a user memory buffer from which... |
Len | ...bytes are to be copied into the shell buffer. |
global_aes | global AES array |
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.
The Desktop uses the information in the shell buffer for several purposes. Applications should not use the shell buffer for their own purposes.
short mt_shel_rdef | ( | char * | lpcmd, |
char * | lpdir, | ||
short * | global_aes | ||
) |
"Shell READ default" - default program query
lpcmd | Pointer on a sufficiently dimensioned string for the name of the application. |
lpdir | Pointer on a sufficiently dimensioned stringer for the path of the application |
global_aes | global AES array |
The function makes it possible to inquire the program which is started after completion of the current (f.e. the Desktop).
short mt_shel_read | ( | char * | Command, |
char * | Tail, | ||
short * | global_aes | ||
) |
is used to determine the current application's parent and the command tail used to call it.
Command | points to a buffer which upon exit will be filled in with the complete file specification of the application. the buffer should have at least 260 bytes. |
Tail | will likewise be filled in with the initial command line. The first BYTE of the command line indicates the length of the string which actually begins at &Tail[1]. |
global_aes | global AES array |
short mt_shel_wdef | ( | const char * | lpcmd, |
const char * | lpdir, | ||
short * | global_aes | ||
) |
"Shell write default" - default program set
lpcmd | |
lpdir | |
global_aes | global AES array |
The function makes it possible to specify the application which is to be the default program (normally the Desktop).
short mt_shel_write | ( | short | wodex, |
short | wisgr, | ||
short | wiscr, | ||
void * | cmd, | ||
char * | tail, | ||
short * | global_aes | ||
) |
is a multi-purpose function which handles the manipulation and launching of processes.
wodex | specifies the action to perform. See the table hereafter. |
wisgr | its meaning depends on wodex. See the table hereafter. |
wiscr | its meaning depends on wodex. See the table hereafter. |
cmd | its meaning depends on wodex. See the table hereafter. |
tail | its meaning depends on wodex. See the table hereafter. |
global_aes | global AES array |
Name | Mode | Meaning |
SWM_LAUNCH | 0 | Launch a GEM or TOS application or GEM desk accessory depending on the extension of the file. This mode is only available as of AES version 4.0.
This function returns the AES id of the started process. If 0 is returned then the process was not launched. Under MultiTOS, processes are launched concurrently with their parent. An exit code is returned in a CH_EXIT message when the child terminates. In AES versions 4.0 and above, mt_appl_getinfo() should be used to determine the exact result of this call. |
SWM_LAUNCHNOW | 1 | Launch a GEM or TOS application based on the value of wisgr.
How do I launch a program in "single mode" under MagiC ?
How do I launch a program in "chain mode" under MagiC ?
After the program terminates the shell will be reloaded automatically. When calling the shell one gets in the command line (-> mt_shel_read() ) the "magic" sequence SHELTAIL. Parent applications which launch children using this mode are suspended under MultiTOS. In AES versions 4.0 and above, mt_appl_getinfo() should be used to determine the exact result of this call. |
SWM_LAUNCHACC | 3 | Launch a GEM desk accessory. For the meaning of other parameters and the meaning of the return value, see mode SWM_LAUNCH. This mode is only supported by AES versions of at least 4.0. |
SWM_SHUTDOWN | 4 | Manipulate 'Shutdown' mode. Shutdown mode is usually used prior to a resolution change to cause system processes to terminate.
N.AES has the following extension:
During a shutdown, processes which have registered themselves as accepting AP_TERM messages will be sent them and all accessories will be sent AC_CLOSE messages. In addition, in complete shutdown mode, AP_TERM messages will also be sent to accessories. Shutdown mode may be aborted but only by the original caller. The status of the shutdown is sent to the calling processes by AES messages. This mode is only supported by AES versions greater than or equal to 4.0. |
SWM_REZCHANGE | 5 | Change screen resolution
If AES accepts the resolution change request, then it will put the system in SHUT DOWN mode. An application can either shut down and exit or deny to shut down by sending a AP_TFAIL message to the AES. N.AES has the following extension:
This mode is only recognized as of AES version 4.0. |
SWM_BROADCAST | 7 | Broadcast an AES message to all processes.
This mode is only recognized as of AES version 4.0. |
SWM_ENVIRON | 8 | Manipulate the AES environment.
This mode is only recognized as of AES version 4.0. |
SWM_NEWMSG | 9 | Inform the AES of a new message the current application understands.
This mode is only recognized as of AES version 4.0. |
SWM_AESMSG | 10 | Send a message to the AES.
This mode is only recognized as of AES version 4.0. |
SWM_THRCREATE | 20 | The application produces a new Thread
|
SWM_THREXIT | 21 | This mode allows a thread to terminate itself.
Returns 0 if an error occured (the function does not return when succeed !). An error can occur if
Normally implementing of this function is not necessary, since the thread is automatically terminated with the end of its procedure (i.e. with the CPU instruction RTS). If the thread has made a Pexec() call, then the running process must be first terminated with Pterm() before the thread can terminate itself. |
SWM_THRKILL | 22 | This mode allows the main program to terminate a thread.
Normally this function is not necessary, since with main program terminates, then all associated Threads are terminated as well. Returns 0 (error) or 1 (OK). An error can occur if:
Even if the return value is 1, one should note that in cases where the thread has launched another program with Pexec() in the meantime, only this program will be terminated with Pterm(EBREAK). The thread will only be terminated when the caller has received THR_EXIT. Warning: One should note that the memory that the thread allocates belongs to the process, i.e. it is not released automatically when the thread terminates. The same applies for open files, which are closed only on program termination. |
The parameter wodex have extended bits, only supported by AES versions of at least 4.0. When the lower eight bits of mode are SWM_LAUNCH, SWM_LAUNCHNOW, or SWM_LAUNCHACC, appropriate bits in the upper byte may be set to enter 'extended' mode. The bits in the upper byte are assigned as follows:
If the upper byte is empty, extended mode is not entered and cmd specifies the filename (to search for the file with mt_shel_find() ) or the complete file specification. Otherwise, if any extended bits are set, cmd points to a SHELW structure (or XSHW_COMMAND structure if you use MagiC6 extension).