示例#1
0
/* IRDMolecule MolFromSmiles (in string smiles); */
NS_IMETHODIMP RDKitImpl::MolFromSmiles(const char *smiles, IRDMolecule **_retval)
{
  std::string smi(smiles);
  RDKit::ROMol *roMol = RDKit::SmilesToMol(smiles);
  if(!roMol) return NS_ERROR_FAILURE;

  RDMolecule *mol = new RDMolecule(roMol);
  if(!mol) return NS_ERROR_OUT_OF_MEMORY;
  *_retval = static_cast<IRDMolecule *>(mol);

  // FIX: does this leak?
  NS_ADDREF(*_retval);

  return NS_OK;
}
示例#2
0
文件: utility.cpp 项目: gnif/ARMT
// Make version information string
std::string format_version_info(const char * prog_name, bool full /*= false*/)
{
  std::string info = strprintf(
    "%s "PACKAGE_VERSION" "
#ifdef SMARTMONTOOLS_SVN_REV
      SMARTMONTOOLS_SVN_DATE" r"SMARTMONTOOLS_SVN_REV
#else
      "(build date "__DATE__")" // checkout without expansion of Id keywords
#endif
      " [%s] "BUILD_INFO"\n"
    "Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net\n",
    prog_name, smi()->get_os_version_str().c_str()
  );
  if (!full)
    return info;

  info += strprintf(
    "\n"
    "%s comes with ABSOLUTELY NO WARRANTY. This is free\n"
    "software, and you are welcome to redistribute it under\n"
    "the terms of the GNU General Public License; either\n"
    "version 2, or (at your option) any later version.\n"
    "See http://www.gnu.org for further details.\n"
    "\n",
    prog_name
  );
  info += strprintf(
    "smartmontools release "PACKAGE_VERSION
      " dated "SMARTMONTOOLS_RELEASE_DATE" at "SMARTMONTOOLS_RELEASE_TIME"\n"
#ifdef SMARTMONTOOLS_SVN_REV
    "smartmontools SVN rev "SMARTMONTOOLS_SVN_REV
      " dated "SMARTMONTOOLS_SVN_DATE" at "SMARTMONTOOLS_SVN_TIME"\n"
#else
    "smartmontools SVN rev is unknown\n"
#endif
    "smartmontools build host: "SMARTMONTOOLS_BUILD_HOST"\n"
    "smartmontools build configured: "SMARTMONTOOLS_CONFIGURE_DATE "\n"
    "%s compile dated "__DATE__" at "__TIME__"\n"
    "smartmontools configure arguments: ",
    prog_name
  );
  info += (sizeof(SMARTMONTOOLS_CONFIGURE_ARGS) > 1 ?
           SMARTMONTOOLS_CONFIGURE_ARGS : "[no arguments given]");
  info += '\n';

  return info;
}
示例#3
0
smart_device * legacy_scsi_device::autodetect_open()
{
  // Open device
  if (!open())
    return this;

  // No Autodetection if device type was specified by user
  if (*get_req_type())
    return this;

  // The code below is based on smartd.cpp:SCSIFilterKnown()

  // Get INQUIRY
  unsigned char req_buff[64] = {0, };
  int req_len = 36;
  if (scsiStdInquiry(this, req_buff, req_len)) {
    // Marvell controllers fail on a 36 bytes StdInquiry, but 64 suffices
    // watch this spot ... other devices could lock up here
    req_len = 64;
    if (scsiStdInquiry(this, req_buff, req_len)) {
      // device doesn't like INQUIRY commands
      close();
      set_err(EIO, "INQUIRY failed");
      return this;
    }
  }

  int avail_len = req_buff[4] + 5;
  int len = (avail_len < req_len ? avail_len : req_len);
  if (len < 36)
    return this;

  // Use INQUIRY to detect type

  // SAT or USB ?
  {
    smart_device * newdev = smi()->autodetect_sat_device(this, req_buff, len);
    if (newdev)
      // NOTE: 'this' is now owned by '*newdev'
      return newdev;
  }

  // Nothing special found
  return this;
}
示例#4
0
bool smart_device::set_err(int no)
{
  return smi()->set_err_var(&m_err, no);
}
示例#5
0
int cardEffect(int card, int choice1, int choice2, int choice3, struct gameState *state, int handPos, int *bonus){
	int currentPlayer = whoseTurn(state);
	
	//uses switch to select card and perform actions
	switch( card ){
		case adventurer:
			adv(currentPlayer, state);
			break;
		case council_room:
			council(currentPlayer, state, handPos);
			break;
		case feast:
			fea(currentPlayer, state, choice1);
			break;
		case gardens:
			return -1;
		case mine:
			min(currentPlayer, state, handPos, choice1, choice2);
			break;
		case remodel:
			rem(currentPlayer, state, handPos, choice1, choice2);
			break;
		case smithy:
			smi(currentPlayer, state, handPos);
			break;
		case village:
			vill(currentPlayer, state, handPos);
			break;
		case baron:
			bar(currentPlayer, state, choice1);
			break;
		case great_hall:
			great(currentPlayer, state, handPos);
			break;
		case minion:
			mini(currentPlayer, state, handPos, choice1, choice2);
			break;
		case steward:
			stew(currentPlayer, state, handPos, choice1, choice2, choice3);
			break;
		case tribute:
			trib(currentPlayer, state);
			break;
		case ambassador:
			ambass(currentPlayer, state, handPos, choice1, choice2);
			break;
		case cutpurse:
			catp(currentPlayer, state, handPos);
			break;
		case embargo: 
			embar(currentPlayer, state, handPos, choice1);
			break;
		case outpost:
			outp(currentPlayer, state, handPos);
			break;
		case salvager:
			salv(currentPlayer, state, handPos, choice1);
			break;
		case sea_hag:
			seahag(currentPlayer, state);
			break;
		case treasure_map:
			treasur(currentPlayer, state, handPos);
			break;
	}
	
  return -1;
}
示例#6
0
bool smart_device::set_err(int no)
{
  smi()->set_err_var(&m_err, no);
  return false;
}