/* relational.h:
 *
 ****************************************************************
 * Copyright (C) 2003 Tom Lord
 *
 * See the file "COPYING" for further information about
 * the copyright and warranty status of this work.
 */

#ifndef INCLUDE__FILE_UTILS__RELATIONAL_H
#define INCLUDE__FILE_UTILS__RELATIONAL_H


#include "hackerlab/machine/types.h"



typedef t_uchar * rel_field;
typedef rel_field * rel_record;
typedef rel_record * rel_table;


struct rel_join_output_spec
{
  int table;
  int field;
};

typedef int * rel_cut_spec;



/* automatically generated __STDC__ prototypes */
extern int rel_n_records (rel_table r);
extern int rel_n_fields (rel_record r);
extern rel_record rel_make_record (t_uchar * field0, ...);
extern void rel_add_records (rel_table * table, ...);
extern void rel_add_field (rel_record * r, t_uchar * field);
extern rel_record rel_singleton_record_n (t_uchar * start, size_t len);
extern void rel_free_table (rel_table t);
extern void rel_free_record (rel_record r);
extern rel_table rel_ws_split (t_uchar * string);
extern rel_table rel_nl_split (t_uchar * string);
extern rel_table rel_copy_table (rel_table t);
extern rel_record rel_copy_record (rel_record r);
extern void rel_append_x (rel_table * out, rel_table t);
extern void rel_reverse_table (rel_table t);
extern void rel_sort_table_by_field (int reverse_p,
                                     rel_table t,
                                     int field_n);
extern void rel_sort_table_by_field_fn (int reverse_p,
                                        rel_table t,
                                        int field_n, 
                                        int (*fn)(t_uchar *, t_uchar *));
extern void rel_sort_table_by_fields (int reverse_p,
                                      rel_table t,
                                      int * fields);
extern int * rel_sort_fields (int f, ...);
extern void rel_uniq_by_field (rel_table * table,
                               int field);
extern rel_table rel_cut (rel_cut_spec fields, rel_table t);
extern rel_record rel_cut_record (rel_cut_spec fields, rel_record r);
extern rel_cut_spec rel_cut_list (int field, ...);
extern rel_table rel_join (int absence_table,
                           struct rel_join_output_spec * output,
                           int table1_field,
                           int table2_field,
                           rel_table table1,
                           rel_table table2);
extern struct rel_join_output_spec * rel_join_output (int table,
                                                      int field, ...);
extern rel_table rel_read_table (int fd,
                                 int n_fields,
                                 char * err_name,
                                 char * err_src);
extern void rel_print_table (int fd, rel_table table);
extern void rel_print_pika_escape_iso8859_1_table (int fd, int escape_classes, rel_table table);
extern void rel_print_table_sp (int fd, rel_table file);
extern void rel_print_pika_escape_iso8859_1_table_sp (int fd, int escape_classes, rel_table file);
#endif  /* INCLUDE__FILE_UTILS__RELATIONAL_H */


/* tag: Tom Lord Sat Jan  5 15:26:10 2002 (relational.h)
 */
