25 if (!strcmp(
name,
"bool")) {
28 if (!strcmp(
name,
"boolean")) {
31 if (!strcmp(
name,
"string")) {
34 if (!strcmp(
name,
"number")) {
45 col->
width = itemLength;
56 c->width =
RZ_MAX(
c->width, itemLength);
127 if (!strcmp(
c->name,
name)) {
142 c->maxWidth = maxWidth;
145 c->width = itemLength;
163 c->width =
RZ_MAX(
c->width, itemLength);
200 name = va_arg(ap,
const char *);
220 eprintf(
"Invalid format string char '%c', use 's' or 'n'\n", *
f);
241 #define add_column_to_rowf(row, fmt, ap) \
243 const char *arg = NULL; \
247 arg = va_arg(ap, const char *); \
248 rz_pvector_push(row, strdup(arg ? arg : "")); \
251 rz_pvector_push(row, rz_str_new(rz_str_bool(va_arg(ap, int)))); \
255 rz_pvector_push(row, rz_str_newf("%d", va_arg(ap, int))); \
258 rz_pvector_push(row, rz_str_newf("%" PFMT64d, va_arg(ap, ut64))); \
261 rz_pvector_push(row, rz_num_units(NULL, 32, va_arg(ap, ut64))); \
265 ut64 n = va_arg(ap, ut64); \
266 if (n == UT64_MAX) { \
268 rz_pvector_push(row, strdup("----------")); \
270 rz_pvector_push(row, strdup("-1")); \
274 rz_pvector_push(row, rz_str_newf("0x%08" PFMT64x, n)); \
276 rz_pvector_push(row, rz_str_newf("0x%" PFMT64x, n)); \
281 eprintf("Invalid format string char '%c', use 's' or 'n'\n", fmt); \
304 for (
const char *
f = fmt; *
f;
f++) {
322 for (
const char *
f = fmt; *
f;
f++) {
337 const char *
arg = va_arg(ap,
const char *);
359 switch (col->
align) {
388 if (col->
total < 0) {
432 char *
s =
rz_str_newf(
"%s%s%s\n", tl_corner, h_line_str, tr_corner);
480 if (len2 < col->
width) {
481 padlen = col->
width - len2;
484 switch (col->
align) {
497 int left = col->
width - (
pad * 2 + len2);
585 const char *
comma =
"";
587 if (strchr(col->
name,
',')) {
601 const char *
comma =
"";
606 if (strchr(col->
name,
',')) {
644 }
else if (*item && *item !=
'0') {
666 size_t page = 0, page_items = 0;
675 sscanf(un,
"%zd/%zd", &page, &page_items);
679 lrow = page_items * (page - 1);
680 uv = page_items * (page);
736 if (nv == 0 && nn !=
NULL) {
737 match = !strcmp(nn, un);
744 match = strcmp(nn, un);
753 match = strlen(nn) == atoi(un);
756 match = strlen(nn) > atoi(un);
759 match = strlen(nn) < atoi(un);
775 static int cmp(
const void *_a,
const void *_b) {
780 int res =
Gcmp(wa, wb);
797 static int cmplen(
const void *_a,
const void *_b) {
802 int res = strlen(wa) - strlen(wb);
816 void *item_lhs, *item_rhs;
825 if (nth == -1 ||
i == nth) {
826 tmp = item_col->
type->
cmp(item_lhs, item_rhs);
857 for (j = 0; j <
i; j++) {
861 fcn(uniq_row, row, nth);
887 if (!strcmp(
op,
"gt")) {
890 if (!strcmp(
op,
"ge")) {
893 if (!strcmp(
op,
"lt")) {
896 if (!strcmp(
op,
"le")) {
899 if (!strcmp(
op,
"eq")) {
902 if (!strcmp(
op,
"ne")) {
937 const char *col_name;
938 size_t new_count = 0;
939 rz_list_foreach (col_names, it, col_name) {
944 col_sources[new_count].oldcol = fc;
945 col_sources[new_count].dup = !free_cols[fc];
946 free_cols[fc] =
false;
955 for (
i = 0;
i < new_count;
i++) {
960 if (col_sources[
i].
dup) {
965 row->
items = new_items;
983 for (
i = 0;
i < new_count;
i++) {
988 if (col_sources[
i].
dup) {
1020 rz_list_foreach (
list,
iter, col) {
1033 if (!strcmp(q,
"quiet")) {
1036 }
else if (!strcmp(q,
"fancy")) {
1038 }
else if (!strcmp(q,
"simple")) {
1040 }
else if (!strcmp(q,
"csv")) {
1042 }
else if (!strcmp(q,
"json")) {
1061 eprintf(
"RzTableQuery> comma separated. 'c' stands for column name.\n");
1062 eprintf(
" c/sort/inc sort rows by given colname\n");
1063 eprintf(
" c/sortlen/inc sort rows by strlen()\n");
1064 eprintf(
" c/cols/c1/c2 only show selected columns\n");
1065 eprintf(
" c only show column c\n");
1066 eprintf(
" c/gt/0x800 grep rows matching col0 > 0x800\n");
1067 eprintf(
" c/ge/0x800 grep rows matching col0 >= 0x800\n");
1068 eprintf(
" c/lt/0x800 grep rows matching col0 < 0x800\n");
1069 eprintf(
" c/le/0x800 grep rows matching col0 <= 0x800\n");
1070 eprintf(
" c/eq/0x800 grep rows matching col0 == 0x800\n");
1071 eprintf(
" c/ne/0x800 grep rows matching col0 != 0x800\n");
1072 eprintf(
" */uniq get the first row of each that col0 is unique\n");
1073 eprintf(
" */head/10 same as | head -n 10\n");
1074 eprintf(
" */tail/10 same as | tail -n 10\n");
1075 eprintf(
" */page/1/10 show the first 10 rows (/page/2/10 will show the 2nd)\n");
1076 eprintf(
" c/str/warn grep rows matching col(name).str(warn)\n");
1077 eprintf(
" c/strlen/3 grep rows matching strlen(col) == X\n");
1078 eprintf(
" c/minlen/3 grep rows matching strlen(col) > X\n");
1079 eprintf(
" c/maxlen/3 grep rows matching strlen(col) < X\n");
1080 eprintf(
" c/sum sum all the values of given column\n");
1081 eprintf(
" :csv .tostring() == .tocsv()\n");
1082 eprintf(
" :json .tostring() == .tojson()\n");
1083 eprintf(
" :fancy fancy table output with lines\n");
1084 eprintf(
" :simple simple table output without lines\n");
1085 eprintf(
" :quiet do not print column names header, implies :simple\n");
1093 rz_list_foreach (queries,
iter, query) {
1104 eprintf(
"Column name is NULL for (%s)\n", query);
1113 if (*columnName ==
'[') {
1114 col = atoi(columnName + 1);
1124 }
else if (!strcmp(operation,
"sort")) {
1126 }
else if (!strcmp(operation,
"uniq")) {
1128 }
else if (!strcmp(operation,
"sortlen")) {
1130 }
else if (!strcmp(operation,
"join")) {
1132 }
else if (!strcmp(operation,
"sum")) {
1140 }
else if (!strcmp(operation,
"strlen")) {
1144 }
else if (!strcmp(operation,
"minlen")) {
1148 }
else if (!strcmp(operation,
"maxlen")) {
1152 }
else if (!strcmp(operation,
"page")) {
1156 }
else if (!strcmp(operation,
"tail")) {
1160 }
else if (!strcmp(operation,
"head")) {
1164 }
else if (!strcmp(operation,
"str")) {
1168 }
else if (!strcmp(operation,
"cols")) {
1179 eprintf(
"Invalid operation (%s)\n", operation);
1229 if (
min != -1 &&
mul > 0) {
1233 for (j = 0; j <
width; j++) {
1236 const char *
arg = (
info->pitv.addr < npos && (
info->pitv.addr +
info->pitv.size) >
pos)
1267 if (
i > 0 &&
len != 0) {
1271 for (j = 0; j <
width; j++) {
1323 if (row_name && t->rows) {
1327 for (
i = 0;
i < t->totalCols;
i++) {
1337 if (transpose->
rows) {
1340 RZ_LOG_WARN(
"Invalid row while doing transpose.\n");
1374 RZ_API void rz_table_fromjson(
RzTable *t,
const char *csv) {
static RzILOpEffect * mul(cs_insn *insn, bool is_thumb)
RzBinInfo * info(RzBinFile *bf)
static const char * typeString(ut32 n, int *bits)
RZ_API char * sdb_fmt(const char *fmt,...)
RZ_API void Ht_() free(HtName_(Ht) *ht)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static void list(RzEgg *egg)
RZ_API RZ_BORROW RzListIter * rz_list_prepend(RZ_NONNULL RzList *list, void *data)
Appends at the beginning of the list a new element.
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API RZ_BORROW void * rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n)
Returns the N-th element of the list.
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode dup
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static void pad(RzStrBuf *sb, ut32 count)
#define rz_warn_if_reached()
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
#define RUNE_CURVE_CORNER_TL
#define RUNE_LONG_LINE_HORIZ
#define RUNE_CURVE_CORNER_BR
#define RUNE_CURVE_CORNER_BL
#define RUNE_CURVE_CORNER_TR
static bool rz_itv_contain(RzInterval itv, ut64 addr)
static ut64 rz_itv_end(RzInterval itv)
int(* RzListComparator)(const void *value, const void *list_data)
#define RZ_LOG_WARN(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API ut64 rz_num_get(RzNum *num, const char *str)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API char * pj_drain(PJ *j)
RZ_API PJ * pj_end(PJ *j)
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
RZ_API PJ * pj_kn(PJ *j, const char *k, ut64 n)
RZ_API const char * rz_str_rwx_i(int rwx)
RZ_API char * rz_str_repeat(const char *ch, int sz)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API size_t rz_str_ansi_len(const char *str)
RZ_API bool rz_str_isnumber(const char *str)
RZ_API size_t rz_str_len_utf8(const char *s)
RZ_API const char * rz_str_trim_head_ro(const char *str)
RZ_API size_t rz_str_len_utf8_ansi(const char *str)
RZ_API int rz_str_cmp(const char *dst, const char *orig, int len)
RZ_API RzList * rz_str_split_list(char *str, const char *c, int n)
Split the string str according to the substring c and returns a RzList with the result.
#define rz_strf(buf,...)
Convenience macro for local temporary strings.
RZ_API RZ_OWN char * rz_strbuf_drain(RzStrBuf *sb)
RZ_API bool rz_strbuf_prepend(RzStrBuf *sb, const char *s)
RZ_API char * rz_strbuf_get(RzStrBuf *sb)
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
RZ_API RzStrBuf * rz_strbuf_new(const char *s)
RZ_API void rz_strbuf_free(RzStrBuf *sb)
RZ_API bool rz_strbuf_appendf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API int rz_strbuf_length(RzStrBuf *sb)
void(* RzTableSelector)(RzTableRow *acc, RzTableRow *new_row, int nth)
static void * rz_pvector_tail(RzPVector *vec)
static void * rz_vector_index_ptr(RzVector *vec, size_t index)
static void ** rz_pvector_index_ptr(RzPVector *vec, size_t index)
RZ_API void rz_vector_remove_at(RzVector *vec, size_t index, void *into)
static void * rz_vector_tail(RzVector *vec)
static size_t rz_pvector_len(const RzPVector *vec)
RZ_API void * rz_vector_push(RzVector *vec, void *x)
RZ_API RzPVector * rz_pvector_new(RzPVectorFree free)
#define rz_vector_foreach(vec, it)
static void ** rz_pvector_push(RzPVector *vec, void *x)
RZ_API void rz_vector_free(RzVector *vec)
RZ_API void rz_pvector_free(RzPVector *vec)
RZ_API RzVector * rz_vector_new(size_t elem_size, RzVectorFree free, void *free_user)
static size_t rz_vector_len(const RzVector *vec)
static void * rz_pvector_at(const RzPVector *vec, size_t index)
RZ_API void rz_vector_sort(RzVector *vec, RzVectorComparator cmp, bool reverse)
Sort function for RzVector.
#define rz_pvector_foreach(vec, it)
RZ_API char * sdb_itoa(ut64 n, char *s, int base)
RZ_API ut64 sdb_atoi(const char *s)
RZ_API bool rz_table_align(RzTable *t, int nth, int align)
#define add_column_to_rowf(row, fmt, ap)
RZ_API RzTableRow * rz_table_row_new(RzPVector *items)
RZ_API void rz_table_add_column(RzTable *t, RzTableColumnType *type, const char *name, int maxWidth)
RZ_API void rz_table_visual_list(RzTable *table, RzList *list, ut64 seek, ut64 len, int width, bool va)
RZ_API void rz_table_column_fini(RZ_NONNULL void *_col)
clear function for RzVector cols in RzTable
static bool set_table_format(RzTable *t, const char *q)
static RzListComparator Gcmp
static int cmp(const void *_a, const void *_b)
static bool __addRow(RzTable *t, RzPVector *items, const char *arg, int col)
RZ_API void rz_table_uniq(RzTable *t)
RZ_API void rz_table_hide_header(RzTable *t)
RZ_API void rz_table_filter_columns(RzTable *t, RzList *list)
RZ_API void rz_table_sortlen(RzTable *t, int nth, bool dec)
static bool column_exists(RzTable *t, const char *name)
RZ_API void rz_table_add_rowf(RzTable *t, const char *fmt,...)
RZ_API void rz_table_add_row_vec(RZ_NONNULL RzTable *t, RZ_NONNULL RzPVector *items)
Add a new row to RzTable.
static int cmplen(const void *_a, const void *_b)
RZ_API RZ_OWN char * rz_table_tojson(RzTable *t)
Convert RzTable to json format.
RZ_API void rz_table_free(RzTable *t)
static void rz_table_row_fini_wrapper(RZ_NONNULL void *_row, void *user)
RZ_API void rz_table_sort(RzTable *t, int nth, bool dec)
RZ_API char * rz_table_tocsv(RzTable *t)
static RzTableColumnType rz_table_type_number
RZ_API bool rz_table_query(RzTable *t, const char *q)
static RzTableColumnType rz_table_type_bool
RZ_API void rz_table_add_row_columnsf(RzTable *t, const char *fmt,...)
RZ_API void rz_table_add_row(RZ_NONNULL RzTable *t, const char *name,...)
RZ_API char * rz_table_tosimplestring(RzTable *t)
RZ_API void rz_table_set_vcolumnsf(RzTable *t, const char *fmt, va_list ap)
Specify the types and names of the referenced table.
RZ_API RzTableColumn * rz_table_column_clone(RzTableColumn *col)
RZ_API void rz_table_group(RzTable *t, int nth, RzTableSelector fcn)
static int __strbuf_append_col_aligned_fancy(RzTable *t, RzStrBuf *sb, RzTableColumn *col, char *str)
static int sortString(const void *a, const void *b)
static int rz_rows_cmp(RzPVector *lhs, RzPVector *rhs, RzVector *cols, int nth)
RZ_API int rz_table_column_nth(RzTable *t, const char *name)
static void __computeTotal(RzTable *t)
static int __strbuf_append_col_aligned(RzStrBuf *sb, RzTableColumn *col, const char *str, bool nopad)
RZ_API void rz_table_set_columnsf(RzTable *t, const char *fmt,...)
Specify the types and names of the referenced table.
RZ_API void rz_table_row_fini(RZ_NONNULL void *_row)
clear function for RzVector rows in RzTable
static int sortNumber(const void *a, const void *b)
RZ_API char * rz_table_tostring(RzTable *t)
RZ_API RZ_OWN RzTable * rz_table_transpose(RZ_NONNULL RzTable *t)
Generates the transpose of RzTable.
static RzTableColumnType rz_table_type_string
RZ_API RzTable * rz_table_new(void)
RZ_API RZ_OWN char * rz_table_tofancystring(RZ_NONNULL RzTable *t)
Convert the content of RzTable to string.
static void __table_adjust(RzTable *t)
RZ_API RzTableColumnType * rz_table_type(const char *name)
static int __resolveOperation(const char *op)
RZ_API void rz_table_columns(RzTable *t, RzList *col_names)
Select specific columns in RzTable.
static void rz_table_column_fini_wrapper(RZ_NONNULL void *_col, void *user)
RZ_API void rz_table_filter(RzTable *t, int nth, int op, const char *un)
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()