Esempio n. 1
0
int main(void)
{
  change_type(lock, $unlocked lock_t);
  lock;
  change_type(lock, $locked lock_t);
  lock;
  change_type(lock, $unlocked lock_t);
  lock;
}
Esempio n. 2
0
File: struct_nm.c Progetto: Selk/Dev
void		add_to_nm(t_nm **nm, struct nlist_64 *nl, void *start)
{
	t_nm	*add;
	t_nm	*current;

	current = *nm;
	add = (t_nm *)malloc(sizeof(t_nm));
	while (current->next)
		current = current->next;
	add->offset = nl->n_value;
	add->type = change_type(nl->n_type);
	add->str = (char *)start + nl->n_un.n_strx;
	current->next = add;
}
Esempio n. 3
0
static HRESULT builtin_propput(DispatchEx *This, func_info_t *func, DISPPARAMS *dp, IServiceProvider *caller)
{
    VARIANT *v, tmpv;
    IUnknown *iface;
    HRESULT hres;

    if(dp->cArgs != 1 || (dp->cNamedArgs == 1 && *dp->rgdispidNamedArgs != DISPID_PROPERTYPUT)
            || dp->cNamedArgs > 1) {
        FIXME("invalid args\n");
        return E_INVALIDARG;
    }

    if(!func->put_vtbl_off) {
        FIXME("No setter\n");
        return E_FAIL;
    }

    v = dp->rgvarg;
    if(func->prop_vt != VT_VARIANT && V_VT(v) != func->prop_vt) {
        hres = change_type(&tmpv, v, func->prop_vt, caller);
        if(FAILED(hres))
            return hres;
        v = &tmpv;
    }

    hres = IUnknown_QueryInterface(This->outer, tid_ids[func->tid], (void**)&iface);
    if(SUCCEEDED(hres)) {
        switch(func->prop_vt) {
#define CASE_VT(vt,type,access) \
        case vt: \
            hres = ((HRESULT (WINAPI*)(IUnknown*,type))((void**)iface->lpVtbl)[func->put_vtbl_off])(iface,access(v)); \
            break
        BUILTIN_TYPES_SWITCH;
#undef CASE_VT
        default:
            FIXME("Unimplemented vt %d\n", func->prop_vt);
            hres = E_NOTIMPL;
        }

        IUnknown_Release(iface);
    }

    if(v == &tmpv)
        VariantClear(v);
    return hres;
}
Esempio n. 4
0
void list_copy(caValue* source, caValue* dest)
{
    INCREMENT_STAT(ListSoftCopy);

    ca_assert(source->value_type->storageType == name_StorageTypeList);

    // prepare 'dest'
    change_type(dest, source->value_type);

    ListData* sourceData = (ListData*) source->value_data.ptr;

    if (sourceData == NULL)
        return;

    list_make_immutable(sourceData);
    list_incref(sourceData);

    dest->value_data.ptr = sourceData;
}
Esempio n. 5
0
static HRESULT invoke_builtin_function(DispatchEx *This, func_info_t *func, DISPPARAMS *dp, VARIANT *res, IServiceProvider *caller)
{
    VARIANT arg_buf[MAX_ARGS], *arg_ptrs[MAX_ARGS], *arg, retv, ret_ref, vhres;
    unsigned i, nconv = 0;
    IUnknown *iface;
    HRESULT hres;

    if(dp->cNamedArgs) {
        FIXME("Named arguments not supported\n");
        return E_NOTIMPL;
    }

    if(dp->cArgs != func->argc) {
        FIXME("Invalid argument count (expected %u, got %u)\n", func->argc, dp->cArgs);
        return E_INVALIDARG;
    }

    hres = IUnknown_QueryInterface(This->outer, tid_ids[func->tid], (void**)&iface);
    if(FAILED(hres))
        return hres;

    for(i=0; i < func->argc; i++) {
        arg = dp->rgvarg+dp->cArgs-i-1;
        if(func->arg_types[i] == V_VT(arg)) {
            arg_ptrs[i] = arg;
        }else {
            hres = change_type(arg_buf+nconv, arg, func->arg_types[i], caller);
            if(FAILED(hres))
                break;
            arg_ptrs[i] = arg_buf + nconv++;
        }
    }

    if(SUCCEEDED(hres)) {
        if(func->prop_vt == VT_VOID) {
            V_VT(&retv) = VT_EMPTY;
        }else {
            V_VT(&retv) = func->prop_vt;
            arg_ptrs[func->argc] = &ret_ref;
            V_VT(&ret_ref) = VT_BYREF|func->prop_vt;

            switch(func->prop_vt) {
#define CASE_VT(vt,type,access)                         \
            case vt:                                    \
                V_BYREF(&ret_ref) = &access(&retv);     \
                break
            BUILTIN_TYPES_SWITCH;
#undef CASE_VT
            default:
                assert(0);
            }
        }

        V_VT(&vhres) = VT_ERROR;
        hres = DispCallFunc(iface, func->call_vtbl_off*sizeof(void*), CC_STDCALL, VT_ERROR,
                    func->argc + (func->prop_vt == VT_VOID ? 0 : 1), func->arg_types, arg_ptrs, &vhres);
    }

    while(nconv--)
        VariantClear(arg_buf+nconv);
    IUnknown_Release(iface);
    if(FAILED(hres))
        return hres;
    if(FAILED(V_ERROR(&vhres)))
        return V_ERROR(&vhres);

    if(res)
        *res = retv;
    else
        VariantClear(&retv);
    return V_ERROR(&vhres);
}
Esempio n. 6
0
int ad_set(int argc, char **argv, AFPObj *obj)
{
    int c, firstarg;
    afpvol_t vol;
    struct stat st;
    int adflags = 0;
    struct adouble ad;

    while ((c = getopt(argc, argv, ":l:t:c:f:a:")) != -1) {
        switch(c) {
        case 'l':
            new_label = strdup(optarg);
            break;
        case 't':
            new_type = strdup(optarg);
            break;
        case 'c':
            new_creator = strdup(optarg);
            break;
        case 'f':
            new_flags = strdup(optarg);
            break;
        case 'a':
            new_attributes = strdup(optarg);
            break;
        case ':':
        case '?':
            usage_set();
            return -1;
            break;
        }

    }

    if (argc <= optind)
        exit(1);

    cnid_init();

    openvol(obj, argv[optind], &vol);
    if (vol.vol->v_path == NULL)
        exit(1);

    if (stat(argv[optind], &st) != 0) {
        perror("stat");
        exit(1);
    }

    if (S_ISDIR(st.st_mode))
        adflags = ADFLAGS_DIR;

    ad_init(&ad, vol.vol);

    if (ad_open(&ad, argv[optind], adflags | ADFLAGS_HF | ADFLAGS_CREATE | ADFLAGS_RDWR, 0666) < 0)
        goto exit;

    if (new_label)
        change_label(argv[optind], &vol, &st, &ad, new_label);
    if (new_type)
        change_type(argv[optind], &vol, &st, &ad, new_type);
    if (new_creator)
        change_creator(argv[optind], &vol, &st, &ad, new_creator);
    if (new_flags)
        change_flags(argv[optind], &vol, &st, &ad, new_flags);
    if (new_attributes)
        change_attributes(argv[optind], &vol, &st, &ad, new_attributes);

    ad_flush(&ad);
    ad_close(&ad, ADFLAGS_HF);

exit:
    closevol(&vol);

    return 0;
}
Esempio n. 7
0
int deal_card(int a[])
{
    int b[7]= {0},c[7]= {0},i,j=0,k=0;
    for(i=0; i<14; i++)
    {
        if(i%2==0)
        {
            switch(a[i])
            {
            case 65:
                b[j]=1;
                break;
            case 50:
                b[j]=2;
                break;
            case 51:
                b[j]=3;
                break;
            case 52:
                b[j]=4;
                break;
            case 53:
                b[j]=5;
                break;
            case 54:
                b[j]=6;
                break;
            case 55:
                b[j]=7;
                break;
            case 56:
                b[j]=8;
                break;
            case 57:
                b[j]=9;
                break;
            case 84:
                b[j]=10;
                break;
            case 74:
                b[j]=11;
                break;
            case 81:
                b[j]=12;
                break;
            case 75:
                b[j]=13;
                break;
            }
            j++;
        }
        else if(i%2==1)
        {
            switch(a[i])
            {
            case 67:
                c[k]=1;
                break;
            case 68:
                c[k]=2;
                break;
            case 72:
                c[k]=3;
                break;
            case 83:
                c[k]=4;
                break;
            }
            k++;
        }
    }

    int n,type0[5]= {0},number[5]= {0},flag=0;
    /*Straight flush*/
    for(i=0; i<3; i++)
    {
        flag=0;
        type0[0]=c[i];
        number[0]=b[i];
        for(j=i+1; j<7; j++)
        {
            if(type0[0]==c[j])
            {
                flag++;
                type0[flag]=c[j];
                number[flag]=b[j];
                if(flag==4)
                    break;
            }
        }
        if(flag==4)
        {
            if(number[0]+1==number[1]&&number[1]+1==number[2]&&number[2]+1==number[3]&&number[3]+1==number[4])
            {
                for(j=0; j<=4; j++)
                {
                    printf("%c%c ",change_number1(number[j]),change_type(type0[j]));
                }
                printf("Straight flush\n");
                return 9;
            }
            else if(number[0]==1&&number[1]==10&&number[2]==11&&number[3]==12&&number[4]==13)
            {
                printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(number[1]),change_type(type0[1]),change_number1(number[2]),change_type(type0[2]),change_number1(number[3]),change_type(type0[3]),change_number1(number[4]),change_type(type0[4]),change_number1(number[0]),change_type(type0[0]));
                printf("Straight flush\n");
                return 9;
            }
            break;
        }
    }
    n=4;
    while(n--)   /*Four of a kind*/
    {
        if(b[n]==b[n+1]&&b[n+1]==b[n+2]&&b[n+2]==b[n+3])
        {
            if(n==3)
            {
                printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[3]),change_type(c[3]),change_number1(b[4]),change_type(c[4]),change_number1(b[5]),change_type(c[5]),change_number1(b[6]),change_type(c[6]),change_number1(b[0]),change_type(c[0]));
                printf("Four of a kind\n");
                return 8;
                break;
            }
            else
            {
                for(i=n; i<=n+4; i++)
                {
                    printf("%c%c ",change_number1(b[n]),change_type(c[n]));
                }
                printf("Four of a kind\n");
                return 8;
                break;
            }
        }
        else
            continue;
    }
    for(i=0; i<=4; i++)   /*Full House*/
    {
        if(b[i]==b[i+1]&&b[i+1]==b[i+2])
        {
            for(j=i+3; j<=5; j++)
            {
                if(b[j]==b[j+1])
                {
                    printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[i]),change_type(c[i]),change_number1(b[i+1]),change_type(c[i+1]),change_number1(b[i+2]),change_type(c[i+2]),change_number1(b[j]),change_type(c[j]),change_number1(b[j+1]),change_type(c[j+1]));
                    printf("Full House\n");
                    return 7;
                    break;
                }
            }
            for(j=i-1; j>=1; j--)
            {
                if(b[j]==b[j-1])
                {
                    printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[i]),change_type(c[i]),change_number1(b[i+1]),change_type(c[i+1]),change_number1(b[i+2]),change_type(c[i+2]),change_number1(b[j]),change_type(c[j]),change_number1(b[j-1]),change_type(c[j-1]));
                    printf("Full House\n");
                    return 7;
                    break;
                }
            }
        }
    }
    /*Flush*/
    for(i=0; i<3; i++)
    {
        flag=0;
        type0[0]=c[i];
        number[0]=b[i];
        for(j=i+1; j<7; j++)
        {
            if(type0[0]==c[j])
            {
                flag++;
                type0[flag]=c[j];
                number[flag]=b[j];
            }
            if(flag==4)
                break;
        }
        if(flag==4)
        {
            for(j=0; j<=4; j++)
            {
                printf("%c%c ",change_number1(number[j]),change_type(type0[j]));
            }
            printf("Flush\n");
            return 6;
        }
    }
    /*Straight*/
    for(i=0; i<3; i++)
    {
        flag=0;
        number[0]=b[i];
        type0[0]=c[i];
        for(j=i+1; j<7; j++)
        {
            if(b[i]+1+flag==b[j])
            {
                flag++;
                number[flag]=b[j];
                type0[flag]=c[j];
            }
            if(flag==4)
                break;
        }
        if(flag==4)
        {
            for(j=0; j<=4; j++)
            {
                printf("%c%c ",change_number1(number[j]),change_type(type0[j]));
            }
            printf("Straight\n");
            return 5;
        }
        else if(number[0]==1&&number[1]==10&&number[2]==11&&number[3]==12&&number[4]==13)
        {
            printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(number[1]),change_type(type0[1]),change_number1(number[2]),change_type(type0[2]),change_number1(number[3]),change_type(type0[3]),change_number1(number[4]),change_type(type0[4]),change_number1(number[0]),change_type(type0[0]));
            printf("Straight\n");
            return 5;
        }
        break;
    }
    for(i=0; i<=4; i++)   /*Three of a kind*/
    {
        if(b[i]==b[i+1]&&b[i+1]==b[i+2])
        {
            if(i<=2)
            {
                printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[i]),change_type(c[i]),change_number1(b[i+1]),change_type(c[i+1]),change_number1(b[i+2]),change_type(c[i+2]),change_number1(b[i+3]),change_type(c[i+3]),change_number1(b[i+4]),change_type(c[i+4]));
                printf("Three of a kind\n");
                return 4;
                break;
            }
            else
            {
                printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[i]),change_type(c[i]),change_number1(b[i+1]),change_type(c[i+1]),change_number1(b[i+2]),change_type(c[i+2]),change_number1(b[i-1]),change_type(c[i-1]),change_number1(b[i-2]),change_type(c[i-2]));
                printf("Three of a kind\n");
                return 4;
                break;
            }
        }
    }
    for(i=0; i<=3; i++)   /*Two pairs*/
    {
        if(b[i]==b[i+1])
        {
            for(j=i+2; j<=5; j++)
            {
                if(b[j]==b[j+1])
                {
                    if(j==5&&i==3)
                    {
                        printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[i]),change_type(c[i]),change_number1(b[i+1]),change_type(c[i+1]),change_number1(b[j]),change_type(c[j]),change_number1(b[j+1]),change_type(c[j+1]),change_number1(b[0]),change_type(c[0]));
                        printf("Two pairs\n");
                        return 3;
                        break;
                    }
                    else if(j==5&&i!=3)
                    {
                        printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[i]),change_type(c[i]),change_number1(b[i+1]),change_type(c[i+1]),change_number1(b[j]),change_type(c[j]),change_number1(b[j+1]),change_type(c[j+1]),change_number1(b[i+2]),change_type(c[i+2]));
                        printf("Two pairs\n");
                        return 3;
                        break;
                    }
                    else
                    {
                        printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[i]),change_type(c[i]),change_number1(b[i+1]),change_type(c[i+1]),change_number1(b[j]),change_type(c[j]),change_number1(b[j+1]),change_type(c[j+1]),change_number1(b[j+2]),change_type(c[j+2]));
                        printf("Two pairs\n");
                        return 3;
                        break;
                    }
                }
            }
        }
    }
    for(i=0; i<=5; i++)   /*One pair*/
    {
        if(b[i]==b[i+1])
        {
            if(i>=3)
            {
                printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[i]),change_type(c[i]),change_number1(b[i+1]),change_type(c[i+1]),change_number1(b[0]),change_type(c[0]),change_number1(b[1]),change_type(c[1]),change_number1(b[2]),change_type(c[2]));
                printf("One pair\n");
                return 2;
                break;
            }
            else
            {
                printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[i]),change_type(c[i]),change_number1(b[i+1]),change_type(c[i+1]),change_number1(b[i+2]),change_type(c[i+2]),change_number1(b[i+3]),change_type(c[i+3]),change_number1(b[i+4]),change_type(c[i+4]));
                printf("One pair\n");
                return 2;
                break;
            }
        }
    }
    /*High Card*/
    printf("%c%c %c%c %c%c %c%c %c%c ",change_number1(b[6]),change_type(c[6]),change_number1(b[5]),change_type(c[5]),change_number1(b[4]),change_type(c[4]),change_number1(b[3]),change_type(c[3]),change_number1(b[2]),change_type(c[2]));
    printf("High Card\n");
    return 1;
}
Esempio n. 8
0
void set_term_ref(caValue* val, Term* term)
{
    change_type(val, &REF_T);
    val->value_data.ptr = term;
}
Esempio n. 9
0
void set_block(caValue* value, Block* block)
{
    change_type(value, TYPES.block);
    value->value_data.ptr = block;
}
Esempio n. 10
0
void set_opaque_pointer(caValue* value, void* addr)
{
    change_type(value, TYPES.opaque_pointer);
    value->value_data.ptr = addr;
}
Esempio n. 11
0
void set_float(caValue* value, float f)
{
    change_type(value, TYPES.float_type);
    value->value_data.asfloat = f;
}
Esempio n. 12
0
void set_int(caValue* value, int i)
{
    change_type(value, TYPES.int_type);
    value->value_data.asint = i;
}
Esempio n. 13
0
void set_bool(caValue* value, bool b)
{
    change_type(value, TYPES.bool_type);
    value->value_data.asbool = b;
}