/****************************************************************************
 * KONOHA COPYRIGHT, LICENSE NOTICE, AND DISCRIMER  
 * 
 * Copyright (c) 2005-2008, Kimio Kuramitsu <kimio at ynu.ac.jp>
 *           (c) 2007       Akihide Takai <atatai at sourceforge.jp>
 *           (c) 2008-      Konoha Software Foundation  
 * All rights reserved.
 * 
 * You may choose one of the following two licenses when you use konoha. 
 * See www.konohaware.org/license.html for further information.
 * 
 * (1) GNU General Public License 2.0      (with    KONOHA_UNDER_GPL2)
 * (2) Konoha Software Foundation License 1.0
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *  
 ****************************************************************************/

/* ************************************************************************ */

#include"commons.h"

/* ************************************************************************ */

#ifdef __cplusplus 
extern "C" {
#endif

	
static int knhrs = 0;

/* ======================================================================== */
// char *url = "test://(hostname)/(DB)";

knh_connptr_t* 
knh_Connection_open__test(Ctx *ctx, knh_bytes_t url, char *uname, char *upwd)
{
	knhrs = 0;
	return (knh_connptr_t*)url.buf;
}

/* ------------------------------------------------------------------------ */

knh_bool_t knh_ResultSet_next__test(Ctx *ctx, knh_rsptr_t *rsptr, ResultSet *b)
{
	knh_ResultSet_initData(ctx, b);
	knhrs++;
	switch(knhrs) {
	case 1:
		knh_ResultSet_set__bytes(ctx, b, 0, STEXT("naruto"));
		knh_ResultSet_set__int(ctx, b, 1, 16);
		return 1;
	case 2:
		knh_ResultSet_set__bytes(ctx, b, 0, STEXT("sasuke"));
		knh_ResultSet_set__int(ctx, b, 1, 16);
		return 1;
	case 3:
		knh_ResultSet_set__bytes(ctx, b, 0, STEXT("sakura"));
		knh_ResultSet_set__int(ctx, b, 1, 15);
		return 1;
	}
	return 0; /* if nothing */
}

/* ------------------------------------------------------------------------ */

void knh_ResultSet_free__test(knh_rsptr_t *rsptr)
{

}

/* ------------------------------------------------------------------------ */

ResultSet* 
knh_Connection_query__test(Ctx *ctx, knh_connptr_t *conn, char *sql)
{
	return new_ResultSet(ctx, 2, NULL, knh_ResultSet_next__test, knh_ResultSet_free__test);
}

/* ------------------------------------------------------------------------ */

void knh_Connection_close__test(Ctx *ctx, knh_connptr_t *conn)
{
	
}

/* ======================================================================== */

#ifdef __cplusplus
}
#endif
