/*
 * 4m v2.15 (4m.h)
 * (C) Copyright 1990 by Carrick Sean Casey
 * (C) Copyright 1993 by Scott Chasin and Michaeljon Miller
 *
 * 3-24-93 See file COPYING for copyright information.
 *
 * Client configuration
 */

#include "../h/config.h"
#include "../h/version.h"
#include "../h/protocol.h"

#include <stdio.h>
#include <sys/param.h>

#ifdef ESIX
# undef MAXHOSTNAMELEN
#endif

#include <ctype.h>

typedef struct {
    char *name;
    void (*function) (/* int, char ** */);
    char *command;
}   table;

extern void c_quit(/* int, char ** */), 
            c_hclear(/* int, char ** */), 
            c_hush(/* int, char ** */), 
            c_log(/* int, char ** */), 
            c_replay(/* int, char ** */),
            c_shell(/* int, char ** */), 
            c_time(/* int, char ** */), 
            c_server(/* int, char ** */), 
            s_cmd(/* int, char ** */), 
            set(/* int, char ** */), 
            c_alias(/* int, char ** */),
            c_send(/* int, char ** */), 
            c_get(/* int, char ** */), 
            c_clear(/* int, char ** */), 
            c_eclear(/* int, char ** */), 
            c_chdir(/* int, char ** */), 
            c_pwd(/* int, char ** */),
            s_personal(/* int, char ** */), 
            c_pipe(/* int, char ** */), 
            c_finger(/* int, char ** */), 
            c_version(/* int, char ** */), 
            c_chat(/* int, char ** */);

/* command usage information */

typedef struct Usage {
    char name[9];
    char type;
    char args[128];
    char usage[128];
    struct Usage *prev, *next;
}   USAGE;

/* special global variables */

typedef struct {
    char cmdchar; /* character to prefix a command */
    int verifyquit; /* verify a quit always */
    int pauseonshell; /* make user hit ret on shell return */
    int interactive;  /* nonzero if interactive session */
    int pagesize; /* lines per page */
    int phistory; /* */
    int bufferlines;  /* lines in the review buffer */
    int history;    /* Command history */
    char *logfile;  /* name of session log file */
    int restricted; /* nonzero if in restricted mode */
    int beeps;  /* whether beeps are audible */
    char *shell;  /* Shell to execute upon /! */
    int editorbeep; /* whether the editor beeps */
    char *default_host; /* Default host */
    int default_port; /* Default port */
    char *group;  /* Default group */
    char *nick; /* Default nick */
    char *o_msgformat;  /* Open message format */
    char *p_msgformat;  /* Private message format */
    char *s_msgformat;  /* Private message format */
    char *p_echoback; /* Echoback private format */
    char *statusbar;  /* Status bar format */
}   GLOBS;

typedef struct {
    int s;  /* Socket fd */
    int fd; /* File fd */
    int type; /* Get or Send */
    int status; /* WAITING, ACTIVE */
    int size; /* Filesize in bytes */
    long bytes; /* Bytes read */
    long start; /* Transfer start time */
    long end; /* Transfer end time */
    unsigned long ip; /* ip */
    unsigned short port;  /* Port */
    char who[13]; /* Send to, or get from */
    char *description;  /* Description */
    char filename[80];  /* Filename */
}   XFER;

/* info on the user's tty */

typedef struct {
    char erase; /* tty erase char */
    char kill;  /* tty kill char */
    char redraw;  /* tty reprint line char */
    char werase;  /* tty word erase char */
    int rows; /* tty word erase char */
    int cols; /* tty word erase char */
}   TTYINFO;

/* a linked list of strings */

typedef struct Strlist {
    struct Strlist *next, *prev;
    char str[1];
}   STRLIST;

typedef struct Namlist {
    STRLIST *head, *tail; /* head and tail of name list */
    STRLIST *p; /* user current location in name list */
    int num;  /* current number of name list entries */
    int max;  /* max number of list entries before discard */
}   NAMLIST;

/* misc */

#define CMDCHAR		'/' /* default char for prefixing commands */
#define PERMCMDCHAR	'\\'  /* like above, but can't be changed */

#define NIL     (char *) NULL
#define CHAR    0
#define INT     1
#define LIST    2
#define VALUE   3

#ifndef TRUE
# define TRUE	1
# define FALSE   0
#endif

/* putline flags */

#define PL_SCR		01  /* text may go to screen */
#define PL_LOG		02  /* text may go to session log */
#define PL_BUF		04  /* text may go to review buffer */
#define PL_SL		(PL_SCR|PL_LOG)
#define PL_ALL		(PL_SCR|PL_LOG|PL_BUF)
