Ejemplo n.º 1
0
qPBReader::qPBReader(int & argc, char ** argv) :
   QApplication(argc, argv),
   _bGlobalConfMode(false),
   _pViewer(0),
   _pConfigDialog(0)
{
   TRSCOPE(app, "qPBReader::qPBReader");

   if (TRACEON)
   {
      TRACE << "Current dir " << ENC(QDir::currentPath()) << endl;
      TRACE << "argc=" << argc << endl;

      for (int idx = 0; idx < argc; idx++)
      {
         TRACE << idx << ": " << ENC(argv[idx]) << endl;
      }
   }

   QString sLangFile = QCoreApplication::applicationFilePath() +
                       "_" +
                       qPBReaderConfig::GetApplicationLanguage();
   TRACE << VAR(sLangFile) << endl;
   _translator.load(sLangFile);
   installTranslator(&_translator);
}
Ejemplo n.º 2
0
static int dss_openssh_fmtkey(void *key, unsigned char *blob, int len)
{
    struct dss_key *dss = (struct dss_key *) key;
    int bloblen, i;

    bloblen =
	ssh2_bignum_length(dss->p) +
	ssh2_bignum_length(dss->q) +
	ssh2_bignum_length(dss->g) +
	ssh2_bignum_length(dss->y) +
	ssh2_bignum_length(dss->x);

    if (bloblen > len)
	return bloblen;

    bloblen = 0;
#define ENC(x) \
    PUT_32BIT(blob+bloblen, ssh2_bignum_length((x))-4); bloblen += 4; \
    for (i = ssh2_bignum_length((x))-4; i-- ;) blob[bloblen++]=bignum_byte((x),i);
    ENC(dss->p);
    ENC(dss->q);
    ENC(dss->g);
    ENC(dss->y);
    ENC(dss->x);

    return bloblen;
}
Ejemplo n.º 3
0
static void test_destructor(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **argv
){
  char *zVal;
  int len;
  sqlite3 *db = sqlite3_user_data(pCtx);
 
  test_destructor_count_var++;
  assert( nArg==1 );
  if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
  len = sqlite3ValueBytes(argv[0], ENC(db)); 
  zVal = sqliteMalloc(len+3);
  zVal[len] = 0;
  zVal[len-1] = 0;
  assert( zVal );
  zVal++;
  memcpy(zVal, sqlite3ValueText(argv[0], ENC(db)), len);
  if( ENC(db)==SQLITE_UTF8 ){
    sqlite3_result_text(pCtx, zVal, -1, destructor);
#ifndef SQLITE_OMIT_UTF16
  }else if( ENC(db)==SQLITE_UTF16LE ){
    sqlite3_result_text16le(pCtx, zVal, -1, destructor);
  }else{
    sqlite3_result_text16be(pCtx, zVal, -1, destructor);
#endif /* SQLITE_OMIT_UTF16 */
  }
}
Ejemplo n.º 4
0
/*
** This function is responsible for invoking the collation factory callback
** or substituting a collation sequence of a different encoding when the
** requested collation sequence is not available in the database native
** encoding.
** 
** If it is not NULL, then pColl must point to the database native encoding 
** collation sequence with name zName, length nName.
**
** The return value is either the collation sequence to be used in database
** db for collation type name zName, length nName, or NULL, if no collation
** sequence can be found.
*/
CollSeq *sqlite3GetCollSeq(
  sqlite3* db, 
  CollSeq *pColl, 
  const char *zName, 
  int nName
){
  CollSeq *p;

  p = pColl;
  if( !p ){
    p = sqlite3FindCollSeq(db, ENC(db), zName, nName, 0);
  }
  if( !p || !p->xCmp ){
    /* No collation sequence of this type for this encoding is registered.
    ** Call the collation factory to see if it can supply us with one.
    */
    callCollNeeded(db, zName, nName);
    p = sqlite3FindCollSeq(db, ENC(db), zName, nName, 0);
  }
  if( p && !p->xCmp && synthCollSeq(db, p) ){
    p = 0;
  }
  assert( !p || p->xCmp );
  return p;
}
Ejemplo n.º 5
0
/*
 ** This function is used to allocate and populate UnpackedRecord
 ** structures intended to be compared against sample index keys stored
 ** in the sqlite_stat4 table.
 **
 ** A single call to this function attempts to populates field iVal (leftmost
 ** is 0 etc.) of the unpacked record with a value extracted from expression
 ** pExpr. Extraction of values is possible if:
 **
 **  * (pExpr==0). In this case the value is assumed to be an SQL NULL,
 **
 **  * The expression is a bound variable, and this is a reprepare, or
 **
 **  * The sqlite3ValueFromExpr() function is able to extract a value
 **    from the expression (i.e. the expression is a literal value).
 **
 ** If a value can be extracted, the affinity passed as the 5th argument
 ** is applied to it before it is copied into the UnpackedRecord. Output
 ** parameter *pbOk is set to true if a value is extracted, or false 
 ** otherwise.
 **
 ** When this function is called, *ppRec must either point to an object
 ** allocated by an earlier call to this function, or must be NULL. If it
 ** is NULL and a value can be successfully extracted, a new UnpackedRecord
 ** is allocated (and *ppRec set to point to it) before returning.
 **
 ** Unless an error is encountered, SQLITE_OK is returned. It is not an
 ** error if a value cannot be extracted from pExpr. If an error does
 ** occur, an SQLite error code is returned.
 */
