예제 #1
0
파일: rdbu.c 프로젝트: Accio/ribios
void rdbu_initLoginInfo (char *filename) {
  /**
     Looks in the following places for user/password\@database
     info needed for logging into database in this order
     1. a file named .login_db in the user's home directory
     2. a file named .login_db in the current directory
     3. a file named 'filename' (optional input parameter)
     4. arguments 'dbuser', 'dbpassword', 'dbname' present  the command line
     Syntax of the files:
     - only the first line is read
     - this line must have the form user/password\@dbname
     - each of these fields can be '-'; in this case the value
       of this field is not changed. E.g. if $HOME/.login_db contains
       -/-\@testdb
      and 'filename' contains
      scott/-@-
      and on the command line there is an argument
      -dbpassword tiger
      then username will be scott, password will be tiger and
      database will be testdb
      optional: if arg_init() was called before then the command line will be
                considered; else the command line is ignored
      Postcondition: rdbu_user() etc can be called
  */
  Stringa fn;
  char *home = getenv ("HOME");
  if (user != NULL)
    die ("rdbu_getLoginInfo() twice");
  user = stringCreate(10);
  password = stringCreate(10);
  database = stringCreate(10);
  if (home != NULL) {
    fn = stringCreate (100);
    stringPrintf (fn,"%s/.login_db",home);
    readUserInfoFile (string (fn));
    stringDestroy (fn);
  }
  readUserInfoFile (".login_db");
  if (filename != NULL && *filename != '\0')
    readUserInfoFile (filename);
  if (arg_isInit ()) {
    if (arg_present ("dbuser"))
      stringCpy (user,arg_get ("dbuser"));
    if (arg_present ("dbpassword"))
      stringCpy (password,arg_get ("dbpassword"));
    if (arg_present ("dbname"))
      stringCpy (database,arg_get ("dbname"));
  }
}
예제 #2
0
파일: cgi.c 프로젝트: Accio/ribios
SEXP r_cgiDecodeWord(SEXP word) {
  static Stringa value;
  stringCreateOnce(value, 16);
  
  stringCpy(value, cStr(word));
  cgiDecodeWord(value);
  return mkString(string(value));
}
예제 #3
0
파일: rdbu.c 프로젝트: Accio/ribios
static void readUserInfoFile (char *filename) {
  char line[200];
  char *u;
  char *p;
  char *db;
  char *slashp;
  char *atp;
  char *cp;
  FILE *f = fopen (filename,"r");
  if (f == NULL)
    return;
  fgets (line,sizeof (line),f);
  fclose (f);
  // user/password@instance
  // - in each field: unknown
  if ((cp = strchr (line,'\n')) != '\0')
    *cp = '\0';
  slashp = strchr (line,'/');
  atp = strchr (line,'@');
  if (slashp == line || slashp == NULL || slashp >= atp-1 ||
      atp == NULL || *(atp+1) == '\0') {
    warn ("cannot understand contents of file %s. ignoring contents.",
          filename);
    return;
  }
  u = line;
  p = slashp+1;
  db = atp+1;
  *slashp = '\0';
  *atp = '\0';
  if (strDiffer (u,"-"))
    stringCpy (user,u);
  if (strDiffer (p,"-"))
    stringCpy (password,p);
  if (strDiffer (db,"-"))
    stringCpy (database,db);
}
예제 #4
0
파일: seqspeclist.c 프로젝트: Accio/ribios
int seqspec_split2continous (Seqspec this1) {
  /**
     If 'this1' sequence segment is of the form 'db:seq_n begin:b end:e'
     it is transformed into 'db:seq begin:b1 end:e1'
     where b1=b+n*100000, e1=e+n*100000
     which means the GCG type split is removed
     @param[in] this1 - the Seqspec object
     @param[out] this1 - the Seqspec object possibly modified
     @return 1 if 'this1' changed, else 0
  */
  static char *seqname = NULL;
  static Stringa dbseqname = NULL;
  int nameLen;
  char *cp;
  int offset;
  int segnum;

  stringCreateClear (dbseqname,40);
  strReplace (&seqname,this1->seqname);
  nameLen = strlen (seqname);
  if (nameLen < 3)
    return 0;
  if ((cp = strrchr(seqname, '_')) == NULL)
    return 0;
  if (*(cp+1) == '\0' || strlen (cp+1) > 2)
    return 0;
  segnum = atoi (cp+1);
  *cp = 0;
  offset = segnum * FRAGMENT_LENGTH;
  this1->begin += offset;
  if (this1->end != 0)
    this1->end += offset;
  stringCpy (dbseqname,this1->dbname);
  stringCat (dbseqname,":");
  stringCat (dbseqname,seqname);
  seqspec_IDset (this1,string (dbseqname));
  return 1;
}
void tst_QAndroidJniObject::ctor()
{
    {
        QAndroidJniObject object;
        QVERIFY(!object.isValid());
    }

    {
        QAndroidJniObject object("java/lang/String");
        QVERIFY(object.isValid());
    }

    {
        QAndroidJniObject string = QAndroidJniObject::fromString(QLatin1String("Hello, Java"));
        QAndroidJniObject object("java/lang/String", "(Ljava/lang/String;)V", string.object<jstring>());
        QVERIFY(object.isValid());
        QCOMPARE(string.toString(), object.toString());
    }

    {
        QAndroidJniEnvironment env;
        jclass javaStringClass = env->FindClass("java/lang/String");
        QAndroidJniObject string(javaStringClass);
        QVERIFY(string.isValid());
    }

    {
        QAndroidJniEnvironment env;
        const QString qString = QLatin1String("Hello, Java");
        jclass javaStringClass = env->FindClass("java/lang/String");
        QAndroidJniObject string = QAndroidJniObject::fromString(qString);
        QAndroidJniObject stringCpy(javaStringClass, "(Ljava/lang/String;)V", string.object<jstring>());
        QVERIFY(stringCpy.isValid());
        QCOMPARE(qString, stringCpy.toString());
    }
}