Ejemplo n.º 1
0
void CODE5G(char far *COM)
{static char RR;
 static char RX;
 static int R1,R2,B2,IS;


 static char BD;
 static char DD;
 static unsigned int DDD;

 static unsigned long ADRESS;
#define B1 B2
#define I2 RX
#define X2 R2


 GET_OPERAND_RX;
 FORWARD_PSW;
 if (ADRESs&0x3)
	 {RQ_PRG=6;
		RETURN=1;
		return;
	 }
 PUT_WORD(ADRESS,R[R1]);
									 /* ST */
}
Ejemplo n.º 2
0
static void
aout_adobe_swap_exec_header_out (bfd *abfd,
				 struct internal_exec *execp,
				 struct external_exec *bytes)
{
  /* Now fill in fields in the raw data, from the fields in the exec
     struct.  */
  H_PUT_32 (abfd, execp->a_info  , bytes->e_info);
  PUT_WORD (abfd, execp->a_text  , bytes->e_text);
  PUT_WORD (abfd, execp->a_data  , bytes->e_data);
  PUT_WORD (abfd, execp->a_bss   , bytes->e_bss);
  PUT_WORD (abfd, execp->a_syms  , bytes->e_syms);
  PUT_WORD (abfd, execp->a_entry , bytes->e_entry);
  PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize);
  PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
}
Ejemplo n.º 3
0
static ISC_STATUS merge_setup(const UCHAR** in, UCHAR** out, const UCHAR* const end,
							  USHORT delta_length)
{
/**************************************
 *
 *	m e r g e _ s e t u p
 *
 **************************************
 *
 * Functional description
 *	Get ready to toss new stuff onto an info packet.  This involves
 *	picking up and bumping the "count" field and copying what is
 *	already there.
 *
 **************************************/
	USHORT length = (USHORT) gds__vax_integer(*in, 2);
	const USHORT new_length = length + delta_length;

	if (*out + new_length + 2 >= end)
	{
		(*out)[-1] = isc_info_truncated;
		return FB_FAILURE;
	}

	*in += 2;
	const USHORT count = 1 + *(*in)++;
	PUT_WORD(*out, new_length);
	PUT(*out, (UCHAR) count);

	// Copy data portion of information sans original count

	if (--length)
	{
		memcpy(*out, *in, length);
		*out += length;
		*in += length;
	}

	return FB_SUCCESS;
}
Ejemplo n.º 4
0
USHORT MERGE_database_info(const UCHAR* in,
							UCHAR* out,
							USHORT out_length,
							USHORT impl,
							USHORT class_,
							USHORT base_level,
							const UCHAR* version,
							const UCHAR* id)
							//ULONG mask Was always zero
{
/**************************************
 *
 *	M E R G E _ d a t a b a s e _ i n f o
 *
 **************************************
 *
 * Functional description
 *	Merge server / remote interface / Y-valve information into
 *	database block.  Return the actual length of the packet.
 *	See also jrd/utl.cpp for decoding of this block.
 *
 **************************************/
	SSHORT l;
	const UCHAR* p;

	UCHAR* start = out;
	const UCHAR* const end = out + out_length;

	UCHAR mergeLevel = 0;
	for (const UCHAR* getMergeLevel = in;
		*getMergeLevel != isc_info_end && *getMergeLevel != isc_info_truncated;
		 getMergeLevel += (3 + gds__vax_integer(getMergeLevel + 1, 2)))
	{
		if (*getMergeLevel == isc_info_implementation)
		{
			mergeLevel = getMergeLevel[3];
			break;
		}
	}

	for (;;)
		switch (*out++ = *in++)
		{
		case isc_info_end:
		case isc_info_truncated:
			return out - start;

		case isc_info_firebird_version:
			l = strlen((char *) (p = version));
			if (l > MAX_UCHAR)
			    l = MAX_UCHAR;
			if (merge_setup(&in, &out, end, l + 1))
				return 0;
			for (*out++ = (UCHAR) l; l; --l)
				*out++ = *p++;
			break;

		case isc_info_db_id:
			l = strlen((SCHAR *) (p = id));
			if (l > MAX_UCHAR)
				l = MAX_UCHAR;
			if (merge_setup(&in, &out, end, l + 1))
				return 0;
			for (*out++ = (UCHAR) l; l; --l)
				*out++ = *p++;
			break;

		case isc_info_implementation:
			if (merge_setup(&in, &out, end, 2))
				return 0;
			PUT(out, (UCHAR) impl);
			PUT(out, (UCHAR) class_);
			break;

		case fb_info_implementation:
			if (merge_setup(&in, &out, end, 6))
				return 0;
			Firebird::DbImplementation::current.stuff(&out);
			PUT(out, (UCHAR) class_);
			PUT(out, mergeLevel);
			break;

		case isc_info_base_level:
			if (merge_setup(&in, &out, end, 1))
				return 0;
			PUT(out, (UCHAR) base_level);
			break;

		default:
			{
				USHORT length = (USHORT) gds__vax_integer(in, 2);
				in += 2;
				if (out + length + 2 >= end)
				{
					out[-1] = isc_info_truncated;
					return 0;
				}
				PUT_WORD(out, length);
				while (length--)
					*out++ = *in++;
			}
			break;
		}
}
Ejemplo n.º 5
0
/**********************************************************************
 * Convert ActiveX control templates to AtlAxWin class instances
 */
