You need two things to handle a file format : loading and saving. One day you won't even have to provide a way to save informations because it will be possible to load a file in a format and save it in another one (this might even work in the other way (saving but no loading but I tend to prefer the first one)).
Gaby is really simple since the two functions you will have to define are load_file and save_file. It's even so simple that I'd like to say you "read the source, Luke" (vcard.c is around 6k long and is a good example).
Alternatively the functions can be named <plugin name>_load_file and <plugin name>_save_file. This alternative may become the standard way so you'd better use it.
gboolean load_file
(struct location* loc);struct location is defined in gaby.h as :
struct location { gchar *filename; gchar *type; int max_index; int offset; int reread; int timeout_tag; gboolean readonly; gboolean disabled; table *table; }; |
filename hold the name of the file you have to read;
table hold the table in which you'll put records you read.
Another thing you have to know is (logically) the record structure.
As soon as you know that the process is really simple :
Read a record from loc->filename
Store this record in a record structure.
Call record_add