SQLITE_PRIVATE int sqlite3Stat4ProbeSetValue(
                                             Parse *pParse,                  /* Parse context */
                                             Index *pIdx,                    /* Index being probed */
                                             UnpackedRecord **ppRec,         /* IN/OUT: Probe record */
                                             Expr *pExpr,                    /* The expression to extract a value from */
                                             u8 affinity,                    /* Affinity to use */
                                             int iVal,                       /* Array element to populate */
                                             int *pbOk                       /* OUT: True if value was extracted */
){
    int rc = SQLITE_OK;
    sqlite3_value *pVal = 0;
    sqlite3 *db = pParse->db;
    
    
    struct ValueNewStat4Ctx alloc;
    alloc.pParse = pParse;
    alloc.pIdx = pIdx;
    alloc.ppRec = ppRec;
    alloc.iVal = iVal;
    
    /* Skip over any TK_COLLATE nodes */
    pExpr = sqlite3ExprSkipCollate(pExpr);
    
    if( !pExpr ){
        pVal = valueNew(db, &alloc);
        if( pVal ){
            sqlite3VdbeMemSetNull((Mem*)pVal);
            *pbOk = 1;
        }
    }else if( pExpr->op==TK_VARIABLE
             || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
             ){
        Vdbe *v;
        int iBindVar = pExpr->iColumn;
        sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);
        if( (v = pParse->pReprepare)!=0 ){
            pVal = valueNew(db, &alloc);
            if( pVal ){
                rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
                if( rc==SQLITE_OK ){
                    sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
                }
                pVal->db = pParse->db;
                *pbOk = 1;
                sqlite3VdbeMemStoreType((Mem*)pVal);
            }
        }else{
            *pbOk = 0;
        }
    }else{
        rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, &alloc);
        *pbOk = (pVal!=0);
    }
    
    assert( pVal==0 || pVal->db==db );
    return rc;
}
Ejemplo n.º 6
0
/*
** Bind a text or BLOB value.
*/
static int bindText(
  sqlite3_stmt *pStmt, 
  int i, 
  const void *zData, 
  int nData, 
  void (*xDel)(void*),
  int encoding
){
  Vdbe *p = (Vdbe *)pStmt;
  Mem *pVar;
  int rc;

  rc = vdbeUnbind(p, i);
  if( rc || zData==0 ){
    return rc;
  }
  pVar = &p->aVar[i-1];
  rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);
  if( rc==SQLITE_OK && encoding!=0 ){
    rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));
  }

  sqlite3Error(((Vdbe *)pStmt)->db, rc, 0);
  return sqlite3ApiExit(((Vdbe *)pStmt)->db, rc);
}
Ejemplo n.º 7
0
void qPBReaderPlatform::ReaderApplicationStarted(const QString & isBookFile)
{
   TRSCOPE(pb, "qPBReaderPlatform::ReaderApplicationStarted");
#ifdef Q_OS_POCKETBOOK

   TRACE << "Declaring " << ENC(isBookFile) << endl;

   // set application icon
   // taskmgr looks for app_%s_icon.bmp file in theme, %s being the
   // task name. Since I have not found another way to provide an icon at
   // runtime, setting task name to "reader" does the job.

   int task = ::GetCurrentTask();
   taskinfo * pTask = ::GetTaskInfo(GetCurrentTask());

   if (pTask)
   {
      int rc = ::SetTaskParameters(task, "reader", 0, 0, pTask->flags);
      TRACE << "SetTaskParameters " << VAR(rc) << endl;
   }

   // switch to reading mode, seems to change panel appearance

   SetReadingMode(true);

   // and register book as read by this program

   ::BookReady(isBookFile.toUtf8().data());
#else

   Q_UNUSED(isBookFile);
#endif
}
Ejemplo n.º 8
0
int qPBReaderDictionaryDialog::InternalDicProcHandler(int type, int par1,
      int par2)
{
   TRSCOPE(dic, "qPBReaderDictionaryDialog::InternalDicProcHandler");

   int rc = 0;

#ifdef Q_OS_POCKETBOOK
   assert(_pDicInternalProc != 0);

   TRACE << type << " " << ENC(iv_evttype(type)) << " " << par1 << " " << par2 <<
         endl;

   TRACE << "thread id=" << (int)syscall(SYS_gettid) << endl;

   rc = _pDicInternalProc(type, par1, par2);
   TRACE << "_pDicInternalProc rc=" << rc << endl;

   if (!rc && !Instance()._bReenter && !ISKEYEVENT(type))
   {
      assert(_pOrgProc != 0);
      TRACE << "Calling _pOrgProc" << endl;
      rc = _pOrgProc(type, par1, par2);
   }

#else
   Q_UNUSED(type);
   Q_UNUSED(par1);
   Q_UNUSED(par2);

#endif
   return rc;
}
Ejemplo n.º 9
0
/*
** Bind a text or BLOB value.
*/
static int bindText(
  sqlite3_stmt *pStmt,   /* The statement to bind against */
  int i,                 /* Index of the parameter to bind */
  const void *zData,     /* Pointer to the data to be bound */
  int nData,             /* Number of bytes of data to be bound */
  void (*xDel)(void*),   /* Destructor for the data */
  u8 encoding            /* Encoding for the data */
){
  Vdbe *p = (Vdbe *)pStmt;
  Mem *pVar;
  int rc;

  rc = vdbeUnbind(p, i);
  if( rc==SQLITE_OK ){
    if( zData!=0 ){
      pVar = &p->aVar[i-1];
      rc = sqlite3VdbeMemSetStr(pVar, zData, nData, encoding, xDel);
      if( rc==SQLITE_OK && encoding!=0 ){
        rc = sqlite3VdbeChangeEncoding(pVar, ENC(p->db));
      }
      sqlite3Error(p->db, rc);
      rc = sqlite3ApiExit(p->db, rc);
    }
    sqlite3_mutex_leave(p->db->mutex);
  }else if( xDel!=SQLITE_STATIC && xDel!=SQLITE_TRANSIENT ){
    xDel((void*)zData);
  }
  return rc;
}
Ejemplo n.º 10
0
qPBReaderJSLoader::qPBReaderJSLoader(QWebPage * p) :
   _p(p)
{
   TRSCOPE(js, "qPBReaderJSLoader::qPBReaderJSLoader");

   // hard-coded module list, keep in synch with aliases in qrc file

   _lNames.append("jquery");
   _lNames.append("jquery_scrollTo");
   _lNames.append("bookmarks");
   _lNames.append("referencing");
   _lNames.append("images");
   _lNames.append("hyphenation");
   _lNames.append("Hyphenator");
   _lNames.append("utils");
   _lNames.append("cfi");
   _lNames.append("indexing");
   _lNames.append("paged");
   _lNames.append("full_screen");
   _lNames.append("mathjax");
   _lNames.append("extract");
   _lNames.append("qPBReader");

   // load resource

   for (int idx = 0; idx < _lNames.size(); idx++)
   {
      QByteArray ba;
      LoadResource(_lNames[idx], ba);
      _lSrc.append(QString::fromUtf8(ba.data(), ba.size()));
      TRACE << "Loaded " << ENC(_lNames[idx]) << ", length=" << _lSrc[idx].size() <<
            endl;
   }

}
Ejemplo n.º 11
0
/*
 * Determine for a character is display string and columns width
 */
