R_API int r_core_log_list(RCore *core, int n, int nth, char fmt) { int printed = 0; int count = 0, i, idx, id = core->log->first; RStrpool *sp = core->log->sp; char *str = sp->str; if (fmt == 'j') { r_cons_printf ("["); } for (i = idx = 0; str && *str; i++, id++) { if ((n && n <= id) || !n) { switch (fmt) { case 'j': r_cons_printf ("%s[%d,\"%s\"]", printed? ",": "", id, str); break; case 't': r_cons_println (str); break; case '*': r_cons_printf ("\"l %s\"\n", str); break; default: r_cons_printf ("%d %s\n", id, str); break; } printed++; if (nth && printed >= nth) { break; } } str = r_strpool_next (sp, idx); if (!str) { break; } idx = r_strpool_get_index (sp, str); count++; } if (fmt == 'j') { r_cons_printf ("]\n"); } return count; }
R_API char *r_strpool_get_i(RStrpool *p, int index) { int i, n = 0; if (index < 0 || index >= p->len) { return NULL; } for (i = 0; i < index; i++) { char *s = r_strpool_next (p, n); n = r_strpool_get_index (p, s); } return p->str + n; }