Esempio n. 1
0
OVL_EXTERN  bool    IOGetLine( a_window wnd, wnd_row row, wnd_piece piece, wnd_line_piece *line )
{
    io_window   *io = WndIO( wnd );
//    bool        ret;
    io_location *curr;
    int         i;
    mad_radix   old_radix, new_radix;
    size_t      max;

    if( row >= io->num_rows )
        return( false );
    curr = &io->list[row];
//    ret = true;
    line->text = TxtBuff;
    switch( piece ) {
    case PIECE_READ:
        SetGadgetLine( wnd, line, GADGET_READ );
        return( true );
    case PIECE_WRITE:
        SetGadgetLine( wnd, line, GADGET_WRITE );
        line->indent = MaxGadgetLength;
        return( true );
    case PIECE_ADDRESS:
        AddrToIOString( &curr->addr, TxtBuff, TXT_LEN );
        line->indent = 2 * MaxGadgetLength;
        return( true );
    case PIECE_VALUE:
        new_radix = IOData.info[curr->type].piece_radix;
        old_radix = NewCurrRadix( new_radix );
        line->indent = 2 * MaxGadgetLength + 10 * WndMaxCharX( wnd );
        if( curr->value_known ) {
            max = TXT_LEN;
            MADTypeHandleToString( new_radix, IOData.info[curr->type].mth, &curr->value, TxtBuff, &max );
        } else {
            for( i = 0; i < IOData.info[curr->type].item_width; ++i ) {
                TxtBuff[i] = '?';
            }
            TxtBuff[i] = NULLCHAR;
        }
        NewCurrRadix( old_radix );
        return( true );
    default:
        return( false );
    }
}
Esempio n. 2
0
char *FmtStr( char *buff, const char *fmt, va_list args )
{
    char                *ptr;
    unsigned            len;
    long                val;
    address             addr;
    char                *res;
    sym_handle          *sym;
    char                save_buff[UTIL_LEN + 1];

    while( *fmt != NULLCHAR ) {
        if( *fmt != '%' ) {
            *buff = *fmt;
            ++buff;
        } else {
            ++fmt;
            switch( *fmt ) {
            case 'c':
                val = va_arg( args, int );
                *buff++ = val;
                break;
            case 's':
                ptr = va_arg( args, char * );
                buff = StrCopy( ptr, buff );
                break;
            case 't':
                ptr = va_arg( args, char * );
                len = va_arg( args, unsigned );
                memcpy( buff, ptr, len );
                buff += len;
                break;
            case 'l':
                addr = va_arg( args, address );
                buff = StrAddr( &addr, buff, TXT_LEN ); // nyi - overflow?
                res = LineAddr( &addr, save_buff, sizeof( save_buff ) );
                if( res != NULL ) {
                    *buff++ = '(';
                    buff = StrCopy( save_buff, buff );
                    *buff++ = ')';
                }
                break;
            case 'A':
                addr = va_arg( args, address );
                buff = UniqStrAddr( &addr, buff, TXT_LEN ); // nyi - overflow?
                break;
            case 'a':
                addr = va_arg( args, address );
                buff = StrAddr( &addr, buff, TXT_LEN ); // nyi - overflow?
                break;
            case 'p':
                addr = va_arg( args, address );
                buff = AddrToIOString( &addr, buff, TXT_LEN ); // nyi - overflow?
                break;
            case 'e':
                val = va_arg( args, unsigned );
                buff = SysErrMsg( val, buff );
                break;
            case 'U':
                buff = CnvULongDec( va_arg( args, unsigned long), buff, TXT_LEN );
                break;
            case 'd':
                val = va_arg( args, int );
                buff = CnvLongDec( val, buff, TXT_LEN );
                break;
            case 'u':
                val = va_arg( args, unsigned );
                buff = CnvULongDec( val, buff, TXT_LEN );
                break;
            case '%':
                *buff++ = '%';
                break;
            case 'o':
                val = va_arg( args, long );
                if( val < 0 ) {
                    *buff++ = '-';
                    val = -val;
                } else {
                    *buff++ = '+';
                }
                buff = AddHexSpec( buff );
                buff = CnvULongHex( val, buff, TXT_LEN );
                break;
            case 'S':
                sym = va_arg( args, sym_handle * );
                buff += SymName( sym, NULL, SN_SOURCE, buff, TXT_LEN );
                break;
            }
        }
        ++fmt;
    }
    *buff = NULLCHAR;
    return( buff );
}