/*
 * Copyright 1988, 1989, 1990, 1991 Massachusetts Institute of Technology
 */
#ifndef STRUCTS_H
#define STRUCTS_H

/* MASSIVE SERVER BUG IS AVOIDED if FORKSPIN IS USED */
#define FORKSPIN

#include "tunables.h"

typedef struct {
  int switcher;
  int channel;
} Output;

#include<stdio.h>
#include<signal.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<sys/time.h>
#include<sys/ioctl.h>
#include<sys/errno.h>
#ifdef SYSLOG
#include<syslog.h>
#else /* SYSLOG */
#include"bsdsyslog.h"
#endif /* SYSLOG */
#define bsdopenlog intopenlog
#define bsdsyslog intsyslog
#ifdef SYSV
#include <sgtty.h>
#include<string.h>
#include<fcntl.h>
#endif /* SYSV */
#include<sys/file.h>
#ifndef SYSV
#include<strings.h>
#include<netinet/tcp.h>
#include<arpa/inet.h>
#include<sys/resource.h>
#endif /* SYSV */
#include<netinet/in.h>
#include<netdb.h>
#include<ctype.h>
#include<pwd.h>
#include<sys/stat.h>
#include<sys/param.h>
#define SYSINCLUDES   /* keeps Glib.h from including same files */
#include"../Glib/Glib.h"
#include"dcm/videoconf.h"
#include"rpd_driv.h"
#include"swtr_driv.h"
#include "inp_driv.h"
#include "dbm.h"

#ifdef UNIXCONN
#ifndef UNIXINCED
#define UNIXINCED
#include<sys/un.h>
#endif /* UNIXINCED */
#endif /* UNIXCONN */

#ifdef inter386
#include <sys/bsdtypes.h>
#include <net/errno.h>
#endif /* inter386 */

#ifndef NETRPD
#define NETRPD 4
#endif /* NETRPD */
#ifndef NETSWTR
#define NETSWTR 5
#endif /* NETRPD */
#ifndef NETRPD_RECORD
#define NETRPD_RECORD 17
#endif /* NETRPD_RECORD */
/* HP-UX won't let me include termio.h and sgtty.h well */
#ifndef PARENB
#define PARENB 0001000
#endif /* PARENB */
#ifndef PARODD
#define PARODD 0002000
#endif /* PARODD */

#ifndef TCFLSH
#ifdef hpux
#define TCFLSH  _IO(T,7)
#else /* hpux */
#define TCFLSH (TIOC|7)
#endif /* hpux */
#endif /* TCFLSH */

#define USED 1
#define UNUSED 0
#define BUSY 0
#define NOT_BUSY 1
#define AVAILABLE 2

/* the number is actually the rev * 10 so that its an int */
#define SERVER_REVISION 25
#define PROTOCOL_REVISION 25

#define QUERY "areyouthere"
#define RESPONSE "imhere"
#define UNIX_STRING "UNIX connection"

typedef struct {
  char volume[30];
  int type;
  int resource[10];
  int output;
  int num_resources;
  int cur_resource;
  int index_state;
  int recordable;
} DeviceList;


typedef struct {
  int sock;
  char *address;
  int rev;
  int db_rev;
  int local;
  int output;
  RPD_SEGLIST *seglist;
  G_INT32 uid;
} Client;

typedef struct {
  char name[30];
  int fd;
} Forward;

#include "externs.h"

#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif /* MAX */
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif /* MIN */


/* cmds passed into the extension's ctrl function using extctrl(cmd, data) */

#define EXT_INIT 0
#define EXT_PREBUILD 1
#define EXT_POSTBUILD 2
#define EXT_PERIODIC 3
#define EXT_SHUTOFF 4

int extnumexts(), extctrl(), extdeal();
char *extname();

#endif /* STRUCTS_H */


