/*
- * $Id: ext.c 28 2005-04-11 20:58:23Z tilman $
+ * $Id: ext.c 29 2005-04-12 17:07:48Z tilman $
*
* Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
*
1, INT2FIX (0)) == Qtrue) \
rb_raise (rb_eArgError, "key must not contain binary zeroes");
+#define CHECK_CLOSED(ef) \
+ if (!*(ef)) \
+ rb_raise (rb_eIOError, "closed stream");
+
static VALUE c_close (VALUE self);
static void
Eet_File **ef = NULL;
Data_Get_Struct (self, Eet_File *, ef);
+ CHECK_CLOSED (ef);
- if (!*ef)
- rb_raise (rb_eIOError, "closed stream");
- else {
- eet_close (*ef);
- *ef = NULL;
+ eet_close (*ef);
+ *ef = NULL;
- eet_shutdown ();
- }
+ eet_shutdown ();
return self;
}
int i, count = 0;
Data_Get_Struct (self, Eet_File *, ef);
-
- if (!*ef)
- rb_raise (rb_eIOError, "closed stream");
+ CHECK_CLOSED (ef);
switch (eet_mode_get (*ef)) {
case EET_FILE_MODE_READ:
char *tmp;
Data_Get_Struct (self, Eet_File *, ef);
-
- if (!*ef)
- rb_raise (rb_eIOError, "closed stream");
+ CHECK_CLOSED (ef);
CHECK_KEY (key);
int size = 0;
Data_Get_Struct (self, Eet_File *, ef);
-
- if (!*ef)
- rb_raise (rb_eIOError, "closed stream");
+ CHECK_CLOSED (ef);
CHECK_KEY (key);
int n;
Data_Get_Struct (self, Eet_File *, ef);
-
- if (!*ef)
- rb_raise (rb_eIOError, "closed stream");
+ CHECK_CLOSED (ef);
rb_scan_args (argc, argv, "21", &key, &buf, &comp);
int w = 0, h = 0, has_alpha = 0, level = 0, quality = 0, lossy = 0;
Data_Get_Struct (self, Eet_File *, ef);
-
- if (!*ef)
- rb_raise (rb_eIOError, "closed stream");
+ CHECK_CLOSED (ef);
CHECK_KEY (key);
int n, lossy = 0, level = 9, quality = 100;
Data_Get_Struct (self, Eet_File *, ef);
-
- if (!*ef)
- rb_raise (rb_eIOError, "closed stream");
+ CHECK_CLOSED (ef);
rb_scan_args (argc, argv, "42", &key, &buf, &w, &h, &has_alpha,
&comp);