Ejemplo n.º 1
0
void show_op(trit (*f)(trit, trit), const char *name) {
	trit a, b;
	printf("\n[%s]\n    F ? T\n  -------", name);
	forall(a) {
		printf("\n%c |", t_s(a));
		forall(b) printf(" %c", t_s(f(a, b)));
	}
	puts("");
}
Ejemplo n.º 2
0
Archivo: cert.cpp Proyecto: GLolol/znc
 void Delete(const CString& line) {
     if (CFile::Delete(PemFile())) {
         PutModule(t_s("Pem file deleted"));
     } else {
         PutModule(t_s(
             "The pem file doesn't exist or there was a error deleting the "
             "pem file."));
     }
 }
Ejemplo n.º 3
0
    void Add(const CString& sCommand) {
        CString sPerf = sCommand.Token(1, true);

        if (sPerf.empty()) {
            PutModule(t_s("Usage: add <command>"));
            return;
        }

        m_vPerform.push_back(ParsePerform(sPerf));
        PutModule(t_s("Added!"));
        Save();
    }
Ejemplo n.º 4
0
    void Del(const CString& sCommand) {
        u_int iNum = sCommand.Token(1, true).ToUInt();

        if (iNum > m_vPerform.size() || iNum <= 0) {
            PutModule(t_s("Illegal # Requested"));
            return;
        } else {
            m_vPerform.erase(m_vPerform.begin() + iNum - 1);
            PutModule(t_s("Command Erased."));
        }
        Save();
    }
Ejemplo n.º 5
0
int main(void)
{
	trit a;

	puts("[Not]");
	forall(a) printf("%c | %c\n", t_s(a), t_s(t_not(a)));

	show_op(t_and,   "And");
	show_op(t_or,    "Or");
	show_op(t_eq,    "Equiv");
	show_op(t_imply, "Imply");

	return 0;
}
Ejemplo n.º 6
0
    void Swap(const CString& sCommand) {
        u_int iNumA = sCommand.Token(1).ToUInt();
        u_int iNumB = sCommand.Token(2).ToUInt();

        if (iNumA > m_vPerform.size() || iNumA <= 0 ||
            iNumB > m_vPerform.size() || iNumB <= 0) {
            PutModule(t_s("Illegal # Requested"));
        } else {
            std::iter_swap(m_vPerform.begin() + (iNumA - 1),
                           m_vPerform.begin() + (iNumB - 1));
            PutModule(t_s("Commands Swapped."));
            Save();
        }
    }
Ejemplo n.º 7
0
 void OnModCommand(const CString& sCommand) override {
     if (GetUser()->IsAdmin()) {
         HandleCommand(sCommand);
     } else {
         PutModule(t_s("Access denied"));
     }
 }
Ejemplo n.º 8
0
    void OnSetTimerCommand(const CString& sLine) {
        SetAwayWait(sLine.Token(1).ToUInt());

        if (m_iAwayWait == 0)
            PutModule(t_s("Timer disabled"));
        else
            PutModule(t_p("Timer set to 1 second", "Timer set to: {1} seconds",
                          m_iAwayWait)(m_iAwayWait));
    }
Ejemplo n.º 9
0
    void OnReasonCommand(const CString& sLine) {
        CString sReason = sLine.Token(1, true);

        if (!sReason.empty()) {
            SetReason(sReason);
            PutModule(t_s("Away reason set"));
        } else {
            PutModule(t_f("Away reason: {1}")(m_sReason));
            PutModule(t_f("Current away reason would be: {1}")(ExpandReason()));
        }
    }
Ejemplo n.º 10
0
 void Show(const CString& sLine) {
     PutModule("m_pISpoofLockFile = " +
               CString((long long)m_pISpoofLockFile));
     PutModule("m_pIRCSock = " + CString((long long)m_pIRCSock));
     if (m_pIRCSock) {
         PutModule("user/network - " +
                   m_pIRCSock->GetNetwork()->GetUser()->GetUserName() + "/" +
                   m_pIRCSock->GetNetwork()->GetName());
     } else {
         PutModule(t_s("identfile is free"));
     }
 }
