uchar OutUtf8(ushort index, fmt_t mode, color_t ntag) { register size_t size = (maxpos - curpos) - outcnt; if ( (int)size <= MIN_ARG_SIZE ) { DEB_ASSERT(((int)size < 0), "OutUtf8"); if ( (size = putLine/*outProc*/()) == 0) return(1 ); } if ( ntag) out_tagon(ntag ); ref_pos = get_output_ptr(); if ( fmtString(index, size, mode, /**outProc*/putLine) < 0) return(1 ); outcnt += get_output_ptr() - ref_pos; if ( ntag) out_tagoff(ntag ); return(0); }
//--------------------------------------------------------------------------- uchar putVal(const op_t &x, uchar mode, uchar warn) { char *ptr = get_output_ptr(); { flags_t sv_uFlag = uFlag; uFlag = 0; OutValue(x, mode); uFlag = sv_uFlag; } char str[MAXSTR]; char *end = set_output_ptr(ptr); size_t len = end - ptr; qstrncpy(str, ptr, qmin(len+1, sizeof(str))); if ( warn ) out_tagon(COLOR_ERROR); if ( warn ) len = tag_remove(str, str, 0); else len = tag_strlen(str); if ( chkOutLine(str, len) ) return 0; if ( warn ) out_tagoff(COLOR_ERROR); return 1; }
//--------------------------------------------------------------------------- uchar putVal(op_t &x, uchar mode, uchar warn) { char str[MAXSTR]; uint32 sv_bufsize = bufsize; char *sv_bufbeg = bufbeg, *sv_ptr = get_output_ptr(); init_output_buffer(str, sizeof(str)); { flags_t sv_uFlag = uFlag; uFlag = 0; OutValue(x, mode); uFlag = sv_uFlag; } out_zero(); init_output_buffer(sv_bufbeg, sv_bufsize); set_output_ptr(sv_ptr); if ( warn) out_tagon(COLOR_ERROR ); { register size_t i; if ( !warn) i = tag_strlen(str ); else i = tag_remove(str, str, 0); if ( chkOutLine(str, i)) return(0 ); } if ( warn) out_tagoff(COLOR_ERROR ); return(1); }
//---------------------------------------------------------------------- uchar putShort(ushort value, uchar wsym) { char tmpstr[32]; register char *p = get_output_ptr(); out_tagon(COLOR_ERROR); if ( wsym) OutChar(wsym ); OutLong(value, #ifdef __debug__ debugmode ? 16 : #endif 10); out_tagoff(COLOR_ERROR); register size_t len = get_output_ptr() - p; memcpy(tmpstr, p, len); tmpstr[len] ='\0'; *p = '\0'; set_output_ptr(p); return(chkOutLine(tmpstr, tag_strlen(tmpstr))); }
uchar OutUtf8(ushort index, fmt_t mode, color_t color) { size_t size = (maxpos - curpos) - outcnt; if ( (int)size <= MIN_ARG_SIZE ) { DEB_ASSERT(((int)size < 0), "OutUtf8"); size = putLine(); if ( size == 0 ) return 1; } if ( color != COLOR_NONE ) out_tagon(color); ref_pos = get_output_ptr(); if ( fmtString(index, size, mode, putLine) < 0 ) return 1; outcnt += get_output_ptr() - ref_pos; if ( color != COLOR_NONE ) out_tagoff(color); return 0; }
//---------------------------------------------------------------------- static void make_new_name(ushort name, ushort subnam, uchar mode, unsigned ip) { char str[MAXNAMELEN]; init_output_buffer(str, sizeof(str)); if ( fmtString(name, sizeof(str)-2, fmt_fullname) ) { trunc: trunc_name(ip, mode & 4); } else if ( (char)mode > 0 ) { register char *p = get_output_ptr(); if ( p >= &str[sizeof(str)-3] ) goto trunc; *p++ = '.'; set_output_ptr(p); if ( fmtString(subnam, &str[sizeof(str)-2] - p, fmt_name) ) goto trunc; } term_output_buffer(); do_name_anyway(ip, convert_clsname(str)); hide_name(ip); }
//---------------------------------------------------------------------- uchar putShort(ushort value, uchar wsym) { char *p = get_output_ptr(); out_tagon(COLOR_ERROR); if ( wsym ) OutChar(wsym); OutLong(value, #ifdef __debug__ debugmode ? 16 : #endif 10); out_tagoff(COLOR_ERROR); char tmpstr[32]; char *end = set_output_ptr(p); size_t len = end - p; qstrncpy(tmpstr, p, qmin(len+1, sizeof(tmpstr))); return chkOutLine(tmpstr, tag_strlen(tmpstr)); }
//---------------------------------------------------------------------- static size_t putLine(void) { color_t color = COLOR_NONE; out_zero(); if ( g_bufbeg != NULL ) { char *p = strrchr(g_bufbeg, COLOR_ON); if ( p != NULL && p[1] && strchr(p+2, COLOR_OFF) == NULL ) // second - PARANOYA { color = (color_t)*(p + 1); out_tagoff(color); } } out_symbol('\\'); if ( change_line(curpos != 0 && !no_prim) ) return 0; curpos = 0; if ( color != COLOR_NONE ) out_tagon(color); ref_pos = get_output_ptr(); return maxpos; }
//---------------------------------------------------------------------- static size_t putLine(void) { register color_t ntag = _CURCOL; out_zero(); { register char *p = strrchr(bufbeg, COLOR_ON); if ( p && p[1] && !strchr(p+2, COLOR_OFF) ) { // second - PARANOYA ntag = (color_t)*(p + 1); out_tagoff(ntag); } } out_symbol('\\'); if ( change_line(curpos != 0 && !no_prim)) return(0 ); curpos = 0; #ifdef __BORLANDC__ #if _CURCOL != 0 #error #endif #endif if ( ntag) out_tagon(ntag ); ref_pos = get_output_ptr(); return(maxpos); }
int dline_add(dline_t * dl, ea_t ea, char options) { char buf[256]; char tmp[256]; char dis[256]; char addr[30]; char * dll; int len; flags_t f; buf[0] = '\0'; f = getFlags(ea); generate_disasm_line(ea, dis, sizeof(dis)); decode_insn(ea); init_output_buffer(buf, sizeof(buf)); // Adds block label if (has_dummy_name(f)) { get_nice_colored_name(ea,tmp,sizeof(tmp),GNCN_NOSEG|GNCN_NOFUNC); out_snprintf("%s", tmp); out_line(":\n", COLOR_DATNAME); } if (options) { qsnprintf(addr, sizeof(addr), "%a", ea); out_snprintf("%s ", addr); } out_insert(get_output_ptr(), dis); term_output_buffer(); len = strlen(buf); if (dl->available < (len+3)) { dll = (char *)qrealloc(dl->lines, sizeof(char*) * (dl->num+len+256)); if (!dll) return -1; dl->available = len+256; dl->lines = dll; } if (dl->num) { dl->lines[dl->num] = '\n'; dl->num++; } memcpy(&dl->lines[dl->num], buf, len); dl->available -= len+1; dl->num += len; dl->lines[dl->num] = '\0'; return 0; }
//---------------------------------------------------------------------- inline void out_zero(void) { *get_output_ptr() = '\0'; }