Beispiel #1
0
void color_manager::serialize(JsonOut &json) const
{
    json.start_array();
    for( auto &entry : color_array ) {
        if ( !entry.name_custom.empty() || !entry.name_invert_custom.empty()) {
            json.start_object();

            json.member( "name", id_to_name( entry.col_id ) );
            json.member( "custom", entry.name_custom );
            json.member( "invertcustom", entry.name_invert_custom );

            json.end_object();
        }
    }

    json.end_array();
}
Beispiel #2
0
static void
display_group(int id)
{
    int i, offset;
    int print_grp = 0;

    offset = ntohl(prh.idHash[IDHash(id)]);
    while (offset) {
	lseek(dbase_fd, offset + HDRSIZE, L_SET);
	if (read(dbase_fd, &pre, sizeof(struct prentry)) < 0) {
	    fprintf(stderr, "pt_util: read i/o error: %s\n", strerror(errno));
	    exit(1);
	}
	fix_pre(&pre);
	if (pre.id == id)
	    break;
	offset = pre.nextID;
    }

    if (print_id(id)) {
	fprintf(dfp, FMT_BASE, pre.name, pre.flags, pre.ngroups, pre.id,
		pre.owner, pre.creator);
	print_grp = 1;
    }

    if ((flags & DO_MEM) == 0)
	return;

    for (i = 0; i < PRSIZE; i++) {
	if ((id = pre.entries[i]) == 0)
	    break;
	if (id == PRBADID)
	    continue;
	if (print_id(id) || print_grp == 1) {
	    if (print_grp == 0) {
		fprintf(dfp, FMT_BASE, pre.name, pre.flags, pre.ngroups,
			pre.id, pre.owner, pre.creator);
		print_grp = 2;
	    }
	    fprintf(dfp, FMT_MEM, id_to_name(id), id);
	}
    }
    if (i == PRSIZE) {
	offset = pre.next;
	while (offset) {
	    lseek(dbase_fd, offset + HDRSIZE, L_SET);
	    if (read(dbase_fd, &prco, sizeof(struct contentry)) < 0) {
		fprintf(stderr, "pt_util: read i/o error: %s\n",
			strerror(errno));
		exit(1);
	    }
	    prco.next = ntohl(prco.next);
	    for (i = 0; i < COSIZE; i++) {
		prco.entries[i] = ntohl(prco.entries[i]);
		if ((id = prco.entries[i]) == 0)
		    break;
		if (id == PRBADID)
		    continue;
		if (print_id(id) || print_grp == 1) {
		    if (print_grp == 0) {
			fprintf(dfp, FMT_BASE, pre.name, pre.flags,
				pre.ngroups, pre.id, pre.owner, pre.creator);
			print_grp = 2;
		    }
		    fprintf(dfp, FMT_MEM, id_to_name(id), id);
		}
	    }
	    if ((i == COSIZE) && prco.next)
		offset = prco.next;
	    else
		offset = 0;
	}
    }
}
Beispiel #3
0
char *ref_to_name(char *s)
{
	if (isdigit(s[0]))
		return id_to_name(s);
	return s;
}