#ifndef __xznol_h__
#define __xznol_h__

/*
 * $Id: xznol.h,v 1.3 92/07/05 00:33:31 marc Exp $
 */

#include <sys/types.h>
#include <sys/time.h>
#include <X11/Intrinsic.h>
#include <X11/Xaw/Table.h>
#include <zephyr/zephyr.h>

#define LINE_USER 0
#define LINE_KNAME 1
#define LINE_FULL 2
#define LINE_NICK 3
#define LINE_OFFICE 4
#define LINE_OPHONE 5
#define LINE_HPHONE 6
#define LINE_USERBASE 7
#define LINE_HOST 7
#define LINE_TIME 8
#define LINE_TTY 9
#define LINE_TABLEBASE 10

typedef struct _user {
   char *line[LINE_USERBASE];

   struct _table **tables;
   int ntables;

   time_t lastloc;
   int recheck;

   struct _user *next;
} user;

typedef struct _peruser {
   struct _user *u;
   char *info;
} peruser;

typedef struct _table {
   Widget w;

   XawTableLine *lines;
   int nlines;
   int alines;

   peruser *users;
   int nusers;
   int ausers;

   /* resources */
   char *file;
   int recheck;
} table;

/* functions which operate on user * */

Widget user_list_constructor(Widget parent, char *name);
void make_user_line(user *u, char *name, char *kname);
void free_user_line(user *u);
user *find_user_field(int field, char *name);
user *find_user(char **l);
char *get_user_fnum_text(user *u, int fnum);
char *get_user_field_text(user *u, char *field);
void add_user(table *t, char *name, char *info);
void redisplay_user(char *kname);
int login_user(char *kname, ZLocations_t *zloc);
int logout_user(char *kname, ZLocations_t *zloc);
int replace_user(char *kname, ZLocations_t *zloc, int nzloc);
void locate_user(user *u);
void sub_user(user *u);
void locate_all_users(int force);
void sub_all_users();

/* functions which operate on table * */

char *table_file(table *t);
int table_recheck(table *t);
void locate_table(table *t);
void sub_table(table *t);
void recheck_table_timer(XtPointer client_data, XtIntervalId *timer);
void table_init_line(XawTableLine *l);
table *widget_to_table(Widget w);
Widget table_constructor(Widget parent, char *name);
void add_user_to_table(table *t, user *u, char *info);
void delete_user_from_table(table *t, user *u);
char *get_user_info_from_table(table *t, user *u);
void redisplay_table(table *t);
int login_user_in_table(table *t, char **l, ZLocations_t *zloc);
int logout_user_in_table(table *t, char **l, ZLocations_t *zloc);
int replace_user_in_table(table *t, char  **l, ZLocations_t *zloc,
			  int nzloc);

/* other functions */

Widget user_table_text_constructor(Widget parent, char *name);
Widget adduser_text_constructor(Widget parent, char *name);
void set_label_to_field(Widget w, XtPointer client_data, XtPointer call_data);
void process_xinput(void);
void add_zwfn_timeout(int timeout);
int app_zwfn();
void remove_zwfn_timeout();

#endif
