Пример #1
0
void
putTrailer(uchar *p, PaqTrailer *h)
{
	putl(p, h->magic);
	putl(p+4, h->root);
	outdg = sha1(p, 8, p+8, outdg);
}
Пример #2
0
void	draw_grid(t_env *e, t_point **grid, int i, int j)
{
	grid = map_to_point(e);
	grid = (e->proj == 0) ? isometric(grid, e) : parallel(grid, e);
	i = 0;
	while ((i + 1) < e->map[0][0] - 1)
	{
		j = 0;
		while ((j + 1) < e->map[i + 1][0] - 1)
		{
			(grid[i][j + 1].x) ? putl(e, grid[i][j], grid[i][j + 1]) : 1;
			(grid[i + 1][j].x) ? putl(e, grid[i][j], grid[i + 1][j]) : 1;
			if (j + 1 == e->map[i + 1][0] - 2
				&& e->map[i + 1][0] <= e->map[i + 2][0])
				putl(e, grid[i][j + 1], grid[i + 1][j + 1]);
			if (i + 1 == e->map[0][0] - 2)
				putl(e, grid[i + 1][j], grid[i + 1][j + 1]);
			j++;
		}
		i++;
	}
	mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0);
	print_state(e);
	mlx_do_sync(e->mlx);
}
Пример #3
0
Файл: macros.c Проект: bszcz/c
int main(void) {
	const int max = 3;
	fori(max) {
		forj(max) {
			printf("(%d, %d) ", i, j);
		}
		printf("\n");
	}
	printf("\n");

	some_func(max);
	printf("\n");

	const int i = 10;
	const float f = 1.0f;
	putl(i);
	putd(f);
	putl(10); // still works, sort of...

	putx(i);
	putx(f);

	print_vec2(vec(1.0, 2.0));
	print_vec3(vec(1.0, 2.0, 3.0));

	struct player p1 = player("Mario");
	struct player p2 = player("Luigi", .lives = 2); // -Winitializer-overrides warning
	print_player(p1);
	print_player(p2);
}
Пример #4
0
static void
draw_detailed(void)
{
	int start_pos, end_pos, i;
	intf_t *intf;
	double rx, tx;
	char *rx_u, *tx_u;
	int attr_flag = 0;

	intf = get_current_intf();

	if (NULL == intf)
		return;
	
	move(row, 40);
	addch(ACS_TTEE);
	move(row, 0);
	
#ifndef DISABLE_OVERFLOW_WORKAROUND
	if (intf->i_rx_bytes.r_overflows)
		rx = sumup((intf->i_rx_bytes.r_overflows * OVERFLOW_LIMIT) +
			intf->i_rx_bytes.r_total, &rx_u);
#endif
	else
		rx = sumup(intf->i_rx_bytes.r_total, &rx_u);

#ifndef DISABLE_OVERFLOW_WORKAROUND
	if (intf->i_tx_bytes.r_overflows)
		tx = sumup((intf->i_tx_bytes.r_overflows * OVERFLOW_LIMIT) +
			intf->i_tx_bytes.r_total, &tx_u);
#endif
	else
		tx = sumup(intf->i_tx_bytes.r_total, &tx_u);

	NEXT_ROW;
	start_pos = row;
	putl("                      RX          TX                             RX          TX");

	NEXT_ROW;
	putl(" Bytes:        %9.1f %s%8.1f %s    Packets:    %11llu %11llu",
		rx, rx_u, tx, tx_u,
		intf->i_rx_packets.r_total, intf->i_tx_packets.r_total);

	foreach_attr(intf, draw_attr_detail, &attr_flag);

	end_pos = row;
	for (i = start_pos; i <= end_pos; i++) {
		move(i, 40);
		addch(ACS_VLINE);
	}
	move(end_pos, 0);
}
Пример #5
0
void
putBlock(uchar *p, PaqBlock *b)
{
	if(b->size < 65536){
		putl(p, b->magic);
		puts(p+4, b->size);
	}else{
		assert(b->magic == BlockMagic);
		puts(p, BigBlockMagic);
		putl(p+2, b->size);
	}
	p[6] = b->type;
	p[7] = b->encoding;
	putl(p+8, b->adler32);
}
Пример #6
0
void
putDir(uchar *p, PaqDir *d)
{
	uchar *q;

	puts(p, paqDirSize(d));
	putl(p+2, d->qid);	
	putl(p+6, d->mode);
	putl(p+10, d->mtime);
	putl(p+14, d->length);
	putl(p+18, d->offset);
	q = putstr(p+22, d->name);
	q = putstr(q, d->uid);
	q = putstr(q, d->gid);
	assert(q-p == paqDirSize(d));
}
Пример #7
0
void
putHeader(uchar *p, PaqHeader *h)
{
	if(h->blocksize < 65536){
		putl(p, h->magic);
		puts(p+4, h->version);
		puts(p+6, h->blocksize);
	}else{
		assert(h->magic == HeaderMagic);
		puts(p, BigHeaderMagic);
		puts(p+2, h->version);
		putl(p+4, h->blocksize);
	}
	putl(p+8, h->time);
	memmove(p+12, h->label, sizeof(h->label));
}
Пример #8
0
static void draw_detailed(void)
{
	int start_pos, end_pos, i;
	item_t *intf;
	int attr_flag = 0;

	intf = get_current_item();

	if (NULL == intf)
		return;
	
	move(row, 39);
	addch(ACS_TTEE);
	move(row, 0);

	NEXT_ROW;
	start_pos = row;
	putl("                    RX           TX     " \
	     "                    RX           TX");

	foreach_attr(intf, draw_attr_detail, &attr_flag);

	end_pos = row;
	for (i = start_pos; i <= end_pos; i++) {
		move(i, 39);
		addch(ACS_VLINE);
	}
	move(end_pos, 0);
}
Пример #9
0
static void draw_attr_detail(stat_attr_t *attr, void *arg)
{
	int rxprec, txprec;
	double rx, tx;
	char *rxu, *txu;
	int *t = (int *) arg;

	rx = cancel_down(attr_get_rx(attr), attr->a_unit, &rxu, &rxprec);
	tx = cancel_down(attr_get_tx(attr), attr->a_unit, &txu, &txprec);

	if (0 == *t) {
		NEXT_ROW;
		putl(" %-12s%9.*f%-3s %9.*f%-3s",
			type2desc(attr->a_type),
			rxprec, rx, rxu, txprec, tx, txu);

		if (!(attr->a_flags & ATTR_FLAG_RX_ENABLED)) {
			move(row, 20);
			addstr("N/A");
		}

		if (!(attr->a_flags & ATTR_FLAG_TX_ENABLED)) {
			move(row, 33);
			addstr("N/A");
		}

		move(row, 40);
		*t = 1;
	} else {
		putl(" %-12s%9.*f%-3s %9.*f%-3s",
			type2desc(attr->a_type),
			rxprec, rx, rxu, txprec, tx, txu);
		
		if (!(attr->a_flags & ATTR_FLAG_RX_ENABLED)) {
			move(row, 60);
			addstr("N/A");
		}
		
		if (!(attr->a_flags & ATTR_FLAG_TX_ENABLED)) {
			move(row, 73);
			addstr("N/A");
		}

		move(row, 0);
		*t = 0;
	}
}
Пример #10
0
PaqDir *
paqFile(char *name, Dir *dir)
{
	int fd, n, nn, nb;
	vlong tot;
	uchar *block, *pointer;
	ulong offset;

	fd = open(name, OREAD);
	if(fd < 0) {
		warn("could not open file: %s: %r", name);
		return nil;
	}

	block = emallocz(blocksize);
	pointer = emallocz(blocksize);
	nb = 0;
	n = 0;
	tot = 0;
	for(;;) {
		nn = read(fd, block+n, blocksize-n);
		if(nn < 0) {
			warn("read failed: %s: %r", name);
			goto Err;
		}
		tot += nn;
		if(nn == 0) {	
			if(n == 0)
				break;	
			/* pad out last block */
			memset(block+n, 0, blocksize-n);
			nn = blocksize - n;
		}
		n += nn;
		if(n < blocksize)
			continue;
		if(nb >= blocksize/OffsetSize) {
			warn("file too big for blocksize: %s", name);
			goto Err;
		}
		offset = writeBlock(block, DataBlock);
		putl(pointer+nb*OffsetSize, offset);
		nb++;
		n = 0;
	}

	offset = writeBlock(pointer, PointerBlock);

	close(fd);
	free(pointer);
	free(block);
	dir->length = tot;
	return paqDirAlloc(dir, offset);
Err:
	close(fd);
	free(pointer);
	free(block);
	return nil;
}
Пример #11
0
bool WEXPORT WObjectFile::writeIndex( WObject* obj, bool force )
{
    bool firstTime = false;
    if( obj == NULL ) {
        putl( -1 );
    } else {
        int index = _objects.indexOfSame( obj );
        if( force || index < 0 ) {
            index = _objects.count();
            _objects.add( obj );
            firstTime = true;
        }
        putl( index );
    }
    writeEOItem();
    return( firstTime );
}
Пример #12
0
static void
draw_attr_detail(intf_attr_t *attr, void *arg)
{
	int *t = (int *) arg;

	if (0 == *t) {
		NEXT_ROW;
		putl(" %-12s%11llu %11llu",
			type2name(attr->a_type), attr->a_rx, attr->a_tx);

		if (!attr->a_rx_enabled) {
			move(row, 21);
			addstr("N/A");
		}

		if (!attr->a_tx_enabled) {
			move(row, 33);
			addstr("N/A");
		}

		move(row, 44);
		*t = 1;
	} else {
		putl("%-12s%11llu %11llu",
			type2name(attr->a_type), attr->a_rx, attr->a_tx);
		
		if (!attr->a_rx_enabled) {
			move(row, 64);
			addstr("N/A");
		}
		
		if (!attr->a_tx_enabled) {
			move(row, 76);
			addstr("N/A");
		}

		move(row, 0);
		*t = 0;
	}
}
Пример #13
0
int main(void)
{
	printstr("OK\n");
	if (init_video())
	{
		return(1);
	}

	printstr("    Resetting disk...");
	if (print_error(disk_reset(loader_setup.boot_drive), disk_errors, N_DISK_ERRORS, TRUE))
	{
		return(1);
	}

	printstr("    Getting disk info...");
	if (print_error(disk_info_standard(loader_setup.boot_drive,
									   &disk_geometry.cylinder,
									   &disk_geometry.head,
									   &disk_geometry.sector),
					 disk_errors, N_DISK_ERRORS, TRUE))
	{
		return(1);
	}

	printstr("...OK\n");

	printstr("Loading HIKernel (");
	putl(loader_setup.kernel_sectors, 10);
	printstr(" sectors)...\n");

	if (print_error(read_kernel(), disk_errors, N_DISK_ERRORS, TRUE))
	{
		return(1);
	}

	printstr("Killing floppy motor...\n");
	stop_floppy();

	printstr("Starting the BOSS...");

	engage();

	update_cursor();
	printstr("\nBack in the aMOS loader\n");
	printstr("Can't play that funky music, giving it up\n");
	printstr("Let down and hanging around\n");
	for (;;) {}

	return(0);
}
Пример #14
0
bool WEXPORT WObjectFile::open( const char* name, OpenStyle style )
{
    _objOk = _objOk & WFile::open( name, style );
    if( _objOk ) {
        _objects.reset();
        if( style & OStyleWrite ) {
            putl( _version );
            writeEOItem();
        } else {
            _version = getl();
            readEOItem();
        }
    }
    return( _objOk );
}
Пример #15
0
/**
 * read_phy_reg - MII interface  to read  @reg_addr register of phy at @phy_addr
 * return positive and zero value if success, or negative value if fail
 * may be used by other standard ethernet phy
 */
