Example #1
0
static void main_menu() {
    while (true) {
        print_header();

        console_puts("It will attempt to completley destory ALL DATA on SELECTED ATA DISKS.\n\n");

        console_puts("The following devices have been detected:\n");

        uint8_t devices = 0;
        for (uint8_t i = 0; i < 4; i++) {
            if (ide_device_is_present(i) && ide_device_get_type(i) == 0) {
                console_putsf("    - ATA Device %u (%s) %7uMB - %s\n", i, ide_device_is_dma_capable(i) ? "DMA" : "PIO", ide_device_get_size(i) / 1024 / 2, ide_device_get_string(i, IDE_STRING_MODEL));
                devices++;
            }
        }

        if (devices == 0) {
            console_color(0x0C);
            console_puts("\nNo devices have been detected. You cannot run this tool.\n");
            console_color(0x07);
        }

        for (uint8_t i = 0; i < 12 - devices + 1 - (devices ? 0 : 2); i++) console_puts("\n");

        console_puts("Press \"i\"      to view technical information.\n");

        if (devices == 0) {
            console_puts("You may turn the computer off.");
        } else {
            console_puts("Press \"ENTER\" to continue.");
        }

        char c = get_key();
        switch (c) {
            case 'i':
                print_tech_info();
                break;
            case '\n':
                if(devices) run_tool(devices);
                break;
        }
    }
}
bool longcb(puppeteer_msgs::long_command::Request &req,
	    puppeteer_msgs::long_command::Response &res)
{
    // Create a new variable to publish:
    geometry_msgs::PointStamped cmd;
    
    if(exit_flag == false) 
    { 
	ROS_DEBUG("Sending Received Data");

	unsigned char dataPtr[128];

	MakeLongString(dataPtr, req.type, req.num1, req.num2, req.num3,
		       req.num4, req.num5, req.div);
	sendData(req.robot_index, dataPtr, LONG_PACKET_SIZE);

	// If data sent with no errors, we set the response to an
	// affirmitive value.
	res.error = false;
      
	ROS_DEBUG("Send Complete");

	int tmp = get_key(req.robot_index);
	cmd.header.frame_id = req.type;
	cmd.header.stamp = ros::Time::now();
	cmd.point.x = req.num1;
	cmd.point.y = req.num2;
	cmd.point.z = req.num3;
	pub[tmp-1].publish(cmd);
	cmd.point.x = req.num4;
	cmd.point.y = req.num5;
	cmd.point.z = 0.0;
	if (tmp != 0)
	    pub[tmp-1].publish(cmd);
    }
    else
    {
	ROS_DEBUG("Send Request Denied");
	res.error = true;
    }

    return true;
}
Example #3
0
int get_auth_level(){
	char *IP, *URL, *id, *id_ori, *key, *salt;
	int level;
	salt = calloc(128, 1);
	IP = getenv("REMOTE_ADDR");
	if(!IP) die(BAD_IP);
	URL = getenv("HTTP_REFERER");
	if(!URL) die(BAD_URL);
	key = get_key();
	if(!key) die(BAD_SERV);
	snprintf(salt, 128, "$5$%s$", IP);
	id = sha(URL, salt);
	id = strrchr(id, '$') + 1;
	id_ori = get_id(key, &level);
	if(!id_ori) die(NO_REG);
	if(strcmp(id, id_ori)) die(BAD_SERV);
	free(salt);
	return(level);
}
/* Check the FULL binary, just for good measure. There is not a chance we'll
   have a false positive here but this function is not performance critical. */
