
/*
 *   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 + EOM, where request_buffer consists of:
 * the request_type + DLMF + parameter1 + DLMF + parameter2 + DLMF + ...
 */
/*
 *   Request Types (from Client to Server)
 *   First parameter for each request is student mit id (SSN - 9 symbols).
 *   If a request has other parameters they will be mentioned below.
 *   Each parameter is delimetered by DLMF.
 */

#define BIO_RECORD                  'b' /* Get BIO record                    */
#define GRADE_HISTORY_TERM_DEF      'h' /* Get Grade History for a specified */
                                        /* term with a default sorting.      */
                                        /* Parameters:                       */
                                        /* - term ("881")                    */
#define GRADE_HISTORY_ALL_DEF       'd' /* Get Grade History for all terms   */
                                        /* with a default sorting            */
#define GRADE_HISTORY_TERM_SORT     'o' /* Get Grade History for a specified */
                                        /* term. Parameters:                 */
                                        /* - term ("881"),                   */
                                        /* - sort clause (ready to use in    */
                                        /*   ORACLE SQL statement)           */
#define GRADE_HISTORY_ALL_SORT      'r' /* Get Grade History for all terms.  */
                                        /* Parameters:                       */
                                        /* - sort clause (ready to use in    */
                                        /*   ORACLE SQL statement)           */
#define TERM_SUMMARY_ALL            't' /* Get Term Summary for all terms    */
#define GRADES_TERM                 'e' /* Get Grades for a specified term   */
                                        /* Parameters:                       */
                                        /* - term ("881")                    */
#define GRADES_ALL                  'g' /* Get Grades for all terms          */
#define AUDIT_STRIP                 'a' /* Get Audit Strip                   */
#define SUBJECT_INFO                's' /* Get Subject Info for all the      */
                                        /* subjects in the current year ?    */
#define UPDATED_BIO_RECORD          'u'

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

#define CR                          "\015"
#define LF                          "\012"
#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.
 */

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;



