GLuint QGLPixmapData::bind(bool copyBack) const
{
    ensureCreated();

    GLuint id = m_texture.id;
    glBindTexture(GL_TEXTURE_2D, id);

    if (m_hasFillColor) {
            m_source = QVolatileImage(w, h, QImage::Format_ARGB32_Premultiplied);
            m_source.fill(PREMUL(m_fillColor.rgba()));

        m_hasFillColor = false;

        GLenum format = qt_gl_preferredTextureFormat();
        QImage tx(w, h, QImage::Format_ARGB32_Premultiplied);
        tx.fill(qt_gl_convertToGLFormat(m_fillColor.rgba(), format));
        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, format, GL_UNSIGNED_BYTE, tx.constBits());
    }

    return id;
}
Example #2
0
void MultithreadTest::TestAnyTranslit() {
#if !UCONFIG_NO_TRANSLITERATION
    UErrorCode status = U_ZERO_ERROR;
    LocalPointer<Transliterator> tx(Transliterator::createInstance("Any-Latin", UTRANS_FORWARD, status));
    if (U_FAILURE(status)) {
        dataerrln("File %s, Line %d: Error, status = %s", __FILE__, __LINE__, u_errorName(status));
        return;
    }
    gSharedTranslit = tx.getAlias();
    TxThread  threads[4];
    int32_t i;
    for (i=0; i<UPRV_LENGTHOF(threads); i++) {
        threads[i].start();
    }

    for (i=0; i<UPRV_LENGTHOF(threads); i++) {
        threads[i].join();
    }
    gSharedTranslit = NULL;
#endif  // !UCONFIG_NO_TRANSLITERATION
}
/** Fill in the fee on behalf of the client.
    This is called when the client does not explicitly specify the fee.
    The client may also put a ceiling on the amount of the fee. This ceiling
    is expressed as a multiplier based on the current ledger's fee schedule.

    JSON fields

    "Fee"   The fee paid by the transaction. Omitted when the client
            wants the fee filled in.

    "fee_mult_max"  A multiplier applied to the current ledger's transaction
                    fee that caps the maximum the fee server should auto fill.
                    If this optional field is not specified, then a default
                    multiplier is used.

    @param tx       The JSON corresponding to the transaction to fill in
    @param ledger   A ledger for retrieving the current fee schedule
    @param result   A JSON object for injecting error results, if any
    @param admin    `true` if this is called by an administrative endpoint.
*/
static void autofill_fee (Json::Value& request,
    Ledger::pointer ledger, Json::Value& result, bool admin)
{
    Json::Value& tx (request["tx_json"]);
    if (tx.isMember ("Fee"))
        return;

    int mult = DEFAULT_AUTO_FILL_FEE_MULTIPLIER;
    if (request.isMember ("fee_mult_max"))
    {
        if (request["fee_mult_max"].isNumeric ())
        {
            mult = request["fee_mult_max"].asInt();
        }
        else
        {
            RPC::inject_error (rpcHIGH_FEE, RPC::expected_field_message (
                "fee_mult_max", "a number"), result);
            return;
        }
    }

    std::uint64_t const feeDefault = getConfig().FEE_DEFAULT;

    // Administrative endpoints are exempt from local fees
    std::uint64_t const fee = ledger->scaleFeeLoad (feeDefault, admin);
    std::uint64_t const limit = mult * feeDefault;

    if (fee > limit)
    {
        std::stringstream ss;
        ss <<
            "Fee of " << fee <<
            " exceeds the requested tx limit of " << limit;
        RPC::inject_error (rpcHIGH_FEE, ss.str(), result);
        return;
    }

    tx ["Fee"] = static_cast<int>(fee);
}
Example #4
0
//sign
void MultisigDialog::on_signButton_clicked()
{
    if(!model)
        return;
   try{
        //parse tx hex
        CTransaction txRead;
        if(!DecodeHexTx(txRead, ui->transactionHex->text().toStdString())){
            throw runtime_error("Failed to decode transaction hex!");
        }

        CMutableTransaction tx(txRead);

        //check if transaction is already fully verified
        if(isFullyVerified(tx)){
            this->multisigTx = tx;
            ui->commitButton->setEnabled(true);
            ui->signButtonStatus->setText("This transaction is ready to commit. \nThe commit button in now enabled.");
            return;
        }

        string errorOut = string();
        bool fComplete = signMultisigTx(tx, errorOut, ui->keyList);

        if(!errorOut.empty()){
            throw runtime_error(errorOut.data());
        }else{
            this->multisigTx = tx;
        }

        ui->signButtonStatus->setStyleSheet("QTextEdit{ color: black }");
        ui->signButtonStatus->setText(buildMultisigTxStatusString(fComplete, tx));

    }catch(const runtime_error& e){
        ui->signButtonStatus->setStyleSheet("QTextEdit{ color: red }");
        ui->signButtonStatus->setText(tr(e.what()));
    }
}
Example #5
0
void MultisigDialog::commitMultisigTx()
{
    CMutableTransaction tx(multisigTx);
    try{
#ifdef ENABLE_WALLET
        CWalletTx wtx(pwalletMain, tx);
        CReserveKey keyChange(pwalletMain);
        if (!pwalletMain->CommitTransaction(wtx, keyChange))
            throw runtime_error(string("Transaction rejected - Failed to commit"));
#else
        uint256 hashTx = tx.GetHash();
        CCoinsViewCache& view = *pcoinsTip;
        const CCoins* existingCoins = view.AccessCoins(hashTx);
        bool fOverrideFees = false;
        bool fHaveMempool = mempool.exists(hashTx);
        bool fHaveChain = existingCoins && existingCoins->nHeight < 1000000000;

        if (!fHaveMempool && !fHaveChain) {
            // push to local node and sync with wallets
            CValidationState state;
            if (!AcceptToMemoryPool(mempool, state, tx, false, NULL, !fOverrideFees)) {
                if (state.IsInvalid())
                    throw runtime_error(strprintf("Transaction rejected - %i: %s", state.GetRejectCode(), state.GetRejectReason()));
                else
                    throw runtime_error(string("Transaction rejected - ") + state.GetRejectReason());
            }
        } else if (fHaveChain) {
            throw runtime_error("transaction already in block chain");
        }
        RelayTransaction(tx);
#endif
        //disable commit if successfully committed
        ui->commitButton->setEnabled(false);
        ui->signButtonStatus->setText(strprintf("Transaction has been successfully published with transaction ID:\n %s", tx.GetHash().GetHex()).c_str());
    }catch(const runtime_error& e){
        ui->signButtonStatus->setText(e.what());
    }
}
Example #6
0
void q_power_frobenius(ECn3 &S,ZZn2& X)
{
	ZZn6 X1,X2,Y1,Y2;
	ZZn3 Sx,Sy,T;

	int qnr=get_mip()->cnr;

	S.get(Sx,Sy);

	// untwist    
    Sx=Sx/qnr;
    Sy=tx(Sy);
    Sy=Sy/(qnr*qnr);

	X1=shuffle(Sx,(ZZn3)0); Y1=shuffle((ZZn3)0,Sy);
	X1.powq(X); Y1.powq(X);
	unshuffle(X1,Sx,T); unshuffle(Y1,T,Sy);
	
	// twist
	Sx=qnr*Sx;
	Sy=txd(Sy*qnr*qnr);
	S.set(Sx,Sy);
}
Example #7
0
void CropSpriteCommand::onExecute(Context* context)
{
  ContextWriter writer(context);
  Doc* document(writer.document());
  Sprite* sprite(writer.sprite());

  gfx::Rect bounds;
  if (m_bounds.isEmpty())
    bounds = document->mask()->bounds();
  else
    bounds = m_bounds;

  {
    Tx tx(writer.context(), "Sprite Crop");
    document->getApi(tx).cropSprite(sprite, bounds);
    tx.commit();
  }

#ifdef ENABLE_UI
  if (context->isUIAvailable())
    update_screen_for_document(document);
#endif
}
Example #8
0
void RemoveFrameCommand::onExecute(Context* context)
{
  ContextWriter writer(context);
  Doc* document(writer.document());
  Sprite* sprite(writer.sprite());
  {
    Tx tx(writer.context(), "Remove Frame");
    DocApi api = document->getApi(tx);
    const Site* site = writer.site();
    if (site->inTimeline() &&
        !site->selectedFrames().empty()) {
      for (frame_t frame : site->selectedFrames().reversed()) {
        api.removeFrame(sprite, frame);
      }
    }
    else {
      api.removeFrame(sprite, writer.frame());
    }

    tx.commit();
  }
  update_screen_for_document(document);
}
Example #9
0
void * worker_thread(void *arg)
{
	int cpu, v1;

	cpu = sched_getcpu();
	PRINT("worker_thread start on CPU %d\n",cpu);
#ifdef __CALIBRATION__
	calibrate_compensated_timer();
#endif
#ifdef __CALIBRATED_TIMER__
	compensated_timer();
#endif
#ifdef __CALIBRATED_JIFFIE__
	calibrate_lpj();
#endif
#ifdef __CALIBRATED_LSTREAM__
	calibrate_lstream();
#endif
#ifdef __CALIBRATED_TX__
	if(transmitter)
		calibrated_tx();
	else{
		while(1){
			v1 = *spinlock;
			while(*spinlock == v1);
			fprintf(stderr, "%d\n",v1);
		}
	}
#endif
#ifdef __AUTO_CALIBRATION__
	auto_calibration_main(2393715000);
#endif
#ifdef __TX__
	tx();
#endif
	return NULL;
}
Example #10
0
   void BivarStats<T>::add(const T& x, const T& y)
   {
      if (ns == 0)
      {
         sumX = sumY = sumX2 = sumY2 = sumXY = T(0);
         xMin = xMax = x;
         yMin = yMax = y;
         scaleX = scaleY = T(1);
      }

      if (scaled)
      {
         if (scaleX==T(1) && x!=T()) scaleX=ABS(x);
         if (scaleY==T(1) && y!=T()) scaleY=ABS(y);
         T tx(x/scaleX);
         T ty(y/scaleY);
         sumX += tx;
         sumY += ty;
         sumX2 += tx*tx;
         sumY2 += ty*ty;
         sumXY += tx*ty;
      }
      else
      {
         sumX += x;
         sumY += y;
         sumX2 += x*x;
         sumY2 += y*y;
         sumXY += x*y;
      }

      if(x < xMin) xMin=x;
      if(x > xMax) xMax=x;
      if(y < yMin) yMin=y;
      if(y > yMax) yMax=y;
      ns++;
   }
