예제 #1
0
static sg_error
set_valid_filesystems(char const *fslist) {
	char const **newfs;
	char const **given_fs;

	while(sg_is_spc(*fslist))
		++fslist;
	if('!' == *fslist) {
		size_t new_items = 0, given_items = 0;
		const char **old_valid_fs = sg_get_valid_filesystems(0);

		if( NULL == old_valid_fs )
			sg_die("sg_get_valid_filesystems()", 1);

		++fslist;
		while(*fslist && sg_is_spc(*fslist))
			++fslist;

		given_fs = split_list(fslist);
		for(newfs = given_fs; *newfs; ++newfs) {
			++given_items;
		}
		qsort(given_fs, given_items, sizeof(given_fs[0]), fsnmcmp);

		newfs = NULL;
		new_items = 0;

		while(*old_valid_fs) {
			if (NULL == bsearch(old_valid_fs, given_fs, given_items, sizeof(given_fs[0]), fsnmcmp)) {
				newfs = push_item(newfs, *old_valid_fs, new_items++);
			}
			++old_valid_fs;
		}
		newfs = push_item(newfs, NULL, new_items);
	}
	else {
		newfs = given_fs = split_list(fslist);
	}

        if( SG_ERROR_NONE != sg_set_valid_filesystems( newfs ) )
		sg_die("sg_set_valid_filesystems() failed", 1);

	for(newfs = given_fs; *newfs; ++newfs) {
		free((void *)(*newfs));
	}

	return SG_ERROR_NONE;
}
예제 #2
0
int32_t rdConfLoader::handle_line(const char* line, rdConfUnit* root, rdConfUnit*& current) 
{
    if (NULL == root || NULL == current) {
        return E_NULL_POINTER;
    }

    std::vector<std::string> paths;
    std::string key;
    std::string value;

    if (0 == handle_as_section(line, paths)) {
        if (0 == paths.size()) {
            return E_CONF_ERROR;
        }
        current = push_section(root, paths);
        if (NULL == current) {
            return E_CONF_ERROR;
        }
    }
    else if (0 == handle_as_item(line, key, value)) {
        if (0 != push_item(current, key, value)) {
            return E_CONF_ERROR;
        }
    }
    else {
        return E_CONF_ERROR;
    }

    return 0;
}
예제 #3
0
static const char *add_icon(cmd_parms *cmd, void *d, char *icon, char *to)
{
    char *iconbak = ap_pstrdup(cmd->pool, icon);

    if (icon[0] == '(') {
	char *alt;
	char *cl = strchr(iconbak, ')');

	if (cl == NULL) {
	    return "missing closing paren";
	}
	alt = ap_getword_nc(cmd->pool, &iconbak, ',');
	*cl = '\0';				/* Lose closing paren */
	add_alt(cmd, d, &alt[1], to);
    }
    if (cmd->info == BY_PATH) {
        if (!strcmp(to, "**DIRECTORY**")) {
	    to = "^^DIRECTORY^^";
	}
    }
    if (cmd->info == BY_ENCODING) {
	ap_str_tolower(to);
    }

    push_item(((autoindex_config_rec *) d)->icon_list, cmd->info, to,
	      cmd->path, iconbak);
    return NULL;
}
예제 #4
0
int check_and_update_cache(redisContext *context, const char *actor, char *reason, char *list, expanding_vector *ev, time_t *last_update_time)
{
  long current_seconds = time(NULL);

  if (*last_update_time + cache_expiry < current_seconds) {
    clear_expanding_vector(ev);
    redisReply *listed = redisCommand(context, "SMEMBERS repsheet:cidr:%s", list);
    if (listed) {
      if (listed->type == REDIS_REPLY_ARRAY) {
        int i;

        char *block;
        for(i = 0; i < listed->elements; i++) {
          block = strtok(listed->element[i]->str, ":");
          range range;
          int rc = block_to_range(block, &range);
          if (rc >= 0) {
            snprintf(range.block, MAX_BLOCK_SIZE, "%s", block);
            push_item(ev, &range);
          }
        }
      }
      freeReplyObject(listed);
    } else {
      return DISCONNECTED;
    }
    //loaded ok, update the cache time
    *last_update_time = current_seconds;
  }
  return 0;
}
예제 #5
0
void LuaGossip::OnHello(Object* pObject, Player* Plr)
{
    GET_LOCK;
    if(pObject->GetTypeId() == TYPEID_UNIT)
    {
        if(m_unit_gossip_binding == NULL) { RELEASE_LOCK; return; }

        lua_engine::BeginLuaFunctionCall(m_unit_gossip_binding->refs[GOSSIP_EVENT_ON_TALK]);
        push_creature(TO_CREATURE(pObject));
        push_int(GOSSIP_EVENT_ON_TALK);
        push_player(Plr);
        lua_engine::ExecuteLuaFunction(3);
    }
    else if(pObject->GetTypeId() == TYPEID_ITEM)
    {
        if(m_item_gossip_binding == NULL) { RELEASE_LOCK; return; }

        lua_engine::BeginLuaFunctionCall(m_item_gossip_binding->refs[GOSSIP_EVENT_ON_TALK]);
        push_item(TO_ITEM(pObject));
        push_int(GOSSIP_EVENT_ON_TALK);
        push_player(Plr);
        lua_engine::ExecuteLuaFunction(3);
    }
    else if(pObject->GetTypeId() == TYPEID_GAMEOBJECT)
    {
        if(m_go_gossip_binding == NULL) { RELEASE_LOCK; return; }

        lua_engine::BeginLuaFunctionCall(m_go_gossip_binding->refs[GOSSIP_EVENT_ON_TALK]);
        push_go(TO_GAMEOBJECT(pObject));
        push_int(GOSSIP_EVENT_ON_TALK);
        push_player(Plr);
        lua_engine::ExecuteLuaFunction(3);
    }
    RELEASE_LOCK
}
예제 #6
0
	// Queue item push insert.
	char *push ( int port, jack_nframes_t time, size_t size )
	{
		char *item = push_item(time, size + sizeof(unsigned short));
		if (item) {
			*(unsigned short *) item = port;
			item += sizeof(unsigned short);
		}
		return item;
	}
