File:  [LON-CAPA] / capa / capa51 / pProj / capaRQO.c
Revision 1.1: download - view: text, annotated - select for diffs
Tue Sep 28 21:26:22 1999 UTC (24 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
Initial revision

    1: #include <stdio.h>
    2: #include "capaCommon.h"
    3: #include "capaParser.h"
    4: #include "capaRQO.h"
    5: extern RandQO_t          *QuestionOrder;
    6: 
    7: /*FIXME I don't actually do anything yet*/
    8: void rqo_finish()
    9: {
   10:   printf("rqo_finish\n");
   11: }
   12: 
   13: void rqo_1spec()
   14: {
   15:   printf("rqo_1spec\n");
   16: }
   17: 
   18: void rqo_2spec()
   19: {
   20:   printf("rqo_2spec\n");
   21: }
   22: 
   23: void init_rqo()
   24: {
   25:   QuestionOrder=(RandQO_t*) capa_malloc(sizeof(RandQO_t),1);
   26:   QuestionOrder->num=0;
   27:   QuestionOrder->used=(int *) capa_malloc(sizeof(int)*MAX_BUFFER_SIZE,1);
   28:   QuestionOrder->length=MAX_BUFFER_SIZE;
   29:   QuestionOrder->groups=(RandGroup_t**)capa_malloc(sizeof(RandGroup_t*)*MAX_BUFFER_SIZE,1);
   30:   QuestionOrder->length=MAX_BUFFER_SIZE;
   31: }
   32: 
   33: int rqo_used(int a)
   34: {
   35:   if (QuestionOrder->used[a]) return 1;
   36:   QuestionOrder->used[a]=1;
   37:   return 0;
   38: }
   39: 
   40: void rqo_expand_range()
   41: {
   42:   /*int num=QuestionOrder->num-1;*/
   43: }
   44: 
   45: void start_rqo_type(int type)
   46: {
   47:   int num;
   48:   printf("start_rqo_type,%d\n",type);
   49:   if (!QuestionOrder) {init_rqo();}
   50:   if (QuestionOrder->groups[(QuestionOrder->num)-1]->type == RANGE) rqo_expand_range();
   51:   num=QuestionOrder->num;
   52:   QuestionOrder->groups[num]=(RandGroup_t*)capa_malloc(sizeof(RandGroup_t),1);
   53:   QuestionOrder->groups[num]->type=type;
   54:   QuestionOrder->groups[num]->length=0;
   55:   QuestionOrder->groups[num]->list=(int *) capa_malloc(sizeof(int)*MAX_BUFFER_SIZE,1);
   56:   QuestionOrder->num++;
   57: }
   58: 
   59: void append_rqo(Symbol*s)
   60: {
   61:   int num=QuestionOrder->num-1;
   62:   printf("append_rqo,%ld\n",s->s_int);
   63:   QuestionOrder->groups[num]->list[QuestionOrder->groups[num]->length]=s->s_int;
   64:   QuestionOrder->groups[num]->length++;
   65:   if (rqo_used(s->s_int)) {
   66:     char warn_msg[WARN_MSG_LENGTH];
   67:     sprintf(warn_msg,"Question %ld, used twice in /RQO",s->s_int);
   68:     capa_msg(MESSAGE_ERROR,warn_msg);
   69:   }
   70:   capa_mfree((char*)s);
   71: }
   72: 
   73: void prefix_rqo(Symbol*s)
   74: {
   75:   int i, num=QuestionOrder->num-1;
   76:   printf("prefix_rqo,%ld\n",s->s_int);
   77:   for(i=(QuestionOrder->groups[num]->length);i>0;i--) {
   78:       QuestionOrder->groups[num]->list[i]=QuestionOrder->groups[num]->list[i-1];
   79:   }
   80:   QuestionOrder->groups[num]->list[0]=s->s_int;
   81:   QuestionOrder->groups[num]->length++;
   82:   if (rqo_used(s->s_int)) {
   83:     char warn_msg[WARN_MSG_LENGTH];
   84:     sprintf(warn_msg,"Question %ld, used twice in /RQO",s->s_int);
   85:     capa_msg(MESSAGE_ERROR,warn_msg);
   86:   }
   87:   capa_mfree((char*)s);
   88: }
   89: 

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