static int cmp_exact(char *source, int index)
{
	int i = 0, len, result;
	char *p, *key = get_key(index);
	char delim;
	unsigned char *binary, *crypt;

	delim = strchr(source, '.') ? '.' : '$';
	p = strrchr(source, delim) + 1;
	len = strlen(p) / 2;

	if (len == BINARY_SIZE) return 1;

	binary = mem_alloc(len);
	crypt = mem_alloc(len);

	while (*p) {
		binary[i++] = (atoi16[ARCH_INDEX(*p)] << 4) |
			atoi16[ARCH_INDEX(p[1])];
		p += 2;
	}
#if !ARCH_LITTLE_ENDIAN
	for (i = 0; i < len/sizeof(uint32_t); ++i) {
		((uint32_t*)binary)[i] = JOHNSWAP(((uint32_t*)binary)[i]);
	}
#endif
	pbkdf2_sha1((const unsigned char*)key,
	            strlen(key),
	            cur_salt->salt, cur_salt->length,
	            cur_salt->iterations, crypt, len, 0);
	result = !memcmp(binary, crypt, len);
#if 0
	dump_stuff_msg("hash binary", binary, len);
	dump_stuff_msg("calc binary", crypt, len);
#endif
	MEM_FREE(binary);
	MEM_FREE(crypt);
	if (!result)
		fprintf(stderr, "\n%s: Warning: Partial match for '%s'.\n"
		        "This is a bug or a malformed input line of:\n%s\n",
		        FORMAT_LABEL, key, source);
	return result;
}
ObjectGroup::ObjectGroup(const ReaderMapping& reader) :
  name(),
  icons(),
  for_worldmap(false)
{
  icons.clear();
  icons.push_back( ObjectIcon("#move", "images/engine/editor/arrow.png") );

  reader.get("name", name);
  reader.get("worldmap", for_worldmap);

  auto iter = reader.get_iter();
  while(iter.next()) {
    const std::string& token = iter.get_key();
    if (token == "object") {
      icons.push_back( ObjectIcon( iter.as_mapping() ) );
    }
  }
}
Example #6
0
/**
 * Read the DER formatted RSA key and populate the key ring buffer.
 *
 * @param rsa_keyfile
 * @return
 */
int util_set_rsakey(char *rsa_keyfile)
{
    int ret = FALSE;
    int fdin;
    uint8_t *pInfile;
    struct stat sb;
    fdin = open(rsa_keyfile, O_RDONLY);
    if (fdin == -1)
    {
        perror("Could not open input");
        return TRUE;
    }
    fstat(fdin, &sb);
    pInfile = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fdin, 0);
    ret = get_key(pInfile);
    munmap(pInfile, sb.st_size);
    close(fdin);
    return ret;
}
Example #7
0
data_object* object_generator::get_object(int iter)
{
    // compute key
    (void) get_key(iter, NULL);
    
    // compute size
    unsigned int new_size = 0;
    if (m_data_size_type == data_size_fixed) {
        new_size = m_data_size.size_fixed;
    } else if (m_data_size_type == data_size_range) {
        if (m_data_size_pattern && *m_data_size_pattern=='S') {
            double a = (m_key_index-m_key_min)/static_cast<double>(m_key_max-m_key_min);
            new_size = (m_data_size.size_range.size_max-m_data_size.size_range.size_min)*a + m_data_size.size_range.size_min;
        } else {
            new_size = random_range(m_data_size.size_range.size_min > 0 ? m_data_size.size_range.size_min : 1,
                m_data_size.size_range.size_max);
        }
    } else if (m_data_size_type == data_size_weighted) {
        new_size = m_data_size.size_list->get_next_size();
    } else {
        assert(0);
    }
    
    // compute expiry
    int expiry = 0;
    if (m_expiry_max > 0) {
        expiry = random_range(m_expiry_min, m_expiry_max);
    }
    
    // modify object content in case of random data
    if (m_random_data) {
        m_value_buffer[m_value_buffer_mutation_pos++]++;
        if (m_value_buffer_mutation_pos >= m_value_buffer_size)
            m_value_buffer_mutation_pos = 0;
    }

    // set object
    m_object.set_key(m_key_buffer, strlen(m_key_buffer));
    m_object.set_value(m_value_buffer, new_size);
    m_object.set_expiry(expiry);    
    
    return &m_object;
}
Example #8
0
 static object get_item( pair_type& p, size_t index ){
     switch( index ){
         case 0:{
             return get_key( p );
         }
         case 1:{
             return get_mapped( p );
         }
         case 2:{
             objects::stop_iteration_error();
             return object(); //will not reach this line
         }
         default:{
             PyErr_SetString( PyExc_IndexError, "the only valid index numbers are: 0 and 1");
             throw_error_already_set();
             return object(); //will not reach this line
         }
     }
 }