예제 #7
0
/**
 * \brief Calls the on_ability_used() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param ability_name The ability just used.
 */
void LuaContext::item_on_ability_used(EquipmentItem& item, const std::string& ability_name) {

  if (!userdata_has_field(item, "on_ability_used")) {
    return;
  }

  push_item(l, item);
  on_ability_used(ability_name);
  lua_pop(l, 1);
}
예제 #8
0
/**
 * \brief Calls the on_npc_interaction() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param npc An NPC.
 */
void LuaContext::item_on_npc_interaction(EquipmentItem& item, Npc& npc) {

  if (!userdata_has_field(item, "on_npc_interaction")) {
    return;
  }

  push_item(l, item);
  on_npc_interaction(npc);
  lua_pop(l, 1);
}
예제 #9
0
/**
 * \brief Calls the on_ability_used() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param ability The ability just used.
 */
void LuaContext::item_on_ability_used(EquipmentItem& item, Ability ability) {

  if (!userdata_has_field(item, "on_ability_used")) {
    return;
  }

  push_item(l, item);
  on_ability_used(ability);
  lua_pop(l, 1);
}
예제 #10
0
/**
 * \brief Calls the on_amount_changed() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param amount The amount of this item.
 */
void LuaContext::item_on_amount_changed(EquipmentItem& item, int amount) {

  if (!userdata_has_field(item, "on_amount_changed")) {
    return;
  }

  push_item(l, item);
  on_amount_changed(amount);
  lua_pop(l, 1);
}
예제 #11
0
/**
 * \brief Calls the on_using() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 */
void LuaContext::item_on_using(EquipmentItem& item) {

  if (!userdata_has_field(item, "on_using")) {
    return;
  }

  push_item(l, item);
  on_using();
  lua_pop(l, 1);
}
예제 #12
0
/**
 * \brief Calls the on_npc_collision_fire() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param npc An NPC.
 */
void LuaContext::item_on_npc_collision_fire(EquipmentItem& item, Npc& npc) {

  if (!userdata_has_field(item, "on_npc_collision_fire")) {
    return;
  }

  push_item(l, item);
  on_npc_collision_fire(npc);
  lua_pop(l, 1);
}
예제 #13
0
/**
 * \brief Calls the on_obtained() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param treasure The treasure just obtained.
 */
