Added file_fh() allowing external modules to obtain FILE * associated with
authorMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 26 Sep 2006 11:40:08 +0000 (11:40 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Tue, 26 Sep 2006 11:40:08 +0000 (11:40 +0000)
a File object.

mmsoftware/js/classes/js_file.c
mmsoftware/js/classes/js_file.h

index a2ed596..c587f43 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: js_file.c,v 1.1 2006/09/25 23:06:23 mmondor Exp $ */
+/* $Id: js_file.c,v 1.2 2006/09/26 11:40:08 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -220,6 +220,23 @@ err:
        return NULL;
 }
 
+/*
+ * Allows external modules to obtain FILE * associated with a File
+ */
+FILE *
+file_fh(JSContext *cx, JSObject *o)
+{
+       file_t  *f = NULL;
+
+       assert(cx != NULL && f != NULL);
+
+       f = JS_GetInstancePrivate(cx, o, &file_class, NULL);
+       assert(f != NULL);
+
+       return f->fh;
+}
+
+
 
 /*
  * File object control
index 09a342d..29a6b69 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: js_file.h,v 1.1 2006/09/25 23:06:23 mmondor Exp $ */
+/* $Id: js_file.h,v 1.2 2006/09/26 11:40:08 mmondor Exp $ */
 
 /*
  * Copyright (c) 2006, Matthew Mondor
@@ -13,5 +13,6 @@
 extern JSObject        *js_InitFileClass(JSContext *, JSObject *);
 
 extern JSObject        *file_new(JSContext *, FILE *, int);
+extern FILE    *file_fh(JSContext *, JSObject *);
 
 #endif