Ejemplo n.º 1
0
/* Updates the scan-monitoring file list with the given values */
void
filelist_scan_monitor( int *node_counts, int64 *size_counts )
{
	const char *str;
	int64 size_total = 0;
	int node_total = 0;
	int i;

	gtk_clist_freeze( GTK_CLIST(file_clist_w) );
	for (i = 1; i <= NUM_NODE_TYPES; i++) {
		/* Column 2 */
		if (i < NUM_NODE_TYPES) {
			str = i64toa( node_counts[i] );
			node_total += node_counts[i];
		}
		else
			str = i64toa( node_total );
		gtk_clist_set_text( GTK_CLIST(file_clist_w), i - 1, 1, str );

		/* Column 3 */
		if (i < NUM_NODE_TYPES) {
			str = i64toa( size_counts[i] );
			size_total += size_counts[i];
		}
		else
			str = i64toa( size_total );
		gtk_clist_set_text( GTK_CLIST(file_clist_w), i - 1, 2, str );
	}
	gtk_clist_thaw( GTK_CLIST(file_clist_w) );
}
Ejemplo n.º 2
0
/* Creates the clist widget used in the "Contents" page of the Properties
 * dialog for a directory */
GtkWidget *
dir_contents_list( GNode *dnode )
{
        char *col_titles[2];
	char *clist_row[2];
	GtkWidget *clist_w;
	Icon *icon;
	int i;

	g_assert( NODE_IS_DIR(dnode) );

	col_titles[0] = _("Node type");
	col_titles[1] = _("Quantity");

	/* Don't use gui_clist_add( ) as this one shouldn't be placed
	 * inside a scrolled window */
        clist_w = gtk_clist_new_with_titles( 2, col_titles );
	gtk_clist_set_selection_mode( GTK_CLIST(clist_w), GTK_SELECTION_SINGLE );
	for (i = 0; i < 2; i++)
		gtk_clist_set_column_auto_resize( GTK_CLIST(clist_w), i, TRUE );

	clist_row[0] = NULL;
	for (i = 1; i < NUM_NODE_TYPES; i++) {
		clist_row[1] = (char *)i64toa( DIR_NODE_DESC(dnode)->subtree.counts[i] );
		gtk_clist_append( GTK_CLIST(clist_w), clist_row );
		icon = &node_type_mini_icons[i];
		gtk_clist_set_pixtext( GTK_CLIST(clist_w), i - 1, 0, _(node_type_plural_names[i]), 2, icon->pixmap, icon->mask );
	}

	return clist_w;
}
Ejemplo n.º 3
0
	vint64_t atoi64_test(const AString& string, bool& success)
	{
		char* endptr = 0;
		vint64_t result = _strtoi64(string.Buffer(), &endptr, 10);
		success = endptr == string.Buffer() + string.Length() && i64toa(result) == string;
		return result;
	}
