Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

config.h File Reference

Go to the source code of this file.

Data Structures

struct  modem_conf_struct
 This structure contains the modems' configuration data. More...


Defines

#define MODEM_CONF_MAX_ENTRY   256
 Maximum number of modems' configuration records.

#define MODEM_CONF_IDENTIFIER_SIZE   7
 Maximum number of bytes (including the final 0) for the buffer used to store the constructor's signature.

#define MODEM_CONF_TAG_NAME_SIZE   256
 Maximum number of bytes (including the final 0) for the label that represents the constructor.

#define MODEM_CONF_AUTOCONF_SIZE   4
 Maximum number of bytes (including the final 0) for the auto-configuration tag ("yes" or "no").

#define MODEM_CONF_ACTION_SIZE   256
 Maximum number of bytes (including the final 0) for the path to the dinamically loadable module that implements the calculation of the MAC address.

#define PARSE_CONFIGURATION_FILE_NOT_FOUND   -1
 configuration parser could not open the configuration file.

#define PARSE_CONFIGURATION_NO_MEM   -2
 configuration parser could not allocate memory.

#define PARSE_CONFIGURATION_SYNTAX_ERROR   -3
 configuration parser found an invalid line.

#define PARSE_CONFIGURATION_DUPLICATED_TAG   -4
 configuration parser found a duplicated tag.

#define PARSE_CONFIGURATION_DLL_OPEN_ERROR   -5
 Could not load the DLL.

#define PARSE_CONFIGURATION_DLL_INVALID   -6
 The DLL is not valid.

#define PARSE_CONFIGURATION_MODEM_CONF_NOT_VALID   -7
 One record that represents a modem's configuration is not valid.

#define PARSE_CONFIGURATION_OK   0
 configuration parser terminated successfully.

#define CONFIG_HD

Functions

int parse_configuration_file (char *path, int *err)
 Load a given configuration file. More...

void free_all_configuration_data ()
 Free all data allocated for the hash table. More...

int get_value (char *tag, char **value)
 Return the value associated with a given tag. More...

char * dummy_mac_processor (char *addr)
 Dummy MAC address calculator. More...

char * conf_get_last_error ()
 Return the last error message. More...

int get_number_of_modem_conf ()
 Return the number of records in the modems' configuration file. More...

int modem_conf_get_id (char *mac)
 Returns the ID of a given MAC address. More...

char * modem_conf_get_tag_name (int id)
 Returns the tag name of a given MAC address, representd by its ID. More...

int modem_conf_is_autoconf (int id)
 Returns a value that indicates if a given modem supports auto-configuration. More...

void * modem_conf_get_function (int id)
 Returns the MAC processor for a given MAC address. More...


Detailed Description

Header file for config.c.

Definition in file config.h.


Function Documentation

char* conf_get_last_error  
 

Return the last error message.

Author:
Denis BEURIVE
Returns:
The function returns a zero terminated, statically allocated, string of characters that represents the last error message.

Definition at line 31 of file config.c.

References last_error.

Referenced by configuration_load().

char* dummy_mac_processor char *    addr
 

Dummy MAC address calculator.

Author:
Denis BEURIVE
Parameters:
addr  Pointer to a zero terminated string of characters that represents the original MAC address.
Returns:
The function returns a pointer to a zero terminated, statically allocated, string of characters. This string contains a copy of the original MAC address.
Remarks:
Make sure that the buffer "mac" is big enough.

Definition at line 122 of file config.c.

Referenced by parse_configuration_file().

void free_all_configuration_data  
 

Free all data allocated for the hash table.

Author:
Denis BEURIVE

Definition at line 330 of file config.c.

References allochtab, and htab.

Referenced by parse_configuration_file().

int get_number_of_modem_conf  
 

Return the number of records in the modems' configuration file.

Author:
Denis BEURIVE
Returns:
The function returns the number of modems' configuration records.

Definition at line 112 of file config.c.

References nb_modem.

Referenced by modem_conf_get_id(), and parse_configuration_file().

int get_value char *    tag,
char **    value
 

Return the value associated with a given tag.

Author:
Denis BEURIVE
Parameters:
tag  Pointer to a zero terminated string of characters that represents the tag to look for.
value  Pointer that will point to the corresponding value (if the tag was found).
Returns:
  • If the tag could not be find, the function returns the value 0. 'value' is NULL.
  • If the tag has been found, the function returns the value 1.
  • If the function ran out of memory, the function returns the value -1. 'value' is NULL.

Definition at line 343 of file config.c.

References htab.

Referenced by configuration_load(), and load_mysql_configuration_from_file().

void* modem_conf_get_function int    id
 

Returns the MAC processor for a given MAC address.