Ejemplo n.º 11
0
Archivo: cert.cpp Proyecto: GLolol/znc
 void Info(const CString& line) {
     if (HasPemFile()) {
         PutModule(t_f("You have a certificate in {1}")(PemFile()));
     } else {
         PutModule(t_s(
             "You do not have a certificate. Please use the web interface "
             "to add a certificate"));
         if (GetUser()->IsAdmin()) {
             PutModule(t_f("Alternatively you can either place one at {1}")(
                 PemFile()));
         }
     }
 }
Ejemplo n.º 12
0
    void OnSecsCommand(const CString& sCommand) {
        const CString& sArg = sCommand.Token(1, true);

        if (sArg.empty()) {
            PutModule(t_s("Usage: Secs <limit>"));
            return;
        }

        m_iThresholdSecs = sArg.ToUInt();
        if (m_iThresholdSecs == 0) m_iThresholdSecs = 1;

        OnShowCommand("");
        Save();
    }
Ejemplo n.º 13
0
void CFDDataPack::reinitViscous()
{
	grad_rho = duh[0];
	grad_mom = RealTensor(duh[1], duh[2], duh[3]);

	for (int a = 0; a < 3; ++a)
		for (int b = 0; b < 3; ++b)
			grad_vel(a, b) = (grad_mom(a, b) - vel(a)*grad_rho(b))/r;

	tau = grad_vel + grad_vel.transpose();
	vel_div =  grad_vel.tr();
	tau(0, 0) -= 2./3*vel_div; tau(1, 1) -= 2./3*vel_div; tau(2, 2) -= 2./3*vel_div;

	if(_cfd_problem._vis_type == 0) vis = 0.0;
	else if(_cfd_problem._vis_type == 1) vis = 1.0;
	else if(_cfd_problem._vis_type == 2)
	{
		Real t_ref(288), t_s(110.4);
		vis = pow(t/t_ref, 1.5)*(t_ref+t_s)/(t+t_s);
	}
	else mooseError("不可知的粘性模型");
	tau *= vis/_reynolds;

	grad_enthalpy = (duh[4]-uh[4]/uh[0] * duh[0])/r - grad_vel.transpose() * vel;
	grad_enthalpy *= (vis/_reynolds)*(_gamma/_prandtl);

	invis_flux[0] = r*vel;

	invis_flux[1] = mom(0)*vel;
	invis_flux[1](0) += p;

	invis_flux[2] = mom(1)*vel;
	invis_flux[2](1) += p;

	invis_flux[3] = mom(2)*vel;
	invis_flux[3](2) += p;

	invis_flux[4] = r*h*vel;

	vis_flux[0].zero();
	vis_flux[1] = tau.row(0);
	vis_flux[2] = tau.row(1);
	vis_flux[3] = tau.row(2);
	vis_flux[4] = tau * vel + grad_enthalpy;
}
Ejemplo n.º 14
0
    EModRet OnIRCConnecting(CIRCSock* pIRCSock) override {
        if (m_pISpoofLockFile != nullptr) {
            DEBUG("Aborting connection, ident spoof lock file exists");
            PutModule(
                t_s("Aborting connection, another user or network is currently "
                    "connecting and using the ident spoof file"));
            return HALTCORE;
        }

        if (!WriteISpoof()) {
            DEBUG("identfile [" + GetNV("File") + "] could not be written");
            PutModule(
                t_f("[{1}] could not be written, retrying...")(GetNV("File")));
            return HALTCORE;
        }

        SetIRCSock(pIRCSock);
        return CONTINUE;
    }
