Annotation of capa/capa51/pProj/capaCommon.h, revision 1.1

1.1     ! albertel    1: 
        !             2: /**********************************************************/
        !             3: /*   This header defines Application Interface to the     */
        !             4: /*    CAPA system.  It needs capaParser.h and capaToken.h */
        !             5: /*    CAPA version 4.3                                    */
        !             6: /*    Date Oct 23 1995                                    */
        !             7: /*   Isaac Tsai                                           */
        !             8: /*                                                        */
        !             9: /*   Get rid of old style structure definition *_t        */
        !            10: /*   Make all structure definition begin with T_          */
        !            11: /*   1997, 1998, 1999  Isaac Tsai                         */
        !            12: /**********************************************************/
        !            13: 
        !            14: #ifndef   CAPA_COMMON_H
        !            15: #define   CAPA_COMMON_H
        !            16: 
        !            17: #include <stdio.h>
        !            18: #ifdef linux
        !            19: #include <stdlib.h>
        !            20: #endif
        !            21: #ifdef NeXT
        !            22: #include <stdlib.h>
        !            23: #include <libc.h>
        !            24: #else
        !            25: #include <malloc.h>
        !            26: #include <unistd.h>
        !            27: #endif
        !            28: 
        !            29: #include <math.h>
        !            30: #include <string.h>
        !            31: #include <time.h>
        !            32: #include <sys/fcntl.h>    /* lockf()  */
        !            33: #include <sys/file.h>     /* flock()  */
        !            34: #include <sys/types.h>
        !            35: #include "capaParser.h"
        !            36: 
        !            37: #ifndef    MAX
        !            38: #define    MAX(a,b) ((a>b)? (a):(b))
        !            39: #endif
        !            40: 
        !            41: #define    MAX_SECTION_SIZE    10240    /* Max # of students in the class */
        !            42: #define    MAX_SECTION_COUNT   1024
        !            43: #define    MAX_NAME_CHAR       30      /* Student's name max length      */
        !            44: #define    MAX_STUDENT_NUMBER   9      /* Student Number length          */
        !            45: #define    MAX_EMAIL_CHAR      40      /* Email address */
        !            46: #define    FILE_NAME_LENGTH    1024
        !            47: #define    MAX_PIN_CHAR        4
        !            48: #define    MAX_BUFFER_SIZE     2048
        !            49: #define    TMP_LINE_LENGTH     2048     /* used to read in log.db set.db dates.db */
        !            50: #define    SMALL_LINE_BUFFER   128     /* used to read classl, active.db */
        !            51: #define    SETDB_BUF_SIZE      (256*1024)
        !            52: /*  user input string length now in capaParser.h*/
        !            53: /*#define    ANSWER_STRING_LENG       81*/
        !            54: /*#define    UNIT_STRING_LENG         64*/
        !            55: #define    FORMAT_STRING_LENG       32
        !            56: 
        !            57: /* -------- used in check_date() */
        !            58: #define    CHECK_OPEN_DATE      1
        !            59: #define    CHECK_DUE_DATE       2
        !            60: #define    CHECK_ANS_DATE       3
        !            61: 
        !            62: 
        !            63: 
        !            64: /******************************************************************************/
        !            65: /* STRUCTURE FOR THE HEADER OF A DATABASE FILE                                */
        !            66: /******************************************************************************/
        !            67: 
        !            68: typedef struct {
        !            69:   char   num_questions[FORMAT_STRING_LENG];
        !            70:   char   *weight;
        !            71:   char   *partial_credit;
        !            72: }  T_header;
        !            73: 
        !            74: /******************************************************************************/
        !            75: /* STRUCTURE FOR A NORMAL DATABASE FILE ENTRY                                 */
        !            76: /******************************************************************************/
        !            77: 
        !            78: typedef struct {
        !            79:  char    student_number[MAX_STUDENT_NUMBER+1]; /* Student number */
        !            80:  int     e_probs;
        !            81:  char   *answers; /* String of answers */
        !            82:  char   *tries;
        !            83: } T_entry;
        !            84: 
        !            85: /******************************************************************************/
        !            86: /* STRUCTURE FOR A STUDENT IN THE STUDENT ARRAY                               */
        !            87: /******************************************************************************/
        !            88: 
        !            89: typedef struct _student {
        !            90:    struct _student *s_next;
        !            91:    struct _student *s_prev;
        !            92:    int    s_sec;
        !            93:    int    s_scores;
        !            94:    char   s_key[MAX_NAME_CHAR+MAX_NAME_CHAR+2]; /* sorting key */
        !            95:    char   s_sn[MAX_STUDENT_NUMBER+1];
        !            96:    char   s_nm[MAX_NAME_CHAR+1];
        !            97:    char   s_email[MAX_EMAIL_CHAR+1];
        !            98:    int    s_capaid;
        !            99: }  T_student;
        !           100: 
        !           101: /******************************************************************************/
        !           102: /* STRUCTURE FOR Login dates for a set                                        */
        !           103: /******************************************************************************/
        !           104: /*section number DATE_DEFAULTs contains the default dates an assignment is due*/ 
        !           105: #define DATE_DEFAULTS 0
        !           106: #define OPEN_OFFSET 0
        !           107: #define DUE_OFFSET 17
        !           108: #define ANSWER_OFFSET 34
        !           109: #define DATE_LENGTH 16
        !           110: #define DATE_BUFFER 17
        !           111: #define OPTION_INHIBIT_RESPONSE 100
        !           112: #define OPTION_VIEW_PROBLEMS_AFTER_DUE 101
        !           113: typedef struct _date {
        !           114:   struct _date *s_next;
        !           115:   int    section_start;
        !           116:   int    section_end;
        !           117:   char   open_date[DATE_BUFFER];
        !           118:   char   due_date[DATE_BUFFER];
        !           119:   char   answer_date[DATE_BUFFER];
        !           120:   char   duration[DATE_BUFFER];
        !           121:   int    inhibit_response;
        !           122:   int    view_problems_after_due;
        !           123: } T_dates;
        !           124: 
        !           125: /******************************************************************************/
        !           126: /* STRUCTURE FOR Login history for a student                                  */
        !           127: /******************************************************************************/
        !           128: typedef struct {
        !           129:  int     count;  /* Number of questions */
        !           130:  char   *answers; /* String of answers   */
        !           131: } login_history_t;
        !           132: 
        !           133: #define	leap_year(yr) ((yr) <= 1752 ? !((yr) % 4) : !((yr) % 4) && (((yr) % 100) || !((yr) % 400)))
        !           134: 
        !           135: #define	centuries_since_1700(yr) ((yr) > 1700 ? (yr) / 100 - 17 : 0)
        !           136: 
        !           137: #define	quad_centuries_since_1700(yr)  ((yr) > 1600 ? ((yr) - 1600) / 400 : 0)
        !           138: 
        !           139: #define	leap_years_since_year_1(yr)  ((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
        !           140: 
        !           141: /*=============================================================================*/
        !           142: /* CAPA PROTOTYPES FOR FUNCTIONS IN COMMON.C                                   */
        !           143: /*=============================================================================*/
        !           144: /*-----------------------------------------------------------------------------*/
        !           145: int   capa_get_section  CAPA_ARG((T_student **student_pp, int section));
        !           146: int   capa_sorted_section  CAPA_ARG((T_student **student_pp, int section));
        !           147: void  msort_main        CAPA_ARG((T_student **head_pp));
        !           148: void  msort_split       CAPA_ARG((T_student *a_sp, T_student **b_pp));
        !           149: void  msort_merge       CAPA_ARG((T_student *a_sp, T_student *b_sp, T_student **c_pp));
        !           150: int   capa_get_student  CAPA_ARG((char *student_number,T_student *student_p));
        !           151: int   capa_student_byname  CAPA_ARG((char *student_name,T_student *student_p));
        !           152: int   capa_pick_student CAPA_ARG((int  section, T_student *student_p));
        !           153: int   capa_add_student  CAPA_ARG((T_student *student_p));
        !           154: int   capa_parse        CAPA_ARG((int  set,Problem_t **problem,char *student_number,int *num_questions,void (*func_ptr)()));
        !           155: int   capa_parse_student CAPA_ARG((int  set,Problem_t **problem,T_student *astudent,int *num_questions,void (*func_ptr)()));
        !           156: void  free_problems     CAPA_ARG((Problem_t *problem_p));
        !           157: void  free_students     CAPA_ARG((T_student *student_p));
        !           158: void  free_units        CAPA_ARG(());
        !           159: int   read_capa_config  CAPA_ARG((char* key_word, char *value));
        !           160: int   capa_access       CAPA_ARG((const char *pathname, int mode));
        !           161: /*-----------------------------------------------------------------------------*/
        !           162: void  capa_seed         CAPA_ARG((long *seed1, long *seed2, char *student_number));
        !           163: int   capa_PIN          CAPA_ARG((char *student_number, int set, int guess));
        !           164: char* capa_id_plus      CAPA_ARG((char *student_number, int set, int plus));
        !           165: int   capa_set_header   CAPA_ARG((T_header *header, int set));
        !           166: int   capa_get_header   CAPA_ARG((T_header *header, int set));
        !           167: 
        !           168: int   capa_set_entry    CAPA_ARG((T_entry *entry, char *student_number, int set, long offset));
        !           169: int   capa_change_entry    CAPA_ARG((T_entry *entry, char *student_number, int set));
        !           170: long  capa_append_entry CAPA_ARG((T_entry *entry, char *student_number, int set));
        !           171: long  capa_get_entry    CAPA_ARG((T_entry *entry, char *student_number, int set));
        !           172: int   capa_excuse       CAPA_ARG((int set, int prob, int section));
        !           173: int   capa_get_score    CAPA_ARG((char *student_number, int set, int *valid_scores, char **answers_pp));
        !           174: char* capa_get_seat     CAPA_ARG((char *studentnum, char *seatfile));
        !           175: /*-----------------------------------------------------------------------------*/
        !           176: int   capa_get_login_count    CAPA_ARG((char *student_number,int set));
        !           177: int   capa_get_login_db       CAPA_ARG((T_entry *login_item,int *num_probs,int set));
        !           178: int   capa_get_section_count  CAPA_ARG((int *cnt_arry));
        !           179: int   login_check       CAPA_ARG((char *student_number));
        !           180: int   logout_check      CAPA_ARG((char *student_number));
        !           181: /*-----------------------------------------------------------------------------*/
        !           182: int   flockstream_sh    CAPA_ARG((FILE *fp));
        !           183: int   flockstream       CAPA_ARG((FILE *fp));
        !           184: int   funlockstream     CAPA_ARG((FILE *fp));
        !           185: /*-----------------------------------------------------------------------------*/
        !           186: time_t convertTime       CAPA_ARG((char *dateStr,char *timeStr));
        !           187: int    weekday           CAPA_ARG((int year, int month, int day));
        !           188: int    julianday         CAPA_ARG((int year, int month, int day));
        !           189: /*int    compare_datetime  CAPA_ARG((time_t time,char *datetime));*/
        !           190: int    capa_check_date   CAPA_ARG((int which,char *student_number,int section,int set));
        !           191: int    capa_get_date     CAPA_ARG((int which,char *student_number,int section,int set,char *date_str));
        !           192: void   free_dates        CAPA_ARG((T_dates *dates));
        !           193: int    capa_get_all_dates CAPA_ARG((int set, T_dates **dates));
        !           194: int    capa_set_all_dates CAPA_ARG((int set, T_dates *dates));
        !           195: int    capa_get_section_dates CAPA_ARG((int section,int set,T_dates** dates));
        !           196: T_dates* add_date_info    CAPA_ARG((int lowsec,int highsec, char *dateinfo));
        !           197: int    capa_get_login_time CAPA_ARG((char *student_number,int set,time_t *logintime));
        !           198: int    capa_set_login_time CAPA_ARG((char *student_number,int set));
        !           199: int    capa_get_duration  CAPA_ARG((char *student_number,int section,int set));
        !           200: int    capa_check_option  CAPA_ARG((int option,int set,int section));
        !           201: int    check_int          CAPA_ARG((char *an_int ));
        !           202: int    check_real         CAPA_ARG((char *a_real ));
        !           203: char  *answers_string     CAPA_ARG((int mode, Problem_t  *p ));
        !           204: int    capa_check_ans     CAPA_ARG((AnswerInfo_t *ai, char *answer));
        !           205: int    capa_check_answer  CAPA_ARG((Problem_t *p, char *answer));
        !           206: int    capa_check_answers CAPA_ARG((Problem_t *p, char **answers, int cnt));
        !           207: int    check_formula_ans  CAPA_ARG((char *fml_str,char *input_str,char *var_list,PointsList_t *pts_list,int tol_type,double tol));  
        !           208: 
        !           209: int    is_all_ws          CAPA_ARG((char *answer));
        !           210: void   trim_response_ws   CAPA_ARG((char *answer));
        !           211: void   throwaway_line     CAPA_ARG((FILE* fp));
        !           212: void   protect_log_string CAPA_ARG((char* log_string));
        !           213: int    calc_ansrange  CAPA_ARG((int type,int calc_type,char *input,char *fmt,int tol_type,double tol,char *lower,char *upper));
        !           214: /*-----------------------------------------------------------------------------*/
        !           215: int    capa_set_subjective CAPA_ARG((int set,int problem,char *student_num,char* response));
        !           216: char*  capa_get_subjective CAPA_ARG((int set,int problem,char *student_num));
        !           217: /*============================================================================*/
        !           218: 
        !           219: #endif  /* CAPA_COMMON_H  */
        !           220: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>