Example #1
0
   virtual bool Read(void *mem, dword len){

      dword read_len = 0;
      const dword wanted_len = len;
      dword rl = 0;
      while(curr+len>top){
         dword rl1 = top-curr;
         MemCpy(mem, curr, rl1);
         len -= rl1;
         mem = (byte*)mem + rl1;
         dword sz = ReadCache();
         top = base + sz;
         curr_pos += sz;
         rl += rl1;
         if(!sz){
            read_len = rl;
            goto check_read_size;
            //return rl;
         }
      }
      MemCpy(mem, curr, len);
      curr += len;
      read_len = rl + len;
      //return rl + len;
check_read_size:
      return (read_len == wanted_len);
   }
Example #2
0
/// <summary>
/// Construct a new String instance by concatenating exactly two strings together.
/// </summary>
/// <param name="str">The first string to concatenate.</param>
/// <param name="other">The second string to concatenate.</param>
/// <returns>The new String instance.</returns>
String String_Concat(const String str, const String other)
{
	struct StringInt *result, *s1, *s2;
	Byte *newText;
	Int length;

	s1 = (struct StringInt *)str;
	s2 = (struct StringInt *)other;

	if (s1 == NULL || s1->length == 0) return s2 != NULL ? (String)s2 : String_Empty;
	if (s2 == NULL || s2->length == 0) return (String)s1;

	length = s1->length + s2->length;

	result = GC_MALLOC_STRUCT(struct StringInt);
	if (result == NULL) Smile_Abort_OutOfMemory();
	newText = GC_MALLOC_TEXT(length);
	if (newText == NULL) Smile_Abort_OutOfMemory();

	result->length = length;
	result->text = newText;

	MemCpy(newText, s1->text, s1->length);
	MemCpy(newText + s1->length, s2->text, s2->length);
	newText[length] = '\0';

	return (String)result;
}
Example #3
0
//
// TextPacket::TextPacket			- not described in the book
//
TextPacket::TextPacket(char const * const text)
 :BinaryPacket(static_cast<u_long>(strlen(text) + 2))
{ 
	MemCpy(text, strlen(text), 0);
	MemCpy("\r\n", 2, 2);
	*(u_long *)m_Data = 0;
}
Example #4
0
File: map.cpp Project: f3yagi/mysrc
Map *ReadMap(char *name)
{
    char *buf;
    int x, y, i, n;
    Map *map = NULL;
    char *data;

    buf = LoadFile(name, &n);
    data = buf;
    map = (Map *)Malloc(sizeof(Map));
    map->object = NULL;
    MemCpy(&map->width, buf, sizeof(int));
    buf += sizeof(int);
    MemCpy(&map->height, buf, sizeof(int));
    buf += sizeof(int);
    map->data = (struct MapData *)Malloc(sizeof(struct MapData) * map->width * map->height);
    for (y = 0; y < map->height; y++) {
        for (x = 0; x < map->width; x++) {
            MemCpy(&map->data[POS(x, y)], buf, sizeof(struct MapData));
            buf += sizeof(struct MapData);
        }
    }
    MemCpy(&map->objectNum, buf, sizeof(int));
    buf += sizeof(int);
    map->object = (struct ObjectData *)Malloc(sizeof(struct ObjectData) * map->objectNum);    
    for (i = 0; i < map->objectNum; i++) {
        MemCpy(&map->object[i], buf, sizeof(struct ObjectData));
        buf += sizeof(struct ObjectData);
    }
    Free(data);
    return map;
}
static int Codec618CmdWrite(RK618_DEVICE_CLASS *dev,UINT16 RegAddr, UINT32 uData)
{
    uint8 cmd,data[4];
    I2C_CMD_ARG stArg;
    uint32 set_bit, read_value, new_value;
    int i;

    HDC hI2c = dev->hI2C;
    if(hI2c != NULL)
    {
        if (!Is_rk618_mfd_register(RegAddr) && !Is_rk618_codec_register(RegAddr))
        {
    		rk_printf("%s : reg error!\n", __func__);
    		return -EINVAL;
    	}

    	// set codec mask bit
    	i = rk618_mfd_codec_bit(RegAddr);
    	if (i >= 0)
        {
    		set_bit = rk618_mfd_codec_bit_list[i].value;
    		read_value = Codec618CmdRead(dev, RegAddr);
    		uData = (read_value & ~set_bit) | (uData & set_bit);
    	}
        else if (Is_rk618_mfd_mask_register(RegAddr))
        {
    		uData = ((0xffff0000 & rk618_read_reg_cache(RegAddr)) | (uData & 0x0000ffff));
    	}

        new_value = rk618_set_init_value(dev, RegAddr, uData);

//        data[0] = (0xff & uData);
//        data[1] = (0xff00 & uData) >> 8;
//        data[2] = (0xff0000 & uData)>>16;
//        data[3] = (0xff000000 & uData)>>24;
        MemCpy(data, (uint8 *)&uData, 4);

        stArg.SlaveAddress  = RK618_Codec_I2CAddr;
        stArg.RegAddr       = RegAddr;
        stArg.RWmode        = NormalMode;
        stArg.speed         = RK618_Codec_I2CSpeed;
        stArg.addr_reg_fmt  = I2C_7BIT_ADDRESS_16BIT_REG;

        I2cDev_SendData(hI2c,data,4,&stArg);

	    if (new_value != uData)
        {
            MemCpy(data, (uint8 *)&new_value, 4);
            I2cDev_SendData(hI2c,data,4,&stArg);
		    uData = new_value;
	    }

	    rk618_write_reg_cache(RegAddr, uData);
    }

    return 0;
}
Example #6
0
File: sgutil.c Project: rwgk/sglite
void SgOpsCpy(T_SgOps *t, const T_SgOps *s)
{
  t->NoExpand = s->NoExpand;
  t->nLSL = s->nLSL;
  t->nSSL = s->nSSL;
  t->nLTr = s->nLTr;
  t->fInv = s->fInv;
  t->nSMx = s->nSMx;
  MemCpy(t->LTr, s->LTr, SgOps_mLTr);
  MemCpy(t->InvT, s->InvT, 3);
  MemCpy(t->SMx, s->SMx, SgOps_mSMx);
}
Example #7
0
int FatWriteBootRecord (struct FatSB *fsb)
{
	uint8 temp_sector[512];
	uint16 signature;
	int t;
	
	KPRINTF ("FatWriteBootRecord()");
	
	ReadBlocks (fsb, &kernel_as, temp_sector, 0, 0, 512);

	MemCpy (temp_sector, &fsb->bpb, sizeof (struct FatBPB));
	
	
	if (fsb->fat_type == TYPE_FAT32)
	{
		MemCpy (temp_sector + BPB_EXT_OFFSET, &fsb->bpb32, sizeof (struct FatBPB_32Ext));
		MemCpy (temp_sector + FAT32_BOOTCODE_START, fat32_bootcode, SIZEOF_FAT32_BOOTCODE);
	}
	else
	{
		MemCpy (temp_sector + BPB_EXT_OFFSET, &fsb->bpb16, sizeof (struct FatBPB_16Ext));
		MemCpy (temp_sector + FAT16_BOOTCODE_START, fat16_bootcode, SIZEOF_FAT16_BOOTCODE);
	}
	
	*(temp_sector + 510) = 0x55;
	*(temp_sector + 511) = 0xaa;	

	WriteBlocks (fsb, &kernel_as, temp_sector, 0, 0, 512, BUF_IMMED);
	
	
	
	
	
	
	if (fsb->fat_type == TYPE_FAT32)
	{		
		WriteBlocks (fsb, &kernel_as, &fsb->fsi, 1, 0, sizeof (struct FatFSInfo), BUF_IMMED);
			
		signature = 0xaa55;
				
		WriteBlocks (fsb, &kernel_as, &signature, 2, 510, 2, BUF_IMMED);
		
		
		for (t=0; t<3; t++)
		{			
			ReadBlocks (fsb, &kernel_as, temp_sector, t, 0, 512);
			WriteBlocks (fsb, &kernel_as, temp_sector, 6+t, 0, 512, BUF_IMMED);
		}
	}
	
	return 0;
}
Example #8
0
/* This function fills the "tags" part of the HTML_dtd structure with
   what we want to use, either tags_table0 or tags_table1.  Note that it
   has to be called at least once before HTML_dtd is used, otherwise
   the HTML_dtd contents will be invalid!  This could be coded in a way
   that would make an initialisation call unnecessary, but my C knowledge
   is limited and I didn't want to list the whole tags_table1 table
   twice... - kw */