Ejemplo n.º 15
0
static void to_subpaving(cmd_context & ctx, expr * t) {
    ast_manager & m = ctx.m();
    unsynch_mpq_manager qm;
    scoped_ptr<subpaving::context> s;
    s = subpaving::mk_mpq_context(ctx.m().limit(), qm);
    expr2var e2v(m);
    expr2subpaving e2s(m, *s, &e2v);
    params_ref p;
    p.set_bool("mul_to_power", true);
    th_rewriter simp(m, p);
    expr_ref t_s(m);
    simp(t, t_s);
    scoped_mpz n(qm), d(qm);
    ctx.regular_stream() << mk_ismt2_pp(t_s, m) << "\n=======>" << std::endl;
    subpaving::var x = e2s.internalize_term(t_s, n, d);
    expr2var::iterator it  = e2v.begin();
    expr2var::iterator end = e2v.end();
    for (; it != end; ++it) {
        ctx.regular_stream() << "x" << it->m_value << " := " << mk_ismt2_pp(it->m_key, m) << "\n";
    }
    s->display_constraints(ctx.regular_stream());
    ctx.regular_stream() << n << "/" << d << " x" << x << "\n";
}
Ejemplo n.º 16
0
    void List(const CString& sCommand) {
        CTable Table;
        unsigned int index = 1;

        Table.AddColumn(t_s("Id", "list"));
        Table.AddColumn(t_s("Perform", "list"));
        Table.AddColumn(t_s("Expanded", "list"));

        for (const CString& sPerf : m_vPerform) {
            Table.AddRow();
            Table.SetCell(t_s("Id", "list"), CString(index++));
            Table.SetCell(t_s("Perform", "list"), sPerf);

            CString sExpanded = ExpandString(sPerf);

            if (sExpanded != sPerf) {
                Table.SetCell(t_s("Expanded", "list"), sExpanded);
            }
        }

        if (PutModule(Table) == 0) {
            PutModule(t_s("No commands in your perform list."));
        }
    }
Ejemplo n.º 17
0
Archivo: cert.cpp Proyecto: GLolol/znc
        if (sPageName == "index") {
            Tmpl["Cert"] = CString(HasPemFile());
            return true;
        } else if (sPageName == "update") {
            CFile fPemFile(PemFile());

            if (fPemFile.Open(O_WRONLY | O_TRUNC | O_CREAT)) {
                fPemFile.Write(WebSock.GetParam("cert", true, ""));
                fPemFile.Close();
            }

            WebSock.Redirect(GetWebPath());
            return true;
        } else if (sPageName == "delete") {
            CFile::Delete(PemFile());
            WebSock.Redirect(GetWebPath());
            return true;
        }

        return false;
    }
};

template <>
void TModInfo<CCertMod>(CModInfo& Info) {
    Info.AddType(CModInfo::UserModule);
    Info.SetWikiPage("cert");
}

