#include "config.h"

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
 
#ifdef SOLARIS 
#include "/usr/ucbinclude/sys/dir.h"
#include <sys/mkdev.h>
#else
#if defined(SYSV) || defined(POSIX)
#include <dirent.h>
#else 
#include <sys/dir.h>
#endif
#endif
#include <sys/param.h>
#if defined(BSD) && !defined(POSIX)
#include <unistd.h>
#endif
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include <sys/errno.h>
#include <Xm/DialogS.h>
#include <Xm/SelectioB.h>
#include <Xm/PushB.h>
#include <Xm/PushBG.h>
#include <Xm/Form.h>
#include <Xm/RowColumn.h>
#include <Xm/Frame.h>
#include <Xm/MessageB.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/List.h>
#include <Xm/Label.h>
#include <Xm/ArrowB.h>
#include <Xm/PanedW.h>
#include <X11/Xlib.h>
/*   solaris/BSD fixes   */
#if defined(SOLARIS) || defined (POSIX)
#  define getwd(a) getcwd(a,MAXPATHLEN-1)
#endif
#ifndef MAXNAMELEN
#  define MAXNAMELEN MAXPATHLEN 
#endif
#if defined(BSD) || defined(SOLARIS)
#  define dirent direct
#endif

/*  directory structure definition  */
typedef struct file_list{
  struct file_list *next_file; 
  char filename[MAXNAMELEN];
  char *fullname;  /* to hold data about link if needed */
  XmString name_str, fullname_str;
  struct stat stats;
  char link_info;
} file_list_struct;
typedef struct head_path{
  int total_files;
  file_list_struct *first_file;
  char pathname[MAXPATHLEN];
  struct head_path *next_path;
} head_path_struct;
typedef struct {
  uid_t id;
  char name[10];  /*  will truncate long usernames  */
} uidname;

typedef struct{
  file_list_struct **file;
  int total;
} index_struct;
typedef struct{
  char source[MAXNAMELEN], *dest;
} copy_file_struct;
typedef struct{
  char source_path[MAXPATHLEN], dest_path[MAXPATHLEN];
  char string_request[1000];
  char button_okay[20], button_cancel[20];
  copy_file_struct *files;
} copy_files_struct;


/* constants */

#define BY_NAME 0
#define BY_INODE 1
#define BY_SIZE 2
#define BY_DATE 3

#define PROMPT 1
#define PROMPT_QUIT 2
#define FULLNAME 4
#define DIR_FIRST 8
#define OVERWRITE 16

#define MAXBUTTONLENGTH 20

#define IS_LINK 4
#define IS_FILE 2
#define IS_DIRECTORY 1
#define NOTHING 0

#define COMPLETE 2
#define PART 1
#define NONE 0

#define LEFT 0
#define RIGHT ~0

#define OK 1
#define CANCEL 2
#define OTHER 4

#define BUFFERSIZE BUFSIZ

#define STRING 0
#define BYTE 1
#define SHORT 2
#define LONG 3

#define FILENAME 0
#define EXTENSION 1
#define PREFIX 2
/* done with constants */

/* Version number... shouldn't be changed....  */
#define VERSION_NO "0.01 alpha"
