Exemple #1
0
void BPlusTree::remove(int val) {
    if (!root) {
        // tree is empty
        throw new std::exception();
    }
    
    BTreeNode *tp = root;
    while (!tp->isLeaf) {
        for(ListNode* lp = tp->children.begin(); lp->next; lp = lp->next) {
            if (val < lp->index) {
                tp = lp->child;
                break;
            }
        }
    }
    
    tp->children.remove(val);
    // if less then A*D keys are in this Node take fuse
    if (tp->children.getLength() <= D*A) {
        if (tp->lbro && tp->lbro->children.getLength() > D*A+1) {
            share(tp, tp->lbro);
        } else if (tp->rbro && tp->rbro->children.getLength() > D*A+1) {
            share(tp, tp->rbro);
        } else if (tp->lbro && tp->lbro->children.getLength() <= D*A+1) {
            fuse(tp, tp->lbro);
        } else if (tp->rbro && tp->rbro->children.getLength() <= D*A+1) {
            fuse(tp, tp->rbro);
        } else {
            for(ListNode *lp = tp->children.begin(); lp; lp = lp->next) {
                tp->parent->children.insert(lp->index, lp->child);
            }
        }
    }
}
Exemple #2
0
int main ()
{
	SomeScorer scorer;
	std::shared_ptr<XYZScorer> ptr =
        decorate<FixZToFirstInteractionScorer, ApplyEnergyCutsScorer>(scorer);

	std::shared_ptr<XYZScorer> ptr2 =
        share(fixZToFirstInteraction(applyEnergyCuts(scorer)));

	static_assert(std::is_same<
		decltype(decorate<FixZToFirstInteractionScorer, ApplyEnergyCutsScorer>(scorer)),
		decltype(share(fixZToFirstInteraction(applyEnergyCuts(scorer))))
	>::value, "");
}
Exemple #3
0
// appends a string to an URL, making it another URL
// subdirs '.' and ".." can be recognized and interpreted
// This function parses the URL at the same time
// returns 0 on error, or the new URL
char *Util::append(const char* URL, const char *string, bool interpretDirs)
{
	// first have a correct URL
	parse(URL, interpretDirs);
	// Correct URL reconstruction in the return variable
	newstrcpy(appendValue,	buildURL(user(),password(),workgroup(),host(),share(),path(),ip()));
	// append the string
	newstrappend(appendValue, "/", string);
	// reparse for a correct URL and interpreting the directories
	parse(appendValue, interpretDirs);
	// Final reconstruction
	newstrcpy(appendValue,	buildURL(user(),password(),workgroup(),host(),share(),path(),ip()));
	return appendValue;
}
Exemple #4
0
// AES with shares. The subbyte computation with shares is given as parameter
void aes_share_subkeys(byte in[16],byte out[16],byte *wshare[176],uint8_t n,void (*subbyte_share_call)(byte *,uint8_t))
{
  uint8_t i,j;
  uint8_t round=0;

  byte *stateshare[16];

  for(i=0;i<16;i++)
  {
    stateshare[i]=(byte*) malloc(n*sizeof(byte));
    share(in[i],stateshare[i],n);
    refresh(stateshare[i],n);
  }  

  addroundkey_share(stateshare,wshare,0,n);

  for(round=1;round<10;round++)
  { 
    subbytestate_share(stateshare,n,subbyte_share_call);
    shiftrows_share(stateshare,n);
    mixcolumns_share(stateshare,n);
    addroundkey_share(stateshare,wshare,round,n);
  }
  subbytestate_share(stateshare,n,subbyte_share_call);
  shiftrows_share(stateshare,n);
  addroundkey_share(stateshare,wshare,10,n);

  for(i=0;i<16;i++)
  {
    out[i]=decode(stateshare[i],n);
    free(stateshare[i]);
  }
}
Exemple #5
0
double run_aes_share(byte in[16],byte out[16],byte key[16],uint8_t n,void (*subbyte_share_call)(byte *,uint8_t),uint8_t nt)
{
  uint8_t i;
  byte w[176];
  byte *wshare[176];
  //clock_t start,end;
  keyexpansion(key,w);
  
  for(i=0;i<176;i++)
  {
    wshare[i]=(byte *) malloc(n*sizeof(byte));
    share(w[i],wshare[i],n);
    refresh(wshare[i],n);
  }

  //start=clock();
  for(i=0;i<nt;i++)
    aes_share_subkeys(in,out,wshare,n,subbyte_share_call);
  //end=clock();

  for(i=0;i<176;i++)
    free(wshare[i]);
  
  return 1;//(double) (end-start);
}
Exemple #6
0
void subbyte_htable(byte *a,int n)
{
  byte T[K][n];
  byte Tp[K][n];
  byte b[n];
  int i,j,k;
 
  for(k=0;k<K;k++)
    share(sbox[k],T[k],n);

  for(i=0;i<(n-1);i++)
  {
    for(k=0;k<K;k++)
      for(j=0;j<n;j++)
	Tp[k][j]=T[k ^ a[i]][j];

    for(k=0;k<K;k++)
    {
      for(j=0;j<n;j++) 
	T[k][j]=Tp[k][j];
      refresh(T[k],n);
    }
  }
  
  for(j=0;j<n;j++)
    b[j]=T[a[n-1]][j];

  refresh(b,n);
  for(j=0;j<n;j++) a[j]=b[j];
}
Exemple #7
0
void evalSbox(byte *a,byte *S,int n)
{
  unsigned char T[K][n];
  unsigned char Tp[K][n];
  byte b[n];
  int i,j,k,k2;
 
  for(k=0;k<K;k++)
    share(S[k],T[k],n);

  for(i=0;i<(n-1);i++)
  {
    for(k=0;k<K;k++)
    {
      k2=k ^ a[i];
      memcpy(Tp[k],T[k2],n);
    }

    for(k=0;k<K;k++)
    {
      memcpy(T[k],Tp[k],n);
      refresh(T[k],n);
    }
  }
  
  for(j=0;j<n;j++)
    b[j]=T[a[n-1]][j];

  refresh(b,n);
  for(j=0;j<n;j++) a[j]=b[j];
}
Exemple #8
0
PostProcBlur::PostProcBlur(uint32_t width, uint32_t height, uint32_t power, uint32_t internalFormat, uint32_t format) :PostProcEffect(width, height)
{
	effectPower = power;

	fbo = share(new FrameBufferObject());
	fbo->Init();
	fbo->Set();

	hBlurTex = CreateFullScreenTexture(internalFormat, format);
	vBlurTex = CreateFullScreenTexture(internalFormat, format);

	fbo->AttachTexture(0, hBlurTex);
	fbo->AttachTexture(1, vBlurTex);
	fbo->EnableBuffer(0);
	fbo->EnableBuffer(1);

	fbo->Unset();

	if (!fbo->IsComplete())
	{
		GetContext().GetLogger()->log(loglevel::LOG_ERROR, "FBO INCOMPLETE at %s %s", __FILE__, __LINE__);
	}

	hBlurShader = GetContext().GetResourceManager()->LoadShader("res/engine/shaders/hblur");
	vBlurShader = GetContext().GetResourceManager()->LoadShader("res/engine/shaders/vblur");
}
HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share,
                                            bool p_isGL2)
{
    emugl::Mutex::AutoLock mutex(m_lock);
    HandleType ret = 0;

    const FbConfig* config = getConfigs()->get(p_config);
    if (!config) {
        return ret;
    }

    RenderContextPtr share(NULL);
    if (p_share != 0) {
        RenderContextMap::iterator s(m_contexts.find(p_share));
        if (s == m_contexts.end()) {
            return ret;
        }
        share = (*s).second;
    }
    EGLContext sharedContext =
            share.Ptr() ? share->getEGLContext() : EGL_NO_CONTEXT;

    RenderContextPtr rctx(RenderContext::create(
        m_eglDisplay, config->getEglConfig(), sharedContext, p_isGL2));
    if (rctx.Ptr() != NULL) {
        ret = genHandle();
        m_contexts[ret] = rctx;
        RenderThreadInfo *tinfo = RenderThreadInfo::get();
        tinfo->m_contextSet.insert(ret);
    }
    return ret;
}
Exemple #10
0
Samples::Samples(Samples *src)
{
	reset();
	share(src->get_shmid());
	set_allocated(src->get_allocated());
	set_offset(src->get_offset());
}
Exemple #11
0
void ShareManager::slotShareCreated(const QVariantMap &reply)
{
    //Parse share
    auto data = reply.value("ocs").toMap().value("data").toMap();
    QSharedPointer<Share> share(parseShare(data));

    emit shareCreated(share);
}
Exemple #12
0
 BOOST_FORCEINLINE void
 combine_eigens(const T& wr,  const T& wi, A0& w)
 {
   typedef typename A0::value_type type_t;
   int n = numel(wr);
   w.resize(of_size(n, 1));
   nt2::container::table<type_t, nt2::shared_> sw(of_size(n, 1), share(w.data(), w.data()+n));
   sw = tocomplex(wr, wi);
 }