NETWORKMODULEDEFS(CCertMod, t_s("Use a ssl certificate to connect to a server"))
Ejemplo n.º 18
0
CInlineFormatMessage CCoreTranslationMixin::t_f(const CString& sEnglish,
                                                const CString& sContext) {
    return CInlineFormatMessage(t_s(sEnglish, sContext));
}
Ejemplo n.º 19
0
/*not telepathic, smart*/
gamestate_t nt_s(npc *monster, cell_t *cell_arr, path_node_t *c_path,
		 character *player)
{
  int n_x, n_y, dam;
  gamestate_t result;
  cell_t *c_cell, *n_cell;
  character *temp;
  std::stringstream mes;

  result = normal;

  c_cell = cell_arr + (MAP_WIDTH * monster->y_pos) + monster->x_pos;

  /*if it sees player, moves same as telpathic smart*/
  if(update_sight(player, monster, cell_arr))
    {
      return t_s(monster, cell_arr, c_path, player);
    }

  /*If monster is where last seen*/

  if(monster->x_pos == monster->seen_x &&
     monster->y_pos == monster->seen_y)
    {
      monster->seen_x = 150;
    }

  /*if it does not know where the player is, guess*/
  if(monster->seen_x > 100)
    {
      monster->seen_x = random_number(1, MAP_WIDTH - 2);
      monster->seen_y = random_number(1, MAP_HEIGHT - 2);
    }

  n_x = monster->seen_x - monster->x_pos;
  n_y = monster->seen_y - monster->y_pos;

  if(n_x < 0)
    {
      n_x = -1;
    }
  else if(n_x > 0)
    {
      n_x = 1;
    }
  if(n_y < 0)
    {
      n_y = -1;
    }
  else if(n_y > 0)
    {
      n_y = 1;
    }

  n_x += monster->x_pos;
  n_y += monster->y_pos;

  n_cell = cell_arr + (MAP_WIDTH * n_y) + n_x;

  //if pass do not worry about this part of code
  if(!(monster->traits & IS_PASS))
    {
      if(monster->traits & IS_TUNNELING)
	{
     
	  if(n_cell->cell_type == stone)
	    {
	      n_cell->hardness -= 85;
	      if(n_cell->hardness > 0)
		{
		  update_tunn_map(c_path, cell_arr);
		  return normal;
		}
	      else
		{
		  n_cell->hardness = 0;
		  n_cell->cell_type = corridor;
		  update_tunn_map(c_path, cell_arr);
		  result = update_nt_map;
		}
	    }
	}
      else if(n_cell->cell_type == stone)
	{
	  n_cell = cell_arr + (MAP_WIDTH * monster->y_pos) + n_x;
	  if(n_cell->cell_type == stone)
	    {
	      n_x = monster->x_pos;
	    }

	  n_cell = cell_arr + (MAP_WIDTH * n_y) + monster->x_pos;
	  if(n_cell->cell_type == stone)
	    {
	      n_y = monster->y_pos;
	    }

	  /*if cant continue on path, guess again*/
	  if(n_y == monster->y_pos && n_x == monster->x_pos)
	    {
	      monster->seen_x = random_number(1, MAP_WIDTH - 2);
	      monster->seen_y = random_number(1, MAP_HEIGHT - 2);
	    }
	}
    }

  n_cell = cell_arr + (MAP_WIDTH * n_y) + n_x;

  if(n_cell->character != NULL)
     {
       if(((character *)(n_cell->character))->print() == '@')
	 {
	   dam = monster->damage->roll();
	   dam = ((pc *)(n_cell->character))->attack(dam);

	   mes << "Attacked by " << *monster->name;
	   mes << " for " << dam << " hitpoints";
	   add_message(mes.str());

	   if(n_cell->character->hitpoints <= 0)
	     {
	       result = player_died;
	       n_cell->character = NULL;
	     }
	 }
       else
	 {
	   temp = n_cell->character;
	   temp->x_pos = monster->x_pos;
	   temp->y_pos = monster->y_pos;
	   c_cell->character = temp;
	   monster->y_pos = n_y;
	   monster->x_pos = n_x;
	   n_cell->character = monster;
	 }
       return result;
     }

   
  monster->y_pos = n_y;
  monster->x_pos = n_x;
  c_cell->character = NULL;
  n_cell->character = monster;

  return result;
}
Ejemplo n.º 20
0
        for (const CString& sPerf : m_vPerform) {
            CTemplate& Row = Tmpl.AddRow("PerformLoop");
            Row["Perform"] = sPerf;
        }

        return true;
    }

  private:
    void Save() {
        CString sBuffer = "";

        for (const CString& sPerf : m_vPerform) {
            sBuffer += sPerf + "\n";
        }
        SetNV("Perform", sBuffer);
    }

    VCString m_vPerform;
};

template <>
void TModInfo<CPerform>(CModInfo& Info) {
    Info.AddType(CModInfo::UserModule);
    Info.SetWikiPage("perform");
}

NETWORKMODULEDEFS(
    CPerform,
    t_s("Keeps a list of commands to be executed when ZNC connects to IRC."))
Ejemplo n.º 21
0
 CString GetWebMenuTitle() override { return t_s("Perform"); }
