#include "common.h"

/***************************************************
 *
 *  FUNCTION Declaration
 *
 ***************************************************/

FILE *command_line_check();
FILE *open_fname_out();

int gethostname();
int strdup();
int getpid();
int getSATlimit();

/***************************************************
 *
 *  STRUCT Declaration
 *
 ***************************************************/

/* Literal data element */
struct vardata5 {
  int weight;
  int order;
  int vorder;
};

/* Literal data element */
struct litdata5 {
  int weight_new;
  int weight;
};

/***************************************************
 *
 *  CONSTANT Declaration
 *
 ***************************************************/

#define SATBOX_VERSION "1.0"
#define VERSION_DATE "06/04/2004"
#define MAX_ATOM (1+Max_atom)           /* can be anything under MAX_VAR */
#define UNDEF             -1

#define BUILD_TIME          0
#define SEARCH_TIME         1

/***************************************************
 *
 *  MACRO Declaration 
 *
 **************************************************/

#ifdef MORETRACE
#define trace(x,y) if (satbox_flag(TRACE)>=x) y
#define trace1(x,y) if (satbox_flag(TRACE)==x || x>8) y
#define check(x,y) if (x) y
#else
#define trace(x,y) 
#define trace1(x,y) 
#define check(x,y) 
#endif

#define memory_count_set(x) Memory_count = x
#define memory_count_get() (satbox_memory_count()+Memory_count)/1024.0
#define memory_count(x) Memory_count += (x)

#define time_in_second time((long *) NULL)
#define value_of_var(i) satbox_var_value(i)

#define print_x_subsume(k) \
   trace(7, printf("    [C%d] is subsumed by x%d.\n", Clause_num, lit_var(k)))

#define print_x_skip(k) \
   trace(7, printf("    %d in [C%d] is skipped.\n", lit_var(k), Clause_num))

#define print_output_result(s)\
  trace(2, { printf(" %s level %d: ", s, output[0]); \
	           for (i = output[1]; i>1; i--) print_lit(output[i]); \
 	           printf("= true literals\n"); })

/***************************************************
 *
 *  VARIBALE Declaration 
 *
 **************************************************/
/* The initials of names of global variables are capitalized. */
GLOB long Memory_count;   
GLOB unsigned int POS_num, Pure_num, NH_num, Subsume_num; 
GLOB unsigned int Unit_num, Bicl_num, Trcl_num;
GLOB unsigned int Clause_num0, Clause_num, Branch_succ, Branch_skip;
GLOB unsigned long Branch_num;
/* During the search:
   Branch_num = 1 + Branch_succ + Branch_fail + Branch_open + Branch_skip + Branch_jump
   At the end of the search:
   Branch_num = Branch_succ + Branch_fail + Branch_open + Branch_skip + Branch_jump
   */


GLOB struct litdata5 **LD5;
GLOB struct vardata5 **VD5;
GLOB char *Input_file;
GLOB char *line;
GLOB long random_seed;

GLOB int Max_atom;
GLOB int Max_cand;
GLOB int Stop;
GLOB int OLDV;
GLOB int *Old_value;
GLOB int *VarOrder, VarOrderSize, VarOrderFirst;

/* Parameters and Flags */
GLOB int CHOICE2;
GLOB int HOURS; 
GLOB int LINE;
GLOB int MINUTES; 
GLOB int MINVAR; 
GLOB int MODEL;
GLOB int RANJUM;
GLOB int RENAME;
GLOB int RESTRICT;
GLOB int SELECT;
GLOB int TRIE;
GLOB int SBX;