int main() {
  coord 	t(3);
  coord		Q(3);
  coord		R(3);
  coord		pi(3);
  coord		QxtxQ(3);
  coord		txQ(3);
  double 	k;

  t[0] = 1.0;
  t[1] = 2.0;
  t[2] = 3.0;

  pi[0] = -0.5;
  pi[1] = -2.345;
  pi[2] = 1.2345;

  Q = pi;
  R = pi - t;

  transformMatrix tx(cross_prod, t[0], t[1], t[2]);
  transformMatrix Qx(cross_prod, Q[0], Q[1], Q[2]);


  //  txQ = tx*Q;
  QxtxQ = Qx*tx*Q;

  std::cout << "R0 = " << (R*Q).sum() << std::endl;
  std::cout << "R1 = " << (R*QxtxQ).sum() << std::endl;
  //std::cout << "R2 = " << (R*txQ).sum() << std::endl;

  k = ((t*Q).sum() - (t*QxtxQ).sum()*(R*Q).sum()/(R*QxtxQ).sum())/(Q*Q).sum();

  std::cout << "pi = " << k*Q << std::endl;

  return(0);
}
Example #12
0
int
main(int argc, char *argv[])
{
	START(argc, argv, "obj_cpp_map");

	if (argc != 3 || strchr("co", argv[1][0]) == nullptr)
		UT_FATAL("usage: %s <c,o> file-name", argv[0]);

	const char *path = argv[2];

	nvobj::pool<root> pop;
	bool open = (argv[1][0] == 'o');

	try {
		if (open) {
			pop = nvobj::pool<root>::open(path, LAYOUT);

		} else {
			pop = nvobj::pool<root>::create(path, LAYOUT,
							PMEMOBJ_MIN_POOL * 2,
							S_IWUSR | S_IRUSR);
			nvobj::transaction::manual tx(pop);
			pop.get_root()->cons =
				nvobj::make_persistent<containers>(pop);
			nvobj::transaction::commit();
		}
	} catch (nvml::pool_error &pe) {
		UT_FATAL("!pool::create: %s %s", pe.what(), path);
	}

	test_map(pop, open);

	pop.close();

	DONE(nullptr);
}
Example #13
0
/** Send the UeState to the GPS
*   \param    ril - handle returned from BrcmLbsRil_init 
*   \param    protocol - BrcmCpHalAsn1_Protocol
*   \param    state - BrcmLbsRilAsn1_UeState
*********************************************************************************/
BrcmLbs_Result BrcmLbsRil_setUeState(OsHandle ril, 
    BrcmLbsRilAsn1_Protocol protocol,
    BrcmLbsRilAsn1_UeState state)
{
    uint8_t buf[1024];

    D("%s\n", __FUNCTION__);

    brcm_marshall_func_init(buf, sizeof(buf), BRCMLBSRIL_SETUESTATE);

    if (brcm_marshall_func_add_arg(buf, sizeof(buf), BRCM_MARSHALL_ARG_UINT32, 
        (uint32_t)protocol, NULL, 0) < 0)
    {
        return BRCM_LBS_ERROR_PARAMETER_INVALID;
    }

    if (brcm_marshall_func_add_arg(buf, sizeof(buf), BRCM_MARSHALL_ARG_UINT32, 
        (uint32_t)state, NULL, 0) < 0)
    {
        return BRCM_LBS_ERROR_PARAMETER_INVALID;
    }

    return tx(ril, buf, brcm_marshall_get_len(buf, sizeof(buf)));
}
Example #14
0
bool checkMeta(const char* path,
	       const char* sval, double* dvals, int ndvals, int16_t* ivals, int nivals,
	       const char* xval)
{
    std::string error;
    PtexPtr<PtexTexture> tx(PtexTexture::open(path, error));
    if (!tx) {
	std::cerr << error << std::endl;
	return 0;
    }
    PtexPtr<PtexMetaData> meta(tx->getMetaData());

    const char* f_sval;
    meta->getValue("sval", f_sval);

    const double* f_dvals;
    int f_ndvals;
    meta->getValue("dvals", f_dvals, f_ndvals);

    const int16_t* f_ivals;
    int f_nivals;
    meta->getValue("ivals", f_ivals, f_nivals);

    const char* f_xval;
    meta->getValue("xval", f_xval);

    bool ok = ((!sval || 0==strcmp(sval, f_sval)) &&
	       (!ndvals || ndvals == f_ndvals && 0==memcmp(dvals, f_dvals, ndvals*sizeof(dvals[0]))) &&
	       (!nivals || nivals == f_nivals && 0==memcmp(ivals, f_ivals, nivals*sizeof(ivals[0]))) &&
	       (!xval || 0==strcmp(xval, f_xval)));
    if (!ok) {
	std::cerr << "Meta data readback failed" << std::endl;
	return 0;
    }
    return 1;
}
/*
 *	Measure the time it takes for the logd posting call to make it into
 * the logs. Expect this to be less than double the process wakeup time (2ms).
 */
