Beispiel #1
0
void Error::readSystemException(hash data) {
    if (!data.contains(1)) {
        LOG_ERROR("Empty User Exception");
        return;
    }

    bool ok;
    int errorCode = data[1].toInt(&ok);

    if (!ok) {
        LOG_ERROR("Unknown User Exception");
        return;
    }

    EDAMErrorCode(errorCode);

    if (data.contains(2)) {
        QString message = data[2].toString();
        LOG_INFO(message);
    }

    if (data.contains(3)) {
        int rateLimitDuration = data[3].toInt();
        LOG_INFO(QString("Rate Limit Duration: %1 s.").arg(rateLimitDuration));
    }
}
Beispiel #2
0
void Error::readExceptions(hash data) {
    if (data.contains(1))
        readUserException(data[1].value<hash>());

    if (data.contains(2))
        readSystemException(data[2].value<hash>());

    if (data.contains(3))
        readNotFoundException(data[3].value<hash>());
}
Beispiel #3
0
/* finalize the hash computation and output the result */
void skein512::finalize( hash &hashVal )
{
    size_t n,byteCnt;
    uint64_t Y[8];

    _T[1] |= SKEIN_T1_FLAG_FINAL;                 /* tag as the final block */
    if ( _block_size < 64 )            /* zero pad b[] if necessary */
        memset( &_block[_block_size], 0, 64 - _block_size );

    process( _block, 1, _block_size );  /* process the final block */

    /* now output the result */
    byteCnt = (512 + 7) >> 3;             /* total number of output bytes */

    /* run Threefish in "counter mode" to generate output */
    memset( _block, 0, sizeof(_block) );  /* zero out b[], so it can hold the counter */
    memcpy( Y, _X, sizeof(_X) );       /* keep a local copy of counter mode "key" */
    for ( size_t i = 0; i * 64 < byteCnt; i++ )
	{
		_block64[0] = Skein_Swap64( uint64_t(i) ); /* build the counter block */

        start_new_type( SKEIN_T1_BLK_TYPE_OUT_FINAL );
        process( _block, 1, sizeof(uint64_t) ); /* run "counter mode" */
        n = byteCnt - i*64;   /* number of output bytes left to go */
        if (n >= 64)
            n  = 64;
        Skein_Put64_LSB_First(hashVal.data()+i*64,_X,n);   /* "output" the ctr mode bytes */
        memcpy(_X,Y,sizeof(_X));   /* restore the counter mode key for next time */
	}
}
Beispiel #4
0
 result_type
 operator()(T const& t) const noexcept
 {
     H h;
     using hash::hash_append;
     hash_append(h, t);
     return static_cast<result_type>(h);
 }
Beispiel #5
0
void Error::readNotFoundException(hash data) {
    QString e("Not Found Exception");

    if (data.contains(1)) {
        QString identifier = data[1].toString();
        e.append(" Identifier:");
        e.append(identifier);
    }

    if (data.contains(2)) {
        QString key = data[2].toString();
        e.append(" Key:");
        e.append(key);
    }

    LOG_ERROR(e);
}
Beispiel #6
0
int main(int argc, char *argv[])
{
    //freopen("rank.in","r",stdin);freopen("rank.out","w",stdout);
    scanf("%d",&n);
    for(int i = 1;i<=n;i++)
    {
     int w;char c=0;
     while(c != '+' && c != '?')
      scanf("%c",&c);
     switch(c)
     {
      case '+':
           {
            scanf("%s %d\n",s,&w);
            int u = h.find();
            if(u == 0)
             ins(root,w);
            else
             del(u),ins(root,w);
            break;
           }
      case '?':
           {
            scanf("%s\n",s);
            if(!isupper(s[0]))
            {
             w = strtol(s,0,10);
             int tot = min(t[root].size,w+9);
             for(int j = w;j<=tot;j++)
             {
              findkth(root,j);
              printf("%s",s);
              if( j < tot)
               printf(" ");
              else
               puts("");
             }
            }else
             printf("%d\n",count(h.find()));
           }
     }
    }
    //fclose(stdin);fclose(stdout);
    return EXIT_SUCCESS;
}
Beispiel #7
0
static void
add_expr_commutative (const_tree t1, const_tree t2, hash &hstate)
{
  hash one, two;

  inchash::add_expr (t1, one);
  inchash::add_expr (t2, two);
  hstate.add_commutative (one, two);
}
Beispiel #8
0
      inline void add(key_t key, const add_t &val, val_t *oval = 0) {
        while(true) {
          while(atomic::cas(&status, FREE, INUSE) != FREE)
            my_hash->wait_event_is_done();

          if(ary->add(key, val, oval))
            break;

          // Improve this. Undefined behavior if dump_to_file throws an error.
          if(my_hash->get_event_locks()) {
            my_hash->dump();
            my_hash->release_event_locks();
          }
        }
        
        if(atomic::cas(&status, INUSE, FREE) != INUSE)
          my_hash->signal_not_in_use();
      }
