libtpcmisc
 All Data Structures Files Functions Variables Enumerator Defines
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:

Go to the source code of this file.

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)
int iftdup (IFT *ift1, IFT *ift2)

Variables

static const char * ift_status []

Function Documentation

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.

Definition at line 182 of file ift.c.

References IFT_FAULT, IFT_OK, 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:

int iftdup ( IFT ift1,
IFT ift2 
)

Make a copy (duplicate) of IFT struct.

Returns:
Returns 0 (IFT_OK) when successful, otherwise an appropriate ift status code.
Parameters:
ift1Pointer to IFT struct to be copied
ift2Pointer to initiated IFT struct; any previous contents are deleted.

Definition at line 237 of file ift.c.

References IFT_FAULT, IFT_OK, IFT_TEST, iftEmpty(), iftPut(), IFT::item, IFT_KEY_AND_VALUE::key, IFT::keyNr, IFT::status, IFT_KEY_AND_VALUE::sw, IFT_KEY_AND_VALUE::type, IFT::type, and IFT_KEY_AND_VALUE::value.

Here is the call graph for this function:

void iftEmpty ( IFT ift)

Free memory allocated for IFT. All contents are destroyed.

Parameters:
ifttarget IFT structure

Definition at line 104 of file ift.c.

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 defRead(), iftdup(), and iftRead().

void iftInit ( IFT ift)

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

Parameters:
ifttarget ift structure

Definition at line 90 of file ift.c.

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

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.

Definition at line 130 of file ift.c.

References IFT::_memNr, IFT_FAULT, IFT_NOMEMORY, IFT_OK, 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 defRead(), iftdup(), and iftRead().

Here is the call graph for this function:

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.

Definition at line 215 of file ift.c.

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

Here is the call graph for this function:

void iftSetStatus ( IFT ift,
int  status 
)

Sets IFT status

Parameters:
ifttarget IFT structure
statusnew status value

Definition at line 78 of file ift.c.

References IFT_FAULT, ift_status, and IFT::status.

Referenced by defRead(), iftDeleteItem(), iftFindNthKey(), iftFindNthValue(), iftGet(), iftGetFloatValue(), iftGetFrom(), iftGetFullmatchFrom(), iftGetIntValue(), iftGetNth(), iftPut(), iftRead(), iftReplaceNthValue(), iftWrite(), and iftWriteItem().


Variable Documentation

const 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",

  0
  }

Definition at line 56 of file ift.c.

Referenced by iftSetStatus().