示例#1
0
文件: LyXVC.cpp 项目: cburschka/lyx
string LyXVC::toggleReadOnly()
{
	if (!vcs)
		return string();
	if (!vcs->toggleReadOnlyEnabled())
		return string();

	switch (vcs->status()) {
	case VCS::UNLOCKED:
		LYXERR(Debug::LYXVC, "LyXVC: toggle to locked");
		return checkOut();
	case VCS::LOCKED: {
		LYXERR(Debug::LYXVC, "LyXVC: toggle to unlocked");
		string log;
		if (checkIn(log) != VCSuccess)
			return string();
		return log;
	}
	case VCS::NOLOCKING:
		Buffer * b = vcs->owner();
		bool const newstate = !b->hasReadonlyFlag();
		string result = "LyXVC: toggle to ";
		result += (newstate ? "readonly" : "readwrite");
		LYXERR(Debug::LYXVC, result);
		b->setReadonly(newstate);
		return result;
	}
	return string();
}
示例#2
0
static int  checkOut( int p, int v, int l)
{ int i,vv,ll,s;

  if( vcs.vertlist[v][l].prop&IN_PRTCL) return -1;
  if( vcs.vertlist[v][l].prop&OUT_PRTCL)
  { int pt=vcs.vertlist[v][l].partcl; 
    if( pt==p) return 1; 
    else 
    {  long N=prtclbase[pt-1].N;
       if(N==22 || N==21) return 0;
       else return 2;
    } 
  }
  
  vv=vcs.vertlist[v][l].nextvert.vno-1;
  ll=vcs.vertlist[v][l].nextvert.edno-1;                                      


  for(s=0,i=0;i< vcs.valence[vv];i++) if(i!=ll)
  { int r= checkOut(p,vv,i);                                       
    if(r<0) return -1;
    if(r>1) return  2;
    s+=r;
  } 
  if(s) return s;
  
}    
int main(int argc, char *argv[])
{
if (argc != 2)
    usage();
checkOut(argv[1]);
return 0;
}
// Delete read stream, checkout from objectRegistry and destroy
regIOobject::~regIOobject()
{
    if (objectRegistry::debug)
    {
        Info<< "Destroying regIOobject called " << name()
            << " of type " << type()
            << " in directory " << path()
            << endl;
    }

    if (isPtr_)
    {
        delete isPtr_;

        // Make sure we won't delete this object more than once. MB 06/2010
        isPtr_ = NULL;
    }

    // Check out of objectRegistry if not owned by the registry

    if (!ownedByRegistry_)
    {
        checkOut();
    }
}
示例#5
0
static int rtypepropag(int v, int l)
{
  int p,r;
  int vv,ll;
  
  p=vcs.vertlist[v-1][l-1].partcl;

  r=checkOut(p,v-1,l-1);
  if(r==-1) 
  {   vv=vcs.vertlist[v-1][l-1].nextvert.vno-1; 
      ll=vcs.vertlist[v-1][l-1].nextvert.edno-1;
      p=vcs.vertlist[vv][ll].partcl;
      r=checkOut(p,vv,ll);
  }
  if(r!=1) r=0;
  return r;
}
// Rename object and re-register with objectRegistry under new name
void regIOobject::rename(const word& newName)
{
    // Check out of objectRegistry
    checkOut();

    IOobject::rename(newName);

    // Re-register object with objectRegistry
    checkIn();
}
示例#7
0
void main(void)
{   
    init_devices();
	checkOut();
    while(1)
    {
		  if(endlineFlag==1)
		 {
		  	setMessage();
			endlineFlag=0;	
			PORTB|=0x04;				
		  }
		 // PORTB|=0x01;
    }
}
// Assign to IOobject
void regIOobject::operator=(const IOobject& io)
{
    if (isPtr_)
    {
        delete isPtr_;
        isPtr_ = NULL;
    }

    // Check out of objectRegistry
    checkOut();

    IOobject::operator=(io);

    // Re-register object with objectRegistry
    checkIn();
}
示例#9
0
void Foam::objectRegistry::clear()
{
    List<regIOobject*> myObjects(size());
    label nMyObjects = 0;

    for (iterator iter = begin(); iter != end(); ++iter)
    {
        if (iter()->ownedByRegistry())
        {
            myObjects[nMyObjects++] = iter();
        }
    }

    for (label i=0; i < nMyObjects; i++)
    {
        checkOut(*myObjects[i]);
    }
}
示例#10
0
void Foam::regIOobject::operator=(const IOobject& io)
{
    if (isPtr_)
    {
        delete isPtr_;
        isPtr_ = nullptr;
    }

    // Check out of objectRegistry
    checkOut();

    IOobject::operator=(io);

    if (registerObject())
    {
        // Re-register object with objectRegistry
        checkIn();
    }
}
示例#11
0
// Delete read stream, checkout from objectRegistry and destroy
Foam::regIOobject::~regIOobject()
{
    if (objectRegistry::debug)
    {
        Info<< "Destroying regIOobject called " << name()
            << " of type " << type()
            << " in directory " << path()
            << endl;
    }

    if (isPtr_)
    {
        delete isPtr_;
        isPtr_ = NULL;
    }

    // Check out of objectRegistry if not owned by the registry

    if (!ownedByRegistry_)
    {
        checkOut();
    }
}
示例#12
0
BOOL CLicenseMgr::CheckOutLicense(const char *feature)
{
	m_feature = feature;
	std::string strErr;
	int status = 0;
	int res = 0;
	setPromptForFile(1);
	status = newJob();
	if(!status)
	{
		res = checkOut(feature);
		if(!res)
		{
			int days = getExpireDays(feature);
			if (days < 0)
			{
				::MessageBox(NULL,"License许可文件已过期!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				return FALSE;
			}
			return TRUE;
		}
		else
		{
			switch(res)
			{
			case -1:
				::MessageBox(NULL,"找不到许可文件!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			case -2:
				::MessageBox(NULL,"无效的许可文件格式!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			case -4:
				::MessageBox(NULL,"已达到许可个数使用上限!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			case -8:
				::MessageBox(NULL,"这个许可号/签名以及数据和模块不匹配!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			case -9:
				::MessageBox(NULL,"系统的主机标识与许可文件中的主机标识不匹配!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			case -15:
				::MessageBox(NULL,"连接不到许可服务器。\r\n可能是许可服务还没有启动,或者是使用了错误的port@host 或者许可文件,或许可文件中的TCP/IP端口号或者机器名被更改!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			case -34:
				::MessageBox(NULL,"客户端和许可服务器系统之间的时钟差异太大!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			case -88:
				::MessageBox(NULL,"系统时钟已经被回拨!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			case -97:
				::MessageBox(NULL,"所需的供应商守护程序已关闭!",g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			default:
				UTF8Tomulti(getErrorString(res),strErr);
				CString strerrcode;
				strerrcode.Format("其他异常错误!错误代码:%d\n%s", res, strErr.c_str());
				::MessageBox(NULL,strerrcode,g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
				break;
			}
			
			return FALSE;
		}
	}
	else
	{
		UTF8Tomulti(getErrorString(status),strErr);
		::MessageBox(NULL,strErr.c_str(),g_lpszMsgTitle,MB_OK|MB_ICONWARNING);
		return FALSE;
	}

	return TRUE;
}
示例#13
0
Foam::Callback<CallbackType>::~Callback()
{
    checkOut();
}
示例#14
0
int main( int argc, char * argv [] )
{
	boost::program_options::options_description optionsDescription( "options" );
	optionsDescription.add_options()
		("help", "produce help message")
		("objectStoreRootPath", boost::program_options::value< std::string >()->default_value( "/var/lib/osmosis/objectstore" ),
			"Path where osmosis will store objects. relevant for 'server', 'purge', 'labellog' and 'leastrecentlyused' commands" )
		("serverTCPPort", boost::program_options::value< unsigned short >()->default_value( 1010 ),
			"the TCP port to bind to, if command is 'server'")
		( "objectStores", boost::program_options::value< std::string >()->default_value( "127.0.0.1:1010" ),
			"the object store to act againt. May be a '+' seperated list for 'checkout' command" )
		( "MD5", "use MD5, not SHA1 for hash in 'checkin' operation" )
		( "putIfMissing", "when command is 'checkout' or 'transfer', this flag will cause any objects received not from the "
		        "nearest object store to be put into all objects stores up to the one it was fetched from" )
		( "removeUnknownFiles", "for checkout: remove files from disk that are not in the dirlist being checked out" )
		( "myUIDandGIDcheckout", "for checkout: use my uid and gid" )
		( "ignore", boost::program_options::value< std::string >(),
			"for checkout: ignore the existance of all files in this ':' seperated list. "
			"if a directory was specified, ignored everything under it as well. specified paths "
			"must reside inside the checkout path" )
		( "transferDestination", boost::program_options::value< std::string >(),
			"destination object store to transfer the label into" )
		( "reportFile", boost::program_options::value< std::string >()->default_value( "" ),
			"periodically write report in JSON format into this file" )
		( "reportIntervalSeconds", boost::program_options::value< unsigned >()->default_value( 15 ),
			"period to report progress" )
		( "noChainTouch", "avoid touching fetched label in all object stores in chain (used for label bookeeping)" )
		( "keep", boost::program_options::value< std::string >()->default_value( "keepforever|bootstrap" ),
		  	"regular expression for labels to never erase. Only relevant under 'leastrecentlyused' command" )
		( "maximumDiskUsage", boost::program_options::value< std::string >(),
		  	"<number>M or <number>G for the amount of storage used for label objects before 'leastrecentlyused' starts erasing labels");

	boost::program_options::options_description positionalDescription( "positionals" );
	positionalDescription.add_options()
		( "command", boost::program_options::value< std::string >() )
		( "arg1", boost::program_options::value< std::string >() )
		( "arg2", boost::program_options::value< std::string >() );

	boost::program_options::positional_options_description positionalMapping;
	positionalMapping.add( "command", 1 ).add( "arg1", 1 ).add( "arg2", 1 );

	boost::program_options::options_description allOptions;
	allOptions.add( optionsDescription ).add( positionalDescription );

	boost::program_options::variables_map options;
	try {
		boost::program_options::store(
			boost::program_options::command_line_parser( argc, argv ).
				positional( positionalMapping ).options( allOptions ).
				run(),
			options );
		boost::program_options::notify( options );
	} catch ( boost::exception & e ) {
		TRACE_BOOST_EXCEPTION( e, "Unable to parse command line" );
		usage( optionsDescription );
		return 1;
	}

	if ( options.count( "help" ) ) {
		usage( optionsDescription );
		return 1;
	}

	try {
		std::string command = options[ "command" ].as< std::string >();
		if ( command == "server" ) {
			if ( options.count( "arg1" ) > 0 or options.count( "arg2" ) > 0 ) {
				TRACE_ERROR( "'workDir' or 'label' must not be present in command line"
						"if 'server' is specified as the command" );
				usage( optionsDescription );
				return 1;
			}
			server( options );
		} else if ( command == "checkin" )
			checkIn( options );
		else if ( command == "checkout" )
			checkOut( options );
		else if ( command == "transfer" )
			transfer( options );
		else if ( command == "listlabels" )
			listLabels( options );
		else if ( command == "eraselabel" )
			eraseLabel( options );
		else if ( command == "purge" )
			purge( options );
		else if ( command == "renamelabel" )
			renameLabel( options );
		else if ( command == "labellog" )
			dumpLabelLog( options );
		else if ( command == "leastrecentlyused" )
			leastRecentlyUsed( options );
		else if ( command == "testhash" )
			testHash( options );
		else {
			TRACE_ERROR( "Unknown command '" << command << "'" );
			usage( optionsDescription );
			return 1;
		}
	} catch ( boost::exception & e ) {
		TRACE_BOOST_EXCEPTION( e, "Terminated on a boost exception" );
		return 1;
	} catch ( Error & e ) {
		TRACE_ERROR( "Terminated on 'Error' exception: '" << e.what() << "' from " << e.backtrace() );
		return 1;
	} catch ( std::exception & e ) {
		TRACE_ERROR( "Terminated on std::exception: '" << e.what() );
		return 1;
	} catch ( ... ) {
		TRACE_ERROR( "Terminated on unknown exception" );
		return 1;
	}

	return 0;
}