recutils
rec.h
Go to the documentation of this file.
1 /* -*- mode: C -*-
2  *
3  * File: rec.h
4  * Date: Fri Feb 27 20:04:59 2009
5  *
6  * GNU recutils - Main Header
7  *
8  */
9 
10 /* Copyright (C) 2009-2019 Jose E. Marchesi */
11 
12 /* This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef GNU_REC_H
27 #define GNU_REC_H
28 
29 #include <stdbool.h>
30 #include <stdio.h>
31 #include <fcntl.h>
32 
33 /*
34  * rec format version implemented by this library.
35  */
36 
37 #define REC_VERSION_MAJOR 1
38 #define REC_VERSION_MINOR 0
39 #define REC_VERSION_STRING "1.0"
40 
41 /*
42  * INITIALIZATION of the library
43  */
44 
45 void rec_init (void);
46 void rec_fini (void);
47 
48 /*
49  * HETEROGENEOUS ORDERED SETS (MULTI-SETS)
50  *
51  * Element types: A, B, C
52  *
53  * type value next_A next_B next_C
54  * +-----+----------+-------+--------+--------+
55  * | | | | | |
56  * +-----+----------+-------+--------+--------+
57  * . . . . . .
58  * | | | | | |
59  * +-----+----------+-------+--------+--------+
60  */
61 
62 /* Opaque data type representing a multi-set. */
63 
64 typedef struct rec_mset_s *rec_mset_t;
65 
66 /* Opaque data type representing an element which is stored in the
67  multi-set. */
68 
70 
71 /* Structure to hold iterators in the stack. Note that the inner
72  structure must have the same structure than the gl_list_iterator_t
73  structure in the internal (and not distributed) gl_list.h. This
74  structure must be keep up to date. */
75 
76 typedef struct
77 {
78  void *vtable;
79  void *list;
80  size_t count;
81  void *p; void *q;
82  size_t i; size_t j;
84 
85 typedef struct
86 {
90 
91 
92 /* Data types for the callbacks that can be registered in the
93  multi-set and will be triggered to some events. */
94 
95 typedef void (*rec_mset_disp_fn_t) (void *data);
96 typedef bool (*rec_mset_equal_fn_t) (void *data1, void *data2);
97 typedef void *(*rec_mset_dup_fn_t) (void *data);
98 typedef int (*rec_mset_compare_fn_t) (void *data1, void *data2, int type2);
99 
100 
101 /* Data type representing an element type in a multi-set. This type
102  is assured to be a scalar and thus it is possible to use the
103  comparison operators, but otherwise its contents must be
104  opaque. */
105 
106 typedef int rec_mset_type_t;
107 #define MSET_ANY 0
108 
109 /*************** Creating and destroying multi-sets *****************/
110 
111 /* Create a new empty multi-set and return a reference to it. NULL is
112  returned if there is no enough memory to complete the
113  operation. */
114 
115 rec_mset_t rec_mset_new (void);
116 
117 /* Destroy a multi-set, freeing all used resources. This disposes all
118  the memory used by the mset internals, but not the data elements
119  stored in the multi-set. */
120 
122 
123 /* Create a copy of a multi-set and return a reference to it. This
124  operation performs a deep copy using the user-provided callback to
125  duplicate the elements stored in the set. NULL is returned if
126  there is no enough memory to complete the operation. */
127 
129 
130 /*************** Registering Types in a multi-set *****************/
131 
132 /* Return true if the multi-set has the specified TYPE registered.
133  Return false otherwise. Note that this function always returns
134  true when TYPE is MSET_ANY. */
135 
137 
138 /* Register a type in a multi-set. NAME must be a NULL-terminated
139  string with a unique name that will identify the type. The
140  provided callbacks will be called when needed. This function
141  returns an integer value that will identify the newly created type.
142  The only assumption user code can make about this number is that it
143  cant equal MSET_ANY. */
144 
146  char *name,
147  rec_mset_disp_fn_t disp_fn,
148  rec_mset_equal_fn_t equal_fn,
149  rec_mset_dup_fn_t dup_fn,
150  rec_mset_compare_fn_t compare_fn);
151 
152 /* Return the number of elements of the given type stored in a
153  multi-set. If TYPE is MSET_ANY then the total number of elements
154  stored in the set is returned, regardless their type. If the
155  specified type does not exist in the multi-set then this function
156  returns 0. */
157 
159 
160 /*************** Getting, inserting and removing elements **********/
161 
162 /* Get the data stored at a specific position in a mset. The returned
163  data occupies the POSITIONth position in the internal list of
164  elements of the specified type. If there is no element stored at
165  POSITION this function returns NULL. */
166 
169  size_t position);
170 
171 /* Create a new element at a specific position in a mset, storing a
172  given data. If POSITION is 0 then the element is prepended. If
173  POSITION is equal or bigger than the number of the existing
174  elements with the same type in the mset then the new element is
175  appended. The function returns the newly created element, or NULL
176  if there is not enough memory to perform the operation. */
177 
180  void *data,
181  size_t position);
182 
183 /* Insert some given data just after another element in a mset. The
184  function returns the newly created element, or NULL if there was no
185  enough memory to perform the operation. */
186 
189  void *data,
190  rec_mset_elem_t elem);
191 
192 /* Append some given daata to a mset. This is equivalent to call
193  rec_mset_insert_at specifying a position equal or bigger than the
194  number of the existing elements with type TYPE in the mset. The
195  function returns the newly created element, or NULL if there was no
196  enough memory to perform the operation. */
197 
199  rec_mset_type_t elem_type,
200  void *data,
202 
203 /* Add some given data to a mset. The position where the new element
204  is inserted depends on the sorting criteria implemented by the
205  compare_fn callback for the element type. The function returns the
206  newly created element, or NULL if there was no enough memory to
207  perform the operation. */
208 
211  void *data);
212 
213 /* Remove the element occupying the specified position from a record
214  set. This function returns true if the element was removed, and
215  false if there were no element stored at the specified
216  position. */
217 
220  size_t position);
221 
222 /* Remove an element from the multi-set. The function returns true if
223  the element was found in the list and removed. */
224 
226 
227 /* Search for an element storing the specified data in a mset and
228  return it. NULL is returned in case no element in the record set
229  is storing DATA. */
230 
232 
233 /*************** Iterating on mset elements *************************/
234 
235 /* Create and return an iterator traversing elements in the multi-set.
236  The mset contents must not be modified while the iterator is in
237  use, except for replacing or removing the last returned
238  element. */
239 
241 
242 /* Advance the iterator to the next element of the given type. The
243  data stored by the next element is stored in *DATA if DATA is
244  non-NULL and a reference to the element in *ELEM if ELEM is
245  non-NULL. The function returns true if there is a next element to
246  which iterate to, and false otherwise. */
247 
250  const void **data,
251  rec_mset_elem_t *elem);
252 
253 /* Free an iterator. */
254 
256 
257 /*************** Managing mset elements ******************************/
258 
259 /* Return the type of the given multi-set element. Since every
260  element must be of some concrete type, the returned value cannot be
261  equal to MSET_ANY. */
262 
264 
265 /* Set the type of the given multi-set element. This function is
266  useful to transform records into comments. */
267 
269 
270 /* Return a void pointer pointing to the data stored in the given mset
271  element. If no data was stored in the element then this function
272  returns NULL. */
273 
275 
276 /* Set the data stored in a multi-set element. The memory pointed by
277  the previous value of the internal pointer is not freed or altered
278  in any other way by this operation. */
279 
280 void rec_mset_elem_set_data (rec_mset_elem_t elem, void *data);
281 
282 /* Determine whether the values stored in two multi-set elements are
283  equal. The comparison is performed using the user-provided
284  compare_fn callback. */
285 
287 
288 /* Create a copy of the data stored in a mset element and return a
289  reference to it. This uses the user-provided callback to duplicate
290  the data. NULL is returned if there is no enough memory to
291  complete the operation. */
292 
294 
295 /************** Sorting, grouping and other operations **************/
296 
297 /* Sort a given multi-set using the compare_fn callbacks provided by
298  the user when defining the types of the elements stored. This is a
299  destructive operation. Returns a copy of the mset argument if the
300  operation suceeded, NULL if there is not enough memory to perform
301  the operation. */
302 
304 
305 /************************* Debugging ********************************/
306 
307 /* Dump the contents of a multi-set to the terminal. For debugging
308  purposes. */
309 
311 
312 /*
313  * FLEXIBLE BUFFERS
314  *
315  * A flexible buffer (rec_buf_t) is a buffer to which stream-like
316  * operations can be applied. Its size will grow as required.
317  */
318 
319 typedef struct rec_buf_s *rec_buf_t;
320 
321 rec_buf_t rec_buf_new (char **data, size_t *size);
322 void rec_buf_close (rec_buf_t buffer);
323 
324 /* rec_buf_putc returns the character written as an unsigned char cast
325  to an int, or EOF on error. */
326 int rec_buf_putc (int c, rec_buf_t buffer);
327 /* rec_buf_puts returns a non-negative number on success (number of
328  characters written), or EOF on error. */
329 int rec_buf_puts (const char *s, rec_buf_t buffer);
330 
331 void rec_buf_rewind (rec_buf_t buf, int n);
332 
333 /*
334  * COMMENTS
335  *
336  * A comment is a block of text. The printed representation of a
337  * comment includes a sharp (#) character after each newline (\n)
338  * character.
339  */
340 
341 typedef char *rec_comment_t;
342 
343 /* Create a new comment and return it. NULL is returned if there is
344  not enough memory to perform the operation. */
345 
346 rec_comment_t rec_comment_new (char *text);
347 
348 /* Destroy a comment, freeing all used resources. */
349 
350 void rec_comment_destroy (rec_comment_t comment);
351 
352 /* Make a copy of the passed comment and return it. NULL is returned
353  if there is not enough memory to perform the operation. */
354 
356 
357 /* Return a string containing the text in the comment. */
358 
359 char *rec_comment_text (rec_comment_t comment);
360 
361 /* Set the text of a comment. Any previous text associated with the
362  comment is destroyed and its memory freed. */
363 
364 void rec_comment_set_text (rec_comment_t *comment, char *text);
365 
366 /* Determine whether the texts stored in two given comments are
367  equal. */
368 
369 bool rec_comment_equal_p (rec_comment_t comment1, rec_comment_t comment2);
370 
371 /* FIELD NAMES
372  *
373  */
374 
375 /******************* Regexps for field names *******************/
376 
377 #define REC_FNAME_RE "[a-zA-Z%][a-zA-Z0-9_]*"
378 
379 #define REC_TYPE_NAME_RE "[a-zA-Z][a-zA-Z0-9_-]*"
380 #define REC_URL_REGEXP "(file|http|ftp|https)://[^ \t]+"
381 #define REC_FILE_REGEXP "(/?[^/ \t\n]+)+"
382 
383 /******************* Field data types **************************/
384 
385 /*
386  * The following enumeration contains identifiers for the standard
387  * fields used by the library.
388  *
389  * Changes to this enumerated value will require some fixes in
390  * rec-field-name.c.
391  */
392 
394 {
408 };
409 
410 /******************* Field name utilities **********************/
411 
412 /* Determine whether two given strings contain the same field name.
413  Note that this function does not check wheter the strings actually
414  contain valid field names. */
415 
416 bool rec_field_name_equal_p (const char *name1, const char *name2);
417 
418 /* Determine whether a given string is a correct field name. */
419 
420 bool rec_field_name_p (const char *str);
421 
422 /* Normalise a field name. Any non alphanumeric character, including
423  '_', '-' and '%', are transformed into '_'. This function returns
424  NULL if there is not enough memory to perform the operation. */
425 
426 char *rec_field_name_normalise (const char *str);
427 
428 /* Return the field name corresponding to a standard field, as defined
429  above. */
430 
431 const char *rec_std_field_name (enum rec_std_field_e std_field);
432 
433 /*
434  * FIELD EXPRESSIONS
435  *
436  * A Field expression is composed by a sequence of "elements". Each
437  * element makes a reference to one or more fields in a record.
438  */
439 
440 /* Opaque data types for field expressions and the elements stored in
441  them. */
442 
443 typedef struct rec_fex_s *rec_fex_t;
445 
447 {
451 };
452 
453 /* Regular expressions matching written fexes. */
454 
455 #define REC_FNAME_FEX_RE REC_FNAME_RE "(\\." REC_FNAME_RE ")?"
456 #define REC_FNAME_LIST_RE REC_FNAME_RE "([ \n\t]+" REC_FNAME_RE ")*"
457 #define REC_FNAME_LIST_CS_RE REC_FNAME_FEX_RE "(," REC_FNAME_FEX_RE ")*"
458 #define REC_FNAME_SUB_RE REC_FNAME_FEX_RE "(\\[[0-9]+(-[0-9]+)?\\])?"
459 #define REC_FEX_FUNCTION_NAME "[a-zA-Z_][a-zA-Z0-9_]*"
460 #define REC_FEX_CALL REC_FEX_FUNCTION_NAME "\\(" REC_FNAME_FEX_RE "\\)"
461 #define REC_FNAME_LIST_SUB_ELEM_RE "(" REC_FNAME_SUB_RE "|" REC_FEX_CALL ")" "(:" REC_FNAME_FEX_RE ")?"
462 #define REC_FNAME_LIST_SUB_RE REC_FNAME_LIST_SUB_ELEM_RE "(," REC_FNAME_LIST_SUB_ELEM_RE ")*"
463 
464 /*********** Creating and destroying field expressions ************/
465 
466 /* Parse and create a field expression, and return it. A fex kind
467  shall be specified in KIND. If STR does not contain a valid FEX of
468  the given kind then NULL is returned. If there is not enough
469  memory to perform the operation then NULL is returned. If STR is
470  NULL then an empty fex is returned. */
471 
472 rec_fex_t rec_fex_new (const char *str, enum rec_fex_kind_e kind);
473 
474 /* Destroy a field expression, freeing any used resource. */
475 
476 void rec_fex_destroy (rec_fex_t fex);
477 
478 /* Create a copy of a given fex and return a reference to it. If
479  there is not enough memory to perform the operation then NULL is
480  returned. */
481 
483 
484 /********* Getting and setting field expression properties **********/
485 
486 /* Get the number of elements stored in a field expression. */
487 
488 size_t rec_fex_size (rec_fex_t fex);
489 
490 /* Check whether a given field (or set of fields) identified by their
491  name and indexes, are contained in a fex. */
492 
493 bool rec_fex_member_p (rec_fex_t fex, const char *fname, int min, int max);
494 
495 /* Get the element of a field expression occupying the given position.
496  If the position is invalid then NULL is returned. */
497 
498 rec_fex_elem_t rec_fex_get (rec_fex_t fex, size_t position);
499 
500 /* Append an element at the end of the fex and return it. This
501  function returns NULL if there is not enough memory to perform the
502  operation. */
503 
504 rec_fex_elem_t rec_fex_append (rec_fex_t fex, const char *fname,
505  int min, int max);
506 
507 /* Determine whether all the elements of the given FEX are function
508  calls. */
509 
510 bool rec_fex_all_calls_p (rec_fex_t fex);
511 
512 /**************** Accessing field expression elements **************/
513 
514 /* Return the name of the field(s) referred by a given fex
515  element. */
516 
517 const char *rec_fex_elem_field_name (rec_fex_elem_t elem);
518 
519 /* Set the name of the field(s) referred by a given fex element. This
520  function returns 'false' if there is not enough memory to perform
521  the operation. */
522 
523 bool rec_fex_elem_set_field_name (rec_fex_elem_t elem, const char *fname);
524 
525 /* Get the 'min' index associated with the field(s) referred by a
526  given fex element. */
527 
529 
530 /* Get the 'max' index associated with the field(s) referred by a
531  given fex element. Note that if the index is unused (the element
532  refers to just one field) then -1 is returned. */
533 
535 
536 /* Get the 'rewrite_to' field name associated with the field(s) referred
537  by a given fex element. If no rewrite rule was specified in the
538  fex entry then NULL is returned. */
539 
540 const char *rec_fex_elem_rewrite_to (rec_fex_elem_t elem);
541 
542 /* Get the function name associated with a given fex element. If the
543  fex entry is not a function call then NULL is returned. */
544 
545 const char *rec_fex_elem_function_name (rec_fex_elem_t elem);
546 
547 /* Get the pointer to the context data to be used in the function
548  call, if any. */
549 
551 
552 /*********** Miscellaneous field expressions functions ************/
553 
554 /* Check whether a given string STR contains a proper fex description
555  of type KIND. */
556 
557 bool rec_fex_check (const char *str, enum rec_fex_kind_e kind);
558 
559 /* Sort the elements of a fex using the 'min' index of the elements as
560  the sorting criteria. */
561 
562 void rec_fex_sort (rec_fex_t fex);
563 
564 /* Get the written form of a field expression. This function returns
565  NULL if there is not enough memory to perform the operation. */
566 
567 char *rec_fex_str (rec_fex_t fex, enum rec_fex_kind_e kind);
568 
569 /*
570  * FIELD TYPES
571  *
572  */
573 
575  {
576  /* Unrestricted. */
578  /* An integer number. */
580  /* A Boolean. */
582  /* An integer number within a given range. */
584  /* A real number. */
586  /* A string with a limitation on its size. */
588  /* A line. */
590  /* A regexp. */
592  /* A date. */
594  /* An Enumeration. */
596  /* A field name. */
598  /* An email. */
600  /* An universally unique identifier (uuid). */
602  /* A foreign key. */
604  };
605 
606 typedef struct rec_type_s *rec_type_t;
607 
608 /* Create a new type based on the textual description in STR. */
609 rec_type_t rec_type_new (const char *str);
610 
611 /* Destroy a type. */
612 void rec_type_destroy (rec_type_t type);
613 
614 /* Determine whether a string contains a valid type description. */
615 bool rec_type_descr_p (const char *str);
616 
617 /* Get the kind of the type. The _str version returns a string with
618  the name of the type. */
620 char *rec_type_kind_str (rec_type_t type);
621 
622 /* Get the min and max parametes of a range type. If the type does
623  not define a range then -1 is returned. */
624 int rec_type_min (rec_type_t type);
625 int rec_type_max (rec_type_t type);
626 
627 /* Get the record set name of a rec type. If the type does not define
628  a rec then NULL is returned. */
629 const char *rec_type_rec (rec_type_t type);
630 
631 /* Get and set the name of a type. Types are created anonymous by
632  rec_type_new, so the getter will return NULL unless a name is
633  set. */
634 const char *rec_type_name (rec_type_t type);
635 void rec_type_set_name (rec_type_t type, const char *name);
636 
637 /* Determine whether two types are the same type.
638  *
639  * Two types are equal if,
640  *
641  * - They are of the same kind, and
642  *
643  * - Depending on the kind of types:
644  *
645  * + For sizes
646  *
647  * The maximum size specified in both types is the same.
648  *
649  * + For ranges
650  *
651  * The ranges specified in both types are the same.
652  *
653  * + For enums
654  *
655  * Both enums have the same number of entries, they are identical
656  * and in the same order.
657  *
658  * + For regexps
659  *
660  * They are never equal.
661  */
662 bool rec_type_equal_p (rec_type_t type1, rec_type_t type2);
663 
664 /* Check the contents of a string against a type. In case some error
665  arises, return it in ERROR_STR if it is not NULL. */
666 
667 bool rec_type_check (rec_type_t type, const char *str, char **error_str);
668 
669 /* Compare two values of a given type. The comparison criteria will
670  vary depending of the given type: numerical for ints and reals,
671  time comparison for dates, etc. If TYPE is NULL then a
672  lexicographic comparison is performed. Return -1 if VAL1 < VAL2, 0
673  if VAL1 == VAL2 and 1 if VAL1 > VAL2. */
674 
675 int rec_type_values_cmp (rec_type_t type, const char *val1, const char *val2);
676 
677 /*
678  * TYPE REGISTRIES.
679  *
680  * Type registries are collections of named types. The following API
681  * provides facilities to maintain type registries.
682  */
683 
685 
686 /* Create and return an empty type registry. NULL is returned if
687  there is not enough memory to perform the operation. */
688 
690 
691 /* Destroy a type registry, freeing resources. */
693 
694 /* Insert a new type in the type registry. If a type with the same
695  name already exists in the registry then it gets replaced. */
697 
698 /* Insert a new type in the type registry as a synonim of another
699  type. If a type with the same name already exists in the registry
700  then it gets replaced. */
701 void rec_type_reg_add_synonym (rec_type_reg_t reg, const char *type_name,
702  const char *to_name);
703 
704 /* Get the type named TYPE_NAME stored in REG. If it does not exist
705  NULL is returned. */
706 rec_type_t rec_type_reg_get (rec_type_reg_t reg, const char *type_name);
707 
708 /*
709  * FIELDS
710  *
711  * A field is an association between a label and a value.
712  */
713 
714 /* Opaque data type representing a field. */
715 
716 typedef struct rec_field_s *rec_field_t;
717 
718 /*************** Creating and destroying fields *****************/
719 
720 /* Create a new field and return a reference to it. NULL is returned
721  if there is no enough memory to perform the operation. */
722 
723 rec_field_t rec_field_new (const char *name, const char *value);
724 
725 /* Destroy a field freeing all used resources. This disposes all the
726  memory used by the field internals. */
727 
728 void rec_field_destroy (rec_field_t field);
729 
730 /* Create a copy of a field and return a reference to it. This
731  operation performs a deep copy of the contents of the field. NULL
732  is returned if there is no enough memory to perform the
733  operation. */
734 
736 
737 /******************** Comparing fields ****************************/
738 
739 /* Determine wether two given fields are equal (i.e. they have equal
740  names but possibly different values). */
741 
742 bool rec_field_equal_p (rec_field_t field1, rec_field_t field2);
743 
744 /************ Getting and Setting field properties *****************/
745 
746 /* Return a NULL terminated string containing the name of a field.
747  Note that this function can't return the empty string for a
748  properly initialized field. */
749 
750 const char *rec_field_name (rec_field_t field);
751 
752 /* Set the name of a field. This function returns 'false' if there is
753  not enough memory to perform the operation. */
754 
755 bool rec_field_set_name (rec_field_t field, const char *name);
756 
757 /* Return a NULL terminated string containing the value of a field,
758  i.e. the string stored in the field. The returned string may be
759  empty if the field has no value, but never NULL. */
760 
761 const char *rec_field_value (rec_field_t field);
762 
763 /* Set the value of a given field to the given string. This function
764  returns 'false' if there is not enough memory to perform the
765  operation. */
766 
767 bool rec_field_set_value (rec_field_t field, const char *value);
768 
769 /* Return a string describing the source of the field. The specific
770  meaning of the source depends on the user: it may be a file name,
771  or something else. This function returns NULL for a field for
772  which a source was never set. */
773 
774 const char *rec_field_source (rec_field_t field);
775 
776 /* Set a string describing the source of the field. Any previous
777  string associated to the field is destroyed and the memory it
778  occupies is freed. This function returns 'false' if there is not
779  enough memory to perform the operation. */
780 
781 bool rec_field_set_source (rec_field_t field, const char *source);
782 
783 /* Return an integer representing the location of the field within its
784  source. The specific meaning of the location depends on the user:
785  it may be a line number, or something else. This function returns
786  0 for fields not having a defined source. */
787 
788 size_t rec_field_location (rec_field_t field);
789 
790 /* Return the textual representation for the location of a field
791  within its source. This function returns NULL for fields not
792  having a defined source. */
793 
794 const char *rec_field_location_str (rec_field_t field);
795 
796 /* Set a number as the new location for the given field. Any
797  previously stored location is forgotten. This function returns
798  'false' if there is not enough memory to perform the operation. */
799 
800 bool rec_field_set_location (rec_field_t field, size_t location);
801 
802 /* Return an integer representing the char location of the field
803  within its source. The specific meaning of the location depends on
804  the user, usually being the offset in bytes since the beginning of
805  a file or memory buffer. This function returns 0 for fields not
806  having a defined source. */
807 
808 size_t rec_field_char_location (rec_field_t field);
809 
810 /* Return the textual representation for the char location of a field
811  within its source. This function returns NULL for fields not
812  having a defined source. */
813 
814 const char *rec_field_char_location_str (rec_field_t field);
815 
816 /* Set a number as the new char location for the given field. Any
817  previously stored char location is forgotten. This function
818  returns 'false' if there is not enough memory to perform the
819  operation. */
820 
822 
823 /* Get/set the mark of a given field, which is an integer associated
824  to the field ADT. */
825 
826 void rec_field_set_mark (rec_field_t field, int mark);
827 int rec_field_mark (rec_field_t field);
828 
829 /********************* Transformations in fields ********************/
830 
831 /* Get the textual representation of a field and make it a comment
832  variable. This function returns NULL if there is no enough memory
833  to perform the operation. */
834 
836 
837 /*
838  * RECORDS
839  *
840  * A record is an ordered set of one or more fields intermixed with
841  * comment blocks.
842  */
843 
844 /* Opaque data type representing a record. */
845 
846 typedef struct rec_record_s *rec_record_t;
847 
848 /* Record mset types. Note that the following constants are relying
849  on the fact the multi-sets assign consecutive type ids starting
850  with 1. This is done this way for performance reasons, but it
851  means that this constants must be ajusted in case the order in
852  which the types are registered in rec_record_new changes. */
853 
854 #define MSET_FIELD 1
855 #define MSET_COMMENT 2
856 
857 /*************** Creating and destroying records *****************/
858 
859 /* Create a new empty record and return a reference to it. NULL is
860  returned if there is no enough memory to perform the operation. */
861 
863 
864 /* Destroy a record, freeing all used resources. This disposes all
865  the memory used by the record internals, including any stored field
866  or comment. */
867 
868 void rec_record_destroy (rec_record_t record);
869 
870 /* Create a copy of a record and return a reference to it. This
871  operation performs a deep copy of the contained fields and
872  comments. NULL is returned if there is no enough memory to perform
873  the operation. */
874 
876 
877 /******************** Comparing records ***************************/
878 
879 /* Determine whether a given record is a subset of another record. A
880  record 'A' is a subset of a record 'B' if and only if for every
881  field or comment contained in 'A' there is an equivalent field or
882  comment in 'B'. The order of the elements is not relevant. */
883 
884 bool rec_record_subset_p (rec_record_t record1, rec_record_t record2);
885 
886 /* Determine whether a given record is equal to another record. A
887  record 'A' is equal to a record 'B' if the 'A' is a subset of 'B'
888  and 'B' is a subset of 'A'. */
889 
890 bool rec_record_equal_p (rec_record_t record1, rec_record_t record2);
891 
892 /************ Getting and Setting record properties ****************/
893 
894 /* Return the multi-set containing the elements stored by the given
895  record. */
896 
898 
899 /* Return the number of elements stored in the given record, of any
900  type. */
901 
902 size_t rec_record_num_elems (rec_record_t record);
903 
904 /* Return the number of fields stored in the given record. */
905 
906 size_t rec_record_num_fields (rec_record_t record);
907 
908 /* Return the number of comments stored in the given record. */
909 
910 size_t rec_record_num_comments (rec_record_t record);
911 
912 /* Return a string describing the source of the record. The specific
913  meaning of the source depends on the user: it may be a file name,
914  or something else. This function returns NULL for a record for
915  which a source was never set. */
916 
917 char *rec_record_source (rec_record_t record);
918 
919 /* Set a string describing the source of the record. Any previous
920  string associated to the record is destroyed and the memory it
921  occupies is freed. */
922 
923 void rec_record_set_source (rec_record_t record, char *source);
924 
925 /* Return an integer representing the location of the record within
926  its source. The specific meaning of the location depends on the
927  user: it may be a line number, or something else. This function
928  returns 0 for records not having a defined source. */
929 
930 size_t rec_record_location (rec_record_t record);
931 
932 /* Return the textual representation for the location of a record
933  within its source. This function returns NULL for records not
934  having a defined source. */
935 
937 
938 /* Set a number as the new location for the given record. Any
939  previously stored location is forgotten. */
940 
941 void rec_record_set_location (rec_record_t record, size_t location);
942 
943 /* Return an integer representing the char location of the record
944  within its source. The specific meaning of the location depends on
945  the user, usually being the offset in bytes since the beginning of
946  a file or memory buffer. This function returns 0 for records not
947  having a defined source. */
948 
949 size_t rec_record_char_location (rec_record_t record);
950 
951 /* Return the textual representation for the char location of a record
952  within its source. This function returns NULL for records not
953  having a defined source. */
954 
956 
957 /* Set a number as the new char location for the given record. Any
958  previously stored char location is forgotten. */
959 
961 
962 
963 /* Return the position occupied by the specified field in the
964  specified records, not considering comments. */
965 
967 
968 /* Return the position occupied by the specified field in the
969  specified record among the fields having the same name. Thus, if
970  the provided field is the first having its name in the record then
971  the function returns 0. If it is the third then the function
972  returns 2. */
973 
975 
976 /* Determine whether a record contains some field whose value is STR.
977  The string comparison can be either case-sensitive or
978  case-insensitive. */
979 
980 bool rec_record_contains_value (rec_record_t record, const char *value, bool case_insensitive);
981 
982 /* Determine whether a record contains a field whose name is
983  FIELD_NAME and value FIELD_VALUE. */
984 
985 bool rec_record_contains_field (rec_record_t record, const char *field_name, const char *field_value);
986 
987 /* Determine whether a given record contains a field named after a
988  given field name. */
989 
990 bool rec_record_field_p (rec_record_t record, const char *field_name);
991 
992 /* Return the number of fields name after a given field name stored in
993  a record. */
994 
996  const char *field_name);
997 
998 /* Return the Nth field named after the given field name in a record.
999  This function returns NULL if there is no such a field. */
1000 
1002  const char *field_name,
1003  size_t n);
1004 
1005 /* Remove the Nth field named after the given field name in a
1006  record. */
1007 
1009  const char *field_name,
1010  size_t n);
1011 
1012 /* Return the 'container pointer' of a record. It is a pointer which
1013  is used by the user of the record. This function returns NULL if
1014  no container pointer has been set in the record. */
1015 
1016 void *rec_record_container (rec_record_t record);
1017 
1018 /* Set the 'container pointer' of a record, replacing any previous
1019  value. */
1020 
1021 void rec_record_set_container (rec_record_t record, void *container);
1022 
1023 /********************* Transformations in records *******************/
1024 
1025 /* Get the textual representation of a record and make it a comment
1026  variable. This function returns NULL if there is no enough memory
1027  to perform the operation. */
1028 
1030 
1031 /* Remove duplicated fields in a given record. Fields are compared by
1032  field name and value. */
1033 
1034 void rec_record_uniq (rec_record_t record);
1035 
1036 /* Append two records. This function adds all the fields in
1037  SRC_RECORD to DEST_RECORD. */
1038 
1039 void rec_record_append (rec_record_t dest_record, rec_record_t src_record);
1040 
1041 /********************* Field Marks in records **********************/
1042 
1043 /* Reset the marks of all fields in a given records, setting all the
1044  marks to 0. */
1045 
1046 void rec_record_reset_marks (rec_record_t record);
1047 
1048 /* Set the mark of a given field. Return true if the field is marked
1049  as desired. Return false if the field is not stored in the
1050  record. */
1051 
1052 bool rec_record_mark_field (rec_record_t record, rec_field_t field, int mark);
1053 
1054 /* Get the mark associated to a field in a record. If the given field
1055  is not found in the record then return 0. */
1056 
1057 int rec_record_field_mark (rec_record_t record, rec_field_t field);
1058 
1059 /*
1060  * RECORD SETS
1061  *
1062  * A record set is an ordered set of zero or more records and comments
1063  * maybe preceded by a record descriptor.
1064  */
1065 
1066 #define REC_RECORD_TYPE_RE REC_FNAME_RE
1067 
1068 /* Opaque data type representing a record set. */
1069 
1070 typedef struct rec_rset_s *rec_rset_t;
1071 
1072 /* Opaque data type representing a selection expression. This is
1073  placed here as a forward declaration. See below in this file for
1074  the definition of the selection expressions stuff. */
1075 
1076 typedef struct rec_sex_s *rec_sex_t;
1077 
1078 /* Record set mset types. MSET_COMMENT is defined above. */
1079 
1080 #define MSET_RECORD 1
1081 
1082 /************ Creating and destroying record sets **************/
1083 
1084 /* Create a new empty record set and return a reference to it. NULL
1085  is returned if there is no enough memory to perform the
1086  operation. */
1087 
1088 rec_rset_t rec_rset_new (void);
1089 
1090 /* Destroy a record set, freeing all user resources. This disposes
1091  all the memory used by the record internals, including any stored
1092  record or comment. */
1093 
1094 void rec_rset_destroy (rec_rset_t rset);
1095 
1096 /* Create a copy of a record set and return a reference to it. This
1097  operation performs a deep copy of the contained records and
1098  comments. NULL is returned if there is no enough memory to perform
1099  the operation. */
1100 
1102 
1103 /********* Getting and Setting record set properties *************/
1104 
1105 /* Return the multi-set containing the elements stored by the given
1106  record set. */
1107 
1109 
1110 /* Return the number of elements stored in the given record set, of
1111  any type. */
1112 
1113 size_t rec_rset_num_elems (rec_rset_t rset);
1114 
1115 /* Return the number of records stored in the given record set. */
1116 
1117 size_t rec_rset_num_records (rec_rset_t rset);
1118 
1119 /* Return the number of comments stored in the given record set. */
1120 
1121 size_t rec_rset_num_comments (rec_rset_t rset);
1122 
1123 /***************** Record descriptor management ******************/
1124 
1125 /* Return the record descriptor of a given record set. NULL is
1126  returned if the record set does not feature a record
1127  descriptor. */
1128 
1130 
1131 /* Set a new record descriptor for a given record set. If there was
1132  previously a record descriptor in the rset then it is destroyed.
1133  This function performs all the requires updates to the semantics
1134  associated with record sets, such as the type registry, size
1135  constraints, etc. If RECORD is NULL then the record set wont
1136  feature a record descriptor. */
1137 
1138 void rec_rset_set_descriptor (rec_rset_t rset, rec_record_t record);
1139 
1140 /* Return the relative position of the descriptor with respect the
1141  first element in the record set. For example, if there are two
1142  comments before the record descriptor in the record set then this
1143  function returns 3. */
1144 
1145 size_t rec_rset_descriptor_pos (rec_rset_t rset);
1146 
1147 /* Set the relative position of the descriptor with respect the first
1148  element in the record set. See the documentation for
1149  rec_rset_descriptor_pos for details. */
1150 
1151 void rec_rset_set_descriptor_pos (rec_rset_t rset, size_t position);
1152 
1153 /* Return the URL associated with a record set (external descriptor).
1154  NULL is returned if the record set does not feature a record
1155  descriptor, or if the record set is not featuring an external
1156  descriptor. */
1157 
1158 char *rec_rset_url (rec_rset_t rset);
1159 
1160 /* Return the type name of a record set. NULL is returned if the
1161  record set does not feature a record descriptor. */
1162 
1163 char *rec_rset_type (rec_rset_t rset);
1164 
1165 /* Set the type name of a record set. If there was not a record
1166  descriptor in the rset then it is created with a single %rec field.
1167  In case there was an existing descriptor in the rset then it is
1168  updated to reflect the new name. */
1169 
1170 void rec_rset_set_type (rec_rset_t rset, const char *type);
1171 
1172 /************ Management of the type registry ***********************/
1173 
1174 /* Return the type registry of a record set. Note that the registry
1175  will be empty for a newly created rset. */
1176 
1178 
1179 /* Return the declared type for fields named after the provided field
1180  name in a record set. NULL is returned if no such a type is
1181  found. */
1182 
1184  const char *field_name);
1185 
1186 /********************** Size constraints ****************************/
1187 
1188 /* Return the minimum number of records allowed for a rset in its
1189  record descriptor. This is 0 for record sets for which no size
1190  constraints have been defined. */
1191 
1192 size_t rec_rset_min_records (rec_rset_t rset);
1193 
1194 /* Return the maximum number of records allowed for a rset in its
1195  record descriptor. This is SIZE_MAX for record sets for which no
1196  size constraints have been defined. */
1197 
1198 size_t rec_rset_max_records (rec_rset_t rset);
1199 
1200 /********************** Sex constraints *****************************/
1201 
1202 /* Return the number of sex constraints defined in a record set. This
1203  is 0 for record sets for which no sex constraints have been
1204  defined. */
1205 
1207 
1208 /* Return a given sex constraint defined in a record sex. The
1209  provided index must be between 0 and the value returned by
1210  rec_rset_num_sex_constraints - 1. */
1211 
1212 rec_sex_t rec_rset_sex_constraint (rec_rset_t rset, size_t index);
1213 
1214 
1215 /********************** Other functionality *************************/
1216 
1217 /* Rename a field in a record descriptor. Field names are not
1218  modified in the records themselves, but only in the record
1219  descriptor. Note that the comparisons of the field names are
1220  EQL. */
1221 
1223  const char *field_name,
1224  const char *new_field_name);
1225 
1226 /* Return a fex with the names of all the fields defined as
1227  auto-incremented fields in a record set. */
1228 
1230 
1231 /* Return the name of the key field of the record set. If the record
1232  set does not have a key defined then return NULL. */
1233 
1234 const char *rec_rset_key (rec_rset_t rset);
1235 
1236 /* Return a fex with the names of all the fields defined as
1237  confidential fields in a record set. */
1238 
1240 
1241 /* Determine whether a given field name corresponds to a confidential
1242  field in a record set. */
1243 
1244 bool rec_rset_field_confidential_p (rec_rset_t rset, const char *field_name);
1245 
1246 /* Return a string describing the source of the record set. The
1247  specific meaning of the source depends on the user: it may be a
1248  file name, or something else. This function returns NULL for a
1249  record set for which a source was never set. */
1250 
1251 char *rec_rset_source (rec_rset_t rset);
1252 
1253 /* Set an orderd set of of field names that will be used as the
1254  sorting criteria for a record set. The field names will take
1255  precedence to any other way to define the sorting criteria, such as
1256  the %sort special field in the record descriptor. This function
1257  returns 'false' if there is not enough memory to perform the
1258  operation. */
1259 
1260 bool rec_rset_set_order_by_fields (rec_rset_t rset, rec_fex_t field_names);
1261 
1262 /* Return the field names that are used to sort a record set. */
1263 
1265 
1266 /* Sort a record set. The SORT_BY parameter is a fex that, if non
1267  NULL, contains the field names which will be used as the sorting
1268  criteria. If no SORT_BY fields is specified then whatever sorting
1269  criteria specified in the record set is used. If no sorting
1270  criteria exists then the function is a no-op. The function returns
1271  a copy of RSET or NULL if there is not enough memory to perform the
1272  operation. */
1273 
1275 
1276 /* Group the records of a record set by the given fields in GROUP_BY.
1277  The given record set must be sorted by GROUP_BY. Note that this
1278  function uses the first field with the given names found in a
1279  record, ignoring any subsequent field. It is up to the user to
1280  provide the right records in order to get the desired results. The
1281  function returns a copy of RSET or NULL if there was not enough
1282  memory to perform the operation. */
1283 
1285 
1286 /* Add missing auto fields defined in a record set to a given record.
1287  The record could not be stored in the record set used to determine
1288  which auto fields to add. This function is a no-operation if the
1289  given record set is not defining any auto field, or if the passed
1290  record already contains all fields marked as auto in the record
1291  set. The function returns a copy of RSET or NULL if there was not
1292  enough memory to perform the operation. */
1293 
1295 
1296 /*
1297  * DATABASES
1298  *
1299  * A database is an ordered set of zero or more record sets.
1300  */
1301 
1302 /* Opaque type representing a database. */
1303 
1304 typedef struct rec_db_s *rec_db_t;
1305 
1306 /* Opaque data type representing a registry of aggregates. This is
1307  placed here as a forward declaration. See below in this file for
1308  the description of field functions. */
1309 
1311 
1312 /************ Creating and destrying databases *********************/
1313 
1314 /* Create a new empty database and return it. This function returns
1315  NULL if there is not enough memory to perform the operation. */
1316 
1317 rec_db_t rec_db_new (void);
1318 
1319 /* Destroy a database, freeing any used memory. This means that all
1320  the record sets contained in the database are also destroyed. */
1321 
1322 void rec_db_destroy (rec_db_t db);
1323 
1324 /*********** Getting and setting properties of databases **********/
1325 
1326 /* Return the number of record sets contained in a given record
1327  set. */
1328 
1329 size_t rec_db_size (rec_db_t db);
1330 
1331 /*********** Managing record sets in a database *******************/
1332 
1333 /* Return the record set occupying the given position in the database.
1334  If no such record set is contained in the database then NULL is
1335  returned. */
1336 
1337 rec_rset_t rec_db_get_rset (rec_db_t db, size_t position);
1338 
1339 /* Insert the given record set into the given database at the given
1340  position. If POSITION >= rec_rset_size (DB), RSET is appended to
1341  the list of fields. If POSITION < 0, RSET is prepended. Otherwise
1342  RSET is inserted at the specified position. If the rset is inserted
1343  then 'true' is returned. If there is an error then 'false' is
1344  returned. */
1345 
1346 bool rec_db_insert_rset (rec_db_t db, rec_rset_t rset, size_t position);
1347 
1348 /* Remove the record set contained in the given position into the
1349  given database. If POSITION >= rec_db_size (DB), the last record
1350  set is deleted. If POSITION <= 0, the first record set is deleted.
1351  Otherwise the record set occupying the specified position is
1352  deleted. If a record set has been removed then 'true' is returned.
1353  If there is an error or the database has no record sets 'false' is
1354  returned. */
1355 
1356 bool rec_db_remove_rset (rec_db_t db, size_t position);
1357 
1358 /* Determine whether an rset named TYPE exists in a database. If TYPE
1359  is NULL then it refers to the default record set. */
1360 
1361 bool rec_db_type_p (rec_db_t db, const char *type);
1362 
1363 /* Get the rset with the given type from db. This function returns
1364 NULL if there is no a record set having that type. */
1365 
1366 rec_rset_t rec_db_get_rset_by_type (rec_db_t db, const char *type);
1367 
1368 /******************** Miscellaneous database functions ****************/
1369 
1370 /* Return the registry of aggregates of the given database. */
1371 
1373 
1374 /******************** Database High-Level functions *******************/
1375 
1376 /* Query for some data in a database. The resulting data is returned
1377  in a record set.
1378 
1379  This function takes the following arguments:
1380 
1381  DB
1382 
1383  Database to query.
1384 
1385  TYPE
1386 
1387  The type of records to query. This string must identify a
1388  record set contained in the database. If TYPE is NULL then the
1389  default record set, if any, is queried.
1390 
1391  JOIN
1392 
1393  If not NULL, this argument must be a string denoting a field
1394  name. This field name must be a foreign key (field of type
1395  'rec') defined in the selected record set. The query operation
1396  will do an inner join using T1.Field = T2.Field as join
1397  criteria.
1398 
1399  INDEX
1400 
1401  If not NULL, this argument is a pointer to a buffer containing
1402  pairs of Min,Max indexes, identifying intervals of valid
1403  records. The list of ends with the pair
1404  REC_Q_NOINDEX,REC_Q_NOINDEX.
1405 
1406  INDEX is mutually exclusive with any other selection option.
1407 
1408  SEX
1409 
1410  Selection expression which is evaluated for every record in the
1411  referred record set. If SEX is NULL then all records are
1412  selected.
1413 
1414  This argument is mutually exclusive with any other selection
1415  option.
1416 
1417  FAST_STRING
1418 
1419  If this argument is not NULL then it is a string which is used
1420  as a fixed pattern. Records featuring fields containing
1421  FAST_STRING as a substring in their values are selected.
1422 
1423  This argument is mutually exclusive with any other selection
1424  option.
1425 
1426  RANDOM
1427 
1428  If not 0, this argument indicates the number of random records
1429  to select from the referred record set.
1430 
1431  This argument is mutually exclusive with any other selection
1432  option.
1433 
1434  FEX
1435 
1436  Field expression to apply to the matching records to build the
1437  records in the result record set. If FEX is NULL then the
1438  matching records are unaltered.
1439 
1440  PASSWORD
1441 
1442  Password to use to decrypt confidential fields. If the password
1443  does not work then the encrypted fields are returned as-is. If
1444  PASSWORD is NULL, or if it is the empty string, then no attempt
1445  to decrypt encrypted fields will be performed.
1446 
1447  GROUP_BY
1448 
1449  If not NULL, group the record set by the given field names.
1450 
1451  SORT_BY
1452 
1453  If not NULL, sort the record set by the given field names.
1454 
1455  FLAGS
1456 
1457  ORed value of any of the following flags:
1458 
1459  REC_Q_DESCRIPTOR
1460 
1461  If set returned record set will feature a record descriptor. If
1462  the query is involving a single record set then the descriptor
1463  will be a copy of the descriptor of the referred record set, and
1464  will feature the same record type name. Otherwise it will be
1465  built from the several descriptors of the involved record sets,
1466  and the record type name will be formed concatenating the type
1467  names of the involved record sets. If this flag is not
1468  activated then the returned record set won't feature a record
1469  descriptor.
1470 
1471  REC_Q_ICASE
1472 
1473  If set the string operations in the selection expression will be
1474  case-insensitive. If FALSE any string operation will be
1475  case-sensitive.
1476 
1477  This function returns NULL if there is not enough memory to
1478  perform the operation. */
1479 
1480 #define REC_F_DESCRIPTOR 1
1481 #define REC_F_ICASE 2
1482 #define REC_F_UNIQ 4
1483 
1484 #define REC_Q_NOINDEX ((size_t)-1)
1485 
1487  const char *type,
1488  const char *join,
1489  size_t *index,
1490  rec_sex_t sex,
1491  const char *fast_string,
1492  size_t random,
1493  rec_fex_t fex,
1494  const char *password,
1495  rec_fex_t group_by,
1496  rec_fex_t sort_by,
1497  int flags);
1498 
1499 /* Insert a new record into a database, either appending it to some
1500  record set or replacing one or more existing records.
1501 
1502  This function takes the following arguments:
1503 
1504  DB
1505 
1506  Database where to insert the record.
1507 
1508  TYPE
1509 
1510  Type of the new record. If there is an existing record set
1511  holding records of that type then the record is added to it.
1512  Otherwise a new record set is appended into the database.
1513 
1514  INDEX
1515 
1516  If not NULL, this argument is a pointer to a buffer containing
1517  pairs of Min,Max indexes, identifying intervals of records that
1518  will be replaced by copies of the provided record. The list of
1519  ends with the pair REC_Q_NOINDEX,REC_Q_NOINDEX.
1520 
1521  INDEX is mutually exclusive with any other selection option.
1522 
1523  SEX
1524 
1525  Selection expression which is evaluated for every record in the
1526  referred record set. If SEX is NULL then all records are
1527  selected.
1528 
1529  This argument is mutually exclusive with any other selection
1530  option.
1531 
1532  FAST_STRING
1533 
1534  If this argument is not NULL then it is a string which is used
1535  as a fixed pattern. Records featuring fields containing
1536  FAST_STRING as a substring in their values are selected.
1537 
1538  This argument is mutually exclusive with any other selection
1539  option.
1540 
1541  RANDOM
1542 
1543  If not 0, this argument indicates the number of random records
1544  to select from the referred record set.
1545 
1546  This argument is mutually exclusive with any other selection
1547  option.
1548 
1549  PASSWORD
1550 
1551  Password to use to crypt confidential fields. If PASSWORD is
1552  NULL, or if it is the empty string, then no attempt to crypt
1553  confidential fields will be performed.
1554 
1555  RECORD
1556 
1557  Record to insert. If more than one record is replaced in the
1558  database they will be substitued with copies of this record.
1559 
1560  FLAGS
1561 
1562  ORed value of any of the following flags:
1563 
1564  REC_F_ICASE
1565 
1566  If set the string operations in the selection expression will be
1567  case-insensitive. If FALSE any string operation will be
1568  case-sensitive.
1569 
1570  REC_F_NOAUTO
1571 
1572  If set then no auto-fields will be added to the newly created
1573  records in the database.
1574 
1575  If no selection option is used then the new record is appended to
1576  either an existing record set identified by TYPE or to a newly
1577  created record set. If some selection option is used then the
1578  matching existing records will be replaced.
1579 
1580  This function returns 'false' if there is not enough memory to
1581  perform the operation. */
1582 
1583 #define REC_F_NOAUTO 8
1584 
1585 bool rec_db_insert (rec_db_t db,
1586  const char *type,
1587  size_t *index,
1588  rec_sex_t sex,
1589  const char *fast_string,
1590  size_t random,
1591  const char *password,
1592  rec_record_t record,
1593  int flags);
1594 
1595 /* Delete records from a database, either physically removing them or
1596  commenting them out.
1597 
1598  This function takes the following arguments:
1599 
1600  DB
1601 
1602  Database where to remove records.
1603 
1604  TYPE
1605 
1606  Type of the records to remove.
1607 
1608  INDEX
1609 
1610  If not NULL, this argument is a pointer to a buffer containing
1611  pairs of Min,Max indexes, identifying intervals of records that
1612  will be deleted or commented out. The list of ends with the pair
1613  REC_Q_NOINDEX,REC_Q_NOINDEX.
1614 
1615  INDEX is mutually exclusive with any other selection option.
1616 
1617  SEX
1618 
1619  Selection expression which is evaluated for every record in the
1620  referred record set. If SEX is NULL then all records are
1621  selected.
1622 
1623  This argument is mutually exclusive with any other selection
1624  option.
1625 
1626  FAST_STRING
1627 
1628  If this argument is not NULL then it is a string which is used
1629  as a fixed pattern. Records featuring fields containing
1630  FAST_STRING as a substring in their values are selected.
1631 
1632  This argument is mutually exclusive with any other selection
1633  option.
1634 
1635  RANDOM
1636 
1637  If not 0, this argument indicates the number of random records
1638  to select for deletion in the referred record set.
1639 
1640  This argument is mutually exclusive with any other selection
1641  option.
1642 
1643  FLAGS
1644 
1645  ORed value of any of the following flags:
1646 
1647  REC_F_ICASE
1648 
1649  If set the string operations in the selection expression will be
1650  case-insensitive. If FALSE any string operation will be
1651  case-sensitive.
1652 
1653  REC_F_COMMENT_OUT
1654 
1655  If set the selected records will be commented out instead of physically
1656  removed from the database.
1657 
1658  This function returns 'false' if there is not enough memory to
1659  perform the operation. */
1660 
1661 #define REC_F_COMMENT_OUT 16
1662 
1663 bool rec_db_delete (rec_db_t db,
1664  const char *type,
1665  size_t *index,
1666  rec_sex_t sex,
1667  const char *fast_string,
1668  size_t random,
1669  int flags);
1670 
1671 /* Manipulate the fields of the selected records in a database: remove
1672  them, set their values or rename them.
1673 
1674  This function takes the following arguments:
1675 
1676  DB
1677 
1678  Database where to set fields.
1679 
1680  TYPE
1681 
1682  Type of the records to act in.
1683 
1684  INDEX
1685 
1686  If not NULL, this argument is a pointer to a buffer containing
1687  pairs of Min,Max indexes, identifying intervals of records that
1688  will be deleted or commented out. The list of ends with the pair
1689  REC_Q_NOINDEX,REC_Q_NOINDEX.
1690 
1691  INDEX is mutually exclusive with any other selection option.
1692 
1693  SEX
1694 
1695  Selection expression which is evaluated for every record in the
1696  referred record set. If SEX is NULL then all records are
1697  selected.
1698 
1699  This argument is mutually exclusive with any other selection
1700  option.
1701 
1702  FAST_STRING
1703 
1704  If this argument is not NULL then it is a string which is used
1705  as a fixed pattern. Records featuring fields containing
1706  FAST_STRING as a substring in their values are selected.
1707 
1708  This argument is mutually exclusive with any other selection
1709  option.
1710 
1711  RANDOM
1712 
1713  If not 0, this argument indicates the number of random records
1714  to select for manipulation in the referred record set.
1715 
1716  This argument is mutually exclusive with any other selection
1717  option.
1718 
1719  FEX
1720 
1721  Field expression selecting the fields in the selected records
1722  which will be modified.
1723 
1724  ACTION
1725 
1726  Action to perform to the selected fields. Valid values for this
1727  argument are:
1728 
1729  REC_SET_ACT_RENAME
1730 
1731  Rename the matching fields to the string pointed by ACTION_ARG.
1732 
1733  REC_SET_ACT_SET
1734 
1735  Set the value of the matching fields to the string pointed by
1736  ACTION_ARG.
1737 
1738  REC_SET_ACT_ADD
1739 
1740  Add new fields with the names specified in the fex to the
1741  selected records. The new fields will have the string pointed
1742  by ACTION_ARG as their value.
1743 
1744  REC_SET_ACT_SETADD
1745 
1746  Set the selected fields to the value pointed by ACTION_ARG. IF
1747  the fields dont exist then create them with that value.
1748 
1749  REC_SET_ACT_DELETE
1750 
1751  Delete the selected fields. ACTION_ARG is ignored by this
1752  action.
1753 
1754  REC_SET_ACT_COMMENT
1755 
1756  Comment out the selected fields. ACTION_ARG is ignored by this
1757  action.
1758 
1759  ACTION_ARG
1760 
1761  Argument to the selected action. It is ok to pass NULL for
1762  actions which dont require an argument.
1763 
1764  FLAGS
1765 
1766  ORed value of any of the following flags:
1767 
1768  REC_F_ICASE
1769 
1770  If set the string operations in the selection expression will be
1771  case-insensitive. If FALSE any string operation will be
1772  case-sensitive.
1773 
1774  This function return s'false' if there is not enough memory to
1775  perform the operation.
1776 */
1777 
1778 #define REC_SET_ACT_NONE 0
1779 #define REC_SET_ACT_RENAME 1
1780 #define REC_SET_ACT_SET 2
1781 #define REC_SET_ACT_ADD 3
1782 #define REC_SET_ACT_SETADD 4
1783 #define REC_SET_ACT_DELETE 5
1784 #define REC_SET_ACT_COMMENT 6
1785 
1786 bool rec_db_set (rec_db_t db,
1787  const char *type,
1788  size_t *index,
1789  rec_sex_t sex,
1790  const char *fast_string,
1791  size_t random,
1792  rec_fex_t fex,
1793  int action,
1794  const char *action_arg,
1795  int flags);
1796 
1797 /*
1798  * INTEGRITY.
1799  *
1800  */
1801 
1802 /* Check the integrity of all the record sets stored in a given
1803  database. This function returns the number of errors found.
1804  Descriptive messages about the errors are appended to ERRORS. */
1805 
1806 int rec_int_check_db (rec_db_t db,
1807  bool check_descriptors_p,
1808  bool remote_descriptors_p,
1809  rec_buf_t errors);
1810 
1811 /* Check the integrity of a given record set. This function returns
1812  the number of errors found. Descriptive messages about the errors
1813  are appended to ERRORS. */
1814 
1816  rec_rset_t rset,
1817  bool check_descriptor_p,
1818  bool remote_descriptor_p,
1819  rec_buf_t errors);
1820 
1821 /* Check the integrity of a database provided ORIG_REC is replaced by
1822  REC. This function returns the number of errors found.
1823  Descriptive messages about the errors are appended to ERRORS. */
1824 
1826  rec_rset_t rset,
1827  rec_record_t orig_rec,
1828  rec_record_t rec,
1829  rec_buf_t errors);
1830 
1831 /* Check the type of a given field. This function returns the number
1832  of errors found. Descriptive messages about the errors are
1833  appended to ERRORS. */
1834 
1836  rec_rset_t rset,
1837  rec_field_t field,
1838  rec_buf_t errors);
1839 
1840 /*
1841  * PARSER
1842  *
1843  * The rec parser provides functions to parse field, records and
1844  * entire record sets from a file stream or a memory buffer.
1845  */
1846 
1847 /* Opaque data type representing a parser. */
1848 
1849 typedef struct rec_parser_s *rec_parser_t;
1850 
1851 /**************** Creating and destroying parsers ******************/
1852 
1853 /* Create a parser associated with a given file stream that will be
1854  used as the source for the tokens. If not enough memory, return
1855  NULL. */
1856 
1857 rec_parser_t rec_parser_new (FILE *in, const char *source);
1858 
1859 /* Create a parser associated with a given buffer that will be used as
1860  the source for the tokens. The buffer is of specified size and
1861  doesn't have to be null-terminated. If not enough memory, return
1862  NULL. */
1863 
1864 rec_parser_t rec_parser_new_mem (const char *buffer, size_t size, const char *source);
1865 
1866 /* Create a parser associated with a given null-terminated buffer that
1867  will be used as the source for the tokens. If not enough memory,
1868  return NULL. */
1869 
1870 rec_parser_t rec_parser_new_str (const char *buffer, const char *source);
1871 
1872 /* Destroy a parser, freeing all used resources. Note that this call
1873  is not closing the associated file stream or the associated memory
1874  buffer. */
1875 
1876 void rec_parser_destroy (rec_parser_t parser);
1877 
1878 /*********************** Parsing routines **************************/
1879 
1880 /* Parse a field name and return it in FNAME. This function returns
1881  'false' and the value in FNAME is undefined if a parse error is
1882  found. */
1883 
1884 bool rec_parse_field_name (rec_parser_t parser, char **fname);
1885 
1886 /* Parse a field name from a string and return it. This function
1887  returns NULL if a parse error is found. */
1888 
1889 char *rec_parse_field_name_str (const char *str);
1890 
1891 /* Parse a field and return it in FIELD. This function returns
1892  'false' and the value in FIELD is undefined if a parse error is
1893  found. */
1894 
1895 bool rec_parse_field (rec_parser_t parser, rec_field_t *field);
1896 
1897 /* Parse a record and return it in RECORD. This function returns
1898  'false' and the value in RECORD is undefined if a parse error is
1899  found. */
1900 
1901 bool rec_parse_record (rec_parser_t parser, rec_record_t *record);
1902 
1903 /* Parse a record from a string and return it. This function builds
1904  up an ephimeral parser internally in order to do the parsing. This
1905  function returns NULL if a parse error is found. */
1906 
1907 rec_record_t rec_parse_record_str (const char *str);
1908 
1909 /* Parse a record set and return it in RSET. This function returns
1910  'false' and the value in RSET is undefined if a parse error is
1911  found. */
1912 
1913 bool rec_parse_rset (rec_parser_t parser, rec_rset_t *rset);
1914 
1915 /* Parse a database and return it in DB. This function returns
1916  'false' and the value in DB is undefined if a parse error is
1917  found. */
1918 
1919 bool rec_parse_db (rec_parser_t parser, rec_db_t *db);
1920 
1921 /************ Getting and Setting properties of parsers *************/
1922 
1923 /* Determine whether a given parser is in an EOF (end of file)
1924  state. */
1925 
1926 bool rec_parser_eof (rec_parser_t parser);
1927 
1928 /* Determine whether a given parser is in an error state. If the
1929  parser is in an error state then rec_parser_perror can be used to
1930  get a string describing the error. */
1931 
1932 bool rec_parser_error (rec_parser_t parser);
1933 
1934 /* Reset the error status and EOF of a parser. */
1935 
1936 void rec_parser_reset (rec_parser_t parser);
1937 
1938 /* Print a message with details on the last parser error. This
1939  * function produces a message on the standard error output,
1940  * describing the last error encountered while parsing. First, if FMT
1941  * is not NULL, it is printed along with any remaining argument. Then
1942  * a colon and a space are printed, and finally an error message
1943  * describing what went wrong.
1944  */
1945 
1946 void rec_parser_perror (rec_parser_t parser, const char *fmt, ...);
1947 
1948 /* Change the position in file of the parser to a given offset from
1949  the start of the input. The line number is only used to store it
1950  in the parsed records. Return 'false' on error, e.g. when the
1951  stream used is not seekable or when the position is outside the
1952  buffer. */
1953 bool rec_parser_seek (rec_parser_t parser, size_t line_number, size_t position);
1954 
1955 /* Return the current position in the file of the parser or -1 on error. */
1956 long rec_parser_tell (rec_parser_t parser);
1957 
1958 /*
1959  * WRITER
1960  *
1961  * The rec writer provides functions to generate the written form of
1962  * rec objects such as fields and records.
1963  */
1964 
1965 /* Opaque data type representing a rec writer. */
1966 
1967 typedef struct rec_writer_s *rec_writer_t;
1968 
1969 /* Enumerated value identifying the operation modes of the writers.
1970  The operation mode defines what kind of output the writer will
1971  generate. */
1972 
1974 {
1975  REC_WRITER_NORMAL, /* Generate output in rec format. */
1976  REC_WRITER_VALUES, /* Generate output in values format. */
1977  REC_WRITER_VALUES_ROW, /* Generate output in row format. */
1978  REC_WRITER_SEXP /* Generate output in sexps. */
1979 };
1980 
1982 
1983 /**************** Creating and destroying writers ******************/
1984 
1985 /* Create a writer associated with a given file stream. If not enough
1986  memory, return NULL. */
1987 
1988 rec_writer_t rec_writer_new (FILE *out);
1989 
1990 /* Create a writer associated with a given string. If not enough
1991  memory, return NULL. */
1992 
1993 rec_writer_t rec_writer_new_str (char **str, size_t *str_size);
1994 
1995 /* Destroy a writer, freeing any used resources. Note that this call
1996  is not closing the associated file stream, nor free the associated
1997  string. */
1998 
1999 void rec_writer_destroy (rec_writer_t writer);
2000 
2001 /************ Getting and setting writer properties ***************/
2002 
2003 /* Set whether the writer must "collapse" the output records when
2004  writing record sets. */
2005 
2006 void rec_writer_set_collapse (rec_writer_t writer, bool value);
2007 
2008 /* Set whether the writer must skip comments when outputting record
2009  sets and records. */
2010 
2011 void rec_writer_set_skip_comments (rec_writer_t writer, bool value);
2012 
2013 /* Set the operation mode of the writer. See the enumerated type
2014  defined above for a list of allowed modes. Note that the mode can
2015  be changed at any time. */
2016 
2018 
2019 /************** Getting the properties of a writer ****************/
2020 
2021 /* Determine whether a given writer is in an EOF (end-of-file)
2022  state. */
2023 
2025 
2026 /********************** Writing routines **************************/
2027 
2028 /* Write a string in the given writer. This function returns 'false'
2029  if there was an EOF condition. */
2030 
2031 bool rec_write_string (rec_writer_t writer, const char *str);
2032 
2033 /* Write a comment in the given writer. This function returns 'false'
2034  if there was an EOF condition. */
2035 
2036 bool rec_write_comment (rec_writer_t writer, rec_comment_t comment);
2037 
2038 /* Write a field name in the given writer. This function returns
2039  'false' if there was an EOF condition. */
2040 
2041 bool rec_write_field_name (rec_writer_t writer, const char *field_name);
2042 
2043 /* Write a field in the given writer. If NAME is not NULL, use it
2044  instead of the proper name of the field. This function returns
2045  'false' if there was an EOF condition. */
2046 
2047 bool rec_write_field (rec_writer_t writer, rec_field_t field);
2048 
2049 /* Write a record in the given writer. This function returns 'false'
2050  if there was an EOF condition. */
2051 
2052 bool rec_write_record (rec_writer_t writer, rec_record_t record);
2053 
2054 /* Write a record set to the given writer. This function returns
2055  'false' if there was an EOF condition. */
2056 
2057 bool rec_write_rset (rec_writer_t writer, rec_rset_t rset);
2058 
2059 /* Write a database to the given writer. This function returns
2060  'false' if there was an EOF condition. */
2061 
2062 bool rec_write_db (rec_writer_t writer, rec_db_t db);
2063 
2064 /* Create a string with the written representation of a field name and
2065  return it. This function returns NULL if there is not enough
2066  memory to perform the operation. */
2067 
2068 char *rec_write_field_name_str (const char *field_name, rec_writer_mode_t mode);
2069 
2070 /* Create a string with the written representation of a field and
2071  return it. This function returns NULL if there is not enough
2072  memory to perform the operation. */
2073 
2075 
2076 /* Create a string with the written representation of a comment and
2077  return it. This function returns NULL if there is not enough
2078  memory to perform the operation. */
2079 
2081 
2082 /*
2083  * SELECTION EXPRESSIONS
2084  *
2085  * A selection expression is an expression that can be applied to a
2086  * record. The result of the evaluation is a boolean value indicating
2087  * whether the record matches the expression.
2088  *
2089  * The abbreviated term to refer to a selection expression is 'a sex'.
2090  * The plural form is 'sexes'.
2091  */
2092 
2093 /* The opaque type rec_sex_t is defined above in this file as a
2094  forward declaration. */
2095 
2096 /**************** Creating and destroying sexes ******************/
2097 
2098 /* Create a new selection expression and return it. If there is not
2099  enough memory to create the sex, then return NULL. */
2100 
2101 rec_sex_t rec_sex_new (bool case_insensitive);
2102 
2103 /* Destroy a sex, freeing any used resources. */
2104 
2105 void rec_sex_destroy (rec_sex_t sex);
2106 
2107 /**************** Compiling and applying sexes ******************/
2108 
2109 /* Compile a sex. Sexes must be compiled before being used. If there
2110  is a parse error return false. */
2111 
2112 bool rec_sex_compile (rec_sex_t sex, const char *expr);
2113 
2114 /* Apply a sex expression to a record, setting STATUS in accordance:
2115  'true' if the record matched the sex, 'false' otherwise. The
2116  function returns the same value that is stored in STATUS. */
2117 
2118 bool rec_sex_eval (rec_sex_t sex, rec_record_t record, bool *status);
2119 
2120 /* Apply a sex expression and get the result as an allocated
2121  string. */
2122 
2123 char *rec_sex_eval_str (rec_sex_t sex, rec_record_t record);
2124 
2125 /**************** Miscellaneous sexes functions ******************/
2126 
2127 /* Print the abstract syntax tree of a compiled sex. This function is
2128  intended to be used for debugging purposes. */
2129 
2130 void rec_sex_print_ast (rec_sex_t sex);
2131 
2132 
2133 /*
2134  * ENCRYPTION
2135  *
2136  * The following routines encrypt and decrypt fields in rec data.
2137  *
2138  * If librec was built without encryption support, all of them will do
2139  * nothing and return 'false' as if an error occurred.
2140  */
2141 
2142 /* Prefix used in the encrypted and ASCII encoded field values, which
2143  is used to recognize encrypted values. */
2144 
2145 #define REC_ENCRYPTED_PREFIX "encrypted-"
2146 
2147 /**************** Encryption routines *******************************/
2148 
2149 /* Encrypt a given buffer and place the encrypted data in an allocated
2150  output buffer. This function returns 'false' if there was an error
2151  while performing the encryption, such as an incorrect password or
2152  an out-of-memory condition. */
2153 
2154 bool rec_encrypt (char *in, size_t in_size, const char *password,
2155  char **out, size_t *out_size);
2156 
2157 
2158 /* Encrypt and ASCII-encode the value of a field used the provided
2159  password. The REC_ENCRYPTED_PREFIX is prepended to the result.
2160  This function returns 'false' if there was an error while
2161  performing the encryption, such as an incorrect password or an
2162  out-of-memory condition. */
2163 
2164 bool rec_encrypt_field (rec_field_t field, const char *password);
2165 
2166 /* Encrypt and ASCII-encode the fields of a record marked as
2167  "confidential" in a given record set, using the provided password.
2168  The REC_ENCRYPTED_PREFIX is prepended to the result. This function
2169  returns 'false' if there was an error while performing the
2170  encryption, such as an incorrect password or an out-of-memory
2171  condition. */
2172 
2173 bool rec_encrypt_record (rec_rset_t rset, rec_record_t record,
2174  const char *password);
2175 
2176 /**************** Decryption routines *******************************/
2177 
2178 /* Decrypt a given buffer and place the decrypted data in an allocated
2179  output buffer. This function returns 'false' if there was an error
2180  while performing the decryption, such as an incorrect password or
2181  an out-of-memory condition. */
2182 
2183 bool rec_decrypt (char *in, size_t in_size, const char *password,
2184  char **out, size_t *out_size);
2185 
2186 /* Decrypt the value of a field used the provided password. This
2187  function returns 'false' if there was an error while perfoming the
2188  decryption, such as an incorrect password or an out-of-memory
2189  condition. Note that this function uses the REC_ENCRYPTED_PREFIX
2190  in order to determine whether a field is already encrypted. */
2191 
2192 bool rec_decrypt_field (rec_field_t field, const char *password);
2193 
2194 /* Decrypt the encrypted fields of a record marked as "confidential"
2195  in a given record set, using the provided password. This function
2196  returns 'false' if there was an error while performing the
2197  decryption, such as an incorrect password or an out-of-memory
2198  condition. Note that this function uses the REC_ENCRYPTED_PREFIX
2199  in order to determine whether a field is already encrypted. */
2200 
2201 bool rec_decrypt_record (rec_rset_t rset, rec_record_t record,
2202  const char *password);
2203 
2204 /*
2205  * AGGREGATES
2206  *
2207  * The following routines and data types provide support for
2208  * "aggregate functions". Aggregate functions are applied to sets of
2209  * fields and return a single value.
2210  */
2211 
2212 /* Data type representing an aggregate function. Aggregate functions
2213  get a record set, a record, a field name and subscripts which can
2214  be -1. The field functions must return a string, which may be
2215  empty. If an out-of-memory condition occurs then they return
2216  NULL. */
2217 
2218 typedef char *(*rec_aggregate_t) (rec_rset_t rset,
2219  rec_record_t record,
2220  const char *field_name);
2221 
2222 /*
2223  * AGGREGATES REGISTRIES
2224  *
2225  * The following data types and functions provide support for
2226  * maintaining registries with collections of aggregate functions.
2227  * The aggregate functions are identified by a constant string that
2228  * must be unique in the registry.
2229  */
2230 
2231 /* See the definition of rec_aggregate_reg_t above. */
2232 
2233 /******** Creating and destroying function registries ************/
2234 
2235 /* Create a new, empty aggregates registry. If there is not error to
2236  perform the operation then NULL is returned. */
2237 
2239 
2240 /* Destroy a functions registry, freeing any used resources. */
2241 
2243 
2244 /********* Registering functions and fetching them ***************/
2245 
2246 /* Register a field function into a functions register, associating it
2247  with a given constant string. If a function associated with the
2248  given string already exists in the registry then it is substitued
2249  by the provided function. The function true if the operation was
2250  successful, and false if there was not enough memory to perform the
2251  operation. */
2252 
2253 bool rec_aggregate_reg_add (rec_aggregate_reg_t func_reg, const char *name, rec_aggregate_t function);
2254 
2255 /* Fetch a field function from a functions registry. If no function
2256  associated with NAME is found in the registry then NULL is
2257  returned. */
2258 
2259 rec_aggregate_t rec_aggregate_reg_get (rec_aggregate_reg_t func_get, const char *name);
2260 
2261 /* Register the standard built-in functions shipped with librec in the
2262  given aggregate register. */
2263 
2265 
2266 /* Determine whether a given function name is a standard aggregate.
2267  The comparison is case-insensitive. */
2268 
2269 bool rec_aggregate_std_p (const char *name);
2270 
2271 #endif /* !GNU_REC_H */
2272 
2273 /* End of rec.h */
bool rec_field_equal_p(rec_field_t field1, rec_field_t field2)
Definition: rec-field.c:178
rec_type_reg_t rec_type_reg_new(void)
Definition: rec-types.c:703
bool rec_db_delete(rec_db_t db, const char *type, size_t *index, rec_sex_t sex, const char *fast_string, size_t random, int flags)
Definition: rec-db.c:726
rec_sex_t rec_rset_sex_constraint(rec_rset_t rset, size_t index)
Definition: rec-rset.c:922
rec_parser_t rec_parser_new_str(const char *buffer, const char *source)
Definition: rec-parser.c:137
void rec_aggregate_reg_add_standard(rec_aggregate_reg_t func_reg)
Definition: rec-aggregate.c:188
bool rec_db_set(rec_db_t db, const char *type, size_t *index, rec_sex_t sex, const char *fast_string, size_t random, rec_fex_t fex, int action, const char *action_arg, int flags)
Definition: rec-db.c:817
char *(* rec_aggregate_t)(rec_rset_t rset, rec_record_t record, const char *field_name)
Definition: rec.h:2218
rec_buf_t rec_buf_new(char **data, size_t *size)
Definition: rec-buf.c:51
rec_mset_type_t rec_mset_register_type(rec_mset_t mset, char *name, rec_mset_disp_fn_t disp_fn, rec_mset_equal_fn_t equal_fn, rec_mset_dup_fn_t dup_fn, rec_mset_compare_fn_t compare_fn)
Definition: rec-mset.c:292
bool rec_field_name_equal_p(const char *name1, const char *name2)
Definition: rec-field-name.c:113
void rec_type_destroy(rec_type_t type)
Definition: rec-types.c:679
char * rec_write_field_str(rec_field_t field, rec_writer_mode_t mode)
Definition: rec-writer.c:625
rec_comment_t rec_comment_new(char *text)
Definition: rec-comment.c:38
bool rec_field_set_location(rec_field_t field, size_t location)
Definition: rec-field.c:247
void rec_mset_dump(rec_mset_t mset)
Definition: rec-mset.c:704
void * rec_record_container(rec_record_t record)
Definition: rec-record.c:639
bool rec_db_remove_rset(rec_db_t db, size_t position)
Definition: rec-db.c:193
int rec_int_check_rset(rec_db_t db, rec_rset_t rset, bool check_descriptor_p, bool remote_descriptor_p, rec_buf_t errors)
Definition: rec-int.c:123
rec_rset_t rec_rset_group(rec_rset_t rset, rec_fex_t group_by)
Definition: rec-rset.c:750
rec_comment_t rec_field_to_comment(rec_field_t field)
Definition: rec-field.c:199
bool rec_write_comment(rec_writer_t writer, rec_comment_t comment)
Definition: rec-writer.c:127
rec_mset_t rec_record_mset(rec_record_t record)
Definition: rec-record.c:263
rec_fex_elem_t rec_fex_append(rec_fex_t fex, const char *fname, int min, int max)
Definition: rec-fex.c:442
bool rec_db_type_p(rec_db_t db, const char *type)
Definition: rec-db.c:218
bool rec_type_equal_p(rec_type_t type1, rec_type_t type2)
Definition: rec-types.c:873
bool rec_record_contains_field(rec_record_t record, const char *field_name, const char *field_value)
Definition: rec-record.c:614
bool rec_write_string(rec_writer_t writer, const char *str)
Definition: rec-writer.c:685
rec_mset_iterator_t rec_mset_iterator(rec_mset_t mset)
Definition: rec-mset.c:593
rec_std_field_e
Definition: rec.h:394
@ REC_FIELD_TYPEDEF
Definition: rec.h:404
@ REC_FIELD_ALLOWED
Definition: rec.h:407
@ REC_FIELD_REC
Definition: rec.h:400
@ REC_FIELD_AUTO
Definition: rec.h:395
@ REC_FIELD_PROHIBIT
Definition: rec.h:399
@ REC_FIELD_KEY
Definition: rec.h:397
@ REC_FIELD_SORT
Definition: rec.h:402
@ REC_FIELD_SIZE
Definition: rec.h:401
@ REC_FIELD_CONSTRAINT
Definition: rec.h:406
@ REC_FIELD_TYPE
Definition: rec.h:403
@ REC_FIELD_MANDATORY
Definition: rec.h:398
@ REC_FIELD_CONFIDENTIAL
Definition: rec.h:396
@ REC_FIELD_UNIQUE
Definition: rec.h:405
void ** rec_fex_elem_function_data(rec_fex_elem_t elem)
Definition: rec-fex.c:491
rec_record_t rec_parse_record_str(const char *str)
Definition: rec-parser.c:699
struct rec_record_s * rec_record_t
Definition: rec.h:846
int rec_mset_type_t
Definition: rec.h:106
rec_mset_t rec_mset_sort(rec_mset_t mset)
Definition: rec-mset.c:225
rec_type_t rec_type_reg_get(rec_type_reg_t reg, const char *type_name)
Definition: rec-types.c:820
void rec_comment_destroy(rec_comment_t comment)
Definition: rec-comment.c:47
size_t rec_field_location(rec_field_t field)
Definition: rec-field.c:241
enum rec_writer_mode_e rec_writer_mode_t
Definition: rec.h:1981
rec_comment_t rec_comment_dup(rec_comment_t comment)
Definition: rec-comment.c:53
bool rec_record_mark_field(rec_record_t record, rec_field_t field, int mark)
Definition: rec-record.c:755
rec_writer_mode_e
Definition: rec.h:1974
@ REC_WRITER_VALUES
Definition: rec.h:1976
@ REC_WRITER_VALUES_ROW
Definition: rec.h:1977
@ REC_WRITER_NORMAL
Definition: rec.h:1975
@ REC_WRITER_SEXP
Definition: rec.h:1978
char * rec_comment_text(rec_comment_t comment)
Definition: rec-comment.c:59
size_t rec_rset_descriptor_pos(rec_rset_t rset)
Definition: rec-rset.c:360
bool rec_type_descr_p(const char *str)
Definition: rec-types.c:302
void rec_fini(void)
Definition: rec.c:46
bool rec_mset_elem_equal_p(rec_mset_elem_t elem1, rec_mset_elem_t elem2)
Definition: rec-mset.c:690
bool rec_mset_remove_elem(rec_mset_t mset, rec_mset_elem_t elem)
Definition: rec-mset.c:491
bool rec_int_check_field_type(rec_db_t db, rec_rset_t rset, rec_field_t field, rec_buf_t errors)
Definition: rec-int.c:244
const char * rec_fex_elem_rewrite_to(rec_fex_elem_t elem)
Definition: rec-fex.c:300
size_t rec_record_get_field_index_by_name(rec_record_t record, rec_field_t field)
Definition: rec-record.c:395
void rec_writer_set_collapse(rec_writer_t writer, bool value)
Definition: rec-writer.c:692
rec_writer_t rec_writer_new(FILE *out)
Definition: rec-writer.c:79
void rec_rset_set_descriptor_pos(rec_rset_t rset, size_t position)
Definition: rec-rset.c:366
const char * rec_type_rec(rec_type_t type)
Definition: rec-types.c:951
void rec_rset_destroy(rec_rset_t rset)
Definition: rec-rset.c:230
void rec_sex_destroy(rec_sex_t sex)
Definition: rec-sex.c:95
char * rec_type_kind_str(rec_type_t type)
Definition: rec-types.c:485
rec_mset_elem_t rec_mset_search(rec_mset_t mset, void *data)
Definition: rec-mset.c:570
void *(* rec_mset_dup_fn_t)(void *data)
Definition: rec.h:97
char * rec_record_location_str(rec_record_t record)
Definition: rec-record.c:507
bool rec_decrypt_field(rec_field_t field, const char *password)
Definition: rec-crypt-dummy.c:66
bool rec_writer_eof(rec_writer_t writer)
bool rec_fex_all_calls_p(rec_fex_t fex)
Definition: rec-fex.c:497
bool rec_parse_db(rec_parser_t parser, rec_db_t *db)
Definition: rec-parser.c:620
void rec_writer_set_mode(rec_writer_t writer, enum rec_writer_mode_e mode)
Definition: rec-writer.c:706
void rec_buf_close(rec_buf_t buffer)
Definition: rec-buf.c:76
void rec_aggregate_reg_destroy(rec_aggregate_reg_t func_reg)
Definition: rec-aggregate.c:125
bool rec_record_contains_value(rec_record_t record, const char *value, bool case_insensitive)
Definition: rec-record.c:577
rec_rset_t rec_rset_dup(rec_rset_t rset)
Definition: rec-rset.c:269
size_t rec_record_location(rec_record_t record)
Definition: rec-record.c:501
rec_aggregate_t rec_aggregate_reg_get(rec_aggregate_reg_t func_get, const char *name)
Definition: rec-aggregate.c:171
rec_parser_t rec_parser_new(FILE *in, const char *source)
Definition: rec-parser.c:114
bool rec_aggregate_std_p(const char *name)
Definition: rec-aggregate.c:197
size_t rec_record_num_fields(rec_record_t record)
Definition: rec-record.c:275
rec_record_t rec_rset_descriptor(rec_rset_t rset)
Definition: rec-rset.c:337
size_t rec_record_num_elems(rec_record_t record)
Definition: rec-record.c:269
size_t rec_fex_size(rec_fex_t fex)
Definition: rec-fex.c:255
char * rec_rset_type(rec_rset_t rset)
Definition: rec-rset.c:407
rec_aggregate_reg_t rec_db_aggregates(rec_db_t db)
Definition: rec-db.c:963
void rec_parser_destroy(rec_parser_t parser)
Definition: rec-parser.c:168
char * rec_write_field_name_str(const char *field_name, rec_writer_mode_t mode)
Definition: rec-writer.c:645
bool rec_rset_set_order_by_fields(rec_rset_t rset, rec_fex_t field_names)
Definition: rec-rset.c:706
rec_type_t rec_rset_get_field_type(rec_rset_t rset, const char *field_name)
Definition: rec-rset.c:656
void rec_record_set_char_location(rec_record_t record, size_t char_location)
Definition: rec-record.c:562
rec_mset_t rec_mset_dup(rec_mset_t mset)
Definition: rec-mset.c:158
rec_mset_elem_t rec_mset_insert_at(rec_mset_t mset, rec_mset_type_t type, void *data, size_t position)
Definition: rec-mset.c:421
rec_record_t rec_record_dup(rec_record_t record)
Definition: rec-record.c:149
int rec_fex_elem_min(rec_fex_elem_t elem)
Definition: rec-fex.c:288
void rec_field_destroy(rec_field_t field)
Definition: rec-field.c:185
bool rec_parse_rset(rec_parser_t parser, rec_rset_t *rset)
Definition: rec-parser.c:514
int rec_type_max(rec_type_t type)
Definition: rec-types.c:934
size_t rec_field_char_location(rec_field_t field)
Definition: rec-field.c:274
size_t rec_mset_count(rec_mset_t mset, rec_mset_type_t type)
Definition: rec-mset.c:313
char * rec_comment_t
Definition: rec.h:341
void rec_record_remove_field_by_name(rec_record_t record, const char *field_name, size_t n)
Definition: rec-record.c:369
bool rec_write_record(rec_writer_t writer, rec_record_t record)
Definition: rec-writer.c:377
void rec_comment_set_text(rec_comment_t *comment, char *text)
Definition: rec-comment.c:65
bool rec_record_field_p(rec_record_t record, const char *field_name)
Definition: rec-record.c:311
rec_writer_t rec_writer_new_str(char **str, size_t *str_size)
Definition: rec-writer.c:94
size_t rec_record_get_field_index(rec_record_t record, rec_field_t field)
Definition: rec-record.c:287
void rec_record_uniq(rec_record_t record)
Definition: rec-record.c:651
struct rec_type_reg_s * rec_type_reg_t
Definition: rec.h:684
bool rec_type_check(rec_type_t type, const char *str, char **error_str)
Definition: rec-types.c:574
void(* rec_mset_disp_fn_t)(void *data)
Definition: rec.h:95
const char * rec_fex_elem_field_name(rec_fex_elem_t elem)
Definition: rec-fex.c:273
const char * rec_field_source(rec_field_t field)
Definition: rec-field.c:226
rec_fex_t rec_fex_new(const char *str, enum rec_fex_kind_e kind)
Definition: rec-fex.c:77
char * rec_record_source(rec_record_t record)
Definition: rec-record.c:471
bool rec_write_field(rec_writer_t writer, rec_field_t field)
Definition: rec-writer.c:210
rec_mset_elem_t rec_mset_append(rec_mset_t mset, rec_mset_type_t elem_type, void *data, rec_mset_type_t type)
Definition: rec-mset.c:479
bool rec_field_set_char_location(rec_field_t field, size_t location)
Definition: rec-field.c:280
bool rec_write_rset(rec_writer_t writer, rec_rset_t rset)
Definition: rec-writer.c:476
bool rec_field_name_p(const char *str)
Definition: rec-field-name.c:69
void rec_record_append(rec_record_t dest_record, rec_record_t src_record)
Definition: rec-record.c:719
rec_type_t rec_type_new(const char *str)
Definition: rec-types.c:351
rec_field_t rec_field_dup(rec_field_t field)
Definition: rec-field.c:128
rec_mset_type_t rec_mset_elem_type(rec_mset_elem_t elem)
Definition: rec-mset.c:662
char * rec_write_comment_str(rec_comment_t comment, rec_writer_mode_t mode)
Definition: rec-writer.c:665
bool rec_write_field_name(rec_writer_t writer, const char *field_name)
Definition: rec-writer.c:331
void * rec_mset_elem_dup_data(rec_mset_elem_t elem)
Definition: rec-mset.c:698
void rec_record_set_source(rec_record_t record, char *source)
Definition: rec-record.c:488
bool rec_write_db(rec_writer_t writer, rec_db_t db)
Definition: rec-writer.c:594
rec_fex_kind_e
Definition: rec.h:447
@ REC_FEX_SIMPLE
Definition: rec.h:448
@ REC_FEX_CSV
Definition: rec.h:449
@ REC_FEX_SUBSCRIPTS
Definition: rec.h:450
void rec_rset_set_type(rec_rset_t rset, const char *type)
Definition: rec-rset.c:373
const char * rec_fex_elem_function_name(rec_fex_elem_t elem)
Definition: rec-fex.c:485
void rec_parser_perror(rec_parser_t parser, const char *fmt,...)
Definition: rec-parser.c:190
int rec_record_field_mark(rec_record_t record, rec_field_t field)
Definition: rec-record.c:778
bool rec_rset_field_confidential_p(rec_rset_t rset, const char *field_name)
rec_mset_t rec_mset_new(void)
Definition: rec-mset.c:104
const char * rec_field_value(rec_field_t field)
Definition: rec-field.c:83
const char * rec_field_name(rec_field_t field)
Definition: rec-field.c:69
bool rec_encrypt_field(rec_field_t field, const char *password)
Definition: rec-crypt-dummy.c:59
bool rec_parse_field_name(rec_parser_t parser, char **fname)
Definition: rec-parser.c:214
rec_rset_t rec_rset_add_auto_fields(rec_rset_t rset, rec_record_t record)
Definition: rec-rset.c:839
rec_rset_t rec_db_get_rset_by_type(rec_db_t db, const char *type)
Definition: rec-db.c:225
bool rec_parser_seek(rec_parser_t parser, size_t line_number, size_t position)
Definition: rec-parser.c:717
bool rec_mset_remove_at(rec_mset_t mset, rec_mset_type_t type, size_t position)
Definition: rec-mset.c:390
bool rec_parse_field(rec_parser_t parser, rec_field_t *field)
Definition: rec-parser.c:352
rec_fex_t rec_fex_dup(rec_fex_t fex)
Definition: rec-fex.c:155
rec_parser_t rec_parser_new_mem(const char *buffer, size_t size, const char *source)
Definition: rec-parser.c:144
bool rec_encrypt_record(rec_rset_t rset, rec_record_t record, const char *password)
Definition: rec-crypt-dummy.c:51
struct rec_rset_s * rec_rset_t
Definition: rec.h:1070
bool rec_sex_eval(rec_sex_t sex, rec_record_t record, bool *status)
Definition: rec-sex.c:196
int rec_field_mark(rec_field_t field)
Definition: rec-field.c:313
bool rec_decrypt(char *in, size_t in_size, const char *password, char **out, size_t *out_size)
Definition: rec-crypt-dummy.c:41
struct rec_fex_elem_s * rec_fex_elem_t
Definition: rec.h:444
rec_type_kind_e
Definition: rec.h:575
@ REC_TYPE_UUID
Definition: rec.h:601
@ REC_TYPE_ENUM
Definition: rec.h:595
@ REC_TYPE_NONE
Definition: rec.h:577
@ REC_TYPE_BOOL
Definition: rec.h:581
@ REC_TYPE_SIZE
Definition: rec.h:587
@ REC_TYPE_REC
Definition: rec.h:603
@ REC_TYPE_REAL
Definition: rec.h:585
@ REC_TYPE_FIELD
Definition: rec.h:597
@ REC_TYPE_LINE
Definition: rec.h:589
@ REC_TYPE_RANGE
Definition: rec.h:583
@ REC_TYPE_EMAIL
Definition: rec.h:599
@ REC_TYPE_REGEXP
Definition: rec.h:591
@ REC_TYPE_INT
Definition: rec.h:579
@ REC_TYPE_DATE
Definition: rec.h:593
void rec_mset_iterator_free(rec_mset_iterator_t *iterator)
Definition: rec-mset.c:649
bool rec_db_insert_rset(rec_db_t db, rec_rset_t rset, size_t position)
Definition: rec-db.c:158
void rec_buf_rewind(rec_buf_t buf, int n)
Definition: rec-buf.c:92
size_t rec_rset_num_elems(rec_rset_t rset)
Definition: rec-rset.c:319
int rec_buf_puts(const char *s, rec_buf_t buffer)
Definition: rec-buf.c:127
rec_type_reg_t rec_rset_get_type_reg(rec_rset_t rset)
Definition: rec-rset.c:449
int rec_buf_putc(int c, rec_buf_t buffer)
Definition: rec-buf.c:99
bool rec_fex_check(const char *str, enum rec_fex_kind_e kind)
Definition: rec-fex.c:223
rec_comment_t rec_record_to_comment(rec_record_t record)
Definition: rec-record.c:422
struct rec_mset_s * rec_mset_t
Definition: rec.h:64
const char * rec_std_field_name(enum rec_std_field_e std_field)
Definition: rec-field-name.c:63
struct rec_buf_s * rec_buf_t
Definition: rec.h:319
void rec_init(void)
Definition: rec.c:37
rec_fex_t rec_rset_confidential(rec_rset_t rset)
rec_rset_t rec_db_query(rec_db_t db, const char *type, const char *join, size_t *index, rec_sex_t sex, const char *fast_string, size_t random, rec_fex_t fex, const char *password, rec_fex_t group_by, rec_fex_t sort_by, int flags)
Definition: rec-db.c:267
rec_mset_elem_t rec_mset_add_sorted(rec_mset_t mset, rec_mset_type_t type, void *data)
Definition: rec-mset.c:736
void rec_mset_destroy(rec_mset_t mset)
Definition: rec-mset.c:144
bool(* rec_mset_equal_fn_t)(void *data1, void *data2)
Definition: rec.h:96
void rec_rset_rename_field(rec_rset_t rset, const char *field_name, const char *new_field_name)
Definition: rec-rset.c:455
void rec_type_reg_destroy(rec_type_reg_t reg)
Definition: rec-types.c:718
rec_sex_t rec_sex_new(bool case_insensitive)
Definition: rec-sex.c:75
void rec_db_destroy(rec_db_t db)
Definition: rec-db.c:120
void rec_writer_destroy(rec_writer_t writer)
Definition: rec-writer.c:109
struct rec_fex_s * rec_fex_t
Definition: rec.h:443
rec_fex_elem_t rec_fex_get(rec_fex_t fex, size_t position)
Definition: rec-fex.c:261
bool rec_field_set_name(rec_field_t field, const char *name)
Definition: rec-field.c:75
size_t rec_record_get_num_fields_by_name(rec_record_t record, const char *field_name)
Definition: rec-record.c:318
int(* rec_mset_compare_fn_t)(void *data1, void *data2, int type2)
Definition: rec.h:98
size_t rec_rset_max_records(rec_rset_t rset)
Definition: rec-rset.c:682
char * rec_field_name_normalise(const char *str)
Definition: rec-field-name.c:75
rec_db_t rec_db_new(void)
Definition: rec-db.c:82
bool rec_mset_type_p(rec_mset_t mset, rec_mset_type_t type)
Definition: rec-mset.c:285
struct rec_field_s * rec_field_t
Definition: rec.h:716
const char * rec_type_name(rec_type_t type)
Definition: rec-types.c:861
void rec_record_set_container(rec_record_t record, void *container)
Definition: rec-record.c:645
rec_rset_t rec_rset_sort(rec_rset_t rset, rec_fex_t sort_by)
Definition: rec-rset.c:721
bool rec_decrypt_record(rec_rset_t rset, rec_record_t record, const char *password)
Definition: rec-crypt-dummy.c:73
bool rec_field_set_value(rec_field_t field, const char *value)
Definition: rec-field.c:89
void rec_sex_print_ast(rec_sex_t sex)
Definition: rec-sex.c:271
struct rec_parser_s * rec_parser_t
Definition: rec.h:1849
void rec_record_set_location(rec_record_t record, size_t location)
Definition: rec-record.c:524
struct rec_type_s * rec_type_t
Definition: rec.h:606
char * rec_rset_url(rec_rset_t rset)
Definition: rec-rset.c:428
void rec_parser_reset(rec_parser_t parser)
Definition: rec-parser.c:344
struct rec_sex_s * rec_sex_t
Definition: rec.h:1076
bool rec_encrypt(char *in, size_t in_size, const char *password, char **out, size_t *out_size)
Definition: rec-crypt-dummy.c:31
bool rec_sex_compile(rec_sex_t sex, const char *expr)
Definition: rec-sex.c:114
void rec_type_reg_add_synonym(rec_type_reg_t reg, const char *type_name, const char *to_name)
Definition: rec-types.c:781
void * rec_mset_get_at(rec_mset_t mset, rec_mset_type_t type, size_t position)
Definition: rec-mset.c:320
rec_aggregate_reg_t rec_aggregate_reg_new(void)
Definition: rec-aggregate.c:113
long rec_parser_tell(rec_parser_t parser)
Definition: rec-parser.c:745
const char * rec_field_char_location_str(rec_field_t field)
Definition: rec-field.c:290
struct rec_writer_s * rec_writer_t
Definition: rec.h:1967
int rec_int_check_record(rec_db_t db, rec_rset_t rset, rec_record_t orig_rec, rec_record_t rec, rec_buf_t errors)
Definition: rec-int.c:220
size_t rec_rset_min_records(rec_rset_t rset)
Definition: rec-rset.c:676
void rec_mset_elem_set_type(rec_mset_elem_t elem, rec_mset_type_t type)
Definition: rec-mset.c:668
void rec_type_reg_add(rec_type_reg_t reg, rec_type_t type)
Definition: rec-types.c:736
struct rec_mset_elem_s * rec_mset_elem_t
Definition: rec.h:69
struct rec_aggregate_reg_s * rec_aggregate_reg_t
Definition: rec.h:1310
enum rec_type_kind_e rec_type_kind(rec_type_t type)
Definition: rec-types.c:479
const char * rec_rset_key(rec_rset_t rset)
Definition: rec-rset.c:559
bool rec_parse_record(rec_parser_t parser, rec_record_t *record)
Definition: rec-parser.c:399
rec_mset_elem_t rec_mset_insert_after(rec_mset_t mset, rec_mset_type_t type, void *data, rec_mset_elem_t elem)
Definition: rec-mset.c:511
rec_fex_t rec_rset_order_by_fields(rec_rset_t rset)
Definition: rec-rset.c:715
char * rec_fex_str(rec_fex_t fex, enum rec_fex_kind_e kind)
Definition: rec-fex.c:343
void rec_record_reset_marks(rec_record_t record)
Definition: rec-record.c:741
size_t rec_record_num_comments(rec_record_t record)
Definition: rec-record.c:281
bool rec_fex_elem_set_field_name(rec_fex_elem_t elem, const char *fname)
Definition: rec-fex.c:279
void rec_writer_set_skip_comments(rec_writer_t writer, bool value)
Definition: rec-writer.c:699
char * rec_rset_source(rec_rset_t rset)
Definition: rec-rset.c:688
int rec_type_min(rec_type_t type)
Definition: rec-types.c:917
int rec_fex_elem_max(rec_fex_elem_t elem)
Definition: rec-fex.c:294
bool rec_aggregate_reg_add(rec_aggregate_reg_t func_reg, const char *name, rec_aggregate_t function)
Definition: rec-aggregate.c:138
bool rec_db_insert(rec_db_t db, const char *type, size_t *index, rec_sex_t sex, const char *fast_string, size_t random, const char *password, rec_record_t record, int flags)
Definition: rec-db.c:517
void rec_rset_set_descriptor(rec_rset_t rset, rec_record_t record)
Definition: rec-rset.c:343
char * rec_parse_field_name_str(const char *str)
Definition: rec-parser.c:658
void rec_type_set_name(rec_type_t type, const char *name)
Definition: rec-types.c:867
rec_rset_t rec_db_get_rset(rec_db_t db, size_t position)
Definition: rec-db.c:137
struct rec_db_s * rec_db_t
Definition: rec.h:1304
void rec_field_set_mark(rec_field_t field, int mark)
Definition: rec-field.c:307
rec_fex_t rec_rset_auto(rec_rset_t rset)
Definition: rec-rset.c:579
const char * rec_field_location_str(rec_field_t field)
Definition: rec-field.c:257
bool rec_comment_equal_p(rec_comment_t comment1, rec_comment_t comment2)
Definition: rec-comment.c:73
rec_field_t rec_field_new(const char *name, const char *value)
Definition: rec-field.c:98
void * rec_mset_elem_data(rec_mset_elem_t elem)
Definition: rec-mset.c:677
bool rec_record_subset_p(rec_record_t record1, rec_record_t record2)
Definition: rec-record.c:210
size_t rec_db_size(rec_db_t db)
Definition: rec-db.c:131
size_t rec_rset_num_records(rec_rset_t rset)
Definition: rec-rset.c:325
size_t rec_rset_num_sex_constraints(rec_rset_t rset)
Definition: rec-rset.c:916
char * rec_sex_eval_str(rec_sex_t sex, rec_record_t record)
Definition: rec-sex.c:153
bool rec_parser_eof(rec_parser_t parser)
Definition: rec-parser.c:178
void rec_fex_destroy(rec_fex_t fex)
Definition: rec-fex.c:135
void rec_mset_elem_set_data(rec_mset_elem_t elem, void *data)
Definition: rec-mset.c:683
char * rec_record_char_location_str(rec_record_t record)
Definition: rec-record.c:545
bool rec_parser_error(rec_parser_t parser)
Definition: rec-parser.c:184
void rec_fex_sort(rec_fex_t fex)
Definition: rec-fex.c:306
rec_field_t rec_record_get_field_by_name(rec_record_t record, const char *field_name, size_t n)
Definition: rec-record.c:339
bool rec_fex_member_p(rec_fex_t fex, const char *fname, int min, int max)
Definition: rec-fex.c:418
bool rec_mset_iterator_next(rec_mset_iterator_t *iterator, rec_mset_type_t type, const void **data, rec_mset_elem_t *elem)
Definition: rec-mset.c:611
size_t rec_record_char_location(rec_record_t record)
Definition: rec-record.c:539
rec_rset_t rec_rset_new(void)
Definition: rec-rset.c:165
bool rec_field_set_source(rec_field_t field, const char *source)
Definition: rec-field.c:232
size_t rec_rset_num_comments(rec_rset_t rset)
Definition: rec-rset.c:331
void rec_record_destroy(rec_record_t record)
Definition: rec-record.c:136
int rec_int_check_db(rec_db_t db, bool check_descriptors_p, bool remote_descriptors_p, rec_buf_t errors)
Definition: rec-int.c:96
bool rec_record_equal_p(rec_record_t record1, rec_record_t record2)
Definition: rec-record.c:255
rec_record_t rec_record_new(void)
Definition: rec-record.c:77
int rec_type_values_cmp(rec_type_t type, const char *val1, const char *val2)
Definition: rec-types.c:964
rec_mset_t rec_rset_mset(rec_rset_t rset)
Definition: rec-rset.c:313
Definition: rec-aggregate.c:50
Definition: rec-buf.c:35
size_t size
Definition: rec-buf.c:37
char * data
Definition: rec-buf.c:36
Definition: rec-db.c:42
Definition: rec-fex.c:41
int min
Definition: rec-fex.c:47
char * str
Definition: rec-fex.c:42
int max
Definition: rec-fex.c:46
Definition: rec-fex.c:56
Definition: rec-field.c:40
int mark
Definition: rec-field.c:57
char * value
Definition: rec-field.c:45
char * name
Definition: rec-field.c:44
size_t location
Definition: rec-field.c:50
char * source
Definition: rec-field.c:49
Definition: rec-mset.c:44
rec_mset_type_t type
Definition: rec-mset.c:45
void * data
Definition: rec-mset.c:46
rec_mset_t mset
Definition: rec-mset.c:51
Definition: rec.h:86
rec_mset_list_iter_t list_iter
Definition: rec.h:88
rec_mset_t mset
Definition: rec.h:87
Definition: rec.h:77
void * p
Definition: rec.h:81
size_t count
Definition: rec.h:80
void * list
Definition: rec.h:79
size_t i
Definition: rec.h:82
void * vtable
Definition: rec.h:78
Definition: rec-mset.c:55
Definition: rec-parser.c:72
char * source
Definition: rec-parser.c:78
Definition: rec-record.c:38
void * container
Definition: rec-record.c:42
size_t char_location
Definition: rec-record.c:54
size_t location
Definition: rec-record.c:52
char * source
Definition: rec-record.c:51
Definition: rec-rset.c:73
Definition: rec-sex.c:44
Definition: rec-types.c:261
Definition: rec-types.c:228
char * name
Definition: rec-types.c:229
Definition: rec-writer.c:46
enum rec_writer_mode_e mode
Definition: rec-writer.c:60