void LuaContext::item_on_obtained(EquipmentItem& item, const Treasure& treasure) {

  if (!userdata_has_field(item, "on_obtained")) {
    return;
  }

  push_item(l, item);
  on_obtained(treasure);
  lua_pop(l, 1);
}
예제 #14
0
/**
 * \brief Calls the on_suspended() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param suspended true if the game is suspended.
 */
void LuaContext::item_on_suspended(EquipmentItem& item, bool suspended) {

  if (!userdata_has_field(item, "on_suspended")) {
    return;
  }

  push_item(l, item);
  on_suspended(suspended);
  lua_pop(l, 1);
}
예제 #15
0
/**
 * \brief Calls the on_map_changed() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param map A map.
 */
void LuaContext::item_on_map_changed(EquipmentItem& item, Map& map) {

  if (!userdata_has_field(item, "on_map_changed")) {
    return;
  }

  push_item(l, item);
  on_map_changed(map);
  lua_pop(l, 1);
}
예제 #16
0
/**
 * \brief Calls the on_finished() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 */
void LuaContext::item_on_finished(EquipmentItem& item) {

  push_item(l, item);
  if (userdata_has_field(item, "on_finished")) {
    on_finished();
  }
  remove_timers(-1);  // Stop timers and menus associated to this item.
  remove_menus(-1);
  lua_pop(l, 1);
}
예제 #17
0
/**
 * \brief Calls the on_pickable_created() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param pickable The instance of pickable item that has just appeared.
 */
void LuaContext::item_on_pickable_created(EquipmentItem& item,
    Pickable& pickable) {

  if (!userdata_has_field(item, "on_pickable_created")) {
    return;
  }

  push_item(l, item);
  on_pickable_created(pickable);
  lua_pop(l, 1);
}
예제 #18
0
/**
 * \brief Calls the on_pickable_movement_changed() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 * \param pickable The instance of pickable item whose movement has changed.
 * \param movement The movement.
 */
void LuaContext::item_on_pickable_movement_changed(EquipmentItem& item,
    Pickable& pickable, Movement& movement) {

  if (!userdata_has_field(item, "on_pickable_movement_changed")) {
    return;
  }

  push_item(l, item);
  on_pickable_movement_changed(pickable, movement);
  lua_pop(l, 1);
}
예제 #19
0
/**
 * \brief Calls the on_npc_interaction_item() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item The equipment item linked to the NPC.
 * \param npc An NPC.
 * \param item_used The equipment item used.
 * \return true if an interaction occurred.
 */
bool LuaContext::item_on_npc_interaction_item(EquipmentItem& item, Npc& npc,
    EquipmentItem& item_used) {

  if (!userdata_has_field(item, "on_npc_interaction_item")) {
    return false;
  }

  push_item(l, item);
  bool result = on_npc_interaction_item(npc, item_used);
  lua_pop(l, 1);
  return result;
}
예제 #20
0
/**
 * \brief Implementation of game:get_item().
 * \param l The Lua context that is calling this function.
 * \return Number of values to return to Lua.
 */
int LuaContext::game_api_get_item(lua_State* l) {

  Savegame& savegame = check_game(l, 1);
  const std::string& item_name = luaL_checkstring(l, 2);

  if (!savegame.get_equipment().item_exists(item_name)) {
    error(l, StringConcat() << "No such item: '" << item_name << "'");
  }

  push_item(l, savegame.get_equipment().get_item(item_name));
  return 1;
}
예제 #21
0
/**
 * \brief Calls the on_update() method of a Lua equipment item.
 *
 * Does nothing if the method is not defined.
 *
 * \param item An equipment item.
 */
