GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

GATConfig.c File Reference

Main file for the GATConfig class. More...

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <unistd.h>
#include <sys/stat.h>
#include "GATUtil.h"
#include "GATConfig.h"
#include "GATTable.h"
#include "GATContext.h"
#include "GATErrors.h"

Include dependency graph for GATConfig.c:

Include dependency graph

Go to the source code of this file.

Compounds

struct  adaptor_list
struct  GATConfig_S

Defines

#define LINE_LENGTH   1024
#define RC_FILENAME   ".gatrc"
#define MAX_PATH   _POSIX_PATH_MAX

Enumerations

enum  linetype {
  line_blank,
  line_comment,
  line_section,
  line_adaptor,
  line_string
}
enum  parse_error {
  parse_success,
  parse_empty_token,
  parse_memory_failure,
  parse_malformed_line
}

Functions

GATResult AddToAdaptorConfig (GATContext error_context, struct adaptor_list *adaptor, const char *nickname, GATTable config)
 AddAdaptorToConfig Adds a configuration table to an internal list for an adaptor.

GATResult ParseConfigFile (GATConfig this, GATContext error_context, const char *filename)
 ParseConfigFile Parse a GAT configuration file.

enum parse_error Tokenise (const char *line, char **token1, char **token2, enum linetype *type)
 Tokenise Determine what sort of string has been pased in and split into tokens.

enum parse_error ParseKeyVal (const char *string, char **token1, char **token2, enum linetype *type)
 ParseKeyVal Parse a line defining a key/value pair.

enum parse_error ParseString (const char *token_start, char **buffer)
 ParseString Parse a string token Strip whitespace from either end of a string and get rid of comments.

enum parse_error ParseSection (const char *token_start, char **buffer)
 ParseSection Parse a section definition Get a section name from a section definition.

GATConfig GATConfig_Create (GATContext error_context)
 GATConfig_Create The GATConfig constructor.

void GATConfig_Destroy (GATConfig *object)
 GATConfig_Destroy The GATConfig destructor.

GATTable_const GATConfig_GetSystemConfig (GATConfig_const this)
 GATConfig_GetSystemConfig Gets the system configuration table.

GATConfigTableList_const GATConfig_GetAdaptorConfigs (GATConfig_const this, const char *adaptor)
 GATConfig_GetAdaptorConfigs Gets the configuration tables for an adaptor.

GATResult GATConfig_AddAdaptorConfig (GATConfig this, GATContext error_context, const char *adaptor, const char *nickname, GATTable config)
 GATConfig_AddAdaptorConfig Adds a configuration table to an adaptor.


Variables

const char * rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATConfig.c,v 1.18 2004/04/28 10:50:10 hartmutkaiser Exp $"


Detailed Description

Main file for the GATConfig class.

A GATConfig object contains a set of configuration tables which define configuration parameters for the system and for specific adaptors.

Date:
Tue Sep 23 2003
Version:
Header:
/export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATConfig.c,v 1.18 2004/04/28 10:50:10 hartmutkaiser Exp

Copyright (C) Tom Goodale This file is part of the GAT Engine. Contributed by Tom Goodale <goodale@aei.mpg.de>.