Example #9
0
int list_del(char* base, char* key, int key_len)
{
    int ndel = 0;
    btree_node* bp = (btree_node*) base;
    int* i = &bp->cell_list;
    while(*i != 0) {
        list_node* np = (list_node*)(base+*i);
        if(np->key_len == key_len && 
                memcmp(get_key(np), key, key_len) == 0) // match
        {
            ndel++;
            arena_free(base, *i);
            *i = np->next;
        }
        else
            i = &np->next;
    }
    return ndel;
}
Example #10
0
void main() {
	char * map =
		"####  ####"
		"#  ####  #"
		"#        #"
		"##      ##"
		" #      # "
		" #      # "
		"##      ##"
		"#        #"
		"#  ####  #"
		"####  ####";
	int map_w = 10;

	POINT player = { 2, 2 };
	unsigned char scancode = 0;
	unsigned char ascii = 0;

	clear();
	draw_map(map, 0, 0, map_w, 5);

	do {
		draw_char(' ', player.x, player.y, 15);
		switch (scancode) {
		case 72:
			move(map, &player, player.x, player.y - 1,map_w);
			break;
		case 80:
			move(map, &player, player.x, player.y + 1,map_w);
			break;
		case 75:
			move(map, &player, player.x - 1, player.y,map_w);
			break;
		case 77:
			move(map, &player, player.x + 1, player.y,map_w);
			break;
		}
		draw_char('@', player.x, player.y, 15);

		get_key(&scancode, &ascii);
	}while (scancode != 1);
}
Example #11
0
bool offset_rindex::load(const std::string& url, gulong _filecount, gulong fsize,
	bool CreateCacheFile)
{
	filecount = _filecount;
	npages=(filecount-1)/ENTR_PER_PAGE+2;
	if (!oft_file.load_cache(url, url, npages*sizeof(guint32))) {
		MapFile map_file;
		if (!map_file.open(url.c_str(), fsize))
			return false;
		const gchar *idxdatabuffer=map_file.begin();
		/* oft_file.wordoffset[i] holds offset of the i-th page in the index file */
		oft_file.allocate_wordoffset(npages);
		const gchar *p1 = idxdatabuffer;
		gulong index_size;
		guint32 j=0;
		for (guint32 i=0; i<filecount; i++) {
			index_size=strlen(p1) +1 + 2*sizeof(guint32);
			if (i % ENTR_PER_PAGE==0) {
				oft_file.get_wordoffset(j)=p1-idxdatabuffer;
				++j;
			}
			p1 += index_size;
		}
		oft_file.get_wordoffset(j)=p1-idxdatabuffer;
		map_file.close();
		if (CreateCacheFile) {
			if (!oft_file.save_cache(url))
				g_printerr("Cache update failed.\n");
		}
	}

	if (!(idxfile = fopen(url.c_str(), "rb"))) {
		return false;
	}

	first.assign(0, read_first_on_page_key(0));
	last.assign(npages-2, read_first_on_page_key(npages-2));
	middle.assign((npages-2)/2, read_first_on_page_key((npages-2)/2));
	real_last.assign(filecount-1, get_key(filecount-1));

	return true;
}
Example #12
0
int switch_boot_mode(void)
{
	unsigned long hold_time = 5000000, polling_time = 10000, tmp;
	//unsigned long upgrade_step;
	unsigned int key_flag=0;

	while(hold_time > 0)
	{
		udelay(polling_time);
		tmp = get_key();
		if(tmp && (key_flag<10)) {  
		    printf("get_key(): %d\n", tmp);
                    key_flag++;
                }
                else if(!tmp && (key_flag>=10) && (key_flag<20)) {
		    printf("get_key(): %d\n", tmp);
                    key_flag++;
                }
                else if(key_flag>=20)
                    break;
        
		hold_time -= polling_time;
        if((key_flag==0) && (hold_time<4950000))
            break;
	}
        printf("key_flag=%d\n", key_flag);
	if(key_flag >= 15)
	{
                printf("nand key burning.... please wait\n");
                run_command ("tiny_usbtool 20000", 0);
                return 1;
	}
	else if(key_flag == 10)
	{
		printf("upgrading... please wait\n");
		into_recovery();
	} else {
		printf("Normal Start...\n");
		return	1;
        }

}
Example #13
0
static void touch_response_handler(lcb_server_t *server,
                                   packet_info *info)
{
    lcb_t root = server->instance;
    char *packet;
    lcb_uint16_t nkey;
    const char *key = get_key(server, &nkey, &packet);
    lcb_uint16_t status = PACKET_STATUS(info);
    lcb_error_t rc = map_error(root, status);

    if (key == NULL) {
        lcb_error_handler(server->instance, LCB_EINTERNAL,
                          NULL);
    } else {
        lcb_touch_resp_t resp;
        setup_lcb_touch_resp_t(&resp, key, nkey, PACKET_CAS(info));
        root->callbacks.touch(root, info->ct.cookie, rc, &resp);
        release_key(server, packet);
    }
}
Example #14
0
gint
test_hash(autounit_test_t *t) 
{
  di_hash_table *table;
  int i,nbr_of_insert=20;
  char str[KEY_VALUE_NBR][STRING_MAX_LENGTH];
  di_rstring key[KEY_VALUE_NBR];


  table = di_hash_table_new(di_rstring_hash, di_rstring_equal);

  for (i=0;i<nbr_of_insert;i++) {
    snprintf(str[i],STRING_MAX_LENGTH,"%d",i);
    get_key(str[i],&key[i]);
    di_hash_table_insert (table, &key[i], str[i]);
  }
  au_assert(t,di_hash_table_size(table) == nbr_of_insert,"hash table size is different with the number of data inserted");

  return TRUE;
}
Example #15
0
static void unlock_response_handler(lcb_server_t *server,
                                    packet_info *info)
{
    lcb_t root = server->instance;
    lcb_uint16_t status = PACKET_STATUS(info);
    char *packet;
    lcb_uint16_t nkey;
    struct lcb_command_data_st *command_data = &info->ct;
    const char *key = get_key(server, &nkey, &packet);
    lcb_error_t rc = map_error(root, status);

    if (key == NULL) {
        lcb_error_handler(server->instance, LCB_EINTERNAL, NULL);
    } else {
        lcb_unlock_resp_t resp;
        setup_lcb_unlock_resp_t(&resp, key, nkey);
        root->callbacks.unlock(root, command_data->cookie, rc, &resp);
        release_key(server, packet);
    }
}
Example #16
0
/*------------------------------------------------------------
 * Function Name  : FormateFlash
 * Description    : 用于第一次使用时格式化FLASH
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void FormateFlash( void )
{	
	SetFormateFlashTimeOut(1000);

	while (GetFormateFlashTimeOut() == TIMEIN)
	{
		if (KEY_STOP != get_key(0xffffffff))
		{
			return;
		}
	}
		
	if (EraseFlashAskHandler() == DISABLE)
	{
		return;
	}
	
	SetPage(USER_LOGIN_PAGE);
	if (FAILED == LoadManagerLogin() )
	{
		lcd_clear(COLOR_BACK);
		return;
	}
		
	memset(get_pcm(),0x00,PCM_MEM_SIZE);				
	memset(get_prm(),0x00,PRM_MEM_SIZE);		
	memset(get_prv(),0x00,PRV_MEM_SIZE);
	
	pHmi->test_standard_index = KYSNJS;	//设置默认试验
	pHmi->lcd_light_use = 5;			//设置默认亮度
	
	pcm_save();
	prm_save();
	prv_save();
	
	pcm_read();												
	prm_read();												
	prv_read();	

	lcd_clear(COLOR_BACK);	
}
Example #17
0
void demo_bitmap() {
	printf("Demo bitmap.\n");

	lcd_load_bmp("pic1.bmp", display);
	lcd_set_bmp(0,0,display);

	if (get_key() == QUIT)
		return;

	lcd_load_bmp("pic2.bmp", display);
	lcd_set_bmp(0,0,display);

	if (get_key() == QUIT)
		return;

	lcd_load_bmp("pic4.bmp", display);
	clear_screen();
	lcd_set_bmp(0,0,display);

	if (get_key() == QUIT)
		return;

	lcd_set_bmp(40,0,display);

	if (get_key() == QUIT)
		return;

	lcd_set_bmp(80,0,display);

	if (get_key() == QUIT)
		return;

	lcd_load_bmp("pic3.bmp", display);
	lcd_set_bmp(10,10,display);

	if (get_key() == QUIT)
		return;

	lcd_set_bmp(70,70,display);

	if (get_key() == QUIT)
		return;
}
BOOST_SERIALIZATION_DECL void  
extended_type_info::key_unregister() const{
    if(NULL == get_key())
        return;
    // note: it's been discovered that at least one platform is not guaranteed
    // to destroy singletons reverse order of construction.  So we can't
    // use a runtime assert here.  Leave this in a reminder not to do this!
    // BOOST_ASSERT(! singleton<detail::ktmap>::is_destroyed());
    if(! singleton<detail::ktmap>::is_destroyed()){
        detail::ktmap & x = singleton<detail::ktmap>::get_mutable_instance();
        detail::ktmap::iterator start = x.lower_bound(this);
        detail::ktmap::iterator end = x.upper_bound(this);
        // remove entry in map which corresponds to this type
        for(;start != end; ++start){
            if(this == *start){
                x.erase(start);
                break;
            }
        }
    }
}
static void
cancel_supports_port (MMPlugin *plugin,
                      const char *subsys,
                      const char *name)
{
    MMPluginBase *self = MM_PLUGIN_BASE (plugin);
    MMPluginBasePrivate *priv = MM_PLUGIN_BASE_GET_PRIVATE (self);
    MMPluginBaseSupportsTask *task;
    char *key;

    key = get_key (subsys, name);
    task = g_hash_table_lookup (priv->tasks, key);
    if (task) {
        /* Let the plugin cancel any ongoing tasks */
        if (MM_PLUGIN_BASE_GET_CLASS (self)->cancel_task)
            MM_PLUGIN_BASE_GET_CLASS (self)->cancel_task (self, task);
        g_hash_table_remove (priv->tasks, key);
    }

    g_free (key);
}
Example #20
0
/*
 * Print a help message.
 */