void LuaContext::item_on_update(EquipmentItem& item) {

  // This particular method is tried so often that we want to save optimize
  // the std::string construction.
  static const std::string method_name = "on_update";
  if (!userdata_has_field(item, method_name)) {
    return;
  }

  push_item(l, item);
  on_update();
  lua_pop(l, 1);
}
예제 #22
0
파일: stk_test.c 프로젝트: loiso/scalc
int
main()
{
  struct stack sp;
	
	stk_init(&sp);
	mpl_int a, b, c, d, e, f;
	char as[] = "12";
	char bs[] = "128";
	char cs[] = "5";
	
	char str[10];
	int i;
	
	mpl_init(&a);
	mpl_init(&b);
	mpl_init(&c);
	
	mpl_set_str(&a, as, 10);	
	mpl_set_str(&b, bs, 10);
	mpl_set_str(&c, cs, 10);
	
	push_item(&sp, &a);
	push_item(&sp, &b);
	push_item(&sp, &c);
	
	print_stk(&sp);
	
	pop_item(&sp, &d);
	pop_item(&sp, &e);
	pop_item(&sp, &f);
	
	mpl_add(&d, &f, &e);
	mpl_to_str(&d, str, 10, 10);
	for (i = 0; str[i] != '\0'; i++)
		printf("%c", str[i]);
	printf("\n");
	return 0;
}
예제 #23
0
파일: syntax.c 프로젝트: loiso/scalc
static void
pr_expr(void)
{
	number val;
	int rv;
	
	rv = mpl_init(&val.value);
	if (rv != MPL_OK){
		err = MEM_ERR;
		goto out;
	}
	
	switch (token.type) {
	
	case TOKEN_LPARENTH:
		get_next_token();
		add_expr();
		
		if (err == SYN_ERR || err == MEM_ERR) {
			goto out;
		}
		if (token.type != TOKEN_RPARENTH) {
			err = SYN_ERR;
			goto out;
		} else {
			get_next_token();
		}
		goto out;
		
	case TOKEN_INTEGER:
		rv = mpl_copy(&val.value, &token.num.value);
		val.frac = token.num.frac;
		if (rv != MPL_OK)
			goto err;
			
		rv = push_item(&sp, &val);
		if (rv != OK)
			goto err;

		get_next_token();
		goto out;
		
	default:
		err = SYN_ERR;
		goto out;
	}
err:
	err = MEM_ERR;
out:
	return ;
}
예제 #24
0
static const char *add_alt(cmd_parms *cmd, void *d, char *alt, char *to)
{
    if (cmd->info == BY_PATH) {
        if (!strcmp(to, "**DIRECTORY**")) {
	    to = "^^DIRECTORY^^";
	}
    }
    if (cmd->info == BY_ENCODING) {
	ap_str_tolower(to);
    }

    push_item(((autoindex_config_rec *) d)->alt_list, cmd->info, to,
	      cmd->path, alt);
    return NULL;
}
예제 #25
0
/**
 * \brief Implementation of game:get_item_assigned().
 * \param l The Lua context that is calling this function.
 * \return Number of values to return to Lua.
 */
