Dynamics
Pseudocode for support tools $Revision: 1.2 $ State approved
Date 07-Dec-1998 Author Jari Hautio
Review date 10-Dec-1998 Reviewed by Jouni Malinen
Approval date 10-Dec-1998 Approved by Jouni Malinen
$Id: api_pseudocode.html,v 1.2 1998/12/09 23:53:20 jkmaline Exp $

Pseudocode for support tools

Program first examines the command line parameters. If they exist, the command specified on the command line is executed. If the command did not include monitoring time interval, the program quits. Otherwise it continues to user-interface part.

The user-interface part consist of a loop where user input is waited for a specific time interval. Time interval is used to rerun monitoring commands. Initially this timeout is infinite, but when monitoring command is executed, it assigns a time interval to this timeout.

Command is processed by splitting the input to command part and parameter part. Depending on the command part a library function call is made or the program exits. On library calls the storage for results must be reserved and the return value is examined to determine whether an error message should be printed or the results shown. The command processing function presented in pseudocode is a template function. The actual processing functions will vary between tools and implement the commands specified for them.

If the command was a monitoring command and included time interval, the input_timeout variable is set to given time interval.

Variables:

string command
int input_timeout
int library_timeout

Main:

library_timeout ::= 10 (seconds)

If command line parameters
    command ::=command line parameters
    input_timeout ::= 0
    ProcessCommand
    if input_timeout = 0
        Exit program
end if
input_timeout = infinite
Do forever
    wait for user input for input_timeout seconds
    if user input
        command ::= user input
    ProcessCommand
end do

Process Command:
int return_value
int parameter

Split command to command_part and parameter_part

if command_part is library call
    if parameters are illegal
        show error message
        return
    Allocate space for result_buffer
    return_value ::= library_call(paramter, result_buffer, library_timeout)
    if return_value = success
        Show results
    else Show error message
    if timeout was specifed in parameter_part and is between 1 and 60
        input_timeout ::= parameter_part timeout
    Free result_buffer

if (command_part = "quit")
    Quit program
if (command_part = "help")
    if paramater matches to command
        Show help for the command
    else show general help