Ejemplo n.º 1
0
static void
e_contact_editor_fullname_get_property (GObject *object,
                                        guint property_id,
                                        GValue *value,
                                        GParamSpec *pspec)
{
	EContactEditorFullname *e_contact_editor_fullname;

	e_contact_editor_fullname = E_CONTACT_EDITOR_FULLNAME (object);

	switch (property_id) {
	case PROP_NAME:
		extract_info (e_contact_editor_fullname);
		g_value_set_pointer (
			value, e_contact_name_copy (
			e_contact_editor_fullname->name));
		break;
	case PROP_EDITABLE:
		g_value_set_boolean (
			value, e_contact_editor_fullname->editable);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}
Ejemplo n.º 2
0
void exec_cmd(FILE* w, bool first,  Disc* d, const string& basename) {
	
	for (auto i=cmds.begin();i!=cmds.end();i++)
	{
		switch((*i)[0]) 
		{
			case 'g':
				{

				int start_fad = atoi((++i)->c_str());
				int size = atoi((++i)->c_str());

				extract_data(w, first, d, start_fad, size);
				
			}
			break;

			case 'i':
				extract_info(w, first, d, basename);
				break;

			case 'h':
				printf("hashes not supported yet");
				break;

			case 'f':
				printf("fingerprint not supported yet");
				break;
		}
	}
}
Ejemplo n.º 3
0
static void
e_contact_editor_im_get_property (GObject *object, guint prop_id,
					GValue *value, GParamSpec *pspec)
{
	EContactEditorIm *e_contact_editor_im;

	e_contact_editor_im = E_CONTACT_EDITOR_IM (object);

	switch (prop_id) {
	case PROP_SERVICE:
		g_value_set_int (value, e_contact_editor_im->service);
		break;
	case PROP_LOCATION:
		g_value_set_string (value, e_contact_editor_im->location);
		break;
	case PROP_USERNAME:
		extract_info(e_contact_editor_im);
		g_value_set_string (value, e_contact_editor_im->username);
		break;
	case PROP_EDITABLE:
		g_value_set_boolean (value, e_contact_editor_im->editable ? TRUE : FALSE);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
/* Process the raw netlink message and dispatch to helper functions
 * accordingly */
static void
receive_netlink_message (GUPnPLinuxContextManager *self, GError **error)
{
        static char buf[4096];
        static const int bufsize = 4096;

        gssize len;
        GError *inner_error = NULL;
        struct nlmsghdr *header = (struct nlmsghdr *) buf;
        struct ifinfomsg *ifi;
        struct ifaddrmsg *ifa;


        len = g_socket_receive (self->priv->netlink_socket,
                                buf,
                                bufsize,
                                NULL,
                                &inner_error);
        if (len == -1) {
                if (inner_error->code != G_IO_ERROR_WOULD_BLOCK)
                        g_warning ("Error receiving netlink message: %s",
                                   inner_error->message);
                g_propagate_error (error, inner_error);

                return;
        }

        for (;NLMSG_IS_VALID (header, len); header = NLMSG_NEXT (header,len)) {
                switch (header->nlmsg_type) {
                        /* RTM_NEWADDR and RTM_DELADDR are sent on real address
                         * changes.
                         * RTM_NEWLINK is sent on varous occations:
                         *  - Creation of a new device
                         *  - Device goes up/down
                         *  - Wireless status changes
                         * RTM_DELLINK is sent only if device is removed, like
                         * openvpn --rmtun /dev/tun0, NOT on ifconfig down. */
                        case RTM_NEWADDR:
                            {
                                char *label = NULL;

                                ifa = NLMSG_DATA (header);
                                extract_info (header, &label);
                                create_context (self, label, ifa);
                                g_free (label);
                            }
                            break;
                        case RTM_DELADDR:
                            {
                                char *label = NULL;

                                ifa = NLMSG_DATA (header);
                                extract_info (header, &label);
                                remove_context (self, label, ifa);
                                g_free (label);
                            }
                            break;
                        case RTM_NEWLINK:
                                ifi = NLMSG_DATA (header);

                                /* Check if wireless is up for chit-chat */
                                if (is_wireless_status_message (header))
                                        continue;
                                handle_device_status_change (self, ifi);
                                break;
                        case RTM_DELLINK:
                                ifi = NLMSG_DATA (header);
                                remove_device (self, ifi);
                                break;
                        case NLMSG_ERROR:
                                break;
                        default:
                                break;
                }
        }
}
Ejemplo n.º 6
0
/*
 * get_ap_raw_info - to collect the key info of ap for connecting
 * @interface - wifi interface name, such as "ra0", "wlan0"
 * @ap_cnt  - total ap that were scanned
 *             NULL - just store the ap info
 * @ap_list   - the specific infomation of each ap
 *             NULL - just get the count of ap
 * Returns: 0 if collect raw info succeed, -1 if fail
 */
int get_ap_raw_info(IN struct wifi_info **ap_list, 
		OUT int *ap_cnt, IN char *interface)
{
	int cnt = 0;
	int all_ap = 0;
	int len = 0;
	char *buf;
	FILE *fp = NULL;

	if (ap_list == NULL)
		return -1;

	fp = fopen("/dev/wifi/list_ap","r");
	if(fp == NULL)
	{
		FPRINTF_CA(stderr, "cant find file /dev/wifi/list_ap\n");
		return -1;
	}

	fseek(fp,0,SEEK_END);
	len = ftell(fp);
	if(len == 0)
	{
		FPRINTF_CA(stderr, "file len is zero \n");
		fclose(fp);
		return -1;
	}

	buf = malloc(len);
	if(buf == NULL)
	{
		FPRINTF_CA(stderr, "malloc buff error  \n");
		fclose(fp);
		return -1;
	}

	fseek(fp,0,SEEK_SET);
	
	fread(buf,len,1,fp);
	fclose(fp);

	if (!strncmp(buf, "no such interface.", 18)) {
		PRINTF_CA("%s", buf);
		free(buf);
		return -NOSUCHINF;
	} else if (!strncmp(buf, "no ap found.", 12)) {
		PRINTF_CA("%s", buf);
		*ap_cnt = all_ap;
		free(buf);
		return -NOAPFOUND;
	}

	for (cnt = 0; cnt < strlen(buf); cnt++) {
		if ('\n' == buf[cnt])
			all_ap++;
	}

	if (ap_cnt != NULL) {
		if (all_ap > *ap_cnt)
			all_ap = *ap_cnt;

		*ap_cnt = all_ap;
	}
	
	int count;
	char **line_index;
	char *space_index[MAX_PART + 1] = {NULL};
	line_index = (char **)malloc(sizeof(char *) * (all_ap + 1));
	extract_info(buf, '\n', line_index);
	for (count = 0; count < all_ap; count++) {
		extract_ap_info(line_index[count], ' ' , space_index); 

		store_info(&(*ap_list)[count], space_index);
	}

	free(line_index);
	free(buf);

	return 0;
}
Ejemplo n.º 7
0
/* Check a hash */
int		cmd_kmem_chash()
{
  int	i, ret, mode, stype, type, nsize, size, off, origmode, val;
  char  buff[BUFSIZ], buff2[256];
  char	*param, *str;
  unsigned long addr;
  revmexpr_t *expr;
  revmobj_t *obj;

  unsigned char origbuffer[BUFSIZ];
  char	buffhash[BUFSIZ];
  unsigned char *hashbuffer;
  char *tmp;

  FILE *fd;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);
  
  val = 0;
  memset(buff, '\0', sizeof(buff));
  memset(buff2, '\0', sizeof(buff2));

  param = world.curjob->curcmd->param[0];

  stype = (int)config_get_data(LIBKERNSH_CONFIG_HASH);

  if (param != NULL)
    {
      expr = revm_lookup_param(param, 1);
      obj = expr->value;

      if (obj->otype->type == ASPECT_TYPE_STR)
	{
	  str = (obj->immed ? obj->immed_val.str : 
		 obj->get_name(obj->root, obj->parent));
	  
	  memcpy(buff2, str, sizeof(buff2));
	  param = buff2;
	}

      /* We must get hash in a file ? */
      if (!strstr(param, ":"))
	{
	  fd = fopen(param, "r");
	  if (fd == NULL)
	    {
	      PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
			   "Unable to open file",
			   -1);
	    }

	  while(fgets(buff, sizeof(buff), fd) != NULL)
	    {
	      buff[strlen(buff) - 1] = '\0';
	      
	      if (buff[0] == '#')
		continue;

	      if (extract_info(buff, 
			       &addr, 
			       &mode,
			       &type,
			       &size, 
			       &off, 
			       origbuffer, 
			       sizeof(origbuffer)))
		{
		  
		  PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
			       "Bad format", -1);
		}
	      /* Switch to the mode where the hash has been done */
	      origmode = elfsh_get_mode();
	      elfsh_set_mode(mode);

	      config_update_key(LIBKERNSH_CONFIG_HASH, (void *)type);
	      hashbuffer = kernsh_hash(addr+off, size, &nsize);	      
	      	      
	      elfsh_set_mode(origmode);

	      i = 0;
	      tmp = buffhash;
	      while((i < sizeof(buffhash)) && (hashbuffer[i] != '\0'))
		{
		  sprintf(tmp, "%02x", hashbuffer[i]);
		  i++;
		  tmp += 2;
		}

	      memset(buff, '\0', sizeof(buff));
	      
	      if (!strncmp((const char *)origbuffer, 
			   (const char *)buffhash, 
			   sizeof(origbuffer)))
		{
		  snprintf(buff, sizeof(buff),
			   "%s @ %s with size = %s and offset = %s\n",
			   revm_colorstr("HASH MATCH @ !"),
			   revm_coloraddress(XFMT, (eresi_Addr) addr),
			   revm_colornumber("%u", size),
			   revm_colornumber("%u", off));
		  revm_output(buff);
		  revm_endline();
		}
	      else
		{
		  snprintf(buff, sizeof(buff),
			   "%s @ %s with size = %s and offset = %s\n %s != %s\n",
			   revm_colorstr("HASH MISMATCH @ !"),
			   revm_coloraddress(XFMT, (eresi_Addr) addr),
			   revm_colornumber("%u", size),
			   revm_colornumber("%u", off),
			   revm_colorstr((char *)origbuffer),
			   revm_colorstr((char *)buffhash));
		  revm_output(buff);
		  revm_endline();
		  val++;
		}
	    }

	  fclose(fd);
	}
      else
	{
	  if (extract_info(param, 
			   &addr, 
			   &mode,
			   &type,
			   &size, 
			   &off, 
			   origbuffer, 
			   sizeof(origbuffer)))
	  {
	    
	    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
			 "Bad format", -1);
	  }

	  origmode = elfsh_get_mode();
	  elfsh_set_mode(mode);
	  config_update_key(LIBKERNSH_CONFIG_HASH, (void *)type);
	  hashbuffer = kernsh_hash(addr+off, size, &nsize);

	  elfsh_set_mode(origmode);
	  i = 0;
	  tmp = buffhash;
	  while((i < sizeof(buffhash)) && (hashbuffer[i] != '\0'))
	    {
	      sprintf(tmp, "%02x", hashbuffer[i]);
	      i++;
	      tmp += 2;
	    }

	  if (hashbuffer == NULL)
	    {
	      PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
			   "Unable to make hash", -1);
	    }

	  memset(buff, '\0', sizeof(buff));

	  if (!strncmp((const char *)origbuffer, 
		       (const char *)buffhash, 
		       sizeof(origbuffer)))
	    {
	      snprintf(buff, sizeof(buff),
		       "%s @ %s with size = %s and offset = %s\n\n",
		       revm_colorstr("HASH MATCH @ !"),
		       revm_coloraddress(XFMT, (eresi_Addr) addr),
		       revm_colornumber("%u", size),
		       revm_colornumber("%u", off));
	      revm_output(buff);
	    }
	  else
	    {
	      snprintf(buff, sizeof(buff),
		       "%s @ %s with size = %s and offset = %s\n %s != %s\n\n",
		       revm_colorstr("HASH MISMATCH @ !"),
		       revm_coloraddress(XFMT, (eresi_Addr) addr),
		       revm_colornumber("%u", size),
		       revm_colornumber("%u", off),
		       revm_colorstr((char *)origbuffer),
		       revm_colorstr((char *)buffhash));
	      revm_output(buff);
	      val++;
	    }
	}
    }

  config_update_key(LIBKERNSH_CONFIG_HASH, (void *)stype);

  revm_setvar_int(REVM_VAR_RESULT, val);  

  revm_endline();
  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret);
}