Ejemplo n.º 1
0
int proc_tell(int index,int pathIndex,loff_t *seek,size_t *size,context *ct)
{
	Down(index);
	*size = (BPOS(ct))?(BUFF_SIZE):(SIZE(ct));
	*seek=POS(ct);
	Up(index);
	
	return(0);
}
Ejemplo n.º 2
0
Archivo: z29.c Proyecto: thektulu/lout
void DeleteEverySym(void)
{ int i, j, load, cost;  OBJECT p, plink, link, x, entry;
  debug0(DST, DD, "DeleteEverySym()");

  /* dispose the bodies of all symbols */
  for( i = 0;  i < MAX_TAB;  i++ )
  { entry = (OBJECT) &symtab[i];
    for( plink = Down(entry);  plink != entry;  plink = NextDown(plink) )
    { Child(p, plink);
      for( link = Down(p);  link != p;  link = NextDown(link) )
      {	Child(x, link);  DeleteSymBody(x);
	/* *** will not work now
	while( base_uses(x) != nilobj )
	{ tmp = base_uses(x);  base_uses(x) = next(tmp);
	  PutMem(tmp, USES_SIZE);
	}
	while( uses(x) != nilobj )
	{ tmp = uses(x);  uses(x) = next(tmp);
	  PutMem(tmp, USES_SIZE);
	}
	*** */
      }
    }
  }

  /* dispose the symbol name strings, gather statistics, and print them */
  load = cost = 0;
  for( i = 0;  i < MAX_TAB;  i++ )
  { j = 1; entry = (OBJECT) &symtab[i];
    while( Down(entry) != entry )
    { load += 1;  cost += j;  j += 1;
      DisposeChild(Down(entry));
    }
  }
  if( load > 0 )
  { debug4(DST, DD, "size = %d, items = %d (%d%%), probes = %.1f",
      MAX_TAB, load, (100*load)/MAX_TAB, (float) cost/load);
  }
  else
  { debug1(DST, DD, "table size = %d, no entries in table", MAX_TAB);
  }
  debug0(DST, DD, "DeleteEverySym returning.");
} /* end DeleteEverySym */
Ejemplo n.º 3
0
Archivo: z29.c Proyecto: thektulu/lout
OBJECT ChildSym(OBJECT s, unsigned typ)
{ OBJECT link, y;
  for( link = Down(s);  link != s;  link = NextDown(link) )
  { Child(y, link);
    if( type(y) == typ && enclosing(y) == s )  return y;
  }
  Error(29, 10, "symbol %s has missing %s", FATAL, &fpos(s),
    SymName(s), Image(typ));
  return nilobj;
} /* end ChildSym */
Ejemplo n.º 4
0
Archivo: z05.c Proyecto: thektulu/lout
void ReadDatabaseDef(unsigned typ, OBJECT encl)
{ OBJECT symbs, t, fname;
  New(symbs, ACAT);
  t = LexGetToken();
  while( type(t)==CLOSURE || (type(t)==WORD && string(t)[0]==CH_SYMSTART) )
  { if( type(t) == CLOSURE )
    { Link(symbs, t);
    }
    else
    { Error(5, 7, "unknown or misspelt symbol %s", WARN, &fpos(t), string(t));
      Dispose(t);
    }
    t = LexGetToken();
  }
  if( type(t) != LBR )
  { Error(5, 8, "symbol name or %s expected here (%s declaration)",
      WARN, &fpos(t), KW_LBR, KW_DATABASE);
    Dispose(t);
    return;
  }
  if( Down(symbs) == symbs )
  { Error(5, 9, "symbol names missing in %s declaration",
      WARN, &fpos(t), KW_DATABASE);
  }
  fname = Parse(&t, encl, FALSE, FALSE);
  fname = ReplaceWithTidy(fname, ACAT_TIDY);
  if( !is_word(type(fname)) )
  { Error(5, 10, "name of %s file expected here", WARN, &fpos(fname),
      KW_DATABASE);
    DisposeObject(fname);
    return;
  }
  if( StringEndsWith(string(fname), DATA_SUFFIX) )
  { Error(5, 47, "%s suffix should be omitted in %s clause", WARN,
      &fpos(fname), DATA_SUFFIX, KW_DATABASE);
    DisposeObject(fname);
    return;
  }
  if( Down(symbs) != symbs )
    (void) DbLoad(fname, typ == DATABASE ? DATABASE_PATH : SYSDATABASE_PATH,
      TRUE, symbs, InMemoryDbIndexes);
} /* end ReadDatabaseDef */
Ejemplo n.º 5
0
Archivo: z29.c Proyecto: thektulu/lout
OBJECT ChildSymWithCode(OBJECT s, unsigned char code)
{ OBJECT link, y;
  for( link = Down(actual(s));  link != actual(s);  link = NextDown(link) )
  { Child(y, link);
    if( type(y) == NPAR && enclosing(y) == actual(s) && npar_code(y) == code )
      return y;
  }
  Error(29, 11, "symbol %s has erroneous code %c (database out of date?)",
    FATAL, &fpos(s), SymName(actual(s)), (char) code);
  return nilobj;
} /* end ChildSym */
Ejemplo n.º 6
0
// insert a written block.
int proc_insertBuff(int index,int pathIndex,struct block *buff,loff_t pos, size_t count,context *ct)
{
	loff_t* f_pos,spos;
	size_t left = count, wrt;
	int ret;

	if(RELEASE(index)) return count;

	if(pathIndex==INDEX_PATH_NUM) {
		spos = ((pipes[index].ct)[CONTEXT]).bpos + pos;
	} else {
		spos=pos;
	}
	
			
	f_pos=(loff_t *)&spos;
	
	
	while(1) {
		Down(index);
		wrt = left;
		ret = dev_insertBuff(&((pipes[index]).device), f_pos,buff, &left, ct);
		if(pathIndex==INDEX_PATH_NUM)
			POS(ct)=*f_pos-((pipes[index].ct)[CONTEXT]).bpos;
		else
			POS(ct)=*f_pos;
			
		if(ret == DEV_FAULT) {Up(index); return -EFAULT;}

		if(wrt && !R_ABLE(ct)) {
			R_ABLE(ct) = 1;
			if(ret == DEV_SEEK) {
				wake_up_interruptible_sync(&(RQ(index)));
			}
			else {
				wake_up_interruptible(&(RQ(index)));
			}
		}
		if(ret == DEV_SEEK) {Up(index); return -P_ESEEK;}

		if(ret == DEV_FULL) {
			W_ABLE(ct) = 0; Up(index);
			PDEBUG("<%d>: device full, sleep, left %d\n", current->pid, (int)left);
			Wait_Event(WQ(index), RELEASE(index)||W_ABLE(ct));
			if(RELEASE(index)) return count;
			continue;
		}
		Up(index);

		if(left <= 0) break;
	}
	return count;

}
Ejemplo n.º 7
0
bool DGSwitch1::ProcessMouse2D (int event, int mx, int my)
{
	if (event & PANEL_MOUSE_LBDOWN) {
		if (my < 26) Up();
		else         Down();
	} else if (event & PANEL_MOUSE_LBUP) {
		if (mode == SPRING)
			SetState (CENTER);
	}
	return (state != vstate2);
}
Ejemplo n.º 8
0
bool DGSwitch1::ProcessMouseVC (int event, VECTOR3 &p)
{
	if (event & PANEL_MOUSE_LBDOWN) {
		if (p.y < 0.5) Down();
		else           Up();
	} else if (event & PANEL_MOUSE_LBUP) {
		if (mode == SPRING)
			SetState (CENTER);
	}
	return (state != vstate);
}
Ejemplo n.º 9
0
/*!	\brief Enables or disables this protocol.
	
	A disabled protocol is ignored and Up() is not called!
*/
void
KPPPProtocol::SetEnabled(bool enabled)
{
	fEnabled = enabled;
	
	if (!enabled) {
		if (IsUp() || IsGoingUp())
			Down();
	} else if (!IsUp() && !IsGoingUp() && IsUpRequested() && Interface().IsUp())
		Up();
}
Ejemplo n.º 10
0
Archivo: z09.c Proyecto: thektulu/lout
OBJECT ParameterCheck(OBJECT x, OBJECT env)
{ OBJECT link, y, res, prnt_env, par, prnt;
  debug2(DCE, DD, "ParameterCheck(%s, %s)", EchoObject(x), EchoObject(env));
  assert( type(x) == CLOSURE, "ParameterCheck given non-CLOSURE!");

  /* case x is a parameter */
  prnt = SearchEnv(env, enclosing(actual(x)));
  if( prnt == nilobj )
  { debug0(DCE, DD, "ParameterCheck returning nilobj (prnt fail)");
    return nilobj;
  }
  prnt_env = GetEnv(prnt);
  for( link = Down(prnt);  link != prnt;  link = NextDown(link) )
  { Child(par, link);
    if( type(par) == PAR && actual(par) == actual(x) )
    {	assert( Down(par) != par, "ParameterCheck: Down(par)!");
	Child(y, Down(par));
	res = is_word(type(y)) ? CopyObject(y, no_fpos) : nilobj;
	debug1(DCE, DD, "  ParameterCheck returning %s", EchoObject(res));
	return res;
    }
  }

  /* case x is a default parameter */
  y = sym_body(actual(x));
  if( y == nilobj )
  { res = nilobj;
  }
  else if( is_word(type(y)) )
  { res = CopyObject(y, &fpos(y));
  }
  else if( type(y) == CLOSURE && is_par(type(actual(y))) )
  { res = ParameterCheck(y, prnt_env);
  }
  else
  { res = nilobj;
  }
  debug1(DCE, DD, "ParameterCheck returning %s", EchoObject(res));
  return res;
} /* end ParameterCheck */
Ejemplo n.º 11
0
Archivo: z09.c Proyecto: thektulu/lout
OBJECT SearchEnv(OBJECT env, OBJECT sym)
{ OBJECT link, y;
  debug2(DCE, DD, "[ SearchEnv(%s, %s)", EchoObject(env), SymName(sym));
  for(;;)
  {
    debug1(DCE, DDD, "  searching env %s", EchoObject(env));
    assert( env != nilobj && type(env) == ENV, "SearchEnv: env!" );
    if( Down(env) == env )
    { debug0(DCE, DD, "] SearchEnv returning <nilobj>");
      return nilobj;
    }
    Child(y, Down(env));
    assert( type(y) == CLOSURE, "SearchEnv: type(y) != CLOSURE!" );
    if( actual(y) == sym )
    { debug1(DCE, DD, "] SearchEnv returning %s", EchoObject(y));
      return y;
    }
    assert( LastDown(y) != y, "SearchEnv: LastDown(y) == y!" );
    link = LastDown(env) != Down(env) ? LastDown(env) : LastDown(y);
    Child(env, link);
  }
} /* end SearchEnv */
Ejemplo n.º 12
0
Archivo: z29.c Proyecto: thektulu/lout
void InsertAlternativeName(FULL_CHAR *str, OBJECT s, FILE_POS *xfpos)
{ register int sum, rlen;
  register unsigned char *x;
  int len;
  OBJECT entry, link, plink, p, q;
  debug3(DST, DD, "InsertAlternativeName(%s, %s, %s)",
    str, SymName(s), EchoFilePos(xfpos));

  len = StringLength(str);
  hash(str, len, sum);

  ifdebug(DST, D, sym_spread[sum]++;  sym_count++);
  entry = (OBJECT) &symtab[sum];
  for( plink = Down(entry);  plink != entry;  plink = NextDown(plink) )
  { Child(p, plink);
    if( length(p) == len && StringEqual(str, string(p)) )
    { for( link = Down(p);  link != p;  link = NextDown(link) )
      {	Child(q, link);
	if( enclosing(s) == enclosing(q) )
	{ Error(29, 12, "symbol name %s previously defined at%s",
	    WARN, &fpos(s), str, EchoFilePos(&fpos(q)) );
	  break;
	}
      }
      goto wrapup;
    }
  }

  /* need a new OBJECT as well as s */
  NewWord(p, WORD, len, xfpos);
  length(p) = len;
  StringCopy(string(p), str);
  Link(entry, p);

 wrapup:
  Link(p, s);
  /* not for copies if( enclosing(s) != nilobj ) Link(enclosing(s), s); */
  debug0(DST, DD, "InsertAlternativeName returning.");
} /* end InsertAlternativeName */
Ejemplo n.º 13
0
int SelectKeys(int cmd)
{
	static int index = 12;

	if (cmd == CMD_ESC)
		return MODE_CONTROLS;

	if (AnyButton(cmd)) {
		PlaySound(rand() % SND_COUNT, 0, 255);

		switch (index) {
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
			HighlightKey(index);
			ChangeKey(&gPlayer1Data, &gPlayer2Data, index);
			break;

		case 6:
		case 7:
		case 8:
		case 9:
		case 10:
		case 11:
			HighlightKey(index);
			ChangeKey(&gPlayer2Data, &gPlayer1Data, index - 6);
			break;

		case 12:
			HighlightKey(index);
			ChangeMapKey(&gPlayer1Data, &gPlayer2Data);
			break;

		default:
			return MODE_CONTROLS;
		}
	} else if (index > 0 && Up(cmd)) {
		index--;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (index < 13 && Down(cmd)) {
		index++;
		PlaySound(SND_SWITCH, 0, 255);
	}

	ShowAllKeys(index, -1);

	return MODE_KEYS;
}
Ejemplo n.º 14
0
Archivo: z47.c Proyecto: thektulu/lout
BOOLEAN EnvReadRetrieve(FILE_NUM fnum, int offset, OBJECT *env)
{ int pos;  OBJECT link, y, z;
  debug2(DET, DD, "EnvReadRetrieve(%s, %d)", FileName(fnum), offset);
  stat_reads++;

  hash2(pos, fnum, offset);
  if( tab[pos] != nilobj )
  {
    for( link = Down(tab[pos]);  link != tab[pos];  link = NextDown(link) )
    { Child(y, link);
      Child(z, Down(y));
      if( env_fnum(y) == fnum && env_offset(y) == offset && env_read(y) )
      { MoveLink(LastUp(y), env_cache, PARENT);
	Child(*env, Down(y));
	stat_read_hits++;
        debug1(DET, DD, "EnvReadRetrieve returning env %d", (int) *env);
	  return TRUE;
      }
    }
  }
  debug0(DET, DD, "EnvReadRetrieve returning FALSE");
  return FALSE;
} /* end EnvReadRetrieve */
Ejemplo n.º 15
0
// Drops count number of rings
void Drop(int count)
{
    // Remaining count
    count = GetRingCount() - count;

    if(count < 0)
    {
        count = 0;
    }

    Down();
    while(GetRingCount() > count);
    Up();
}
Ejemplo n.º 16
0
FULL_CHAR *DebugInnersNames(OBJECT inners)
{ static FULL_CHAR buff[MAX_BUFF];
  OBJECT link, y, z;
  StringCopy(buff, STR_EMPTY);
  if( inners != nilobj )
  { for( link = Down(inners);  link != inners;  link = NextDown(link) )
    { Child(y, link);
      if( link != Down(inners) )  StringCat(buff, STR_SPACE);
      switch( type(y) )
      {

        case RECEIVING:
        case UNATTACHED:
      
	  assert( Down(y) != y, "DebugInnersNames: UNATTACHED!");
	  Child(z, Down(y));
          StringCat(buff, SymName(actual(z)));
	  break;


        case PRECEDES:
        case GALL_PREC:
        case DEAD:
      
	  StringCat(buff, Image(type(y)));
	  break;


        default:
      
	  assert1(FALSE, "DebugInnersNames:", Image(type(y)));
	  break;
      }
    }
  }
  return buff;
} /* end DebugInnersNames */
Ejemplo n.º 17
0
void Left(int r, int c, int cnt)
{
	int i;
	for(i=c; i>=1; i--) {
		if(!a[r][i]) {
			a[r][i] = ++cnt;
			if(K == cnt) {
				printf("%d %d\n", i, r);
				return ;
			}
		}
		else break;
	}
	Down(r+1, ++i, cnt);
}
Ejemplo n.º 18
0
Archivo: z19.c Proyecto: thektulu/lout
OBJECT SearchGalley(OBJECT start, OBJECT sym, BOOLEAN forwards,
BOOLEAN subgalleys, BOOLEAN closures, BOOLEAN input)
{ OBJECT y, res, z, zlink, link;
  debug5(DGA, DD, "[ SearchGalley(start, %s, %s, %s, %s, %s)", SymName(sym),
	forwards ? "fwd" : "back", subgalleys ? "subgalleys" : "nosubgalleys",
	closures ? "closures" : "noclosures", input ? "input" : "noinput");
  assert( type(start) == LINK || type(start) == HEAD, "SearchGalley: start!" );

  link = forwards ? NextDown(start) : PrevDown(start);
  res = nilobj;
  while( res == nilobj && type(link) != HEAD )
  { Child(y, link);
    switch( type(y) )
    {
      case UNATTACHED:
      case RECEIVING:
	
        debug1(DGA, DD, "  examining %s", EchoIndex(y));
	if( subgalleys )
	for( zlink = Down(y); zlink!=y && res==nilobj; zlink=NextDown(zlink) )
	{ Child(z, zlink);
	  res = SearchGalley(z, sym, TRUE, TRUE, TRUE, input);
	}
	if( res == nilobj && input && type(y) == RECEIVING &&
	    actual(actual(y)) == InputSym )
	  res = y;
	break;


      case RECEPTIVE:
	
        debug1(DGA, DD, "  examining %s", EchoIndex(y));
	if( closures && type(actual(y)) == CLOSURE
		     && SearchUses(actual(actual(y)), sym) )  res = y;
	else if( input && actual(actual(y)) == InputSym )  res = y;
	break;


      default:
	
	break;

    }
    link = forwards ? NextDown(link) : PrevDown(link);
  }
  debug1(DGA, DD, "] SearchGalley returning %s", EchoIndex(res));
  return res;
} /* end SearchGalley */
Ejemplo n.º 19
0
void PDF_PrintGraphicObject(OBJECT x)
{ OBJECT y, link;
  debug3(DPF, D, "PDF_PrintGraphicObject(%s %s %s)",
    EchoFilePos(&fpos(x)), Image(type(x)), EchoObject(x));
  switch( type(x) )
  {
    case WORD:
    case QWORD:

      PDFPage_WriteGraphic(out_fp, string(x));
      break;
	

    case ACAT:
    
      for( link = Down(x);  link != x;  link = NextDown(link) )
      {	Child(y, link);
	if( type(y) == GAP_OBJ )
	{
	  if( vspace(y) > 0 )  PDFPage_Write(out_fp, "\n");
	  else if( hspace(y) > 0 ) PDFPage_Write(out_fp, " ");
	}
	else if( is_word(type(y)) || type(y) == ACAT )
	  PDF_PrintGraphicObject(y);
	else if( type(y) == WIDE || is_index(type(y)) )
	{
	  /* ignore: @Wide, indexes are sometimes inserted by Manifest */
	}
	else
	{ Error(50, 2, "error in left parameter of %s",
	    WARN, &fpos(x), KW_GRAPHIC);
	  debug1(DPF, D, "  type(y) = %s, y =", Image(type(y)));
	  ifdebug(DPF, D, DebugObject(y));
	}
      }
      break;


    default:
    
      Error(50, 3, "error in left parameter of %s", WARN, &fpos(x), KW_GRAPHIC);
      debug1(DPF, D, "  type(x) = %s, x =", Image(type(x)));
      ifdebug(DPF, D, DebugObject(x));
      break;

  }
  debug0(DPF, D, "PDF_PrintGraphicObject returning");
} /* end PDF_PrintGraphicObject */
Ejemplo n.º 20
0
void Control::Handle(Event& e) {
    switch (e.eventType) {
    case DownEvent:
	Down();
	break;
    case UpEvent:
	Up();
	break;
    case EnterEvent:
	Enter();
	break;
    case LeaveEvent:
	Leave();
	break;
    }
}
Ejemplo n.º 21
0
Point Point::Direction(Cell::Direction dir)
{
  switch (dir)
  {
    case (Cell::Direction::RIGHT):
      return Right();
    case (Cell::Direction::LEFT):
      return Left();
    case (Cell::Direction::UP):
      return Up();
    case (Cell::Direction::DOWN):
      return Down();
  }

  return Cell::Direction::RIGHT;
}
Ejemplo n.º 22
0
static int SelectMain(int cmd)
{
	static int index = 0;

	if (cmd == CMD_ESC) {
		if (index != MODE_QUIT)
			index = MODE_QUIT;
		else
			return MODE_QUIT;
	}
	if (AnyButton(cmd)) {
		switch (index) {
		case 0:
			gCampaign.dogFight = 0;
			gOptions.twoPlayers = 0;
			return MODE_CAMPAIGN;
		case 1:
			gCampaign.dogFight = 0;
			gOptions.twoPlayers = 1;
			return MODE_CAMPAIGN;
		case 2:
			gCampaign.dogFight = 1;
			return MODE_DOGFIGHT;
		}
		return index;
	}
	if (Left(cmd) || Up(cmd)) {
		index--;
		if (index < 0)
			index = MAIN_COUNT - 1;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (Right(cmd) || Down(cmd)) {
		index++;
		if (index >= MAIN_COUNT)
			index = 0;
		PlaySound(SND_SWITCH, 0, 255);
	}

	DrawTPic((SCREEN_WIDTH - PicWidth(gPics[PIC_LOGO])) / 2, (SCREEN_HEIGHT / 12), gPics[PIC_LOGO], gCompiledPics[PIC_LOGO]);

	TextStringSpecial("Classic: " CDOGS_VERSION, TEXT_TOP | TEXT_LEFT, 20, 20);
	TextStringSpecial("SDL Port:  " CDOGS_SDL_VERSION, TEXT_TOP | TEXT_RIGHT, 20, 20);

	DisplayMenuAtCenter(mainMenu, MAIN_COUNT, index);
	
	return MODE_MAIN;
}
Ejemplo n.º 23
0
Archivo: z29.c Proyecto: thektulu/lout
void LoadScopeSnapshot(OBJECT ss)
{ OBJECT link, x, sym;  BOOLEAN tmp;
  assert( type(ss) == ACAT, "LoadScopeSnapshot: type(ss)!" );
  PushScope(StartSym, FALSE, FALSE);
  for( link = LastDown(ss);  link != ss;  link = PrevDown(link) )
  { Child(x, link);
    assert( type(x) == SCOPE_SNAPSHOT, "LoadScopeSnapshot: type(x)!" );
    Child(sym, Down(x));
    PushScope(sym, ss_npars_only(x), ss_vis_only(x));
    body_ok[scope_top-1] = ss_body_ok(x);
  }
  tmp = suppress_visible;
  suppress_visible = ss_suppress(ss);
  ss_suppress(ss) = tmp;
  debug0(DST, D, "after LoadScopeSnapshot, scope is:")
  ifdebug(DST, D, DebugScope());
} /* end LoadScopeSnapshot */
Ejemplo n.º 24
0
void WorldServer::UnInit()
{
    Down();

	DB::gObjectDBConnectionMgr->UnInit();
	delete DB::gObjectDBConnectionMgr;
	DB::gObjectDBConnectionMgr = NULL;

	DB::gDataDBConnectionMgr->UnInit();
	delete DB::gDataDBConnectionMgr;
	DB::gDataDBConnectionMgr = NULL;

	DB::gLogDBConnectionMgr->UnInit();
	delete DB::gLogDBConnectionMgr;
	DB::gLogDBConnectionMgr = NULL;

	Network::Uninitialize();
}
Ejemplo n.º 25
0
void WorldServer::Shutdown()
{
	int worker;

    Down();

	//关闭网络线程
	m_TcpService->UnInit();

	Thread::sleep(2000);

	//关闭所有工作线程
	for (worker = 0; worker < MAX_THREAD_NUM; worker++)
	{
#ifdef OPEN_API_ON
		if(worker < WORKER_THREAD_DB && worker != WORKER_THREAD_OPEN_API)
#else
		if(worker < WORKER_THREAD_DB)
#endif
			m_AllWorker[worker]->Shutdown();
	}

    // XXX: erase all event
	Thread::sleep(2000);
    //GObject::eventWrapper.clear();   //LIBODELETE 
	Thread::sleep(2000);
	m_AllWorker[WORKER_THREAD_DB]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB1]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB2]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB3]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB4]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB5]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB6]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB7]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB8]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB_LOG]->Shutdown();
	m_AllWorker[WORKER_THREAD_DB_LOG1]->Shutdown();