Beispiel #9
0
void Error::readUserException(hash data) {

    if (!data.contains(1)) {
        LOG_ERROR("Empty User Exception");
        return;
    }

    bool ok;
    int errorCode = data[1].toInt(&ok);

    if (!ok) {
        LOG_ERROR("Unknown User Exception");
        return;
    }

    EDAMErrorCode(errorCode);

    QString parameter;
    if (data.contains(2)) {
        parameter = QString::fromUtf8(data[2].toByteArray());
        LOG_INFO(parameter);
    }
}
Beispiel #10
0
void NoteBook::loadFromData(hash data)
{
    qDebug() << "readData" << data.keys();
    if (data.contains(1))
        guid = QString::fromUtf8(data[1].toByteArray());
    if (data.contains(2))
        name = QString::fromUtf8(data[2].toByteArray());
    if (data.contains(5))
        updateSequenceNum = data[5].toInt();
    if (data.contains(6))
        defaultNotebook = data[6].toBool();
    if (data.contains(7))
        serviceCreated = QDateTime::fromMSecsSinceEpoch(data[7].toLongLong());
    if (data.contains(8))
        serviceUpdated = QDateTime::fromMSecsSinceEpoch(data[8].toLongLong());
    if (data.contains(12))
        stack = QString::fromUtf8(data[12].toByteArray());
}
Beispiel #11
0
void ins(int & x,int w)
{
 if(x == 0)
 {
  tot++;
  t[tot] = node(w);
  x = tot;
  h.add(tot);
  return;
 }
 int i = w<=t[x].w;
 ins(t[x].ch[i],w);
 t[t[x].ch[i]].F = x;
 updata(x);
 int y = t[x].ch[i];
 if(rand()%t[x].size < 1){
  rotate(y);
  x = y;
 }
 if(t[x].F == 0)
  root = x;
}
Beispiel #12
0
void Note::readAttributes(hash data)
{
    if (data.contains(1))
        attributes["subjectDate"] = data[1];

    if (data.contains(10))
        attributes["latitude"] = data[10];

    if (data.contains(11))
        attributes["longitude"] = data[11];

    if (data.contains(12))
        attributes["altitude"] = data[12];

    if (data.contains(13))
        attributes["author"] = data[13];

    if (data.contains(14))
        attributes["sourceURL"] = data[14];

    if (data.contains(15))
        attributes["sourceURL"] = data[15];

    if (data.contains(16))
        attributes["sourceApplication"] = data[16];

    if (data.contains(17))
        attributes["shareDate"] = data[17];

    if (data.contains(18))
        attributes["reminderOrder"] = data[18];

    if (data.contains(19))
        attributes["reminderDoneTime"] = data[19];

    if (data.contains(20))
        attributes["reminderTime"] = data[20];

    if (data.contains(21))
        attributes["placeName"] = data[21];

    if (data.contains(22))
        attributes["contentClass"] = data[22];

    if (data.contains(23))
        attributes["applicationData"] = data[23];

    if (data.contains(24))
        attributes["lastEditedBy"] = data[24];

    if (data.contains(25))
        attributes["classifications"] = data[25];

    if (data.contains(27))
        attributes["creatorId"] = data[27];

    if (data.contains(28))
        attributes["lastEditorId"] = data[28];
}
Beispiel #13
0
void Note::loadFromData(hash data)
{
    if (data.contains(1))
        guid = QString::fromUtf8(data[1].toByteArray());
    if (data.contains(2))
        title = QString::fromUtf8(data[2].toByteArray());
    if (data.contains(3))
        content = QString::fromUtf8(data[3].toByteArray());
    if (data.contains(4))
        contentHash = data[4].toByteArray().toHex();
    if (data.contains(5))
        contentLength = data[5].toInt();
    if (data.contains(6))
        created = QDateTime::fromMSecsSinceEpoch(data[6].toLongLong());
    if (data.contains(7))
        updated = QDateTime::fromMSecsSinceEpoch(data[7].toLongLong());
    if (data.contains(8))
        deleted = QDateTime::fromMSecsSinceEpoch(data[8].toLongLong());
    if (data.contains(9))
        active = data[9].toBool();
    if (data.contains(10))
        updateSequenceNum = data[10].toInt();
    if (data.contains(11))
        notebookGuid = QString::fromUtf8(data[11].toByteArray());
    if (data.contains(12)) {
        list l = data[12].toList();
        for (int i=0; i<l.size(); i++){
            QString tguid = QString::fromUtf8(l.at(i).toByteArray());
            tagGuids.append(tguid);
        }
    }
    if (data.contains(13)) {
        list l = data[13].toList();
        QSqlDatabase::database().transaction();
        for (int i=0; i<l.size(); i++){
            hash res = l.at(i).value<hash>();
            Resource *r = new Resource(this, res);
            delete r;
        }
        QSqlDatabase::database().commit();
    }
    if (data.contains(14)) {
        hash attr = data[14].value<hash>();
        readAttributes(attr);
    }
}
Beispiel #14
0
void
add_rtx (const_rtx x, hash &hstate)
{
  enum rtx_code code;
  machine_mode mode;
  int i, j;
  const char *fmt;

  if (x == NULL_RTX)
    return;
  code = GET_CODE (x);
  hstate.add_object (code);
  mode = GET_MODE (x);
  hstate.add_object (mode);
  switch (code)
    {
    case REG:
      hstate.add_int (REGNO (x));
      return;
    case CONST_INT:
      hstate.add_object (INTVAL (x));
      return;
    case CONST_WIDE_INT:
      for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
	hstate.add_object (CONST_WIDE_INT_ELT (x, i));
      return;
    case CONST_POLY_INT:
      for (i = 0; i < NUM_POLY_INT_COEFFS; ++i)
	hstate.add_wide_int (CONST_POLY_INT_COEFFS (x)[i]);
      break;
    case SYMBOL_REF:
      if (XSTR (x, 0))
	hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
      return;
    case LABEL_REF:
    case DEBUG_EXPR:
    case VALUE:
    case SCRATCH:
    case CONST_DOUBLE:
    case CONST_FIXED:
    case DEBUG_IMPLICIT_PTR:
    case DEBUG_PARAMETER_REF:
      return;
    default:
      break;
    }

  fmt = GET_RTX_FORMAT (code);
  for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
    switch (fmt[i])
      {
      case 'w':
	hstate.add_hwi (XWINT (x, i));
	break;
      case 'n':
      case 'i':
	hstate.add_int (XINT (x, i));
	break;
      case 'p':
	hstate.add_poly_int (SUBREG_BYTE (x));
	break;
      case 'V':
      case 'E':
	j = XVECLEN (x, i);
	hstate.add_int (j);
	for (j = 0; j < XVECLEN (x, i); j++)
	  inchash::add_rtx (XVECEXP (x, i, j), hstate);
	break;
      case 'e':
	inchash::add_rtx (XEXP (x, i), hstate);
	break;
      case 'S':
      case 's':
	if (XSTR (x, i))
	  hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
	break;
      default:
	break;
      }
}
Beispiel #15
0
static void
add_hashable_expr (const struct hashable_expr *expr, hash &hstate)
{
  switch (expr->kind)
    {
    case EXPR_SINGLE:
      inchash::add_expr (expr->ops.single.rhs, hstate);
      break;

    case EXPR_UNARY:
      hstate.add_object (expr->ops.unary.op);

      /* Make sure to include signedness in the hash computation.
         Don't hash the type, that can lead to having nodes which
         compare equal according to operand_equal_p, but which
         have different hash codes.  */
      if (CONVERT_EXPR_CODE_P (expr->ops.unary.op)
          || expr->ops.unary.op == NON_LVALUE_EXPR)
        hstate.add_int (TYPE_UNSIGNED (expr->type));

      inchash::add_expr (expr->ops.unary.opnd, hstate);
      break;

    case EXPR_BINARY:
      hstate.add_object (expr->ops.binary.op);
      if (commutative_tree_code (expr->ops.binary.op))
	inchash::add_expr_commutative (expr->ops.binary.opnd0,
					  expr->ops.binary.opnd1, hstate);
      else
        {
          inchash::add_expr (expr->ops.binary.opnd0, hstate);
          inchash::add_expr (expr->ops.binary.opnd1, hstate);
        }
      break;

    case EXPR_TERNARY:
      hstate.add_object (expr->ops.ternary.op);
      if (commutative_ternary_tree_code (expr->ops.ternary.op))
	inchash::add_expr_commutative (expr->ops.ternary.opnd0,
					  expr->ops.ternary.opnd1, hstate);
      else
        {
          inchash::add_expr (expr->ops.ternary.opnd0, hstate);
          inchash::add_expr (expr->ops.ternary.opnd1, hstate);
        }
      inchash::add_expr (expr->ops.ternary.opnd2, hstate);
      break;

    case EXPR_CALL:
      {
        size_t i;
        enum tree_code code = CALL_EXPR;
        gcall *fn_from;

        hstate.add_object (code);
        fn_from = expr->ops.call.fn_from;
        if (gimple_call_internal_p (fn_from))
          hstate.merge_hash ((hashval_t) gimple_call_internal_fn (fn_from));
        else
          inchash::add_expr (gimple_call_fn (fn_from), hstate);
        for (i = 0; i < expr->ops.call.nargs; i++)
          inchash::add_expr (expr->ops.call.args[i], hstate);
      }
      break;

    case EXPR_PHI:
      {
        size_t i;

        for (i = 0; i < expr->ops.phi.nargs; i++)
          inchash::add_expr (expr->ops.phi.args[i], hstate);
      }
      break;

    default:
      gcc_unreachable ();
    }
}