示例#1
0
int resthandler::getToken()
{
    QString queryname = "access_token";
    if(settings->contains(queryname)) {
        QUrl tokeninfo("https://openapi.baidu.com/oauth/2.0/tokeninfo");
        tokeninfo.addQueryItem(queryname, settings->value(queryname).toString());
        QString test = tokeninfo.toString();
        connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(LoginReplyFinished(QNetworkReply*)));
        manager->get(QNetworkRequest(tokeninfo));
    } else {
示例#2
0
static int make_toks(const char *source, int *my_token) {
  int old_tok = STARTTOK, tok_in = 0;
  int index = 0, nparen = 0, lastindex = 0;

  while (source[index] != '\0') {
    int token = find_tok(&my_symb, source + index);

    lastindex = index;
    if (token != my_symb.len)
      index += my_symb.elems[token].len;

    if ((token == MINUS) &&
        ((old_tok == STARTTOK) || (old_tok == COMMA) || (old_tok == LPAREN)))
      token = NEGATE;
    else if (token == LPAREN)
      ++nparen;
    else if (token == RPAREN)
      --nparen;

    if (token == my_symb.len) {
      char num[40];
      double value;
      /*  WARNING  -- ASSUMES 32 bit int  and 64 bit double  */
      union {
        struct {
          int int1;
          int int2;
        } pieces;
        struct {
          double z;
        } num;
      } encoder;

      if (do_num(source, num, &value, &index)) {
        plintf("illegal expression: %s\n", num);
        show_where(source, index);
        return (1);
      }
      /*    new code        3/95      */
      encoder.num.z = value;
      my_token[tok_in++] = NUMTOK;
      my_token[tok_in++] = encoder.pieces.int1;
      my_token[tok_in++] = encoder.pieces.int2;
      if (check_syntax(old_tok, NUMTOK) == 1) {
        plintf("Illegal syntax \n");
        show_where(source, lastindex);
        return (1);
      }
      old_tok = NUMTOK;
    } else {
      my_token[tok_in++] = token;
      if (check_syntax(old_tok, token) == 1) {
        plintf("Illegal syntax (Ref:%d %d) \n", old_tok, token);
        show_where(source, lastindex);
        tokeninfo(old_tok);
        tokeninfo(token);
        return (1);
      }

      old_tok = token;
    }
  }

  my_token[tok_in++] = ENDTOK;
  if (check_syntax(old_tok, ENDTOK) == 1) {
    plintf("Premature end of expression \n");
    show_where(source, lastindex);
    return (1);
  }
  if (nparen != 0) {
    plintf("parentheses don't match\n");
    return (1);
  }
  return (0);
}