int LuaContext::game_api_get_item_assigned(lua_State* l) {

  Savegame& savegame = check_game(l, 1);
  int slot = luaL_checkint(l, 2);

  if (slot < 1 || slot > 2) {
    arg_error(l, 2, "The item slot should be 1 or 2");
  }

  EquipmentItem* item = savegame.get_equipment().get_item_assigned(slot);

  if (item == NULL) {
    lua_pushnil(l);
  }
  else {
    push_item(l, *item);
  }
  return 1;
}
예제 #26
0
void LuaGossip::OnSelectOption(Object* pObject, Player* Plr, uint32 Id, const char* EnteredCode)
{
    GET_LOCK;
    if(pObject->GetTypeId() == TYPEID_UNIT)
    {
        if(m_unit_gossip_binding == NULL) { RELEASE_LOCK; return; }

        lua_engine::BeginLuaFunctionCall(m_unit_gossip_binding->refs[GOSSIP_EVENT_ON_SELECT_OPTION]);
        push_creature(TO_CREATURE(pObject));
        push_int(GOSSIP_EVENT_ON_SELECT_OPTION);
        push_player(Plr);
        push_int(Id);
        push_str(EnteredCode);
        lua_engine::ExecuteLuaFunction(5);
    }
    else if(pObject->GetTypeId() == TYPEID_ITEM)
    {
        if(m_item_gossip_binding == NULL) { RELEASE_LOCK; return; }
        lua_engine::BeginLuaFunctionCall(m_item_gossip_binding->refs[GOSSIP_EVENT_ON_SELECT_OPTION]);
        push_item(TO_ITEM(pObject));
        push_int(GOSSIP_EVENT_ON_SELECT_OPTION);
        push_player(Plr);
        push_int(Id);
        push_str(EnteredCode);
        lua_engine::ExecuteLuaFunction(5);
    }
    else if(pObject->GetTypeId() == TYPEID_GAMEOBJECT)
    {
        if(m_go_gossip_binding == NULL) { RELEASE_LOCK; return; }
        lua_engine::BeginLuaFunctionCall(m_go_gossip_binding->refs[GOSSIP_EVENT_ON_SELECT_OPTION]);
        push_go(TO_GAMEOBJECT(pObject));
        push_int(GOSSIP_EVENT_ON_SELECT_OPTION);
        push_player(Plr);
        push_int(Id);
        push_str(EnteredCode);
        lua_engine::ExecuteLuaFunction(5);
    }
    RELEASE_LOCK
}
void klawisz(GtkWidget *widget, GdkEventKey *event, int stan) { /* parametr stan jest przekazywany do funkcji i przyjmuje wartości 1 lub 0 */

uint klawisz;
klawisz = ((GdkEventKey*) event)->keyval;
uint klawisz_hardware;
klawisz_hardware = ((GdkEventKey*) event)->hardware_keycode;
uint czas;
czas = ((GdkEventKey*) event)->time;

/*pressing keys*/
if (stan == 1) {
printf("klawisz wcisnięty: %6X,%6X,%8hd\n", klawisz, klawisz_hardware,
czas);
if (klawisz == 0xff51) /* strzalka w lewo */
{
stick_x = -32768;
sprintf(wychylenie_x, "%d", stick_x);
gtk_label_set_text(label_x1, wychylenie_x);
wyslij_stick(0, stick_x);
}
if (klawisz == 0xff53) /* strzalka w prawo */
{
stick_x = 32767;
sprintf(wychylenie_x, "%d", stick_x);
gtk_label_set_text(label_x1, wychylenie_x);
wyslij_stick(0, stick_x);
}
if (klawisz == 0xff52) /* strzalka w górę */
{
/*
stick_y = -32768;
sprintf(wychylenie_y, "%d", stick_y);
gtk_label_set_text(label_y1, wychylenie_y);
wyslij_stick(1, stick_y);
*/

// half speed
throttle = 16384;
sprintf(wychylenie_y, "%d", throttle);
gtk_label_set_text(label_y1, wychylenie_y);
wyslij_stick(4, throttle);
}
if (klawisz == 0xff54) /* strzalka w dół */
{
/*
stick_y = 32767;
sprintf(wychylenie_y, "%d", stick_y);
gtk_label_set_text(label_y1, wychylenie_y);
wyslij_stick(1, stick_y);
*/

// quarter speed
throttle = 8192;
sprintf(wychylenie_y, "%d", throttle);
gtk_label_set_text(label_y1, wychylenie_y);
wyslij_stick(4, throttle);
}

/* numpad */
if (klawisz == 0xff96 || klawisz == 0xffb4) /* numpad 4 */
{
//push_item(statusbar, GINT_TO_POINTER(context_id), "numpad 4 pressed");
wyslij_stick(8, -32768);
}

if (klawisz == 0xff98 || klawisz == 0xffb6) /* numpad 6 */
{
//push_item(statusbar, GINT_TO_POINTER(context_id), "numpad 6 pressed");
wyslij_stick(8, 32767);
}

if (klawisz == 0xff97 || klawisz == 0xffb8) /* numpad 8 */
{
//push_item(statusbar, GINT_TO_POINTER(context_id), "numpad 8 pressed");
wyslij_stick(9, -32768);
}

if (klawisz == 0xff99 || klawisz == 0xffb2) /* numpad 2 */
{
//push_item(statusbar, GINT_TO_POINTER(context_id), "numpad 2 pressed");
wyslij_stick(9, 32767);
}
/* end of numpad */

if (klawisz == 'e')
{
switch_Expo();
}

if (klawisz == 'f')
{
toggle_Fullscreen();
}

/** PID */
if (klawisz == 'q')
/* increase proportional */
{wyslij_dwustan(13, 1);}
if (klawisz == 'a')
/* decrease proportional */
{wyslij_dwustan(13, 0);}
if (klawisz == 'w')
/* increase integral */
{wyslij_dwustan(14, 1);}
if (klawisz == 's')
/* decrease integral */
{wyslij_dwustan(14, 0);}
if (klawisz == 'e')
/* increase derivative */
{wyslij_dwustan(15, 1);}
if (klawisz == 'd')
/* decrease derivative */
{wyslij_dwustan(15, 0);}
if (klawisz == 0x002C)
{/* ',' */
wyslij_stick(6, 32767);
}

if (klawisz == 0x002E)
{/* '.' */
wyslij_stick(6, -32768);
}

if (klawisz == '=')
{
wyslij_stick(7, -32768);
}

if (klawisz == '-')
{
wyslij_stick(7, 32767);
}

if (klawisz == '[')
{
printf("\'[\' - waypoint action No 1\n");
push_item(statusbar, GINT_TO_POINTER(context_id), "\'[\' - waypoint action No 1");
//TODO: include sending waypoints
}

if (klawisz == ']')
{
printf("\']\' - waypoint action No 2\n");
push_item(statusbar, GINT_TO_POINTER(context_id), "\']\' - waypoint action No 2 (skip waypoint)");
skip_point();
}
if (klawisz == 'i')
{
printf("sending introduction\n");
//push_item(statusbar, GINT_TO_POINTER(context_id), "sending introduction");
}

if (klawisz == 'h')
{
wyslij_dwustan(9, 1);
}

if (klawisz == 'k')
{
if (synchronization)
	{
synchronization = FALSE;
gtk_statusbar_push(statusbar, GINT_TO_POINTER(context_id), "synchro OFF");
	}
else
	{
synchronization = TRUE;
gtk_statusbar_push(statusbar, GINT_TO_POINTER(context_id), "synchro ON");
	}
}

if (klawisz == 'l')
{
switch_Shining();
}
}

/*releasing keys*/
if (stan == 0) {
printf("klawisz zwolniony: %6X,%6X,%8hd\n", klawisz, klawisz_hardware,
czas);
if (klawisz == 0xff51) /* strzalka w lewo zwolniona */
{
stick_x = 0;
sprintf(wychylenie_x, "%d", stick_x);
gtk_label_set_text(label_x1, wychylenie_x);
wyslij_stick(0, stick_x);
}
if (klawisz == 0xff53) /* strzalka w prawo zwolniona */
{
stick_x = 0;
sprintf(wychylenie_x, "%d", stick_x);
gtk_label_set_text(label_x1, wychylenie_x);
wyslij_stick(0, stick_x);
}
if (klawisz == 0xff52) /* strzalka w górę zwolniona */
{
/*
stick_y = 0;
sprintf(wychylenie_y, "%d", stick_y);
gtk_label_set_text(label_y1, wychylenie_y);
wyslij_stick(1, stick_y);
*/

throttle = 0;
sprintf(wychylenie_y, "%d", throttle);
gtk_label_set_text(label_y1, wychylenie_y);
wyslij_stick(4, throttle);
}
if (klawisz == 0xff54) /* strzalka w dół zwolniona */
{
/*
stick_y = 0;
sprintf(wychylenie_y, "%d", stick_y);
gtk_label_set_text(label_y1, wychylenie_y);
wyslij_stick(1, stick_y);
*/

throttle = 0;
sprintf(wychylenie_y, "%d", throttle);
gtk_label_set_text(label_y1, wychylenie_y);
wyslij_stick(4, throttle);
}

if (klawisz == 0x002C)
{/* ',' */
wyslij_stick(6, 0);
}

if (klawisz == 0x002E)
{/* '.' */
wyslij_stick(6, 0);
}

if (klawisz == '=')
{
wyslij_stick(7, 0);
}

if (klawisz == '-')
{
wyslij_stick(7, 0);
}

if (klawisz == 'h')
{
wyslij_dwustan(9, 0);
}

/* numpad */
if (klawisz == 0xff96 || klawisz == 0xffb4) /* numpad 4 */
{
wyslij_stick(8, 0);
}

if (klawisz == 0xff98 || klawisz == 0xffb6) /* numpad 6 */
{
wyslij_stick(8, 0);
}

if (klawisz == 0xff97 || klawisz == 0xffb8) /* numpad 8 */
{
wyslij_stick(9, 0);
}

if (klawisz == 0xff99 || klawisz == 0xffb2) /* numpad 2 */
{
wyslij_stick(9, 0);
}
/* end of numpad */
}
}
예제 #28
0
    int read_item() {
        config_file *f;
        int tk;
        config_item *item;
        ll_failed_return(tk = get_token());

        switch (tk) {
        case token_eof:
            f = _files.pop_front();
            f->close();
            if (!_files.empty()) {
                getc();
            }
            return ok;
        case '\n':
            return ok;
        case token_string: 
        {
            item = _new<config_item>(_pool, _cur);
            item->name = _t;
            while (1) {
                ll_failed_return(tk = get_token());
                switch (tk) {
                case EOF:
                case '\n':
                    if (item->value_count) {
                        config_text *t;
                        while ((t = (config_text*)list_pop())) {
                            _pool->grow(t);
                        }
                        item->values = (config_text**)_pool->finish();
                    }
                    else {
                        item->values = nullptr;
                    }
                    push_item(item);
                    return ok;
                case token_string:
                    item->value_count++;
                    list_push(_t);
                    break;
                default:
                    error_at(getpos(), "expected string or new line or EOF.");
                    return fail;
                }
            }
            break;
        }
        case '<': 
        {
            ll_failed_return(tk = get_token());
            if (tk != token_string) {
                error_at(getpos(), "expected string.");
                return fail;
            }
            item = _new<config_item>(_pool, _cur);
            item->name = _t;
            while (1) {
                ll_failed_return(tk = get_token());
                switch (tk) {
                case '>':
                    ll_failed_return(tk = get_token());
                    if (tk != '\n' && tk != EOF) {
                        error_at(getpos(), "expected new line or EOF.");
                        return fail;
                    }
                    if (item->value_count) {
                        config_text **p, *t;
                        p = item->values = (config_text**)_pool->alloc(sizeof(config_text*) * item->value_count);
                        while ((t = (config_text*)list_pop())) {
                            *p++ = t;
                        }
                    }
                    else {
                        item->values = nullptr;
                    }
                    push_item(item);
                    _cur = item;
                    return ok;
                case token_string:
                    item->value_count++;
                    list_push(_t);
                    break;
                default:
                    error_at(getpos(), "expected string or '>'.");
                    return fail;
                }
            }
            break;
        }
        case token_block_end: 
        {
            ll_failed_return(tk = get_token());
            if (tk != token_string) {
                error_at(getpos(), "expected string.");
                return fail;
            }
            if (_cur == nullptr || 
                strcmp(*static_cast<config_item*>(_cur)->name, *_t) != 0) {
                error_at(getpos(), "unmatching item block.");
                return fail;
            }
            _cur = _cur->_parent;

            ll_failed_return(tk = get_token());
            if (tk != '>') {
                error_at(getpos(), "expected '>'.");
                return fail;
            }
            ll_failed_return(tk = get_token());
            if (tk != '\n' && tk != EOF) {
                error_at(getpos(), "expected new line or EOF.");
                return fail;
            }
            return ok;
        }
        case token_include: 
        {
            ll_failed_return(tk = get_token());
            if (tk != token_string) {
                error_at(getpos(), "expected string.");
                return fail;
            }

            ll_failed_return(tk = get_token());
            if (tk != '>') {
                error_at(getpos(), "expected '>'.");
                return fail;
            }
            ll_failed_return(tk = get_token());
            if (tk != '\n' && tk != EOF) {
                error_at(getpos(), "expected new line or EOF.");
                return fail;
            }

            f = _new<config_file>(_pool);
            
            if (ll_failed(f->open(*_t))) {
                error_at(_t->loc.start, "open file '%s' failed.", _t->text());
                return fail;
            }

            for (auto& f2 : _files) {
                if ((f->stat.st_dev == f2.stat.st_dev) && (f->stat.st_ino == f2.stat.st_ino)) {
                    error_at(_t->loc.start, "recursive include file '%s'.", _t->text());
                    return fail;
                }
            }
            _files.push_front(f);
            getc();
            return ok;
        }
        }
        return 0;
    }
예제 #29
0
static const char *add_readme(cmd_parms *cmd, void *d, char *name)
{
    push_item(((autoindex_config_rec *) d)->rdme_list, 0, NULL, cmd->path,
	      name);
    return NULL;
}
예제 #30
0
static const char *add_ignore(cmd_parms *cmd, void *d, char *ext)
{
    push_item(((autoindex_config_rec *) d)->ign_list, 0, ext, cmd->path, NULL);
    return NULL;
}