

/*
 * Limey freeload server (Surfer Dude)
 */

#ifndef server_h_INCLUDED
#define server_h_INCLUDED

#include <krb.h>
#include <sys/types.h>
#include <sys/param.h>

#define SERVER_FACILITY LOG_LOCAL4
  
#define MAXUSERNAME 9
#define MAXVOLNAME 30
#define MAXPARTITIONS 20
#define MAXPARTITION 20
#define MAXMOUNTPOINT 64

typedef struct freeload_s {
  char username[MAXUSERNAME];		/* Who got this space? */
  char volname[MAXVOLNAME];		/* What volume did we create? */
  char partition[MAXPARTITION];		/* What afs server/partition was it created on? */
  char mountpoint[MAXMOUNTPOINT];	/* Where did we mount it? */
  time_t issued;			/* When did we create it? */
  long quota;				/* How much space did we give? */
  char servername[MAXHOSTNAMELEN];	/* Which server was down? */
  char serverpath[MAXPARTITION];	/* Where was the locker? */
} Freeload;

/*#define SECSPERDAY 86400*/

#define SECSPERDAY 10
#define DAYSLEFT(tim) (max_lifetime-((time(0)-(tim))/SECSPERDAY))
#define malloc_strcpy(to,from) strcpy((to)=(char*)malloc(strlen((from))+1),(from))

extern char *hostdb_path;               /* pathname to database of hosts down */
extern char *database_path;		/* Pathname to database (not including .dir or .pag) */
extern char *afs_cell;			/* What cell are we in?  (i.e., SIPB.MIT.EDU) */
extern char *mount_path;		/* Pathname to create AFS mountpoints for users */
extern long k_per_user;			/* How much space do give each user (a la afs quota) */
extern long k_total;			/* What's the total amount of space we'll give out? */
extern long max_lifetime;		/* What's the absolute longest we'll let a locker live (in days)? */
extern long grace_period;		/* Days from server up to cutoff (NOT IMPLEMENTED) */
extern char *server_partitions[MAXPARTITIONS]; /* What partitions can we put these things on? */
extern long recheck_time;		/* Seconds between polling of downed partitions */  
extern char *attach; 			/* Pathname of attach program */                    
extern char *detach; 			/* Pathname of detach program */                    
extern char *attach_opt; 		/* Options to give attach */                        
extern char *aklog; 			/* Pathname of aklog */                             
extern char *unlog; 			/* Pathname of unlog */                             
extern char *vos; 			/* Pathname of vos */                               
extern char *pts; 			/* Pathname of pts */                               
extern char *fs; 			/* Pathname of fs */                                
extern char *srvtab; 			/* Pathname to the srvtab */
extern char *volume_base;               /* volume base name */


extern int debug_mode;
extern int disable_afs_admin_commands;
extern int have_afs_admin_tokens;

typedef struct statistics_s {
  long volumes;				/* How many volumes have I made? */
  long space;				/* How much space have I used? */
  long next_partition;			/* What partition do I store the next volume on? */
} Statistics;


#define MAXCONNECTIONS 100
#define MAXINPUTSIZE 2048

typedef struct server_s {
  char partition[MAXPARTITION];
  char hostname[MAXHOSTNAMELEN];
} Server;

typedef struct usercontext_c {
  char name[ANAME_SZ], instance[INST_SZ], realm[REALM_SZ];
  char input[MAXINPUTSIZE];
  int indx;
  int sock;
  int uid;

  /* for the user_context*/
  int list_index;

  /* server stuff */
  Server server;
} UserContext;


#endif
