| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

libmsg

Page history last edited by PBworks 15 years, 12 months ago

libmsg

libmsg (libmsg.a) is a collection of tools for parsing text files.

Version: 1.0

Status: 100% completed

 


 

Description

Currently supported formats include:

  • message files
  [messageName]
  Message goes here...
  [anotherMessage]
  ...
  • .ini files
  ; An .ini file
  [Config]
  option=value      ; Some comments

 

Usage

 

Types

MSGTABLE

  • Message string contents, and a list of message section indices.

MSGSLOT

  • Indexes one section (header and contents) from the message file.

INIFILE

  • Message table, and a list of key/value pairs from all sections.

INIITEM

  • Identifies one key/value pair from the INIFILE.

 

Functions

MSGTABLE* msg_load(const char* filename, FILE* msgfile)

  • Load a message table from a file on disk or an open stream. Pass NULL for the other argument.

MSGTABLE* msg_load_string(const char *string)

  • Load a message table from a string.

MSGSLOT* msg_find(MSGTABLE* table, const char *key, int matchcase)

  • Find a section named by key in table. Pass MSG_KEY_CASE_ANY (0) in matchcase to ignore the case of the message title, or MSG_KEY_CASE_EXACT (1) for case-sensitive matching.

char* msg_get(MSGTABLE* table, const char* key, const char *prefix)

  • Find the contents of the first message named by prefix + key in table. prefix can be NULL.

 

INIFILE* ini_load_string(const char *string, int maxitems)

  • Loads an INI format file from string, with a maximum size of maxitems.

INIFILE* ini_load(const char *filename, int maxitems)

  • Loads an INI format file from the disk file filename, with a maximum size of maxitems.

int ini_get_section_count(INIFILE* ini)

  • Returns the number of sections in the INI file.

int ini_get_section_index(INIFILE* ini, const char *title, int matchcase)

  • Returns the number of items preceding the section in the key/value pair list.

const char *ini_get_section_title(INIFILE* ini, int section)

  • Returns the title of section.

int ini_get_item_count(INIFILE* ini, int section)

  • Returns the number of items in section.

INIITEM* ini_get_item(INIFILE* ini, int section, int item)

  • Returns an INIITEM structure for the item-th key/value pair in section of ini.

const char *ini_get_string(INIFILE* ini, int section, const char *key)

  • Returns the first value string from section named by key

const char *ini_get_string_iter(INIFILE* ini, int section, const char *key, void** iter)

  • Returns all value strings from section named by key

int ini_get_int(INIFILE* ini, int section, const char *key, int dflt)

  • Returns the first value from section named by key as an integer if it exists, or dflt otherwise.

int ini_get_host(INIFILE* ini, int section, const char *key)

  • Returns a network-order integer IP for an entry (name or dotted I.P. address)

void ini_free(INIFILE* ini)

  • Release the memory resources associated with this INIFILE.

 

 

 

Todo

  • hosts/smb.conf style options parsing nameserver 192.168.1.1

 

History

Version 1.0 - [John, 2008-04-24]

  • Added INI parsing support. No current need for writing.
  • Still need HOSTS section parsing. Format too simple to make writing code.
  • Keeps any default section at top of file before first section header
  • Now has an iterator to return all keys in section with a given name

Comments (0)

You don't have permission to comment on this page.