/*
 * ccd.h
 */

/* $Id: ccd.h,v 1.8 1993/07/03 12:44:41 beust Exp $ */

#ifndef __CCD_H__
#define __CCD_H__

#include "database.h"

#define CCD_VAR_LAST_DIR "ccd/LAST_DIR"
#define CCD_FILE_DEFAULT_CONFIG "ccd:.ccdconfig"
#define CCD_FILE_DEFAULT_ANTI_CONFIG "ccd:.ccdanticonfig"
#define CCD_FILE_REXX "t:ccdChangeDir.rexx"
#define CCD_FILE_GUIDE "t:ccd.guide"

/* How each line of the config file is represented */
typedef struct _Entry {
  char *fullPath;      /* full pathname of the entry */
  char *name;         /* name that will appear in the GUI */
  char *spaces;      /* number of spaces to put before */
  int line;
} *Entry;

/* The options given on the command line */
struct Prefs {
  LONG create;            /* BOOL actually */
  LONG update;            /* BOOL actually */
  char *configFile;
  char *antiConfigFile;
  LONG noExpand;          /* BOOL actually, but must be long-aligned */
  LONG showAmbiguities;   /* BOOL actually */
  LONG gui;               /* BOOL actually */
  LONG verbose;           /* BOOL actually */
  char **dirs;
};

struct GlobalVars {
  struct IntuitionBase *IntuitionBase;
  char *usage;
  struct Prefs prefs;
  DataBase db;                /* will contain the descriptors (struct _Entry) */
  DataBase ambdb;            /* will contain the ambiguities (struct _Entry) */
  DataBase antidb;          /* will contain the anti database (struct _Entry) */
  char actualdir[128];
  struct Window *win;
  int configLines;    /* number of lines in ccdconfig */
  int actualLine;
  BPTR lockList[128];
  int lockpt;
  int dirCount;    /* number of directories on the command line */
};

/****************************************************************************/
/* ccd.c */
/****************************************************************************/

void
displayDir(struct GlobalVars *gv, int line);
/* Display the directory of the volume in the window, starting at the */
/* line in the config file */

void updatePrompt(char *currentdir);
/* Update the concerned field with the new current dir                 */
/* This routine is for users of wshell or such, thar display this name */
/* as the shell prompt.                                                */
/* This trick was previously pointed to me by Henry J. Cobb on Usenet  */
/* for my 'find' program (another great utility of mine :-)).          */
/* Let him be thanked again!                                           */

void getRealName(struct GlobalVars *gv, BPTR lock, char *result);
/* This is a very useful function! Put in result path of lock */
/* Assume lock is not null */
/* Result always device:dir/dir/...   */

void changeDir(struct GlobalVars *gv, char *dir, int occ);
/* The main function to change to the fragment of dir given,  */
/* to the occ'th occurence found in the config file */
/* New 1.3: first, try to cd right into 'dir' */

void showAmbiguities(struct GlobalVars *gv, char *dir);
/* Display the directory of the volume in the window */

/****************************************************************************/
/* graphics.c */
/****************************************************************************/

void
displayTree(struct GlobalVars *gv, DataBase db);
/* Graphically display the tree */
/* The selected directory will be found in the variable $CCD/LAST_DIR */

#endif
