Exemplo n.º 1
0
bool registry_tests()
{
	Omega::IObject* pObj = Omega::GetObject(Omega::Registry::OID_Registry_Instance,Omega::Activation::Default,OMEGA_GUIDOF(Omega::Registry::IKey));
	TEST(pObj);
	
	Omega::Registry::IKey* pRootKey = static_cast<Omega::Registry::IKey*>(pObj);
	pObj = NULL;
	
	bool bTest;
	try
	{
		bTest = test_root_key(pRootKey);
	}
	catch (...)
	{
		pRootKey->Release();
		throw;
	}
	pRootKey->Release();
	if (!bTest)
		return false;
		
	// Check we can use the textual OID
	pObj = Omega::GetObject("Omega.Registry",Omega::Activation::Default,OMEGA_GUIDOF(Omega::Registry::IKey));
	TEST(pObj);
	pObj->Release();

	if (!test_key("System"))
		return false;

	if (!test_key("Local User"))
		return false;

	return true;
}
Exemplo n.º 2
0
int check_key_pressing(void)
{
	struct kpp_key_info *key_info = NULL;
	int state = 0, keys, i;

	int ret = 0;

	mxc_kpp_init();
	/* due to glitch suppression circuit,
	   wait sometime to let all keys scanned. */
	udelay(1000);
	keys = mxc_kpp_getc(&key_info);

	printf("Detecting VOL_DOWN+POWER key for recovery(%d:%d) ...\n",
		keys, keys ? key_info->val : 0);
	if (keys > 1) {
		for (i = 0; i < keys; i++) {
			if (test_key(CONFIG_POWER_KEY, &key_info[i]))
				state |= PRESSED_POWER;
			else if (test_key(CONFIG_VOL_DOWN_KEY, &key_info[i]))
				state |= PRESSED_VOL_DOWN;
		}
	}
	if ((state & RECOVERY_KEY_MASK) == RECOVERY_KEY_MASK)
		ret = 1;
	if (key_info)
		free(key_info);
	return ret;
}
Exemplo n.º 3
0
t_uint32 get_key_code(WPARAM wp) {
	t_uint32 code = (t_uint32)(wp & 0xFF);
	if (test_key(VK_CONTROL)) code|=F_CTRL;
	if (test_key(VK_SHIFT)) code|=F_SHIFT;
	if (test_key(VK_MENU)) code|=F_ALT;
	if (test_key(VK_LWIN) || test_key(VK_RWIN)) code|=F_WIN;
	return code;
}
Exemplo n.º 4
0
static unsigned get_key_code(WPARAM wp)
{
	unsigned code = (unsigned)(wp & 0xFF);
	if (test_key(VK_CONTROL)) code|=F_CTRL;
	if (test_key(VK_SHIFT)) code|=F_SHIFT;
	if (test_key(VK_MENU)) code|=F_ALT;
	if (test_key(VK_LWIN) || test_key(VK_RWIN)) code|=F_WIN;
	return code;
}
Exemplo n.º 5
0
size_t key_index_alt(dict *d, size_t key) {
    size_t index = 0;
    for (size_t i = 0; i < key; i++) {
        index += test_key(d, i);
    }
    return index;
}
Exemplo n.º 6
0
void do_do (void)
{	int udfold;
	char name[16];
	char *oldnext=next,*udflineold;
	header *var;
	scan_space(); scan_name(name); if (error) return;
	var=searchudf(name);
	if (!var || var->type!=s_udf)
	{	output("Need a udf!\n"); error=220; return;
	}
	udflineold=udfline; udfline=next=udfof(var); udfold=udfon; udfon=1;
	while (!error && udfon==1)
	{	command();
		if (udfon==2) break;
		if (test_key()==escape) 
		{	output("User interrupted!\n"); error=58; break;
		}
	}
	if (error) output1("Error in function %s\n",var->name);
	if (udfon==0)
	{	output1("Return missing in %s!\n",var->name); error=55; }
	udfon=udfold; udfline=udflineold;
	if (udfon) next=oldnext;
	else { next=input_line; *next=0; }
}
Exemplo n.º 7
0
static int builtin_input_id(struct udev_device *dev, int argc, char *argv[], bool test)
{
        struct udev_device *pdev;
        unsigned long bitmask_ev[NBITS(EV_MAX)];
        unsigned long bitmask_abs[NBITS(ABS_MAX)];
        unsigned long bitmask_key[NBITS(KEY_MAX)];
        unsigned long bitmask_rel[NBITS(REL_MAX)];

        /* walk up the parental chain until we find the real input device; the
         * argument is very likely a subdevice of this, like eventN */
        pdev = dev;
        while (pdev != NULL && udev_device_get_sysattr_value(pdev, "capabilities/ev") == NULL)
                pdev = udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL);

        /* not an "input" class device */
        if (pdev == NULL)
                return EXIT_SUCCESS;

        /* Use this as a flag that input devices were detected, so that this
         * program doesn't need to be called more than once per device */
        udev_builtin_add_property(dev, test, "ID_INPUT", "1");
        get_cap_mask(dev, pdev, "capabilities/ev", bitmask_ev, sizeof(bitmask_ev), test);
        get_cap_mask(dev, pdev, "capabilities/abs", bitmask_abs, sizeof(bitmask_abs), test);
        get_cap_mask(dev, pdev, "capabilities/rel", bitmask_rel, sizeof(bitmask_rel), test);
        get_cap_mask(dev, pdev, "capabilities/key", bitmask_key, sizeof(bitmask_key), test);
        test_pointers(dev, bitmask_ev, bitmask_abs, bitmask_key, bitmask_rel, test);
        test_key(dev, bitmask_ev, bitmask_key, test);
        return EXIT_SUCCESS;
}
Exemplo n.º 8
0
void do_repeat (void)
/***** do_loop
	do a loop command in a UDF.
	for value to value; .... ; endfor
*****/
{	int h;
	char *jump;
	if (!udfon)
	{	output("Repeat only allowed in functions!\n");
		error=57; return;
	}
	newram=endlocal;
	scan_space(); if (*next==';' || *next==',') next++;
	jump=next;
	while (!error)
	{	if (*next==1)
		{	output("End missing in repeat statement!\n");
			error=401; break;
		}
		h=command();
		if (udfon!=1 || h==c_return) break;
		if (h==c_break) { scan_end(); break; }
		if (h==c_end)
		{	next=jump;
			if (test_key()==escape)
			{   output1("User interrupted\n");
				error=1; break;
			}
		}
	}
}
Exemplo n.º 9
0
int main()
{
  printf("System Restarted!!!\n");
  //unsigned char mydata[8];

  //strcpy(fifo,"######");

  Uart_init();//Register RS232_RXD
  wifi_init();//initialize the wifi module


  while(1)
  {
	  //led_init();
	 test_key();
	 test_alarm();
	 test_alarm_en();
	  welcome();
	  Alarm();
	  //printf("%X\n",ringbell);
	  //printf("%x",IORD_ALTERA_AVALON_PIO_DATA(MYINPUT_BASE));

	  Uart_send_n("AT",2);
	  Uart_send(0x0d);
	  Uart_send(0x0a);

	  usleep(2000000);//2s
  }
  return 0;
}
Exemplo n.º 10
0
size_t next_key(dict *d, size_t last) {
    while(last < d->max_key) {
        if (test_key(d, ++last)) {
            return last;
        }
    }
    return last;
}
Exemplo n.º 11
0
void do_loop (void)
/***** do_loop
	do a loop command in a UDF.
	loop value to value; .... ; end
*****/
{	int h;
	char *jump;
	header *init,*end;
	long vend,oldindex;
	if (!udfon)
	{	output("Loop only allowed in functions!\n");
		error=57; return;
	}
	init=scan(); if (error) return;
	init=getvalue(init); if (error) return;
	if (init->type!=s_real)
	{	output("Startvalue must be real!\n"); error=72; return;
	}
	oldindex=loopindex;
	loopindex=(long)*realof(init);
	scan_space(); if (strncmp(next,"to",2))
	{	output("Endvalue missing in loop!\n"); error=73; goto end;
	}
	next+=2;
	end=scan(); if (error) goto end;
	end=getvalue(end); if (error) goto end;
	if (end->type!=s_real)
	{	output("Endvalue must be real!\n"); error=73; goto end;
	}
	vend=(long)*realof(end);
	if (loopindex>vend) { scan_end(); goto end; }
	newram=endlocal;
	scan_space(); if (*next==';' || *next==',') next++;
	jump=next;
	while (!error)
	{	if (*next==1)
		{	output("End missing in loop!\n");
			error=401; goto end;
		}
		h=command();
		if (udfon!=1 || h==c_return) break;
		if (h==c_break) { scan_end(); break; }
		if (h==c_end)
		{	loopindex++;
			if (loopindex>vend) break;
			else next=jump;
			if (test_key()==escape)
			{	output("User interrupted!\n");
				error=1; break;
			}
		}
	}
	end : loopindex=oldindex;
}
Exemplo n.º 12
0
int main (int argc, char** argv)
{
	struct udev *udev;
	struct udev_device *dev;

	char devpath[PATH_MAX];
	unsigned long bitmask_ev[NBITS(EV_MAX)];
	unsigned long bitmask_abs[NBITS(ABS_MAX)];
	unsigned long bitmask_key[NBITS(KEY_MAX)];
        unsigned long bitmask_rel[NBITS(REL_MAX)];

	if (argc != 2) {
		fprintf(stderr, "Usage: %s <device path (without /sys)>\n", argv[0]);
		exit(1);
	}

	/* get the device */
	udev = udev_new();
	if (udev == NULL)
		return 1;

	snprintf(devpath, sizeof(devpath), "%s/%s", udev_get_sys_path(udev), argv[1]);
	dev = udev_device_new_from_syspath(udev, devpath);
	if (dev == NULL) {
		fprintf(stderr, "unable to access '%s'\n", devpath);
		return 1;
	}

	/* walk up the parental chain until we find the real input device; the
	 * argument is very likely a subdevice of this, like eventN */
	while (dev != NULL && udev_device_get_sysattr_value(dev, "capabilities/ev") == NULL)
		dev = udev_device_get_parent_with_subsystem_devtype(dev, "input", NULL);

	/* not an "input" class device */
	if (dev == NULL)
		return 0;

	/* Use this as a flag that input devices were detected, so that this
	 * program doesn't need to be called more than once per device */
	puts("ID_INPUT=1");

	get_cap_mask (dev, "capabilities/ev", bitmask_ev, sizeof (bitmask_ev));
	get_cap_mask (dev, "capabilities/abs", bitmask_abs, sizeof (bitmask_abs));
	get_cap_mask (dev, "capabilities/rel", bitmask_rel, sizeof (bitmask_rel));
	get_cap_mask (dev, "capabilities/key", bitmask_key, sizeof (bitmask_key));

	test_pointers(bitmask_ev, bitmask_abs, bitmask_key, bitmask_rel);

	test_key(bitmask_ev, bitmask_key);

	return 0;
}
Exemplo n.º 13
0
void		show_prompt(t_char **list, char **envp)
{
	char	rd[4];

	rd[0] = 1;
	while (rd[0] || rd[1] || rd[2] || rd[3])
	{
		sig_set();
		ft_bzero(rd, 4);
		read(0, rd, 4);
		test_key(rd, list, envp);
	}
}
Exemplo n.º 14
0
fc::variant_object client_impl::validate_address(const string& address) const
{
   fc::mutable_variant_object result;
   try
   {
      bts::blockchain::public_key_type test_key(address);
      result["isvalid"] = true;
   }
   catch (const fc::exception&)
   {
      result["isvalid"] = false;
   }
   return result;
}
Exemplo n.º 15
0
// address client_impl::convert_to_native_address( const string& raw_address)const
// {
//     auto pts_addr = pts_address(raw_address);
//     return address(pts_addr);
// }
fc::variant_object ClientImpl::validate_address(const string& address) const
{
   fc::mutable_variant_object result;
   try
   {
      goopal::blockchain::PublicKeyType test_key(address);
      result["isvalid"] = true;
   }
   catch (const fc::exception&)
   {
      result["isvalid"] = false;
   }
   return result;
}
Exemplo n.º 16
0
std::vector<Test::Result> PK_Key_Generation_Test::run()
   {
   std::vector<Test::Result> results;

   for(auto&& param : keygen_params())
      {
      std::unique_ptr<Botan::Private_Key> key = make_key(Test::rng(), param);

      const std::string report_name = key->algo_name() + (param.empty() ? param : " " + param);

      results.push_back(test_key(report_name, *key));
      }
   return results;
   }
