Exemplo n.º 1
0
void hex_dump(const char *str, const void *data, ssize_t len, const struct debug_strings *decode)
{
	size_t i;
	const uint8_t *p = data;
	const char *decodedval;

	if (opt_debug < 3)
		return;

	printf("   ");
	switch (len) {
	case DUMP_UINT8:
		decodedval = val_to_string(*(uint8_t *)p, decode);
		printf("%s: %02x%s\n", str, *(uint8_t *)p, decodedval);
		return;
	case DUMP_UINT16:
		decodedval = val_to_string(*(uint16_t *)p, decode);
		printf("%s: %04x%s\n", str, *(uint16_t *)p, decodedval);
		return;
	case DUMP_UINT32:
		decodedval = val_to_string(*(uint32_t *)p, decode);
		printf("%s: %08x%s\n", str, *(uint32_t *)p, decodedval);
		return;
	}

	printf("%s:%s", str, (len <= 16) ? " " : "\n   ");
	for (i = 0; i < (size_t)len; i++) {
		if (i && !(i % 32))
			printf("\n   ");
		else if (i && !(i % 4))
			printf(" ");
		printf("%02x", p[i]);
	}
	printf("\n");
}
Exemplo n.º 2
0
Arquivo: util.c Projeto: cabrilo/ripe
const char* to_string(Value v)
{
  return val_to_string(
    method_call0(v, dsym_to_string)
  );
}
Exemplo n.º 3
0
/******************************************************************************
 *
 * \par Function Name: ui_print_table
 *
 * \par Purpose: Prints a table to stdout.
 *
 * \par
 * COL HDR: Name (Type), Name (Type), Name (Type)...
 * ROW   0: Value1, Value2, Value3...
 * ROW   1: Value1, Value2, Value3...
 *
 * \param[in]  table  The table to be printed
 *
 * Modification History:
 *  MM/DD/YY  AUTHOR         DESCRIPTION
 *  --------  ------------   ---------------------------------------------
 *  06/8/16  E. Birrane     Initial implementation,
 *****************************************************************************/
void ui_print_table(table_t *table)
{
	int32_t i = 0;
	uint32_t row_num = 1;
	int8_t first = 0;

	LystElt elt;
	LystElt elt2;

	char *temp = NULL;
	blob_t *cur_blob = NULL;
	table_row_t *cur_row = NULL;

	if(table == NULL)
	{
		printf("NULL");
		return;
	}

	printf("COL HDR: ");
	for(elt = lyst_first(table->hdr.names); elt; elt = lyst_next(elt))
	{
		cur_blob = (blob_t*) lyst_data(elt);

		if(first == 0)
		{
			first = 1;
		}
		else
		{
			printf(", ");
		}
		printf(" %s (%s)", (char *)cur_blob->value, type_to_str(table->hdr.types.value[i]));
		i++;
	}
	printf("\n");

	for(elt = lyst_first(table->rows); elt; elt = lyst_next(elt))
	{
		cur_row = (table_row_t*) lyst_data(elt);

		printf("ROW %3d: ", row_num++);

		if(cur_row == NULL)
		{
			printf("NULL");
		}
		else
		{
			first = 0;
			i = 0;

			for(elt2 = lyst_first(cur_row->cels); elt2; elt2 = lyst_next(elt2))
			{
				cur_blob = (blob_t *) lyst_data(elt2);
				value_t  val = val_from_blob(cur_blob, table->hdr.types.value[i]);

				if(first == 0)
				{
					first = 1;
				}
				else
				{
					printf(", ");
				}

				temp = val_to_string(val);
				printf("%s", temp);
				SRELEASE(temp);
				val_release(&val, 0);
				i++;
			}
			printf("\n");
		}
	}

}