static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
{
#define GET_WORD(x)  (*(const  WORD *)(x))
#define GET_DWORD(x) (*(const DWORD *)(x))
#define PUT_BLOCK(x,y) do {if (!advance_array(&output, &allocated, &filled, (x), (y))) return NULL;} while (0)
#define PUT_WORD(x)  do {WORD w = (x);PUT_BLOCK(&w, 1);} while(0)
#define PUT_DWORD(x)  do {DWORD w = (x);PUT_BLOCK(&w, 2);} while(0)
    const WORD *tmp, *src = (const WORD *)src_tmpl;
    WORD *output;
    DWORD allocated, filled; /* in WORDs */
    BOOL ext;
    WORD signature, dlgver, rescount;
    DWORD style;

    filled = 0; allocated = 256;
    output = HeapAlloc( GetProcessHeap(), 0, allocated * sizeof(WORD) );
    if (!output)
        return NULL;

    /* header */
    tmp = src;
    signature = GET_WORD(src);
    dlgver = GET_WORD(src + 1);
    if (signature == 1 && dlgver == 0xFFFF)
    {
        ext = TRUE;
        src += 6;
        style = GET_DWORD(src);
        src += 2;
        rescount = GET_WORD(src++);
        src += 4;
        if ( GET_WORD(src) == 0xFFFF ) /* menu */
            src += 2;
        else
            src += strlenW(src) + 1;
        if ( GET_WORD(src) == 0xFFFF ) /* class */
            src += 2;
        else
            src += strlenW(src) + 1;
        src += strlenW(src) + 1; /* title */
        if ( style & (DS_SETFONT | DS_SHELLFONT) )
        {
            src += 3;
            src += strlenW(src) + 1;
        }
    } else {
        ext = FALSE;
        style = GET_DWORD(src);
        src += 4;
        rescount = GET_WORD(src++);
        src += 4;
        if ( GET_WORD(src) == 0xFFFF ) /* menu */
            src += 2;
        else
            src += strlenW(src) + 1;
        if ( GET_WORD(src) == 0xFFFF ) /* class */
            src += 2;
        else
            src += strlenW(src) + 1;
        src += strlenW(src) + 1; /* title */
        if ( style & DS_SETFONT )
        {
            src++;
            src += strlenW(src) + 1;
        }
    }
    PUT_BLOCK(tmp, src-tmp);

    while(rescount--)
    {
        src = (const WORD *)( ( ((ULONG_PTR)src) + 3) & ~3); /* align on DWORD boundary */
        filled = (filled + 1) & ~1; /* depends on DWORD-aligned allocation unit */

        tmp = src;
        if (ext)
            src += 12;
        else
            src += 9;
        PUT_BLOCK(tmp, src-tmp);

        tmp = src;
        if ( GET_WORD(src) == 0xFFFF ) /* class */
        {
            src += 2;
        } else
        {
            src += strlenW(src) + 1;
        }
        src += strlenW(src) + 1; /* title */
        if ( GET_WORD(tmp) == '{' ) /* all this mess created because of this line */
        {
            static const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n', 0};
            PUT_BLOCK(AtlAxWin, sizeof(AtlAxWin)/sizeof(WCHAR));
            PUT_BLOCK(tmp, strlenW(tmp)+1);
        } else
            PUT_BLOCK(tmp, src-tmp);

        if ( GET_WORD(src) )
        {
            WORD size = (GET_WORD(src)+sizeof(WORD)-1) / sizeof(WORD); /* quite ugly :( Maybe use BYTE* instead of WORD* everywhere ? */
            PUT_BLOCK(src, size);
            src+=size;
        }
        else
        {
            PUT_WORD(0);
            src++;
        }
    }
    return (LPDLGTEMPLATEW) output;
}
Ejemplo n.º 6
0
Archivo: i386lynx.c Proyecto: 5kg/gdb
static void
NAME(lynx,swap_std_reloc_out) (bfd *abfd,
			       arelent *g,
			       struct reloc_std_external *natptr)
{
  int r_index;
  asymbol *sym = *(g->sym_ptr_ptr);
  int r_extern;
  unsigned int r_length;
  int r_pcrel;
  int r_baserel, r_jmptable, r_relative;
  asection *output_section = sym->section->output_section;

