// $Id: uciosess.h,v 1.1 2008/05/31 00:35:09 lpoulsen Exp $
//
// Copyright (c) 2008 by AFAR Communications Inc, Santa Barbara, CA 93117 USA
//
// Command parser session control structure definitions
// Ported from Afar's embedded software code tree May 2008
//
// $Log: uciosess.h,v $
// Revision 1.1  2008/05/31 00:35:09  lpoulsen
// Econ 4.x preview - now with command shell
//
//
#ifndef _UCIO_SESSION_H    // include only once per build
#define _UCIO_SESSION_H

#define UCIO_SESSION_STKSIZE 8192
#define MAX_COMMAND_SIZE 80
#define HISTORY_SIZE 40
#define MAX_PROMPT_SIZE 31	// one less than n*4

#define MAX_UCIO_SESSIONS 6
#define TASK_CMD_PRIORITY 2
#define SESSION_BUFFER_SIZE 128
#define SEND_FLUSH_THRESHOLD 950 // must be less than 1500
#define WAIT_FOR_CHAR 5000

#ifdef __cplusplus
extern "C" {
#endif

typedef void (command_task_func)(int sidx);

typedef enum {
    SESS_UNUSED,
    SESS_ALLOCD,
    SESS_ACTIVE,
    SESS_LOGOUT,
    SESS_CLOSED
} sess_state;

typedef struct {
    int        taskID;
    uint16     session_flags;
#define SESSION_VALID  1
#define SESSION_NOEXIT 2
    int        session_id;
    FILE      *session_infile;
    FILE      *session_outfile;
    char       session_prompt[MAX_PROMPT_SIZE+1];
    boolean    session_unlocked;
    boolean    session_config;
    sess_state session_state;
    uint32     timestamp ;
} ucio_session;

extern void         session_set_prompt(char *nodename);

extern int          checkForSessionTimeout(void);
extern void         show_consoles(FILE *out);
extern void         ucio_econ_details(FILE *target, FILE *out);
extern void         ucio_tcp_details(FILE *target, FILE *out);
#ifdef __cplusplus
}
#endif

#endif
