Data Structures | Functions | Variables
ift.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  IFT_KEY_AND_VALUE
 
struct  IFT
 

Functions

void libift_printdate (FILE *fp)
 
void iftSetStatus (IFT *ift, int status)
 
void iftInit (IFT *ift)
 
void iftEmpty (IFT *ift)
 
int iftPut (IFT *ift, char *key, char *value, char *cmt_type)
 
int iftRead (IFT *ift, char *filename, int is_key_required)
 
int iftWriteItem (IFT *ift, int item, FILE *fp)
 
int iftWrite (IFT *ift, char *filename)
 
int iftGet (IFT *ift, char *key)
 
int iftGetNth (IFT *ift, char *key, int n)
 
int iftFindNthKey (IFT *ift, char *str, int n)
 
int iftFindNthValue (IFT *ift, char *str, int n)
 
int iftDeleteItem (IFT *ift, int item)
 
int iftReplaceNthValue (IFT *ift, int item, char *value)
 

Variables

int IFT_TEST
 

Function Documentation

◆ iftDeleteItem()

int iftDeleteItem ( IFT ift,
int  item 
)

Remove the specified item from IFT.

Parameters
iftPointer to existing IFT
itemIndex [0..keyNr-1] of key and value to delete
Returns
0 if ok.

References IFT_TEST, iftSetStatus(), IFT::item, IFT_KEY_AND_VALUE::key, IFT::keyNr, IFT_KEY_AND_VALUE::sw, IFT_KEY_AND_VALUE::type, and IFT_KEY_AND_VALUE::value.

Here is the call graph for this function:

◆ iftEmpty()

void iftEmpty ( IFT ift)

Free memory allocated for IFT. All contents are destroyed.

Parameters
ifttarget IFT structure

References IFT::_memNr, IFT::data, IFT::datasize, IFT_TEST, IFT::item, IFT_KEY_AND_VALUE::key, IFT::keyNr, and IFT_KEY_AND_VALUE::value.

Referenced by iftRead().

◆ iftFindNthKey()

int iftFindNthKey ( IFT ift,
char *  str,
int  n 
)

Find the Nth item of IFT where the specified string is found in the key. Comparison is case sensitive.

Parameters
iftPointer to existing IFT
strPointer to the case-sensitive (partial) key string
nNth (1..keyNr-1) insidence of value is searched.
Returns
-1 if key was not found, or other negative value in case of an error, and the index [0..keyNr-1] if matching key is found.

References IFT_TEST, iftSetStatus(), IFT::item, IFT_KEY_AND_VALUE::key, and IFT::keyNr.

Here is the call graph for this function:

◆ iftFindNthValue()

int iftFindNthValue ( IFT ift,
char *  str,
int  n 
)

Find the Nth item of IFT where the specified string is found in the value. Comparison is case sensitive.

Parameters
iftPointer to existing IFT
strPointer to the case-sensitive (partial) value string
nNth (1..keyNr-1) insidence of value is searched.
Returns
-1 if key was not found, or other negative value in case of an error, and the index [0..keyNr-1] if matching value is found.

References IFT_TEST, iftSetStatus(), IFT::item, IFT::keyNr, and IFT_KEY_AND_VALUE::value.

Here is the call graph for this function:

◆ iftGet()

int iftGet ( IFT ift,
char *  key 
)

Find the key in the IFT and return the index [0..keyNr-1]. Key is case insensitive.

Parameters
iftPointer to existing IFT
keyPointer to the key string; contents are replaced by the correct key string
Returns
-1 if key was not found, or other negative value in case of an error

References IFT_TEST, iftSetStatus(), IFT::item, IFT_KEY_AND_VALUE::key, and IFT::keyNr.

Here is the call graph for this function:

◆ iftGetNth()

int iftGetNth ( IFT ift,
char *  key,
int  n 
)

Find the Nth key with similar name in the IFT and return the index [0..keyNr-1]. Key is case insensitive.

Parameters
iftPointer to existing IFT
keyPointer to the key string; contents are replaced by the correct key string
nNth (1..) insidence of key is searched.
Returns
-1 if key was not found, or other negative value in case of an error

