Exemple #1
0
int
mts_connect (long reconnect)
{
  if (reconnect)
    vd_use_mts = 1;
  if (!reconnect && local_rm)
    goto ret;
  LOCK_OBJECT (local_rm);
  if (local_rm)
    {
      if (!reconnect)
	{
	  RELEASE_OBJECT (local_rm);
	  goto ret;
	}
      free_RM (&local_rm);
    }
  local_rm = init_RM ();
  if (!local_rm)
    {
      RELEASE_OBJECT (local_rm);
      return 0;
    };
  RELEASE_OBJECT (local_rm);
ret:
  return 1;
}
Exemple #2
0
int
mts_trx_enlist (lock_trx_t * lt, caddr_t tr_cookie, unsigned long len)
{
  if (!local_rm)
    {
      return 1;
    }
  DOUBLE_LOCK (trx_import, enlist);
  if (!local_rm->rm)
    {
      RELEASE_OBJECT (local_rm);
      return 0;
    }
  try
  {
    HRESULT hr =
	DtcGetTransactionManager (0, 0, __uuidof (ITransactionImport),
	0, 0, 0, (void **) &local_rm->trx_import);
    MTS_THROW_ASSERT (hr, "Get Transaction Import");
  }
  catch (const mts_error & err)
  {
    err.dump ();
    RELEASE_OBJECT (local_rm);
    return err.get_errcode ();
  }
  RELEASE_OBJECT (local_rm);
enlist:
  try
  {
    auto_interface < ITransaction > itrx;
    tp_data_t *tpd;
    HRESULT hr = local_rm->trx_import->Import (len,
	(BYTE *) tr_cookie,
	(IID *) & __uuidof (ITransaction),
	(void **) &itrx.get ());
    MTS_THROW_ASSERT (hr, "Import transaction");

    hr = mts_trx_enlist_loc (lt->lt_client, itrx.get ());
    MTS_THROW_ASSERT (hr, "Enlist local transaction");
    tpd = (tp_data_t *) dk_alloc (sizeof (tp_data_t));
    memset (tpd, 0, sizeof (tp_data_t));
    tpd->cli_tp_enlisted = CONNECTION_PREPARED;
    tpd->cli_tp_trx = itrx.release ();
    tpd->cli_tp_sem2 = semaphore_allocate (0);
    lt->lt_client->cli_tp_data = tpd;
    lt->lt_2pc._2pc_type = tpd->cli_trx_type = TP_MTS_TYPE;
#ifdef MSDTC_DEBUG
    lt->lt_in_mts = 1;
#endif
  }
  catch (const mts_error & err)
  {
    err.dump ();
    return err.get_errcode ();
  }
  return 0;
};
//
// Super
//
void Super_KillGlobals(void)
{
	// free the other allocated
	// arrays
	//free(ant_globals->score_obj);	
	//free(ant_globals);
	RELEASE_OBJECT(ant_globals->score_obj);	
	RELEASE_OBJECT(ant_globals);

} // end of the function 
Exemple #4
0
box_t
mts_server_status ()
{
  LOCK_OBJECT (local_rm);
  if (local_rm)
    {
      RELEASE_OBJECT (local_rm);
      return box_dv_short_string ("connected");
    }
  else
    {
      RELEASE_OBJECT (local_rm);
      return box_dv_short_string ("disconnected");
    }
}
Exemple #5
0
caddr_t
mts_get_rmcookie ()
{
  if (!local_rm)
    {
      return 0;
    }

  DOUBLE_LOCK (rmcookie, alloc_ret);

  try
  {
    auto_interface < ITransactionImportWhereabouts > import_abouts;
    HRESULT hr = DtcGetTransactionManager (0,
	0,
	__uuidof (ITransactionImportWhereabouts),
	0,
	0,
	0,
	(void **) &import_abouts.get ());
    MTS_THROW_ASSERT (hr, "Get ITransactionImportWhereabouts");

    hr = import_abouts->GetWhereaboutsSize (&local_rm->rmcookie_len);
    MTS_THROW_ASSERT (hr, "GetTransactionImportWhereaboutsLen");

    DWORD used;
    auto_dkptr < BYTE >
	whereabouts_aptr ((BYTE *) dk_alloc (sizeof (BYTE) *
	    local_rm->rmcookie_len));
    hr = import_abouts->GetWhereabouts (local_rm->rmcookie_len,
	whereabouts_aptr.get (), &used);

    local_rm->rmcookie = whereabouts_aptr.release ();
  }
  catch (const mts_error & err)
  {
    RELEASE_OBJECT (local_rm);
    err.dump ();
    return 0;
  }
  RELEASE_OBJECT (local_rm);

alloc_ret:
  caddr_t cookie = (caddr_t) dk_alloc_box (local_rm->rmcookie_len, DV_BIN);
  memcpy (cookie, local_rm->rmcookie, local_rm->rmcookie_len);

  return cookie;
};
Exemple #6
0
int
mts_trx_enlist_loc (client_connection_t * connection, ITransaction * itrn)
{
  MTS_TRACE (("mts_trx_enlist_loc client (%x)\n", connection));
  CTransactResourceAsync *ctra = 0;
  try
  {
    if (!itrn)
      {
	throw mts_error (0, "uninitialized ITransaction object");
      }
    XACTUOW guid;
    long used;
    ctra = new CTransactResourceAsync;
    ITransactionEnlistmentAsync *enlistment;

    LOCK_OBJECT (local_rm);
    HRESULT hr = local_rm->rm->Enlist (itrn, ctra, &guid, &used, &enlistment);
    RELEASE_OBJECT (local_rm);
    MTS_THROW_ASSERT (hr, "Enlisting");

    ctra->SetEnlistment (enlistment);
    ctra->SetConnection (connection);
  }
  catch (const mts_error & err)
  {
    delete ctra;
    err.dump ();
    return err.get_errcode ();
  }
  return 0;
}
//
// 
// Rewrite File
//
// if the file doesnt exist
//
void Rewrite_File(void)
{
	int i =0;
	int f_flag = 0;

	// who needs types
	void  *tmp = NULL;
	float *tmp_f = NULL;
	int	  *tmp_i = NULL;

	f_newfile = fopen(CONFIG_FILE_NAME, "w");


	for (i = 0; i < MAX_TXT_MSGS; i++)
	{
		fprintf(f_newfile, "%s", text_msg[i]);
	} // end of the for 



	for (i = 0; i < MAX_ERRORS; i++)
	{
		if (i == 0)
			continue;

		fprintf(f_newfile, "[");
		fprintf(f_newfile, "%s", error_str[i]);
		fprintf(f_newfile, "]=");

		f_flag = 0;

		tmp = Get_ConfValue(i, &f_flag);
		
		if (f_flag) {
			tmp_f = (float *)tmp;
			fprintf(f_newfile,"%0.2ff;\n", (float &)*tmp_f);
		} else{
			tmp_i = (int *)tmp;
			fprintf(f_newfile,"%d;\n", (int &)*tmp_i);
		} // end of if-else



		//free(tmp);
		RELEASE_OBJECT(tmp);
		tmp = NULL;

	} // end of the for 

	fprintf(f_newfile, "\n\n");

	fclose(f_newfile);

} // end of the function 
Exemple #8
0
//Implementation of DeviceClose routine.
static DWORD FatDeviceClose(__COMMON_OBJECT* lpDrv,
                            __COMMON_OBJECT* lpDev,
                            __DRCB* lpDrcb)
{
    __DEVICE_OBJECT*        pDeviceObject    = (__DEVICE_OBJECT*)lpDev;
    __FAT32_FS*             pFat32Fs         = NULL;
    __FAT32_FILE*           pFileObject      = NULL;
    DWORD                   _dwFlags;

    if((NULL == pDeviceObject) || (NULL == lpDrcb))
    {
        return 0;
    }
    pFileObject = (__FAT32_FILE*)pDeviceObject->lpDevExtension;
    pFat32Fs    = pFileObject->pFileSystem;
    //Delete the fat32 file object from file system.
    __ENTER_CRITICAL_SECTION(NULL, _dwFlags);
    if((pFileObject->pPrev == NULL) && (pFileObject->pNext == NULL))
    {
        pFat32Fs->pFileList = NULL;
    }
    else
    {
        if(pFileObject->pPrev == NULL)  //This is the first object in file list.
        {
            pFat32Fs->pFileList = pFileObject->pNext;
            pFileObject->pNext->pPrev = NULL;
        }
        else  //Not the fist file in list.
        {
            if(NULL == pFileObject->pNext)  //This is the last one in list.
            {
                pFileObject->pPrev->pNext = NULL;
            }
            else  //Neither is the first nor is the last one in list.
            {
                pFileObject->pPrev->pNext = pFileObject->pNext;
                pFileObject->pNext->pPrev = pFileObject->pPrev;
            }
        }
    }
    __LEAVE_CRITICAL_SECTION(NULL, _dwFlags);
    //Release the file object.
    RELEASE_OBJECT(pFileObject);

    //Destroy file device object.
    IOManager.DestroyDevice((__COMMON_OBJECT*)&IOManager,pDeviceObject);

    return 0;
}
//
// Shutdown Nests
//
static void Shutdown_Pheromones(void)
{
	int index = 0;

	for (index = 0; index <  CURRENT_BOT.max_items; index++)
	{
		 CURRENT_BOT.destroy( CURRENT_BOT.objects[index]);

	} // end of the for 

	// Shrug, free the ptr-to-ptrs
	//free(CURRENT_BOT.objects);	
	RELEASE_OBJECT(CURRENT_BOT.objects);


} // end of the function
Exemple #10
0
//Initialize FAT32 partition,this routine is called by CheckPartition,which is then
//called by CreateDevice of IOManager.
static __FAT32_FS* InitFat32(__COMMON_OBJECT* pPartObj)
{
    __DEVICE_OBJECT*  pPartition  = (__DEVICE_OBJECT*)pPartObj;
    __FAT32_FS*       pFatObject = NULL;
    BYTE              buff[SECTOR_SIZE];

    if(NULL == pPartition)
    {
        goto __TERMINAL;
    }

    //Check the validity of partition device object.
    if(DEVICE_OBJECT_SIGNATURE != pPartition->dwSignature)  //Invalid signature.
    {
        goto __TERMINAL;
    }

    if(!ReadDeviceSector(pPartObj,
                         0,
                         1,
                         buff))
    {
        PrintLine("Can not read sector 0.");
        goto __TERMINAL;
    }
    pFatObject = (__FAT32_FS*)CREATE_OBJECT(__FAT32_FS);
    if(NULL == pFatObject)  //Can not create FAT32 object.
    {
        goto __TERMINAL;
    }
    pFatObject->pPartition = pPartObj;    //Very important.
    //Initialize the FAT32 file system.
    if(!Fat32Init(pFatObject,buff))
    {
        PrintLine("Can not initialize the FAT32 file system.");
        RELEASE_OBJECT(pFatObject);       //Release it.
        pFatObject = NULL;
        goto __TERMINAL;
    }
    GetVolumeLbl(pFatObject,pFatObject->VolumeLabel);  //This operation may failed,but we no
    //need to concern it.
    DumpFat32(pFatObject);
__TERMINAL:
    return pFatObject;
}
Exemple #11
0
GdiFont::~GdiFont(void)
{

	size_t size = m_FontTextures.size();
	while (m_FontTextures.empty()==false)
	{
		HTEXTURE hTex = m_FontTextures.front();
		m_FontTextures.pop_front();
		m_pHGE->Texture_Free(hTex);
	}

	if ((m_hBitmap)) DeleteObject(m_hBitmap);
	if ((m_hFont)) DeleteObject(m_hFont);
	if ((m_hBrush)) DeleteObject(m_hBrush);
	if ((m_hMemDC)) DeleteDC(m_hMemDC);

	DELETE_OBJECT(m_pSprite);
	RELEASE_OBJECT(m_pHGE);
}
Exemple #12
0
//Implementation of CreateFile for FAT file system.
static __COMMON_OBJECT* FatDeviceOpen(__COMMON_OBJECT* lpDrv,
                                      __COMMON_OBJECT* lpDev,
                                      __DRCB* lpDrcb)   //Open file.
{
    __FAT32_FILE*       pFat32File    = NULL;
    __FAT32_FS*         pFat32Fs      = NULL;
    __COMMON_OBJECT*    pFileDevice   = NULL;
    CHAR                FileName[MAX_FILE_NAME_LEN];
    __FAT32_SHORTENTRY  ShortEntry;
    DWORD               dwDirClus     = 0;
    DWORD               dwDirOffset   = 0;
    DWORD               dwFlags;
    static CHAR         NameIndex     = 0;
    BOOL                bResult       = FALSE;
    CHAR                FileDevName[16];

    if((NULL == lpDrv) || (NULL == lpDev))
    {
        goto __TERMINAL;
    }
    pFat32Fs = (__FAT32_FS*)(((__DEVICE_OBJECT*)lpDev)->lpDevExtension);
    //strcpy(FileName,(LPSTR)lpDrcb->lpInputBuffer);
    StrCpy((LPSTR)lpDrcb->lpInputBuffer,FileName);
    ToCapital(FileName);
    if(!GetDirEntry(pFat32Fs,&FileName[0],&ShortEntry,&dwDirClus,&dwDirOffset))
    {
        goto __TERMINAL;
    }

    if(FILE_ATTR_DIRECTORY & ShortEntry.FileAttributes)  //Is a directory.
    {
        goto __TERMINAL;
    }
    //Create a file object.
    pFat32File = (__FAT32_FILE*)CREATE_OBJECT(__FAT32_FILE);
    if(NULL == pFat32File)
    {
        goto __TERMINAL;
    }
    pFat32File->Attributes     = ShortEntry.FileAttributes;
    pFat32File->dwClusOffset   = 0;
    pFat32File->bInRoot        = FALSE;          //Caution,not check currently.
    pFat32File->dwCurrClusNum  = ((DWORD)ShortEntry.wFirstClusHi << 16)
                                 + (DWORD)ShortEntry.wFirstClusLow;
    pFat32File->dwCurrPos      = 0;
    pFat32File->dwFileSize     = ShortEntry.dwFileSize;
    pFat32File->dwOpenMode     = lpDrcb->dwInputLen;     //dwInputLen is used to contain open mode.
    pFat32File->dwShareMode    = lpDrcb->dwOutputLen;    //dwOutputLen is used to contain share mode.
    pFat32File->dwStartClusNum = pFat32File->dwCurrClusNum;
    pFat32File->pFileSystem    = pFat32Fs;
    pFat32File->pPartition     = pFat32Fs->pPartition;   //CAUTION!!!
    pFat32File->dwParentClus   = dwDirClus;              //Save parent directory's information.
    pFat32File->dwParentOffset = dwDirOffset;
    pFat32File->pNext          = NULL;
    pFat32File->pPrev          = NULL;
    //Now insert the file object to file system object's file list.
    __ENTER_CRITICAL_SECTION(NULL,dwFlags);
    if(pFat32Fs->pFileList == NULL)  //Not any file object in list yet.
    {
        pFat32Fs->pFileList = pFat32File;
        pFat32File->pNext = NULL;
        pFat32File->pPrev = NULL;
    }
    else
    {
        pFat32File->pNext = pFat32Fs->pFileList;
        pFat32Fs->pFileList->pPrev = pFat32File;

        pFat32File->pPrev = NULL;
        pFat32Fs->pFileList = pFat32File;
    }
    __LEAVE_CRITICAL_SECTION(NULL,dwFlags);
    //Now create file device object.
    //strcpy(FileDevName,FAT32_FILE_NAME_BASE);
    StrCpy(FAT32_FILE_NAME_BASE,FileDevName);
    FileDevName[13] += NameIndex;
    NameIndex ++;
    pFileDevice = (__COMMON_OBJECT*)IOManager.CreateDevice((__COMMON_OBJECT*)&IOManager,
                  FileDevName,
                  DEVICE_TYPE_FILE,
                  1, //For file,block size is 1.
                  DEVICE_BLOCK_SIZE_ANY,
                  DEVICE_BLOCK_SIZE_ANY,
                  pFat32File,
                  (__DRIVER_OBJECT*)lpDrv);
    if(NULL == pFileDevice)
    {
        goto __TERMINAL;
    }
    bResult = TRUE;
__TERMINAL:
    if(!bResult)  //The transaction has failed.
    {
        if(pFat32File)
        {
            RELEASE_OBJECT(pFat32File);
        }
        if(pFileDevice)
        {
            IOManager.DestroyDevice((__COMMON_OBJECT*)&IOManager,
                                    (__DEVICE_OBJECT*)pFileDevice);
        }
        return NULL;
    }
    return pFileDevice;
}
//
// DestroyBot
//
static void DestroyGarden(CURRENT_PTR b)
{
    //free(b);
    RELEASE_OBJECT(b);

} // end of the function
Exemple #14
0
//For each extension partition in hard disk,this function travels the
//extension partition table list,to install one by one into IOManager.
//How many logical partition(s) is returned.
static int InitExtension(int nHdNum,          //The hard disk number.
						 BYTE* pSector0,      //First sector of extension partition.
						 DWORD dwStartSector, //Position of this partition,in physical disk.
						 DWORD dwExtendStart, //Start position of extension partition.
						 int nBaseNumber,     //The partition base number.
						 __DRIVER_OBJECT* lpDrvObject)
{
	__DEVICE_OBJECT* pDevObject = NULL;
	__PARTITION_EXTENSION* pPe = NULL;
	BYTE* pStart = NULL;
	BYTE  buffer[512];  //Buffer used to read one sector.
	DWORD dwNextStart;  //Next extension's start sector if any.
	DWORD dwAttributes = DEVICE_TYPE_PARTITION;
	CHAR strDevName[MAX_DEV_NAME_LEN + 1];
	DWORD dwFlags;
	int nPartitionNum = 0;

	if((NULL == pSector0) || (NULL == lpDrvObject)) //Invalid parameters.
	{
		goto __TERMINAL;
	}
	//Locate the partition table's position.
	pStart = pSector0 + 0x1BE;
	if(0 == *(pStart + 4)) //Partition type is zero,invalid.
	{
		goto __TERMINAL;
	}
	//Now create the partition extension object and initialize it.
	pPe = (__PARTITION_EXTENSION*)CREATE_OBJECT(__PARTITION_EXTENSION);
	if(NULL == pPe)
	{
		goto __TERMINAL;
	}
	pPe->dwCurrPos     = 0;
	pPe->BootIndicator = *pStart;
	pStart += 4;
	pPe->PartitionType = *pStart;
	pStart += 4;
	pPe->dwStartSector = *(DWORD*)pStart;
	pStart += 4;
	pPe->dwSectorNum   = *(DWORD*)pStart;
	pStart += 4;  //Now pStart pointing to next partition entry.
	//Validate if all parameters are correct.
	if((pPe->dwStartSector == 0)  ||  //Should invalid.
	   (pPe->dwSectorNum   == 0))     //Impossible.
	{
		goto __TERMINAL;
	}
	switch(pPe->PartitionType)
	{
	case 0x0B:  //FAT32
	case 0x0C:  //FAT32
	case 0x0E:
		dwAttributes |= DEVICE_TYPE_FAT32;
		break;
	case 0x07:
		dwAttributes |= DEVICE_TYPE_NTFS;
		break;
	default:
		break;
	}
	pPe->dwStartSector += dwStartSector;  //Adjust the start sector to physical one.
	//Partiton information is OK,now create the device object.
	StrCpy(PARTITION_NAME_BASE,strDevName); //Form device name.
	__ENTER_CRITICAL_SECTION(NULL, dwFlags);
	strDevName[StrLen(PARTITION_NAME_BASE) - 1] += (CHAR)IOManager.dwPartitionNumber;
	IOManager.dwPartitionNumber += 1;
	__LEAVE_CRITICAL_SECTION(NULL, dwFlags);
	pDevObject = IOManager.CreateDevice(
		(__COMMON_OBJECT*)&IOManager,
		strDevName,
		dwAttributes,
		512,
		16384,
		16384,
		pPe,
		lpDrvObject);
	nPartitionNum += 1;

	//Now check the next table entry to see if there is another extension embeded.
	if(*(pStart + 4) == 0x05)  //Is a extension partition.
	{
		dwNextStart = dwExtendStart + (*(DWORD*)(pStart + 8));
		if(!ReadSector(
			nHdNum,
			dwNextStart,
			1,
			buffer))
		{
			goto __TERMINAL;
		}
		nPartitionNum += InitExtension(
			nHdNum,
			buffer,
			pPe->dwStartSector + pPe->dwSectorNum,//dwStartSector,
			dwExtendStart,
			nBaseNumber + 1,
			lpDrvObject);
	}

__TERMINAL:
	if(0 == nPartitionNum)  //Not any logical partiton is created.
	{
		if(pPe)
		{
			RELEASE_OBJECT(pPe);
		}
		if(pDevObject)
		{
			IOManager.DestroyDevice((__COMMON_OBJECT*)&IOManager,
				pDevObject);
		}
	}
	return nPartitionNum;
}
Exemple #15
0
//This function travels all partition table in sector 0 in current
//hard disk,from the MBR,to install each primary partition into IOManager.
//For extension partition,it calls InitExtension function to install.
static int InitPartitions(int nHdNum,
						  BYTE* pSector0,
						  __DRIVER_OBJECT* lpDrvObject)
{
	static int nPartNum = 0;  //How many partitons in current system.
	__DEVICE_OBJECT* pDevObject = NULL;
	__PARTITION_EXTENSION* pPe  = NULL;
	BYTE* pStart                = NULL;
	DWORD dwStartSector;  //Used to seek next partition.
	DWORD dwAttributes = DEVICE_TYPE_PARTITION;
	CHAR strDevName[MAX_DEV_NAME_LEN + 1];
	int i;
	DWORD dwFlags;
	BYTE Buff[512];

	if((NULL == pSector0) || (NULL == lpDrvObject))  //Invalid parameter.
	{
		return 0;
	}
	pStart = pSector0 + 0x1be;  //Locate to the partition table start position.
	for(i = 0;i < 4;i ++) //Analyze each partition table entry.
	{
		if(*(pStart + 4) == 0) //Table entry is empty.
		{
			break;
		}
		if(*(pStart + 4) == 0x0F)  //Extension partiton.
		{
			dwStartSector = *(DWORD*)(pStart + 8);
			if(!ReadSector(nHdNum,dwStartSector,1,Buff))
			{
				break;
			}
			nPartNum += InitExtension(nHdNum,
				Buff,
				dwStartSector,
				dwStartSector,
				i,
				lpDrvObject);
			pStart += 16;  //Pointing to next partition table entry.
			continue;
		}
		pPe = (__PARTITION_EXTENSION*)CREATE_OBJECT(__PARTITION_EXTENSION);
		if(NULL == pPe)  //Can not create object.
		{
			break;
		}
		pPe->dwCurrPos     = 0;
		pPe->BootIndicator = *pStart;
		pStart += 4;
		pPe->PartitionType = *pStart;
		pStart += 4;
		pPe->dwStartSector = *(DWORD*)pStart;
		pStart += 4;
		pPe->dwSectorNum   = *(DWORD*)pStart;
		pStart += 4;  //Pointing to next partition table entry.
		switch(pPe->PartitionType)
		{
		case 0x0B:   //FAT32.
		case 0x0C:   //Also FAT32.
		case 0x0E:   //FAT32 also.
			dwAttributes |= DEVICE_TYPE_FAT32;
			break;
		case 0x07:
			dwAttributes |= DEVICE_TYPE_NTFS;
			break;
		default:
			break;
		}

		//Create device object for this partition.
		//strcpy(strDevName,PARTITION_NAME_BASE);  // -------- CAUTION !!! ---------
		StrCpy(PARTITION_NAME_BASE,strDevName);
		__ENTER_CRITICAL_SECTION(NULL, dwFlags);
		strDevName[StrLen(PARTITION_NAME_BASE) - 1] += (BYTE)IOManager.dwPartitionNumber;
		IOManager.dwPartitionNumber += 1;
		__LEAVE_CRITICAL_SECTION(NULL, dwFlags);
		nPartNum ++;  //Increment the partition number.
		pDevObject = IOManager.CreateDevice(
			(__COMMON_OBJECT*)&IOManager,
			strDevName,
			dwAttributes,
			512,
			16384,
			16384,
			pPe,
			lpDrvObject);
		if(NULL == pDevObject)  //Can not create device object.
		{
			RELEASE_OBJECT(pPe);
			break;
		}
		dwAttributes = DEVICE_TYPE_PARTITION;  //Reset to default value,very important.
	}
	return nPartNum;
}
//
// DestroyLight
//
void DestroyLight(DriverLightsPtr b)
{
	//free(b);
	RELEASE_OBJECT(b);

} // end of the functino 
//
// Destroy List
//
void DestroyParticleList(ParticleList *list) 
{
    RELEASE_OBJECT(list);

} // end of the function