Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

lcmaps_db_read.c File Reference

the LCMAPS database reader More...

#include <stdlib.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include "lcmaps_log.h"
#include "_lcmaps_db_read.h"

Go to the source code of this file.

Defines

#define MAXDBENTRIES   250
#define MAXPAIRS   2
#define PAIR_SEP_CHARS   ","
#define VARVAL_SEP_CHARS   "="
#define PAIR_TERMINATOR_CHARS   PAIR_SEP_CHARS WHITESPACE_CHARS
#define VARVAL_TERMINATOR_CHARS   VARVAL_SEP_CHARS WHITESPACE_CHARS

Functions

int lcmaps_db_read_entries (FILE *)
 Read db entries from stream and fill a lsit of db entries.

int lcmaps_db_parse_line (char *, lcmaps_db_entry_t **)
 Parses database line and fills database structure.

int lcmaps_db_parse_pair (char *, char **, char **)
 Parses a database variable-value pair and returns the variable name and its value.

int lcmaps_db_parse_string (char **)
 Takes a string and removes prepending and trailing spaces and quotes (unless escaped).

lcmaps_db_entry_t ** lcmaps_db_read (char *lcmaps_db_fname)
 Read database from file.

lcmaps_db_entry_tlcmaps_db_fill_entry (lcmaps_db_entry_t **list, lcmaps_db_entry_t *entry)
 Add a database entry to a list.

int lcmaps_db_clean_list (lcmaps_db_entry_t **list)
 Clean/remove the database list.

int lcmaps_db_clean ()
 Clean/remove the database structure.


Variables

lcmaps_db_entry_tlcmaps_db_list = NULL


Detailed Description

the LCMAPS database reader

Author:
Martijn Steenbakkers for the EU DataGrid.

Definition in file lcmaps_db_read.c.


Define Documentation

#define MAXDBENTRIES   250
 

maximum number of LCMAPS database entries

Definition at line 37 of file lcmaps_db_read.c.

Referenced by lcmaps_db_read(), and lcmaps_db_read_entries().

#define MAXPAIRS   2
 

maximum number of variable-value pairs that will be parsed per line

Definition at line 38 of file lcmaps_db_read.c.

Referenced by lcmaps_db_parse_line().

#define PAIR_SEP_CHARS   ","
 

Characters separating variable-value pairs in the lcmaps database file

Definition at line 47 of file lcmaps_db_read.c.

Referenced by lcmaps_db_parse_line().

#define PAIR_TERMINATOR_CHARS   PAIR_SEP_CHARS WHITESPACE_CHARS
 

Characters that terminate pairs in the lcmaps database file. This is a combination of whitespace and separators.

Definition at line 59 of file lcmaps_db_read.c.

#define VARVAL_SEP_CHARS   "="
 

Characters separating variables from values

Definition at line 49 of file lcmaps_db_read.c.

Referenced by lcmaps_db_parse_pair().

#define VARVAL_TERMINATOR_CHARS   VARVAL_SEP_CHARS WHITESPACE_CHARS
 

Characters that terminate variables and values in the lcmaps database file. This is a combination of whitespace and separators.

Definition at line 64 of file lcmaps_db_read.c.


Function Documentation

int lcmaps_db_clean  ) 
 

Clean/remove the database structure.

Return values:
0 succes
1 failure

Definition at line 592 of file lcmaps_db_read.c.

References lcmaps_db_clean_list(), lcmaps_db_list, and lcmaps_log().

Referenced by startPluginManager().

int lcmaps_db_clean_list lcmaps_db_entry_t **  list  ) 
 

Clean/remove the database list.

Parameters:
list pointer to the database list
Return values:
0 succes.
1 failure.

Definition at line 562 of file lcmaps_db_read.c.

References lcmaps_db_entry_t, lcmaps_log_debug(), lcmaps_db_entry_s::next, and lcmaps_db_entry_s::pluginname.

