Esempio n. 1
0
int main(int argc, char* argv[])
{
  if (argc < 3 || argc > 9)
  {
    std::cout << "Usage: props [-V] [-E] [-asp] [-cc] [-S] example.graphml" << std::endl;
    exit(1);
  }

  typedef conan::undirected_graph<conan::adj_listS> Graph;
  Graph g = conan::read_graphml<Graph>(argv[argc - 1]);

  std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << std::endl;
  std::cout << "<graph name=\"" << argv[argc - 1] << "\">" << std::endl;
  for (int i = 1; i < argc - 1; ++i)
  {
    if ( !strcmp(argv[i], "-V") )
      print_property("number of vertices", boost::num_vertices(g));
    else if ( !strcmp(argv[i], "-E") )
      print_property("number of edges", boost::num_edges(g));
    else if ( !strcmp(argv[i], "-asp") )
      print_property("average shortest path", conan::graph_avg_shortest_path(g));
    else if ( !strcmp(argv[i], "-cc") )
      print_property("clustering coefficient", conan::graph_avg_clustering(g));
    else if ( !strcmp(argv[i], "-S") )
      print_property("topological entropy", conan::graph_entropy(g));
  }
  std::cout << "</graph>" << std::endl;
  return(0);
}
/* ------------------------------------------------------------------------ */
int main(void){
  property_list_t p = property_list_const();
  int a = 9;
  int b = 8;
  add_property(&p, 0, int_t, 2, &a);
  add_property(&p, 1, int_t, 1, &b);
  print_property(&p, 0);
  print_property(&p, 1);
  
  return 0;
};
Esempio n. 3
0
void print_cls_directives(Output& out, const PreClass* cls) {
  print_cls_enum_ty(out, cls);
  print_cls_used_traits(out, cls);
  for (auto& c : cls->allConstants())  print_constant(out, &c);
  for (auto& p : cls->allProperties()) print_property(out, &p);
  for (auto* m : cls->allMethods())    print_method(out, m);
}
Esempio n. 4
0
void print_properties(DrmPropObject& o, int ind)
{
	auto pmap = o.get_prop_map();
	printf("%sProperties, %u in total:\n", width(ind, "").c_str(),
	       (unsigned) pmap.size());
	for (auto pp : pmap) {
		const Property& p = *o.card().get_prop(pp.first);
		print_property(pp.second, p, ind + 2);
	}
}
static int cmd_bat_read(int argc, char **argv)
{
    int rc = 0;
    int maxp;
    int i;
    struct battery_property *prop;

    if (argc < 2) {
        console_printf("Invalid number of arguments, use read <prop>\n");
        goto err;
    }

    if (argc == 2 && strcmp("all", argv[1]) == 0) {
        maxp = battery_get_property_count(bat, NULL);
        for (i = 0; i < maxp; ++i) {
            prop = battery_enum_property(bat, NULL, i);
            battery_prop_get_value(prop);
            if (!prop->bp_valid) {
                console_printf("Error reading property\n");
                goto err;
            }
            print_property(prop);
        }
    } else {
        for (i = 1; i < argc; ++i) {
            prop = battery_find_property_by_name(bat, argv[i]);
            if (prop == NULL) {
                console_printf("Invalid property name %s\n", argv[i]);
                goto err;
            }
            battery_prop_get_value(prop);
            if (!prop->bp_valid) {
                console_printf("Error reading property\n");
                goto err;
            }
            print_property(prop);
        }
    }
err:
    return rc;
}
Esempio n. 6
0
static int
list_props_xi1(Display *dpy, int argc, char** argv, char* name, char *desc)
{
    XDeviceInfo *info;
    XDevice     *dev;
    int          i;
    int         nprops;
    Atom        *props;

    if (argc == 0)
    {
        fprintf(stderr, "Usage: xinput %s %s\n", name, desc);
        return EXIT_FAILURE;
    }

    for (i = 0; i < argc; i++)
    {
        info = find_device_info(dpy, argv[i], False);
        if (!info)
        {
            fprintf(stderr, "unable to find device %s\n", argv[i]);
            continue;
        }

        dev = XOpenDevice(dpy, info->id);
        if (!dev)
        {
            fprintf(stderr, "unable to open device '%s'\n", info->name);
            continue;
        }

        props = XListDeviceProperties(dpy, dev, &nprops);
        if (!nprops)
        {
            printf("Device '%s' does not report any properties.\n", info->name);
            continue;
        }

        printf("Device '%s':\n", info->name);
        while(nprops--)
        {
            print_property(dpy, dev, props[nprops]);
        }

        XFree(props);
        XCloseDevice(dpy, dev);
    }
    return EXIT_SUCCESS;
}
Esempio n. 7
0
int watch_props(Display *dpy, int argc, char** argv, char* n, char *desc)
{
    XDevice     *dev;
    XDeviceInfo *info;
    XEvent      ev;
    XDevicePropertyNotifyEvent *dpev;
    char        *name;
    int         type_prop;
    XEventClass cls_prop;

    if (list_props(dpy, argc, argv, n, desc) != EXIT_SUCCESS)
        return EXIT_FAILURE;

    info = find_device_info(dpy, argv[0], False);
    if (!info)
    {
        fprintf(stderr, "unable to find device %s\n", argv[0]);
        return EXIT_FAILURE;
    }

    dev = XOpenDevice(dpy, info->id);
    if (!dev)
    {
        fprintf(stderr, "unable to open device '%s'\n", info->name);
        return EXIT_FAILURE;
    }

    DevicePropertyNotify(dev, type_prop, cls_prop);
    XSelectExtensionEvent(dpy, DefaultRootWindow(dpy), &cls_prop, 1);

    while(1)
    {
        XNextEvent(dpy, &ev);

        dpev = (XDevicePropertyNotifyEvent*)&ev;
        if (dpev->type != type_prop)
            continue;

        name = XGetAtomName(dpy, dpev->atom);
        printf("Property '%s' changed.\n", name);
        print_property(dpy, dev, dpev->atom);
    }

    XCloseDevice(dpy, dev);
}
Esempio n. 8
0
void
print_rule(fz_css_rule *rule)
{
	fz_css_selector *sel;
	fz_css_property *prop;

	for (sel = rule->selector; sel; sel = sel->next)
	{
		print_selector(sel);
		printf(" /* %d */", selector_specificity(sel, 0));
		if (sel->next)
			printf(", ");
	}

	printf("\n{\n");
	for (prop = rule->declaration; prop; prop = prop->next)
	{
		print_property(prop);
	}
	printf("}\n");
}
Esempio n. 9
0
static void cmd_show_item(int argc, char *argv[])
{
	GDBusProxy *proxy;

	proxy = g_dbus_proxy_lookup(items, NULL, argv[1],
						BLUEZ_MEDIA_ITEM_INTERFACE);
	if (!proxy) {
		bt_shell_printf("Item %s not available\n", argv[1]);
		return bt_shell_noninteractive_quit(EXIT_SUCCESS);
	}

	bt_shell_printf("Item %s\n", g_dbus_proxy_get_path(proxy));

	print_property(proxy, "Player");
	print_property(proxy, "Name");
	print_property(proxy, "Type");
	print_property(proxy, "FolderType");
	print_property(proxy, "Playable");
	print_property(proxy, "Metadata");

	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool test)
{
    const char *root_partition;
    int64_t offset = 0;
    bool noraid = false;
    _cleanup_close_ int fd = -1;
    blkid_probe pr;
    const char *data;
    const char *name;
    int nvals;
    int i;
    int err = 0;
    bool is_gpt = false;

    static const struct option options[] = {
        { "offset", optional_argument, NULL, 'o' },
        { "noraid", no_argument, NULL, 'R' },
        {}
    };

    for (;;) {
        int option;

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

        switch (option) {
        case 'o':
            offset = strtoull(optarg, NULL, 0);
            break;
        case 'R':
            noraid = true;
            break;
        }
    }

    pr = blkid_new_probe();
    if (!pr)
        return EXIT_FAILURE;

    blkid_probe_set_superblocks_flags(pr,
                                      BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
                                      BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
                                      BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION);

    if (noraid)
        blkid_probe_filter_superblocks_usage(pr, BLKID_FLTR_NOTIN, BLKID_USAGE_RAID);

    fd = open(udev_device_get_devnode(dev), O_RDONLY|O_CLOEXEC);
    if (fd < 0) {
        fprintf(stderr, "error: %s: %m\n", udev_device_get_devnode(dev));
        goto out;
    }

    err = blkid_probe_set_device(pr, fd, offset, 0);
    if (err < 0)
        goto out;

    log_debug("probe %s %sraid offset=%llu",
              udev_device_get_devnode(dev),
              noraid ? "no" : "", (unsigned long long) offset);

    err = probe_superblocks(pr);
    if (err < 0)
        goto out;

    /* If we are a partition then our parent passed on the root
     * partition UUID to us */
    root_partition = udev_device_get_property_value(dev, "ID_PART_GPT_AUTO_ROOT_UUID");

    nvals = blkid_probe_numof_values(pr);
    for (i = 0; i < nvals; i++) {
        if (blkid_probe_get_value(pr, i, &name, &data, NULL))
            continue;

        print_property(dev, test, name, data);

        /* Is this a disk with GPT partition table? */
        if (streq(name, "PTTYPE") && streq(data, "gpt"))
            is_gpt = true;

        /* Is this a partition that matches the root partition
         * property we inherited from our parent? */
        if (root_partition && streq(name, "PART_ENTRY_UUID") && streq(data, root_partition))
            udev_builtin_add_property(dev, test, "ID_PART_GPT_AUTO_ROOT", "1");
    }

    if (is_gpt)
        find_gpt_root(dev, pr, test);

    blkid_free_probe(pr);
out:
    if (err < 0)
        return EXIT_FAILURE;

    return EXIT_SUCCESS;
}
Esempio n. 11
0
static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool test)
{
        int64_t offset = 0;
        bool noraid = false;
        int fd = -1;
        blkid_probe pr;
        const char *data;
        const char *name;
        int nvals;
        int i;
        size_t len;
        int err = 0;

        static const struct option options[] = {
                { "offset", optional_argument, NULL, 'o' },
                { "noraid", no_argument, NULL, 'R' },
                {}
        };

        for (;;) {
                int option;

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

                switch (option) {
                case 'o':
                        offset = strtoull(optarg, NULL, 0);
                        break;
                case 'R':
                        noraid = true;
                        break;
                }
        }

        pr = blkid_new_probe();
        if (!pr)
                return EXIT_FAILURE;

        blkid_probe_set_superblocks_flags(pr,
                BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
                BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
                BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION);

        if (noraid)
                blkid_probe_filter_superblocks_usage(pr, BLKID_FLTR_NOTIN, BLKID_USAGE_RAID);

        fd = open(udev_device_get_devnode(dev), O_RDONLY|O_CLOEXEC);
        if (fd < 0) {
                fprintf(stderr, "error: %s: %m\n", udev_device_get_devnode(dev));
                goto out;
        }

        err = blkid_probe_set_device(pr, fd, offset, 0);
        if (err < 0)
                goto out;

        log_debug("probe %s %sraid offset=%llu\n",
                  udev_device_get_devnode(dev),
                  noraid ? "no" : "", (unsigned long long) offset);

        err = probe_superblocks(pr);
        if (err < 0)
                goto out;

        nvals = blkid_probe_numof_values(pr);
        for (i = 0; i < nvals; i++) {
                if (blkid_probe_get_value(pr, i, &name, &data, &len))
                        continue;
                len = strnlen((char *) data, len);
                print_property(dev, test, name, (char *) data);
        }

        blkid_free_probe(pr);
out:
        if (fd > 0)
                close(fd);
        if (err < 0)
                return EXIT_FAILURE;
        return EXIT_SUCCESS;
}
Esempio n. 12
0
static void cmd_show(int argc, char *argv[])
{
	GDBusProxy *proxy;
	GDBusProxy *folder;
	GDBusProxy *item;
	DBusMessageIter iter;
	const char *path;

	if (argc < 2) {
		if (check_default_player() == FALSE)
			return bt_shell_noninteractive_quit(EXIT_FAILURE);

		proxy = default_player;
	} else {
		proxy = g_dbus_proxy_lookup(players, NULL, argv[1],
						BLUEZ_MEDIA_PLAYER_INTERFACE);
		if (!proxy) {
			bt_shell_printf("Player %s not available\n", argv[1]);
			return bt_shell_noninteractive_quit(EXIT_FAILURE);
		}
	}

	bt_shell_printf("Player %s\n", g_dbus_proxy_get_path(proxy));

	print_property(proxy, "Name");
	print_property(proxy, "Repeat");
	print_property(proxy, "Equalizer");
	print_property(proxy, "Shuffle");
	print_property(proxy, "Scan");
	print_property(proxy, "Status");
	print_property(proxy, "Position");
	print_property(proxy, "Track");

	folder = g_dbus_proxy_lookup(folders, NULL,
					g_dbus_proxy_get_path(proxy),
					BLUEZ_MEDIA_FOLDER_INTERFACE);
	if (folder == NULL)
		return bt_shell_noninteractive_quit(EXIT_SUCCESS);

	bt_shell_printf("Folder %s\n", g_dbus_proxy_get_path(proxy));

	print_property(folder, "Name");
	print_property(folder, "NumberOfItems");

	if (!g_dbus_proxy_get_property(proxy, "Playlist", &iter))
		return bt_shell_noninteractive_quit(EXIT_SUCCESS);

	dbus_message_iter_get_basic(&iter, &path);

	item = g_dbus_proxy_lookup(items, NULL, path,
					BLUEZ_MEDIA_ITEM_INTERFACE);
	if (item == NULL)
		return bt_shell_noninteractive_quit(EXIT_SUCCESS);

	bt_shell_printf("Playlist %s\n", path);

	print_property(item, "Name");

	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
Esempio n. 13
0
int main(int argc, char **argv)
{
    Display *display;
    XFontStruct *fs;
    int i;
    unsigned long prop;

    if (!(display=XOpenDisplay(""))) {
	fprintf(stderr, "Unable to connect to server\n");
	exit(EXIT_FAILURE);
    }
    fs = XLoadQueryFont(display, argv[1]);
    if (!fs) {
	fprintf(stderr, "Unable to load font %s\n", argv[1]);
	exit(EXIT_FAILURE);
    }
    printf("FontID\t\t%lu\n"
	  "Direction\t%i\n"
	  "MinChar\t\t%i\n"
	  "MaxChar\t\t%i\n"
	  "MinByte\t\t%i\n"
	  "MaxByte\t\t%i\n"
	  "All Exist\t%s\n"
	  "Default Char\t%i\n"
	  "Ascent\t\t%i\n"
	  "Descent\t\t%i\n"
	  "Extra Data\t%s\n"
	  "Properties\t%i\n",
	  fs->fid, fs->direction, fs->min_char_or_byte2, fs->max_char_or_byte2,
	  fs->min_byte1, fs->max_byte1, (fs->all_chars_exist?"Yes":"No"),
	  fs->default_char, fs->ascent, fs->descent, (fs->ext_data?"Yes":"No"),
	  fs->n_properties);
    for (i=0; i<fs->n_properties; i++)
	print_property(display, fs->properties+i);
    if (XGetFontProperty(fs, XA_POINT_SIZE, &prop))
	printf("PointSize\t%li\n", prop);
    if (XGetFontProperty(fs, XA_COPYRIGHT, &prop))
	printf("Copyright\t%li\n", prop);
    printf("%8s%8s%8s%8s%8s%8s   %8s\n", "Pos","Left", "Right", "Width",
	   "Ascent", "Descent", "Attrib");
    print_charstruct(&fs->min_bounds, -1);
    print_charstruct(&fs->max_bounds, -2);
    if (!fs->per_char) printf("All glyphs have equal size\n");
    else {
	if (!fs->min_byte1 && !fs->max_byte1) {
	    /* single byte fonts */
	    int i,j,n;
	    j=fs->min_char_or_byte2;
	    n=fs->max_char_or_byte2-j+1;
	    for (i=0; i<n; i++)
		print_charstruct(fs->per_char+i, j+i);
	} else {
	    /* double byte fonts */
	    int i,j,n;
	    j=(fs->max_char_or_byte2-fs->min_char_or_byte2+1);
	    n=j*(fs->max_byte1-fs->min_byte1+1);
	    printf("Total %i, Row: %i\n", n,j);
	    for (i=0; i<n; i++) {
		print_charstruct(fs->per_char+i,
				 ((i/j+fs->min_byte1)<<8)+i%j+
				 fs->min_char_or_byte2);
	    }
	}
    }
    XCloseDisplay(display);
    return 0;
}
static int bat_property(struct battery_prop_listener *listener,
        const struct battery_property *prop)
{
    print_property(prop);
    return 0;
}