void PrintHelpMessage( void )
/***************************/
{
    const int           lineCount = 15;
    int                 count;
    int                 num;
    int                 ch;

    BannerMessage();
    for( count=0,num=0; usageMsg[count]!=NULL; count++,num++ ) {
        if( num == lineCount ) {
            printf( "\t(Press return to continue)" );
            fflush( stdout );
            ch = get_key();
            printf( "\n" );
            if( ch == 'q' )  break;
            num = 0;
        }
        printf( "%s\n", usageMsg[count] );
    }
}
Example #21
0
test_case insert_then_remove_then_search(
    int insertions,
    int removals,
    int search_successes,
    int search_failures,
    unsigned int seed
) {
    std::mt19937 rng(seed);
    test_case ret( insertions + search_successes + search_failures + removals );
    auto rem = efficiently_choose_target_to_remove{
        std::vector<std::pair<int,bool>>(insertions),
        insertions
    };

    // Generate the insertions
    for( int i = 0; i < insertions; i++ ) {
        ret[i] = operation{ operation_type::insert, 2 * i + 2 };
        rem.keys[i] = std::make_pair( 2 * i + 2, true );
    }
    std::shuffle( ret.begin(), ret.begin() + insertions, rng );

    // Generate the removals
    for( int i = 0; i < removals; i++ )
        ret[i+insertions] = operation{ operation_type::erase, rem.get_key(rng) };

    // Generate the searches
    std::uniform_int_distribution<> success_index(0, rem.keys.size()-1);
    std::uniform_int_distribution<> failure(0, insertions);

    auto bits = random_bits(search_failures, search_successes, rng);
    for( int i = 0; i < search_successes + search_failures; i++ )
        if( bits[i] )
            ret[i + insertions+removals] =
                operation{ operation_type::count, rem.keys[success_index(rng)].first };
        else
            ret[i + insertions+removals] =
                operation{ operation_type::count, 2*failure(rng) + 1};

    return ret;
}
Example #22
0
File: main.c Project: pixma/ecs
void main(){
	char  cChoiceMenu;	
	lcdBegin();
	SplashScreenWindow();
	InitUartComm();
	delay( 1000 );
	key_init();
	ecs_MainMenu();	
	while( 1 )
	{		
		//pooling for the keypads to let the user to select the choice from the options shown...	
		cChoiceMenu = translateKeyCode( get_key() );
		
		if( cChoiceMenu == '3' ){
				//Sync Data operation mode....
				syncScreenActivity();
				clearLcdScreen();
				ecs_MainMenu();
		}
		else if( cChoiceMenu == '7' )
		{
			//Settings like date settings only...
			SettingActivity();
			clearLcdScreen();
			ecs_MainMenu();
		}
		else if( cChoiceMenu == 'B')
		{
			//Data Entry Mode operation....
			dataEntrySession();
			clearLcdScreen();
			ecs_MainMenu();
		}
		else
		{
			//catch the unallocated button as invalid and indicate the user about it...
		}				
	}
	
}
Example #23
0
static cJSON *
get_cJSON(cJSON *parent, const char *json_pointer, int offset)
{
	if (parent == NULL || parent->type == cJSON_NULL) {
		return NULL;
	}
	if (offset == strlen(json_pointer)) {
		//如果为"" => obj
		return parent;
	}
	// / => ""  => obj[""]
	// /key => "key" =>obj["key"]
	char * key = get_key(json_pointer, &offset);

	if (key == NULL) {
		return NULL;
	}
	cJSON *value = NULL;
	if (parent->type == cJSON_Array) {
		//key必须为0 or 123,456
		int index = atoi(key);
		//strtol()
		value = cJSON_GetArrayItem(parent, index);
	} else if (parent->type == cJSON_Object) {
		value = cJSON_GetObjectItem(parent, key);
	} else {
		//null,number,string,boolean
		//不应该有key了
		value = NULL;
	}

	free(key);

	if (value != NULL && value->type != cJSON_NULL) {

		return get_cJSON(value, json_pointer, offset);
	} else {
		return NULL;
	}
}
Example #24
0
// python function stop(channel)
static PyObject *py_stop_channel(PyObject *self, PyObject *args, PyObject *kwargs)
{
    char key[8];
    char *channel;
    int gpio;
    int allowed = -1;

    clear_error_msg();

    if (!PyArg_ParseTuple(args, "s", &channel))
        return NULL;

    if (!get_key(channel, key)) {
        PyErr_SetString(PyExc_ValueError, "Invalid PWM key or name.");
        return NULL;
    }

    // check to ensure gpio is one of the allowed pins
    // Not protecting the call as if the get_key() fails, we won't make it here
    get_gpio_number(channel, &gpio);

    // Check to see if GPIO is allowed on the hardware
    // A 1 means we're good to go
    allowed = gpio_allowed(gpio);
    if (allowed == -1) {
        char err[2000];
        snprintf(err, sizeof(err), "Error determining hardware. (%s)", get_error_msg());
        PyErr_SetString(PyExc_ValueError, err);
        return NULL;
    } else if (allowed == 0) {
        char err[2000];
        snprintf(err, sizeof(err), "GPIO %d not available on current Hardware", gpio);
        PyErr_SetString(PyExc_ValueError, err);
        return NULL;
    }

    softpwm_disable(key);

    Py_RETURN_NONE;
}
Example #25
0
int		main(int argc, char **argv)
{
  t_letter	*msg;
  t_letter	*key;
  t_letter	*res;
  char		*base;
  int		flag;

  if (argc != 8)
    {
      my_printf("Usage : %s <message> <nb1 nb2 nb3 nb4> <base> <flag>\n", argv[0]);
      return (0);
    }
  if ((msg = get_message(argv[1])) == NULL)
    return (1);
  if ((key = get_key(argv)) == NULL)
    return (1);
  base = argv[6];
  flag = my_getnbr(argv[7]);
  return (0);
  res = my_crypt_101(msg, key, get_len(msg));
}
Example #26
0
/*
 * Look up pin in keys file. We store a dictionary for each
 * remote address, and inside that we have a data object for
 * each local address containing the pin.
 */