Referenced by lcmaps_db_clean().

lcmaps_db_entry_t* lcmaps_db_fill_entry lcmaps_db_entry_t **  list,
lcmaps_db_entry_t entry
 

Add a database entry to a list.

Parameters:
list database list (array of database entry pointers)
entry the database entry to be added
Returns:
a pointer to the newly created database entry in the list or NULL (error)

Definition at line 205 of file lcmaps_db_read.c.

References lcmaps_db_entry_t, lcmaps_log(), lcmaps_log_debug(), LCMAPS_MAXARGSTRING, LCMAPS_MAXPATHLEN, lcmaps_db_entry_s::next, lcmaps_db_entry_s::pluginargs, and lcmaps_db_entry_s::pluginname.

Referenced by lcmaps_db_read_entries().

int lcmaps_db_parse_line char *  line,
lcmaps_db_entry_t **  entry
[static]
 

Parses database line and fills database structure.

Parameters:
line database line
entry pointer to a pointer to a database structure (can/should be freed afterwards)
Return values:
1 succes.
0 failure.

Definition at line 268 of file lcmaps_db_read.c.

References lcmaps_db_entry_t, lcmaps_db_parse_pair(), lcmaps_log(), lcmaps_log_debug(), LCMAPS_MAXARGSTRING, LCMAPS_MAXPATHLEN, MAXPAIRS, PAIR_SEP_CHARS, lcmaps_db_entry_s::pluginargs, and lcmaps_db_entry_s::pluginname.

Referenced by lcmaps_db_read_entries().

int lcmaps_db_parse_pair char *  pair,
char **  pvar,
char **  pval
[static]
 

Parses a database variable-value pair and returns the variable name and its value.

Parameters:
pair string containing the pair
pvar pointer to the variable string
pval pointer to the value string
Return values:
1 succes.
0 failure.

Definition at line 404 of file lcmaps_db_read.c.

References lcmaps_db_parse_string(), lcmaps_log(), and VARVAL_SEP_CHARS.

Referenced by lcmaps_db_parse_line().

int lcmaps_db_parse_string char **  pstring  )  [static]
 

Takes a string and removes prepending and trailing spaces and quotes (unless escaped).

Parameters:
pstring pointer to a pointer to a char
Return values:
1 succes.
0 failure.

Definition at line 501 of file lcmaps_db_read.c.

References lcmaps_log().

Referenced by lcmaps_db_parse_pair().

lcmaps_db_entry_t** lcmaps_db_read char *  lcmaps_db_fname  ) 
 

Read database from file.

Parameters:
lcmaps_db_fname database file.
Returns:
a pointer to the database list

Definition at line 96 of file lcmaps_db_read.c.

References lcmaps_db_entry_t, lcmaps_db_list, lcmaps_db_read_entries(), lcmaps_log(), and MAXDBENTRIES.

Referenced by startPluginManager().

int lcmaps_db_read_entries FILE *  dbstream  )  [static]
 

Read db entries from stream and fill a lsit of db entries.

Parameters:
dbstream database stream
Returns:
the number of entries found (failure --> negative number)

Definition at line 139 of file lcmaps_db_read.c.

References lcmaps_db_entry_t, lcmaps_db_fill_entry(), lcmaps_db_list, lcmaps_db_parse_line(), lcmaps_log_debug(), MAXDBENTRIES, lcmaps_db_entry_s::pluginargs, and lcmaps_db_entry_s::pluginname.

Referenced by lcmaps_db_read().


Variable Documentation

lcmaps_db_entry_t* lcmaps_db_list = NULL [static]
 

list of database entries

Definition at line 81 of file lcmaps_db_read.c.

Referenced by lcmaps_db_clean(), lcmaps_db_read(), and lcmaps_db_read_entries().


Generated on Sun May 29 21:22:12 2005 for lcmaps by doxygen 1.3.5