void HTSwitchDTD(int new_flag)
{
    if (TRACE)
	CTRACE((tfp,
		"HTMLDTD: Copying %s DTD element info of size %d, %d * %d\n",
		new_flag ? "strict" : "tagsoup",
		(int) (new_flag ? sizeof(tags_table1) : sizeof(tags_table0)),
		HTML_ALL_ELEMENTS,
		(int) sizeof(HTTag)));
    if (new_flag)
	MemCpy(tags, tags_table1, HTML_ALL_ELEMENTS * sizeof(HTTag));
    else
	MemCpy(tags, tags_table0, HTML_ALL_ELEMENTS * sizeof(HTTag));
}
Example #9
0
//增加一条记录,并同步显示
//Addr不能为0,Name可以为空,name为空,则不修改name
static void AddOneDevice(u8 Addr,u8 *Name)
{
	u8 i;
	u8 Len=0;
	u16 NameChk;

	if(Name!=NULL) Len=strlen((void *)Name);
	if(Len>=DEVICE_NAME_MAX_LEN) Len=DEVICE_NAME_MAX_LEN-1;
	NameChk=MakeHash33(Name,Len);

	for(i=0;i<DEVICE_INFO_MAX_CLIENT_RECORD;i++)
	{
		//对比地址或名字,如果地址相等,直接修改名字,如果名字相同,则修改地址。
		if((gpQwpVar->ClientRecord[i].Addr==Addr)||((gpQwpVar->ClientRecord[i].Addr!=0)&&(gpQwpVar->ClientRecord[i].NameChk==NameChk)))
		{//修改现成的
			gpQwpVar->ClientRecord[i].Addr=Addr;
			
			if((Name!=NULL)&&(gpQwpVar->ClientRecord[i].NameChk!=NameChk))//修改名字
			{
				MemCpy(gpQwpVar->ClientRecord[i].Name,Name,Len);
				gpQwpVar->ClientRecord[i].Name[Len]=0;
			}

			if(gpQwpVar->ClientRecord[i].IsHiLight==TRUE)
				DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,HighLightDisp);
			else
				DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,NormalDisp);
			break;
		}
	}

	if(i==DEVICE_INFO_MAX_CLIENT_RECORD)//not found ,add new one.
	{//建新的
		for(i=0;i<DEVICE_INFO_MAX_CLIENT_RECORD;i++)
			if(gpQwpVar->ClientRecord[i].Addr==0)
			{
				gpQwpVar->ClientRecord[i].Addr=Addr;
				MemCpy(gpQwpVar->ClientRecord[i].Name,Name,Len);
				gpQwpVar->ClientRecord[i].Name[Len]=0;
				gpQwpVar->ClientRecord[i].NameChk=MakeHash33(gpQwpVar->ClientRecord[i].Name,Len);
				gpQwpVar->ClientRecord[i].DispIdx=++gpQwpVar->NowDispNum;
				DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,NormalDisp);
				break;
			}
	}	

	DrawState();//更新下状态
}
Example #10
0
public CTaskSettings *SettingsPush(CTask *task=NULL,I64 flags=0)
{ //This is typically used at the start of an application.
  //It saves many settings so they can be restored
  //at the end of the application with $LK,"SettingsPop","MN:SettingsPop"$().

  CTaskSettings *tempse;
  CDoc *doc;
  if (!task) task=Fs;
  if (!TaskValidate(task)) return NULL;
  tempse=CAlloc(sizeof(CTaskSettings),task);
  tempse->draw_it=task->draw_it;
  GetVGAPalette4(tempse->palette4);
  tempse->task_end_cb=task->task_end_cb;

  if (!(flags&TSF_SAME_SONG)) {
    if (tempse->song_task=task->song_task) {
      Suspend(task->song_task);
      Snd(0);
    }
    task->song_task=NULL;
  }

  if (tempse->animate_task=task->animate_task)
    Suspend(task->animate_task);
  task->animate_task=NULL;

  if (doc=DocPut(task)) {
    tempse->cursor=!Bt(&doc->flags,DOCf_HIDE_CURSOR);
    tempse->scroll=!Bt(&doc->flags,DOCf_NO_SCROLL_BARS);
  }

  tempse->left=task->win_left;
  tempse->right=task->win_right;
  tempse->top=task->win_top;
  tempse->bottom=task->win_bottom;

  tempse->scroll_x=task->win_scroll_x;
  tempse->scroll_y=task->win_scroll_y;
  tempse->scroll_z=task->win_scroll_z;

  tempse->win_inhibit=task->win_inhibit;
  MemCpy(&tempse->snap,&task->snap,sizeof(CSnap));

  tempse->win_max_refresh=task->win_max_refresh;
  tempse->text_attr=task->text_attr;
  StrCpy(tempse->task_title,task->task_title);
  tempse->title_src  =task->title_src;
  tempse->border_attr=task->border_attr;
  tempse->border_src =task->border_src;
  tempse->border=!Bt(&task->display_flags,DISPLAYf_NO_BORDER);
  tempse->preempt=Bt(&task->task_flags,TASKf_PREEMPT);
  if (TaskValidate(ws_task))
    tempse->wordstat=TRUE;
  else
    tempse->wordstat=FALSE;

  tempse->next=task->next_settings;
  task->next_settings=tempse;
  return tempse;
}
Example #11
0
void SetName( INDEX iWorld, INDEX iName, CTEXTSTR text )
{
	GETWORLD( iWorld );
	PNAME name = GetName( iName );
	int l, start, end;
	if( !name )
		return;
	if( name->name )
	{
		for( l = 0; l < name->lines; l++ )
			Release( name->name[l].name );
		Release( name->name );
	}
	name->lines = LineCount( text );
	if( name->lines )
	{
		name->name = (struct name_data*)Allocate( sizeof( *name->name ) * name->lines );
		start = 0;
		end = 0;
		for( l= 0; l < name->lines; l++ )
		{
			while( text[end] && text[end] != '\n' ) end++;
			name->name[l].length = end-start;
			name->name[l].name = (TEXTCHAR*)Allocate( (end-start) + 1 );
			MemCpy( name->name[l].name, text + start, end-start );
			name->name[l].name[end-start] = 0;
			start = end+1;
			end = start;
		}
	}
	else
		name->name = NULL;
}
Example #12
0
U0 SettingsPop2(CTask *task,CTaskSettings *tempse)
{
  CDoc *doc;

  if (doc=DocPut(task)) {
    LBEqu(&doc->flags,DOCf_HIDE_CURSOR,!tempse->cursor);
    LBEqu(&doc->flags,DOCf_NO_SCROLL_BARS,!tempse->scroll);
  }

  WinBorder(tempse->border,task);
  SetWinHorz(tempse->left,tempse->right,task);
  SetWinVert(tempse->top,tempse->bottom,task);
  task->win_scroll_x=tempse->scroll_x;
  task->win_scroll_y=tempse->scroll_y;
  task->win_scroll_z=tempse->scroll_z;
  MemCpy(&task->snap,&tempse->snap,sizeof(CSnap));
  task->win_inhibit=tempse->win_inhibit;
  task->win_max_refresh=tempse->win_max_refresh;
  task->text_attr=tempse->text_attr;
  task->border_attr=tempse->border_attr;
  task->border_src =tempse->border_src;
  task->title_src  =tempse->title_src;
  StrCpy(task->task_title,tempse->task_title);
  WordStat(tempse->wordstat);
  SetVGAPalette4(tempse->palette4);
  Snd(0);
}
Example #13
0
/// <summary>
/// Construct a new String instance by concatenating a byte onto the end of a string.
/// </summary>
/// <param name="str">The string to concatenate.</param>
/// <param name="ch">The byte to append to it.</param>
/// <returns>The new String instance.</returns>
String String_ConcatByte(const String str, Byte ch)
{
	struct StringInt *result, *s1;
	Byte *newText;
	Int length;

	s1 = (struct StringInt *)str;

	if (s1 == NULL || s1->length == 0)
		return String_CreateRepeat(ch, 1);

	length = s1->length + 1;

	result = GC_MALLOC_STRUCT(struct StringInt);
	if (result == NULL) Smile_Abort_OutOfMemory();
	newText = GC_MALLOC_TEXT(length);
	if (newText == NULL) Smile_Abort_OutOfMemory();

	result->length = length;
	result->text = newText;

	MemCpy(newText, s1->text, s1->length);
	newText[length-1] = ch;
	newText[length] = '\0';

	return (String)result;
}
Example #14
0
void BasicMessageBox( TEXTCHAR *title, TEXTCHAR *content )
{
    PCOMMON msg;
    TEXTCHAR *start, *end;
    TEXTCHAR msgtext[256];
    int done = 0, okay = 0;
    int y = 5;
    msg = CreateFrame( title, 0, 0, 312, 120, 0, frame );
    end = start = content;
    do
    {
        while( end[0] && end[0] != '\n' )
            end++;
        if( end[0] )
        {
            MemCpy( msgtext, start, end-start );
            msgtext[end-start] = 0;
            //end[0] = 0;
            MakeTextControl( msg, 5, y, 302, 16, -1
                             , msgtext, 0 );
            //end[0] = '\n';
            end = start = end+1;
            y += 18;
        }
        else
            MakeTextControl( msg, 5, y, 302, 16, -1
                             , start, 0 );
    } while( end[0] );
    //AddExitButton( msg, &done );
    AddCommonButtons( msg, NULL, &okay );
    DisplayFrame( msg );
    CommonLoop( &okay, NULL );
    DestroyFrame( &msg );
}
Example #15
0
/*********************************************************************//**
 * @brief 			Inquiry the mass storage device.
 * @param[in]		None.
 * @return 		MS_FUNC_OK       if Success
 *				ERR_MS_CMD_FAILED if failed
 **********************************************************************/
