コード例 #1
0
ファイル: dbi.c プロジェクト: PRADEEPKJ/eclipseclp-aarch64
int
p_session_sql_dml(
		/* + */ value v_session, type t_session,
		/* + */ value v_SQL, type t_SQL,
		/* - */ value v_rows, type t_rows
		)
{
	session_t * session;
	cursor_t * cursor;
	char * SQL;
	word rows, *prows;
	int res;

	Check_String(t_SQL);
	Check_Output_Integer(t_rows);
	Get_Typed_Object(v_session,t_session,&session_handle_tid,session);


	cursor = session_sql_prepare(session, StringStart(v_SQL), StringLength(v_SQL), 0);
	if (NULL == cursor)
	    Bip_Error(dbi_errno);

	if (res = cursor_sql_execute(cursor, 1))
	{
	    cursor_free(cursor);
	    Bip_Error(Error_Code(res));
	}

	cursor_field_value(cursor, rows_processed_count, (void **)&prows);
	rows = *prows;

	cursor_free(cursor);

	Return_Unify_Integer(v_rows, t_rows, rows);
}
コード例 #2
0
ファイル: bip_parallel.c プロジェクト: CoryXie/BarrelfishOS
static int
p_dbag_create(value vbag, type tbag)
{
    dbag_descr_t *dbag_descr;
    aport_id_t bag_aport_id;

#ifndef lint
    if (sizeof(aport_id_t) > sizeof(value))
    {
	Bip_Error(UNIMPLEMENTED);	/* can't pack aport_id in integer */
    }
#endif

    if (aport_allocate(&bag_aport_id, dbag_port_upcall) != AMSG_OK)
	{ Bip_Error(MPS_ERROR); }
    if (aport_set_option(bag_aport_id, APORT_NOTIFY_LEVEL, (aport_optval_t) 3)
	    != AMSG_OK)
	{ Bip_Error(MPS_ERROR); }

    dbag_descr = (dbag_descr_t *) hp_alloc_size(sizeof(dbag_descr_t));
    dbag_descr->last = dbag_descr->first.msg_data_hdr = &dbag_descr->first;

    if (aport_set_option(bag_aport_id, APORT_DATA_PTR,
				(aport_optval_t) dbag_descr) != AMSG_OK)
	{ Bip_Error(MPS_ERROR); }

    Return_Unify_Integer(vbag, tbag, (long) bag_aport_id);
}
コード例 #3
0
static int
p_atom_length(value aval, type atag, value nval, type ntag)
{
        Check_Output_Integer(ntag);
	if (IsRef(atag))
	    { Bip_Error(PDELAY_1); }
	Check_Output_Atom_Or_Nil(aval, atag);
	Return_Unify_Integer(nval, ntag, DidLength(aval.did));
}
コード例 #4
0
static int
p_string_length(value sval, type stag, value nval, type ntag)
{
        Check_Output_Integer(ntag);
	if (IsRef(stag))
	    { Bip_Error(PDELAY_1); }
	else if (!IsString(stag))
	    { Bip_Error(TYPE_ERROR); }

	Return_Unify_Integer(nval, ntag, StringLength(sval));
}
コード例 #5
0
ファイル: bip_parallel.c プロジェクト: CoryXie/BarrelfishOS
/*ARGSUSED*/
static int
p_get_oracle3(value vfrom, type tfrom, value vto, type tto, value v, type t)
{
    pword *b_aux;
    char *buf;
    int size;

    if (IsRef(tto))
    {
	b_aux = B.args;
	while (!IsParallelFrame(BTop(b_aux)))
	    b_aux = BPrev(b_aux);
    }
    else
	b_aux = vto.ptr;

    size = oracle_size(vfrom.ptr, b_aux);
    buf = (char *) hp_alloc(size);
    retrieve_oracle(buf, size, vfrom.ptr, b_aux);

    Return_Unify_Integer(v, t, (long) buf);
}
コード例 #6
0
ファイル: error.c プロジェクト: CoryXie/BarrelfishOS
static int
p_max_error(value val1, type tag1)
{
	Check_Output_Integer(tag1);
	Return_Unify_Integer(val1, tag1, MAX_ERRORS - 1);
}
コード例 #7
0
ファイル: error.c プロジェクト: CoryXie/BarrelfishOS
static int
p_get_last_errno(value v, type t)
{
    Return_Unify_Integer(v, t, ec_os_errno_);
}
コード例 #8
0
static int
p_substring(value val1, type tag1, value val2, type tag2, value valp, type tagp)
{
	char	*p1, *p2;
	word	length1, length2;
	word	i, j;

        /* string1 and string2 must be strings; posn an integer/variable. */ 

	Check_Output_Integer(tagp);
        Check_Output_String(tag1);
        Check_String(tag2);
	Error_If_Ref(tag1);

	length1 = StringLength(val1);
	length2 = StringLength(val2);

	if (!IsRef(tagp))
	{
		if (valp.nint <= 0 || valp.nint > length1 + 1)
		{
		    Bip_Error(RANGE_ERROR);
		}
		if (valp.nint > length1 - length2 + 1)
		{
		    Fail_;	/* string 2 is too long to match */
		}

		p1 = StringStart(val1) + valp.nint - 1;
		p2 = StringStart(val2);
		for(j = 0; j < length2; ++j)
		{
		    if (p1[j] != p2[j])
		    {
			Fail_;
		    }
		}
		Succeed_;
	}
	else
	{
		p1 = StringStart(val1);
		p2 = StringStart(val2);
		for (i = 1; i <= length1 - length2 + 1; i++)
		{
			/*
	         	 * search through p (i.e. string1) 'length2' characters
		 	 * at a time for val2.str (i.e. string2), till the end
		 	 * of string1. 
			 */ 
			for(j = 0; j < length2; ++j)
			{
			    if (p1[j] != p2[j])
				break;
			}
			if (j == length2)
			{
			    Return_Unify_Integer(valp, tagp, i);
			}
			p1++;
		}
		/* if not found, fail. */	
		Fail_;
	}	
}