Exemple #13
0
int main()
{
    {
        std::shared_ptr<Point> movable = share(Point(1, 2));
        std::cout << movable->x << ", " << movable->y << std::endl;
    }
    {
        std::unique_ptr<Point> movable = create(Point(1, 2));
        std::cout << movable->x << ", " << movable->y << std::endl;
    }
}
Exemple #14
0
std::vector< share_t > reshare(const std::vector< share_t >& shares, unsigned int t_old, unsigned int t_new, unsigned int n_new, const mpz_class& p, gmp_randclass& randomGenerator, unsigned int security)
{
    std::vector< std::vector< share_t > > randomShares;
    randomShares.reserve(shares.size());
    for (size_t j = 0; j < shares.size(); ++j)
    {
        randomShares.push_back( share(randomGenerator.get_z_bits(security) % p, t_old, n_new, p, randomGenerator, security) );
    }
    std::vector< share_t > maskedShares;
    maskedShares.resize(shares.size());
    for (size_t j = 0; j < shares.size(); ++j)
    {
        maskedShares[j] = shares[j];
        mpz_class y_j = maskedShares[j].second;
        for (size_t i = 0; i < randomShares.size(); ++i)
        {
            y_j = (y_j + randomShares[i][shares[j].first.get_ui() + 1].second) % p;
        }
        maskedShares[j].second = y_j;
    }
    mpz_class maskedSecret = recover(maskedShares, p);
    gmp_printf("maskedSecret %Zx\n", maskedSecret.get_mpz_t());

    std::vector< share_t > newMaskedShares = share(maskedSecret, t_new, n_new, p, randomGenerator, security);
    std::vector< share_t > newShares;
    newShares.resize(newMaskedShares.size());

    for (size_t j = 0; j < newShares.size(); ++j)
    {
        newShares[j] = newMaskedShares[j];
        mpz_class y_j = newShares[j].second;
        size_t index = newShares[j].first.get_ui() + 1;
        for (size_t i = 0; i < randomShares.size(); ++i)
        {
            mpz_class randomShare = randomShares[i][index].second;
            y_j = (y_j + invertAdditive(randomShare, p)) % p;
        }
        newShares[j].second = y_j;
    }
    return newShares;
}
vm_placement_problem_result<TraitsT> make_vm_placement_problem_result(ProblemDescrT problem_descr, ProblemResultT problem_res)
{
	typedef TraitsT traits_type;
	typedef vm_placement_problem_result<traits_type> result_type;
	typedef typename result_type::real_type real_type;
	typedef typename result_type::resource_share_container resource_share_container;
	typedef typename result_type::physical_machine_identifier_type physical_machine_identifier_type;
	typedef typename result_type::virtual_machine_identifier_type virtual_machine_identifier_type;

	result_type res;

	res.cost(problem_res.cost());

	typename ProblemResultT::smallint_matrix_type placement_flags(problem_res.virtual_machine_placement());
	typename ProblemResultT::real_matrix_type placement_shares(problem_res.virtual_machine_shares());

	::std::size_t npm(::boost::numeric::ublasx::num_rows(placement_flags));
	::std::size_t nvm(::boost::numeric::ublasx::num_columns(placement_flags));

	for (::std::size_t i = 0; i < npm; ++i)
	{
		physical_machine_identifier_type pm_id(problem_descr.pm_ids[i]);

		real_type share_sum(0); // Normalization factor
		for (::std::size_t k = 0; k < 2; ++k)
		{
			for (::std::size_t j = 0; j < nvm; ++j)
			{
				if (placement_flags(i,j))
				{
					if (k == 0)
					{
						share_sum += placement_shares(i,j);
					}
					else
					{
						virtual_machine_identifier_type vm_id(problem_descr.vm_ids[j]);
						real_type share(placement_shares(i,j));
						if (share_sum > 1)
						{
							share /= share_sum;
						}
						//FIXME: CPU resource category is hard-coded.
						resource_share_container shares(1, ::std::make_pair(cpu_resource_category, share));
						res.placement()[::std::make_pair(pm_id, vm_id)] = shares;
					}
				}
			}
		}
	}

	return res;
}
Exemple #16
0
    void GLSLShader::generate(std::ostream& os) {
        // Turn shared expression nodes into precalculated variables.
        share();

        // First, we need to turn If nodes into separate statements.
        splitBranches();

        // Sharing set up a lot of redundant (and incorrectly
        // scope-restricting) block nodes.  Let's remove those.
        removeRedundantBlocks(main);

        output(os);
    }
