Hello! SQLite API has functions for query formatting.
For example: char * sqlite3_get_passwd_sqlite(char * file, char* user, char* passwd_type) { char *passwd; char *rec; sqlite3 *db; char *sql = NULL; sqlite3_stmt *stmt; const char *tail; int rc; const char zSql_cleartext[] = "select 'cleartext ' || password as password from users where nickname=? \ and delete_date IS NULL and date_expire>strftime('%s',datetime('now')) and not password IS NULL"; const char zSql_des[] = "select 'des ' || password_des as password from users where nickname=? \ and delete_date IS NULL and date_expire>strftime('%s',datetime('now')) and not password_des IS NULL"; const char zSql_md5[] = "select 'md5 ' || password_md5 as password from users where nickname=? \ and delete_date IS NULL and date_expire>strftime('%s',datetime('now')) and not password_md5 IS NULL"; /* an alternate filename */ if (!(access(file, R_OK) == 0)) { report(LOG_ERR, "Cannot access to sqlite database file %s for user %s -- %s", file, user, strerror(errno)); return(0); } /* open SQLite database */ if (sqlite3_open(file, &db) != SQLITE_OK) report(LOG_ERR, "sqlite3_open(): failed open % database", file); sqlite3_busy_timeout(db, DB_AUTH_DEFAULT_TIMEOUT); if (!strcmp(passwd_type, "cleartext")) { sql = (char*)zSql_cleartext; } else if (!strcmp(passwd_type, "des")) { sql = (char*)zSql_des; } else if (!strcmp(passwd_type, "md5")) { sql = (char*)zSql_md5; } else { report(LOG_ERR, "Unknown password type %s for user %s", passwd_type, user); } if (sqlite3_prepare(db, sql, -1, &stmt, 0) != SQLITE_OK) { /*Fatal DB Error.*/ report(LOG_ERR, "slite3 prepare error: %s", sql); sqlite3_close(db); return(NULL); } sqlite3_bind_text(stmt, 1, user, -1, SQLITE_STATIC); rc = sqlite3_step(stmt); if(rc == SQLITE_ROW) { // return row passwd = tac_strdup((char*)sqlite3_column_text(stmt,0)); // if (debug) // report(LOG_NOTICE, "slite3 return user nickname=%s, password=%s",user,passwd); sqlite3_finalize(stmt); /* close database */ sqlite3_close(db); return(passwd); } sqlite3_finalize(stmt); /* close database */ sqlite3_close(db); return(NULL); } Best regards, Alexey. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users