Exemplo n.º 1
0
VkResult WrappedVulkan::vkBindBufferMemory(
    VkDevice                                    device,
    VkBuffer                                    buffer,
    VkDeviceMemory                              mem,
    VkDeviceSize                                memOffset)
{
	VkResourceRecord *record = GetRecord(buffer);

	if(m_State >= WRITING)
	{
		Chunk *chunk = NULL;

		{
			CACHE_THREAD_SERIALISER();
		
			SCOPED_SERIALISE_CONTEXT(BIND_BUFFER_MEM);
			Serialise_vkBindBufferMemory(localSerialiser, device, buffer, mem, memOffset);

			chunk = scope.Get();
		}
	
		// memory object bindings are immutable and must happen before creation or use,
		// so this can always go into the record, even if a resource is created and bound
		// to memory mid-frame
		record->AddChunk(chunk);

		record->AddParent(GetRecord(mem));
		record->baseResource = GetResID(mem);
	}

	return ObjDisp(device)->BindBufferMemory(Unwrap(device), Unwrap(buffer), Unwrap(mem), memOffset);
}
Exemplo n.º 2
0
tBOOL GetFindThDic(tCHAR *szStr, RECORD *lpRetRec)
{
	THSTR_FORMAT ThStr;
	tINT nPos, i;
	STR_FORMAT Str;

	if (bOpenIndexThDic == FALSE) return FALSE;
	if (strlen(szStr) >= MAX_THSTR) return FALSE; // exception
	strcpy(ThStr.szStr, szStr);

	nPos = FindRecord(&RecThStr, &ThStr, TRUE, (CompProcP)CompRecThStr);

	if (nPos == -1) return FALSE;

	GetRecord(&RecThStr, nPos, &ThStr);

	i = 0;
	while (i < C_THSTR && ThStr.nStr[i] >= 0) {
		GetRecord(&RecStr, ThStr.nStr[i], &Str);

		AppendRecord(lpRetRec, &Str);
		i ++ ;
	}

	return TRUE;
}
Exemplo n.º 3
0
tBOOL DelHash(DWHASH_TYPE *lpHash, tVOID *lpItem, tINT nDelInfo)
{
	tINT nPos;
	DWHASH_BLOCK_TYPE HashItem;
	DWHASH_NEXT_TYPE NextItem;
	tINT i;

	nPos = lpHash->pHashCalFunc(lpItem);

	if (nPos < 0) nPos *= -1;
	if (nPos >= lpHash->nBucketCount) { // exception
		nPos %= lpHash->nBucketCount;
	}
	memcpy(&HashItem, lpHash->lpBuf + nPos*sizeof(DWHASH_BLOCK_TYPE), sizeof(DWHASH_BLOCK_TYPE));
	if (HashItem.nInfo == nDelInfo) { // 처음 것을 지울 때..
		if (HashItem.lpNextRec == NULL) {
			HashItem.nInfo = -1;
			memcpy(lpHash->lpBuf + nPos*sizeof(DWHASH_BLOCK_TYPE), &HashItem, sizeof(DWHASH_BLOCK_TYPE));
		}
		else { // 첫번째 것을 세팅한다.
			GetRecord(HashItem.lpNextRec, 0, &NextItem);
			DelRecord(HashItem.lpNextRec, 0);

			HashItem.nInfo = NextItem.nInfo;

			if (HashItem.lpNextRec->nUsed == 0) { // clear하자
				FreeRecord(HashItem.lpNextRec);
				free(HashItem.lpNextRec);
				HashItem.lpNextRec = NULL;
			}	
			memcpy(lpHash->lpBuf + nPos*sizeof(DWHASH_BLOCK_TYPE), &HashItem, sizeof(DWHASH_BLOCK_TYPE));
			if (lpHash->nCollision > 0) lpHash->nCollision --;
		}
	}
	else if (HashItem.lpNextRec) { // 더 있으면 더 찾아야지..
		for ( i = 0 ; i < HashItem.lpNextRec->nUsed ; i ++ ) {
			GetRecord(HashItem.lpNextRec, i, &NextItem);
			if (NextItem.nInfo == nDelInfo) {
				DelRecord(HashItem.lpNextRec, i);
				if (lpHash->nCollision > 0) lpHash->nCollision --;
				break;
			}
		}
		if (HashItem.lpNextRec->nUsed == 0) { // clear하자
			FreeRecord(HashItem.lpNextRec);
			free(HashItem.lpNextRec);
			HashItem.lpNextRec = NULL;
			memcpy(lpHash->lpBuf + nPos*sizeof(DWHASH_BLOCK_TYPE), &HashItem, sizeof(DWHASH_BLOCK_TYPE));
		}	
	}
	else { // not found
		return TRUE; 
	}
	return TRUE;
}
Exemplo n.º 4
0
tBOOL UpdateThTime(pthread_t ThreadId)
{
	tBOOL bRetVal = TRUE;
#if defined(_USE_SAFETH)
	tINT nItem;
	SAFETH_FORMAT SafeItem;
	time_t t = time(NULL);
	tINT last_state;

	if (!bStSafeTh) return TRUE;
	//pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &last_state);
	pthread_cleanup_push((tVOID *)pthread_mutex_unlock, (tVOID *)&gCheckTh);
	pthread_mutex_lock(&gCheckTh) ;

	SafeItem.ThreadId = ThreadId;

        nItem = FindRecord(&RecordThTime,  &SafeItem, TRUE, (CompProcP)Comp_ThreadId);
        if (nItem == -1) { // 새로운 thread
		bRetVal = FALSE;
		goto EndProc;
        }
        else {
                t = time(NULL); // 현재 시간..
                GetRecord(&RecordThTime, nItem, &SafeItem);
                memcpy(&(SafeItem.s_time), &t, sizeof(time_t));
                SetRecord(&RecordThTime, nItem, &SafeItem);
        }

EndProc:;
	//pthread_mutex_unlock(&gCheckTh);
	pthread_cleanup_pop(1);
	//pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &last_state);
#endif
	return bRetVal;
}
Exemplo n.º 5
0
int GlNormal3f(int argument_count, void* data)
{
    int error = 0;

    VALUE X = GetRecord("x", gCurrentContext);
    VALUE Y = GetRecord("y", gCurrentContext);
    VALUE Z = GetRecord("z", gCurrentContext);

    glNormal3f(TypeFloat(X), 
               TypeFloat(Y), 
               TypeFloat(Z));

    gLastExpression.type = VAL_NIL;
    gLastExpression.data.primitive = 0;
    return error;
}
Exemplo n.º 6
0
int GlColor3f(int argument_count, void* data)
{
    int error = 0;

    VALUE R = GetRecord("r", gCurrentContext);
    VALUE G = GetRecord("g", gCurrentContext);
    VALUE B = GetRecord("b", gCurrentContext);

    glColor3f(TypeFloat(R), 
              TypeFloat(G), 
              TypeFloat(B));

    gLastExpression.type = VAL_NIL;
    gLastExpression.data.primitive = 0;
    return error;
}
Exemplo n.º 7
0
tBOOL PutHash(DWHASH_TYPE *lpHash, tVOID *lpItem)
{
	tINT nPos;
	DWHASH_BLOCK_TYPE HashItem;
	DWHASH_NEXT_TYPE NextItem;
	tINT i;

	nPos = lpHash->pHashCalFunc(lpItem);

	if (nPos < 0) nPos *= -1;
	if (nPos >= lpHash->nBucketCount) { // exception
		nPos %= lpHash->nBucketCount;
	}
	memcpy(&HashItem, lpHash->lpBuf + nPos*sizeof(DWHASH_BLOCK_TYPE), sizeof(DWHASH_BLOCK_TYPE));
	if (HashItem.nInfo == -1) { // 없다.
		return FALSE;
	}
	lpHash->pHashPutFunc(lpItem, HashItem.nInfo);
	if (HashItem.lpNextRec) {
		for ( i = 0 ; i < HashItem.lpNextRec->nUsed ; i ++ ) {
			GetRecord(HashItem.lpNextRec, i, &NextItem);
			lpHash->pHashPutFunc(lpItem, NextItem.nInfo);

		}
	}

	return TRUE;
}
Exemplo n.º 8
0
/* parses(source) -> boolean */
int DuckParses(int argument_count, void* data)
{
    L_TOKEN*      lexing;
    char*         buffer;
    int           error = 0;

    VALUE argument = GetRecord("source", gCurrentContext);

    gLastExpression.type = VAL_PRIMITIVE;
    gLastExpression.data.primitive = 0;

    if (argument.type == VAL_STRING) 
    {
        lexing = LexSourceBuffer(argument.data.string, &buffer, CONTEXT_FREE_GRAMMAR);
        if (lexing == NULL) 
        {
            gLastExpression.data.primitive = -1;
            FreeLexing(lexing, buffer);
            //return 1;
            return 0;
        }
        gLastExpression.data.primitive = ParseSucceeds(lexing, PARSE_TABLE, CONTEXT_FREE_GRAMMAR);
        if (gLastExpression.data.primitive == 0) {
            FreeLexing(lexing, buffer);
            return 0;
        }

        /* free lexing */
        FreeLexing(lexing, buffer);
    }

    return error;
}
Exemplo n.º 9
0
wyChar *
wyIni::GetValue(const wyChar *sec,const wyChar *key,  wyChar *comment)
{
    struct tagSection *st = GetSection(sec);
    struct tagRecord *result;

    if(!st)
    {
        strcpy(comment,"");
        return "";
    }

	result =	GetRecord(st,key);	

	if(result != NULL)
	{
        strcpy(comment,result->m_comments.GetString());
        return (wyChar *)result->m_value.GetString();
	}	
	else
	{
		strcpy(comment,"");
		return "";
	}
}
Exemplo n.º 10
0
// needs to be separate because it releases internal resources
void WrappedVulkan::vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR obj, const VkAllocationCallbacks* pAllocator)
{
	// release internal rendering objects we created for rendering the overlay
	{
		SwapchainInfo &info = *GetRecord(obj)->swapInfo;

		RenderDoc::Inst().RemoveFrameCapturer(LayerDisp(m_Instance), info.wndHandle);

		VkRenderPass unwrappedRP = Unwrap(info.rp);
		GetResourceManager()->ReleaseWrappedResource(info.rp, true);
		ObjDisp(device)->DestroyRenderPass(Unwrap(device), unwrappedRP, NULL);

		for(size_t i=0; i < info.images.size(); i++)
		{
			VkFramebuffer unwrappedFB = Unwrap(info.images[i].fb);
			VkImageView unwrappedView = Unwrap(info.images[i].view);
			GetResourceManager()->ReleaseWrappedResource(info.images[i].fb, true);
			// note, image doesn't have to be destroyed, just untracked
			GetResourceManager()->ReleaseWrappedResource(info.images[i].im, true);
			GetResourceManager()->ReleaseWrappedResource(info.images[i].view, true);
			ObjDisp(device)->DestroyFramebuffer(Unwrap(device), unwrappedFB, NULL);
			ObjDisp(device)->DestroyImageView(Unwrap(device), unwrappedView, NULL);
		}
	}

	VkSwapchainKHR unwrappedObj = Unwrap(obj);
	GetResourceManager()->ReleaseWrappedResource(obj, true);
	ObjDisp(device)->DestroySwapchainKHR(Unwrap(device), unwrappedObj, pAllocator);
}
Exemplo n.º 11
0
void CDocStructRecordItem::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics) {
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    CDocStructRecord* pRecord = (CDocStructRecord*)GetRecord();
    if (pRecord == NULL) {
        return;
    }
    pDrawArgs->nTextAlign = DT_VCENTER;
    if (pRecord->m_nCurrentLayout == DocumentStructureLayout(Thumbnail)) {
        if (pRecord->IsPage()) {
            CRect rcCaption;
            rcCaption.SetRect(pDrawArgs->rcItem.left - RECORD_ITEM_OFFSET + 1, pDrawArgs->rcItem.bottom - RECORD_TEXT_OFFSET - 5, pDrawArgs->rcItem.right - pDrawArgs->pRow->GetTreeDepth() * RECORD_ITEM_OFFSET, pDrawArgs->rcItem.bottom);
            pDrawArgs->rcItem.SetRect(rcCaption.TopLeft(), rcCaption.BottomRight());
        } else {
            CRect rcCaption (pDrawArgs->rcItem);
            rcCaption.left += 3;
            rcCaption.right -= pDrawArgs->pRow->GetTreeDepth() * RECORD_ITEM_OFFSET;
            pDrawArgs->rcItem.SetRect(rcCaption.TopLeft(), rcCaption.BottomRight());
        }
    }

    // If this is a "click" page, draw icon in front of page title
    bool bDrawClickIcon = pRecord->IsPage() && pRecord->m_pContainer != NULL && pRecord->m_pContainer->ShowClickIcon(pRecord->m_pvData);
    if (bDrawClickIcon) { 
        CXTPReportPaintManager* pPaintManager = pDrawArgs->pControl->GetPaintManager();
        if (pPaintManager) {
            CRect rcCaption(pDrawArgs->rcItem);
            CRect rcBitmap(rcCaption.right-22, rcCaption.top, rcCaption.right-2, rcCaption.bottom);
            CSize csBitmap = ((CXTPDocumentStructurePaintManager*)pPaintManager)->DrawCustomBitmap(pDrawArgs->pDC, pDrawArgs->pRow, rcBitmap, 5);
            pDrawArgs->rcItem.right = rcBitmap.left;
        }
    }

    CXTPReportRecordItem::OnDrawCaption(pDrawArgs, pMetrics);
}
Exemplo n.º 12
0
HRESULT KG3DDefaultShaderGroupSolid::ReplaceDefaultShader( DWORD dwType, const KG3DDefaultShaderGroupElem& newShader, KG3DDefaultShaderGroupElem& oldShader)
{
	DefaultShaderRecord& DS =GetRecord(dwType);
	oldShader = DS.elem;
	DS.elem = newShader;
	return S_OK;
}
Exemplo n.º 13
0
	// get or create the record for a specified key
	void *Untyped::Open(Key aKey)
	{
		// convert key to a slot
		// (HACK: assume key is already a hash)
		size_t slot = FindSlot(aKey);

		// if the slot is not empty...
		if (slot != EMPTY)
		{
			// return the record
			return GetRecord(slot);
		}

		// grow if the database is full
		if (mCount >= mLimit)
			Grow();

		// add a new record
		void *record = AllocRecord(aKey);

		// check parent
		const void *source = mNil;
		if (this != &parent && parent.GetCount())
			if (Key aParentKey = parent.Get(aKey))
				source = Find(aParentKey);
		CreateRecord(record, source);

		// return the record
		return record;
	}