Ejemplo n.º 4
0
bool fix_field_unparse(struct fix_field *self, struct buffer *buffer)
{
    buffer->end += uitoa(self->tag, buffer_end(buffer));

    buffer_put(buffer, '=');

    switch (self->type) {
    case FIX_TYPE_STRING: {
        const char *p = self->string_value;

        while (*p) {
            buffer_put(buffer, *p++);
        }
        break;
    }
    case FIX_TYPE_STRING_8: {
        for (int i = 0; i < sizeof(self->string_8_value) && self->string_8_value[i]; ++i) {
            buffer_put(buffer, self->string_8_value[i]);
        }
        break;
    }
    case FIX_TYPE_CHAR: {
        buffer_put(buffer, self->char_value);
        break;
    }
    case FIX_TYPE_FLOAT: {
        // dtoa2 do not print leading zeros or .0, 7 digits needed sometimes
        buffer->end += modp_dtoa2(self->float_value, buffer_end(buffer), 7);
        break;
    }
    case FIX_TYPE_INT: {
        buffer->end += i64toa(self->int_value, buffer_end(buffer));
        break;
    }
    case FIX_TYPE_CHECKSUM: {
        buffer->end += checksumtoa(self->int_value, buffer_end(buffer));
        break;
    }
    default:
        break;
    };

    buffer_put(buffer, 0x01);

    return true;
}
Ejemplo n.º 5
0
/* Returns a NodeInfo struct for the given node */
const struct NodeInfo *
get_node_info( GNode *node )
{
	static struct NodeInfo ninfo = {
		NULL,	/* name */
		NULL,	/* prefix */
		NULL,	/* size */
		NULL,	/* size_abbr */
		NULL,	/* size_alloc */
		NULL,	/* size_alloc_abbr */
		NULL,	/* user_name */
		NULL,	/* group_name */
		NULL,	/* atime */
		NULL,	/* mtime */
		NULL,	/* ctime */
		NULL,	/* subtree_size */
		NULL,	/* subtree_size_abbr */
		NULL,	/* file_type_desc */
		NULL,	/* target */
		NULL	/* abstarget */
	};
	struct passwd *pw;
	struct group *gr;
	static char blank[] = "-";
	const char *absname;
	const char *cstr;
	char *str;

	absname = node_absname( node );

	/* Name */
	if (strlen( NODE_DESC(node)->name ) > 0)
		cstr = NODE_DESC(node)->name;
	else
		cstr = _("/. (root)");
	ninfo.name = xstrredup( ninfo.name, cstr );
	/* Prefix */
	str = g_dirname( absname );
	if (!strcmp( str, "/" )) {
		g_free( str );
		str = g_strdup( _("/. (root)") );
	}
	ninfo.prefix = xstrredup( ninfo.prefix, str );
	g_free( str );

	/* Size */
	ninfo.size = xstrredup( ninfo.size, i64toa( NODE_DESC(node)->size ) );
	ninfo.size_abbr = xstrredup( ninfo.size_abbr, abbrev_size( NODE_DESC(node)->size ) );
	/* Allocation size */
	ninfo.size_alloc = xstrredup( ninfo.size_alloc, i64toa( NODE_DESC(node)->size_alloc ) );
	ninfo.size_alloc_abbr = xstrredup( ninfo.size_alloc_abbr, abbrev_size( NODE_DESC(node)->size_alloc ) );

	/* User name */
	pw = getpwuid( NODE_DESC(node)->user_id );
	if (pw == NULL)
		cstr = _("Unknown");
	else
		cstr = pw->pw_name;
	ninfo.user_name = xstrredup( ninfo.user_name, cstr );
	/* Group name */
	gr = getgrgid( NODE_DESC(node)->group_id );
	if (gr == NULL)
		cstr = _("Unknown");
	else
		cstr = gr->gr_name;
	ninfo.group_name = xstrredup( ninfo.group_name, cstr );

	/* Timestamps - remember to strip ctime's trailing newlines */
	ninfo.atime = xstrredup( ninfo.atime, ctime( &NODE_DESC(node)->atime ) );
        ninfo.atime[strlen( ninfo.atime ) - 1] = '\0';
	ninfo.mtime = xstrredup( ninfo.mtime, ctime( &NODE_DESC(node)->mtime ) );
        ninfo.mtime[strlen( ninfo.mtime ) - 1] = '\0';
	ninfo.ctime = xstrredup( ninfo.ctime, ctime( &NODE_DESC(node)->ctime ) );
	ninfo.ctime[strlen( ninfo.ctime ) - 1] = '\0';

	/* For directories: subtree size */
	if (NODE_DESC(node)->type == NODE_DIRECTORY) {
		ninfo.subtree_size = xstrredup( ninfo.subtree_size, i64toa( DIR_NODE_DESC(node)->subtree.size ) );
		ninfo.subtree_size_abbr = xstrredup( ninfo.subtree_size_abbr, abbrev_size( DIR_NODE_DESC(node)->subtree.size ) );
	}
	else {
		ninfo.subtree_size = xstrredup( ninfo.subtree_size, blank );
		ninfo.subtree_size_abbr = xstrredup( ninfo.subtree_size_abbr, blank );
	}

	/* For regular files: file type description */
	if (NODE_DESC(node)->type == NODE_REGFILE)
		ninfo.file_type_desc = get_file_type_desc( absname );
	else
		ninfo.file_type_desc = blank;

	/* For symbolic links: target name(s) */
	if (NODE_DESC(node)->type == NODE_SYMLINK) {
		ninfo.target = read_symlink( absname );
		str = g_dirname( absname );
		ninfo.abstarget = absname_merge( str, ninfo.target );
		g_free( str );
	}
	else {
		ninfo.target = blank;
		ninfo.abstarget = blank;
	}

	return &ninfo;
}