Download Ericsson CH337 Specifications
Transcript
2 COMMUNICATING WITH THE SYSTEM SCREEN
From command line to reserved statics
As mentioned earlier in this chapter, an application should analyse its command line on start-up, and
should write various values from this command line into Epoc reserved statics as a result.
As an example of how this could be done, there follows the source code for two Hwif routines:
GLDEF_C VOID hSetUpStatusNames(TEXT *pb)
{
TEXT buf[P_FNAMESIZE];
P_FPARSE crk;
DatUsedPathNamePtr=pb;
p_fparse(pb,0,&buf[0],&crk);
DatStatusNamePtr=pb+P_FSYSNAMESIZE+crk.device+crk.path;
}
GLDEF_C INT hCrackCommandLine(VOID)
{
INT ret;
TEXT *pb;
pb=DatCommandPtr;
pb+=p_slen(pb)+1;
if (!*pb++)
ret=0;
else
{
ret=(*pb++);
DatProcessNamePtr=pb;
pb+=p_slen(pb)+1;
pb+=p_slen(pb)+1;
if (*pb)
hSetUpStatusNames(pb);
else
DatStatusNamePtr=DatProcessNamePtr;
}
return(ret);
}
For details of the DatCommandPtr and other reserved statics see the Processes and Inter-Process
Messaging chapter of the Plib Reference manual.
Applications that disregard their command line
Simple applications - especially those that are not file based - have no need to pay any attention to the
command line passed to them by the System Screen. In this case, the various relevant Epoc statics are left
at their default (zero) values. This fact is picked up by the System Screen and by other parts of the OS,
with the following results:
•
The name displayed in any status window and in the file list in the System Screen is just that of
the application .app file
•
If the user requests the application to be shut down, from the System Screen, the application is
shut down by the OS, without the application itself being informed of this fact (just as if the user
had selected the Kill option in the System Screen).
In case an application wishes to do its own processing in response to a Shutdown request issued by the
user in the System Screen, it must therefore make a call to a routine such as hCrackCommandLine during
its initialisation. This is true even if the application is not file-based.
One final drawback of an application not processing its command line is that users will be unable to
assign application buttons with any effect to that application. Suppose a user assigns CONTROL+WORLD to
a version of the Spy application, for example, that fails to write anything suitable to DatProcessNamePtr.
If the user subsequently presses the key combination CONTROL+WORLD, the Spy application will fail to be
brought into foreground - thus spoiling the whole purpose of assigning the application button.
2-11