/* Header for the low-level Bbuuzzb sort routines.
   Rick Smereka, Copyright (C) 2002.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, get a copy via the Internet at
   http://gnu.org/copyleft/gpl.html or write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   MA 02111-1307 USA

   You can contact the author via email at rsmereka@future-lab.com

   Original Linux version Aug/2002, Rick Smereka

   Ported to Debian Linux. Nov/2002, Rick Smereka

   Ported to QNX, 32bit Windows and DOS. Dec/2002, Rick Smereka */

/* sort element node */

struct dbeng_sort_node
   {
   char *arec;
   struct dbeng_sort_node *next;
   };

/* sort spec node */

struct dbeng_sort_spec
   {
   int order;
   int field_num;
   struct dbeng_sort_spec *next;
   };

/* sort bin file node */

struct dbeng_sort_bin
   {
   struct dbeng_table *abin;
   struct dbeng_sort_bin *next;
   };

/* sort orders */

#define DBENGSRT_ORDER_ASCENDING 1
#define DBENGSRT_ORDER_DESCENDING 2

/* NULL pointer defines */

#define DBENGSRT_ROT_NULL ((struct dbeng_sort_node *)NULL)
#define DBENGSRT_SOT_NULL ((struct dbeng_sort_spec *)NULL)
#define DBENGSRT_BOT_NULL ((struct dbeng_sort_bin *)NULL)

/* 'dbeng_sort_bll_delete' flags */

#define DBENGSRT_NDELBIN 1
#define DBENGSRT_DELBIN 2

/* default maximums */

#define DBENGSRT_MAX_SORT_ALLOC 100000L
#define DBENGSRT_MAX_OPEN_BIN 10

#ifdef __cplusplus
extern "C"
{
#endif

int dbeng_sort(struct dbeng_table *, char *);
int dbeng_sort_get_max_mem(struct dbeng_table *, long *);
int dbeng_sort_set_max_mem(struct dbeng_table *, long);
int dbeng_sort_get_max_open_bin(struct dbeng_table *, int *);
int dbeng_sort_set_max_open_bin(struct dbeng_table *, int);

#ifdef __cplusplus
}
#endif