  PUT_WORD (abfd, g->address, natptr->r_address);

  r_length = g->howto->size;	/* Size as a power of two */
  r_pcrel = (int) g->howto->pc_relative;	/* Relative to PC? */
  /* r_baserel, r_jmptable, r_relative???  FIXME-soon */
  r_baserel = 0;
  r_jmptable = 0;
  r_relative = 0;

  /* name was clobbered by aout_write_syms to be symbol index */

  /* If this relocation is relative to a symbol then set the
     r_index to the symbols index, and the r_extern bit.

     Absolute symbols can come in in two ways, either as an offset
     from the abs section, or as a symbol which has an abs value.
     check for that here
  */

  if (bfd_is_com_section (output_section)
      || bfd_is_abs_section (output_section)
      || bfd_is_und_section (output_section))
    {
      if (bfd_abs_section_ptr->symbol == sym)
	{
	  /* Whoops, looked like an abs symbol, but is really an offset
	     from the abs section */
	  r_index = 0;
	  r_extern = 0;
	}
      else
	{
	  /* Fill in symbol */
	  r_extern = 1;
	  r_index = (*g->sym_ptr_ptr)->KEEPIT;
	}
    }
  else
    {
      /* Just an ordinary section */
      r_extern = 0;
      r_index = output_section->target_index;
    }