unsigned short read_phy_reg_ksz8041(ec_priv_t * ecp, unsigned short reg_addr)
{
	u32 op_reg;

	do {
		op_reg = getl(MAC_CSR10);
	} while (op_reg & MII_MNG_SB);

	putl(MII_MNG_SB | MII_MNG_OPCODE(MII_OP_READ) | MII_MNG_REGADD(reg_addr) |
		MII_MNG_PHYADD(ASOC_ETHERNET_PHY_ADDR), MAC_CSR10);

	do {
		op_reg = getl(MAC_CSR10);
	} while (op_reg & MII_MNG_SB);

	return (u16)MII_MNG_DATA(op_reg);
}
Пример #16
0
/**
 * write_phy_reg - MII interface  to write  @val to @reg_addr register of phy at @phy_addr
 * return zero if success, negative value if fail
 * may be used by other standard ethernet phy
 */
int write_phy_reg_ksz8041(ec_priv_t * ecp, unsigned short reg_addr, unsigned short val)
{
	u32 op_reg;

	do {
		op_reg = getl(MAC_CSR10);
	} while (op_reg & MII_MNG_SB);

	putl(MII_MNG_SB | MII_MNG_OPCODE(MII_OP_WRITE) | MII_MNG_REGADD(reg_addr) |
		MII_MNG_PHYADD(ASOC_ETHERNET_PHY_ADDR) | val, MAC_CSR10);

	do {
		op_reg = getl(MAC_CSR10);
	} while (op_reg & MII_MNG_SB);

	return 0;
}
Пример #17
0
static void __draw_graphic(stat_attr_hist_t *a, int selected, int xunit)
{
	int w;
	graph_t *g;
	g = create_configued_graph(&a->a_hist, c_graph_height, a->a_unit, xunit);

	NEXT_ROW;
	putl("RX    %s                        [%s]",
	     g->g_rx.t_y_unit, type2desc(a->a_type));

	if (selected) {
		move(row, 72);
		attron(A_BOLD);
		addstr("(sel)");
		attroff(A_BOLD);
		move(row, 0);
	}

	for (w = (c_graph_height - 1); w >= 0; w--) {
		NEXT_ROW;
		putl(" %8.2f %s\n", g->g_rx.t_y_scale[w], (char *) g->g_rx.t_data + (w * (HISTORY_SIZE + 1)));
	}

	move(row, 71);
	putl("[%.2f%%]", rtiming.rt_variance.v_error);
	NEXT_ROW;
	putl("          1   5   10   15   20   25   30   35   40   45   50   55   60 %s", g->g_rx.t_x_unit);

	NEXT_ROW;
	putl("TX    %s", g->g_tx.t_y_unit);

	for (w = (c_graph_height - 1); w >= 0; w--) {
		NEXT_ROW;
		putl(" %8.2f %s\n", g->g_tx.t_y_scale[w], (char *) g->g_tx.t_data + (w * (HISTORY_SIZE + 1)));
	}

	move(row, 71);
	putl("[%.2f%%]", rtiming.rt_variance.v_error);
	NEXT_ROW;
	putl("          1   5   10   15   20   25   30   35   40   45   50   55   60 %s", g->g_tx.t_x_unit);

	free_graph(g);
}
Пример #18
0
static void
draw_graphic(void)
{
	int w;
	graph_t *g;
	intf_t *intf = get_current_intf();

	if (NULL == intf)
		return;
	
	g = create_configued_graph(&intf->i_bytes_hist, c_graph_height);

	NEXT_ROW;
	putl("RX    %s", g->g_rx.t_y_unit);

	for (w = (c_graph_height - 1); w >= 0; w--) {
		NEXT_ROW;
		putl(" %8.2f %s\n", g->g_rx.t_y_scale[w], (char *) g->g_rx.t_data + (w * (HISTORY_SIZE + 1)));
	}

	move(row, 71);
	putl("[%.2f%%]", rtiming.rt_variance.v_error);
	NEXT_ROW;
	putl("          1   5   10   15   20   25   30   35   40   45   50   55   60 %s", g->g_rx.t_x_unit);

	NEXT_ROW;
	putl("TX    %s", g->g_tx.t_y_unit);

	for (w = (c_graph_height - 1); w >= 0; w--) {
		NEXT_ROW;
		putl(" %8.2f %s\n", g->g_tx.t_y_scale[w], (char *) g->g_tx.t_data + (w * (HISTORY_SIZE + 1)));
	}

	move(row, 71);
	putl("[%.2f%%]", rtiming.rt_variance.v_error);
	NEXT_ROW;
	putl("          1   5   10   15   20   25   30   35   40   45   50   55   60 %s", g->g_tx.t_x_unit);

	free_graph(g);
}
Пример #19
0
static void
draw_node(node_t *node, void *arg)
{
	int i;

	attrset(A_BOLD);
	NEXT_ROW; 
	putl("%s (source: %s)", node->n_name,
		node->n_from ? node->n_from : "local");
	attroff(A_BOLD);

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_LIST) | layout[LAYOUT_LIST].attr);

	for (i = 0; i < node->n_nintf; i++)
		draw_intf(node, &node->n_intf[i]);

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_DEFAULT) | layout[LAYOUT_DEFAULT].attr);
}
Пример #20
0
static void
draw_intf_list_entry(intf_t *intf, node_t *node)
{
	float rx, tx;
	char *rx_u, *tx_u;
	char pad[IFNAMSIZ + 32];
	
	rx = sumup(intf->i_rx_bytes.r_tps, &rx_u);
	tx = sumup(intf->i_tx_bytes.r_tps, &tx_u);

	memset(pad, ' ', sizeof(pad));
	pad[sizeof(pad) - 1] = '\0';
	if (intf->i_level >= 15)
		strcpy(&pad[sizeof(pad) - 1], intf->i_name);
	else
		strcpy(&pad[2 * intf->i_level], intf->i_name);

	NEXT_ROW;

	if (intf->i_index == node->n_selected && node == get_current_node()) {
		if (c_use_colors)
			attrset(COLOR_PAIR(LAYOUT_SELECTED) | layout[LAYOUT_SELECTED].attr);
		else
			attron(A_REVERSE);
	}
	
	printw("  %-3d%s", intf->i_index, intf->i_folded ? "+" : " ");

	if (intf->i_index == node->n_selected && node == get_current_node()) {
		if (c_use_colors)
			attrset(COLOR_PAIR(LAYOUT_LIST) | layout[LAYOUT_LIST].attr);
		else
			attroff(A_REVERSE);
	}

	
	putl("%-20s %10.2f%s %10d %10.2f%s %10d", pad,
		rx, rx_u, intf->i_rx_packets.r_tps,
		tx, tx_u, intf->i_tx_packets.r_tps);
}
Пример #21
0
/**
 * read_phy_reg - MII interface  to read  @reg_addr register of phy at @phy_addr
 * return positive and zero value if success, or negative value if fail
 * may be used by other standard ethernet phy
 */
