
Let's analyze parameters of the command line.
I offer the following logic of a process:

If  parameters  are absent,  then  we  simply  display to  a  stdout
information about both files.

These are possible parameters:

/s - to compare structures of databases.
/c - to compare contents of databases.
/f:condition -  to set a filter.
	It has  meaning if we  compare contents of  files, therefore
	this   parameter   will   switch   on   the   parameter   /c
	automatically.
/o:field,field,field - set order of records.
	It has  meaning if we  compare contents of  files, therefore
	this   parameter   will   switch   on   the   parameter   /c
	automatically.

As the  function main() is ready  and it does not  require a further
completion, the following steps will describe three functions of the
program:
	StructInfo(), 
	CmpStruct(),
	CmpContent().

Here  I  want to  attract  your  attention  to  the fact,  that  the
parameters are  transferred in the  command line, and we  cannot use
symbols <>| in the filter condition.

I offer to replace  them to the following characters: {};. 
In the program  we shall replace them to back.

The setting of a filter is simple:

set_filter(d1, &argv[use_filter][3], NULL);

First parameter - pointer to a database,
second 		- expression of a filter,
third 		- address of a callback function or NULL.

That function should be described  as void __stdcall FCallBack(); 
In that function  you are free to do anything:  to draw progressbar,
percents etc.

The setting of an order of records:

SortBase(d1, &argv[use_order][3], NULL);

First parameter - pointer to a database, 
second 		- fields, delimited with a comma or a semicolon,
third 		- address of a callback function or NULL.


#include "dbf.h"

struct	DBF	*d1, *d2;

int	cmp_struct=0;
int	cmp_content=0;
int	use_order=0;
int	use_filter=0;

void	help();
void	error(char *s);
void	StructInfo();
void	CmpStruct();
void	CmpContent();

int
main(int argc, char *argv[])
{
 int	i;

 if (argc<3) help();

 d1=OpenBase(argv[1]);
 d2=OpenBase(argv[2]);
 if (!d1 || !d2) error("Open error...");

 for(i=3;i<argc;i++)
 {
  if (!stricmp (argv[i], "/s"   ))   cmp_struct =1;
  if (!stricmp (argv[i], "/c"   ))   cmp_content=1;
  if (!strnicmp(argv[i], "/o:",3)) { cmp_content=1; use_order=i;  }
  if (!strnicmp(argv[i], "/f:",3)) { cmp_content=1; use_filter=i; }
 } 

 StructInfo();
 if (cmp_struct)  CmpStruct();

 if (use_filter)
 {
  char	*t;
  int	j;
  t=&argv[use_filter][3];
  j=lstrlen(t);
  for (i=0;i<j;i++)
  {
   if (t[i]=='}') t[i]='>';
   if (t[i]=='{') t[i]='<';
   if (t[i]==';') t[i]='|';
  }

  set_filter(d1, &argv[use_filter][3], NULL);
  set_filter(d2, &argv[use_filter][3], NULL);
 }

 if (use_order)
 {
  SortBase(d1, &argv[use_order][3], NULL);
  SortBase(d2, &argv[use_order][3], NULL);
 }

 if (cmp_content) CmpContent();

 CloseBase(d1);
 CloseBase(d2);

 return 0;
}


void
StructInfo()
{
}

void
CmpStruct()
{
}

void
CmpContent()
{
}

void
help()
{
 puts("DBF File Compare. Version 1.00 Copyright (c) Sergey Chehuta, 2001\n"
      "Use:\n"
      "\tDFC <file1.dbf> <file2.dbf> [switches]\n"
      "Switches:\n"
      "\t/s - compare structure\n"
      "\t/c - compare contenet\n"
      "\t/f:condition...      - set filter\n"
      "\t/o:field1,field2,... - order of records for comparison\n"
     );
 exit(0);
}

void
error(char *s)
{
 puts(s);
 exit(1);
}


