예제 #1
0
파일: record.c 프로젝트: fanyang01/sql
int update_record(ALLOC * a, table_t * t, handle_t h, record_t * r)
{
    unsigned char *buf, *p;
    record_t *old;
    size_t len = 0;
    int ret;

    if (_validate_record(a, t, r) < 0)
        return -1;
    if ((old = read_record(a, t, h)) == NULL)
        return -1;

    for (int i = 0; i < t->ncols; i++) {
        if (t->cols[i].unique == COL_NORMAL)
            continue;
        if (_equal(&old->vals[i], &r->vals[i]))
            continue;
        if (t->cols[i].index != 0) {
            if (index_exist(t->cols[i].idx, &r->vals[i])) {
                xerrno = ERR_UNIQ;
                goto Error;
            }
            continue;
        }
        for (handle_t h = t->head; h != 0;) {
            record_t *x;
            int eq;

            if ((x = read_record(a, t, h)) == NULL)
                goto Error;
            h = x->next;
            eq = _equal(&x->vals[i], &r->vals[i]);
            _free_record(x);
            if (eq) {
                xerrno = ERR_UNIQ;
                goto Error;
            }
        }
    }

    if ((buf = read_blk(a, h, NULL, &len)) == NULL)
        goto Error;
    _free_record(old);

    p = record2b_skip(buf, t, r);
    ret = realloc_blk(a, h, buf, p - buf);
    buf_put(a, buf);
    return ret;
Error:
    preserve_errno(_free_record(old));
    return -1;
}
예제 #2
0
파일: abuse.c 프로젝트: yixuanzi/blocksword
int callfunc(struct rule *r,struct function *f,void *dp,int type){
	int i=0;
	int fid=f->fid;	
	for(i=0;i<10;i++){
		if(!fid)
			break;
		switch (fid)
		{
		case 1:
			_addself(r,f->pt);
			break;
		case 2:
			_delself(r,f->pt);
			break;
		case 3:
			_greater(r,f->pt);
			break;
		case 4:
			_less(r,f->pt);
			break;
		case 5:
			_equal(r,f->pt);
			break;
		case 6:
			_unequal(r,f->pt);
			break;
		case FUNC_LOG:
			_log(r,f->pt);
		case FUNC_ALERT:
			_alert(r,f->pt);
		
		}
	}
}
예제 #3
0
파일: scheme.c 프로젝트: xitscj/moby-scheme
bool _equal(val_t a, val_t b) {
    if (_eqv(a, b)) return true;

    if (a -> type == b -> type)
        switch (a -> type) {
        case STRING:
            return (strcmp(a -> data.string, b -> data.string) == 0);
        case STRUCT: {
            struct_t *sa = a -> data.struct_, *sb = b -> data.struct_;
            if (sa -> type == sb -> type && sa -> size == sb -> size) {
                for (int i = 0; i < sa -> size; i++)
                    if (!_equal(sa -> data[i], sb -> data[i])) return false;
                return true;
            }
            else return false;
        }
        case SB: {
            sb_t *sba = a -> data.sb, *sbb = b -> data.sb;
            if( sba -> size == sbb -> size) { /* Technically, this test isn't needed but it is included for consistency's sake */
                for (int i = 0; i < sba -> size; i++)
                    if(sba -> data[i] != sbb -> data[i]) return false;
                return true;
            }
            else return false;
        }
        default:
            return false;
        }
    else return false;
}
예제 #4
0
파일: record.c 프로젝트: fanyang01/sql
int _validate_unique(ALLOC * a, table_t * t, record_t * r)
{
    for (int i = 0; i < t->ncols; i++) {
        if (t->cols[i].unique == COL_NORMAL)
            continue;
        // primary or unique
        // use index
        if (t->cols[i].index != 0) {
            if (index_exist(t->cols[i].idx, &r->vals[i])) {
                xerrno = ERR_UNIQ;
                return -1;
            }
            continue;
        }
        // full scan
        for (handle_t h = t->head; h != 0;) {
            record_t *x;
            int eq;

            if ((x = read_record(a, t, h)) == NULL)
                return -1;
            h = x->next;
            eq = _equal(&x->vals[i], &r->vals[i]);
            _free_record(x);
            if (eq) {
                xerrno = ERR_UNIQ;
                return -1;
            }
        }
    }
    return 0;
}
예제 #5
0
 inline bool operator !=(const value_t &other) const
 {
     return _type != other._type ? !_equal(other): false;
 }
예제 #6
0
 bool operator!=(const fwd_list_iterator<__Type>& _Rhs) const { return !(_equal(_Rhs)); }
예제 #7
0
 bool operator==(const fwd_list_iterator<__Type>& _Rhs) const { return _equal(_Rhs); }
예제 #8
0
SCODE GadgetProvider::CreateInstanceEnumAsync(
    const BSTR className,
    long flags,
    IWbemContext* context,
    IWbemObjectSink FAR* handler)
{
    // Check credentials:

    HRESULT hr = CoImpersonateClient();

    if (FAILED(hr))
    {
        handler->SetStatus(0, hr, NULL, NULL);
        return hr;
    }

    if (_impersonateLevel() < RPC_C_IMP_LEVEL_IMPERSONATE)
    {
        CoRevertToSelf();
        hr = WBEM_E_ACCESS_DENIED;
        handler->SetStatus(0, hr, NULL, NULL);
        return hr;
    }

    // Check parameters:

    if (!handler || !_nameSpace)
    {
        return WBEM_E_INVALID_PARAMETER;
    }

    if (_equal(className, L"Gadget"))
    {
        for (size_t i = 0; i < _numDefs; i++)
        {
            IWbemClassObject FAR* newInstance = NULL;

            SCODE sc = _makeGadget(
                _nameSpace,
                _defs[i].key,
                _defs[i].value,
                &newInstance,
                className,
                context);

            if (sc != S_OK)
            {
                handler->SetStatus(0,sc,NULL, NULL);
                return sc;
            }

            handler->Indicate(1, &newInstance);
            newInstance->Release();
        }
    }

    // Set status

    handler->SetStatus(0, S_OK, NULL, NULL);
    return S_OK;
}
예제 #9
0
파일: string.hpp 프로젝트: jashook/ev6
 bool operator!=(const string& _Rhs) { return !_equal(_Rhs); }
예제 #10
0
파일: string.hpp 프로젝트: jashook/ev6
 bool operator==(const string& _Rhs) { return _equal(_Rhs); }
예제 #11
0
 bool operator!=(const avl_tree_iter< __Key, __Value, __Compare >& _Rhs) const { return !(_equal(_Rhs)); }
예제 #12
0
 bool operator()(K const& k, Pair const& p) const { return _equal(k, p.first); }