  /* now the fun stuff */
  if (bfd_header_big_endian (abfd))
    {
      natptr->r_index[0] = r_index >> 16;
      natptr->r_index[1] = r_index >> 8;
      natptr->r_index[2] = r_index;
      natptr->r_type[0] =
	(r_extern ? RELOC_STD_BITS_EXTERN_BIG : 0)
	| (r_pcrel ? RELOC_STD_BITS_PCREL_BIG : 0)
	| (r_baserel ? RELOC_STD_BITS_BASEREL_BIG : 0)
	| (r_jmptable ? RELOC_STD_BITS_JMPTABLE_BIG : 0)
	| (r_relative ? RELOC_STD_BITS_RELATIVE_BIG : 0)
	| (r_length << RELOC_STD_BITS_LENGTH_SH_BIG);
    }
  else
    {
Ejemplo n.º 7
0
TEST( Types, basic_word_put ) {
	util::Buffer w(1);
	w.resize(2);
	PUT_WORD(0x0102, w.buffer());
	ASSERT_EQ( "02:01", w.asHexa() );
}
Ejemplo n.º 8
0
/************************************************************************
 *									*
 *	capi2_register2							*
 *									*
 ***********************************************************************/
int rcapi_register(int		msgsize, 
			int		level3cnt, 
			int		datablkcnt, 
			int		datablklen, 
			char		*datablock,
			rcapi_host_t	*host,
			rcapi_auth_t	*auth)
{
    int ev, fd = -1;
    CAPI_register_req_t req;
    struct {
	CAPI_register_conf_t conf;
	char buffer[256];
    } a;
    union CAPI_primitives *cmsg;

    memset(&req, 0, sizeof(req));
    memset(&a, 0, sizeof(a));

    if ((fd = rcapi_open(host)) == -1) {
	cTRACE( 1, perror("capi2_open"));
	capi2_errno = CAPI2_E_REG_CAPI_NOT_INSTALLED;
	goto error;
    }
    if(auth != NULL) {
	if (capi2_checkuser2(fd, auth->user ,auth->passwd) < 0) 				return -1;
    }
    PUT_WORD(  req.len          , sizeof(req));
    PUT_WORD(  req.appl         , fd);
    PUT_WORD(  req.PRIM_type    , CAPI_REGISTER_REQ);
    PUT_WORD(  req.messid       , 0);

    PUT_WORD(  req.nmess	, msgsize);
    PUT_WORD(  req.nconn	, level3cnt);
    PUT_WORD(  req.ndblock	, datablkcnt);
    PUT_WORD(  req.dblocksiz	, datablklen);

    PUT_BYTE(  req.version      , 2);	/*  CAPI 2.0  */

    if ((ev = capi2_put_message( fd, (char *)&req)) != 0) {
	cTRACE( 1, fprintf( stderr, "capi2_put_message rn=0x%x", ev));
	capi2_errno = ev;
	goto error;
    }

    while ((ev = capi2_get_message( fd, &cmsg, (union CAPI_primitives *)&a, 
				    NULL, 0)) != 0) {
	if (ev != CAPI2_E_MSG_QUEUE_EMPTY) break;
    }
    if (ev) { capi2_errno = ev; goto error; }

    if (GET_PRIMTYPE(cmsg) == CAPI_REGISTER_CONF
	&& GET_WORD(a.conf.info) == 0
    ) {
	return fd;
    }

error:
    cTRACE( 1, fprintf( stderr, "capi2_register_req failed\n"));
    capi2_close(fd);
    return -1;
}
Ejemplo n.º 9
0
int capi2_checkuser2(int	fd,
		     char	*user,
		     char	*passwd)
{
#define CCHECK_ERR -1

    int ev;
    struct {
	CAPI_control_req_t	req;
	char			buffer[256];
    } r;
    struct {
	CAPI_control_conf_ex_t	conf;
	char			buffer[256];
    } a;
    union CAPI_primitives *cmsg = (union CAPI_primitives *)&a;
    int 	len;
    int		chall_len	= 0;
    char	*chall		= NULL;
    struct userdata	*data;
    md5context_t	md5Context;
   
    memset(&r.req, 0, sizeof(r.req));

    if (user == NULL) {
	return 0;	/* OK no authentication desired */
    }
    if (passwd == NULL) {
	passwd = "";
    }


    PUT_WORD(  r.req.len          , sizeof(r.req));
    PUT_WORD(  r.req.appl         , fd);
    PUT_WORD(  r.req.PRIM_type    , CAPI_CONTROL_REQ);
    PUT_WORD(  r.req.messid       , 0);
    PUT_WORD(  r.req.contrl       , 0);
    PUT_WORD(  r.req.type         , CTRL_GETCHALLENGE);
    PUT_BYTE(  r.req.structlen    , 0);

    if ((ev = capi2_put_message( fd, (char *)&r)) != 0) {
	cTRACE( 1, fprintf( stderr, "capi2_put_message rn=0x%x\n", ev));
	capi2_errno = ev;
	return CCHECK_ERR;
    }

    if ((ev = capi2_wait_for_signal(fd, MAXRTT)) != 0) {
        cTRACE(1, fprintf(stderr, "capi2_wait_for_signal 0x%x\n", ev));
        capi2_errno = ev;
	return CCHECK_ERR;    
    }

    if ((ev = capi2_get_message( fd, &cmsg, (union CAPI_primitives *)&a, NULL, 0)) != 0) {
	cTRACE( 1, fprintf( stderr, "capi2_get_message rn=0x%x\n", ev));
        capi2_errno = ev;
	return CCHECK_ERR;
    }

    if (GET_PRIMTYPE(cmsg) == CAPI_CONTROL_CONF
	&& GET_WORD(a.conf.type) == CTRL_GETCHALLENGE    /* get random number */
	&& a.conf.structlen	
    ) {
	chall_len = (size_t)a.conf.structlen;
	chall = a.buffer;  /* random number computed by the brick */
    } else {
        cTRACE( 1, fprintf( stderr, "CAPI_CONTROL_CONF failed\n"));
        capi2_errno = CAPI2_E_REG_OS_RESOURCE_ERROR;
	return CCHECK_ERR;
    }


    /*
     * calculate hash value;
     * see RFC 1321 for a description of the MD5 algorithm
     */

    MD5Init(&md5Context);
    MD5Update (&md5Context, (unsigned char *) user, strlen(user));
    MD5Update (&md5Context, chall, chall_len);
    MD5Update (&md5Context, (unsigned char *) passwd, strlen(passwd));
    MD5Final (&md5Context);

    PUT_WORD(  r.req.appl         , fd);
    PUT_WORD(  r.req.PRIM_type    , CAPI_CONTROL_REQ);
    PUT_WORD(  r.req.messid       , 0);
    PUT_WORD(  r.req.contrl       , 0);
    PUT_WORD(  r.req.type         , CTRL_SETUSER);
    /* copy user and hash value */
    data = (struct userdata *)&r.req.structlen;
 
    data->length = strlen(user);
    memcpy( data->data, user, data->length);
    data = (struct userdata *)&data->data[data->length];
 
    data->length = CAPI_MD5_HASH_LEN;


    memcpy( data->data, md5Context.digest, CAPI_MD5_HASH_LEN);  /* hash value to be compared */
    data = (struct userdata *)&data->data[data->length];        /* on the other side */
 
    len = (char *)data - (char *)&r;
    PUT_WORD(  r.req.len, len );
 
    if ((ev = capi2_put_message( fd, (char *)&r)) != 0) {
	cTRACE( 1, fprintf( stderr, "capi2_put_message rn=0x%x\n", ev));
	capi2_errno = ev;
	return CCHECK_ERR;
    }

    if ((ev = capi2_wait_for_signal(fd, MAXRTT)) != 0) {
        cTRACE(1, fprintf(stderr, "capi2_wait_for_signal 0x%x\n", ev));
        capi2_errno = ev;
	return CCHECK_ERR;
    }

    if ((ev = capi2_get_message( fd, &cmsg, (union CAPI_primitives *)&a, NULL, 0)) != 0) {
	cTRACE( 1, fprintf( stderr, "capi2_get_message rn=0x%x\n", ev));
        capi2_errno = ev;
	return CCHECK_ERR;
    }

    if (GET_PRIMTYPE(cmsg) == CAPI_CONTROL_CONF
	&& GET_WORD(a.conf.type) == CTRL_SETUSER
	&&  GET_WORD(a.conf.info) == 1
    ) {
	return 0; 		/* OK authentication passed */
    }
    cTRACE( 1, fprintf( stderr, "CAPI_CONTROL_CONF failed, invalid authentication"));
    capi2_errno = CAPI2_E_REG_EXT_EQUIPMENT_NOT_SUPPORTED;
    return CCHECK_ERR;
}