void ring_murmurhash3_x64_128(void *pPointer) { char *key = NULL; int keylen; int seed = 0; uint64_t out[2]; int ret_type = 0; List *tmp_list, *ret_val; if (RING_API_PARACOUNT < 2 || RING_API_PARACOUNT > 3) { RING_API_ERROR(RING_API_MISS2PARA); return ; } if (!RING_API_ISSTRING(1)) { RING_API_ERROR("murmurhash3_x64_128 expects the first parameter to be a string"); return; } if (!RING_API_ISNUMBER(2)) { RING_API_ERROR("murmurhash3_x64_128 expects the first parameter to be an integer"); return; } key = RING_API_GETSTRING(1); keylen = strlen(key); seed = RING_API_GETNUMBER(2); if (RING_API_PARACOUNT == 3) { if (RING_API_ISNUMBER(3)) { ret_type = RING_API_GETNUMBER(3); if (!is_bool(ret_type)) { RING_API_ERROR("Third parameter should be boolean value\n"); } } else { RING_API_ERROR("murmurhash3_x64_128 expects the third parameter to be an integer\n"); } } MurmurHash3_x64_128(key, keylen, seed, out); ret_val = RING_API_NEWLIST; tmp_list = ring_list_newlist_gc(((VM *)pPointer)->pRingState, ret_val); for (int i = 0; i < 2; i++) { if (ret_type) { char tmp[50]; LONG2HEX(tmp, out[i]); ring_list_addstring2(tmp_list, (char*) tmp, strlen((char *) tmp)); } else { ring_list_addint(tmp_list, out[i]); } } RING_API_RETLIST(ret_val); }
void ring_vm_odbc_autocommit ( void *pPointer ) { ring_odbc *pODBC ; SQLRETURN ret ; if ( RING_API_PARACOUNT != 2 ) { RING_API_ERROR(RING_API_MISS2PARA); return ; } if ( RING_API_ISPOINTER(1) && RING_API_ISNUMBER(2) ) { pODBC = (ring_odbc *) RING_API_GETCPOINTER(1,RING_VM_POINTER_ODBC) ; if ( pODBC == NULL ) { return ; } if ( RING_API_GETNUMBER(2) == 1 ) { ret = SQLSetConnectAttr(pODBC->dbc,SQL_ATTR_AUTOCOMMIT, ( SQLPOINTER ) SQL_AUTOCOMMIT_ON,0); } else { ret = SQLSetConnectAttr(pODBC->dbc,SQL_ATTR_AUTOCOMMIT, ( SQLPOINTER ) SQL_AUTOCOMMIT_OFF,0); } if ( SQL_SUCCEEDED(ret) ) { RING_API_RETNUMBER(1); } else { RING_API_RETNUMBER(0); } } else { RING_API_ERROR(RING_API_BADPARATYPE); } }
void ring_murmurhash1_aligned(void *pPointer) { char *key = NULL; int keylen; int seed = 0; uint32_t out; int ret_type = 0; if (RING_API_PARACOUNT < 2 || RING_API_PARACOUNT > 3) { RING_API_ERROR(RING_API_MISS2PARA); return ; } if (!RING_API_ISSTRING(1)) { RING_API_ERROR("murmurhash1_aligned expects the first parameter to be a string"); return; } if (!RING_API_ISNUMBER(2)) { RING_API_ERROR("murmurhash1_aligned expects the first parameter to be an integer"); return; } key = RING_API_GETSTRING(1); keylen = strlen(key); seed = RING_API_GETNUMBER(2); if (RING_API_PARACOUNT == 3) { if (RING_API_ISNUMBER(3)) { ret_type = RING_API_GETNUMBER(3); if (!is_bool(ret_type)) { RING_API_ERROR("Third parameter should be boolean value\n"); } } else { RING_API_ERROR("murmurhash1_aligned expects the third parameter to be an integer\n"); } } out = MurmurHash1Aligned(key, keylen, seed); MH_RETURN_INT(out, ret_type); }
void ring_vm_odbc_getdata ( void *pPointer ) { ring_odbc *pODBC ; SQLINTEGER indicator ; SQLUSMALLINT i ; SQLRETURN ret ; char *buf, *buf2 ; int nSize ; if ( RING_API_PARACOUNT != 2 ) { RING_API_ERROR(RING_API_MISS2PARA); return ; } if ( RING_API_ISPOINTER(1) && RING_API_ISNUMBER(2) ) { pODBC = (ring_odbc *) RING_API_GETCPOINTER(1,RING_VM_POINTER_ODBC) ; if ( pODBC == NULL ) { return ; } i = (SQLUSMALLINT) RING_API_GETNUMBER(2) ; nSize = 512 ; buf = (char *) malloc(nSize) ; if ( buf == NULL ) { RING_API_ERROR(RING_OOM); return ; } ret = SQLGetData(pODBC->stmt, i, SQL_C_CHAR,buf, nSize, &indicator); if ( SQL_SUCCEEDED(ret) ) { if ( indicator == SQL_NULL_DATA ) { strcpy(buf,"NULL"); nSize = 4 ; } else if ( (ret == SQL_SUCCESS_WITH_INFO) && (indicator > 512) ) { nSize = 512+indicator ; buf2 = (char *) realloc(buf , nSize); if ( buf2 == NULL ) { RING_API_ERROR(RING_OOM); return ; } buf = buf2 ; SQLGetData(pODBC->stmt, i, SQL_C_CHAR,buf+511, indicator+1, &indicator); nSize = 511+indicator ; } else { nSize = indicator ; } RING_API_RETSTRING2(buf,nSize); } else { RING_API_RETNUMBER(0); } free( buf ) ; } else { RING_API_ERROR(RING_API_BADPARATYPE); } }
void ring_vm_refmeta_setattribute ( void *pPointer ) { List *pList ; char *cStr ; int x ; if ( RING_API_PARACOUNT != 3 ) { RING_API_ERROR(RING_API_BADPARACOUNT); return ; } if ( RING_API_ISLIST(1) && RING_API_ISSTRING(2) ) { pList = RING_API_GETLIST(1) ; if ( ring_vm_oop_isobject(pList) ) { pList = ring_list_getlist(pList,RING_OBJECT_OBJECTDATA); cStr = RING_API_GETSTRING(2) ; ring_string_lower(cStr); for ( x = 1 ; x <= ring_list_getsize(pList) ; x++ ) { if ( strcmp(ring_list_getstring(ring_list_getlist(pList,x),RING_VAR_NAME),cStr) == 0 ) { pList = ring_list_getlist(pList,x) ; if ( RING_API_ISNUMBER(3) ) { ring_list_setdouble(pList,RING_VAR_VALUE,RING_API_GETNUMBER(3)); } else if ( RING_API_ISSTRING(3) ) { ring_list_setstring2(pList,RING_VAR_VALUE,RING_API_GETSTRING(3),RING_API_GETSTRINGSIZE(3)); } else if ( RING_API_ISLIST(3) ) { ring_list_setlist(pList,RING_VAR_VALUE); pList = ring_list_getlist(pList,RING_VAR_VALUE); ring_list_deleteallitems(pList); ring_list_copy(pList,RING_API_GETLIST(3)); } return ; } } RING_API_ERROR("Error : Property is not found!"); } else { RING_API_ERROR(RING_API_BADPARATYPE); } } else { RING_API_ERROR(RING_API_BADPARATYPE); } }