Functions | Variables
ift.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "include/ift.h"
#include "include/substitutions.h"
Include dependency graph for ift.c:

Functions

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 iftDeleteItem (IFT *ift, int item)
 
int iftReplaceNthValue (IFT *ift, int item, char *value)
 

Variables

static char * ift_status []
 

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().

◆ 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:

◆ 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().

Variable Documentation

◆ ift_status

char* ift_status[]
static
Initial value:
= {
"ok",
"fault in calling routine",
"out of memory",
"cannot open file",
"cannot write file",
"unsupported file type",
"key not found",
"file contains no data",
"value not found",
"key not found"
}

Referenced by iftSetStatus().