/*************************************************************************
*   	protocol.h
*
* 	From Server to Client the following is passed: 
* 	message_header + LF + encrypted(message(=buffer)) + EOM.
* 	The structure of buffer depends on the message_header.record_type and
* 	is described in the file tables.h
*
* 	From Client to Server the following is passed:
* 	request_buffer + EOL, where the request_buffer is
* 	the request_type + DLMF + parameter1 + DLMF + parameter2 + DLMF + ...
*       There will be 0, 1, or 2 parameters, depending on the message.
*	Thus:
*
*	request_type 				(always)
		+ DLMF + parameter1        	(if parameter 1)
*	        + DLMF + parameter2       	(if parameter 2)
*	        + EOL				(always)
*
***************************************************************************/

#define REQ_INITIALIZE			'0'
#define REQ_STUDENT_BIO			'1'
#define REQ_MESSAGE_OF_DAY		'2'
#define REQ_GRADES_ALL_TERM_SORT	'3'
#define REQ_GRADES_ALL_SUBJ_SORT	'4'
#define REQ_GRADES_SOME_TERM_SORT	'5'
#define REQ_TERM_SUMMARY		'6'
#define REQ_AUDIT_STRIP			'7'
#define REQ_STATUS_OF_REG		'8'
#define REQ_UPDATED_BIO			'9'
#define REQ_DISCONNECT			'#'

#define NUM_REQUESTS			11

#define DLMF                        ':'
#define DLMF_LEN                    1
#define DLMR                        ';'

#define CR                          "\015"
#define CR_LEN			    1
#define LF                          "\012"
#define LF_LEN			    1
#define CRLF                        "\015\012"
#define EOL                         '\012'          /* End of Line */
#define EOL_LEN                     1
#define EOM                         ".\015\012"     /* End of Message */
#define EOM_LEN                     3
#define EOLM                         "\012.\015\012" /* EOL + EOM */
#define EOLM_LEN                    (EOL_LEN + EOM_LEN)
#define EOC                         "..."
#define EOC_LEN                     3

/*
#define TRUE                        1
*/
#define FILE_IN                     0
#define FILE_OUT                    1

/*
 * Message header is the first part of the message passed from Server to Client
 * Record_type is Request Type.
 */

#define MSG_HEADER_LEN      (13 +  3 * DLMF_LEN  + EOL_LEN)

typedef struct {
                int    buflen;
                short return_code;
                char  record_type;
                short num_records;
                }  message_header_t;

typedef struct  {
                int            buflen;
                char           *bufptr;
                char           *buf_offset;
	        }  buffer_t;

typedef struct  {
                char           rbuffer[300];
	        }  request_buffer_t;
/*
struct _encrypt_struct {
        char    request_type;
        short   encrypt_at_client;
        short   encrypt_at_server;
	}
encrypt_info[NUM_REQUESTS] =
        {
        {REQ_INITIALIZE, 0, 0},
        {REQ_STUDENT_BIO, 0, 1},
        {REQ_MESSAGE_OF_DAY, 0, 0},
        {REQ_GRADES_ALL_TERM_SORT, 0, 1},
        {REQ_GRADES_ALL_SUBJ_SORT, 0, 1},
        {REQ_GRADES_SOME_TERM_SORT, 0, 1},
        {REQ_TERM_SUMMARY, 0, 1},
        {REQ_AUDIT_STRIP, 0, 1},
        {REQ_STATUS_OF_REG, 0, 1},
        {REQ_UPDATED_BIO, 1, 0},
        {REQ_COURSES, 0, 0},
        {REQ_SUBJECT_EXISTS, 0, 0},
        {REQ_ALL_SUBJECTS, 0, 0},
        {REQ_DORMITORIES, 0, 0},
        {REQ_DORM_ADDRESS, 0, 0}
};
*/
