static JSVAL net_socketpair(JSARGS args) { int sv[2]; if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1) { return False(); } JSARRAY a = Array::New(); a->Set(0, Integer::New(sv[0])); a->Set(1, Integer::New(sv[1])); return a; }
static JSVAL fetch_lengths(JSARGS args) { HandleScope scope; MYSQL_RES *result = (MYSQL_RES *) args[0]->IntegerValue(); unsigned int num_fields = mysql_num_fields(result); unsigned long *lengths = mysql_fetch_lengths(result); JSARRAY a = Array::New();; for (unsigned int i=0; i<num_fields; i++) { a->Set(i, Integer::New(lengths[i])); } return scope.Close(a); }
static JSVAL fetch_fields(JSARGS args) { HandleScope scope; MYSQL_RES *result = (MYSQL_RES *) args[0]->IntegerValue(); unsigned int num_fields = mysql_num_fields(result); MYSQL_FIELD *fields = mysql_fetch_fields(result); JSARRAY a = Array::New();; for (unsigned int i=0; i<num_fields; i++) { JSOBJ o = Object::New(); MakeField(&fields[i], o); a->Set(i, o); } return scope.Close(a); }