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 |
int iftDeleteItem | ( | IFT * | ift, |
int | item | ||
) |
Remove the specified item from IFT.
ift | Pointer to existing IFT |
item | Index [0..keyNr-1] of key and value to delete |
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.
void iftEmpty | ( | IFT * | ift | ) |
Free memory allocated for IFT. All contents are destroyed.
ift | target 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().
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.
ift | Pointer to existing IFT |
str | Pointer to the case-sensitive (partial) key string |
n | Nth (1..keyNr-1) insidence of value is searched. |
References IFT_TEST, iftSetStatus(), IFT::item, IFT_KEY_AND_VALUE::key, and IFT::keyNr.
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.
ift | Pointer to existing IFT |
str | Pointer to the case-sensitive (partial) value string |
n | Nth (1..keyNr-1) insidence of value is searched. |
References IFT_TEST, iftSetStatus(), IFT::item, IFT::keyNr, and IFT_KEY_AND_VALUE::value.
int iftGet | ( | IFT * | ift, |
char * | key | ||
) |
Find the key in the IFT and return the index [0..keyNr-1]. Key is case insensitive.
ift | Pointer to existing IFT |
key | Pointer to the key string; contents are replaced by the correct key string |
References IFT_TEST, iftSetStatus(), IFT::item, IFT_KEY_AND_VALUE::key, and IFT::keyNr.
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.
ift | Pointer to existing IFT |
key | Pointer to the key string; contents are replaced by the correct key string |
n | Nth (1..) insidence of key is searched. |
References IFT_TEST, iftSetStatus(), IFT::item, IFT_KEY_AND_VALUE::key, and IFT::keyNr.
void iftInit | ( | IFT * | ift | ) |
Initiate IFT structure. This should be called once before first use.
ift | target ift structure |
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.
ift | Pointer to initiated IFT |
key | Key string; can be empty ("" or NULL) |
value | Value string; can be empty ("" or NULL) |
cmt_type | Pointer to comment character, e.g. '#' or ';' or '!' can be empty ("" or NULL) |
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().
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.
ift | Pointer to initiated but empty IFT |
filename | Input filename |
is_key_required | 0=key name is not required, 1=only lines with key and equals sign are read |
References IFT_TEST, iftEmpty(), iftPut(), iftSetStatus(), istime(), IFT::keyNr, strstr_noquotation(), and IFT::type.
int iftReplaceNthValue | ( | IFT * | ift, |
int | item, | ||
char * | value | ||
) |
Replaces specified value in IFT with a new value.
ift | Pointer to initiated IFT |
item | Index [0..keyNr-1] of key and value |
value | Value string; can be empty ("" or NULL) |
References IFT_TEST, iftSetStatus(), IFT::item, IFT::keyNr, and IFT_KEY_AND_VALUE::value.
void iftSetStatus | ( | IFT * | ift, |
int | status | ||
) |
Sets IFT status
ift | target IFT structure |
status | new status value |
References ift_status, and IFT::status.
Referenced by iftDeleteItem(), iftFindNthKey(), iftFindNthValue(), iftGet(), iftGetNth(), iftPut(), iftRead(), iftReplaceNthValue(), iftWrite(), and iftWriteItem().
int iftWrite | ( | IFT * | ift, |
char * | filename | ||
) |
Write all keys and values.
ift | Pointer to initiated but empty IFT |
filename | Output filename; string "stdout" is identified |
References IFT_TEST, iftSetStatus(), iftWriteItem(), and IFT::keyNr.
int iftWriteItem | ( | IFT * | ift, |
int | item, | ||
FILE * | fp | ||
) |
Write one item in IFT to the specified file pointer.
ift | Pointer to initiated but empty IFT |
item | Index [0..keyNr-1] of key and value to print |
fp | Output file pointer |
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().
void libift_printdate | ( | FILE * | fp | ) |
int IFT_TEST |
Referenced by iftDeleteItem(), iftEmpty(), iftFindNthKey(), iftFindNthValue(), iftGet(), iftGetNth(), iftInit(), iftPut(), iftRead(), iftReplaceNthValue(), iftWrite(), and iftWriteItem().