help-recutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using librec


From: Jose E. Marchesi
Subject: Re: Using librec
Date: Thu, 06 May 2021 13:09:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hello.

> I'm writing a personal organiser (like org-mode, but not glued to a text
> editor and instead in the terminal) and found recutils and librec, which I
> plan to use as the database format. I was reading through some of "rec.h"
> in the source repository for recutils, esp. the High Level database access
> section, but all of these functions seem to relate to creating, querying
> and inserting into a database that is solely in memory. I'm not fluent in
> programming in the UNIX environment, could someone give me pointers on if
> there is a function to read/insert/query rec files from disk? A cursory
> search points me to recutils documentation which claims that if a rec file
> isn't supplied to the recutils command, it will instead using stdin, but
> that isn't applicable for my usage.

The workflow suggested by the high-level rec.h functions is:

- You use the parser (rec_parser_*) to parse the contents of some file
  into a DB.  Something like (simplified, no error checking):

  rec_db_t db;
  FILE *file = fopen ("foo.rec", "r");
  rec_parser_t parser = rec_parser_new (file, "foo.rec");
  rec_parse_db (parser, &db);
  fclose (file);

- Now you can operate on the database, in terms of records, fields,
  constraints, etc etc.

- When you are done, write the database back to the file with the writer
  (rec_writer_*).  Something like (simplified, no error checking):

  FILE *file = fopen ("foo.rec", 
  rec_writer_t writer = rec_writer_new ("foo.rec", "w");
  rec_write_db (writer, db);
  fclose (file);

Hope this helps.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]