Ejemplo n.º 22
0
    void OnClientLogin() override { NotifyAdmins(t_s("attached")); }

    void OnClientDisconnect() override { NotifyAdmins(t_s("detached")); }

  private:
    void SendAdmins(const CString& msg) {
        CZNC::Get().Broadcast(msg, true, nullptr, GetClient());
    }

    void NotifyAdmins(const CString& event) {
        CString client = GetUser()->GetUserName();
        if (GetClient()->GetIdentifier() != "") {
            client += "@";
            client += GetClient()->GetIdentifier();
        }
        CString ip = GetClient()->GetRemoteIP();

        SendAdmins(t_f("{1} {2} from {3}")(client, event, ip));
    }
};

template <>
void TModInfo<CNotifyConnectMod>(CModInfo& Info) {
    Info.SetWikiPage("notify_connect");
}

GLOBALMODULEDEFS(
    CNotifyConnectMod,
    t_s("Notifies all admin users when a client connects or disconnects."))
Ejemplo n.º 23
0
Archivo: cert.cpp Proyecto: GLolol/znc
 CString GetWebMenuTitle() override { return t_s("Certificate"); }
Ejemplo n.º 24
0
int ContactMaterial3D::setTrialStrain (const Vector &strain_from_element)
{
#ifdef _G3DEBUG
  opserr << "ContactMaterial3D::setTrialStrain (const Vector &strain_from_element)" << endln;
#endif
  Vector t_s(2);          // tangential contact force
  double t_n;             // normal contact force
  double f_nplus1_trial;  // trial slip condition

  double gap;             // current gap
  Vector slip(2);         // incremental slip

  double t_s_norm;        // norm of tangential contact force
       
  strain_vec = strain_from_element;

  gap        = strain_vec(0);
  slip(0)    = strain_vec(1);
  slip(1)    = strain_vec(2);
  t_n        = strain_vec(3);    

  Vector zeroVec = slip;  
  zeroVec.Zero();

  // update frictional status
  this->UpdateFrictionalState();

  // trial state (elastic predictor step) -> assume sticking
  inSlip = false;
       
  s_e_nplus1 = (t_n > -tensileStrength) ?  s_e_n + slip : zeroVec; // ctv

  t_s        = stiffness * g * s_e_nplus1; // cov

  // Norm(s_e_nplus1) = sqrt( s_e_nplus1' * g * s_e_nplus1 )
  s_e_nplus1_norm = sqrt( s_e_nplus1(0) * g(0,0) * s_e_nplus1(0)
                          + s_e_nplus1(1) * g(1,0) * s_e_nplus1(0) * 2.0
                          + s_e_nplus1(1) * g(1,1) * s_e_nplus1(1) );

  // Norm(t_s) = sqrt( t_s' * g * t_s )
  //t_s_norm = sqrt( t_s(0) * G(0,0) * t_s(0)
  //                      + t_s(1) * G(1,0) * t_s(0) * 2.0
  //                      + t_s(1) * G(1,1) * t_s(1) );

  //Norm(t_s) = k*Norm(s_e_nplus1)  -- yields same result as above
  t_s_norm = stiffness * s_e_nplus1_norm;

  // slip condition
  f_nplus1_trial = t_s_norm - frictionCoeff*t_n - cohesion;

  // if (f_nplus1_trial > 0.0) {
  // if ( (f_nplus1_trial > 0.0) && (t_n > -cohesion/frictionCoeff) &&  (slip.Norm() > 1e-12) ) {
  if ( (f_nplus1_trial > 0.0) && (t_n > -tensileStrength) && (s_e_nplus1_norm > 1e-12) ) {
 
    // plastic corrector step -> sliding
    inSlip = true;

    gamma = f_nplus1_trial / stiffness * 0.999999999999 ;

    r_nplus1 = s_e_nplus1 / s_e_nplus1_norm; // ctv

    // s_p_nplus1 = s_p_n + gamma * r_nplus1
    // s_e_nplus1 = s_nplus1 - s_p_nplus1
    //        = (s_nplus1 - s_p_n) - gamma * r_nplus1
    //        = (s_n + slip - s_p_n) - gamma * r_nplus1
    //        = (s_e_n + slip) - gamma * r_nplus1
    //        = s_e_nplus1_trial - gamma * r_nplus1
    double scale = (1.0 - gamma/s_e_nplus1_norm);

    s_e_nplus1 = scale * s_e_nplus1; // ctv
    t_s        = scale * t_s;        // cov

  }

#ifdef _G3DEBUG
  if (DEBUG_LEVEL > 1) {
    if (inSlip) {
      opserr << "   ** SLIDING (material)" << endln;
    } else {
      opserr << "   ** STICKING (material)" << endln;
	}
  }
#endif

  //update stress and strain values
  stress_vec(0) = t_n;
  stress_vec(1) = t_s(0);
  stress_vec(2) = t_s(1);
  stress_vec(3) = gap;
       
  return 0;
}
Ejemplo n.º 25
0
        return CONTINUE;
    }

    void OnIRCConnected() override {
        if (m_pIRCSock == GetNetwork()->GetIRCSock()) {
            ReleaseISpoof();
        }
    }

    void OnIRCConnectionError(CIRCSock* pIRCSock) override {
        if (m_pIRCSock == pIRCSock) {
            ReleaseISpoof();
        }
    }

    void OnIRCDisconnected() override {
        if (m_pIRCSock == GetNetwork()->GetIRCSock()) {
            ReleaseISpoof();
        }
    }
};

