Cross reference for modules/pc/protocol_config.c of index.

# File modules/pc/protocol_config.c

      $Revision: 1.37 $

      Protocol config module (pc).  This is the protocol that the admin uses to
      talk to the server.

      Status: NOT REVUED, NOT TESTED

References Functions: | command_help() | modules/pc/pc_commands.c
| command_purify() | modules/pc/pc_commands.c
| command_quit() | modules/pc/pc_commands.c
| command_set() | modules/pc/pc_commands.c
| command_show() | modules/pc/pc_commands.c
| command_stop() | modules/pc/pc_commands.c
| set_acl() | modules/pc/pc_commands.c
| set_counter() | modules/pc/pc_commands.c
| set_err() | modules/pc/pc_commands.c
| set_macro() | modules/pc/pc_commands.c
| set_nodeny() | modules/pc/pc_commands.c
| set_updates() | modules/pc/pc_commands.c
| show_access() | modules/pc/pc_commands.c
| show_acl() | modules/pc/pc_commands.c
| show_const() | modules/pc/pc_commands.c
| show_consts() | modules/pc/pc_commands.c
| show_err() | modules/pc/pc_commands.c
| show_macros() | modules/pc/pc_commands.c
| show_props() | modules/pc/pc_commands.c
| show_threads() | modules/pc/pc_commands.c
| show_uptime() | modules/pc/pc_commands.c
| show_whois() | modules/pc/pc_commands.c
| stop_query() | modules/pc/pc_commands.c

## Included Files

- `#include <stdio.h>`

- `#include <stdlib.h>`

- `#include <time.h>`

- `#include <sys/ioctl.h>`

- `#include "include/thread.h"`
  - `#include <pthread.h>`

- `#include "include/constants.h"`
  - `#include <glib.h>`

- `#include "include/properties.h"`

- `#include <glib.h>`

- `#include "include/sk.h"`
  - `#include "include/stubs.h"`
    - `#include <stdlib.h>`
    - `#include <stdio.h>`
    - `#include <ctype.h>`
  - `#include <sys/types.h>`
  - `#include <sys/socket.h>`
  - `#include <netinet/in.h>`
  - `#include <netdb.h>`
  - `#include <pthread.h>`
  - `#include <stdlib.h>`
  - `#include <errno.h>`
  - `#include <fcntl.h>`
  - `#include <signal.h>`
  - `#include <stdio.h>`
  - `#include "include/iproutines.h"`
    - `#include <sys/types.h>`
    - `#include <glib.h>`
    - `#include <include/inet6def.h>`
    - `#include <include/erroutines.h>`

- `#include "include/ta.h"`
  - `#include <glib.h>`
  - `#include <pthread.h>`
  - `#include <stdio.h>`
  - `#include "include/stubs.h"`
  - `#include "include/memwrap.h"`
    - `#include <erroutines.h>`
    - `#include <glib.h>`
  - `#include "include/sk.h"`
  - `#include "include/timediff.h"`
    - `#include <sys/time.h>`

- `#include "include/ut_string.h"`

- `#include "include/memwrap.h"`

- `#include "modules/pc/pc_commands.h"`

- `#include "modules/pc/protocol_config.h"`

## Preprocessor definitions

`#define PC_IMPL`

## Global Variable command

* Contains the command definitions

`struct _command command[]`

Included from | modules/pc/protocol_config.h
Visible in: |  | modules/pc/pc_commands.c
|  | modules/pc/protocol_config.c
Used in: | command_help() | modules/pc/pc_commands.c
| process_input() | modules/pc/protocol_config.c

## Global Variable show

* Contains the show commands

`struct _command show[]`

Included from | modules/pc/protocol_config.h
Visible in: |  | modules/pc/pc_commands.c
|  | modules/pc/protocol_config.c
Used in: | command_show() | modules/pc/pc_commands.c

## Global Variable set

* Contains the set commands

`struct _command set[]`

Included from | modules/pc/protocol_config.h
Visible in: |  | modules/pc/pc_commands.c
|  | modules/pc/protocol_config.c
Used in: | command_set() | modules/pc/pc_commands.c

## Global Variable stop

`struct _command stop[]`

Included from | modules/pc/protocol_config.h
Visible in: |  | modules/pc/pc_commands.c
|  | modules/pc/protocol_config.c
Used in: | command_stop() | modules/pc/pc_commands.c

## Global Function PC_interact()

      Main function that talks to the user connected on the given socket.
      Starts by authenticating the user (if this mode is active)
      and greeting her with the uptime data. Then it loops reading and executing
      commands until the "quit" command (or any other command that causes
      process_input to return 0).