int32_t MS_Inquire (uint8_t *response)
{
    int32_t rc;
	uint32_t i;

    Fill_MSCommand(0, 0, 0, MS_DATA_DIR_IN, SCSI_CMD_INQUIRY, 6);
    rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, CBW_SIZE);
    if (rc == MS_FUNC_OK) {
        rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, INQUIRY_LENGTH);
        if (rc == MS_FUNC_OK) {
            if (response) {
		for ( i = 0; i < INQUIRY_LENGTH; i++ )
			*response++ = *TDBuffer++;
#if 0
            	MemCpy (response, TDBuffer, INQUIRY_LENGTH);
	        	StrNullTrailingSpace (response->vendorID, SCSI_INQUIRY_VENDORCHARS);
	        	StrNullTrailingSpace (response->productID, SCSI_INQUIRY_PRODUCTCHARS);
	        	StrNullTrailingSpace (response->productRev, SCSI_INQUIRY_REVCHARS);
#endif
            }
            rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, CSW_SIZE);
            if (rc == MS_FUNC_OK) {
                if (TDBuffer[12] != 0) {	// bCSWStatus byte
                    rc = ERR_MS_CMD_FAILED;
                }
            }
        }
    }
    return (rc);
}
Example #16
0
//----- (000025B8) --------------------------------------------------------
__myevic__ uint32_t hidGetInfoCmd( CMD_T *pCmd )
{
	uint32_t u32StartAddr;
	uint32_t u32ParamLen;

	u32StartAddr = pCmd->u32Arg1;
	u32ParamLen = pCmd->u32Arg2;

	myprintf( "Get Info command - Start Addr: %d    Param Len: %d\n", pCmd->u32Arg1, pCmd->u32Arg2 );

	if ( u32ParamLen )
	{
		dfChecksum = Checksum( (uint8_t *)DataFlash.params, FMC_FLASH_PAGE_SIZE - 4 );

		if ( u32StartAddr + u32ParamLen > FMC_FLASH_PAGE_SIZE )
		{
			u32ParamLen = FMC_FLASH_PAGE_SIZE - u32StartAddr;
		}

		MemCpy( hidData, ((uint8_t *)&DataFlash) + u32StartAddr, u32ParamLen );

		hidDataIndex = u32ParamLen;
		pCmd->u32Signature = u32ParamLen;

		USBD_MemCopy(
			(uint8_t *)(USBD_BUF_BASE + USBD_GET_EP_BUF_ADDR(EP2)),
			hidData,
			EP2_MAX_PKT_SIZE
		);
		USBD_SET_PAYLOAD_LEN( EP2, EP2_MAX_PKT_SIZE );
		hidDataIndex -= EP2_MAX_PKT_SIZE;
	}

	return 0;
}
Example #17
0
//--------------------------------------
static void CPROC ImagePngWrite(png_structp png,
                           png_bytep   data,
                           png_size_t  length)
{
	// add this length, data into the buffer...
   // reallcoate buffer by 4096 until complete.
	//sg_pStream->write(length, data);
	ImagePngRawData *self = (ImagePngRawData *) png->io_ptr;
	if( ((*self->r_size) + length ) > self->alloced )
	{
		if( self->alloced )
		{
			self->alloced += ((length > 2048)?length:0) + 4096;
			(*self->r_data) = (uint8_t*)Reallocate( (*self->r_data), self->alloced );
		}
		else
		{
			self->alloced += 4096;
			(*self->r_size) = 0;
			(*self->r_data) = (uint8_t*)Allocate( self->alloced );
		}
	}
	MemCpy( (*self->r_data)+(*self->r_size), data, length );
   (*self->r_size) = (*self->r_size) + length;
}
Example #18
0
//Function called by filesystems to fill readdir entry
static int readDirFiller(void * buf, unsigned int iNode, const char * name, int len)
{
	//Called to fill buffer
	ReadDirFillerBuf * rdBuffer = (ReadDirFillerBuf *) buf;
	IoReadDirEntry * entry = rdBuffer->nextEntry;

	//If count is 0, overflow
	if(rdBuffer->count == 0)
	{
		return -EINVAL;
	}

	//Basic memory checks
	if(!MemCommitForWrite(entry, sizeof(IoReadDirEntry)))
	{
		return -EFAULT;
	}

	//Fill info
	entry->iNode = iNode;
	if(len > 255)
	{
		len = 255;
	}

	MemCpy(entry->name, name, len);
	entry->name[len] = '\0';

	//Move to next entry
	rdBuffer->nextEntry++;
	rdBuffer->count--;
	return 0;
}
Example #19
0
//----- (000025B8) --------------------------------------------------------
__myevic__ uint32_t hidGetInfoCmd( CMD_T *pCmd )
{
	uint32_t u32StartAddr;
	uint32_t u32ParamLen;

	u32StartAddr = pCmd->u32Arg1;
	u32ParamLen = pCmd->u32Arg2;

	myprintf( "Get Info command - Start Addr: %d    Param Len: %d\n", pCmd->u32Arg1, pCmd->u32Arg2 );

	if ( u32ParamLen )
	{
		dfChecksum = Checksum( (uint8_t *)DataFlash.params, FMC_FLASH_PAGE_SIZE - 4 );

		if ( u32StartAddr + u32ParamLen > FMC_FLASH_PAGE_SIZE )
		{
			u32ParamLen = FMC_FLASH_PAGE_SIZE - u32StartAddr;
		}

		MemCpy( hidData, ((uint8_t *)&DataFlash) + u32StartAddr, u32ParamLen );

		hidInDataPtr = hidData;
		hidStartInReport( u32ParamLen );
	}

	return 0;
}
Example #20
0
   virtual C_file::E_WRITE_STATUS Write(const void *mem, dword len){

                              //put into cache
      while(curr_pos+len > CACHE_SIZE){
         dword sz = CACHE_SIZE - curr_pos;
         MemCpy(cache+curr_pos, mem, sz);
         curr_pos += sz;
         (byte*&)mem += sz;
         len -= sz;
         C_file::E_WRITE_STATUS ws = WriteFlush();
         if(ws)
            return ws;
      }
      MemCpy(cache+curr_pos, mem, len);
      curr_pos += len;
      return C_file::WRITE_OK;
   }