void ShareUserGroupWidget::searchForSharees()
{
    _completionTimer.stop();
    ShareeModel::ShareeSet blacklist;

    // Add the current user to _sharees since we can't share with ourself
    QSharedPointer<Sharee> currentUser(new Sharee(_account->credentials()->user(), "", Sharee::Type::User));
    blacklist << currentUser;

    foreach (auto sw, _ui->scrollArea->findChildren<ShareWidget*>()) {
        blacklist << sw->share()->getShareWith();
    }
    _ui->errorLabel->hide();
    _completerModel->fetch(_ui->shareeLineEdit->text(), blacklist);

}
void register_pluginx_js_extensions(JSContext* cx, JS::HandleObject global)
{
    JS::RootedObject ns(cx);
    pluginx::get_or_create_js_obj(cx, global, "plugin", &ns);

    JS::RootedObject iap(cx, jsb_cocos2d_plugin_ProtocolIAP_prototype);
    JS_DefineFunction(cx, iap, "setListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, iap, "getListener", js_pluginx_ProtocolIAP_getResultListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, iap, "payForProduct", js_pluginx_ProtocolIAP_payForProduct, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject ads(cx, jsb_cocos2d_plugin_ProtocolAds_prototype);
    JS_DefineFunction(cx, ads, "setListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, ads, "getListener", js_pluginx_ProtocolAds_getAdsListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject share(cx, jsb_cocos2d_plugin_ProtocolShare_prototype);
    JS_DefineFunction(cx, share, "setListener", js_pluginx_ProtocolShare_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, share, "getListener", js_pluginx_ProtocolShare_getResultListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, share, "share", js_pluginx_ProtocolShare_share, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject social(cx, jsb_cocos2d_plugin_ProtocolSocial_prototype);
    JS_DefineFunction(cx, social, "setListener", js_pluginx_ProtocolSocial_setListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, social, "getListener", js_pluginx_ProtocolSocial_getListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, social, "submitScore", js_pluginx_ProtocolSocial_submitScore, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, social, "unlockAchievement", js_pluginx_ProtocolSocial_unlockAchievement, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject user(cx, jsb_cocos2d_plugin_ProtocolUser_prototype);
    JS_DefineFunction(cx, user, "setActionListener", js_pluginx_ProtocolUser_setActionListener, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, user, "getActionListener", js_pluginx_ProtocolUser_getActionListener, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, user, "login", js_pluginx_ProtocolUser_login, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, user, "logout", js_pluginx_ProtocolUser_logout, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject protocol(cx, jsb_cocos2d_plugin_PluginProtocol_prototype);
    JS_DefineFunction(cx, protocol, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, protocol, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, protocol, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, protocol, "callFloatFuncWithParam", js_pluginx_PluginProtocol_callFloatFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, protocol, "callBoolFuncWithParam", js_pluginx_PluginProtocol_callBoolFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT);
    
    JS::RootedObject facebook(cx, jsb_cocos2d_plugin_FacebookAgent_prototype);
    JS_DefineFunction(cx, facebook, "login", js_pluginx_FacebookAgent_login, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, facebook, "_api", js_pluginx_FacebookAgent_api, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, facebook, "appRequest", js_pluginx_FacebookAgent_appRequest, 0, JSPROP_READONLY | JSPROP_PERMANENT);
    JS_DefineFunction(cx, facebook, "dialog", js_pluginx_FacebookAgent_dialog, 0, JSPROP_READONLY | JSPROP_PERMANENT);

    js_register_pluginx_protocols_PluginParam(cx, ns);
}
Exemple #19
0
ByteBufferPtr File::Read(uint32_t length)
{
	if (m_fileHandle)
	{
		ByteBuffer * buffer = new ByteBuffer();

		buffer->resize(length);
		uint32_t bytesRead = PHYSFS_read(m_fileHandle, (char *)buffer->data(), length, 1) * length;
		buffer->resize(bytesRead);

		return share(buffer);
	}
	else
	{
		return std::shared_ptr<ByteBuffer>();
	}
}
Exemple #20
0
int main()
{
  int rows = 99999;
  int columns = 999;
  std::cout << "Create matrix\n";
  char** test = create_matrix<char> (rows, columns);
  std::cout << "Fill out matrix\n";
  fill_random<char> (test, rows, columns, 'a', 'z');
  std::cout << "Counting\n";
  std::vector<int> result = share(test, rows, columns);
  for (auto& i : result)
    std::cout << i << ' ';
  std::cout << '\n';
  delete [] (*test);
  delete [] test;
  return 0;
}
Exemple #21
0
void ConfigMenu::screenshot()
{
	std::string sdcard = getSDCard();
	CCSize size = CCDirector::sharedDirector()->getWinSize();

	const char* imgName = "/bug_screenshot.jpg";
	sdcard = sdcard.append(imgName);
	CCRenderTexture* pScreen = CCRenderTexture::create(size.width, size.height);
	CCScene* pTempScene = CCDirector::sharedDirector()->getRunningScene();
	pScreen->begin();
	//pTempScene->visit();
	pTempScene->getChildByTag(TAG_RUNNING_LAYER)->visit();
	pScreen->end();
	pScreen->saveToFile(sdcard.c_str());
	CC_SAFE_DELETE(pScreen);
	share();
	CCLOG("sdcard %s", sdcard.c_str());
}
    void setProfile()
    {
        const int sum_of_shares = 100;

        _lawChoice.setSize(Laws_size);
        _lawChoice.setMaxWeights(sum_of_shares);

        int rest_shares = sum_of_shares, item_index = 0;
        _lawChoice[inplacePlusAssociativity] = share(Laws_size, item_index, rest_shares);
        _lawChoice[inplacePlusNeutrality]    = share(Laws_size, item_index, rest_shares);
        _lawChoice[inplacePlusCommutativity] = share(Laws_size, item_index, rest_shares);
        _lawChoice[inplaceEtAssociativity]   = share(Laws_size, item_index, rest_shares);
        _lawChoice[inplaceEtCommutativity]   = share(Laws_size, item_index, rest_shares);
        _lawChoice[inplaceNaturalInversion]  = share(Laws_size, item_index, rest_shares);
        _lawChoice[sectionAbsorbtion]        = share(Laws_size, item_index, rest_shares);
        _lawChoice.init();
    }
Exemple #23
0
 BOOST_FORCEINLINE void
 combine_vects(const T1& rv, const T2& wi, A0& v)
 {
   typedef typename A0::value_type type_t;
   int n = height(rv);
   v.resize(of_size(n, n));
   nt2::container::table<type_t, nt2::shared_> sv(of_size(n, n), share(v.data(), v.data()+numel(v)));
   for(int j=1; j <= n; ++j)
   {
     if(wi(j))
     {
       sv(nt2::_, j  ) = tocomplex(rv(nt2::_, j), rv(nt2::_, j+1));
       sv(nt2::_, j+1) = conj(sv(nt2::_, j));
       ++j;
     }
     else
       sv(nt2::_, j) = rv(nt2::_, j);
   }
 }
Exemple #24
0
void ShareManager::slotLinkShareCreated(const QVariantMap &reply)
{
    QString message;
    int code = OcsShareJob::getJsonReturnCode(reply, message);

    /*
     * Before we had decent sharing capabilities on the server a 403 "generally"
     * meant that a share was password protected
     */
    if (code == 403) {
        emit linkShareRequiresPassword();
        return;
    } 

    //Parse share
    auto data = reply.value("ocs").toMap().value("data").toMap();
    QSharedPointer<LinkShare> share(parseLinkShare(data));

    emit linkShareCreated(share);
}
HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share,
                                            bool p_isGL2)
{
    android::Mutex::Autolock mutex(m_lock);
    HandleType ret = 0;

    RenderContextPtr share(NULL);
    if (p_share != 0) {
        RenderContextMap::iterator s( m_contexts.find(p_share) );
        if (s == m_contexts.end()) {
            return 0;
        }
        share = (*s).second;
    }

    RenderContextPtr rctx( RenderContext::create(p_config, share, p_isGL2) );
    if (rctx.Ptr() != NULL) {
        ret = genHandle();
        m_contexts[ret] = rctx;
    }
    return ret;
}
Exemple #26
0
PostProcEdge::PostProcEdge(uint32_t width, uint32_t height, uint32_t power, uint32_t internalFormat, uint32_t format) :PostProcEffect(width, height)
{
    m_effectPower = power;

    m_fbo = share(new FrameBufferObject());
    m_fbo->Init();
    m_fbo->Set();

    m_tex = CreateFullScreenTexture(internalFormat, format);

    m_fbo->AttachTexture(0, m_tex);
    m_fbo->EnableBuffer(0);

    m_fbo->Unset();

    if (!m_fbo->IsComplete())
    {
        GetContext().GetLogger()->log(loglevel::LOG_ERROR, "m_fbo INCOMPLETE at %s %s", __FILE__, __LINE__);
    }

    m_shader = GetContext().GetResourceManager()->LoadShader("res/engine/shaders/post_proc_edge");
}
Exemple #27
0
void
main(int argc, char *argv[])
{
	int returns;

	returns = 1;
	ARGBEGIN{
	case 'C':
		opt[Echo].noway = 1;
		break;
	case 'd':
		debug = 1;
		break;
	case 'n':
		notkbd = 1;
		break; 
	case 'r':
		returns = 0;
		break;
	case 's':
		srv = EARGF(usage());
		break;
	default:
		usage();
	}ARGEND

	if(argc != 1)
		usage();

	/* options we need routines for */
	opt[Echo].change = echochange;
	opt[Term].sub = termsub;
	opt[Xloc].sub = xlocsub;

	comm = share(sizeof(comm));
	comm->returns = returns;

	telnet(dodial(argv[0]));
}
Exemple #28
0
//Actions
void GameLayer::ccTouchesBegan(CCSet* pTouches, CCEvent* event) {
	_gameManager->ccTouchesBegan(pTouches, event);
	if(_gameManager->getStatus() == STATUS_WAIT){
		CCSetIterator it;
		CCTouch* touch;
		CCPoint tap;
		for (it = pTouches->begin(); it != pTouches->end(); it++) {
			touch = (CCTouch*) (*it);
			if (touch) {
				tap = touch->getLocation();
				if (_leaderboards->boundingBox().containsPoint(tap)) {
					gameServicesShowRecord();
				}
				if (_achievements->boundingBox().containsPoint(tap)) {
					gameServicesShowMedals();
				}
				if (_share->boundingBox().containsPoint(tap)) {
					share();
				}
			}
		}
	}
}
Exemple #29
0
void Range::_share(Node *p_range) {

	Range *r = Object::cast_to<Range>(p_range);
	ERR_FAIL_COND(!r);
	share(r);
}
Exemple #30
0
void System::handleMenu(MAEvent &event) {
  int menuId = event.optionsBoxButtonIndex;
  int fontSize = _output->getFontSize();
  int menuItem = _systemMenu[menuId];
  delete [] _systemMenu;
  _systemMenu = NULL;

  switch (menuItem) {
  case MENU_SOURCE:
    showSystemScreen(true);
    break;
  case MENU_CONSOLE:
    showSystemScreen(false);
    break;
  case MENU_KEYPAD:
    maShowVirtualKeyboard();
    break;
  case MENU_RESTART:
    setRestart();
    break;
  case MENU_BACK:
    setBack();
    break;
  case MENU_ZOOM_UP:
    if (_fontScale > FONT_MIN) {
      _fontScale -= FONT_SCALE_INTERVAL;
      fontSize = (_initialFontSize * _fontScale / 100);
    }
    break;
  case MENU_ZOOM_DN:
    if (_fontScale < FONT_MAX) {
      _fontScale += FONT_SCALE_INTERVAL;
      fontSize = (_initialFontSize * _fontScale / 100);
    }
    break;
  case MENU_COPY:
  case MENU_CUT:
    if (get_focus_edit() != NULL) {
      char *text = get_focus_edit()->copy(menuItem == MENU_CUT);
      if (text) {
        setClipboardText(text);
        free(text);
        _output->redraw();
      }
    }
    break;
  case MENU_PASTE:
    if (get_focus_edit() != NULL) {
      char *text = getClipboardText();
      get_focus_edit()->paste(text);
      _output->redraw();
      free(text);
    }
    break;
  case MENU_SELECT_ALL:
    if (get_focus_edit() != NULL) {
      get_focus_edit()->selectAll();
      _output->redraw();
    }
    break;
  case MENU_CTRL_MODE:
    if (get_focus_edit() != NULL) {
      bool controlMode = get_focus_edit()->getControlMode();
      get_focus_edit()->setControlMode(!controlMode);
    }
    break;
  case MENU_EDITMODE:
    opt_ide = (opt_ide == IDE_NONE ? IDE_INTERNAL : IDE_NONE);
    break;
  case MENU_AUDIO:
    opt_mute_audio = !opt_mute_audio;
    break;
  case MENU_SCREENSHOT:
    ::screen_dump();
    break;
  case MENU_UNDO:
    event.type = EVENT_TYPE_KEY_PRESSED;
    event.key = SB_KEY_CTRL('z');
    break;
  case MENU_REDO:
    event.type = EVENT_TYPE_KEY_PRESSED;
    event.key = SB_KEY_CTRL('y');
    break;
  case MENU_SAVE:
    event.type = EVENT_TYPE_KEY_PRESSED;
    event.key = SB_KEY_CTRL('s');
    break;
  case MENU_RUN:
    event.type = EVENT_TYPE_KEY_PRESSED;
    event.key = SB_KEY_F(9);
    break;
  case MENU_DEBUG:
    event.type = EVENT_TYPE_KEY_PRESSED;
    event.key = SB_KEY_F(5);
    break;
  case MENU_OUTPUT:
    event.type = EVENT_TYPE_KEY_PRESSED;
    event.key = SB_KEY_CTRL('o');
    break;
  case MENU_HELP:
    event.type = EVENT_TYPE_KEY_PRESSED;
    event.key = SB_KEY_F(1);
    break;
  case MENU_SHORTCUT:
    if (!_activeFile.empty()) {
      addShortcut(_activeFile.c_str());
    }
    break;
  case MENU_SHARE:
    if (!_activeFile.empty()) {
      share(_activeFile.c_str());
    }
    break;
  case MENU_COMPLETION_0:
    completeKeyword(0);
    break;
  case MENU_COMPLETION_1:
    completeKeyword(1);
    break;
  case MENU_COMPLETION_2:
    completeKeyword(2);
    break;
  case MENU_COMPLETION_3:
    completeKeyword(3);
    break;
  }

  if (fontSize != _output->getFontSize()) {
    // restart the shell
    _output->setFontSize(fontSize);
    setRestart();
  }

  if (!isRunning()) {
    _output->flush(true);
  }
}