#ifdef OPEN_API_ON
    m_AllWorker[WORKER_THREAD_OPEN_API]->Shutdown();
#endif

    m_AllWorker[WORKER_THREAD_LOAD]->Shutdown();
}
Ejemplo n.º 26
0
void main()
{
    int iCaseNum,iStepNum,iStep;
    char cTurn[10];
    Direction dFace;
    Coordinate cMan;
    cin>>iCaseNum;
    while(iCaseNum--)
    {
        cin>>iStepNum;
        dFace.iFront=0;
        dFace.iTop=2;
        dFace.iLeft=4;
        cMan.iX=cMan.iY=cMan.iZ=0;
        while(iStepNum--)
        {
            cin>>cTurn>>iStep;
            switch(cTurn[0])
            {
            case 'b':
                Back(dFace);
                break;
            case 'l':
                Left(dFace);
                break;
            case 'r':
                Right(dFace);
                break;
            case 'u':
                Up(dFace);
                break;
            case 'd':
                Down(dFace);
                break;
            default:
                break;
            }
            Go(cMan,dFace,iStep);
        }
        cout<<cMan.iX<<" "<<cMan.iY<<" "<<cMan.iZ<<" "<<dFace.iFront<<endl;
    }
}
Ejemplo n.º 27
0
static ssize_t p_write(int index, struct file* filp, const char* buf, size_t count, loff_t* f_pos)
{
	context *ct = filp->private_data;
	size_t left = count, wrt;
	int ret;

	if(RELEASE(index)) return count;

	while(1) {
		Down(index);
		wrt = left;
		ret = dev_write(&((pipes[index]).device), f_pos, buf+(count-left), &left, ct);

		if(ret == DEV_FAULT) {Up(index); return -EFAULT;}

#ifdef __PIPE_SELECT
        pipes[index].r_poll = 1;
#endif
		if(wrt) {
			R_ABLE(ct) = 1;
			if(ret == DEV_SEEK) {
				wake_up_interruptible_sync(&(RQ(index)));
			}
			else {
				wake_up_interruptible(&(RQ(index)));
			}
		}
		if(ret == DEV_SEEK) {Up(index); return -P_ESEEK;}

		if(ret == DEV_FULL) {
			W_ABLE(ct) = 0; Up(index);
			PDEBUG("<%d>: device full, sleep, left %d\n", current->pid, (int)left);
			Wait_Event(WQ(index), RELEASE(index)||W_ABLE(ct));
			if(RELEASE(index)) return count;
			continue;
		}
		Up(index);

		if(left <= 0) break;
	}
	return count;
}
Ejemplo n.º 28
0
static int p_open(int index, struct inode* inode, struct file* filp)
{
	int ret = 0;

	Down(index);
	rcount++;
//	printk("Proc pipe open %d times.\n",rcount);
	if(!(filp->f_mode & FMODE_READ) && (filp->f_mode & FMODE_WRITE)) {
		if(WRITERS(index) < CONTEXT) {
			filp->private_data = &((pipes[index].ct)[WRITERS(index)]);
			(WRITERS(index))++;
		}
		else if(((pipes[index].ct)[CONTEXT]).pid == 0) {
			filp->private_data = &((pipes[index].ct)[CONTEXT]);
			((pipes[index].ct)[CONTEXT]).pid = current->pid;
		}
		else ret = (-EFAULT);
	}
	Up(index);

	return ret;
}
Ejemplo n.º 29
0
void MenuChangeIndex(menu_t *menu, int cmd)
{
	int leftRightMoves = MenuTypeLeftRightMoves(menu->type);
	if (Up(cmd) || (leftRightMoves && Left(cmd)))
	{
		do
		{
			menu->u.normal.index--;
			if (menu->u.normal.index < 0)
			{
				menu->u.normal.index = menu->u.normal.numSubMenus - 1;
			}
		} while (menu->u.normal.subMenus[menu->u.normal.index].type ==
			MENU_TYPE_SEPARATOR);
		SoundPlay(&gSoundDevice, SND_DOOR);
	}
	else if (Down(cmd) || (leftRightMoves && Right(cmd)))
	{
		do
		{
			menu->u.normal.index++;
			if (menu->u.normal.index >= menu->u.normal.numSubMenus)
			{
				menu->u.normal.index = 0;
			}
		} while (menu->u.normal.subMenus[menu->u.normal.index].type ==
			MENU_TYPE_SEPARATOR);
		SoundPlay(&gSoundDevice, SND_DOOR);
	}
	menu->u.normal.scroll =
		CLAMP(menu->u.normal.scroll,
			MAX(0, menu->u.normal.index - 11),
			MIN(menu->u.normal.numSubMenus - 1, menu->u.normal.index + 11));
	if (menu->u.normal.index < menu->u.normal.scroll)
	{
		menu->u.normal.scroll = menu->u.normal.index;
	}
}
Ejemplo n.º 30
0
void MenuChangeIndex(menu_t *menu, int cmd)
{
	// Ignore if no submenus
	if (menu->u.normal.subMenus.size == 0)
	{
		return;
	}

	if (Up(cmd))
	{
		menu->u.normal.index--;
		if (menu->u.normal.index == -1)
		{
			menu->u.normal.index = (int)menu->u.normal.subMenus.size - 1;
		}
		MoveIndexToNextEnabledSubmenu(menu, 0);
		MenuPlaySound(MENU_SOUND_SWITCH);
	}
	else if (Down(cmd))
	{
		menu->u.normal.index++;
		if (menu->u.normal.index == (int)menu->u.normal.subMenus.size)
		{
			menu->u.normal.index = 0;
		}
		MoveIndexToNextEnabledSubmenu(menu, 1);
		MenuPlaySound(MENU_SOUND_SWITCH);
	}
	menu->u.normal.scroll =
		CLAMP(menu->u.normal.scroll,
			MAX(0, menu->u.normal.index - menu->u.normal.maxItems + 1),
			MIN((int)menu->u.normal.subMenus.size - 1, menu->u.normal.index + menu->u.normal.maxItems - 1));
	if (menu->u.normal.index < menu->u.normal.scroll)
	{
		menu->u.normal.scroll = menu->u.normal.index;
	}
}