`void PC_interact ( int sock )`

`int sock`
  connected client socket

Prototyped in: | modules/pc/protocol_config.h
Calls: | CO_get_authenticate() | modules/co/constants.c
| CO_get_prompt() | modules/co/constants.c
| CO_get_welcome() | modules/co/constants.c
| ER_inf_va() | modules/er/er.c
| authenticate_user() | modules/pc/protocol_config.c
| process_input() | modules/pc/protocol_config.c
| show_uptime() | modules/pc/pc_commands.c
| SK_cd_gets(), SK_cd_printf(), SK_cd_puts(), SK_getpeerip(), SK_getpeername(), TA_increment(), TA_setactivity(), free(), memset(), ut_string_compress(), wr_real_free()

## Global Function command_execute()

    		      returns the code of the last command. Code
    		      PC_RET_QUIT is reserved to indicate that the connection
    		      should be closed.

`int command_execute ( Command* comm, char* comm_name, char* input, GString* output, sk_conn_st* condat )`

`int command_execute`
  executes a command from the given array, matching given name. Passes input, output and condat to the function found in the array. Command name is removed from the input line so only next words are passed over to the function.
`Command* comm`
  array of command function structures (defined in protocol_config.h)
`char* comm_name`
  name of the command to be run
`char* input`
  rest of the command line
`GString* output`
  dynamically built output string
`sk_conn_st* condat`
  socket structure for this connection (some commands use it directly instead of storing the output)

Prototyped in: | modules/pc/protocol_config.h
Calls: | find_command() | modules/pc/protocol_config.c
| show_commands() | modules/pc/protocol_config.c
| fprintf(), free(), g_string_sprintfa(), strlen(), strtok_r(), wr_real_string()
Called by: | command_set() | modules/pc/pc_commands.c
| command_show() | modules/pc/pc_commands.c
| command_stop() | modules/pc/pc_commands.c
| process_input() | modules/pc/protocol_config.c

## Global Function show_commands()

`int show_commands ( Command* comm, char* comm_name, GString* output )`

Prototyped in: | modules/pc/protocol_config.h
Calls: | g_string_sprintfa()
Called by: | command_execute() | modules/pc/protocol_config.c
| command_help() | modules/pc/pc_commands.c

## Local Function authenticate_user()

      Authenticates the user - asks for password and checks it. The password is
      echoed by the tcp stack, to disable that one would have to attach a tty
      to this connection and switch to raw mode or try the hard way - renegotiate
      the telnet connection to switch to character mode (and, possibly, back).
      The latter has the drawback that to do it right it has to be able to check
      whether there's telnet on the other side - otherwise, if the connection
      is made by a program just connecting to the socket, garbage will result.
      However, in such case password checking might be not a good idea.

      More:

      Author:
            ottrey
    	marek - slight changes and documentation.

`static char* authenticate_user ( sk_conn_st* condat )`

Calls: | PR_get_property(), SK_cd_gets(), SK_cd_puts(), crypt(), fprintf(), strcmp(), strcpy(), strlen(), strncpy(), wr_real_malloc()
Called by: | PC_interact() | modules/pc/protocol_config.c

## Local Function find_command()

      Finds a command by name in the array of command function structures.

`static int find_command ( char* comm_name, Command* comm )`

`int find_command`
  returns the index to the correct row of the array, or -1 if the command could not be found.
`char* comm_name`
  name of the command
`Command* comm`
  array of command function structures.

Calls: | strcmp(), strtok_r(), wr_real_free(), wr_real_string()
Called by: | command_execute() | modules/pc/protocol_config.c
| process_input() | modules/pc/protocol_config.c

## Local Function process_input()

      Process the input. Finds the proper command in the top level command
      array and invokes the function associated with it with the input and
      output data as arguments.

      More:

      Author:
            ottrey
    	marek - changes and documentation.

`static int process_input ( char* input, sk_conn_st* condat )`

`int process_input`
  returns 1 if the connection is to be kept or 0 when it should be finished - that is, when command_execute() returns PC_RET_QUIT.
`char* input`
  input (presumably a command)
`sk_conn_st* condat`
  connection data

Calls: | CO_get_clear_screen() | modules/co/constants.c
| CO_get_prompt() | modules/co/constants.c
| command_execute() | modules/pc/protocol_config.c
| command_help() | modules/pc/pc_commands.c
| find_command() | modules/pc/protocol_config.c
| SK_cd_printf(), SK_cd_puts(), g_string_free(), g_string_new()
Called by: | PC_interact() | modules/pc/protocol_config.c
References Variables: | command | modules/pc/protocol_config.c