Пример #1
0
int
p_session_start(
 	        /* + */ value v_session, type t_session,
		/* + */ value v_username, type t_username,
		/* + */ value v_host, type t_host,
		/* + */ value v_password, type t_password,
		/* + */ value v_opts, type t_opts
		)
{
        session_t * session;

	Get_Typed_Object(v_session,t_session,&session_handle_tid,session);

	Check_String(t_username);
	Check_String(t_host);
	Check_String(t_password);
	Check_Structure(t_opts);
		
	if ( session_start( session,
			    StringStart(v_username),
			    StringStart(v_host),
			    StringStart(v_password),
			    v_opts) )
	    Bip_Error(dbi_errno);

	Succeed;

}
Пример #2
0
static int
p_shelf_create2(value vinit, type tinit, value vbag, type tbag)
{
    pword bag;
    pword *pheap, *pglobal;
    t_heap_array *obj;
    int i, err;

    Check_Ref(tbag);
    Check_Structure(tinit);
    pglobal = vinit.ptr;
    i = DidArity(pglobal->val.did);

    /* INSTANCE INITIALISATION */
    obj = (t_heap_array *) hg_alloc_size(
			    sizeof(t_heap_array) + i*sizeof(pword));
    obj->ref_ctr = 1;
    pheap = obj->array;
    pheap[0] = pglobal[0];
    for (; i > 0; --i)
    {
	pword *parg = &pglobal[i];
	Dereference_(parg);
	err = create_heapterm(&pheap[i], parg->val, parg->tag);
	Return_If_Not_Success(err);
    }
    bag = ec_handle(&heap_array_tid, (t_ext_ptr) obj);
    Return_Unify_Pw(vbag, tbag, bag.val, bag.tag);
}
Пример #3
0
int
p_transform(value val1, type tag1,
	value val2, type tag2)
{
        pword     *p = Gbl_Tg;
        dident    did1;    /* the DID of the structure */
        int       arity;      /* its arity */
        int       i;

        /* the first argument must be a structure */
        Check_Structure(tag1);
        /* the second argument must be a structure or a variable */
        Check_Output_Structure(tag2);
        /* val1 points to the functor */
        did1 = val1.ptr->val.did;
        arity = DidArity(did1);
        /* reserve space for the functor and (arity + 1) args */
        Gbl_Tg += arity + 2;
        /* insert the functor - the same name and higher arity */
        p[0].tag.kernel = TDICT;
        p[0].val.did = Did(DidName(did1), arity + 1);
        /* copy the arguments */
        for (i = 1; i <= arity; i++)
        {
                p[i].tag.all = val1.ptr[i].tag.all;
                p[i].val.all = val1.ptr[i].val.all;
                /* on some machines use p[i] = val1.ptr[i] */
        }
        /* now create the free variable in the last argument;
         * it is a self-reference
         */
        p[arity + 1].tag.kernel = TREF;
        p[arity + 1].val.ptr = p + (arity + 1);
        /* and unify with the second argument */
        Return_Unify_Structure(val2, tag2, p);
}