unsigned short read_phy_reg_sr8201g(ec_priv_t * ecp, unsigned short reg_addr)
{
	u32 op_reg;
	u32 phy_addr;
	if((ecp->phy_addr)!=0xFF)
		phy_addr=ecp->phy_addr;
	else
		phy_addr=ASOC_ETHERNET_PHY_ADDR;

	do {
		op_reg = getl(MAC_CSR10);
	} while (op_reg & MII_MNG_SB);

	putl(MII_MNG_SB | MII_MNG_OPCODE(MII_OP_READ) | MII_MNG_REGADD(reg_addr) |
		MII_MNG_PHYADD(phy_addr), MAC_CSR10);

	do {
		op_reg = getl(MAC_CSR10);
	} while (op_reg & MII_MNG_SB);

	return (u16)MII_MNG_DATA(op_reg);
}
Пример #22
0
extern int	print_error(unsigned long errno, struct error *errors, unsigned long n_errors, char emit_noerror)
{
	unsigned long	i;

/*	I don't like the way of checking if we're of bounds
	The number of errors in the error array should be determined automaticly (sizeof)*/
	for (i=0; ((errno!=errors[i].errno) && (i<n_errors)); i++);
	
	if (errno)
	{
		printstr("ERROR 0x");
		putl(errno, 0x10);
		printstr(": ");
	}

	if ((!errno) && (!emit_noerror))
		return(errno);
	
	printstr(errors[i].error_msg);
	printstr("\n");

	return(errno);
}
Пример #23
0
/**
 * write_phy_reg - MII interface  to write  @val to @reg_addr register of phy at @phy_addr
 * return zero if success, negative value if fail
 * may be used by other standard ethernet phy
 */
