Changeset 28994
- Timestamp:
- 01/25/09 12:02:21 (4 years ago)
- Location:
- lang/ruby/libarchive/trunk/ext
- Files:
-
- 2 modified
-
libarchive_reader.c (modified) (6 diffs)
-
libarchive_writer.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/libarchive/trunk/ext/libarchive_reader.c
r28539 r28994 21 21 } 22 22 23 static VALUE rb_libarchive_reader_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format ) {23 static VALUE rb_libarchive_reader_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format, const char *cmd) { 24 24 VALUE reader; 25 25 struct rb_libarchive_archive_container *p; … … 32 32 } 33 33 34 if (compression != -1) { 34 if (cmd != NULL) { 35 r = archive_read_support_compression_program(p->ar, cmd); 36 } else if (compression != -1) { 35 37 r = archive_read_support_compression(p->ar, compression); 36 38 } else { … … 101 103 const char *filename = NULL; 102 104 int compression = -1, format = -1; 105 const char *cmd; 103 106 rb_scan_args(argc, argv, "12", &v_filename, &v_compression, &v_format); 104 107 Check_Type(v_filename, T_STRING); 105 108 filename = RSTRING_PTR(v_filename); 106 109 107 if (!NIL_P(v_compression)) { 110 if (T_STRING == TYPE(v_compression)) { 111 compression = -1; 112 cmd = RSTRING_PTR(v_compression); 113 } else if (!NIL_P(v_compression)) { 108 114 compression = NUM2INT(v_compression); 109 115 } … … 113 119 } 114 120 115 return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_filename0, (void *) filename, compression, format );121 return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_filename0, (void *) filename, compression, format, cmd); 116 122 } 117 123 … … 125 131 VALUE v_memory, v_compression, v_format; 126 132 int compression = -1, format = -1; 133 const char *cmd; 127 134 rb_scan_args(argc, argv, "12", &v_memory, &v_compression, &v_format); 128 135 Check_Type(v_memory, T_STRING); 129 136 130 if (!NIL_P(v_compression)) { 137 if (T_STRING == TYPE(v_compression)) { 138 compression = -1; 139 cmd = RSTRING_PTR(v_compression); 140 } else if (!NIL_P(v_compression)) { 131 141 compression = NUM2INT(v_compression); 132 142 } … … 136 146 } 137 147 138 return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_memory0, (void *) v_memory, compression, format );148 return rb_libarchive_reader_s_open0(rb_libarchive_reader_s_open_memory0, (void *) v_memory, compression, format, cmd); 139 149 } 140 150 -
lang/ruby/libarchive/trunk/ext/libarchive_writer.c
r28542 r28994 21 21 } 22 22 23 static VALUE rb_libarchive_writer_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format ) {23 static VALUE rb_libarchive_writer_s_open0(int (*archive_open)(struct rb_libarchive_archive_container *, void *), void *arg, int compression, int format, const char *cmd) { 24 24 VALUE writer; 25 25 struct rb_libarchive_archive_container *p; 26 int r; 26 27 writer = rb_funcall(rb_cArchiveWriter, rb_intern("new"), 0); 27 28 Data_Get_Struct(writer, struct rb_libarchive_archive_container, p); … … 31 32 } 32 33 33 if (archive_write_set_compression(p->ar, compression) != ARCHIVE_OK) { 34 if (cmd != NULL) { 35 r = archive_write_set_compression_program(p->ar, cmd); 36 } else { 37 r = archive_write_set_compression(p->ar, compression); 38 } 39 40 if (r != ARCHIVE_OK) { 34 41 char error_string[BUFSIZ]; 35 42 archive_copy_error_string(p->ar, error_string, BUFSIZ); … … 77 84 const char *filename = NULL; 78 85 int compression, format; 86 const char *cmd = NULL; 79 87 Check_Type(v_filename, T_STRING); 80 88 … … 84 92 85 93 filename = RSTRING_PTR(v_filename); 86 compression = NUM2INT(v_compression); 94 95 if (T_STRING == TYPE(v_compression)) { 96 compression = -1; 97 cmd = RSTRING_PTR(v_compression); 98 } else { 99 compression = NUM2INT(v_compression); 100 } 101 102 87 103 format = NUM2INT(v_format); 88 return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_filename0, (void *) filename, compression, format );104 return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_filename0, (void *) filename, compression, format, cmd); 89 105 } 90 106 … … 98 114 static VALUE rb_libarchive_writer_s_open_memory(VALUE self, VALUE v_memory, VALUE v_compression, VALUE v_format) { 99 115 int compression, format; 116 const char *cmd = NULL; 100 117 Check_Type(v_memory, T_STRING); 101 compression = NUM2INT(v_compression); 118 119 if (T_STRING == TYPE(v_compression)) { 120 compression = -1; 121 cmd = RSTRING_PTR(v_compression); 122 } else { 123 compression = NUM2INT(v_compression); 124 } 125 102 126 format = NUM2INT(v_format); 103 return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_memory0, (void *) v_memory, compression, format );127 return rb_libarchive_writer_s_open0(rb_libarchive_writer_s_open_memory0, (void *) v_memory, compression, format, cmd); 104 128 } 105 129
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)