Ejemplo n.º 1
0
	void run(const OperatorArgs<T>& args, CpuResult<T>& ret) const {
		CpuTiming timing;
		AbstractCpuOperator<T>::start(timing);

		ukoct_ASSERT(args.other() != NULL, "Secondary matrix must be provided for this operator.");
		ukoct_ASSERT(args.state().implementation() != args.other()->implementation(), "Both matrices need to be from the same implementation.");
		ukoct::CpuState<T>& state = reinterpret_cast<CpuState<T>&>(args.state());
		ukoct::CpuState<T>& other = *reinterpret_cast<CpuState<T>*>(args.other());
		plas::DenseMatrix<T>& mat = state.input();
		plas::DenseMatrix<T>& oth = other.input();
		ret.boolResult = true;

		if (&state != &other) {
			if (state.diffSize() != other.diffSize())
				ret.boolResult = false;
				//throw Error("Problem sizes cannot be different.");

			for (plas::var_t i = 1; i <= state.diffSize() && ret.boolResult; ++i)
				for (plas::var_t j = 1; j <= state.diffSize() && ret.boolResult; ++j)
					if (oth(i, j) > mat(i, j))
						ret.boolResult = false;
		}

		AbstractCpuOperator<T>::end(timing);
	}
Ejemplo n.º 2
0
void ManagerBase::notifyPickBottom(Seat* s, const std::vector<Card>& c)
{
    Message m(MsgType::PickBottom);
    auto msg = m.get<PickBottomMsg>();
    msg->set_seat(s->id());
    (*msg) << c;
    Message oth(MsgType::PickBottom);
    msg = oth.get<PickBottomMsg>();
    msg->set_seat(s->id());
    notify(&m, s->seat(), &oth);
}
Ejemplo n.º 3
0
void ManagerBase::notifyDealCard(Seat* s, const Card& c)
{
    Message m(MsgType::DealCard);
    auto msg = m.get<DealCardMsg>();
    msg->set_seat(s->seat());
    msg->set_card(c.value());
    Message oth(MsgType::DealCard);
    msg = oth.get<DealCardMsg>();
    msg->set_seat(s->seat());
    msg->set_card(Card::Null);
    notify(&m, s->seat(), &oth);
}
Ejemplo n.º 4
0
void ManagerBase::notifyFixBottom(Seat* s, const std::vector<Card>& c, int reason)
{
    Message m(MsgType::FixBottom);
    auto msg = m.get<FixBottomMsg>();
    msg->set_seat(s->seat());
    (*msg) << c;
    msg->set_reason(reason);
    Message oth(MsgType::FixBottom);
    msg = oth.get<FixBottomMsg>();
    msg->set_seat(s->seat());
    msg->set_reason(reason);
    notify(&m, s->seat(), &oth);
}
Ejemplo n.º 5
0
void ManagerBase::notifyDiscardFail(Seat* s, const std::vector<Card>& c, int reason)
{
    Message m(MsgType::DiscardFail);
    auto msg = m.get<DiscardFailMsg>();
    msg->set_seat(s->seat());
    msg->set_reason(reason);
    (*msg) << c;
    if (reason == ErrorCode::ThrowFail) {
        Message oth(MsgType::DiscardFail);
        msg = m.get<DiscardFailMsg>();
        msg->set_seat(s->seat());
        msg->set_reason(reason);
        (*msg) << c;
        notify(&m, s->seat(), &oth);
    } else {
        notify(&m, s->seat());
    }
}
Ejemplo n.º 6
0
//----------------------------------------------------------------------
// WLAN_MENU
//----------------------------------------------------------------------
static int wlan_menu() {
    char **interface_list;
    char *filename;

    sprintf(bigbuf,"%s/wlan", globs.cfgdir);
    interface_sel = getenv("CGI_interface_sel");
    interface_list = get_file_chooser(bigbuf,interface_sel,"interface_sel","New Interface");
    if(interface_sel == NULL) {
	interface_sel = strdup(interface_list[1]);
    }

    sprintf(bigbuf,"wlan/%s", interface_sel);
    filename = strdup(bigbuf);
    read_cfg(filename,wkw,SEP,wv);
    free(filename);


    header("wlan");

    out_refresh_script();

    oform(("POST", "/cgi-bin/setup", "formw"));
    ohid("last_menu","wlan");
    ohid("j_click", "IGNORE");

    printf("<h3>Wireless Configuration Options</h3>\n");

    otbl(NULL);

    otr(NULL);
    oth("Wireless Interface");
    if (interface_sel[0] == 0 || strcmp(interface_sel,"__new") == 0) {
	otd(itext("interface_sel", "New Interface", 15, 15));
    } else {	
	otd(sel("onchange=\"send()\"", interface_list));
    }
    otr("/");

    otr(NULL);
    oth("Station ID (ESSID)");
    otd(itext(wkw[WLK_ESSID], wv[WLK_ESSID], 15, 12));
    otr("/");

    otr(NULL);
    oth("Security options (*)");
    {
	char *sec_sel[] = {
	    wkw[WLK_SECURITY], wv[WLK_SECURITY],
	    "None",                             "0",
	    "Hide SSID in beacon frames",       "1",
	    "Ignore clients with \"ANY\" SSID", "2",
	    "Both",                             "3",
	    NULL };
	    otd(sel("",sec_sel));
    }
    otr("/");

    otr(NULL);
    oth("Channel");
    {
	char *chan_sel[] = {
	    wkw[WLK_CHANNEL], wv[WLK_CHANNEL],
	    "Chan 1", "1",
	    "Chan 2", "2",
	    "Chan 3", "3",
	    "Chan 4", "4",
	    "Chan 5", "5",
	    "Chan 6", "6",
	    "Chan 7", "7",
	    "Chan 8", "8",
	    "Chan 9", "9",
	    "Chan 10", "10",
	    "Chan 11", "11",
	    "Chan 12", "12",
	    "Chan 13", "13",
	    NULL };
	    otd(sel("",chan_sel));
    }
    otr("/");

    otr(NULL);
    oth("Antenna Select RX");
    {
	char *aslr_list[] = {
	    wkw[WLK_ANTSEL_RX], wv[WLK_ANTSEL_RX],
	    "Default", "0", "Diversity", "1", "Low", "2", "High", "3",
	    NULL };
	    otd(sel("",aslr_list));
    }
    otr("/");

    otr(NULL);
    oth("TX");
    {
	char *aslt_list[] = {
	    wkw[WLK_ANTSEL_TX], wv[WLK_ANTSEL_TX],
	    "Default", "0", "Diversity", "1", "Low", "2", "High", "3",
	    NULL };
	    otd(sel("",aslt_list));
    }
    otr("/");

    otr(NULL);
    oth("Data Rate");
    {
	char *rate_list[] = {
	    wkw[WLK_RATE], wv[WLK_RATE],
	    "auto", "auto", "11Mb", "11Mb", "5Mb", "5Mb", "2Mb", "2Mb", "1Mb", "1Mb",
	    NULL };
	    otd(sel("",rate_list));
    }
    otr("/");

    otr(NULL);
    oth("Transmit Power");
    otd(itext(wkw[WLK_TXPOWER], wv[WLK_TXPOWER], 5, 4));
    otr("/");

    otr(NULL);
    oth("WEP Key<br>0x0x-0x0x-0x0x-0x0x-0x0x-0x0x-0x");
    otd(itext(wkw[WLK_WEP], wv[WLK_WEP], 40, 32));
    otr("/");

    otr(NULL);
    oth("Number of WDS Entries (AP Mode)");
    otd(itext(wkw[WLK_NWDS], wv[WLK_NWDS], 4, 2));
    otr("/");

    otbl("/");

    printf("(*) This option requires STA f/w ver 1.6.3 or newer\n");

    printf("<br><br>\n");
    ohid("menu","main");
    osub("f_click","OK");
    printf("&nbsp;&nbsp;&nbsp;\n");
    osub("f_click","CANCEL");
    oform(("/"));
}
Ejemplo n.º 7
0
//----------------------------------------------------------------------
// UDHCPD_MENU
//----------------------------------------------------------------------
static int udhcpd_menu()
{
    read_cfg("udhcpd.conf",uckw,uv);

    header("udhcpd");

    oform(("POST", "/cgi-bin/setup", NULL));
    ohid("last_menu","udhcpd");
    printf("<h3>DHCPD Configuration Options</h3>\n");

    otbl(NULL);

    otr(NULL);
    oth("Status");
    {
	char *stat_vals[] = {
	    ukw[UVK_ENABLE], uv[UVK_ENABLE],
	    "Enabled", "yes",
	    "Disabled", "no",
	    NULL };
	    otd(sel("",stat_vals));
    }
    otr("/");

    // This should be dynamically allocated
    otr(NULL);
    oth("Network Interface");
    {
	char *ifaces[] = {
	    ukw[UVK_INTERFACE], uv[UVK_INTERFACE],
	    "Ethernet 0 (eth0)", "eth0", 
	    "Ethernet 1 (eth1)", "eth1",
	    "Wireless 0 (wlan0)", "wlan0",
	    NULL };
	    otd(sel("",ifaces));
    }
    otr("/");

    otr(NULL);
    oth("Starting Address");
    otd(itext(ukw[UVK_START],uv[UVK_START], 18, 15));
    otr("/");

    otr(NULL);
    oth("Ending Address");
    otd(itext(ukw[UVK_END],uv[UVK_END], 18, 15));
    otr("/");

    otr(NULL);
    oth("Subnet Mask");
    otd(itext(ukw[UVK_SUBNET],uv[UVK_SUBNET], 18, 15));
    otr("/");

    otr(NULL);
    oth("Default Router");
    otd(itext(ukw[UVK_ROUTER],uv[UVK_ROUTER], 18, 15));
    otr("/");

    otr(NULL);
    oth("Domain Name Server(DNS)");
    otd(itext(ukw[UVK_DNS],uv[UVK_DNS], 18, 15));
    otr("/");

    otr(NULL);
    oth("Domain Name");
    otd(itext(ukw[UVK_DOMAIN],uv[UVK_DOMAIN], 18, 15));
    otr("/");

    otr(NULL);
    oth("Lease Time (in seconds)");
    otd(itext(ukw[UVK_LEASE], uv[UVK_LEASE], 18, 15));
    otr("/");

    otbl("/");

    printf("<br>\n");
    ohid("lease_file","/var/run/udhcpd.leases");
    ohid("menu","main");
    osub("f_click","OK");
    printf("&nbsp;&nbsp;&nbsp;\n");
    osub("f_click", "CANCEL");

    oform(("/"));
    printf("</body></html>\n");
}
Ejemplo n.º 8
0
//----------------------------------------------------------------------
// NETWORK_MENU
//----------------------------------------------------------------------
static int network_menu()
{
    read_cfg("netcfg",nkw,SEP,nv);

    header("menu");
    oform(("POST ","/cgi-bin/setup", NULL));
    ohid("last_menu","network");
    printf("<h3>Primary Network Interface (R/L 2=wlan0 3=br0 4=eth0)</h3>");

    otbl(NULL);
    otr(NULL);
    oth("Use DHCP");
    {
	char *dhcp_sel[] = {
	    nkw[NV_P_DHCP], nv[NV_P_DHCP],
	    "Enabled", "enabled", "Disabled", "disabled",
	    NULL };
	    otd(sel("",dhcp_sel));
    }
    otr("/");

    otr(NULL);
    oth("Network Address");
    otd(itext(nkw[NV_P_ADDRESS],nv[NV_P_ADDRESS], 18, 15));
    otr("/");

    otr(NULL);
    oth("Mask Address");
    otd(itext(nkw[NV_P_NETMASK],nv[NV_P_NETMASK], 18, 15));
    otr("/");

    otr(NULL);
    oth("Broadcast Address");
    otd(itext(nkw[NV_P_BROADCAST],nv[NV_P_BROADCAST], 18, 15));
    otr("/");

    otbl("/");
    printf("<br>\n");
    printf("<h3>Secondary Network Interface (R/L 2=eth0 4=wlan0 3=N/A)</h3>\n");

    otbl(NULL);

    otr(NULL);
    oth("Use DHCP");
    {
	char *dhcp_sel[] = {
	    nkw[NV_S_DHCP], nv[NV_S_DHCP],
	    "Enabled", "enabled", "Disabled", "disabled",
	    NULL };
	    otd(sel("",dhcp_sel));
    }
    otr("/");

    otr(NULL);
    oth("Network Address");
    otd(itext(nkw[NV_S_ADDRESS],nv[NV_S_ADDRESS], 18, 15));
    otr("/");

    otr(NULL);
    oth("Mask Address");
    otd(itext(nkw[NV_S_NETMASK],nv[NV_S_NETMASK], 18, 15));
    otr("/");

    otr(NULL);
    oth("Broadcast Address");
    otd(itext(nkw[NV_S_BROADCAST],nv[NV_S_BROADCAST], 18, 15));
    otr("/");

    otbl("/");

    printf("<br>\n");
    printf("<h3>Miscellaneous Configuration Data</h3>\n");

    otbl(NULL);

    otr(NULL);
    oth("TFTP Host");
    otd(itext(nkw[NV_TFTPHOST], nv[NV_TFTPHOST], 18,15));
    otr("/");

    otr(NULL);
    oth("Log (syslog) Server");
    otd(itext(nkw[NV_LOGSVR], nv[NV_LOGSVR], 18,15));
    otr("/");

    otr(NULL);
    oth("Watchdog interfaces (sepparated with spaces)");
    otd(itext(nkw[NV_IW_WATCHDOG_IF], nv[NV_IW_WATCHDOG_IF], 18,15));
    otr("/");

    otr(NULL);
    oth("Watchdog time interval (sec)");
    otd(itext(nkw[NV_IW_WATCHDOG_TIME], nv[NV_IW_WATCHDOG_TIME], 18,15));
    otr("/");

    otr(NULL);
    oth("Remote Date Host");
    otd(itext(nkw[NV_TIMESVR], nv[NV_TIMESVR], 18,15));
    otr("/");

    otr(NULL);
    oth("Default Router");
    otd(itext(nkw[NV_ROUTER], nv[NV_ROUTER], 18,15));
    otr("/");

    otr(NULL);
    oth("SWAP (NBD) Server");
    otd(itext(nkw[NV_SWAPSVR], nv[NV_SWAPSVR], 18,15));
    otr("/");

    otr(NULL);
    oth("SWAP (NBD) Port");
    otd(itext(nkw[NV_SWAPPORT], nv[NV_SWAPPORT], 18,15));
    otr("/");

    otr(NULL);
    oth("Masquerade Network");
    otd(itext(nkw[NV_MASQ_NET], nv[NV_MASQ_NET], 18,15));
    otr("/");

    otbl("/");

    printf("<br>\n");
    ohid("menu","main");
    osub("f_click","OK");
    printf("&nbsp;&nbsp;&nbsp;\n");
    osub("f_click", "CANCEL");

    oform(("/"));
    printf("</body></html>\n");
}