uint8_t *
lookup_pin_conf(bdaddr_t *laddr, bdaddr_t *raddr)
{
	link_key_p	key = NULL;

	syslog(LOG_DEBUG, "Got Link_Pin_Request event from '%s', " \
			"remote bdaddr %s", bt_ntoa(laddr, NULL),
			bt_ntoa(raddr, NULL));

	if ((key = get_key(raddr, 0)) != NULL) {
		syslog(LOG_DEBUG, "Found matching entry, " \
				"remote bdaddr %s, name '%s', pin %s",
				bt_ntoa(&key->bdaddr, NULL),
				(key->name != NULL)? key->name : "No name",
				(key->pin != NULL)? "exists" : "doesn't exist");
		return key->pin;
	}

	syslog(LOG_DEBUG, "Could not find link key for remote bdaddr %s",
			bt_ntoa(raddr, NULL));
	return NULL;
}
BOOST_SERIALIZATION_DECL bool
extended_type_info_no_rtti_0::is_less_than(
    const boost::serialization::extended_type_info &rhs) const 
{
    // shortcut for common case
    if(this == & rhs)
        return false;
    const char * l = get_key();
    const char * r = rhs.get_key();
    // if this assertion is triggered, it could mean one of the following
    // a) This class was never exported - make sure all calls which use
    // this method of type id are in fact exported.
    // b) This class was used (e.g. serialized through a pointer) before
    // it was exported.  Make sure that classes which use this method
    // of type id are NOT "automatically" registered by serializating 
    // through a pointer to the to most derived class.  OR make sure
    // that the BOOST_CLASS_EXPORT is included in every file
    // which does this.
    BOOST_ASSERT(NULL != l);
    BOOST_ASSERT(NULL != r);
    return std::strcmp(l, r) < 0;
}
Example #28
0
static void cooked_keys(void)
{
  int key;

  printf("[cooked]");

  for(;;) {
    key = get_key(stdin, 0);

    if ( key == 0x03 ) {
      printf("[done]\n");
      exit(0);
    } else if ( key == '?' )
      return;

    if ( key >= 0x20 && key < 0x100 ) {
      putchar(key);
    } else {
      printf("[%04x]", key);
    }
  }
}
Example #29
0
/*
 * Select Menu
 */