static void rl_analyze_ucs (wint_tt ucs, const char **display, UWORD *columns)
{
   char *utf = NULL;
#if HAVE_WCWIDTH
   int width;
#endif
  
   utf = strdup (ConvUTF8 (ucs));
   *display = ConvTo (utf, ENC(enc_loc))->txt;

    if (ucs < 32 || ucs == 127 || ucs == 173) /* control code */
    {
        *display = s_sprintf ("%s^%c%s", COLINVCHAR, (char)((ucs - 1 + 'A') & 0x7f), COLNONE);
        *columns = 2;
    }
    else if (ucs < 127)
        *columns = 1;
#if HAVE_WCWIDTH
    else if (!prG->locale_broken && (width = rl_wcwidth (ucs, *display)) != -1)
        *columns = 256 | width;
#else
    else if (ucs >= 160) /* no way I'll hard-code double-width or combining marks here */
        *columns = 257;
#endif
    else if (prG->locale_broken && !strcmp (ConvFrom (ConvTo (utf, ENC(enc_loc)), ENC(enc_loc))->txt, utf))
        *columns = 257;
    else if (!(ucs & 0xffff0000)) /* more control code, or unknown */
    {
        *display = s_sprintf ("%s\\u%c%c%c%c%s", COLINVCHAR,
           rl_hex (ucs / 4096), rl_hex (ucs /  256),
           rl_hex (ucs /   16), rl_hex (ucs),
           COLNONE);
        *columns = 6;
    }
    else /* unknown stellar planes */
    {
        *display = s_sprintf ("%s\\U%c%c%c%c%c%c%c%c%s", COLINVCHAR,
           rl_hex (ucs / 268435456), rl_hex (ucs /  16777216),
           rl_hex (ucs /   1048576), rl_hex (ucs /     65536),
           rl_hex (ucs /      4096), rl_hex (ucs /       256),
           rl_hex (ucs /        16), rl_hex (ucs),
           COLNONE);
        *columns = 10;
    }
    free (utf);
}
Ejemplo n.º 12
0
void lightmac(void *data, u32 len, void *tag, void *key) {
    int  i;
    u8   m[BLK_LEN], v[TAG_LEN]; 
    u8   *t=(u8*)tag, *k=(u8*)key, *p=(u8*)data;
    
    union {
      u8  b[8];
      u64 q;
    } s;
    
    // 1. zero initialize V
    for(i=0;i<TAG_LEN;i++) v[i] = 0;

    // 2. set protected counter sum to 1
    s.q = 1;
    
    // 3. while we have blocks of data equal to (n - s)
    while (len >= MSG_LEN) {
      // 4. add counter s to M in big endian byte order
      for(i=0;i<CTR_LEN;i++) {
        m[CTR_LEN-i-1] = s.b[i];
      }
      // 5. add data to M
      for(i=0;i<MSG_LEN;i++) {
        m[CTR_LEN+i] = p[i];
      }
      // 6. encrypt M with K1
      ENC(k, m);
      // 7. update V
      for(i=0;i<TAG_LEN;i++) v[i] ^= m[i];
      // 8. decrease length and advance data pointer
      len -= MSG_LEN;
      p += MSG_LEN;
      // 9. update counter
      s.q++;
    }
    // 10. absorb any data less than (n - s)
    for(i=0;i<len;i++) v[i] ^= p[i];
    // 11. add end bit
    v[i] ^= 0x80;
    // 12. encrypt V with K2
    k += BC_KEY_LEN;
    ENC(k, v);
    // 13. return V in T
    for(i=0;i<TAG_LEN;i++) t[i] = v[i];
}
Ejemplo n.º 13
0
void qPBReaderJSLoader::Load(const QString & isHyphenLang)
{
   TRSCOPE(js, "qPBReaderJSLoader::Load");

   if (_p)
   {
      for (int idx = 0; idx < _lNames.size(); idx++)
      {
         TRACE << "injecting " << ENC(_lNames[idx]) <<  " (" << _lSrc[idx].length() <<
               ")" << endl;
         _p->mainFrame()->evaluateJavaScript(_lSrc[idx]);
      }

      // if hyphenation is required

      if (!isHyphenLang.isEmpty())
      {
         // if pattern lang has changed

         if (isHyphenLang != _sLang)
         {
            // load it from resources

            TRACE << "Loading pattern script" << ENC(isHyphenLang) << endl;
            QByteArray ba;
            LoadResource("patterns/" + isHyphenLang, ba);

            // store lang and corresponding script

            _sLang = isHyphenLang;
            _sPattern = QString::fromUtf8(ba.data(), ba.size());

            TRACE << "Loaded " << ENC(isHyphenLang) << ", length=" << _sLang.size() << endl;
         }
         else
         {
            TRACE << "Pattern script" << ENC(_sLang) << "already loaded" << endl;
         }

         // and load it into page

         TRACE << "injecting hyphens pattern script" << endl;
         _p->mainFrame()->evaluateJavaScript(_sPattern);
      }
   }
}
Ejemplo n.º 14
0
void qPBReaderPlatform::MessageTimeOut(const QString & isTitle,
                                       const QString & isMessage,
                                       int inTimeoutMs)
{
   TRSCOPE(pb, "qPBReaderPlatform::MessageTimeOut");
#ifdef Q_OS_POCKETBOOK

   TRACE << "Message " << ENC(isTitle) << " " << ENC(isMessage) << VAR(inTimeoutMs) << endl;
   ::Message(ICON_INFORMATION,
             isTitle.toUtf8().data(),
             isMessage.toUtf8().data(),
             inTimeoutMs);
#else
   Q_UNUSED(isTitle);
   Q_UNUSED(isMessage);
   Q_UNUSED(inTimeoutMs);
#endif
}
Ejemplo n.º 15
0
bool qPBReaderEpub::Open()
{
   TRSCOPE(epub, "qPBReaderEpub::Open");

   Clean();

   // compute MD5 to get config file and temporary directory

   _sMD5 = qPBReaderUtils::MD5(_sFile);

   bool bOk = !_sMD5.isEmpty();

   if (bOk)
   {
      _sTempDir = qPBReaderConfig::GetTempDir() + "/" + _sMD5;
      TRACE << "temp dir " << ENC(_sTempDir) << endl;

      bOk = InitSettings(qPBReaderConfig::GetDataDir() + "/" + _sMD5 + ".cfg");
   }

   // extract epub file

   if (bOk && qgetenv("qPBReaderDisableEpubExtraction").isEmpty())
   {
      bOk = qPBReaderUnzip::ExtractAllTo(_sFile, _sTempDir);
   }

   // analyze epub. Won't be completely performed if settings are present.

   if (bOk)
   {
      bOk = AnalyzeDocStructure();
   }

   // keep the input file name in config, useful when data
   // will be checked for entries to removed
   // will avoid deleting file if epub has been moved and reopened
   // since first open

   if (bOk)
   {
      QFile f(_sFile);
      _pSettings->SaveEpubFileName(QFileInfo(f).absoluteFilePath());
   }

   // don't stay partially initialized in case of error

   if (!bOk)
   {
      Clean();
   }

   TRACE << TRANAME << " " << VAR(bOk) << endl;

   return bOk;
}
Ejemplo n.º 16
0
/*
 * Sets the prompt
 */
