Main Page   File List   Globals  

server.c File Reference

ADC-ZESOI protocol server. More...

#include <server.h>

Go to the source code of this file.

Defines

#define TEST_MODE

Functions

int main (int argc, char *argv[])
char* readcommand (int fd)
 Read command form file. More...

command_t parsecommand (const char *input, command_t status)
 Parse command. More...

command_t executecommand (command_t c, command_t status, int fd)
 Executes command. More...

void lostconnection (int sig)
 SIGPIPE handler. More...

int acquireandsendsamples (int fd, int no_of_samples, int channel, char resolution)
 Acquires and sends samples. More...

void stopstream (int sig)
 SIGTERM handler. More...

void cleanallchildren (int sig)
 SIGCHLD handler. More...


Variables

const char* help


Detailed Description

ADC-ZESOI protocol server.

Author(s):
Tomislav Petkoviæ , Darko Vasiæ
Date:
2001-12-09

Definition in file server.c.


Define Documentation

#define TEST_MODE
 

Value:

Definition at line 19 of file server.c.


Function Documentation

int acquireandsendsamples ( int fd,
int no_of_samples,
int channel,
char resolution )
 

Acquires and sends samples.

Acquire and send samples. TODO: This function should be replaced with a call to new program that continously stores data samples and proviedes them at request. That project layer is not yet completly implemented (Why? Ask project coordinator Zvonko Kostanjcar at zkostanj@diana.zesoi.fer.hr).

Parameters:
fd   File descriptor.
no_of_samples   Number of samples to send.
channel   Requested channel number.
resolution   Requested resolution.
Returns:
Returns ACQUIRE_SUCCESS if successful.

Definition at line 1436 of file server.c.

void cleanallchildren ( int sig )
 

SIGCHLD handler.

Cleans all child processes.

Parameters:
sig   Signal number.

Definition at line 1564 of file server.c.

command_t executecommand ( command_t c,
command_t status,
int fd )
 

Executes command.

Executes command and prints useful messages about execution.

Parameters:
c   Command to execute.
status   Server status.
fd   File descriptor.
Returns:
Returns new server status.

Definition at line 843 of file server.c.

void lostconnection ( int sig )
 

SIGPIPE handler.

Handles SIGPIPE signal (broken pipe). This signal is received when client terminates connection. Terminates child proces and cleans up everything.

Parameters:
sig   Signal number.

Definition at line 1406 of file server.c.

command_t parsecommand ( const char * input,
command_t status )
 

Parse command.

Input buffer is parsed for ADC-ZESOI protocol commands.

Parameters:
input   Input buffer.
status   Status of the server.
Returns:
Returns a structure which contains command number and additional parameters. It's a copy of command_t status with command_no and error_code changed appropriately. Other parameters are changed if specified by parsed command.

Definition at line 503 of file server.c.

char * readcommand ( int fd )
 

Read command form file.

Reads an aribtrary length command form file specified by file descriptor.

Parameters:
fd   A file descriptor.
Returns:
Returns a pointer to a uninterpreted command, or NULL pointer if unsuccessful.

Definition at line 451 of file server.c.

void stopstream ( int sig )
 

SIGTERM handler.

Handles SIGTERM signal for child process when child process is sending data stream.

Parameters:
sig   Signal number.

Definition at line 1531 of file server.c.


Variable Documentation

const char * help
 

Initial value:

"ADC-ZESOI server v" VERSION ".\n"
"Usage:\n"
" server [options]\n"
"Options are:\n"
" -h --help      Prints this help message.\n"

" -t --test      Test mode - server creates random data (default).\n"
"    --notest    Test mode disabled. Can't be used together with -t.\n"




" -p <port>, --port=<port>   Sets port to <port>. If ommited default port\n"
"                for ADC-ZESOI protocol (port 7777) is used.\n"
" -a --auth      Requires authentification. Default is no\n"
"                authentfication required (option -n).\n"
" -n --noauth    Disable authentification (default). Can't be\n"
"                used together with -a.\n"
"    --nullok    Allow access for passwordless accounts.\n"
"    --maxretries=<retries>   Sets maximum number of login attempts to\n"
"                given number. Default value is 3 login attempts.\n"
" -v --version   Show version number.\n"

Definition at line 26 of file server.c.


Generated at Wed Feb 6 16:45:12 2002 for ADC-ZESOI Server by doxygen1.2.7 written by Dimitri van Heesch, © 1997-2001