static inline M* HANDLE (Handle<Value>v) { if (v->IsNull()) { ThrowException(String::New("Handle is NULL")); return NULL; } return (M *) JSEXTERN(v); }
static inline STATE* log_HANDLE (Handle<Value>v) { if (v->IsNull()) { ThrowException(String::New("Handle is NULL")); return NULL; } STATE *state = (STATE *) JSEXTERN(v); return state; }
static JSVAL popen_puts (JSARGS args) { HandleScope scope; FILE *fp = (FILE *) JSEXTERN(args[0]); String::Utf8Value s(args[1]->ToString()); if (fputs(*s, fp) == EOF) { return scope.Close(False()); } return scope.Close(True()); }
static JSVAL popen_close (JSARGS args) { HandleScope scope; FILE *fp = (FILE *) JSEXTERN(args[0]); #ifdef WIN32 fclose(fp); #else pclose(fp); #endif return Undefined(); }
static JSVAL popen_gets (JSARGS args) { HandleScope scope; FILE *fp = (FILE *) JSEXTERN(args[0]); int size = 4096; if (args.Length() > 1) { size = args[1]->IntegerValue(); } char *buf = new char[size]; char *result = fgets(buf, size, fp); if (!result) { delete [] buf; return scope.Close(False()); } Handle<String>s = String::New(buf); delete [] buf; return scope.Close(s); }
static SFTP *HANDLE (Handle<Value> arg) { return (SFTP *) JSEXTERN(arg); }
static SSH2 *HANDLE(Handle<Value> arg) { return (SSH2 *)JSEXTERN(arg); }