Use, modification and distribution is subject to the Gridlab Software License. (See accompanying file GLlicense.txt or copy at http://www.gridlab.org/GLlicense.txt)

Definition in file GATConfig.c.


Define Documentation

#define LINE_LENGTH   1024
 

Definition at line 44 of file GATConfig.c.

Referenced by ParseConfigFile().

#define RC_FILENAME   ".gatrc"
 

Definition at line 45 of file GATConfig.c.

Referenced by GATConfig_Create().

#define MAX_PATH   _POSIX_PATH_MAX
 

Definition at line 48 of file GATConfig.c.

Referenced by GATConfig_Create(), and ParseConfigFile().


Enumeration Type Documentation

enum linetype
 

Enumeration values:
line_blank 
line_comment 
line_section 
line_adaptor 
line_string 

Definition at line 53 of file GATConfig.c.

Referenced by ParseConfigFile(), ParseKeyVal(), and Tokenise().

enum parse_error
 

Enumeration values:
parse_success 
parse_empty_token 
parse_memory_failure 
parse_malformed_line 

Definition at line 59 of file GATConfig.c.

Referenced by ParseConfigFile(), ParseKeyVal(), ParseSection(), ParseString(), and Tokenise().


Function Documentation

GATResult AddToAdaptorConfig GATContext    error_context,
struct adaptor_list   adaptor,
const char *    nickname,
GATTable    config
[static]
 

AddAdaptorToConfig Adds a configuration table to an internal list for an adaptor.

An adaptor may have more than one configuration table associated with it. This function add a new table to the internal list maintained by a GATConfig structure.

Parameters:
adaptor_list  Structure to add the config to.
nickname  The name for thisinstance of the adaptor.
config  The new configuration table.
Returns:
An error code.

Definition at line 356 of file GATConfig.c.

References GATConfigTableList_S::config, adaptor_list::configs, GAT_CREATE_STATUS, GAT_DUPLICATE_CONFIG, GAT_MEMORYFAILURE, GAT_RETURN_STATUS, GAT_USES_STATUS, GATUtil_strdup(), GATConfigTableList_S::next, and GATConfigTableList_S::nickname.

Referenced by GATConfig_AddAdaptorConfig().

GATResult ParseConfigFile GATConfig    this,
GATContext    error_context,
const char *    filename
[static]
 

ParseConfigFile Parse a GAT configuration file.

Open and parse the contents of a GAT configuration file, creating new configuration tables as necessary.

Parameters:
this  The GATConfig structure
filename  The configuration filename.
Returns:
An error code.

Definition at line 424 of file GATConfig.c.

References filename, GAT_CREATE_STATUS, GAT_CREATE_STATUS_MSG, GAT_FILEOPEN_ERROR, GAT_INVALID_CONFIG_FORMAT, GAT_RETURN_STATUS, GAT_USES_STATUS, GATConfig_AddAdaptorConfig(), GATTable_Add_String(), GATTable_Create(), line_adaptor, line_blank, line_comment, LINE_LENGTH, line_section, line_string, linetype, MAX_PATH, parse_empty_token, parse_error, parse_malformed_line, parse_memory_failure, parse_success, and Tokenise().

Referenced by GATConfig_Create().

enum parse_error Tokenise const char *    line,
char **    token1,
char **    token2,
enum linetype   type
[static]
 

Tokenise Determine what sort of string has been pased in and split into tokens.

Configuration file lines are either blank, comments, section definitions, adaptor definitions, or key/value pairs for the table. This function determines which, and splits the line into the requisite number of tokens.

Parameters:
line  The line to tokenise
token1  Buffer for first token on line.
token2  Buffer for first token on line.
type  What type the line is.
Returns:
An error code.

Definition at line 593 of file GATConfig.c.

References line_blank, line_comment, line_section, linetype, parse_error, parse_success, ParseKeyVal(), and ParseSection().

Referenced by ParseConfigFile().

enum parse_error ParseKeyVal const char *    string,
char **    token1,
char **    token2,
enum linetype   type
[static]
 

ParseKeyVal Parse a line defining a key/value pair.

Key/Value lines are of the form token1 = token2 Where token1 cannot have an "=" in it. Such lines are either destined for the configuration table or define an adaptor.

Parameters:
string  The string to tokenise
token1  Buffer for first token on line.
token2  Buffer for first token on line.
type  What type the line is.
Returns:
An error code.

Definition at line 644 of file GATConfig.c.

References line_adaptor, line_string, linetype, parse_empty_token, parse_error, parse_malformed_line, parse_memory_failure, and ParseString().

Referenced by Tokenise().

enum parse_error ParseString const char *    token_start,
char **    buffer
[static]
 

ParseString Parse a string token Strip whitespace from either end of a string and get rid of comments.

Parameters:
token_start  The beginning of the token.
buffer  Buffer to put the stripped token into.
Returns:
An error code.

Definition at line 715 of file GATConfig.c.

References parse_empty_token, parse_error, parse_memory_failure, and parse_success.

Referenced by ParseKeyVal().

enum parse_error ParseSection const char *    token_start,
char **    buffer
[static]
 

ParseSection Parse a section definition Get a section name from a section definition.

Parameters:
token_start  The beginning of the token.
buffer  Buffer to put the section name into.
Returns:
An error code.

Definition at line 787 of file GATConfig.c.

References parse_empty_token, parse_error, parse_malformed_line, parse_memory_failure, and parse_success.

Referenced by Tokenise().

GATConfig GATConfig_Create GATContext    error_context
 

GATConfig_Create The GATConfig constructor.

This is the constructor for GATConfig objects.

Returns:
A new GATConfig

Definition at line 116 of file GATConfig.c.

References GATConfig_S::adaptor_configs, buf, GAT_CREATE_STATUS, GAT_CREATE_STATUS_MSG, GAT_CURRENT_STATUS, GAT_FAILED, GAT_MEMORYFAILURE, GAT_STORE_STATUS, GAT_USES_STATUS, GATConfig_Destroy(), GATResult, GATTable_Create(), GATUtil_strdup(), MAX_PATH, ParseConfigFile(), RC_FILENAME, and GATConfig_S::system_config.

Referenced by GATSelf_Create().

void GATConfig_Destroy GATConfig   object
 

GATConfig_Destroy The GATConfig destructor.

This is the destructor for GATConfig objects.

Parameters:
this  An old GATConfig

Definition at line 195 of file GATConfig.c.

References GATConfigTableList_S::config, adaptor_list::configs, GATTable_Destroy(), adaptor_list::name, adaptor_list::next, GATConfigTableList_S::next, and GATConfigTableList_S::nickname.

Referenced by GATConfig_Create(), and GATSelf_Destroy().

GATTable_const GATConfig_GetSystemConfig GATConfig_const    this
 

GATConfig_GetSystemConfig Gets the system configuration table.

Gets the GATTable holding system configuration data.

Parameters:
this  The GATConfig structure
Returns:
The system configuration table.

Definition at line 235 of file GATConfig.c.

References GATConfig_const, and GATTable_const.

Referenced by Load().

GATConfigTableList_const GATConfig_GetAdaptorConfigs GATConfig_const    this,
const char *    adaptor
 

GATConfig_GetAdaptorConfigs Gets the configuration tables for an adaptor.

An adaptor may have more than one configuration table associated with it. This function returns a list of them all.

Parameters:
this  The GATConfig structure
adaptor  The adaptor to get the tables for.
Returns:
A list of adaptor configuration tables.

Definition at line 252 of file GATConfig.c.

References adaptor_list::configs, GATConfig_const, adaptor_list::name, and adaptor_list::next.

Referenced by Load().

GATResult GATConfig_AddAdaptorConfig GATConfig    this,
GATContext    error_context,
const char *    adaptor,
const char *    nickname,
GATTable    config
 

GATConfig_AddAdaptorConfig Adds a configuration table to an adaptor.

An adaptor may have more than one configuration table associated with it. This function add a new table.

Parameters:
this  The GATConfig structure
adaptor  The adaptor to add the tables to.
nickname  The name for thisinstance of the adaptor.
config  The new configuration table.
Returns:
An error code.

Definition at line 281 of file GATConfig.c.

References AddToAdaptorConfig(), adaptor_list::configs, GAT_CREATE_STATUS, GAT_MEMORYFAILURE, GAT_RETURN_STATUS, GAT_USES_STATUS, GATUtil_strdup(), adaptor_list::name, and adaptor_list::next.

Referenced by Load(), and ParseConfigFile().


Variable Documentation

const char* rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/src/GATConfig.c,v 1.18 2004/04/28 10:50:10 hartmutkaiser Exp $" [static]
 

Definition at line 21 of file GATConfig.c.