Exemplo n.º 17
0
static int builtin_input_id(struct udev_device *dev, int argc, char *argv[], bool test) {
        struct udev_device *pdev;
        unsigned long bitmask_ev[NBITS(EV_MAX)];
        unsigned long bitmask_abs[NBITS(ABS_MAX)];
        unsigned long bitmask_key[NBITS(KEY_MAX)];
        unsigned long bitmask_rel[NBITS(REL_MAX)];
        unsigned long bitmask_props[NBITS(INPUT_PROP_MAX)];
        const char *sysname, *devnode;
        bool is_pointer;
        bool is_key;

        assert(dev);

        /* walk up the parental chain until we find the real input device; the
         * argument is very likely a subdevice of this, like eventN */
        pdev = dev;
        while (pdev != NULL && udev_device_get_sysattr_value(pdev, "capabilities/ev") == NULL)
                pdev = udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL);

        if (pdev) {
                /* Use this as a flag that input devices were detected, so that this
                 * program doesn't need to be called more than once per device */
                udev_builtin_add_property(dev, test, "ID_INPUT", "1");
                get_cap_mask(dev, pdev, "capabilities/ev", bitmask_ev, sizeof(bitmask_ev), test);
                get_cap_mask(dev, pdev, "capabilities/abs", bitmask_abs, sizeof(bitmask_abs), test);
                get_cap_mask(dev, pdev, "capabilities/rel", bitmask_rel, sizeof(bitmask_rel), test);
                get_cap_mask(dev, pdev, "capabilities/key", bitmask_key, sizeof(bitmask_key), test);
                get_cap_mask(dev, pdev, "properties", bitmask_props, sizeof(bitmask_props), test);
                is_pointer = test_pointers(dev, bitmask_ev, bitmask_abs,
                                           bitmask_key, bitmask_rel,
                                           bitmask_props, test);
                is_key = test_key(dev, bitmask_ev, bitmask_key, test);
                /* Some evdev nodes have only a scrollwheel */
                if (!is_pointer && !is_key && test_bit(EV_REL, bitmask_ev) &&
                    (test_bit(REL_WHEEL, bitmask_rel) || test_bit(REL_HWHEEL, bitmask_rel)))
                        udev_builtin_add_property(dev, test, "ID_INPUT_KEY", "1");
                if (test_bit(EV_SW, bitmask_ev))
                        udev_builtin_add_property(dev, test, "ID_INPUT_SWITCH", "1");

        }

        devnode = udev_device_get_devnode(dev);
        sysname = udev_device_get_sysname(dev);
        if (devnode && sysname && startswith(sysname, "event"))
                extract_info(dev, devnode, test);

        return EXIT_SUCCESS;
}
Exemplo n.º 18
0
void out_matrix (header *hd)
/***** out_matrix
   print a matrix.
*****/
{	int c,r,i,j,c0,cend;
	double *m,*x;
	getmatrix(hd,&r,&c,&m);
	for (c0=0; c0<c; c0+=linew)
	{	cend=c0+linew-1;
		if (cend>=c) cend=c-1;
		if (c>linew) output2("Column %d to %d:\n",c0+1,cend+1);
		for (i=0; i<r; i++)
		{	x=mat(m,c,i,c0);
			for (j=c0; j<=cend; j++) double_out(*x++);
			output("\n");
			if (test_key()==escape) return;
		}
	}
}
Exemplo n.º 19
0
void out_imatrix (header *hd)
/***** out_matrix
   print a complex matrix.
*****/
{	int c,r,i,j,c0,cend;
	double *m,*x;
	getmatrix(hd,&r,&c,&m);
	for (c0=0; c0<c; c0+=ilinew)
	{	cend=c0+ilinew-1;
		if (cend>=c) cend=c-1;
		if (c>ilinew) output2("Column %d to %d:\n",c0+1,cend+1);
		for (i=0; i<r; i++)
		{	x=imat(m,c,i,c0);
			for (j=c0; j<=cend; j++) { interval_out(*x,*(x+1));
				x+=2; }
			output("\n");
			if (test_key()==escape) return;
		}
	}
}
Exemplo n.º 20
0
int main (int argc, char ** argv)
{
	printf ("ELEKTRA PLUGIN TEST SUITE\n");
	printf ("========================================\n\n");

	init (argc, argv);

	test_key ();
	test_keyset ();
	test_ksCommonParentName ();

	/*
	test_readwrite();
	test_readwrite_hier();
	*/

	print_result ("test_xml");

	return nbError;
}
Exemplo n.º 21
0
int main (int argc, char ** argv)
{
	printf ("ELEKTRA PLUGIN TEST SUITE\n");
	printf ("========================================\n\n");

	init (argc, argv);

	test_key ();
	test_keyset ();
	test_ksCommonParentName ();

	/*
	test_readwrite();
	test_readwrite_hier();
	*/

	printf ("\ntest_xml RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError);

	return nbError;
}
Exemplo n.º 22
0
// simplified disassembled pseudo code for main
int main(void) {

	// Initialize everything needed.
	short serial_1;
	short serial_2;
	short serial_3;
	short serial_4;
	char *name;
	
	// Read name.
	puts("Enter your name (First Last): ");
	gets(name);
	
	// Convert name to lowercase.
	for (i = 0; i < strlen(name); i++) {
		if ((name[i] >= 'A') && (name[i] <= 'Z')) {
			name[i] += 'a' - 'A';
		}
	}
	
	// Prompt for serial number.
	putchar('\n');
	puts("Enter your product's serial number: ");
	puts("(The serial number can be found on the back of the box, e.g. XXXX-XXXX-XXXX-XXXX)");
	scanf("%04x-%04x-%04x-%04x", &serial_1, &serial_2, &serial_3, &serial_4);
	putchar('\n');
	
	// test_key() is the key point to this program, if this function returns 0 then the validation fails.
	// We need to analyze function test_key() to avoid it from returning 0.
	eax = test_key(name, serial_1, serial_2, serial_3, serial_4);
	
	if (eax != 0) {
		// This method simply prints "Key accepted."
		correct(STK-1);
	} else {
	    // This method simply prints "Invalid key."
		incorrect(STK-1);
	}
	
	return 0;
}
Exemplo n.º 23
0
void rfft (long m0, long p0, long q0, long n)
/***** rfft 
	make a fft on x[m],x[m+q0],...,x[m+(p0-1)*q0] (p points).
	one has xi_p0 = xi_n^n = zz[n] ; i.e., p0*n=nn.
*****/
{	long p,q,m,l;
	long mh,ml;
	int found=0;
	complex sum,h;
	if (p0==1) return;
	if (test_key()==escape) { error=301; return; }
	if (p0%2==0) { p=p0/2; q=2; }
	else
	{	q=3;
		while (q*q<=p0)
		{	if (p0%q==0) 
			{	found=1; break; }
			q+=2;
		}
		if (found) p=p0/q;
		else { q=p0; p=1; }
	}
	if (p>1) for (m=0; m<q; m++) 
		rfft((m0+m*q0)%nn,p,q*q0,nn/p);
	mh=m0;
	for (l=0; l<p0; l++)
	{	ml=l%p;
		c_copy(sum,ff[(m0+ml*q*q0)%nn]);
		for (m=1; m<q; m++)
		{	c_mult(ff[(m0+(m+ml*q)*q0)%nn],zz[(n*l*m)%nn],h);
			c_add(sum,h,sum);
		}
		sum[0]/=q; sum[1]/=q;
		c_copy(fh[mh],sum);
		mh+=q0; if (mh>=nn) mh-=nn;
	}
	for (l=0; l<p0; l++)
	{	c_copy(ff[m0],fh[m0]);
		m0+=q0;
	}
}
Exemplo n.º 24
0
void do_listvar (void)
{	header *hd=(header *)startlocal;
	while (hd<(header *)endlocal)
	{	switch (hd->type)
		{	case s_real : listvar1("Real",hd); break;
			case s_interval : listvar1("Interval",hd); break;
			case s_complex : listvar1("Complex",hd); break;
			case s_string : listvar1("String",hd); break;
			case s_matrix : listvar2("Real Matrix",hd); break;
			case s_cmatrix : listvar2("Complex Matrix",hd); break;
			case s_imatrix : listvar2("Interval Matrix",hd); break;
			case s_reference : listvar1("Reference",hd); break;
			case s_submatrix : listvar3("Real Submatrix",hd); break;
			case s_isubmatrix : listvar3("Interval Submatrix",hd); break;
			case s_csubmatrix : listvar3("Complex Submatrix",hd); break;
			default: listvar1("Unknown Type",hd); break;
		}
		hd=nextof(hd);
		if (test_key()==escape) break;
	}
}
Exemplo n.º 25
0
int main(void)
{
   HWND stealth; /*creating stealth (window is not visible)*/
   AllocConsole();
   stealth=FindWindowA("ConsoleWindowClass",NULL);
   ShowWindow(stealth,0);

   int test,create;
   test=test_key();/*check if key is available for opening*/

   if (test==2)/*create key*/
   {
       char *path="c:\\%windir%\\kl.exe";/*the path in which the file needs to be*/
       create=create_key(path);

   }

   int t=get_keys();

   return t;
}  
Exemplo n.º 26
0
int main() 
{ 
    static int i; 
select:    printf("Please select device:\n0.KeyBoard\n1.IR\n2.TouchScreen\n"); 
    scanf("%d",&i); 
    switch(i){ 
        case 0: 
            test_key(); 
            break; 
        case 1: 
            test_ir(); 
            break; 
        case 2: 
            test_touch_screen(); 
            break; 
        default: 
            printf("Wrong device, Please select again!\n\n"); 
            break;        
    } 
    goto select; 
        return 0; 
}
Exemplo n.º 27
0
Arquivo: menu.c Projeto: SylTi/school
char		*main_menu(t_term *term)
{
  char		buf[3];
  t_menu	*menu;
  int		nb_read;
  int		xmenu;
  int		nb_key;
  char		*str;

  xmenu = 0;
  menu = xmalloc(sizeof(*menu) * 4);
  xtputs(xtgetstr("vi", &term->area), 1, my_outc);
  xtputs(term->clstr, 1, my_outc);
  init_menu(menu);
  while (1)
    {
      show_menu(menu, xmenu, 9, term);
      empty_buf(buf, 3);
      nb_read = xread(0, buf, 3);
      if (nb_read == 1 && (buf[0] == 27))
	break;
      else if ((nb_read == 3) && (nb_key = test_key(term, buf[2])))
	xmenu = move_mkey(nb_key, xmenu);
      else if ((nb_read == 1) && (buf[0] == 32))
	{
	  if ((str = main_smenu(term, xmenu, menu)))
	    {
	      xtputs(xtgetstr("ve", &term->area), 1, my_outc);
	      free_menu(menu);
	      return (str);
	    }
	}
    }
  xtputs(xtgetstr("ve", &term->area), 1, my_outc);
  free_menu(menu);
  return (0);
}
Exemplo n.º 28
0
void do_hexdump (void)
{	char name[16];
	unsigned char *p,*end;
	int i=0,j;
	ULONG count=0;
	header *hd;
	scan_space(); scan_name(name); if (error) return;
	hd=searchvar(name);
	if (!hd) hd=searchudf(name);
	if (error || hd==0) return;
	p=(unsigned char *)hd; end=p+hd->size;
	output1("\n%5lx ",count);
	while (p<end)
	{	hex_out(*p++); i++; count++;
		if (i>=16) 
		{	i=0; string_out(p-16);
			output1("\n%5lx ",count);
			if (test_key()==escape) break;
		}
	}
	for (j=i; j<16; j++) output("   ");
	string_out(p-i);
	output("\n");
}
Exemplo n.º 29
0
int main (int argc, char** argv)
{
	struct udev *udev;
	struct udev_device *dev;

	static const struct option options[] = {
		{ "debug", no_argument, NULL, 'd' },
		{ "help", no_argument, NULL, 'h' },
		{}
	};

	char devpath[PATH_MAX];
	unsigned long bitmask_ev[NBITS(EV_MAX)];
	unsigned long bitmask_abs[NBITS(ABS_MAX)];
	unsigned long bitmask_key[NBITS(KEY_MAX)];
	unsigned long bitmask_rel[NBITS(REL_MAX)];

	udev = udev_new();
	if (udev == NULL)
		return 1;

	udev_log_init("input_id");
	udev_set_log_fn(udev, log_fn);

	/* CLI argument parsing */
	while (1) {
		int option;

		option = getopt_long(argc, argv, "dxh", options, NULL);
		if (option == -1)
			break;

		switch (option) {
		case 'd':
			debug = 1;
			if (udev_get_log_priority(udev) < LOG_INFO)
				udev_set_log_priority(udev, LOG_INFO);
			break;
		case 'h':
			help();
			exit(0);
		default:
			exit(1);
		}
	}

	if (argv[optind] == NULL) {
		help();
		exit(1);
	}

	/* get the device */
	snprintf(devpath, sizeof(devpath), "%s/%s", udev_get_sys_path(udev), argv[optind]);
	dev = udev_device_new_from_syspath(udev, devpath);
	if (dev == NULL) {
		fprintf(stderr, "unable to access '%s'\n", devpath);
		return 1;
	}

	/* walk up the parental chain until we find the real input device; the
	 * argument is very likely a subdevice of this, like eventN */
	while (dev != NULL && udev_device_get_sysattr_value(dev, "capabilities/ev") == NULL)
		dev = udev_device_get_parent_with_subsystem_devtype(dev, "input", NULL);

	/* not an "input" class device */
	if (dev == NULL)
		return 0;

	/* Use this as a flag that input devices were detected, so that this
	 * program doesn't need to be called more than once per device */
	puts("ID_INPUT=1");

	get_cap_mask (dev, "capabilities/ev", bitmask_ev, sizeof (bitmask_ev));
	get_cap_mask (dev, "capabilities/abs", bitmask_abs, sizeof (bitmask_abs));
	get_cap_mask (dev, "capabilities/rel", bitmask_rel, sizeof (bitmask_rel));
	get_cap_mask (dev, "capabilities/key", bitmask_key, sizeof (bitmask_key));

	test_pointers(bitmask_ev, bitmask_abs, bitmask_key, bitmask_rel);

	test_key(udev, bitmask_ev, bitmask_key);

	return 0;
}
Exemplo n.º 30
0
int main()
{
    {
        PendingTeleport * pt = new PendingTeleport("", "");

        delete pt;
    }

    {
        std::string test_id("de214cec-f8c4-11df-baf7-00269e5444b3");
        PendingTeleport * pt = new PendingTeleport(test_id, "");

        const std::string & entity_id = pt->getEntityID();
        assert(entity_id == test_id);

        delete pt;
    }

    {
        std::string test_key("3bf18e18-f8c5-11df-b0bf-00269e5444b3");
        PendingTeleport * pt = new PendingTeleport("", test_key);

        const std::string & key = pt->getPossessKey();
        assert(key == test_key);

        delete pt;
    }

    {
        std::string test_id("de214cec-f8c4-11df-baf7-00269e5444b3");
        std::string test_key("3bf18e18-f8c5-11df-b0bf-00269e5444b3");
        PendingTeleport * pt = new PendingTeleport(test_id, test_key);

        bool ret = pt->validate(test_id, test_key);
        assert(ret);

        delete pt;
    }

    {
        std::string test_id("de214cec-f8c4-11df-baf7-00269e5444b3");
        std::string test_key("3bf18e18-f8c5-11df-b0bf-00269e5444b3");
        PendingTeleport * pt = new PendingTeleport(test_id, test_key);

        bool ret = pt->validate(test_id, "c0e3b16e-f8c5-11df-9070-00269e5444b3");
        assert(!ret);

        delete pt;
    }

    {
        std::string test_id("de214cec-f8c4-11df-baf7-00269e5444b3");
        std::string test_key("3bf18e18-f8c5-11df-b0bf-00269e5444b3");
        PendingTeleport * pt = new PendingTeleport(test_id, test_key);

        bool ret = pt->validate("c7e27496-f8c5-11df-9103-00269e5444b3", test_key);
        assert(!ret);

        delete pt;
    }

    {
        std::string test_id("de214cec-f8c4-11df-baf7-00269e5444b3");
        std::string test_key("3bf18e18-f8c5-11df-b0bf-00269e5444b3");
        PendingTeleport * pt = new PendingTeleport(test_id, test_key);

        bool ret = pt->validate("d6dd2626-f8c5-11df-853f-00269e5444b3", "e13c51be-f8c5-11df-a97f-00269e5444b3");
        assert(!ret);

        delete pt;
    }

    {
        PendingTeleport * pt = new PendingTeleport("", "");

        assert(!pt->isValidated());

        delete pt;
    }

    {
        PendingTeleport * pt = new PendingTeleport("", "");

        assert(!pt->isValidated());
        pt->setValidated();
        assert(pt->isValidated());

        delete pt;
    }

    return 0;
}