void ReadLinePromptSet (const char *prompt)
{
    rl_prompt_time = time (NULL);
    s_init (&rl_prompt, COLSERVER, 0);
    s_cat  (&rl_prompt, ConvTo (prompt, ENC(enc_loc))->txt);
    s_cat  (&rl_prompt, COLNONE);
    s_catc (&rl_prompt, ' ');
    if (rl_prompt_stat != 0)
        rl_prompt_stat = 2;
}
Ejemplo n.º 17
0
__declspec(dllexport) int WINAPI sqlite3_open16_interop(const char *filename, int flags, sqlite3 **ppdb)
{
  int ret = sqlite3_open_interop(filename, flags, ppdb);
  if (!ret)
  {
    if(!DbHasProperty(*ppdb, 0, DB_SchemaLoaded))
      ENC(*ppdb) = SQLITE_UTF16NATIVE;
  }
  return ret;
}
DCL_STATUS PMIC6326_ccci_control_handler(DCL_HANDLE handle,DCL_CTRL_CMD cmd,DCL_CTRL_DATA_T *data)
{
	DCL_UINT16	regVal;
	DCL_UINT32	val;

	switch(cmd)
	{
		case LDO_BUCK_SET_EN:
		{
			PMU_CTRL_LDO_BUCK_SET_EN *pLdoBuckCtrl=&(data->rPMULdoBuckSetEn);
			switch(pLdoBuckCtrl->mod)
			{
				case VSIM:
				{
					dcl_pmic6326_ccci_vsim_enable((kal_bool)pLdoBuckCtrl->enable);
				}
				break;	
				case VSIM2:
				{
					dcl_pmic6326_ccci_vsim2_enable((kal_bool)pLdoBuckCtrl->enable);
				}
				break;					
				default:				
				return STATUS_UNSUPPORTED;
				break;					
			}			
		}
		break;	
		case LDO_BUCK_SET_VOLTAGE_EN:
		{
			PMU_CTRL_LDO_BUCK_SET_VOLTAGE_EN *pLdoBuckCtrl=&(data->rPMULdoBuckSetVoltageEn);
			regVal=PMU_Parameter_to_Value(ENC(cmd,pLdoBuckCtrl->mod),pLdoBuckCtrl->voltage);
			switch(pLdoBuckCtrl->mod)
			{
				case VSIM:
				{
					dcl_pmic6326_ccci_vsim_sel_and_enable(regVal);
				}
				break;	
				case VSIM2:
				{
					dcl_pmic6326_ccci_vsim2_sel_and_enable(regVal);
				}
				break;					
				default:				
				return STATUS_UNSUPPORTED;
				break;					
			}				
		}
		break;
		default:				
		return STATUS_UNSUPPORTED;
		break;
	}
}
Ejemplo n.º 19
0
void qPBReaderDocView::UseHyphensChanged(const QString & isHyphenPatternLang)
{
   TRSCOPE(view, "qPBReaderDocView::UseHyphensChanged");


   TRACE << ENC(isHyphenPatternLang) << endl;

   _pDoc->SetHyphenPatternLang(isHyphenPatternLang);

   _pMgr->HyphenLangChanged(isHyphenPatternLang);
}
Ejemplo n.º 20
0
Archivo: callback.c Proyecto: cznic/cc
/*
** This routine is called on a collation sequence before it is used to
** check that it is defined. An undefined collation sequence exists when
** a database is loaded that contains references to collation sequences
** that have not been defined by sqlite3_create_collation() etc.
**
** If required, this routine calls the 'collation needed' callback to
** request a definition of the collating sequence. If this doesn't work, 
** an equivalent collating sequence that uses a text encoding different
** from the main database is substituted, if one is available.
*/
int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){
  if( pColl && pColl->xCmp==0 ){
    const char *zName = pColl->zName;
    sqlite3 *db = pParse->db;
    CollSeq *p = sqlite3GetCollSeq(pParse, ENC(db), pColl, zName);
    if( !p ){
      return SQLITE_ERROR;
    }
    assert( p==pColl );
  }
  return SQLITE_OK;
}
Ejemplo n.º 21
0
/*
** Invoke the 'collation needed' callback to request a collation sequence
** in the database text encoding of name zName, length nName.
** If the collation sequence
*/
static void callCollNeeded(sqlite3 *db, const char *zName){
  assert( !db->xCollNeeded || !db->xCollNeeded16 );
  if( db->xCollNeeded ){
    char *zExternal = sqlite3DbStrDup(db, zName);
    if( !zExternal ) return;
    db->xCollNeeded(db->pCollNeededArg, db, (int)ENC(db), zExternal);
    sqlite3DbFree(db, zExternal);
  }
#ifndef SQLITE_OMIT_UTF16
  if( db->xCollNeeded16 ){
    char const *zExternal;
    sqlite3_value *pTmp = sqlite3ValueNew(db);
    sqlite3ValueSetStr(pTmp, -1, zName, SQLITE_UTF8, SQLITE_STATIC);
    zExternal = sqlite3ValueText(pTmp, SQLITE_UTF16NATIVE);
    if( zExternal ){
      db->xCollNeeded16(db->pCollNeededArg, db, (int)ENC(db), zExternal);
    }
    sqlite3ValueFree(pTmp);
  }
#endif
}
Ejemplo n.º 22
0
static int rsa2_openssh_fmtkey(void *key, unsigned char *blob, int len)
{
    struct RSAKey *rsa = (struct RSAKey *) key;
    int bloblen, i;

    bloblen =
	ssh2_bignum_length(rsa->modulus) +
	ssh2_bignum_length(rsa->exponent) +
	ssh2_bignum_length(rsa->private_exponent) +
	ssh2_bignum_length(rsa->iqmp) +
	ssh2_bignum_length(rsa->p) + ssh2_bignum_length(rsa->q);

    if (bloblen > len)
	return bloblen;

    bloblen = 0;
#define ENC(x) \
    PUT_32BIT(blob+bloblen, ssh2_bignum_length((x))-4); bloblen += 4; \
    for (i = ssh2_bignum_length((x))-4; i-- ;) blob[bloblen++]=bignum_byte((x),i);
    ENC(rsa->modulus);
    ENC(rsa->exponent);
    ENC(rsa->private_exponent);
    ENC(rsa->iqmp);
    ENC(rsa->p);
    ENC(rsa->q);

    return bloblen;
}
Ejemplo n.º 23
0
void qPBReaderPlatform::DisplayPanelMessage(const QString & isMessage)
{
   TRSCOPE(pb, "qPBReaderPlatform::DisplayPanelMessage");
#ifdef Q_OS_POCKETBOOK

   TRACE << "Panel " << ENC(isMessage) << endl;
   ::DrawPanel2(0, isMessage.toUtf8().data(), "qPBReader", -1, 1);
   UpdatePanelDisplay();
#else

   Q_UNUSED(isMessage);
#endif
}
Ejemplo n.º 24
0
/*
** The most recently coded instruction was an OP_Column to retrieve the
** i-th column of table pTab. This routine sets the P3 parameter of the 
** OP_Column to the default value, if any.
**
** The default value of a column is specified by a DEFAULT clause in the 
** column definition. This was either supplied by the user when the table
** was created, or added later to the table definition by an ALTER TABLE
** command. If the latter, then the row-records in the table btree on disk
** may not contain a value for the column and the default value, taken
** from the P3 parameter of the OP_Column instruction, is returned instead.
** If the former, then all row-records are guaranteed to include a value
** for the column and the P3 value is not required.
**
** Column definitions created by an ALTER TABLE command may only have 
** literal default values specified: a number, null or a string. (If a more
** complicated default expression value was provided, it is evaluated 
** when the ALTER TABLE is executed and one of the literal values written
** into the sqlite_master table.)
**
** Therefore, the P3 parameter is only required if the default value for
** the column is a literal number, string or null. The sqlite3ValueFromExpr()
** function is capable of transforming these types of expressions into
** sqlite3_value objects.
*/
void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i){
  if( pTab && !pTab->pSelect ){
    sqlite3_value *pValue;
    u8 enc = ENC(sqlite3VdbeDb(v));
    Column *pCol = &pTab->aCol[i];
    sqlite3ValueFromExpr(pCol->pDflt, enc, pCol->affinity, &pValue);
    if( pValue ){
      sqlite3VdbeChangeP3(v, -1, (const char *)pValue, P3_MEM);
    }else{
      VdbeComment((v, "# %s.%s", pTab->zName, pCol->zName));
    }
  }
}
Ejemplo n.º 25
0
/*
** This routine is called on a collation sequence before it is used to
** check that it is defined. An undefined collation sequence exists when
** a database is loaded that contains references to collation sequences
** that have not been defined by sqlite3_create_collation() etc.
**
** If required, this routine calls the 'collation needed' callback to
** request a definition of the collating sequence. If this doesn't work, 
** an equivalent collating sequence that uses a text encoding different
** from the main database is substituted, if one is available.
*/
int sqlite3CheckCollSeq(Parse *pParse, CollSeq *pColl){
  if( pColl ){
    const char *zName = pColl->zName;
    sqlite3 *db = pParse->db;
    CollSeq *p = sqlite3GetCollSeq(db, ENC(db), pColl, zName);
    if( !p ){
      sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
      pParse->nErr++;
      return SQLITE_ERROR;
    }
    assert( p==pColl );
  }
  return SQLITE_OK;
}
Ejemplo n.º 26
0
/*
** Bind a blob value to an SQL statement variable.
*/
int sqlite3_bind_blob(
  sqlite3_stmt *pStmt, 
  int i, 
  const void *zData, 
  int nData, 
  void (*xDel)(void*)
){
  return bindText(pStmt, i, zData, nData, xDel, 0);
}
int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
  int rc;
  Vdbe *p = (Vdbe *)pStmt;
  sqlite3_mutex_enter(p->db->mutex);
  rc = vdbeUnbind(p, i);
  if( rc==SQLITE_OK ){
    sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);
  }
  sqlite3_mutex_leave(p->db->mutex);
  return rc;
}
int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
  return sqlite3_bind_int64(p, i, (i64)iValue);
}
int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
  int rc;
  Vdbe *p = (Vdbe *)pStmt;
  sqlite3_mutex_enter(p->db->mutex);
  rc = vdbeUnbind(p, i);
  if( rc==SQLITE_OK ){
    sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);
  }
  sqlite3_mutex_leave(p->db->mutex);
  return rc;
}
int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
  int rc;
  Vdbe *p = (Vdbe*)pStmt;
  sqlite3_mutex_enter(p->db->mutex);
  rc = vdbeUnbind(p, i);
  sqlite3_mutex_leave(p->db->mutex);
  return rc;
}
int sqlite3_bind_text( 
  sqlite3_stmt *pStmt, 
  int i, 
  const char *zData, 
  int nData, 
  void (*xDel)(void*)
){
  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
}
#ifndef SQLITE_OMIT_UTF16
int sqlite3_bind_text16(
  sqlite3_stmt *pStmt, 
  int i, 
  const void *zData, 
  int nData, 
  void (*xDel)(void*)
){
  return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
}
#endif /* SQLITE_OMIT_UTF16 */
int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
  int rc;
  Vdbe *p = (Vdbe *)pStmt;
  sqlite3_mutex_enter(p->db->mutex);
  rc = vdbeUnbind(p, i);
  if( rc==SQLITE_OK ){
    rc = sqlite3VdbeMemCopy(&p->aVar[i-1], pValue);
    if( rc==SQLITE_OK ){
      rc = sqlite3VdbeChangeEncoding(&p->aVar[i-1], ENC(p->db));
    }
  }
  rc = sqlite3ApiExit(p->db, rc);
  sqlite3_mutex_leave(p->db->mutex);
  return rc;
}
Ejemplo n.º 27
0
/*
** This function is responsible for invoking the collation factory callback
** or substituting a collation sequence of a different encoding when the
** requested collation sequence is not available in the database native
** encoding.
** 
** If it is not NULL, then pColl must point to the database native encoding 
** collation sequence with name zName, length nName.
**
** The return value is either the collation sequence to be used in database
** db for collation type name zName, length nName, or NULL, if no collation
** sequence can be found.
**
** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
*/
CollSeq *sqlite3GetCollSeq(
  sqlite3* db,          /* The database connection */
  CollSeq *pColl,       /* Collating sequence with native encoding, or NULL */
  const char *zName     /* Collating sequence name */
){
  CollSeq *p;

  p = pColl;
  if( !p ){
    p = sqlite3FindCollSeq(db, ENC(db), zName, 0);
  }
  if( !p || !p->xCmp ){
    /* No collation sequence of this type for this encoding is registered.
    ** Call the collation factory to see if it can supply us with one.
    */
    callCollNeeded(db, zName);
    p = sqlite3FindCollSeq(db, ENC(db), zName, 0);
  }
  if( p && !p->xCmp && synthCollSeq(db, p) ){
    p = 0;
  }
  assert( !p || p->xCmp );
  return p;
}
Ejemplo n.º 28
0
bool qPBReaderDocView::GetWordAt(QPoint iScreenPt,
                                 QString & osSelectedWord,
                                 QRect & oScreenRect)
{
   TRSCOPE(view, "qPBReaderDocView::GetWordAt");

   osSelectedWord.clear();
   oScreenRect = QRect();

   QWebHitTestResult hit = _pDoc->mainFrame()->hitTestContent(iScreenPt);
   QWebElement e = hit.enclosingBlockElement();
   TRACE << ENC(e.localName()) << endl;
   QString js = "qPBReaderFindClickedWord(this, " + QString::number(
                   iScreenPt.x()) + "," + QString::number(iScreenPt.y()) + ")";
   TRACE << ENC(js) << endl;

   QList<QVariant> lv = e.evaluateJavaScript(js).toList();
   bool b = lv.size() == 5;
   TRACE << "Javascript word search = " << b << endl;

   if (b)
   {
      osSelectedWord = lv[0].toString();
      oScreenRect = QRect(QPoint(lv[1].toInt(), lv[2].toInt()), QPoint(lv[3].toInt(),
                          lv[4].toInt()));
      TRACE << ENC(osSelectedWord)
            << " rect (" << oScreenRect.left() << ", "
            << oScreenRect.top() << ", "
            << oScreenRect.right() << ", "
            << oScreenRect.bottom() << ")" << endl;
   }

   TRACE << TRANAME << " ended with " << b << endl;

   return b;
}
Ejemplo n.º 29
0
    // pour new coin
    EncryptedCoin(const Coin<FIELD>& coin) {
        ENCRYPTOR ENC(coin.addr().cryptoKey());
        RANDPOOL RNG;

        std::stringstream ss;
        coin.marshal_out(ss, false); // false means omit public address
        const std::string& ptext = ss.str();
        const std::size_t ptextLen = ptext.length() + 1;

        // encrypt message
        m_cipherText = std::vector<byte>(ENC.CiphertextLength(ptextLen), 0xfb);
        ENC.Encrypt(RNG,
                    reinterpret_cast<const byte*>(ptext.data()),
                    ptextLen,
                    m_cipherText.data());
    }
Ejemplo n.º 30
0
void qPBReaderPlatform::DisplayPageNumber(const QString & isTitle,
      int inCurrentPage,
      int inTotal)
{
   TRSCOPE(pb, "qPBReaderPlatform::DisplayPageNumber");
#ifdef Q_OS_POCKETBOOK

   TRACE << "Panel " << ENC(isTitle) << " " << inCurrentPage << " / " << inTotal <<
         endl;
   ::DrawPanel4(0, isTitle.toUtf8().data(), inCurrentPage, inTotal, 1);
   UpdatePanelDisplay();
#else

   Q_UNUSED(isTitle);
   Q_UNUSED(inCurrentPage);
   Q_UNUSED(inTotal);
#endif
}