Esempio n. 1
0
void TimerRegister(
                struct HANDLER_OBJECT * newTimer,
                TIME wait,
                HANDLER_FUNCTION * handler,
                void * context )
{
        TIME time = TimeGet();
        TIME timerTime = time + wait;

        IsrDisable(IRQ_LEVEL_MAX);

        //Construct timer
        HandlerRegister( newTimer );
        newTimer->Function = handler;
        newTimer->Context = context;

        //Add to heap
        if ( timerTime >= time ) {
                HeapAdd(timerTime, &newTimer->Link.WeightedLink, Timers );
        } else {
                //Overflow ocurred
                HeapAdd(timerTime, &newTimer->Link.WeightedLink, TimersOverflow);
        }

        IsrEnable(IRQ_LEVEL_MAX);
        //Because we added a new timer, we may want to wait
        //a different amount of time than previously thought.
        //Lets update the hardware countdown.
        TimerSetNextTimer(time);

}
Esempio n. 2
0
void near FiltOverride(void *v, char *words[], char *line)
{
  OVRLIST ol=malloc(sizeof(*ol));
  int idx;

  NW(line);

  if (!ol)
    NoMem();

/* 0        1       2         3          4 */
/* override message msg_reply sysop/1234 R */

  if (!*words[1])
  {
    printf("Error!  No menu name specified for override on line %d!\n", linenum);
    return;
  }

  if (!*words[3])
  {
    printf("Error!  No access control string specified for override on line %d!\n", linenum);
    return;
  }

  if ((idx=tsearch(words[2], silt_table, silt_table_size)) != -1)
    ol->or.opt=silt_table[idx].opt;
  else Unknown_Ctl(linenum, words[2]);

  if (*words[4])
    ol->or.name=*words[4];
  else ol->or.name=0;

  if (PFI(v)->marea)
  {
    HeapAdd(&PMI(v)->h, &ol->or.menuname, words[1]);
    HeapAdd(&PMI(v)->h, &ol->or.acs, words[3]);

    /* Add this to the linked list of override options */

    ol->next=PMI(v)->ol;
    PMI(v)->ol=ol;

    PMI(v)->ma.num_override++;
  }
  else
  {
    HeapAdd(&PFI(v)->h, &ol->or.menuname, words[1]);
    HeapAdd(&PFI(v)->h, &ol->or.acs, words[3]);

    /* Add this to the linked list of override options */

    ol->next=PFI(v)->ol;
    PFI(v)->ol=ol;

    PFI(v)->fa.num_override++;
  }
}
Esempio n. 3
0
static void near FiltBarricade(void *v, char *words[], char *line)
{
  NW(line);

  if (! *words[1] || !*words[2])
  {
    printf("\n\aError!  Two arguments required for Barricade keyword on line %d!\n", linenum);
    Compiling(-1,NULL,NULL);
  }

  HeapAdd(&PMI(v)->h, &PMI(v)->ma.barricademenu, words[1]);
  HeapAdd(&PMI(v)->h, &PMI(v)->ma.barricade, words[2]);
}
Esempio n. 4
0
int Merge (int arrays[][4], int k, int n, int result[]) 
{
	int i=0, j=0, r=0; 
	HeapNode *node = NULL, *minnode = NULL;
	Heap *h = NULL;
	init_heap (&h, k);

	for (i=0; i<k; i++) {
		node = newnode();
		node->data = arrays[i][0];
		node->array = i;
		node->index = 1;
		HeapAdd (h, node, i);
	}
	MinHeap (h);

	r = 0;

	for (i=0; i<n*k; i++) {
		minnode = getMin (h);

		result[r++] = minnode->data;

		if (minnode->index < n) {
			minnode->data = arrays[minnode->array][minnode->index];
			minnode->index++;
		} else {
			minnode->data = MAX;
		}
		MinHeapify (h, 0);
	}

	return 0;
}
Esempio n. 5
0
void near FiltMenuname(void *v, char *words[], char *line)
{
  NW(line);

  if (! *words[1] || !*words[2])
    printf("\n\aError!  Two arguments must be specified for the MenuName keyword!\n");

  if (PFI(v)->marea)
  {
    HeapAdd(&PMI(v)->h, &PMI(v)->ma.menureplace, words[1]);
    HeapAdd(&PMI(v)->h, &PMI(v)->ma.menuname, words[2]);
  }
  else
  {
    HeapAdd(&PFI(v)->h, &PFI(v)->fa.menureplace, words[1]);
    HeapAdd(&PFI(v)->h, &PFI(v)->fa.menuname, words[2]);
  }
}
Esempio n. 6
0
void ParseMsgDivisionBegin(char *name, char *acs, char *displayfile,
                           char *descript)
{
  MAINFO mi;
  char fullname[PATHLEN];

  if (!do_marea)
    return;

  if (strchr(name, '.'))
    BadDivisionName();

  strcpy(fullname, prefix);
  strcat(fullname, name);

  strcat(prefix, name);
  strcat(prefix, ".");

  MsgAreaWrite(NULL, FALSE);

  memset(&mi, 0, sizeof mi);
  mi.marea=TRUE;

  HeapNew(&mi.h, MAX_MSG_HEAP);

  HeapAdd(&mi.h, &mi.ma.name, fullname);
  HeapAdd(&mi.h, &mi.ma.descript, descript);
  HeapAdd(&mi.h, &mi.ma.acs, acs);
  HeapAdd(&mi.h, &mi.ma.path, displayfile);

  mi.ma.attribs = MA_DIVBEGIN;
  mi.ma.division = division++;

  MsgAreaWrite(&mi, FALSE);
  HeapDelete(&mi.h);
}
Esempio n. 7
0
void Add( int value )
{
        struct ELEMENT * queueNode = malloc( sizeof( struct ELEMENT ) );
        struct ELEMENT * stackNode = malloc( sizeof( struct ELEMENT ) );
        struct ELEMENT * atomicNode = malloc( sizeof( struct ELEMENT ) );
        struct ELEMENT * heapNode = malloc( sizeof( struct ELEMENT ) );

        queueNode->Data = value;
        stackNode->Data = value;
        atomicNode->Data = value;
        heapNode->Data = value;

        LinkedListPush( &stackNode->Link.LinkedListLink, &stackList );
        LinkedListEnqueue( &queueNode->Link.LinkedListLink, &queueList );
        AtomicListPush( &atomicNode->Link.AtomicListLink, &atomicList );
        HeapAdd(value, &heapNode->Link.WeightedLink, &heap );
}
Esempio n. 8
0
void ParseMsgDivisionEnd(void)
{
  MAINFO mi;
  char *p;

  if (!do_marea)
    return;

  if (! *prefix)
  {
    printf("\n\aError!  MsgDivisionEnd on line %d has no correspondig MsgDivisionBegin!\n", linenum);
    Compiling(-1, NULL, NULL);
    return;
  }

  /* Strip off the trailing dot */

  prefix[strlen(prefix)-1]=0;

  /* Now set the prefix back to the prior area */

  if ((p=strrchr(prefix, '.')) != NULL)
    p[1]=0;
  else *prefix=0;

  MsgAreaWrite(NULL, FALSE);

  memset(&mi, 0, sizeof mi);
  mi.marea=TRUE;

  HeapNew(&mi.h, MAX_MSG_HEAP);

  mi.ma.attribs = MA_DIVEND;
  mi.ma.division = --division;
  HeapAdd(&mi.h, &mi.ma.acs, "");

  MsgAreaWrite(&mi, FALSE);
  HeapDelete(&mi.h);
}
Esempio n. 9
0
int ParseMsgArea(FILE *ctlfile, char *name)
{
  char line[PATHLEN];
  char fullname[PATHLEN];
  static MAINFO mi;
  OVRLIST ol;

  struct _vbtab verbs[]=
  {
    {0,           "acs",          &mi.ma.acs},
    {FiltPath,    "path",         &mi.ma.path},
    {0,           "tag",          &mi.ma.echo_tag},
    {0,           "desc",         &mi.ma.descript},
    {0,           "description",  &mi.ma.descript},
    {FiltOrigin,  "origin",       &mi.ma.origin},
#ifdef MAX_TRACKER
    {FiltOwner,   "owner",        NULL},
#endif
    {FiltMenuname,"menuname",     NULL},
    {FiltOverride,"override",     NULL},
    {FiltStyle,   "style",        NULL},
    {FiltRenum,   "renum",        NULL},
    {FiltBarricade,"barricade",   NULL},
    {0,           "app",          NULL},
    {0,           "application",  NULL},
    {0,           "attachpath",   &mi.ma.attachpath},
    {0,           NULL,           NULL}
  };


  if (strchr(name, '.'))
    BadDivisionName();


  if (do_marea)
  {
    /* Make sure that area file is open */

    MsgAreaWrite(NULL, FALSE);

    memset(&mi, 0, sizeof mi);
    mi.marea=TRUE;
    mi.ma.division=division;

    mi.ma.primary=prm.address[0];
    mi.ma.seenby=prm.address[!!prm.address[0].point && prm.address[1].zone];

    HeapNew(&mi.h, MAX_MSG_HEAP);

    strcpy(fullname, prefix);
    strcat(fullname, name);

    HeapAdd(&mi.h, &mi.ma.name, fullname);

#ifdef MAX_TRACKER
    *toNewOwner=0;
#endif
  }

  while (fgets(line, PATHLEN, ctlfile))
    if (VerbParse(&mi, do_marea ? verbs : NULL, line))
      break;

  if (do_marea)
  {
    MsgAreaWrite(&mi, FALSE);

    for (ol=mi.ol; ol; ol=ol->next)
      free(ol);

    HeapDelete(&mi.h);
  }

  return 0;
}
Esempio n. 10
0
int VerbParse(void *pfi, struct _vbtab *verbs, char *line)
{
  char *words[MAX_PARSE_WORDS], *p;
  char szFirstWord[PATHLEN];
  struct _vbtab *pvt;
  int w, rc;

  rc=FALSE;

  Strip_Trailing(line, '\n');

  if ((p=strchr(line, '%')) != NULL)
    *p='\0';

  if ((p=strchr(line, ';')) != NULL)
    *p='\0';

  /* Speed up parsing if we're only looking for the first word */

  if (!verbs)
  {
    words[0]=szFirstWord;
    getword(line, words[0], ctl_delim, 1);
  }
  else
  {
    for (w=0; w < MAX_PARSE_WORDS; w++)
    {
      if ((words[w]=malloc(PATHLEN))==NULL)
        NoMem();

      if (w==0 || *words[w-1])
        getword(line, words[w], ctl_delim, w+1);
      else
        *words[w]=0;
    }
  }

  /* Find this in verb table */

  if (verbs)
    for (pvt=verbs; pvt->verb && !eqstri(words[0], pvt->verb); pvt++)
      ;

  /* If we didn't get a match */

  if (!verbs || !pvt->verb)
  {
    if (eqstri(words[0], "end"))
      rc=TRUE;
    else if (*words[0] && verbs)
      Unknown_Ctl(linenum, words[0]);
  }
  else
  {
    /* If we have a filter function, call it with a ptr to the second word */

    if (pvt->f)
      (*pvt->f)(pfi, words, fchar(line, ctl_delim, 2));

    /* Add this to a zstr heap, if necessary */

    if (pvt->pzstr)
      HeapAdd(&PFI(pfi)->h, pvt->pzstr, fchar(line, ctl_delim, 2));
  }

  /* Deallocate the space used for these words */

  if (verbs)
    for (w=0; w < MAX_PARSE_WORDS; w++)
      free(words[w]);

  linenum++;

  return rc;
}