コード例 #1
0
ファイル: xdb.cpp プロジェクト: dx01259/libxsp
int is_eof(struct rdset *rdsetp)
{
	int result = 0;
	int type = rdsetp->rd_db_type;
	switch (type)
	{
	case DB_ORACLE:
		break;
	case DB_MYSQL:
		{
			if (rdsetp->rd_mysqlp->rd_resp == NULL)
				return 0;
			MYSQL_ROW *rowp = &rdsetp->rd_mysqlp->rd_rowp;
			if (mysql_eof(rdsetp->rd_mysqlp->rd_resp)) //it is always true when use mysql_store_result
			{
				*rowp = mysql_fetch_row(rdsetp->rd_mysqlp->rd_resp);
				if (*rowp)
				{
					result = 1;
					break;
				}
			}
		}
		break;
	default:
		break;
	}
	return result;
}
コード例 #2
0
ファイル: db.c プロジェクト: yangchenzhong/im
int IsEOF(MYSQL_RES *pResult)
{
	if (!pResult)
	{
		ErrorInfor("IsEOF", ERROR_ARGNULL);
		return 1;
	}

	return (mysql_eof(pResult) == 0) ? 0 : 1;
}
コード例 #3
0
int SqlUseResults::_MoveNextRow()
{
	m_cur_row = mysql_fetch_row(m_p_sql_results);

	if (!mysql_eof(m_p_sql_results))
	{
		m_nCurRow ++;
		return m_nCurRow;
	}
	m_nCurRow = -1;
	m_cur_row = NULL;
	return m_nCurRow;
}
コード例 #4
0
int SqlUseResults::_FirstRow()
{
	m_cur_row = mysql_fetch_row(m_p_sql_results);

	if (!mysql_eof(m_p_sql_results))
	{
		m_nCurRow = 0;
		return m_nCurRow;
	}
	m_cur_row = NULL;
	m_nCurRow = -1;
	return m_nCurRow;
}
コード例 #5
0
ファイル: database.c プロジェクト: davidjulien/ouroboros
MYSQL_ROW db_next(MYSQL_RES *res)
{
    MYSQL_ROW row = mysql_fetch_row(res);

    if (row != NULL) {
        return row;
    } else {
        if (!mysql_eof(res)) {
            return NULL;
        } else {
            mysql_free_result(res);
            return NULL;
        }
    }
}
コード例 #6
0
ファイル: issub.c プロジェクト: kunishi/qmail-hg
const char *issub(const char *dir,
		  const char *subdir,
		  const char *userhost)
/* Returns (char *) to match if userhost is in the subscriber database      */
/* dir, 0 otherwise. dir is a base directory for a list and may NOT         */
/* be NULL        */
/* NOTE: The returned pointer is NOT VALID after a subsequent call to issub!*/

{
  MYSQL_RES *result;
  MYSQL_ROW row;
  const char *ret;
  const char *table;
  unsigned long *lengths;

  unsigned int j;

  if ((ret = opensub(dir,subdir,&table))) {
    if (*ret) strerr_die2x(111,FATAL,ret);

    return std_issub(dir,subdir,userhost);

  } else {						/* SQL version  */
	/* SELECT address FROM list WHERE address = 'userhost' AND hash */
	/* BETWEEN 0 AND 52. Without the hash restriction, we'd make it */
	/* even easier to defeat. Just faking sender to the list name would*/
	/* work. Since sender checks for posts are bogus anyway, I don't */
	/* know if it's worth the cost of the "WHERE ...". */

    if (!stralloc_copys(&addr,userhost)) die_nomem();
    j = byte_rchr(addr.s,addr.len,'@');
    if (j == addr.len) return 0;
    case_lowerb(addr.s + j + 1,addr.len - j - 1);

    if (!stralloc_copys(&line,"SELECT address FROM ")) die_nomem();
    if (!stralloc_cats(&line,table)) die_nomem();
    if (!stralloc_cats(&line," WHERE address = '")) die_nomem();
    if (!stralloc_ready(&quoted,2 * addr.len + 1)) die_nomem();
    if (!stralloc_catb(&line,quoted.s,
	mysql_escape_string(quoted.s,userhost,addr.len))) die_nomem();
    if (!stralloc_cats(&line,"'"))
		die_nomem();
    if (mysql_real_query(mysql,line.s,line.len))	/* query */
		strerr_die2x(111,FATAL,mysql_error(mysql));
    if (!(result = mysql_use_result(mysql)))
		strerr_die2x(111,FATAL,mysql_error(mysql));
    row = mysql_fetch_row(result);
    ret = (char *) 0;
    if (!row) {		/* we need to return the actual address as other */
			/* dbs may accept user-*@host, but we still want */
			/* to make sure to send to e.g the correct moderator*/
			/* address. */
      if (!mysql_eof(result))
		strerr_die2x(111,FATAL,mysql_error(mysql));
    } else {
      if (!(lengths = mysql_fetch_lengths(result)))
		strerr_die2x(111,FATAL,mysql_error(mysql));
      if (!stralloc_copyb(&line,row[0],lengths[0])) die_nomem();
      if (!stralloc_0(&line)) die_nomem();
      ret = line.s;
      while ((row = mysql_fetch_row(result)));	/* maybe not necessary */
      mysql_free_result(result);
    }
    return ret;
  }
}