template <>
void TModInfo<CIdentFileModule>(CModInfo& Info) {
    Info.SetWikiPage("identfile");
}

GLOBALMODULEDEFS(
    CIdentFileModule,
    t_s("Write the ident of a user to a file when they are trying to connect."))
Ejemplo n.º 26
0
 void Execute(const CString& sCommand) {
     OnIRCConnected();
     PutModule(t_s("perform commands sent"));
 }
Ejemplo n.º 27
0
    }

    void OnShowCommand(const CString& sCommand) {
        CString sMsgs = t_p("1 CTCP message", "{1} CTCP messages",
                            m_iThresholdMsgs)(m_iThresholdMsgs);
        CString sSecs = t_p("every second", "every {1} seconds",
                            m_iThresholdSecs)(m_iThresholdSecs);
        PutModule(t_f("Current limit is {1} {2}")(sMsgs, sSecs));
    }

  private:
    time_t m_tLastCTCP = 0;
    unsigned int m_iNumCTCP = 0;

    time_t m_iThresholdSecs{};
    unsigned int m_iThresholdMsgs{};
};

template <>
void TModInfo<CCtcpFloodMod>(CModInfo& Info) {
    Info.SetWikiPage("ctcpflood");
    Info.SetHasArgs(true);
    Info.SetArgsHelpText(Info.t_s(
        "This user module takes none to two arguments. The first argument is "
        "the number of lines after which the flood-protection is triggered. "
        "The second argument is the time (sec) to in which the number of lines "
        "is reached. The default setting is 4 CTCPs in 2 seconds"));
}

USERMODULEDEFS(CCtcpFloodMod, t_s("Don't forward CTCP floods to clients"))
Ejemplo n.º 28
0
 void OnClientDisconnect() override { NotifyAdmins(t_s("detached")); }
Ejemplo n.º 29
0
 void OnClientLogin() override { NotifyAdmins(t_s("attached")); }
Ejemplo n.º 30
0
    EModRet OnRaw(CString& sLine) override {
        // Handle 303 reply if m_Requests is not empty
        if (sLine.Token(1) == "303" && !m_ISONRequests.empty()) {
            VCString::iterator it = m_ISONRequests.begin();

            sLine.Trim();

            // Only append a space if this isn't an empty reply
            if (sLine.Right(1) != ":") {
                sLine += " ";
            }

            // add BNC nicks to the reply
            sLine += *it;
            m_ISONRequests.erase(it);
        }

        return CONTINUE;
    }

  private:
    VCString m_ISONRequests;
};

template <>
void TModInfo<CFOModule>(CModInfo& Info) {
    Info.SetWikiPage("modules_online");
}

NETWORKMODULEDEFS(CFOModule, t_s("Makes ZNC's *modules to be \"online\"."))