Author:
Denis BEURIVE
Parameters:
id  ID of the MAC address (as returned by the function modem_conf_get_id()).
Returns:
The function returns a pointer to a function used to calculate the new MAC address.

Definition at line 321 of file config.c.

References modem_conf_struct::calculate_mac_address.

int modem_conf_get_id char *    mac
 

Returns the ID of a given MAC address.

Author:
Denis BEURIVE
Parameters:
mac  Pointer to a zero terminated string of characters that represents the modem's MAC address.
Returns:
The function returns a integer that represents the modem's ID.

Definition at line 281 of file config.c.

References get_number_of_modem_conf().

char* modem_conf_get_tag_name int    id
 

Returns the tag name of a given MAC address, representd by its ID.

Author:
Denis BEURIVE
Parameters:
id  ID of the MAC address (as returned by the function modem_conf_get_id()).
Returns:
The function returns a pointer to a zero terminated string of characters that represents the tag name.

Definition at line 297 of file config.c.

References modem_conf_struct::tag_name.

int modem_conf_is_autoconf int    id
 

Returns a value that indicates if a given modem supports auto-configuration.

Author:
Denis BEURIVE
Parameters:
id  ID of the MAC address (as returned by the function modem_conf_get_id()).
Returns:
The function returns one of the following values:
  • 1: The modem supports auto-configuration.
  • 0: The modem does not support auto-configuration.

Definition at line 309 of file config.c.

Referenced by main().

int parse_configuration_file char *    path,
int *    err
 

Load a given configuration file.

Author:
Denis BEURIVE
Parameters:
path  Path to the configuration file to load.
err  Pointer to an integer that will be used to store the value of 'errno' if an error occured.
Returns:
Upon successful completion, the function returns tha value PARSE_CONFIGURATION_OK. Otherwise the function may return one of the following values:
  • PARSE_CONFIGURATION_NO_MEM: Could not allocate memory.
  • PARSE_CONFIGURATION_FILE_NOT_FOUND: Could not open configuration file. "errno' is set.
  • PARSE_CONFIGURATION_SYNTAX_ERROR: Syntax error in configuration file.
  • PARSE_CONFIGURATION_DUPLICATED_TAG: Configuration contains a duplicated tag.
  • PARSE_CONFIGURATION_DLL_OPEN_ERROR: Could not load DLL.
  • PARSE_CONFIGURATION_DLL_INVALID: DLL is not valid.
  • PARSE_CONFIGURATION_MODEM_CONF_NOT_VALID: Modem's configuration record is not valid.
  • PARSE_CONFIGURATION_OK: Success.
Warning:
  • If the returned value is PARSE_CONFIGURATION_NO_MEM, the module does not free allocated memory. You should abort the program.
  • If the returned value is PARSE_CONFIGURATION_FILE_NOT_FOUND, PARSE_CONFIGURATION_SYNTAX_ERROR, PARSE_CONFIGURATION_DUPLICATED_TAG, PARSE_CONFIGURATION_DLL_OPEN_ERROR, PARSE_CONFIGURATION_DLL_INVALID, PARSE_CONFIGURATION_MODEM_CONF_NOT_VALID, the module free all allocated memory.
Remarks:
In case you think that the same DLL is loaded multiple times, consider this: Only a single copy of an shared library file is brought into the address space, even if dlopen is invoked multiple times in reference to the file, and even if different pathnames are used to reference the file.

Definition at line 171 of file config.c.

References allochtab, modem_conf_struct::calculate_mac_address, config_compare_user_data(), config_free_user_data(), CONFIG_H_ERROR_SIZE, config_hash_function(), configin, configlex(), modem_conf_struct::dll, dummy_mac_processor(), free_all_configuration_data(), get_number_of_modem_conf(), htab, modem_conf_struct::id, last_error, MODEM_CONF_ACTION_SIZE, MODEM_CONF_AUTOCONF_SIZE, MODEM_CONF_IDENTIFIER_SIZE, MODEM_CONF_TAG_NAME_SIZE, nb_modem, PARSE_CONFIGURATION_DLL_INVALID, PARSE_CONFIGURATION_DLL_OPEN_ERROR, PARSE_CONFIGURATION_DUPLICATED_TAG, PARSE_CONFIGURATION_FILE_NOT_FOUND, PARSE_CONFIGURATION_MODEM_CONF_NOT_VALID, PARSE_CONFIGURATION_NO_MEM, PARSE_CONFIGURATION_OK, and PARSE_CONFIGURATION_SYNTAX_ERROR.

Referenced by configuration_load(), and load_mysql_configuration_from_file().


Generated on Mon Jun 19 12:31:06 2006 for MyDhcp_V2 by doxygen1.2.15