static void BM_log_delay(int iters) {
    pid_t pid = getpid();

    struct logger_list * logger_list = android_logger_list_open(LOG_ID_EVENTS,
        O_RDONLY, 0, pid);

    if (!logger_list) {
        fprintf(stderr, "Unable to open events log: %s\n", strerror(errno));
        exit(EXIT_FAILURE);
    }

    signal(SIGALRM, caught_delay);
    alarm(alarm_time);

    StartBenchmarkTiming();

    for (int i = 0; i < iters; ++i) {
        log_time ts(CLOCK_REALTIME);

        LOG_FAILURE_RETRY(
            android_btWriteLog(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));

        for (;;) {
            log_msg log_msg;
            int ret = android_logger_list_read(logger_list, &log_msg);
            alarm(alarm_time);

            if (ret <= 0) {
                iters = i;
                break;
            }
            if ((log_msg.entry.len != (4 + 1 + 8))
             || (log_msg.id() != LOG_ID_EVENTS)) {
                continue;
            }

            char* eventData = log_msg.msg();

            if (eventData[4] != EVENT_TYPE_LONG) {
                continue;
            }
            log_time tx(eventData + 4 + 1);
            if (ts != tx) {
                if (0xDEADBEEFA55A5AA6ULL == caught_convert(eventData + 4 + 1)) {
                    iters = i;
                    break;
                }
                continue;
            }

            break;
        }
    }

    signal(SIGALRM, SIG_DFL);
    alarm(0);

    StopBenchmarkTiming();

    android_logger_list_free(logger_list);
}
Example #16
0
void
PDFWriter::DrawChar(uint16 unicode, const char* utf8, int16 size)
{
	// try to convert from utf8 to MacRoman encoding schema...
	int32 srcLen  = size;
	int32 destLen = 1;
	char dest[3] = "\0\0";
	int32 state = 0;
	bool embed = true;
	font_encoding encoding = macroman_encoding;
	char fontName[B_FONT_FAMILY_LENGTH+B_FONT_STYLE_LENGTH+1];

	if (convert_from_utf8(B_MAC_ROMAN_CONVERSION, utf8, &srcLen, dest, &destLen,
			&state, 0) != B_OK || dest[0] == 0) {
		// could not convert to MacRoman
		font_encoding fenc;
		uint16 index = 0;
		uint8 enc;

		GetFontName(&fState->beFont, fontName);
		embed = EmbedFont(fontName);

		REPORT(kDebug, -1, "find_encoding unicode %d\n", (int)unicode);
		if (find_encoding(unicode, enc, index)) {
			// is code point in the Adobe Glyph List?
			// Note if rendering the glyphs only would be desired, we could
			// always use the second method below (MakeUserDefinedEncoding),
			// but extracting text from the generated PDF would be almost
			// impossible (OCR!)
			REPORT(kDebug, -1, "encoding for %x -> %d %d", unicode, (int)enc,
				(int)index);
			// use one of the user pre-defined encodings
			if (fState->beFont.FileFormat() == B_TRUETYPE_WINDOWS) {
				encoding = font_encoding(enc + tt_encoding0);
			} else {
				encoding = font_encoding(enc + t1_encoding0);
			}
			*dest = index;
		} else if (embed) {
			// if the font is embedded, create a user defined encoding at runtime
			uint8 index;
			MakeUserDefinedEncoding(unicode, enc, index);
			*dest = index;
			encoding = font_encoding(user_defined_encoding_start + enc);
		} else if (find_in_cid_tables(unicode, fenc, index, fFontSearchOrder)) {
			// font is not embedded use one of the CJK fonts for substitution
			REPORT(kDebug, -1, "cid table %d index = %d", (int)fenc, (int)index);
			dest[0] = unicode / 256;
			dest[1] = unicode % 256;
			destLen = 2;
			encoding = fenc;
			embed = false;
		} else {
			static bool found = false;
			REPORT(kDebug, -1, "encoding for %x not found!", (int)unicode);
			if (!found) {
				found = true;
				REPORT(kError, fPage, "Could not find an encoding for character "
					"with unicode %d! Message is not repeated for other unicode "
					"values.", (int)unicode);
			}
			*dest = 0; // paint a box (is 0 a box in MacRoman) or
			return; // simply skip character
		}
	} else {
		REPORT(kDebug, -1, "macroman srcLen=%d destLen=%d dest= %d %d!", srcLen,
			destLen, (int)dest[0], (int)dest[1]);
	}

	// Note we have to build the user defined encoding before it is used in
	// PDF_find_font!
	if (!MakesPDF()) return;

	int		font;

	GetFontName(&fState->beFont, fontName, embed, encoding);
	font = FindFont(fontName, embed, encoding);
	if (font < 0) {
		REPORT(kWarning, fPage, "**** PDF_findfont(%s) failed, back to default "
			"font", fontName);
		font = PDF_findfont(fPdf, "Helvetica", "macroman", 0);
	}

	fState->font = font;

	uint16 face = fState->beFont.Face();
	PDF_set_parameter(fPdf, "underline", (face & B_UNDERSCORE_FACE) != 0
		? "true" : "false");
	PDF_set_parameter(fPdf, "strikeout", (face & B_STRIKEOUT_FACE) != 0
		? "true" : "false");
	PDF_set_value(fPdf, "textrendering", (face & B_OUTLINED_FACE) != 0 ? 1 : 0);

	PDF_setfont(fPdf, fState->font, scale(fState->beFont.Size()));

	const float x = tx(fState->penX);
	const float y = ty(fState->penY);
	const float rotation = fState->beFont.Rotation();
	const bool rotate = rotation != 0.0;

	if (rotate) {
		PDF_save(fPdf);
		PDF_translate(fPdf, x, y);
		PDF_rotate(fPdf, rotation);
	    PDF_set_text_pos(fPdf, 0, 0);
	} else
	    PDF_set_text_pos(fPdf, x, y);

	PDF_show2(fPdf, dest, destLen);

	if (rotate) {
		PDF_restore(fPdf);
	}
}
Example #17
0
void serialRegsInit( void )
{
	tx( prompt );
}
Example #18
0
void
maktab(void)
{
# define FN(i,c) font[stynum[i]][c]
# define SZ(i,c) csize[stynum[i]][c]
	/* define the tab stops of the table */
	int icol, ilin, tsep, k, ik, vforml, il, text;
	int doubled[MAXCOL], acase[MAXCOL];
	char *s;
	char space[40];
	for(icol=0; icol <ncol; icol++)
	{
		doubled[icol] = acase[icol] = 0;
		fprintf(tabout, ".nr %d 0\n", icol+CRIGHT);
		for(text=0; text<2; text++)
		{
			if (text) {
				warnoff();
				fprintf(tabout, ".%02d\n.rm %02d\n", icol+80, icol+80);
				warnon();
			}
			for(ilin=0; ilin<nlin; ilin++)
			{
				if (instead[ilin]|| fullbot[ilin]) continue;
				vforml=ilin;
				for(il=prev(ilin); il>=0 && vspen(table[il][icol].col); il=prev(il))
					vforml=il;
				if (fspan(vforml,icol)) continue;
				if (filler(table[ilin][icol].col)) continue;
				switch(ctype(vforml,icol))
				{
				case 'a':
					acase[icol]=1;
					s = table[ilin][icol].col;
					if (tx(s) && text)
					{
						if (doubled[icol]==0)
							fprintf(tabout, ".nr %d 0\n.nr %d 0\n",S1,S2);
						doubled[icol]=1;
						nreg(space, sizeof(space), s,
						    '-');
						fprintf(tabout, ".if %s>\\n(%d .nr %d %s\n",space,S2,S2,space);
					}
				case 'n':
					if (table[ilin][icol].rcol!=0)
					{
						if (doubled[icol]==0 && text==0)
							fprintf(tabout, ".nr %d 0\n.nr %d 0\n", S1, S2);
						doubled[icol]=1;
						if (real(s=table[ilin][icol].col) && !vspen(s))
						{
							if (tx(s) != text) continue;
							fprintf(tabout, ".nr %d ", TMP);
							wide(s, FN(vforml,icol), SZ(vforml,icol)); fprintf(tabout, "\n");
							fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S1, TMP, S1, TMP);
						}
						if (text==0 && real(s=table[ilin][icol].rcol) && !vspen(s) && !barent(s))
						{
							fprintf(tabout, ".nr %d \\w%c%s%c\n",TMP, F1, s, F1);
							fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n",S2,TMP,S2,TMP);
						}
						continue;
					}
				case 'r':
				case 'c':
				case 'l':
					if (real(s=table[ilin][icol].col) && !vspen(s))
					{
						if (tx(s) != text) continue;
						fprintf(tabout, ".nr %d ", TMP);
						wide(s, FN(vforml,icol), SZ(vforml,icol)); fprintf(tabout, "\n");
						fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", icol+CRIGHT, TMP, icol+CRIGHT, TMP);
					}
				}
			}
		}
		if (acase[icol])
		{
			fprintf(tabout, ".if \\n(%d>=\\n(%d .nr %d \\n(%du+2n\n",S2,icol+CRIGHT,icol+CRIGHT,S2);
		}
		if (doubled[icol])
		{
			fprintf(tabout, ".nr %d \\n(%d\n", icol+CMID, S1);
			fprintf(tabout, ".nr %d \\n(%d+\\n(%d\n",TMP,icol+CMID,S2);
			fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n",TMP,icol+CRIGHT,icol+CRIGHT,TMP);
			fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d +(\\n(%d-\\n(%d)/2\n",TMP,icol+CRIGHT,icol+CMID,icol+CRIGHT,TMP);
		}
		if (cll[icol][0])
		{
			fprintf(tabout, ".nr %d %sn\n", TMP, cll[icol]);
			fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n",icol+CRIGHT, TMP, icol+CRIGHT, TMP);
		}
		for(ilin=0; ilin<nlin; ilin++)
			if ((k=lspan(ilin, icol)))
			{
				s=table[ilin][icol-k].col;
				if (!real(s) || barent(s) || vspen(s) ) continue;
				fprintf(tabout, ".nr %d ", TMP);
				wide(table[ilin][icol-k].col, FN(ilin,icol-k), SZ(ilin,icol-k));
				for(ik=k; ik>=0; ik--)
				{
					fprintf(tabout, "-\\n(%d",CRIGHT+icol-ik);
					if (!expflg && ik>0) fprintf(tabout, "-%dn", sep[icol-ik]);
				}
				fprintf(tabout, "\n");
				fprintf(tabout, ".if \\n(%d>0 .nr %d \\n(%d/%d\n", TMP, TMP, TMP, k);
				fprintf(tabout, ".if \\n(%d<0 .nr %d 0\n", TMP, TMP);
				for(ik=0; ik<k; ik++)
				{
					if (doubled[icol-k+ik])
						fprintf(tabout, ".nr %d +\\n(%d/2\n", icol-k+ik+CMID, TMP);
					fprintf(tabout, ".nr %d +\\n(%d\n", icol-k+ik+CRIGHT, TMP);
				}
			}
	}
	if (textflg) untext();
	/* if even requested, make all columns widest width */
# define TMP1 S1
# define TMP2 S2
	if (evenflg)
	{
		fprintf(tabout, ".nr %d 0\n", TMP);
		for(icol=0; icol<ncol; icol++)
		{
			if (evenup[icol]==0) continue;
			fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n",
			    icol+CRIGHT, TMP, TMP, icol+CRIGHT);
		}
		for(icol=0; icol<ncol; icol++)
		{
			if (evenup[icol]==0)
				/* if column not evened just retain old interval */
				continue;
			if (doubled[icol])
				fprintf(tabout, ".nr %d (100*\\n(%d/\\n(%d)*\\n(%d/100\n",
				    icol+CMID, icol+CMID, icol+CRIGHT, TMP);
				/* that nonsense with the 100's and parens tries
				   to avoid overflow while proportionally shifting
				   the middle of the number */
			fprintf(tabout, ".nr %d \\n(%d\n", icol+CRIGHT, TMP);
		}
	}
	/* now adjust for total table width */
	for(tsep=icol=0; icol<ncol; icol++)
		tsep+= sep[icol];
	if (expflg)
	{
		fprintf(tabout, ".nr %d 0", TMP);
		for(icol=0; icol<ncol; icol++)
			fprintf(tabout, "+\\n(%d", icol+CRIGHT);
		fprintf(tabout, "\n");
		fprintf(tabout, ".nr %d \\n(.l-\\n(.i-\\n(%d%s\n", TMP, TMP,
		    (utf8 || tlp) && (boxflg || dboxflg || allflg) ? "-1n" : "");
		if (boxflg || dboxflg || allflg)
			tsep += 1;
		else
			tsep -= sep[ncol-1];
		fprintf(tabout, ".nr %d \\n(%d/%d\n", TMP, TMP,  tsep);
		fprintf(tabout, ".if \\n(%d<1n .nr %d 1n\n", TMP, TMP);
	}
	else if (xcolflg) {
		fprintf(tabout, ".nr %d 0", TMP);
		for(icol=0; icol<ncol; icol++)
			fprintf(tabout, "+\\n(%d", icol+CRIGHT);
		fprintf(tabout, "\n");
		fprintf(tabout, ".nr %d \\n(.l-\\n(.i-\\n(%d-%dn/%d\n", TMP,
		    TMP, tsep + ((boxflg || dboxflg || allflg) ? 
		    (utf8 || tlp) ? 2 : 1 : -1), xcolflg);
		for(icol=0; icol<ncol; icol++) {
			if (!xcol[icol]) continue;
			fprintf(tabout, ".nr %d +\\n(%d\n", icol+CRIGHT, TMP);
		}
		fprintf(tabout, ".nr %d 1n\n", TMP);
	}
	else
		fprintf(tabout, ".nr %d 1n\n", TMP);
	fprintf(tabout, ".nr %d 0\n",CRIGHT-1);
	tsep= (boxflg || allflg || dboxflg || left1flg) ? 1 : 0;
	for(icol=0; icol<ncol; icol++)
	{
		fprintf(tabout, ".nr %d \\n(%d+(%d*\\n(%d)\n",icol+CLEFT, icol+CRIGHT-1, tsep, TMP);
		fprintf(tabout, ".nr %d +\\n(%d\n",icol+CRIGHT, icol+CLEFT);
		if (doubled[icol])
		{
			/* the next line is last-ditch effort to avoid zero field width */
			/*fprintf(tabout, ".if \\n(%d=0 .nr %d 1\n",icol+CMID, icol+CMID);*/
			fprintf(tabout, ".nr %d +\\n(%d\n", icol+CMID, icol+CLEFT);
			/*  fprintf(tabout, ".if n .if \\n(%d%%24>0 .nr %d +12u\n",icol+CMID, icol+CMID); */
		}
		tsep=sep[icol];
	}
	if (rightl)
		fprintf(tabout, ".nr %d (\\n(%d+\\n(%d)/2\n",ncol+CRIGHT-1, ncol+CLEFT-1, ncol+CRIGHT-2);
	fprintf(tabout, ".nr TW \\n(%d\n", ncol+CRIGHT-1);
	if (boxflg || allflg || dboxflg)
		fprintf(tabout, ".nr TW +%d*\\n(%d\n", sep[ncol-1], TMP);
	fprintf(tabout,
	    ".if t .if \\n(TW>\\n(.l .tm Table at line %d file %s is too wide - \\n(TW units\n", iline-1, ifile);
	return;
}
bool
StateSnapshot::writeHistoryBlocks() const
{
    std::unique_ptr<soci::session> snapSess(
        mApp.getDatabase().canUsePool()
            ? make_unique<soci::session>(mApp.getDatabase().getPool())
            : nullptr);
    soci::session& sess(snapSess ? *snapSess : mApp.getDatabase().getSession());
    soci::transaction tx(sess);

    // The current "history block" is stored in _three_ files, one just ledger
    // headers, one TransactionHistoryEntry (which contain txSets) and
    // one TransactionHistoryResultEntry containing transaction set results.
    // All files are streamed out of the database, entry-by-entry.
    XDROutputFileStream ledgerOut, txOut, txResultOut;
    ledgerOut.open(mLedgerSnapFile->localPath_nogz());
    txOut.open(mTransactionSnapFile->localPath_nogz());
    txResultOut.open(mTransactionResultSnapFile->localPath_nogz());

    // 'mLocalState' describes the LCL, so its currentLedger will usually be 63,
    // 127, 191, etc. We want to start our snapshot at 64-before the _next_
    // ledger: 0, 64, 128, etc. In cases where we're forcibly checkpointed
    // early, we still want to round-down to the previous checkpoint ledger.
    uint32_t begin = mApp.getHistoryManager().prevCheckpointLedger(
        mLocalState.currentLedger);

    uint32_t count = (mLocalState.currentLedger - begin) + 1;
    CLOG(DEBUG, "History") << "Streaming " << count
                           << " ledgers worth of history, from " << begin;

    size_t nHeaders = LedgerHeaderFrame::copyLedgerHeadersToStream(
        mApp.getDatabase(), sess, begin, count, ledgerOut);
    size_t nTxs = TransactionFrame::copyTransactionsToStream(
        mApp.getDatabase(), sess, begin, count, txOut, txResultOut);
    CLOG(DEBUG, "History") << "Wrote " << nHeaders << " ledger headers to "
                           << mLedgerSnapFile->localPath_nogz();
    CLOG(DEBUG, "History") << "Wrote " << nTxs << " transactions to "
                           << mTransactionSnapFile->localPath_nogz() << " and "
                           << mTransactionResultSnapFile->localPath_nogz();

    // When writing checkpoint 0x3f (63) we will have written 63 headers because
    // header 0 doesn't exist, ledger 1 is the first. For all later checkpoints
    // we will write 64 headers; any less and something went wrong[1].
    //
    // [1]: Probably our read transaction was serialized ahead of the write
    // transaction composing the history itself, despite occurring in the
    // opposite wall-clock order, this is legal behavior in SERIALIZABLE
    // transaction-isolation level -- the highest offered! -- as txns only have
    // to be applied in isolation and in _some_ order, not the wall-clock order
    // we issued them. Anyway this is transient and should go away upon retry.
    if (! ((begin == 0 && nHeaders == count - 1) ||
           nHeaders == count))
    {
        CLOG(ERROR, "History") << "Only wrote " << nHeaders << " ledger headers for "
                               << mLedgerSnapFile->localPath_nogz() << ", expecting "
                               << count;
        return false;
    }

    return true;
}
Example #20
0
int i2c_rx_string(unsigned char addr, char* buf, int len) {
  tx(1,0,addr << 1 | 1);
  for(int i=0;i<len-1;i++) buf[i]=rx(0,0);
  buf[len-1]=rx(1,1);
  return 0;
}
Example #21
0
File: tpio.cpp Project: nyaxt/ptnk
void
TPIO::refreshOldPages(page_id_t threshold, size_t pgsPerTx)
{
	// rOP: refreshOldPages
	//
	// case 1:
	//    rOP    s---e
	//    Rebase       s---e
	//
	//    no prob
	//
	// case 2:
	//    rOP          s---e
	//    Rebase s---e      s---e
	//
	//    no prob
	//
	// case 3:
	//    rOP        s-!---e
	//    Rebase s-----e
	//
	//    no prob. rOP waits until rebase is done
	//
	// case 4:
	//    rOP    s---e
	//    Rebase   s-!---e
	//
	//    rebase need to wait until rOP finishes... BAD!
	//

	if(m_bDuringRefresh)
	{
		std::cout << "already during refresh" << std::endl;
		return; 
	}
	PTNK_MEMBARRIER_COMPILER;
	if(! PTNK_CAS(&m_bDuringRefresh, false, true))
	{
		std::cout << "already during refresh (CAS failed)" << std::endl;
		return;
	}
	PTNK_MEMBARRIER_COMPILER;

#ifdef VERBOSE_REFRESH
	std::cout << "refresh start" << std::endl << *this;
#endif
	
	void* cursor = NULL;
	do
	{
		unique_ptr<TPIOTxSession> tx(newTransaction());

		Page pgStart(tx->readPage(tx->pgidStartPage()));
		
		pgStart.refreshAllLeafPages(&cursor, threshold, pgsPerTx, tx.get());

#ifdef VERBOSE_REFRESH
		tx->dumpStat();
#endif
		if(! tryCommit(tx.get(), COMMIT_REFRESH))
		{
			std::cerr << "refresh ci failed!" << std::endl;	
		}
	}
	while(cursor);

	PTNK_MEMBARRIER_COMPILER;
	m_bDuringRefresh = false;

#ifdef VERBOSE_REFRESH
	std::cout << "refresh end" << std::endl << *this;
#endif

	rebase(/* force = */ true);
}
Example #22
0
int i2c_tx_string(unsigned char addr, char* buf, int len) {
  tx(1,0,addr << 1 | 0);
  for(int i=0;i<len-1;i++) tx(0,0,buf[i]);
  tx(0,1,buf[len-1]);
  return 0;
}
Example #23
0
CMUK_ERROR_CODE cmuk::computeStanceDK( const vec3f& body_pos,
                                       const quatf& body_rot,
                                       const vec3f& body_vel,
                                       const vec3f& body_angvel,
                                       const StanceIKMode fmode[4],
                                       const vec3f fpos[4],
                                       const vec3f fvel[4],
                                       DState* state,
                                       int errflags[4] ) const {

  if (!state) {
    return CMUK_INSUFFICIENT_ARGUMENTS;
  }

  Transform3f tx(body_rot, body_pos);

  state->body_pos = body_pos;
  state->body_rot = body_rot;
  state->body_vel = body_vel;
  state->body_angvel = body_angvel;

  mat3f j(false), jinv(false);

  CMUK_ERROR_CODE rval = CMUK_OKAY;
 
  for (int i=0; i<4; ++i) {

    errflags[i] = 0;

    if (fmode[i] == STANCE_IK_IGNORE) {
      continue;
    }

    LegIndex leg = LegIndex(i);

    vec3f pos;

    if (fmode[i] == STANCE_IK_BODY) {
      pos = fpos[i];
    } else {
      pos = tx.transformInv(fpos[i]);
    }

    vec3f q;

    CMUK_ERROR_CODE status = computePreferredFootIK(leg, pos, &q);
    state->leg_rot[i] = q;

    // couldn't exactly get there
    if (status != CMUK_OKAY) { 
      errflags[i] = (errflags[i] | STANCE_ERR_UNREACHABLE);
      // No IK -- zero out velocity and set rval
      if (rval == CMUK_OKAY || rval == CMUK_SINGULAR_MATRIX) { 
        rval = status;
      }
      quatf ignore;
      computeFootFK(leg, q, &pos, &ignore);
    }

    // relative velocity of foot in rotating body frame
    vec3f rvel;

    if (fmode[i] == STANCE_IK_BODY) {

      rvel = fvel[i];

    } else {

      // foot offset in world frame
      vec3f r = tx.transformFwd(pos) - body_pos;

      // foot velocity in world frame due to body if no joint movement
      vec3f fvel_w = body_vel + vec3f::cross(body_angvel, r);    
      
      // rel velocity in world frame
      vec3f fvel_rel_w = fvel[i] - fvel_w;
      
      // rel velocity in body frame
      // TODO: double-check whether this is fwd or inv?
      rvel = tx.rotFwd() * fvel_rel_w;

    }

    computeFootDK(leg, q, &j);
    status = computeDKInverse(j, &jinv);

    state->leg_rotvel[i] = jinv * rvel;

    // if jacobian was singular, make a note of it
    if (status != CMUK_OKAY) {
      errflags[i] = (errflags[i] | STANCE_ERR_SINGULAR);
      if (rval == CMUK_OKAY) { rval = status; }
    }

  }

  return rval;


}
Example #24
0
int main(int argc, char **argv) {
    ECCVerifyHandle globalVerifyHandle;
    std::vector<char> buffer;
    if (!read_stdin(buffer)) return 0;

    if (buffer.size() < sizeof(uint32_t)) return 0;

    uint32_t test_id = 0xffffffff;
    memcpy(&test_id, &buffer[0], sizeof(uint32_t));
    buffer.erase(buffer.begin(), buffer.begin() + sizeof(uint32_t));

    if (test_id >= TEST_ID_END) return 0;

    CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
    try {
        int nVersion;
        ds >> nVersion;
        ds.SetVersion(nVersion);
    } catch (const std::ios_base::failure &e) {
        return 0;
    }

    switch (test_id) {
        case CBLOCK_DESERIALIZE: {
            try {
                CBlock block;
                ds >> block;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CTRANSACTION_DESERIALIZE: {
            try {
                CTransaction tx(deserialize, ds);
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CBLOCKLOCATOR_DESERIALIZE: {
            try {
                CBlockLocator bl;
                ds >> bl;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CBLOCKMERKLEROOT: {
            try {
                CBlock block;
                ds >> block;
                bool mutated;
                BlockMerkleRoot(block, &mutated);
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CADDRMAN_DESERIALIZE: {
            try {
                CAddrMan am;
                ds >> am;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CBLOCKHEADER_DESERIALIZE: {
            try {
                CBlockHeader bh;
                ds >> bh;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CBANENTRY_DESERIALIZE: {
            try {
                CBanEntry be;
                ds >> be;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CTXUNDO_DESERIALIZE: {
            try {
                CTxUndo tu;
                ds >> tu;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CBLOCKUNDO_DESERIALIZE: {
            try {
                CBlockUndo bu;
                ds >> bu;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case COIN_DESERIALIZE: {
            try {
                Coin coin;
                ds >> coin;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CNETADDR_DESERIALIZE: {
            try {
                CNetAddr na;
                ds >> na;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CSERVICE_DESERIALIZE: {
            try {
                CService s;
                ds >> s;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CMESSAGEHEADER_DESERIALIZE: {
            CMessageHeader::MessageMagic pchMessageStart = {0x00, 0x00, 0x00,
                                                            0x00};
            try {
                CMessageHeader mh(pchMessageStart);
                ds >> mh;
                if (!mh.IsValidWithoutConfig(pchMessageStart)) {
                    return 0;
                }
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CADDRESS_DESERIALIZE: {
            try {
                CAddress a;
                ds >> a;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CINV_DESERIALIZE: {
            try {
                CInv i;
                ds >> i;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CBLOOMFILTER_DESERIALIZE: {
            try {
                CBloomFilter bf;
                ds >> bf;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CDISKBLOCKINDEX_DESERIALIZE: {
            try {
                CDiskBlockIndex dbi;
                ds >> dbi;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }
            break;
        }
        case CTXOUTCOMPRESSOR_DESERIALIZE: {
            CTxOut to;
            CTxOutCompressor toc(to);
            try {
                ds >> toc;
            } catch (const std::ios_base::failure &e) {
                return 0;
            }

            break;
        }
        default:
            return 0;
    }
    return 0;
}
Example #25
0
void Link::lockUser(void)
{
	connect(this, SIGNAL(error()), this, SLOT(stopSignals()));
	tx("user[" + employee->getID() + "].lock=" + QString::number(employee->getVersion()) + "\n");
}
Example #26
0
int main(int argc, char *argv[])
{
    int s1 = -1, s2 = -1, ret = -1;
    struct ifreq ifr;
    int ifindex1, ifindex2;
    struct sockaddr_ll ll;
    fd_set rfds;
    struct timeval tv;
    struct rx_result res;

    if (argc != 3) {
        fprintf(stderr, "usage: hwsim_test <ifname1> <ifname2>\n");
        return -1;
    }

    memset(bcast, 0xff, ETH_ALEN);

    s1 = socket(PF_PACKET, SOCK_RAW, htons(HWSIM_ETHERTYPE));
    if (s1 < 0) {
        perror("socket");
        goto fail;
    }

    s2 = socket(PF_PACKET, SOCK_RAW, htons(HWSIM_ETHERTYPE));
    if (s2 < 0) {
        perror("socket");
        goto fail;
    }

    memset(&ifr, 0, sizeof(ifr));
    strncpy(ifr.ifr_name, argv[1], sizeof(ifr.ifr_name));
    if (ioctl(s1, SIOCGIFINDEX, &ifr) < 0) {
        perror("ioctl[SIOCGIFINDEX]");
        goto fail;
    }
    ifindex1 = ifr.ifr_ifindex;
    if (ioctl(s1, SIOCGIFHWADDR, &ifr) < 0) {
        perror("ioctl[SIOCGIFHWADDR]");
        goto fail;
    }
    memcpy(addr1, ifr.ifr_hwaddr.sa_data, ETH_ALEN);

    memset(&ifr, 0, sizeof(ifr));
    strncpy(ifr.ifr_name, argv[2], sizeof(ifr.ifr_name));
    if (ioctl(s2, SIOCGIFINDEX, &ifr) < 0) {
        perror("ioctl[SIOCGIFINDEX]");
        goto fail;
    }
    ifindex2 = ifr.ifr_ifindex;
    if (ioctl(s2, SIOCGIFHWADDR, &ifr) < 0) {
        perror("ioctl[SIOCGIFHWADDR]");
        goto fail;
    }
    memcpy(addr2, ifr.ifr_hwaddr.sa_data, ETH_ALEN);

    memset(&ll, 0, sizeof(ll));
    ll.sll_family = PF_PACKET;
    ll.sll_ifindex = ifindex1;
    ll.sll_protocol = htons(HWSIM_ETHERTYPE);
    if (bind(s1, (struct sockaddr *) &ll, sizeof(ll)) < 0) {
        perror("bind");
        goto fail;
    }

    memset(&ll, 0, sizeof(ll));
    ll.sll_family = PF_PACKET;
    ll.sll_ifindex = ifindex2;
    ll.sll_protocol = htons(HWSIM_ETHERTYPE);
    if (bind(s2, (struct sockaddr *) &ll, sizeof(ll)) < 0) {
        perror("bind");
        goto fail;
    }

    tx(s1, argv[1], ifindex1, addr1, addr2);
    tx(s1, argv[1], ifindex1, addr1, bcast);
    tx(s2, argv[2], ifindex2, addr2, addr1);
    tx(s2, argv[2], ifindex2, addr2, bcast);

    tv.tv_sec = 1;
    tv.tv_usec = 0;

    memset(&res, 0, sizeof(res));
    for (;;) {
        int r;
        FD_ZERO(&rfds);
        FD_SET(s1, &rfds);
        FD_SET(s2, &rfds);

        r = select(s2 + 1, &rfds, NULL, NULL, &tv);
        if (r < 0) {
            perror("select");
            goto fail;
        }

        if (r == 0)
            break; /* timeout */

        if (FD_ISSET(s1, &rfds))
            rx(s1, 1, argv[1], ifindex1, &res);
        if (FD_ISSET(s2, &rfds))
            rx(s2, 2, argv[2], ifindex2, &res);

        if (res.rx_unicast1 && res.rx_broadcast1 &&
                res.rx_unicast2 && res.rx_broadcast2) {
            ret = 0;
            break;
        }
    }

    if (ret) {
        printf("Did not receive all expected frames:\n"
               "rx_unicast1=%d rx_broadcast1=%d "
               "rx_unicast2=%d rx_broadcast2=%d\n",
               res.rx_unicast1, res.rx_broadcast1,
               res.rx_unicast2, res.rx_broadcast2);
    } else {
        printf("Both unicast and broadcast working in both "
               "directions\n");
    }

fail:
    close(s1);
    close(s2);

    return ret;
}
Example #27
0
void Link::unlockUser(void)
{
	stopSignals();
	tx("user[" + employee->getID() + "].unlock\n");
}
Example #28
0
int main(int argc, char **argv)
{
	int c, option_index;

	if (argc < 2)
		print_help(argv[0], -1);

	while (1) {
		option_index = 0;

		c = getopt_long(argc, argv,
#if PCIMAXFM_ENABLE_TX_TOGGLE
				"t::"
#endif /* PCIMAXFM_ENABLE_TX_TOGGLE */
				"f::p::s::"
#if PCIMAXFM_ENABLE_RDS
#if PCIMAXFM_ENABLE_RDS_TOGGLE
				"g::"
#endif /* PCIMAXFM_ENABLE_RDS_TOGGLE */
				"r:"
#endif /* PCIMAXFM_ENABLE_RDS */
				"d::vqehH",
				long_options, &option_index);

		if (c == -1)
			break;

		switch (c) {
#if PCIMAXFM_ENABLE_TX_TOGGLE
			case 't':
				tx(optarg);
				break;
#endif /* PCIMAXFM_ENABLE_TX_TOGGLE */
			case 'f':
				freq(optarg);
				break;
			case 'p':
				power(optarg);
				break;
			case 's':
				stereo(optarg);
				break;
#if PCIMAXFM_ENABLE_RDS
#if PCIMAXFM_ENABLE_RDS_TOGGLE
			case 'g':
				rds_signal(optarg);
				break;
#endif /* PCIMAXFM_ENABLE_RDS_TOGGLE */
			case 'r':
				rds(optarg);
				break;
#endif /* PCIMAXFM_ENABLE_RDS */
			case 'd':
				device(optarg);
				break;
			case 'v':
				verbosity = 1;
				DEBUG_MSG("Verbose output.");
				break;
			case 'q':
				verbosity = -1;
				break;
			case 'e':
				print_version(argv[0]);
			case 'h':
				print_help(argv[0], 0);
#if PCIMAXFM_ENABLE_RDS
			case 'H':
				print_help_rds(0);
#endif /* PCIMAXFM_ENABLE_RDS */
			default:
				exit(1);
		}
	}

	dev_close();

	return 0;
}
Example #29
0
void FORTE_FB_FT_TN64::alg_checkTime(void){
tx() = TIME();
}
Example #30
0
File: t6.c Project: Earnestly/plan9
void
maktab(void)			/* define the tab stops of the table */
{
	int	icol, ilin, tsep, k, ik, vforml, il, s, text;
	char	*ss;

	for (icol = 0; icol < ncol; icol++) {
		doubled[icol] = acase[icol] = 0;
		Bprint(&tabout, ".nr %2s 0\n", reg(icol, CRIGHT));
		for (text = 0; text < 2; text++) {
			if (text)
				Bprint(&tabout, ".%2s\n.rm %2s\n", reg(icol, CRIGHT),
				    reg(icol, CRIGHT));
			for (ilin = 0; ilin < nlin; ilin++) {
				if (instead[ilin] || fullbot[ilin]) 
					continue;
				vforml = ilin;
				for (il = prev(ilin); il >= 0 && vspen(table[il][icol].col); il = prev(il))
					vforml = il;
				if (fspan(vforml, icol)) 
					continue;
				if (filler(table[ilin][icol].col)) 
					continue;
				if ((flags[icol][stynum[ilin]] & ZEROW) != 0) 
					continue;
				switch (ctype(vforml, icol)) {
				case 'a':
					acase[icol] = 1;
					ss = table[ilin][icol].col;
					s = (int)(uintptr)ss;
					if (s > 0 && s < 128 && text) {
						if (doubled[icol] == 0)
							Bprint(&tabout, ".nr %d 0\n.nr %d 0\n",
							    S1, S2);
						doubled[icol] = 1;
						Bprint(&tabout, ".if \\n(%c->\\n(%d .nr %d \\n(%c-\n",
						    s, S2, S2, (int)s);
					}
				case 'n':
					if (table[ilin][icol].rcol != 0) {
						if (doubled[icol] == 0 && text == 0)
							Bprint(&tabout, ".nr %d 0\n.nr %d 0\n",
							    S1, S2);
						doubled[icol] = 1;
						if (real(ss = table[ilin][icol].col) && !vspen(ss)) {
							s = (int)(uintptr)ss;
							if (tx(s) != text) 
								continue;
							Bprint(&tabout, ".nr %d ", TMP);
							wide(ss, FN(vforml, icol), SZ(vforml, icol)); 
							Bprint(&tabout, "\n");
							Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n",
							    S1, TMP, S1, TMP);
						}
						if (text == 0 && real(ss = table[ilin][icol].rcol) && !vspen(ss) && !barent(ss)) {
							Bprint(&tabout, ".nr %d \\w%c%s%c\n",
							    TMP, F1, ss, F1);
							Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S2, TMP, S2,
							     TMP);
						}
						continue;
					}
				case 'r':
				case 'c':
				case 'l':
					if (real(ss = table[ilin][icol].col) && !vspen(ss)) {
						s = (int)(uintptr)ss;
						if (tx(s) != text) 
							continue;
						Bprint(&tabout, ".nr %d ", TMP);
						wide(ss, FN(vforml, icol), SZ(vforml, icol)); 
						Bprint(&tabout, "\n");
						Bprint(&tabout, ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n",
						     reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP);
					}
				}
			}
		}
		if (acase[icol]) {
			Bprint(&tabout, ".if \\n(%d>=\\n(%2s .nr %2s \\n(%du+2n\n", 
			     S2, reg(icol, CRIGHT), reg(icol, CRIGHT), S2);
		}
		if (doubled[icol]) {
			Bprint(&tabout, ".nr %2s \\n(%d\n", reg(icol, CMID), S1);
			Bprint(&tabout, ".nr %d \\n(%2s+\\n(%d\n", TMP, reg(icol, CMID), S2);
			Bprint(&tabout, ".if \\n(%d>\\n(%2s .nr %2s \\n(%d\n", TMP,
			    reg(icol, CRIGHT), reg(icol, CRIGHT), TMP);
			Bprint(&tabout, ".if \\n(%d<\\n(%2s .nr %2s +(\\n(%2s-\\n(%d)/2\n",
			     TMP, reg(icol, CRIGHT), reg(icol, CMID), reg(icol, CRIGHT), TMP);
		}
		if (cll[icol][0]) {
			Bprint(&tabout, ".nr %d %sn\n", TMP, cll[icol]);
			Bprint(&tabout, ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n",
			    reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP);
		}
		for (ilin = 0; ilin < nlin; ilin++)
			if (k = lspan(ilin, icol)) {
				ss = table[ilin][icol-k].col;
				if (!real(ss) || barent(ss) || vspen(ss) ) 
					continue;
				Bprint(&tabout, ".nr %d ", TMP);
				wide(table[ilin][icol-k].col, FN(ilin, icol - k), SZ(ilin, icol - k));
				for (ik = k; ik >= 0; ik--) {
					Bprint(&tabout, "-\\n(%2s", reg(icol - ik, CRIGHT));
					if (!expflg && ik > 0) 
						Bprint(&tabout, "-%dn", sep[icol-ik]);
				}
				Bprint(&tabout, "\n");
				Bprint(&tabout, ".if \\n(%d>0 .nr %d \\n(%d/%d\n", TMP,
				      TMP, TMP, k);
				Bprint(&tabout, ".if \\n(%d<0 .nr %d 0\n", TMP, TMP);
				for (ik = 1; ik <= k; ik++) {
					if (doubled[icol-k+ik])
						Bprint(&tabout, ".nr %2s +\\n(%d/2\n",
						     reg(icol - k + ik, CMID), TMP);
					Bprint(&tabout, ".nr %2s +\\n(%d\n",
					     reg(icol - k + ik, CRIGHT), TMP);
				}
			}
	}
	if (textflg) 
		untext();
				/* if even requested, make all columns widest width */
	if (evenflg) {
		Bprint(&tabout, ".nr %d 0\n", TMP);
		for (icol = 0; icol < ncol; icol++) {
			if (evenup[icol] == 0) 
				continue;
			Bprint(&tabout, ".if \\n(%2s>\\n(%d .nr %d \\n(%2s\n",
			    reg(icol, CRIGHT), TMP, TMP, reg(icol, CRIGHT));
		}
		for (icol = 0; icol < ncol; icol++) {
			if (evenup[icol] == 0)
				/* if column not evened just retain old interval */
				continue;
			if (doubled[icol])
				Bprint(&tabout, ".nr %2s (100*\\n(%2s/\\n(%2s)*\\n(%d/100\n",
				    reg(icol, CMID), reg(icol, CMID), reg(icol, CRIGHT), TMP);
			/* that nonsense with the 100's and parens tries
				   to avoid overflow while proportionally shifting
				   the middle of the number */
			Bprint(&tabout, ".nr %2s \\n(%d\n", reg(icol, CRIGHT), TMP);
		}
	}
				/* now adjust for total table width */
	for (tsep = icol = 0; icol < ncol; icol++)
		tsep += sep[icol];
	if (expflg) {
		Bprint(&tabout, ".nr %d 0", TMP);
		for (icol = 0; icol < ncol; icol++)
			Bprint(&tabout, "+\\n(%2s", reg(icol, CRIGHT));
		Bprint(&tabout, "\n");
		Bprint(&tabout, ".nr %d \\n(.l-\\n(%d\n", TMP, TMP);
		if (boxflg || dboxflg || allflg)
			/* tsep += 1; */ {}
		else
			tsep -= sep[ncol-1];
		Bprint(&tabout, ".nr %d \\n(%d/%d\n", TMP, TMP,  tsep);
		Bprint(&tabout, ".if \\n(%d<0 .nr %d 0\n", TMP, TMP);
	} else
		Bprint(&tabout, ".nr %d 1n\n", TMP);
	Bprint(&tabout, ".nr %2s 0\n", reg(-1, CRIGHT));
	tsep = (boxflg || allflg || dboxflg || left1flg) ? 2 : 0;
	if (sep[-1] >= 0) 
		tsep = sep[-1];
	for (icol = 0; icol < ncol; icol++) {
		Bprint(&tabout, ".nr %2s \\n(%2s+((%d*\\n(%d)/2)\n", reg(icol, CLEFT),
		    reg(icol - 1, CRIGHT), tsep, TMP);
		Bprint(&tabout, ".nr %2s +\\n(%2s\n", reg(icol, CRIGHT), reg(icol, CLEFT));
		if (doubled[icol]) {
			/* the next line is last-ditch effort to avoid zero field width */
			/*Bprint(&tabout, ".if \\n(%2s=0 .nr %2s 1\n",reg(icol,CMID), reg(icol,CMID));*/
			Bprint(&tabout, ".nr %2s +\\n(%2s\n", reg(icol, CMID),
			    reg(icol, CLEFT));
			/*  Bprint(&tabout, ".if n .if \\n(%s%%24>0 .nr %s +12u\n",reg(icol,CMID), reg(icol,CMID)); */
		}
		tsep = sep[icol] * 2;
	}
	if (rightl)
		Bprint(&tabout, ".nr %s (\\n(%s+\\n(%s)/2\n", reg(ncol - 1, CRIGHT),
		      reg(ncol - 1, CLEFT), reg(ncol - 2, CRIGHT));
	Bprint(&tabout, ".nr TW \\n(%2s\n", reg(ncol - 1, CRIGHT));
	tsep = sep[ncol-1];
	if (boxflg || allflg || dboxflg)
		Bprint(&tabout, ".nr TW +((%d*\\n(%d)/2)\n", tsep, TMP);
	Bprint(&tabout,
	    ".if t .if (\\n(TW>\\n(.l .tm Table at line %d file %s is too wide - \\n(TW units\n", iline - 1, ifile);
/*
 * Used to be:
 	    ".if t .if (\\n(TW+\\n(.o)>7.65i .tm Table at line %d file %s is too wide - \\n(TW units\n", iline - 1, ifile);
 * but that gives warnings where none are necessary (or desired) [sape]
 */
}