int write_phy_reg_sr8201g(ec_priv_t * ecp, unsigned short reg_addr, unsigned short val)
{
	u32 op_reg;
	u32 phy_addr;

	if((ecp->phy_addr)!=0xFF)
		phy_addr=ecp->phy_addr;
	else
		phy_addr=ASOC_ETHERNET_PHY_ADDR;

	do {
		op_reg = getl(MAC_CSR10);
	} while (op_reg & MII_MNG_SB);

	putl(MII_MNG_SB | MII_MNG_OPCODE(MII_OP_WRITE) | MII_MNG_REGADD(reg_addr) |
		MII_MNG_PHYADD(phy_addr) | val, MAC_CSR10);

	do {
		op_reg = getl(MAC_CSR10);
	} while (op_reg & MII_MNG_SB);

	return 0;
}
Пример #24
0
static void
curses_draw(void)
{
	if (NULL == get_current_node()) {
		first_node();
		first_intf();
	}

    row = 0;
    move(0,0);
	
	getmaxyx(stdscr, rows, cols);
	
	if (cols < 80) {
		clear();
		putl("Screen must be at least 80 columns wide");
		refresh();
		return;
	}

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	if (get_current_node() && get_current_intf()) {
		putl(" interface: %s at %s",
			get_current_intf()->i_name, get_current_node()->n_name);
	}

	move(row, COLS - strlen(PACKAGE_STRING) - 1);
	putl("%s", PACKAGE_STRING);
	move(row, 0);
	
	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_DEFAULT) | layout[LAYOUT_DEFAULT].attr);
	else
		attroff(A_REVERSE);
	
	print_content();

	if (quit_mode)
		print_quit();
	else if (print_help)
		draw_help();

	for (; row < rows-2;) {
		move(++row, 0);
		putl("");
	}
	
	row = rows-1;
	move(row, 0);

	if (c_use_colors)
		attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr);
	else
		attrset(A_REVERSE);

	putl(" ^ prev interface, v next interface, <- prev node, -> next node, ? help");
	
	attrset(0);
	refresh();
}
Пример #25
0
static void
print_content(void)
{
	int required_lines = 0, disable_detailed = 0, disabled_graphical = 0;

	if (NULL == get_current_node())
		return;

	if (c_list_in_list) {
		NEXT_ROW;
		putl("");

		if (c_use_colors)
			attrset(COLOR_PAIR(LAYOUT_HEADER) | layout[LAYOUT_HEADER].attr);
	
		NEXT_ROW;
		putl("  #   Tarjeta                RX Tasa         RX #   " \
			"  TX Tasa         TX #");
	
		NEXT_ROW;
		hline(ACS_HLINE, cols);

		if (c_combined_node_list)
			foreach_node(draw_node, NULL);
		else
			draw_node(get_current_node(), NULL);
	} else {
		NEXT_ROW;
		hline(ACS_HLINE, cols);
		move(row, 24);
		addstr(" Press l to enable list view ");
		move(row, 0);
	}

	/*
	 * calculate lines required for graphical and detailed stats unfolded
	 */
	if (c_graphical_in_list)
		required_lines += lines_required_for_graphical();
	else
		required_lines++;

	if (c_detailed_in_list)
		required_lines += lines_required_for_detailed();
	else
		required_lines++;

	if ((rows - row) <= (required_lines + 1)) {
		/*
		 * not enough lines, start over with detailed stats disabled
		 */
		required_lines = 0;
		disable_detailed = 1;

		/*
		 * 1 line for folded detailed stats display
		 */
		required_lines++;

		if (c_graphical_in_list)
			required_lines += lines_required_for_graphical();
		else
			required_lines++;

		if ((rows - row) <= (required_lines + 1)) {
			/*
			 * bad luck, not even enough space for graphical stats
			 * reserve 2 lines for displaying folded detailed and
			 * graphical stats
			 */
			required_lines = 2;
			disabled_graphical = 1;
		}
	}

	/*
	 * Clear out spare space
	 */
	while (row < (rows - (required_lines + 2))) {
		NEXT_ROW; putl("");
	}

	NEXT_ROW;
	hline(ACS_HLINE, cols);

	if (c_graphical_in_list) {
		if (disabled_graphical) {
			move(row, 15);
			addstr(" Increase screen size to see graphical statistics ");
			move(row, 0);
		} else
			draw_graphic();
	} else {
		move(row, 20);
		addstr(" Press g to enable graphical statistics ");
		move(row, 0);
	}

	NEXT_ROW;
	hline(ACS_HLINE, cols);

	if (c_detailed_in_list) {
		if (disable_detailed) {
			move(row, 15);
			addstr(" Increase screen size to see detailed statistics ");
			move(row, 0);
		} else
			draw_detailed();
	} else {
		move(row, 20);
		addstr(" Press d to enable detailed statistics ");
		move(row, 0);
	}
}
Пример #26
0
PaqDir *
paqDir(char *name, Dir *dir)
{
	Dir *dirs, *p;
	PaqDir *pd;
	int i, n, nb, fd, ndir;
	uchar *block, *pointer;
	char *nname;
	ulong offset;

	fd = open(name, OREAD);
	if(fd < 0) {
		warn("could not open directory: %s: %r", name);
		return nil;
	}

	ndir = dirreadall(fd, &dirs);
	close(fd);

	if(ndir < 0) {
		warn("could not read directory: %s: %r", name);
		return nil;
	}

	block = emallocz(blocksize);
	pointer = emallocz(blocksize);
	nb = 0;
	n = 0;
	nname = nil;
	pd = nil;

	for(i=0; i<ndir; i++) {
		p = dirs + i;
		free(nname);
		nname = emallocz(strlen(name) + strlen(p->name) + 2);
		sprint(nname, "%s/%s", name, p->name);
		if(p->mode & DMDIR)
			pd = paqDir(nname, p);
		else
			pd = paqFile(nname, p);
		if(pd == nil)
			continue;

		if(n+paqDirSize(pd) >= blocksize) {

			/* zero fill the block */
			memset(block+n, 0, blocksize-n);
			offset = writeBlock(block, DirBlock);
			n = 0;
			if(nb >= blocksize/OffsetSize) {
				warn("directory too big for blocksize: %s", nname);
				goto Err;
			}
			putl(pointer+nb*OffsetSize, offset);
			nb++;
		}
		if(n+paqDirSize(pd) >= blocksize) {
			warn("directory entry does not fit in a block: %s", nname);
			paqDirFree(pd);
			continue;
		}
		putDir(block+n, pd);
		n += paqDirSize(pd);
		paqDirFree(pd);
		pd = nil;
	}

	if(n > 0) {
		/* zero fill the block */
		memset(block+n, 0, blocksize-n);
		offset = writeBlock(block, DirBlock);
		if(nb >= blocksize/OffsetSize) {
			warn("directory too big for blocksize: %s", nname);
			goto Err;
		}
		putl(pointer+nb*OffsetSize, offset);
	}
	offset = writeBlock(pointer, PointerBlock);

	free(nname);
	free(dirs);
	paqDirFree(pd);
	free(block);
	free(pointer);
	return paqDirAlloc(dir, offset);
Err:	
	free(nname);
	free(dirs);
	paqDirFree(pd);
	free(block);
	free(pointer);
	return nil;
}
Пример #27
0
void WEXPORT WObjectFile::writeObject( unsigned long long obj )
{
    putl( (unsigned long)obj );
    writeEOItem();
}
Пример #28
0
void WEXPORT WObjectFile::writeObject( long obj )
{
    putl( obj );
    writeEOItem();
}
Пример #29
0
void WEXPORT WObjectFile::writeObject( unsigned int obj )
{
    putl( obj );
    writeEOItem();
}
Пример #30
0
void WEXPORT WObjectFile::writeObject( unsigned char obj )
{
    putl( obj ); // as of version 39 -- text only
    // putch( obj );
    writeEOItem();
}