Example #21
0
File: sggen.c Project: rwgk/sglite
int ExpSgRMx(T_SgOps *SgOps, const int NewRMx[9])
{
  T_RTMx  SMx[1];

  MemCpy(SMx->s.R, NewRMx, 9);
  IntSetZero(SMx->s.T, 3);
  return ExpSgSMx(SgOps, SMx);
}
Example #22
0
/// <summary>
/// Construct a new String instance by concatenating many other strings together, with a glue string between them.
/// </summary>
/// <param name="glue">The glue string to insert between successive string instances.  This will not be
/// added to the start and end of the resulting string:  Only between strings.</param>
/// <param name="strs">The array of string instances to join to create the new string.</param>
/// <param name="numStrs">The number of string instances in the array.</param>
/// <returns>The new String instance.</returns>
String String_Join(const String glue, const String *strs, Int numStrs)
{
	Int length, dest, i;
	struct StringInt *str;
	Byte *newText;
	const Byte *glueText;
	Int glueLength;

	if (numStrs <= 0) return String_Empty;

	length = 0;
	for (i = 0; i < numStrs; i++)
	{
		length += ((const struct StringInt *)(strs[i]))->length;
	}
	length += (numStrs - 1) * ((const struct StringInt *)glue)->length;

	if (length <= 0) return String_Empty;

	str = GC_MALLOC_STRUCT(struct StringInt);
	if (str == NULL) Smile_Abort_OutOfMemory();
	newText = GC_MALLOC_TEXT(length);
	if (newText == NULL) Smile_Abort_OutOfMemory();

	str->length = length;
	str->text = newText;

	glueText = ((const struct StringInt *)glue)->text;
	glueLength = ((const struct StringInt *)glue)->length;

	MemCpy(newText, ((const struct StringInt *)(strs[0]))->text, ((const struct StringInt *)(strs[0]))->length);
	dest = ((const struct StringInt *)(strs[0]))->length;

	for (i = 1; i < numStrs; i++)
	{
		MemCpy(newText + dest, glueText, glueLength);
		dest += glueLength;
		MemCpy(newText + dest, ((const struct StringInt *)(strs[i]))->text, ((const struct StringInt *)(strs[i]))->length);
		dest += ((const struct StringInt *)(strs[i]))->length;
	}

	newText[length] = '\0';

	return (String)str;
}
Example #23
0
bool BootpRx(char *bootpHeader, short len){
	BOOTP_HEADER	*bhp = (BOOTP_HEADER *)bootpHeader;

	if (len!=BOOTP_HDR_SIZE)		return false;

	// check bootp.
	if (bhp->bh_opcode!=2)			return false;
	if (bhp->bh_htype!=1)			return false;
	if (bhp->bh_hlen!=6)			return false;
	if (MemCmp(&bhp->bh_tid, &bootpID, 4)) return false;
	if (MemCmp(&bhp->bh_chaddr, &clientEther, 6)) return false;

	// get infomation from bootp packet.
	MemCpy(&clientIP, &bhp->bh_yiaddr, 4);
	MemCpy(&hostIP  , &bhp->bh_siaddr, 4);

	bootpState = BOOTP_SUCCESS;
	return true;
}	// BootpRx.
Example #24
0
static int CPROC ServiceFunction( uint32_t *params, uint32_t param_length /*FOLD00*/
										  , uint32_t *result, uint32_t *result_length )
{
	// echo the data we got back to the client...
// most other things will do useful functions in functions.
   //ThreadTo( ClientThread, params[-1] );
	MemCpy( result, params, param_length );
   *result_length = param_length;
   return TRUE;
}
Example #25
0
   virtual bool Read(void *mem, dword len){

      dword left = top - curr;
      if(len > left)
         //THROW(FILE_ERR_EOF);
         return false;
      MemCpy(mem, curr, len);
      curr += len;
      return true;
   }