References IFT_TEST, iftSetStatus(), IFT::item, IFT_KEY_AND_VALUE::key, and IFT::keyNr.

Here is the call graph for this function:

◆ iftInit()

void iftInit ( IFT ift)

Initiate IFT structure. This should be called once before first use.

Parameters
ifttarget ift structure

References IFT::_memNr, IFT::data, IFT::datasize, IFT_TEST, IFT::item, and IFT::keyNr.

◆ iftPut()

int iftPut ( IFT ift,
char *  key,
char *  value,
char *  cmt_type 
)

Add specified key and its value to the IFT. Also comment type (first character pointed to) can be added. Either key or value can be empty, but not both of them.

Parameters
iftPointer to initiated IFT
keyKey string; can be empty ("" or NULL)
valueValue string; can be empty ("" or NULL)
cmt_typePointer to comment character, e.g. '#' or ';' or '!' can be empty ("" or NULL)
Returns
0 if ok. Sets ift->status.

References IFT::_memNr, IFT_TEST, iftSetStatus(), IFT::item, IFT_KEY_AND_VALUE::key, IFT::keyNr, IFT_KEY_AND_VALUE::sw, IFT_KEY_AND_VALUE::type, and IFT_KEY_AND_VALUE::value.

Referenced by iftRead().

Here is the call graph for this function:

◆ iftRead()

int iftRead ( IFT ift,
char *  filename,
int  is_key_required 
)

Read IFT file keys and values. Previous contents of IFT are preserved. This function can read the initial ASCII part of files that contain also binary data.

Parameters
iftPointer to initiated but empty IFT
filenameInput filename
is_key_required0=key name is not required, 1=only lines with key and equals sign are read
Returns
Returns 0 if ok. Sets ift->status.

References IFT_TEST, iftEmpty(), iftPut(), iftSetStatus(), istime(), IFT::keyNr, strstr_noquotation(), and IFT::type.

Here is the call graph for this function:

◆ iftReplaceNthValue()

int iftReplaceNthValue ( IFT ift,
int  item,
char *  value 
)

Replaces specified value in IFT with a new value.

Parameters
iftPointer to initiated IFT
itemIndex [0..keyNr-1] of key and value
valueValue string; can be empty ("" or NULL)
Returns
0 if ok.

References IFT_TEST, iftSetStatus(), IFT::item, IFT::keyNr, and IFT_KEY_AND_VALUE::value.

Here is the call graph for this function:

◆ iftSetStatus()

void iftSetStatus ( IFT ift,
int  status 
)

Sets IFT status

Parameters
ifttarget IFT structure
statusnew status value

References ift_status, and IFT::status.

Referenced by iftDeleteItem(), iftFindNthKey(), iftFindNthValue(), iftGet(), iftGetNth(), iftPut(), iftRead(), iftReplaceNthValue(), iftWrite(), and iftWriteItem().

◆ iftWrite()

int iftWrite ( IFT ift,
char *  filename 
)

Write all keys and values.

Parameters
iftPointer to initiated but empty IFT
filenameOutput filename; string "stdout" is identified
Returns
0 if ok.

References IFT_TEST, iftSetStatus(), iftWriteItem(), and IFT::keyNr.

Here is the call graph for this function:

◆ iftWriteItem()

int iftWriteItem ( IFT ift,
int  item,
FILE *  fp 
)

Write one item in IFT to the specified file pointer.

Parameters
iftPointer to initiated but empty IFT
itemIndex [0..keyNr-1] of key and value to print
fpOutput file pointer
Returns
0 if ok.

References IFT_SPACE_AFTER_EQ_SIGN, IFT_SPACE_BEFORE_EQ_SIGN, IFT_TEST, iftSetStatus(), IFT::item, IFT_KEY_AND_VALUE::key, IFT::keyNr, IFT_KEY_AND_VALUE::type, IFT::type, and IFT_KEY_AND_VALUE::value.

Referenced by iftWrite().

Here is the call graph for this function:

◆ libift_printdate()

void libift_printdate ( FILE *  fp)

Variable Documentation

◆ IFT_TEST

int IFT_TEST