rb_define_const(rb_mArchive, “COMPRESSION_PROGRAM”, INT2NUM(ARCHIVE_COMPRESSION_PROGRAM)); rb_define_const(rb_mArchive, “COMPRESSION_LZMA”, INT2NUM(ARCHIVE_COMPRESSION_LZMA));
static VALUE rb_libarchive_reader_s_open_filename(int argc, VALUE *argv, VALUE self) { VALUE v_filename, v_compression, v_format; const char *filename = NULL; int compression = -1, format = -1; const char *cmd = NULL; rb_scan_args(argc, argv, "12", &v_filename, &v_compression, &v_format); Check_Type(v_filename, T_STRING); filename = RSTRING_PTR(v_filename); if (T_STRING == TYPE(v_compression)) { compression = -1; cmd = RSTRING_PTR(v_compression); } else if (!NIL_P(v_compression)) { compression = NUM2INT(v_compression); } if (!NIL_P(v_format)) { format = NUM2INT(v_format); } return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_filename0, (void *) filename, compression, format, cmd); }
static VALUE rb_libarchive_reader_s_open_memory(int argc, VALUE *argv, VALUE self) { VALUE v_memory, v_compression, v_format; int compression = -1, format = -1; const char *cmd = NULL; rb_scan_args(argc, argv, "12", &v_memory, &v_compression, &v_format); Check_Type(v_memory, T_STRING); if (T_STRING == TYPE(v_compression)) { compression = -1; cmd = RSTRING_PTR(v_compression); } else if (!NIL_P(v_compression)) { compression = NUM2INT(v_compression); } if (!NIL_P(v_format)) { format = NUM2INT(v_format); } return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_memory0, (void *) v_memory, compression, format, cmd); }
VALUE rb_libarchive_s_version_number(VALUE self) { #if ARCHIVE_VERSION >= 2005000 return INT2NUM(archive_version_number()); #else return INT2NUM(archive_version_stamp()); #endif }
VALUE rb_libarchive_s_version_string(VALUE self) { #if ARCHIVE_VERSION_NUMBER >= 2005000 return rb_str_new2(archive_version_string()); #else return rb_str_new2(archive_version()); #endif }
static VALUE rb_libarchive_writer_s_open_filename(VALUE self, VALUE v_filename, VALUE v_compression, VALUE v_format) { const char *filename = NULL; int compression, format; const char *cmd = NULL; Check_Type(v_filename, T_STRING); if (RSTRING_LEN(v_filename) < 1) { rb_raise(rb_eArchiveError, "Open writer failed: No such file or directory"); } filename = RSTRING_PTR(v_filename); if (T_STRING == TYPE(v_compression)) { compression = -1; cmd = RSTRING_PTR(v_compression); } else { compression = NUM2INT(v_compression); } format = NUM2INT(v_format); return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_filename0, (void *) filename, compression, format, cmd); }
static VALUE rb_libarchive_writer_s_open_memory(VALUE self, VALUE v_memory, VALUE v_compression, VALUE v_format) { int compression, format; const char *cmd = NULL; Check_Type(v_memory, T_STRING); if (T_STRING == TYPE(v_compression)) { compression = -1; cmd = RSTRING_PTR(v_compression); } else { compression = NUM2INT(v_compression); } format = NUM2INT(v_format); return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_memory0, (void *) v_memory, compression, format, cmd); }
Generated with the Darkfish Rdoc Generator 2.