Example #26
0
File: sgutil.c Project: rwgk/sglite
T_RTMx *SetLISMx(const T_SgOps *SgOps, int iLTr, int iInv, int iSMx,
                 T_RTMx *LISMx)
{
  int  i;

  MemCpy(LISMx, &SgOps->SMx[iSMx], 1);
  if (iInv) SMx_t_InvT(LISMx, SgOps->InvT, LISMx);
  rangei(3) LISMx->s.T[i] += SgOps->LTr[iLTr].v[i];

  return LISMx;
}
Example #27
0
void CPedSA::Respawn(CVector * position, bool bCameraCut)
{
    CPed * pLocalPlayer = pGame->GetPools()->GetPedFromRef ( (DWORD)1 );

    if ( !bCameraCut )
    {
         // DISABLE call to CCamera__RestoreWithJumpCut when respawning
        MemSet ( (void*)0x4422EA, 0x90, 20 );
    }

    DEBUG_TRACE("void CPedSA::Respawn(CVector * position)");
    FLOAT fX = position->fX;
    FLOAT fY = position->fY;
    FLOAT fZ = position->fZ;
    FLOAT fUnk = 1.0f; 
    DWORD dwFunc = FUNC_RestorePlayerStuffDuringResurrection;
    DWORD dwThis = (DWORD)this->GetInterface();
    _asm
    {
        push    fUnk
        push    fZ
        push    fY
        push    fX
        push    dwThis
        call    dwFunc
        add     esp, 20
    }
#if 0   // Removed to see if it reduces crashes
    dwFunc = 0x441440; // CGameLogic::SortOutStreamingAndMemory
    fUnk = 10.0f;
    _asm
    {
        push    fUnk
        push    position
        call    dwFunc
        add     esp, 8
    }
#endif
    dwFunc = FUNC_RemoveGogglesModel;
    _asm
    {
        mov     ecx, dwThis
        call    dwFunc
    }

    if ( !bCameraCut )
    {
        // B9 28 F0 B6 00 E8 4C 9A 0C 00 B9 28 F0 B6 00 E8 B2 97 0C 00
        unsigned char szCode[] = {0xB9, 0x28, 0xF0, 0xB6, 0x00, 0xE8, 0x4C, 0x9A, 0x0C, 0x00, 0xB9, 0x28, 0xF0, 0xB6, 0x00, 0xE8, 0xB2, 0x97, 0x0C, 0x00} ;
        // RE-ENABLE call to CCamera__RestoreWithJumpCut when respawning
        MemCpy ( (void*)0x4422EA, szCode, 20 );
    }
    //OutputDebugString ( "Respawn!!!!" );
}
Example #28
0
void C_vector_any::_Reserve(dword s){

   s = Max(s, Max(res_size, used_size));
   if(res_size!=s){
      res_size = s;
      byte *new_a = new(true) byte[res_size*elem_size];
      MemCpy(new_a, array, used_size*elem_size);
      delete[] array;
      array = new_a;
   }
}
block_datastr *blkdev_write_block(UID id,char *data)		
{
	int size;
	char *copy_ptr;
	block_datastr *ret;
	block_datastr *bp;

	char *temp;

	int i=0;

	ret = bp = find_freeblock();	 // get free block pointer
	printf("%x\n", ret);

	size = get_datasize(data); // get size of data
	printf("%d\n", size);

	while(size > 0){
		if(bcb.blocksleft <= 0)
		{
			printf("No have empty block");
			return NULL;
		}
		bp->next = (unsigned int)(bp->next)|(0x1);	// check block to be used
		if(size > BLOCK_SIZE)
		{
			MemCpy(bp->data, data, BLOCK_SIZE);
			bp->next = (unsigned int)(bp->next)|(unsigned int)find_freeblock();
			bp = (unsigned int)(bp->next)&0xFFFFFFFE;
		}
		else
		{
			MemCpy(bp->data, data, size);
		}
		size = size - BLOCK_SIZE;
		bcb.blocksleft--;
	}


	return ret;
}
Example #30
0
void test_MemCpy()
{
    U8 dest[128] = {0};
    for (I32 i = 0; i < 128; ++i)
    {
        dest[i] = 3;
    }

    U8 src[128] = {0};
    for (I32 i = 0; i < 128; ++i)
    {
        src[i] = 5;
    }

    MemCpy(dest + 1, src, 4);
    ERROR(dest[0] == 3);
    for (I32 i = 1; i < 5; ++i)
    {
        ERROR(dest[i] == 5);
    }

    for (I32 i = 1; i < 5; ++i)
    {
        src[i] = 7;
    }
    MemCpy(dest, src + 1, 4);
    for (I32 i = 0; i < 4; ++i)
    {
        src[i] = 7;
    }

    for (I32 i = 0; i < 4; ++i)
    {
        src[i] = 11;
    }
    MemCpy(dest, src, 128);
    for (I32 i = 0; i < 4; ++i)
    {
        ERROR(dest[i] == 11);
    }
}