Пример #1
0
void vorbis_ParseComment( es_format_t *p_fmt, vlc_meta_t **pp_meta,
        const uint8_t *p_data, int i_data,
        int *i_attachments, input_attachment_t ***attachments,
        int *i_cover_score, int *i_cover_idx,
        int *i_seekpoint, seekpoint_t ***ppp_seekpoint,
        float (* ppf_replay_gain)[AUDIO_REPLAY_GAIN_MAX],
        float (* ppf_replay_peak)[AUDIO_REPLAY_GAIN_MAX] )
{
    int n;
    int i_comment;

    if( i_data < 8 )
        return;

    n = GetDWLE(p_data); RM(4);
    if( n < 0 || n > i_data )
        return;
#if 0
    if( n > 0 )
    {
        /* TODO report vendor string ? */
        char *psz_vendor = psz_vendor = strndup( p_data, n );
        free( psz_vendor );
    }
#endif
    RM(n);

    if( i_data < 4 )
        return;

    i_comment = GetDWLE(p_data); RM(4);
    if( i_comment <= 0 )
        return;

    /* */
    vlc_meta_t *p_meta = *pp_meta;
    if( !p_meta )
        *pp_meta = p_meta = vlc_meta_New();
    if( !p_meta )
        return;

    /* */
    bool hasTitle        = false;
    bool hasArtist       = false;
    bool hasGenre        = false;
    bool hasCopyright    = false;
    bool hasAlbum        = false;
    bool hasTrackNum     = false;
    bool hasDescription  = false;
    bool hasRating       = false;
    bool hasDate         = false;
    bool hasLanguage     = false;
    bool hasPublisher    = false;
    bool hasEncodedBy    = false;
    bool hasTrackTotal   = false;

    chapters_array_t chapters_array = { 0, NULL };

    for( ; i_comment > 0; i_comment-- )
    {
        char *psz_comment;
        if( i_data < 4 )
            break;
        n = GetDWLE(p_data); RM(4);
        if( n > i_data )
            break;
        if( n <= 0 )
            continue;

        psz_comment = strndup( (const char*)p_data, n );
        RM(n);

        EnsureUTF8( psz_comment );

#define IF_EXTRACT(txt,var) \
    if( !strncasecmp(psz_comment, txt, strlen(txt)) ) \
    { \
        const char *oldval = vlc_meta_Get( p_meta, vlc_meta_ ## var ); \
        if( oldval && has##var) \
        { \
            char * newval; \
            if( asprintf( &newval, "%s,%s", oldval, &psz_comment[strlen(txt)] ) == -1 ) \
                newval = NULL; \
            vlc_meta_Set( p_meta, vlc_meta_ ## var, newval ); \
            free( newval ); \
        } \
        else \
            vlc_meta_Set( p_meta, vlc_meta_ ## var, &psz_comment[strlen(txt)] ); \
        has##var = true; \
    }

#define IF_EXTRACT_ONCE(txt,var) \
    if( !strncasecmp(psz_comment, txt, strlen(txt)) && !has##var ) \
    { \
        vlc_meta_Set( p_meta, vlc_meta_ ## var, &psz_comment[strlen(txt)] ); \
        has##var = true; \
    }

#define IF_EXTRACT_FMT(txt,var,fmt,target) \
    IF_EXTRACT(txt,var)\
    if( fmt && !strncasecmp(psz_comment, txt, strlen(txt)) )\
        {\
            if ( fmt->target ) free( fmt->target );\
            fmt->target = strdup(&psz_comment[strlen(txt)]);\
        }

        IF_EXTRACT("TITLE=", Title )
        else IF_EXTRACT("ARTIST=", Artist )
        else IF_EXTRACT("GENRE=", Genre )
        else IF_EXTRACT("COPYRIGHT=", Copyright )
        else IF_EXTRACT("ALBUM=", Album )
        else if( !hasTrackNum && !strncasecmp(psz_comment, "TRACKNUMBER=", strlen("TRACKNUMBER=" ) ) )
        {
            /* Yeah yeah, such a clever idea, let's put xx/xx inside TRACKNUMBER
             * Oh, and let's not use TRACKTOTAL or TOTALTRACKS... */
            short unsigned u_track, u_total;
            if( sscanf( &psz_comment[strlen("TRACKNUMBER=")], "%hu/%hu", &u_track, &u_total ) == 2 )
            {
                char str[6];
                snprintf(str, 6, "%u", u_track);
                vlc_meta_Set( p_meta, vlc_meta_TrackNumber, str );
                hasTrackNum = true;
                snprintf(str, 6, "%u", u_total);
                vlc_meta_Set( p_meta, vlc_meta_TrackTotal, str );
                hasTrackTotal = true;
            }
            else
            {
                vlc_meta_Set( p_meta, vlc_meta_TrackNumber, &psz_comment[strlen("TRACKNUMBER=")] );
                hasTrackNum = true;
            }
        }
        else IF_EXTRACT_ONCE("TRACKTOTAL=", TrackTotal )
        else IF_EXTRACT_ONCE("TOTALTRACKS=", TrackTotal )
        else IF_EXTRACT("DESCRIPTION=", Description )
        else IF_EXTRACT("COMMENT=", Description )
        else IF_EXTRACT("COMMENTS=", Description )
        else IF_EXTRACT("RATING=", Rating )
        else IF_EXTRACT("DATE=", Date )
        else IF_EXTRACT_FMT("LANGUAGE=", Language, p_fmt, psz_language )
        else IF_EXTRACT("ORGANIZATION=", Publisher )
        else IF_EXTRACT("ENCODER=", EncodedBy )
        else if( !strncasecmp( psz_comment, "METADATA_BLOCK_PICTURE=", strlen("METADATA_BLOCK_PICTURE=")))
        {
            if( attachments == NULL )
                continue;

            uint8_t *p_picture;
            size_t i_size = vlc_b64_decode_binary( &p_picture, &psz_comment[strlen("METADATA_BLOCK_PICTURE=")]);
            input_attachment_t *p_attachment = ParseFlacPicture( p_picture,
                i_size, *i_attachments, i_cover_score, i_cover_idx );
            free( p_picture );
            if( p_attachment )
            {
                TAB_APPEND_CAST( (input_attachment_t**),
                    *i_attachments, *attachments, p_attachment );
            }
        }
        else if ( ppf_replay_gain && ppf_replay_peak && !strncmp(psz_comment, "REPLAYGAIN_", 11) )
        {
            char *p = strchr( psz_comment, '=' );
            if (!p) continue;
            if ( !strncasecmp(psz_comment, "REPLAYGAIN_TRACK_GAIN=", 22) )
            {
                (*ppf_replay_gain)[AUDIO_REPLAY_GAIN_TRACK] = us_atof( ++p );
            }
            else if ( !strncasecmp(psz_comment, "REPLAYGAIN_ALBUM_GAIN=", 22) )
            {
                (*ppf_replay_gain)[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( ++p );
            }
            else if ( !strncasecmp(psz_comment, "REPLAYGAIN_ALBUM_PEAK=", 22) )
            {
                (*ppf_replay_peak)[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( ++p );
            }
            else if ( !strncasecmp(psz_comment, "REPLAYGAIN_TRACK_PEAK=", 22) )
            {
                (*ppf_replay_peak)[AUDIO_REPLAY_GAIN_TRACK] = us_atof( ++p );
            }
        }
        else if( !strncasecmp(psz_comment, "CHAPTER", 7) )
        {
            unsigned int i_chapt;
            seekpoint_t *p_seekpoint = NULL;

            for( int i = 0; psz_comment[i] && psz_comment[i] != '='; i++ )
                if( psz_comment[i] >= 'a' && psz_comment[i] <= 'z' )
                    psz_comment[i] -= 'a' - 'A';

            if( strstr( psz_comment, "NAME=" ) &&
                    sscanf( psz_comment, "CHAPTER%uNAME=", &i_chapt ) == 1 )
            {
                char *p = strchr( psz_comment, '=' );
                p_seekpoint = getChapterEntry( i_chapt, &chapters_array );
                if ( !p || ! p_seekpoint ) continue;
                if ( ! p_seekpoint->psz_name )
                    p_seekpoint->psz_name = strdup( ++p );
            }
            else if( sscanf( psz_comment, "CHAPTER%u=", &i_chapt ) == 1 )
            {
                unsigned int h, m, s, ms;
                char *p = strchr( psz_comment, '=' );
                if( p && sscanf( ++p, "%u:%u:%u.%u", &h, &m, &s, &ms ) == 4 )
                {
                    p_seekpoint = getChapterEntry( i_chapt, &chapters_array );
                    if ( ! p_seekpoint ) continue;
                    p_seekpoint->i_time_offset =
                      (((int64_t)h * 3600 + (int64_t)m * 60 + (int64_t)s) * 1000 + ms) * 1000;
                }
            }
        }
        else if( strchr( psz_comment, '=' ) )
        {
            /* generic (PERFORMER/LICENSE/ORGANIZATION/LOCATION/CONTACT/ISRC,
             * undocumented tags and replay gain ) */
            char *p = strchr( psz_comment, '=' );
            *p++ = '\0';

            for( int i = 0; psz_comment[i]; i++ )
                if( psz_comment[i] >= 'a' && psz_comment[i] <= 'z' )
                    psz_comment[i] -= 'a' - 'A';

            vlc_meta_AddExtra( p_meta, psz_comment, p );
        }
#undef IF_EXTRACT
        free( psz_comment );
    }
Пример #2
0
KONAMI_INLINE UINT32 RM16( UINT32 Addr )
{
	UINT32 result = RM(Addr) << 8;
	return result | RM((Addr+1)&0xffff);
}
Пример #3
0
// --------------------------------------------------------------
// CxaTM_RMMessage::release_from_RMmsgList
// Purpose: Release this meesage from the RMs msgList.
// --------------------------------------------------------------
void CxaTM_RMMessage::release_from_RMmsgList()
{
    // Remove the message from the RMs message list but reuse it for the retry
    RM()->msgList()->remove(msgid());
    msgid(0);
} //CxaTM_RMMessage::release_from_RMmsgList
Пример #4
0
INLINE UINT32 RM16( konami_state *cpustate, UINT32 Addr )
{
	UINT32 result = RM(cpustate, Addr) << 8;
	return result | RM(cpustate, (Addr+1)&0xffff);
}
Пример #5
0
UINT32 m6800_cpu_device::RM16(UINT32 Addr )
{
	UINT32 result = RM(Addr) << 8;
	return result | RM((Addr+1)&0xffff);
}
Пример #6
0
INLINE void rd_s_handler_b( UINT8 *b )
{
	SP_INC;
	*b = RM( S );
}
Пример #7
0
// decodes operand
static void decopr(x86_opr *out, decstruct *d, u4 o) {
	u4 t = OPRTOK(o);

	if(ISREG(t)) {
isreg:
		if(t < ES) { // gpr
			int s = GETTYPE(o);
			if(!d->opr32 || s == WORD) t += AX-eAX; // 16-bit register
			else if(s == BYTE) t += AL-eAX; // 8-bit register
		}
		out->tok = X86_OREG;
		out->reg = t;
	} else if(ISMODRM(t)) {
		if(ISMODRM_REG(t) || R == t || (M != t && MOD(d->modrm) == 3)) {
			o = ISMODRM_REG(t) ? REG(d->modrm) : RM(d->modrm);
			if(S == t) o += ES; // segment register
			else if(T == t) o += TR0;	// test register
			else if(D == t) o += DR0;	// debug register
			else o += eAX;
			t = o;
			goto isreg;
		}
		// else it is a memory reference
		memcpy(&out->mem, &d->mem, sizeof(d->mem));
		out->tok = X86_OMEM;
		out->mem.size = GETTYPE(o);
	} else switch(t) {
		case I:
			out->tok = X86_OVAL;
			memcpy(&out->val, &d->imm, sizeof(d->imm));
			break;
		case J:
			out->tok = X86_OVAL;
			memcpy(&out->val, &d->imm, sizeof(d->imm));
			out->val.sign = 1;
			break;
		case O: case A: // direct address or ds:offset
			out->tok = X86_OMEM;
			if(t == A) out->mem.disp.val = LSB16(d->q)*16;
			else out->mem.seg = DS; // offset in ds
			d->q += 2;
			if(d->adr32) {
				out->mem.disp.val += LSB32(d->q);
				d->q += 4;
			} else {
				out->mem.disp.val += LSB16(d->q);
				d->q += 2;
			}
			if(!(out->mem.size = GETTYPE(o)))
				out->mem.size = d->opr32 ? DWORD : WORD;
			break;
		case X: case Y: // string instruction
			break;
		default:
			if(t >= CONST_0 && t <= CONST_LAST) {
				out->tok = X86_OVAL;
				out->val.val = t-CONST_0;
				out->val.sign = 0;
				out->val.size = GETTYPE(o);
			} else out->tok = X86_ONON;
			break;
	}
	return;
}
Пример #8
0
UINT32 m6809_base_device::RM16(UINT32 addr)
{
	UINT32 result = RM(addr) << 8;
	return result | RM((addr+1)&0xffff);
}
Пример #9
0
/* Main table driver                                                      */
static void percent(char type, char subtype)
{
  int32 vofs;
  char *name;
  int extend = (addrsize == 32) ? 4 : 2;
  char c;

  switch (type) {
  case 'A':                          /* direct address */
       outhex(subtype, extend, 0, addrsize, 0);
       break;

  case 'C':                          /* reg(r/m) picks control reg */
       uprintf("C%d", REG(modrm()));
       must_do_size = 0;
       break;

  case 'D':                          /* reg(r/m) picks debug reg */
       uprintf("D%d", REG(modrm()));
       must_do_size = 0;
       break;

  case 'E':                          /* r/m picks operand */
       do_modrm(subtype);
       break;

  case 'G':                          /* reg(r/m) picks register */
       if (subtype == 'F')                 /* 80*87 operand?   */
         reg_name(RM(modrm()), subtype);
       else
         reg_name(REG(modrm()), subtype);
       must_do_size = 0;
       break;

  case 'I':                            /* immed data */
       outhex(subtype, 0, 0, opsize, 0);
       break;

  case 'J':                            /* relative IP offset */
       switch(bytes(subtype)) {              /* sizeof offset value */
       case 1:
            vofs = (int8)getbyte();
            break;
       case 2:
            vofs = getbyte();
            vofs += getbyte()<<8;
            vofs = (int16)vofs;
            break;
       case 4:
            vofs = (word32)getbyte();           /* yuk! */
            vofs |= (word32)getbyte() << 8;
            vofs |= (word32)getbyte() << 16;
            vofs |= (word32)getbyte() << 24;
            break;
       }
       name = addr_to_hex(vofs+instruction_offset,1);
       uprintf("%s", name);
       break;

  case 'K':
       if (do_distance==0)
         break;
       switch (subtype) {
       case 'f':
            ua_str("far ");
            break;
       case 'n':
            ua_str("near ");
            break;
       case 's':
            ua_str("short ");
            break;
       }
       break;

  case 'M':                            /* r/m picks memory */
       do_modrm(subtype);
       break;

  case 'O':                            /* offset only */
       ua_str("%p:[");
       outhex(subtype, extend, 0, addrsize, 0);
       uputchar(']');
       break;

  case 'P':                            /* prefix byte (rh) */
       ua_str("%p:");
       break;

  case 'R':                            /* mod(r/m) picks register */
       reg_name(REG(modrm()), subtype);      /* rh */
       must_do_size = 0;
       break;

  case 'S':                            /* reg(r/m) picks segment reg */
       uputchar("ecsdfg"[REG(modrm())]);
       uputchar('s');
       must_do_size = 0;
       break;

  case 'T':                            /* reg(r/m) picks T reg */
       uprintf("tr%d", REG(modrm()));
       must_do_size = 0;
       break;

  case 'X':                            /* ds:si type operator */
       uprintf("ds:[");
       if (addrsize == 32)
         uputchar('e');
       uprintf("si]");
       break;

  case 'Y':                            /* es:di type operator */
       uprintf("es:[");
       if (addrsize == 32)
         uputchar('e');
       uprintf("di]");
       break;

  case '2':                            /* old [pop cs]! now indexes */
       ua_str(second[getbyte()]);      /* instructions in 386/486   */
       break;

  case 'g':                            /* modrm group `subtype' (0--7) */
       ua_str(groups[subtype-'0'][REG(modrm())]);
       break;

  case 'd':                             /* sizeof operand==dword? */
       if (opsize == 32)
         uputchar('d');
       uputchar(subtype);
       break;

  case 'w':                             /* insert explicit size specifier */
       if (opsize == 32)
         uputchar('d');
       else
         uputchar('w');
       uputchar(subtype);
       break;

  case 'e':                         /* extended reg name */
       if (opsize == 32) {
         if (subtype == 'w')
           uputchar('d');
         else {
           uputchar('e');
           uputchar(subtype);
         }
       } else
         uputchar(subtype);
       break;

  case 'f':                    /* '87 opcode */
       floating_point(subtype-'0');
       break;

  case 'j':
       if (addrsize==32 || opsize==32) /* both of them?! */
         uputchar('e');
       break;

  case 'p':                    /* prefix byte */
       switch (subtype)  {
       case 'c':
       case 'd':
       case 'e':
       case 'f':
       case 'g':
       case 's':
            prefix = subtype;
            c = getbyte();
            wordop = c & 1;
            ua_str(opmap1[(unsigned char)c]);
            break;
       case ':':
            if (prefix)
              uprintf("%cs:", prefix);
            break;
       case ' ':
            c = getbyte();
            wordop = c & 1;
            ua_str(opmap1[(unsigned char)c]);
            break;
       }
       break;

  case 's':                           /* size override */
       switch (subtype) {
       case 'a':
            addrsize = 48 - addrsize;
            c = getbyte();
            wordop = c & 1;
            ua_str(opmap1[(unsigned char)c]);
/*            ua_str(opmap1[getbyte()]); */
            break;
       case 'o':
            opsize = 48 - opsize;
            c = getbyte();
            wordop = c & 1;
            ua_str(opmap1[(unsigned char)c]);
/*            ua_str(opmap1[getbyte()]); */
            break;
       }
       break;
   }
}
Пример #10
0
/* $12 ILLEGAL */
M6800_INLINE void undoc1 (void)
{
	X += RM( S + 1 );
}
Пример #11
0
/*------------------------------------------------------------------------*/
static void do_modrm(char subtype)
{
  int mod = MOD(modrm());
  int rm = RM(modrm());
  int extend = (addrsize == 32) ? 4 : 2;

  if (mod == 3) { /* specifies two registers */
    reg_name(rm, subtype);
    return;
  }
  if (must_do_size) {
    if (wordop) {
      if (addrsize==32 || opsize==32) {       /* then must specify size */
        ua_str("dword ptr ");
      } else {
        ua_str("word ptr ");
      }
    } else {
      ua_str("byte ptr ");
    }
  }
  if ((mod == 0) && (rm == 5) && (addrsize == 32)) {/* mem operand with 32 bit ofs */
    ua_str("%p:[");
    outhex('d', extend, 0, addrsize, 0);
    uputchar(']');
    return;
  }
  if ((mod == 0) && (rm == 6) && (addrsize == 16)) { /* 16 bit dsplcmnt */
    ua_str("%p:[");
    outhex('w', extend, 0, addrsize, 0);
    uputchar(']');
    return;
  }
  if ((addrsize != 32) || (rm != 4))
    ua_str("%p:[");
  if (addrsize == 16) {
    switch (rm) {
    case 0: uprintf("bx+si"); break;
    case 1: uprintf("bx+di"); break;
    case 2: uprintf("bp+si"); break;
    case 3: uprintf("bp+di"); break;
    case 4: uprintf("si"); break;
    case 5: uprintf("di"); break;
    case 6: uprintf("bp"); break;
    case 7: uprintf("bx"); break;
    }
  } else {
    switch (rm) {
    case 0: uprintf("eax"); break;
    case 1: uprintf("ecx"); break;
    case 2: uprintf("edx"); break;
    case 3: uprintf("ebx"); break;
    case 4: do_sib(mod); break;
    case 5: uprintf("ebp"); break;
    case 6: uprintf("esi"); break;
    case 7: uprintf("edi"); break;
    }
  }
  switch (mod) {
  case 1:
       outhex('b', extend, 1, addrsize, 0);
       break;
  case 2:
       outhex('v', extend, 1, addrsize, 1);
       break;
  }
  uputchar(']');
}
Пример #12
0
void m6805_base_device::rd_s_handler_b(uint8_t *b)
{
	SP_INC;
	*b = RM( S );
}
Пример #13
0
input_attachment_t* ParseFlacPicture( const uint8_t *p_data, int i_data,
    int i_attachments, int *i_cover_score, int *i_cover_idx )
{
    /* TODO: Merge with ID3v2 copy in modules/meta_engine/taglib.cpp. */
    static const char pi_cover_score[] = {
        0,  /* Other */
        5,  /* 32x32 PNG image that should be used as the file icon */
        4,  /* File icon of a different size or format. */
        20, /* Front cover image of the album. */
        19, /* Back cover image of the album. */
        13, /* Inside leaflet page of the album. */
        18, /* Image from the album itself. */
        17, /* Picture of the lead artist or soloist. */
        16, /* Picture of the artist or performer. */
        14, /* Picture of the conductor. */
        15, /* Picture of the band or orchestra. */
        9,  /* Picture of the composer. */
        8,  /* Picture of the lyricist or text writer. */
        7,  /* Picture of the recording location or studio. */
        10, /* Picture of the artists during recording. */
        11, /* Picture of the artists during performance. */
        6,  /* Picture from a movie or video related to the track. */
        1,  /* Picture of a large, coloured fish. */
        12, /* Illustration related to the track. */
        3,  /* Logo of the band or performer. */
        2   /* Logo of the publisher (record company). */
    };

    int i_len;
    int i_type;
    char *psz_mime = NULL;
    char psz_name[128];
    char *psz_description = NULL;
    input_attachment_t *p_attachment = NULL;

    if( i_data < 4 + 3*4 )
        return NULL;
#define RM(x) do { i_data -= (x); p_data += (x); } while(0)

    i_type = GetDWBE( p_data ); RM(4);
    i_len = GetDWBE( p_data ); RM(4);

    if( i_len < 0 || i_data < i_len + 4 )
        goto error;
    psz_mime = strndup( (const char*)p_data, i_len ); RM(i_len);
    i_len = GetDWBE( p_data ); RM(4);
    if( i_len < 0 || i_data < i_len + 4*4 + 4)
        goto error;
    psz_description = strndup( (const char*)p_data, i_len ); RM(i_len);
    EnsureUTF8( psz_description );
    RM(4*4);
    i_len = GetDWBE( p_data ); RM(4);
    if( i_len < 0 || i_len > i_data )
        goto error;

    /* printf( "Picture type=%d mime=%s description='%s' file length=%d\n",
             i_type, psz_mime, psz_description, i_len ); */

    snprintf( psz_name, sizeof(psz_name), "picture%d", i_attachments );
    if( !strcasecmp( psz_mime, "image/jpeg" ) )
        strcat( psz_name, ".jpg" );
    else if( !strcasecmp( psz_mime, "image/png" ) )
        strcat( psz_name, ".png" );

    p_attachment = vlc_input_attachment_New( psz_name, psz_mime,
            psz_description, p_data, i_data );

    if( i_type >= 0 && (unsigned int)i_type < sizeof(pi_cover_score)/sizeof(pi_cover_score[0]) &&
        *i_cover_score < pi_cover_score[i_type] )
    {
        *i_cover_idx = i_attachments;
        *i_cover_score = pi_cover_score[i_type];
    }

error:
    free( psz_mime );
    free( psz_description );
    return p_attachment;
}
Пример #14
0
int decode_rm32(Bit32u *addr, u_int *is_addr, u_int *regop, unsigned char **csp)
{
    int rm, mod;
    Bit8u op;

    ASSERT(addr && is_addr && regop && csp);

    op = **csp;
    rm = RM(op);
    mod = MOD(op);
    *regop = REG_OPCODE(op);
    *is_addr = 1;

    (*csp) ++;		/* past RM */

    switch (mod) {
    case 0:
    {
	switch (rm) {
	case 0:
	case 1:
	case 2:
	case 3:
	case 6:
	case 7:
	    *addr = get_reg(rm, 4);
	    break;
	case 4:
	    *addr = calculate_sib(csp, mod);	/* past SIB and any disp */
	    break;
	case 5:
	    *addr = *(Bit32u *)(*csp);
	    (*csp) += 4;	/* past disp32 */
	    break;
	}
	break;
    }
    case 1:
    {
	switch (rm) {
	case 0:
	case 1:
	case 2:
	case 3:
	case 5:
	case 6:
	case 7:
	    *addr = get_reg(rm, 4);
	    break;
	case 4:
	    *addr = calculate_sib(csp, mod);	/* past SIB and any disp */
	    break;
	}
	*addr += **csp;
	(*csp) ++;		/* past disp8 */

	break;
    }
    case 2:
    {
	switch (rm) {
	case 0:
	case 1:
	case 2:
	case 3:
	case 5:
	case 6:
	case 7:
	    *addr = get_reg(rm, 4);
	    break;
	case 4:
	    *addr = calculate_sib(csp, mod);	/* past SIB and any disp */
	    break;
	}
	*addr += *(Bit32u*)(*csp);
	(*csp) += 4;		/* past disp32 */
	break;
    }
    case 3:
	*addr = rm;
	*is_addr = 0;
	break;
    default:
	leaveemu(ERR_ASSERT);
    }
    
    return 0;
}
Пример #15
0
int x86dis(x86_inst *ins, u1 *p, bool bits32) {
	decstruct d;
	opcode *o; // opcode byte

	memset(ins, 0, sizeof(*ins));
	memset(&d, 0, sizeof(d));
	d.opr32 = bits32;
	d.adr32 = bits32;
	d.q = d.p = p;

	o = &map[*d.q++];
	while(o->t&PREFIX_MASK) { // while prefix byte
		switch(o->t) {
			case X86_PREFIX_SEGOVR:
				d.segovr = o->o1;
				break;
			case X86_PREFIX_OPROVR:	d.opr32 = !d.opr32;; break;
			case X86_PREFIX_ADROVR:	d.adr32 = !d.adr32; break;
			case X86_PREFIX_REPE: case X86_PREFIX_REPNE:
									ins->prefix = o->t;
									break;
			default: break;
		}
		if(o->t == X86_PREFIX_0F) o = &map0f[*d.q++];
		else o = &map[*d.q++];
	}

	d.o1 = o->o1;
	d.o2 = o->o2;
	d.o3 = o->o3;
	d.of = o->f;

	if(d.of & MODRM) { // instruction has mod/rm byte
		int mod, rm, reg;
		d.modrm = *d.q++;
		mod = MOD(d.modrm);
		rm = RM(d.modrm);
		reg = REG(d.modrm);
		if(d.of & EXT) { // opcode is extended by modrm
			o = &mapext[(d.o3<<3)|reg];
			d.o1 |= o->o1;
			d.o2 |= o->o2;
			d.o3 = o->o3;
			d.of |= o->f;
		}
		memset(&d.mem, 0, sizeof(d.mem));

		if(mod != 3) {
			d.mem.seg = DS;
			if(d.opr32) { // 32-bit case
				if(rm == 4) { // has sib byte
					u1 sib = *d.q++;
					if(mod == 0 && RM(sib) == 5) { // ds:flat_offset_32bit
						d.mem.disp.val = LSB32(d.q);
						d.mem.disp.sign = 0;
						d.mem.disp.size = 4;
						d.q += 4;
					}
					if(REG(sib) != 4) { // has scaled index
						d.mem.index = REG(sib);
						d.mem.scale = 2<<MOD(sib);
					}
					d.mem.base = RM(sib)+eAX;
				} else if(mod || rm != 5) {
					d.mem.base = rm+eAX;
				}

				if(mod == 1) {
					d.mem.disp.val = *d.q++;
					d.mem.disp.sign = 1;
					d.mem.disp.size = 1;
				} else if(mod == 2) {
					d.mem.disp.val = LSB32(d.q);
					d.mem.disp.sign = 0;
					d.mem.disp.size = 4;
					d.q += 4;
				} else if(mod == 0 && rm == 5) { // ds:flat_offset_32bit
					d.mem.disp.val = LSB32(d.q);
					d.mem.disp.sign = 0;
					d.mem.disp.size = 4;
					d.q += 4;
				}
			} else { // 16-bit case
				if(mod == 0 && rm == 6) { // ds:flat_offset_16bit
					d.mem.disp.val = LSB16(d.q);
					d.mem.disp.sign = 0;
					d.mem.disp.size = 2;
					d.q += 2;
				} else {
					if(mod == 1) {
						d.mem.disp.val = *d.q++;
						d.mem.disp.sign = 1;
						d.mem.disp.size = 1;
					} else if(mod == 2) {
						d.mem.disp.val = LSB16(d.q);
						d.mem.disp.sign = 0;
						d.mem.disp.size = 2;
						d.q += 2;
					}
					switch(rm) {
						case 0: // [BX+SI]
							d.mem.base = BX;
							d.mem.index = SI;
							break;
						case 1: // [BX+DI]
							d.mem.base = BX;
							d.mem.index = DI;
							break;
						case 2: // [BP+SI]
							d.mem.base = BP;
							d.mem.index = SI;
							break;
						case 3: // [BP+DI]
							d.mem.base = BP;
							d.mem.index = DI;
							break;
						case 4: // [SI]
							d.mem.base = SI;
							break;
						case 5: // [DI]
							d.mem.base = DI;
							break;
						case 6: // [SS:BP]
							d.mem.base = BP;
							d.mem.seg = SS; // BP defaults to SS
							break;
						case 7: // [BX]
							d.mem.base = BX;
							break;
						default:
							break;
					}
					if(d.segovr) d.mem.seg = d.segovr;
				}
			}
		}
	}

	if(o->t == X86_NH) return X86_DIS_NH;

	if(d.of & IMM) { // instruction takes immediate value
		if(BYTE == o->immsz) { // 1-byte immediate
			d.imm.val = *d.q++;
			d.imm.size = 1;
		} else if(d.opr32 && WORD != o->immsz) {
			d.imm.val = LSB32(d.q);
			d.imm.size = 4;
			d.q += 4;
		} else {
			d.imm.val = LSB16(d.q);
			d.imm.size = 2;
			d.q += 2;
		}
	}


	//printf("%s\n", o->m); fflush(stdout);
	//printf("hello\n"); fflush(stdout);
	if(d.of & SPEC) {
		switch(o->t) {
			case X86_ENTER:
				ins->argc = 2;
				ins->argv[0].tok = X86_OVAL;
				ins->argv[0].val.val = LSB16(d.q);
				ins->argv[0].val.size = WORD;
				d.q += 2;
				ins->argv[0].tok = X86_OVAL;
				ins->argv[0].val.val = *d.q++;
				ins->argv[0].val.size = BYTE;
				break;
			default:
				break;
		}
		/*if(strcmp(o->m, "lea")) {
		  }	
		  else*/;
	} else if(d.o1) {
		decopr(&ins->argv[0], &d, d.o1);
		if(d.o2) {
			decopr(&ins->argv[1], &d, d.o2);
			if(d.o3) {
				decopr(&ins->argv[2], &d, d.o3);
				ins->argc = 3;
			} else ins->argc = 2;
		} else ins->argc = 1;
	} else ins->argc = 0;
	ins->tok = o->t;
	ins->m = o->m;

	return (int)(d.q-d.p);
}
Пример #16
0
int decode_rm16(Bit32u *addr, u_int *is_addr, u_int *regop, unsigned char **csp)
{
    int rm, mod;
    Bit8u op;

    ASSERT(addr && is_addr && regop && csp);

    op = **csp;
    rm = RM(op);
    mod = MOD(op);
    *regop = REG_OPCODE(op);
    *is_addr = 1;

    (*csp) ++;		/* past RM */

    switch (mod) {
    case 0:
    {
	switch (rm) {
	case 0: *addr = _BX+_SI; break;
	case 1: *addr = _BX+_DI; break;
	case 2: *addr = _BP+_SI; break;
	case 3: *addr = _BP+_SI; break;
	case 4: *addr = _SI; break;
	case 5: *addr = _DI; break;
	case 6:
	    *addr = *(Bit16u*)(*csp);
	    (*csp) += 2; /* past disp16 */
	    break;
	case 7: *addr = _BX; break;
	}
	break;
    }
    case 1:
    {
	switch (rm) {
	case 0: *addr = _BX+_SI; break;
	case 1: *addr = _BX+_DI; break;
	case 2: *addr = _BP+_SI; break;
	case 3: *addr = _BP+_SI; break;
	case 4: *addr = _SI; break;
	case 5: *addr = _DI; break;
	case 6: *addr = _BP; break;
	case 7: *addr = _BX; break;
	}
	*addr += *(Bit8s*)(*csp);
	(*csp) ++;	/* past disp8 */
	break;
    }
    case 2:
    {
	switch (rm) {
	case 0: *addr = _BX+_SI; break;
	case 1: *addr = _BX+_DI; break;
	case 2: *addr = _BP+_SI; break;
	case 3: *addr = _BP+_SI; break;
	case 4: *addr = _SI; break;
	case 5: *addr = _DI; break;
	case 6: *addr = _BP; break;
	case 7: *addr = _BX; break;
	}
	*addr += *(Bit16s*)(*csp);
	(*csp) += 2;	/* past disp16 */
	break;
    }
    case 3:
	*addr = rm;
	*is_addr = 0;
	break;
    default:
	leaveemu(ERR_ASSERT);
    }

    return 0;
}
Пример #17
0
P1(PUBLIC pascal, void, SysError, short, errorcode)
{
    GrafPort alertport;
    Region viscliprgn;
    HIDDEN_RgnPtr rp;
    Rect r;
    struct adef *ap;
    char quickbytes[grafSize];
    INTEGER offsetx, offsety;
    Rect main_gd_rect;

#if defined (BINCOMPAT)
    LONGINT tmpa5;
#endif /* BINCOMPAT */

    main_gd_rect = PIXMAP_BOUNDS (GD_PMAP (MR (MainDevice)));

    if (!DSAlertTab) {
#if defined (CLIFF_CENTERING_ALGORITHM)
        DSAlertTab = CL((Ptr) &myalerttab);
        DSAlertRect.top    = CWC(64);
        DSAlertRect.left   = CWC(32);
        DSAlertRect.bottom = CWC(190);
        DSAlertRect.right  = CWC(480);
#else
        INTEGER screen_width = CW (main_gd_rect.right);
        INTEGER screen_height = CW (main_gd_rect.bottom);

        DSAlertTab = RM((Ptr) &myalerttab);
        DSAlertRect.top    = CW((screen_height - 126) / 3);
        DSAlertRect.left   = CW((screen_width - 448) / 2);
        DSAlertRect.bottom = CW(CW(DSAlertRect.top) + 126);
        DSAlertRect.right  = CW(CW(DSAlertRect.left) + 448);
#endif

        offsetx = CW (DSAlertRect.left) - 32;
        offsety = CW (DSAlertRect.top) - 64;
    }
    else {
        offsetx = offsety = 0;
    }

    /* IM-362 */
    /* 1. Save registers and Stack Pointer */
    /*	  NOT DONE YET... signal handlers sort of do that anyway */

    /* 2. Store errorcode in DSErrCode */
    DSErrCode = CW(errorcode);

    /* 3. If no Cx(DSAlertTab), bitch */
    if (!DSAlertTab) {
        write(2, "This machine thinks its a sadmac\n",
              sizeof("This machine thinks its a sadmac\n")-1);
        exit(255);
    }

    /* 4. Allocate and re-initialize QuickDraw */
#if defined (BINCOMPAT)
    a5 = (LONGINT) (long) US_TO_SYN68K (&tmpa5);
    CurrentA5 = (Ptr) (long) CL(a5);
#endif /* BINCOMPAT */
    InitGraf((Ptr) quickbytes + sizeof(quickbytes) - 4);
    ROMlib_initport(&alertport);
    SetPort(&alertport);
    InitCursor();
    rp.p = RM(&viscliprgn);
    alertport.visRgn = alertport.clipRgn = RM(&rp);
    viscliprgn.rgnSize = CWC(10);
#if 0 && !defined(MSDOS)
    viscliprgn.rgnBBox = DSAlertRect;
#else
    viscliprgn.rgnBBox = main_gd_rect;
#endif

    /* 5, 6. Draw alert box if the errorcode is >= 0 */
    TRAPBEGIN();
    if (errorcode < 0)
        errorcode = -errorcode;
    else {
        r = DSAlertRect;
        FillRect(&r, white);
#if defined (OLDSTYLEALERT)
        r.right = CW(CW(r.right) - (2));
        r.bottom = CW(CW(r.bottom) - (2));
        FrameRect(&r);
        PenSize(2, 2);
        MoveTo(CW(r.left)+2, CW(r.bottom));
        LineTo(CW(r.right), CW(r.bottom));
        LineTo(CW(r.right), CW(r.top)+2);
        PenSize(1, 1);
#else /* OLDSTYLEALERT */
        FrameRect(&r);
        InsetRect(&r, 3, 3);
        PenSize(2, 2);
        FrameRect(&r);
        PenSize(1, 1);
#endif /* OLDSTYLEALERT */
    }

    /* find appropriate entry */

    ap = (struct adef *) findid(errorcode);
    if (!ap)
        ap = (struct adef *) ((INTEGER *) MR(DSAlertTab) + 1);

    /* 7. text strings */
    drawtextstring(CW(ap->primetextid), offsetx, offsety);
    drawtextstring(CW(ap->secondtextid), offsetx, offsety);

    /* 8. icon */
    drawicon(CW(ap->iconid), offsetx, offsety);

    /* 9. TODO: figure out what to do with the proc ... */

    /* 10, 11, 12, 13. check for non-zero button id */
    /* #warning We blow off ResumeProc until we can properly handle it */
    if (ap->buttonid)
        dobuttons(/* CL(ResumeProc) ? Cx(ap->buttonid) + 1 : */ Cx(ap->buttonid),
                offsetx, offsety, false);

    TRAPEND();
}
Пример #18
0
uint32_t m6800_cpu_device::RM16(uint32_t Addr )
{
	uint32_t result = RM(Addr) << 8;
	return result | RM((Addr+1)&0xffff);
}
Пример #19
0
P9(PUBLIC pascal trap, ListHandle,  LNew, Rect *, rview,	/* IMIV-270 */
	    Rect *, bounds, Point, csize, INTEGER, proc, WindowPtr, wind,
	      BOOLEAN, draw, BOOLEAN, grow, BOOLEAN, scrollh, BOOLEAN, scrollv)
{
    ListHandle retval;
    ListPtr lp;
    INTEGER noffs, min, max;
    INTEGER *ip;
    Rect r;
    int i;
    DataHandle tempdatah;
    Handle temph;
    LISTDECL();

    noffs = (CW(bounds->right) - CW(bounds->left)) *
				     (CW(bounds->bottom) - CW(bounds->top)) +1;
    retval = (ListHandle) NewHandle(sizeof(ListRec) -
	         sizeof(HxX(retval, cellArray)) + (noffs+1) * sizeof(INTEGER));
    if (!retval)
/*-->*/	return 0;	/* couldn't allocate memory */

    temph = RM(GetResource(TICK("LDEF"), proc));
    if (!(HxX(retval, listDefProc) = temph)) {
	DisposHandle((Handle) retval);
/*-->*/	return 0;	/* spooey list definition proc */
    }

    TRAPBEGIN();
    tempdatah = RM((DataHandle) NewHandle(0));
    HxX(retval, cells) = tempdatah;
    HLock((Handle) retval);
    lp = STARH(retval);

    lp->dataBounds  = *bounds;
    lp->rView       = *rview;
    lp->port        = RM(wind);
    lp->indent.h    = 0;
    lp->indent.v    = 0;
    lp->selFlags    = 0;
#if defined (STEF_lActivefix)
    lp->lActive     = TRUE;
#else
    lp->lActive     = FrontWindow() == wind;
#endif
    lp->lReserved   = 0;
    lp->clikTime    = 0;
    lp->clikLoc.h   = CWC(-32768);
    lp->clikLoc.v   = CWC(-32768);
    lp->mouseLoc.h  = -1;
    lp->mouseLoc.v  = -1;
    lp->lClikLoop   = 0;
    lp->lastClick.h = -1;
    lp->lastClick.v = -1;
    lp->refCon      = 0;
    lp->userHandle  = (Handle) 0;
    lp->maxIndex    = -1;	/* What is this anyway? */
    ip = (INTEGER *) lp->cellArray;
    for (i = 0; i <= noffs; i++)
        *ip++ = 0;

    lp->visible.top  = bounds->top;
    lp->visible.left = bounds->left;
    lp->vScroll = 0;
    lp->hScroll = 0;
    C_LCellSize(csize, retval);	/* sets cellSize and visible */

    lp->listFlags = draw ? DODRAW : 0;
    if (scrollv) {
	r = lp->rView;
	r.top = CW(CW(r.top) - 1);
	r.left = r.right;
	r.right = CW(CW(r.right) + (16));
	r.bottom = CW(CW(r.bottom) + 1);
	ROMlib_vminmax(&min, &max, lp);
	lp->vScroll = RM(NewControl((WindowPtr) wind, &r, (StringPtr) "",
	       draw && lp->lActive, min, min, max, scrollBarProc, (LONGINT) 0));
	STARH(MR(lp->vScroll))->contrlRfCon = RM((LONGINT) (long) retval);
	lp->listFlags |= lDoVAutoscroll;
    }

    if (scrollh) {
	r = lp->rView;
	r.left = CW(CW(r.left) - 1);
	r.top = r.bottom;
	r.bottom = CW(CW(r.bottom) + (16));
	r.right = CW(CW(r.right) + 1);
	ROMlib_hminmax(&min, &max, lp);
	lp->hScroll = RM(NewControl((WindowPtr) wind, &r, (StringPtr) "",
	       draw && lp->lActive, min, min, max, scrollBarProc, (LONGINT) 0));
	STARH(MR(lp->hScroll))->contrlRfCon = RM((LONGINT) (long) retval);
	lp->listFlags |= lDoHAutoscroll;
    }

    HUnlock((Handle) retval);
    LISTBEGIN(retval);
    LISTCALL(lInitMsg, FALSE, (Rect *)0, * (Cell *)&lp->clikLoc, 0, 0, retval);
    LISTEND(retval);
    TRAPEND();
#if defined (LIST_DEBUG)
    add_list (retval);
#endif
    return retval;
}
Пример #20
0
void m6805_base_device::rd_s_handler_b(UINT8 *b)
{
	SP_INC;
	*b = RM( S );
}
Пример #21
0
#undef GRAY_RGB
#undef WHITE_RGB
#undef BLACK_RGB
      
void
wind_color_init (void)
{
  /* initalize the default window colortable */
  ZONE_SAVE_EXCURSION
    (SysZone,
     {
       default_aux_win = (AuxWinHandle) NewHandle (sizeof (AuxWinRec));
       HxX (default_aux_win, awNext) = 0;
       HxX (default_aux_win, awOwner) = 0;
       HxX (default_aux_win, awCTable)
	 = (CTabHandle) RM (GetResource (TICK("wctb"), 0));
       HxX (default_aux_win, dialogCItem) = 0;
       HxX (default_aux_win, awFlags) = 0;
       HxX (default_aux_win, awReserved) = 0;
       HxX (default_aux_win, awRefCon) = 0;
     });
}

AuxWinHandle *
lookup_aux_win (WindowPtr w)
{
  AuxWinHandle *t;

  for (t = &AuxWinHead;
       *t && HxP (MR (*t), awOwner) != w;
       t = &HxX (MR (*t), awNext))
Пример #22
0
/* $13 ILLEGAL */
INLINE void undoc2 (void)
{
	X += RM( S + 1 );
}
Пример #23
0
/* Static variables */

static int tms7000_icount;
static int tms7000_div_by_16_trigger;
static int tms7000_cycles_per_INT2;

#define RM(Addr) ((unsigned)program_read_byte_8(Addr))
#define WM(Addr,Value) (program_write_byte_8(Addr,Value))

UINT16 RM16( UINT32 mAddr );	/* Read memory (16-bit) */
UINT16 RM16( UINT32 mAddr )
{
	UINT32 result = RM(mAddr) << 8;
	return result | RM((mAddr+1)&0xffff);
}
Пример #24
0
// --------------------------------------------------------------
// CxaTM_RM::checkError
// Check the error returned by BMSG_BREAK_ and determine whether
// to retry the LINK.
// If break returns an error we retry the link - resend the 
// message to the RM.
// We don't need to cancel/abandon the message. If Seabed 
// returned an error it already abandoned it.
// pv_breakError - return code from BMSG_BREAK_.
// pp_xaError will contain the XA error code on return.
// pv_softRetry - true (default) Will retry true (retry link) if an
//                     XA_RETRY occurs.  This happens if a 
//                     FEPATHDOWN, FENOLCB, or an XA_RETRY occur.
//                false Will return retry = false if one of these
//                     errors occurs. This allows the XA_RETRY to
//                     be passed up to the next level for xa_recover.
// pv_transid only used for event messages (error reporting).
// return code
//    true = retry link.
//    false = Don't retry. Retries exceeded or error is not 
//            retryable.
// --------------------------------------------------------------
bool CxaTM_RMMessage::checkError(short pv_breakError, int *pp_xaError, 
                                 bool pv_softRetry, int64 pv_transid)
{
   bool lv_retryLink = false;
   *pp_xaError = XA_OK;
   char la_buf[DTM_STRING_BUF_SIZE];
   CTmTxKey lv_txn = (CTmTxKey) pv_transid;

   XATrace(XATM_TraceExit,
           ("XATM: CxaTM_RMMessage::checkError ENTRY txn ID (%d,%d) msgid=%d, breakError=%d, "
            "rmid=%d, softRetry=%d.\n", lv_txn.node(), lv_txn.seqnum(), iv_msgid, pv_breakError, 
            RM()->getRmid(), pv_softRetry));

   lock();
   // For XARM clients connecting to a DTM TM, we always retry the error.
   // DTM TMs don't run as process pairs, but we are attempting to send to
   // a specific node which might go down and switch to a spare. Also the
   // TSE might switch to it's backup.
   // If it's a retryable error (FEPATHDOWN (201) or FEOWNERSHIP (200)) or
   // FENOLCB (30) from a TSE then we'll retry. 
   if ((tm_XARM_generic_library() && pv_breakError) || 
       pv_breakError == FEPATHDOWN ||
       pv_breakError == FEOWNERSHIP ||
      pv_breakError == FENOLCB )
   {
      // Retry sending the request to the RM.  This is used to deal with failovers.
      if (ip_RM->inc_totalRetries())
      {
         sprintf(la_buf, "Retrying send to RM. BMSG_BREAK_ failed for Txn ID (%d,%d) with "
                 "error %d, rmid=%d, msgid=%d, retries=%d/%d\n", 
                 lv_txn.node(), lv_txn.seqnum(), pv_breakError, RM()->getRmid(), msgid(), 
                 sendAttempts(), RM()->maxSendRetries());

         tm_log_event(DTM_TM_INFO_MSGBRK_FAIL3, SQ_LOG_WARNING,
                      "DTM_TM_INFO_MSGBRK_FAIL3", pv_breakError, RM()->getRmid(),lv_txn.node(),lv_txn.seqnum(),
                      msgid(),-1,-1,-1, sendAttempts(),-1,-1,-1,-1,-1,-1,-1,RM()->getRMnameDetail());
         XATrace(XATM_TraceError,("XATM: CxaTM_RMMessage::checkError : %s", la_buf));
      }
      if ((pv_breakError == FEPATHDOWN) || (pv_breakError == FENOLCB))          
         *pp_xaError = XA_RETRY;

      lv_retryLink = can_we_retrySend(pp_xaError);
   }
   else
   {
      if (pv_breakError == FEOK)
      {
         *pp_xaError = getRmError();
         if (*pp_xaError != XA_OK)
         {
            XATrace(XATM_TraceDetail,("XATM: CxaTM_RMMessage::checkError : "
                    "XA error %s encountered.\n", XAtoa(*pp_xaError)));
            // If the RM responds XA_RETRY, we retry as for a break error, but allow
            // this to retry forever.
            if (*pp_xaError == XA_RETRY)
            {
               lv_retryLink = can_we_retrySend(pp_xaError);
               clear_sendAttempts();
            }
         }
      }
      else
      {
         sprintf(la_buf, "RM connection error. txn ID (%d,%d) BMSG_BREAK_ failed with "
                 "error %d, rmid=%d, msgid=%d, retries=%d/%d\n", 
                 lv_txn.node(), lv_txn.seqnum(), pv_breakError, RM()->getRmid(), msgid(), 
                 sendAttempts(), RM()->maxSendRetries());

         tm_log_event(DTM_TM_INFO_MSGBRK_FAIL4, SQ_LOG_WARNING,
                      "DTM_TM_INFO_MSGBRK_FAIL4",pv_breakError, RM()->getRmid(), 
                      lv_txn.node(),lv_txn.seqnum(),msgid(),-1,-1,-1, sendAttempts(),
                      -1,-1,-1,-1,-1,-1,-1,RM()->getRMnameDetail());
         XATrace(XATM_TraceError,("XATM: CxaTM_RMMessage::checkError : %s", la_buf));
         *pp_xaError = XAER_RMFAIL;
      }
   }
   unlock();

   if (!pv_softRetry && *pp_xaError == XA_RETRY)
      lv_retryLink = false;

   XATrace(XATM_TraceExit,
           ("XATM: CxaTM_RMMessage::checkError EXIT txn ID (%d,%d) msgid=%d, returning "
            "retryLink=%d, xaError=%s.\n",
            lv_txn.node(), lv_txn.seqnum(), msgid(), lv_retryLink, XAtoa(*pp_xaError)));
   return lv_retryLink;
} //CxaTM_RMMessage::checkError
Пример #25
0
HD6309_INLINE UINT32 RM16( UINT32 mAddr )
{
	UINT32 result = RM(mAddr) << 8;
	return result | RM((mAddr+1)&0xffff);
}
Пример #26
0
INLINE UINT32 RM16(m68_state_t *m68_state, UINT32 Addr )
{
    UINT32 result = RM(Addr) << 8;
    return result | RM((Addr+1)&0xffff);
}
Пример #27
0
A6(PUBLIC, OSErr, ROMlib_PBMoveOrRename, ParmBlkPtr, pb,	/* INTERNAL */
		BOOLEAN, a, LONGINT, dir, LONGINT, newdir, char *, newname,
							 MoveOrRenameType, op)
{
    ParamBlockRec npb;
    OSErr err;
    char *oldpathname, *oldfilename, *oldendname;
    char *newpathname, *newfilename, *newendname, *fullnewname;
    char *rname, *rnew;
    int renamefailed;
    VCBExtra *vcbp;
    struct stat sbuf;
    LONGINT dirid;
    ALLOCABEGIN

    oldpathname = 0;
    newpathname = 0;
    rname = 0;
    rnew  = 0;

    if ((err = ROMlib_nami(pb, dir, NoIndex, &oldpathname, &oldfilename,
				 &oldendname, TRUE, &vcbp, &sbuf)) == noErr) {
	npb.ioParam.ioNamePtr = RM((StringPtr) newname);
	npb.ioParam.ioVRefNum = pb->ioParam.ioVRefNum;
	if ((err = ROMlib_nami(&npb, newdir, NoIndex, &newpathname,
			       &newfilename, &newendname, TRUE, (VCBExtra **)0,
					        (struct stat *) 0)) == noErr) {
	    if (op == CatMove) {
		fullnewname = ALLOCA(newendname - newpathname +
			 oldendname - oldfilename + 2); /* + '/' and null */
		sprintf(fullnewname, "%s/%s", newpathname, oldfilename);
	    } else
		fullnewname = newpathname;
	    if (strcmp (oldpathname, fullnewname) != 0 &&
		Ustat(fullnewname, &sbuf) != -1)
		err = dupFNErr;
	    else {
	        if (stat (oldpathname, &sbuf) != 0)
		  {
		    sbuf.st_ino = 0;
#if defined (CYGWIN32)
		    sbuf.st_rdev = 0;
#endif
		  }
	      
		if ((renamefailed = Urename(oldpathname, fullnewname)) == 0) {
		    ROMlib_dbm_delete_inode (vcbp, ST_INO (sbuf));
		    dirid = 0;
		    ROMlib_dbm_store(vcbp, fullnewname, &dirid, TRUE);
		    rname = ROMlib_resname(oldpathname, oldfilename,
								   oldendname);
		    if (Ustat(rname, &sbuf) != -1) {
			if (op == CatMove) {
			    newfilename = strrchr(fullnewname, '/') + 1;
			    newendname = fullnewname + strlen(fullnewname) + 1;
			}
			rnew = ROMlib_resname(fullnewname, newfilename,
								   newendname);
			double_dir_op (rnew, mkdir_op);
			renamefailed = Urename(rname, rnew);
			double_dir_op (rname, rmdir_op);
		    }
/* TODO: eventually put a call to ROMlib_fcbrename here, but that requires
   us to know the parent id number, something we don't know right now. */
		}
		if (renamefailed != 0)
		    err = ROMlib_maperrno();
	    }
	}
    }
    if (oldpathname)
	free (oldpathname);
    if (newpathname)
	free (newpathname);
    if (rname)
	free (rname);
    if (rnew)
	free (rnew);
    return err;
    ALLOCAEND
}