int select_menu(unsigned int level, unsigned int n_menu)
{
	unsigned int num=0;

	MZ_disp(level*13+13,num+1,0x04);
	while(1){
		if((z80_sts.status&S_FBTN)==0) return(-1);
		switch(get_key()){
		case 0x0d:	// menu select
			MZ_disp(level*13+13,num+1,0x9a);
			return(num);
			break;
		case 0x1b:	// escape menu
			z80_sts.status&=~S_FBTN;
			break;
		case 0x1d:	// menu back
			MZ_disp(level*13+13,num+1,0x9a);
			return(999);
			break;
		case 0x1e:	// up
			if(num>0){
				MZ_disp(level*13+13,num,0x04);
				MZ_disp(level*13+13,num+1,0x9a);
				num--;
			}
			break;
		case 0x1f:	// down
			if(num<(menus[n_menu].items-1)){
				MZ_disp(level*13+13,num+1,0x9a);
				MZ_disp(level*13+13,num+2,0x04);
				num++;
			}
			break;
		default:
			break;
		}
	}
	return(-1);
}
Example #30
0
static void unlock_response_handler(lcb_server_t *server,
                                    struct lcb_command_data_st *command_data,
                                    protocol_binary_response_header *res)
{
    lcb_t root = server->instance;
    lcb_uint16_t status = ntohs(res->response.status);
    char *packet;
    lcb_uint16_t nkey;
    const char *key = get_key(server, &nkey, &packet);
    lcb_error_t rc = map_error(root, status);

    if (key == NULL) {
        lcb_error_handler(server->instance, LCB_EINTERNAL,
                          NULL);
    } else {
        lcb_unlock_resp_t resp;
        setup_lcb_unlock_resp_t(&resp, key, nkey);
        TRACE_UNLOCK_END(res->response.opaque, command_data->vbucket, rc, &resp);
        root->callbacks.unlock(root, command_data->cookie, rc, &resp);
        release_key(server, packet);
    }
}