Exemplo n.º 14
0
// get value
wyInt32
wyIni::GetValue(const wyChar *sec,const wyChar *key, const wyChar *defval, wyString *returnedstring)
{
    struct  tagSection *st = GetSection(sec);
    struct  tagRecord *result;
    wyInt32 noofchars;

    if(!st)
    {
        noofchars = strlen(defval);
        returnedstring->SetAs(defval);
        return noofchars;
    }

	result =	GetRecord(st,key);	

	if(result != NULL)
    {
        returnedstring->SetAs(result->m_value.GetString());
        return result->m_value.GetLength();
    }
	/*else if(allkeylength == 1 || allkeylength == 0)
    {
		return allkeylength;
    }*/
    else
    {
        noofchars = strlen(defval);
        returnedstring->SetAs(defval);
        return noofchars;
    }
}
Exemplo n.º 15
0
int DatosProceso(int id,Tipo_Proceso *pProceso,char szProceso[])
{
	char szSql[1000];
	Tipo_XML *xml=NULL;
	int sts;
	sprintf(szSql,"select ip,cantidad,port from procesos where proceso='%s'",szProceso);
	xml=GetRecord(id,szSql,xml,&sts);
	if (sts==0) 
	{
		printf("El proceso %s, no existe en la tabla de procesos\n\r",szProceso);
		xml=CierraXML(xml);
		exit(1);
	}

	//ImprimeXML(xml);
	if (!GetIntXML(xml,"CANTIDAD",&pProceso->nCantidad)) goto close;
	if (!GetIntXML(xml,"PORT",&pProceso->nPort)) goto close;
	//if (!GetIntXML(xml,"FORMA_CONEXION_BD",&pProceso->nFormaConexionBD)) goto close;
	GetStrXML(xml,"IP",pProceso->szIp,sizeof(pProceso->szIp));
	xml=CierraXML(xml);
	global.nProcesos = pProceso->nCantidad;
	return 1;
close:
	CloseDatabase(id);
	exit(1);
}
Exemplo n.º 16
0
int dbDatabase::GetRecord(const String &tbname, int recno, dbRecord& Record) {
  int h;

  if((h = GetTableHandle(tbname)) == MTDB_TB_NOT_FOUND)
  	return MTDB_TB_NOT_FOUND;

	return GetRecord(h, recno, Record);
}
Exemplo n.º 17
0
string CIniFile::GetValue(string KeyName, string SectionName, string FileName)
{
	vector<Record> content = GetRecord(KeyName,SectionName, FileName);		// Get the Record

	if(!content.empty())													// Make sure there is a value to return
		return content[0].Value;											// And return the value

	return "";																// No value was found
}
Exemplo n.º 18
0
/*Math.pow(base, exponent)*/
int MathPow(int arg_count){
  float base = 0.0;
  float exponent = 0.0;
  float val = 0.0;

  VALUE base_arg = GetRecord("base", gCurrentContext);
  VALUE exp_arg = GetRecord("exponent", gCurrentContext);

  base = TypeFloat(base_arg);
  exponent = TypeFloat(exp_arg);

  val = pow(base, exponent);

  gLastExpression.type = VAL_FLOATING_POINT;
  gLastExpression.floatp = val;

  return 0;
}
Exemplo n.º 19
0
/* float(value) */
int DuckFloat(int argument_count, void* data)
{
    int error = 0;

    VALUE argument = GetRecord("value", gCurrentContext);

    gLastExpression.type = VAL_FLOATING_POINT;
    gLastExpression.data.floatp = TypeFloat(argument);
    
    return error;
}
Exemplo n.º 20
0
VkResult WrappedVulkan::vkFlushMappedMemoryRanges(
			VkDevice                                    device,
			uint32_t                                    memRangeCount,
			const VkMappedMemoryRange*                  pMemRanges)
{
	if(m_State >= WRITING)
	{
		bool capframe = false;
		{
			SCOPED_LOCK(m_CapTransitionLock);
			capframe = (m_State == WRITING_CAPFRAME);
		}

		for(uint32_t i = 0; i < memRangeCount; i++)
		{
			ResourceId memid = GetResID(pMemRanges[i].memory);
			
			MemMapState *state = GetRecord(pMemRanges[i].memory)->memMapState;
			state->mapFlushed = true;

			if(state->mappedPtr == NULL)
			{
				RDCERR("Flushing memory that isn't currently mapped");
				continue;
			}

			if(capframe)
			{
				CACHE_THREAD_SERIALISER();

				SCOPED_SERIALISE_CONTEXT(FLUSH_MEM);
				Serialise_vkFlushMappedMemoryRanges(localSerialiser, device, 1, pMemRanges + i);

				m_FrameCaptureRecord->AddChunk(scope.Get());
				GetResourceManager()->MarkResourceFrameReferenced(GetResID(pMemRanges[i].memory), eFrameRef_Write);
			}
			else
			{
				GetResourceManager()->MarkDirtyResource(memid);
			}
		}
	}
	
	VkMappedMemoryRange *unwrapped = GetTempArray<VkMappedMemoryRange>(memRangeCount);
	for(uint32_t i=0; i < memRangeCount; i++)
	{
		unwrapped[i] = pMemRanges[i];
		unwrapped[i].memory = Unwrap(unwrapped[i].memory);
	}

	VkResult ret = ObjDisp(device)->FlushMappedMemoryRanges(Unwrap(device), memRangeCount, unwrapped);

	return ret;
}
Exemplo n.º 21
0
VkResult WrappedVulkan::vkMapMemory(
			VkDevice                                    device,
			VkDeviceMemory                              mem,
			VkDeviceSize                                offset,
			VkDeviceSize                                size,
			VkMemoryMapFlags                            flags,
			void**                                      ppData)
{
	void *realData = NULL;
	VkResult ret = ObjDisp(device)->MapMemory(Unwrap(device), Unwrap(mem), offset, size, flags, &realData);

	if(ret == VK_SUCCESS && realData)
	{
		ResourceId id = GetResID(mem);

		if(m_State >= WRITING)
		{
			VkResourceRecord *memrecord = GetRecord(mem);

			// must have map state, only non host visible memories have no map
			// state, and they can't be mapped!
			RDCASSERT(memrecord->memMapState);
			MemMapState &state = *memrecord->memMapState;

			// ensure size is valid
			RDCASSERT(size == VK_WHOLE_SIZE || (size > 0 && size <= memrecord->Length));

			state.mappedPtr = (byte *)realData;
			state.refData = NULL;

			state.mapOffset = offset;
			state.mapSize = size == VK_WHOLE_SIZE ? memrecord->Length : size;
			state.mapFlushed = false;

			*ppData = realData;

			if(state.mapCoherent)
			{
				SCOPED_LOCK(m_CoherentMapsLock);
				m_CoherentMaps.push_back(memrecord);
			}
		}
		else
		{
			*ppData = realData;
		}
	}
	else
	{
		*ppData = NULL;
	}

	return ret;
}
Exemplo n.º 22
0
HRESULT WrappedID3D12Device::CreateCommandSignature(const D3D12_COMMAND_SIGNATURE_DESC *pDesc,
                                                    ID3D12RootSignature *pRootSignature,
                                                    REFIID riid, void **ppvCommandSignature)
{
  if(ppvCommandSignature == NULL)
    return m_pDevice->CreateCommandSignature(pDesc, Unwrap(pRootSignature), riid, NULL);

  if(riid != __uuidof(ID3D12CommandSignature))
    return E_NOINTERFACE;

  ID3D12CommandSignature *real = NULL;
  HRESULT ret =
      m_pDevice->CreateCommandSignature(pDesc, Unwrap(pRootSignature), riid, (void **)&real);

  if(SUCCEEDED(ret))
  {
    SCOPED_LOCK(m_D3DLock);

    if(GetResourceManager()->HasWrapper(real))
    {
      real->Release();
      ID3D12CommandSignature *existing =
          (ID3D12CommandSignature *)GetResourceManager()->GetWrapper(real);
      existing->AddRef();
      *ppvCommandSignature = existing;
      return ret;
    }

    WrappedID3D12CommandSignature *wrapped = new WrappedID3D12CommandSignature(real, this);

    if(m_State >= WRITING)
    {
      SCOPED_SERIALISE_CONTEXT(CREATE_COMMAND_SIG);
      Serialise_CreateCommandSignature(pDesc, pRootSignature, riid, (void **)&wrapped);

      D3D12ResourceRecord *record = GetResourceManager()->AddResourceRecord(wrapped->GetResourceID());
      record->type = Resource_CommandSignature;
      record->Length = 0;
      wrapped->SetResourceRecord(record);

      if(pRootSignature)
        record->AddParent(GetRecord(pRootSignature));
      record->AddChunk(scope.Get());
    }
    else
    {
      GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped);
    }

    *ppvCommandSignature = (ID3D12CommandSignature *)wrapped;
  }

  return ret;
}
Exemplo n.º 23
0
/* int(value) */
int DuckInt(int argument_count, void* data)
{
    int error = 0;

    VALUE argument = GetRecord("value", gCurrentContext);

    gLastExpression.type = VAL_PRIMITIVE;
    gLastExpression.data.primitive = TypeInt(argument);
    
    return error;
}
Exemplo n.º 24
0
void WrappedVulkan::vkGetPhysicalDeviceMemoryProperties(
    VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties *pMemoryProperties)
{
  if(pMemoryProperties)
  {
    *pMemoryProperties = *GetRecord(physicalDevice)->memProps;
    return;
  }

  ObjDisp(physicalDevice)->GetPhysicalDeviceMemoryProperties(Unwrap(physicalDevice), pMemoryProperties);
}
Exemplo n.º 25
0
// append list
void 
wyIni::Append(const wyChar *sec,const wyChar *key,const wyChar *value)
{
	struct tagSection *tmp_sec;
	struct tagRecord *temp;	
	
	// find section
	tmp_sec = GetSection(sec);

	if(tmp_sec != NULL)
	{
		temp = GetRecord(tmp_sec,key);
		if(temp == NULL)
		{
			//temp = (struct record *)malloc(sizeof(struct record));
            temp = new  tagRecord;
			if(temp == NULL)
			{
				m_errormsg = "cannot malloc memory !";
				return;
			}
			temp->m_next = NULL;	
			
            if(key)
                temp->m_key.SetAs(key);
            if(value)
                temp->m_value.SetAs(value);			

			tmp_sec->m_datasize++;

			if (tmp_sec->m_datafirst == NULL)
			{
				tmp_sec->m_datafirst = temp;
				tmp_sec->m_datalast  = temp;
			}
			else
			{
				tmp_sec->m_datalast->m_next = temp;
				tmp_sec->m_datalast = temp;
			}			
		}
		else if(m_flag == REPLACE)
		{
            temp->m_key.SetAs(key);
            temp->m_value.SetAs(value);
		}
		
	}
	else
	{
		AddSection(sec,"");
		Append(sec,key,value);
	}
}
Exemplo n.º 26
0
static int ConvertLog(FILE *input, FILE *output, char *format)
{
    u2record tmp_record;

    /* Determine conversion function */
    int (* ConvertRecord)(u2record *, FILE *) = NULL;

    /* This will become an if/else series once more formats are supported.
     * Callbacks are used so that this comparison only needs to happen once. */
    if (strncmp(format, "pcap", 4) == 0)
    {
        ConvertRecord = PcapConversion;
    }

    /* Initialize the record's data pointer */
    tmp_record.data = malloc(MAX_U2RECORD_DATA_LENGTH * sizeof(uint8_t));
    if (tmp_record.data == NULL)
    {
        fprintf(stderr, "Error allocating memory, aborting...\n");
        return FAILURE;
    }

    /* Run through input file and convert records */
    while ( !(feof(input) || ferror(input) || ferror(output)) )
    {
        if (GetRecord(input, &tmp_record) == FAILURE)
        {
            break;
        }
        if (ConvertRecord(&tmp_record, output) == FAILURE)
        {
            break;
        }
    }
    if (tmp_record.data != NULL)
    {
        free(tmp_record.data);
        tmp_record.data = NULL;
    }
    if (ferror(input))
    {
        fprintf(stderr, "Error reading input file, aborting...\n"); 
        return FAILURE;
    }
    if (ferror(output))
    {
        fprintf(stderr, "Error reading output file, aborting...\n");
        return FAILURE;
    }

    return SUCCESS;
}
Exemplo n.º 27
0
void CMyEditShowList::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{	
	CEdit::OnChar(nChar, nRepCnt, nFlags);
	oncharflag=true;
	CString str;
    CGATHEROUT *cwnd=( CGATHEROUT *)GetParent();
	CRect rect1;cwnd->GetClientRect(rect1);
    ClientToScreen(rect1);	
	CRect rect;
	GetClientRect(rect);
	int a=rect.left;
	int b=rect.top;
	ClientToScreen(rect);
	if(!m_list)
	{
	  m_list.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT,CRect(rect.left,rect.top,rect.right+200,rect.bottom+200), cwnd, 1);	
	  m_list.InsertColumn(0,"商品编号",LVCFMT_LEFT,60);
	  m_list.InsertColumn(1,"商品名称",LVCFMT_LEFT,60);
	  m_list.InsertColumn(2,"单价",LVCFMT_LEFT,60);
	  m_list.InsertColumn(3,"规格型号",LVCFMT_LEFT,60);
	  m_list.InsertColumn(4,"供应商",LVCFMT_LEFT,60);
	  m_list.InsertColumn(5,"单位",LVCFMT_LEFT,60);
	  m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
	}
	TEXTMETRIC Metrics ;
	CDC * dc=this->GetDC();
	dc->GetTextMetrics(&Metrics) ; 
	 
	if(nChar!=VK_BACK)
	{   
		this;
		cwnd->UpdateData();
		querystr=cwnd->m_mercid;
		width+=Metrics.tmHeight/8;
        m_list.MoveWindow(rect.left-100+width,rect.top-100,rect.right+width,rect.bottom-500,true);
	}
    else
	{
		querystr=querystr.Mid(0,querystr.GetLength()-1);
        width-=Metrics.tmHeight/8;
        m_list.MoveWindow(rect.left-100+width,rect.top-100,rect.right+width,rect.bottom-500,true);
	}
	if(nChar==VK_DOWN)
	{
	
		::SetFocus(m_list.m_hWnd);
	}
	str.Format("select * from tb_merchangiseinfo where id like '%%%s%%'",querystr);
    GetRecord(str);

	SetListValue("");
}
Exemplo n.º 28
0
/*Math.tan(angle)*/
int MathTan(int arg_count){
  float angle = 0.0;
  float val = 0.0;
  VALUE argument = GetRecord("angle", gCurrentContext);

  angle = TypeFloat(argument);
  val = tan(angle);

  gLastExpression.type = VAL_FLOATING_POINT;
  gLastExpression.floatp = val;

  return 0;
}
Exemplo n.º 29
0
	// clear all records
	void Untyped::Clear(void)
	{
		for (size_t slot = 0; slot < mCount; ++slot)
		{
			void *record = GetRecord(slot);
			DeleteRecord(record);
			mPool->Free(record);
		}
		memset(mMap, EMPTY, mLimit * 2 * sizeof(size_t));
		memset(mKey, 0, mLimit * sizeof(Key));
		memset(mData, 0, mLimit * sizeof(void *));
		mCount = 0;
	}
Exemplo n.º 30
0
/*Math.atan(num)*/
int MathAtan(int arg_count){
  float input = 0.0;
  float val = 0.0;
  VALUE argument = GetRecord("num", gCurrentContext);

  input = TypeFloat(argument);
  val = atan(input);

  gLastExpression.type = VAL_FLOATING_POINT;
  gLastExpression.floatp = val;

  return 0;
}