[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Momonga-devel.en:00038] {ruby-rpm} patch for pointer changes



Author: Daniel Mclellan <raijin>
Date: Wed May 20 16:29:28 EDT 2009

Modified: ruby-rpm-1.2.3/ext/rpm/package.c

Log: changes for API changes in pointer and length values

--- ruby-rpm/BUILD/ruby-rpm-1.2.3/ext/rpm/package.c	2009-05-20
15:36:48.223136366 -0400
+++ ruby19-rpm/BUILD/ruby-rpm-1.2.3/ext/rpm/package.c	2009-05-20
14:30:44.179479905 -0400
@@ -111,11 +111,11 @@
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}

 	hdr = headerNew();
-        headerAddEntry(hdr,RPMTAG_NAME,RPM_STRING_TYPE,RSTRING_PTR(name),1);
-        headerAddEntry(hdr,RPMTAG_VERSION,RPM_STRING_TYPE,RSTRING_PTR(rpm_version_get_v(version)),1);
-        headerAddEntry(hdr,RPMTAG_RELEASE,RPM_STRING_TYPE,RSTRING_PTR(rpm_version_get_r(version)),1);
+        headerAddEntry(hdr,RPMTAG_NAME,RPM_STRING_TYPE,RSTRING(name)->ptr,1);
+        headerAddEntry(hdr,RPMTAG_VERSION,RPM_STRING_TYPE,RSTRING(rpm_version_get_v(version))->ptr,1);
+        headerAddEntry(hdr,RPMTAG_RELEASE,RPM_STRING_TYPE,RSTRING(rpm_version_get_r(version))->ptr,1);
         if(!NIL_P(rpm_version_get_e(version))){
 		int e = NUM2INT(rpm_version_get_e(version));
         	headerAddEntry(hdr,RPMTAG_EPOCH,RPM_INT32_TYPE,&e,1);
 	}
@@ -134,12 +134,12 @@
 	if (TYPE(filename) != T_STRING) {
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}

-	fd = Fopen(RSTRING_PTR(filename), "r");
+	fd = Fopen(RSTRING(filename)->ptr, "r");
 	if (!fd) {
 		rb_raise(rb_eRuntimeError, "can not open file %s",
-				 RSTRING_PTR(filename));
+				 RSTRING(filename)->ptr);
 	}
 	rc = rpmReadPackageInfo(fd, &sigs, &hdr);
 	Fclose(fd);

@@ -188,17 +188,17 @@

 	Check_Type(str, T_STRING);

 	temp = ruby_rpm_make_temp_name();
-	fd = Fopen(RSTRING_PTR(temp), "wb+");
-	Fwrite(RSTRING_PTR(str), RSTRING_LEN(str), 1, fd);
+	fd = Fopen(RSTRING(temp)->ptr, "wb+");
+	Fwrite(RSTRING(str)->ptr, RSTRING(str)->len, 1, fd);
 	Fseek(fd, 0, SEEK_SET);
 	hdr = headerRead(fd, HEADER_MAGIC_YES);
 	Fclose(fd);
 #if RPM_VERSION(4,6,0) <= RPM_VERSION_CODE
-	unlink(RSTRING_PTR(temp));
+	unlink(RSTRING(temp)->ptr);
 #else
-	Unlink(RSTRING_PTR(temp));
+	Unlink(RSTRING(temp)->ptr);
 #endif

 	if (!hdr) {
 		rb_raise(rb_eArgError, "unable load RPM::Package");
@@ -255,10 +255,10 @@
 	nametag = NUM2INT(rpm_dependency_get_nametag(dep));
 	versiontag = NUM2INT(rpm_dependency_get_versiontag(dep));
 	flagstag = NUM2INT(rpm_dependency_get_flagstag(dep));

-	name = RSTRING_PTR(rpm_dependency_get_name(dep));
-	evr = RSTRING_PTR(rpm_version_to_vre(rpm_dependency_get_version(dep)));
+	name = RSTRING(rpm_dependency_get_name(dep))->ptr;
+	evr = RSTRING(rpm_version_to_vre(rpm_dependency_get_version(dep)))->ptr;
 	flag = NUM2INT(rpm_dependency_get_flags(dep));

 	headerAddOrAppendEntry(RPM_HEADER(pkg),nametag,RPM_STRING_ARRAY_TYPE,&name,1);
 	headerAddOrAppendEntry(RPM_HEADER(pkg),versiontag,RPM_STRING_ARRAY_TYPE,&evr,1);
@@ -289,9 +289,9 @@
 {
 	if ((TYPE(val) != T_STRING))  {
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}
-	headerAddOrAppendEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_STRING_ARRAY_TYPE,&RSTRING_PTR(val),1);
+	headerAddOrAppendEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_STRING_ARRAY_TYPE,&RSTRING(val)->ptr,1);
   return Qnil;
 }

 VALUE
@@ -299,9 +299,9 @@
 {
 	if ((TYPE(val) != T_STRING))  {
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}
-	headerAddEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_STRING_TYPE,RSTRING_PTR(val),1);
+	headerAddEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_STRING_TYPE,RSTRING(val)->ptr,1);
   return Qnil;
 }

 VALUE
@@ -309,9 +309,9 @@
 {
 	if ((TYPE(val) != T_STRING))  {
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}
-	headerAddEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_BIN_TYPE,RSTRING_PTR(val),RSTRING_LEN(val));
+	headerAddEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_BIN_TYPE,RSTRING(val)->ptr,RSTRING(val)->len);
   return Qnil;
 }

 VALUE
@@ -584,37 +584,37 @@
 	register int i;

 	files = rb_ary_new();
 	if (!NIL_P(basenames)) {
-		for (i = 0; i < RARRAY_LEN(basenames);i++) {
+		for (i = 0; i < RARRAY(basenames)->len; i++) {
 			static char buf[BUFSIZ];
 			VALUE file;
 			buf[0] = '\0';
-			stpcpy(stpcpy(buf, RSTRING_PTR(RARRAY_PTR(dirnames)[
-				           NUM2INT(RARRAY_PTR(diridxs)[i])])),
-					   RSTRING_PTR(RARRAY_PTR(basenames)[i]));
+			stpcpy(stpcpy(buf, RSTRING(RARRAY(dirnames)->ptr[
+				           NUM2INT(RARRAY(diridxs)->ptr[i])])->ptr),
+					   RSTRING(RARRAY(basenames)->ptr[i])->ptr);
 			file = rpm_file_new(
 				buf,
-				RSTRING_PTR(RARRAY_PTR(md5list)[i]),
+				RSTRING(RARRAY(md5list)->ptr[i])->ptr,
 				(NIL_P(linklist)
 				 ? NULL
-				 : RSTRING_PTR(RARRAY_PTR(linklist)[i])),
-				NUM2UINT(RARRAY_PTR(sizelist)[i]),
-				NUM2INT(RARRAY_PTR(mtimelist)[i]),
+				 : RSTRING(RARRAY(linklist)->ptr[i])->ptr),
+				NUM2UINT(RARRAY(sizelist)->ptr[i]),
+				NUM2INT(RARRAY(mtimelist)->ptr[i]),
 				(NIL_P(ownerlist)
 				 ? NULL
-				 : RSTRING_PTR(RARRAY_PTR(ownerlist)[i])),
+				 : RSTRING(RARRAY(ownerlist)->ptr[i])->ptr),
 				(NIL_P(grouplist)
 				 ? NULL
-				 : RSTRING_PTR(RARRAY_PTR(grouplist)[i])),
-				NUM2UINT(RARRAY_PTR(rdevlist)[i]),
-				NUM2UINT(RARRAY_PTR(modelist)[i]),
+				 : RSTRING(RARRAY(grouplist)->ptr[i])->ptr),
+				NUM2UINT(RARRAY(rdevlist)->ptr[i]),
+				NUM2UINT(RARRAY(modelist)->ptr[i]),
 				(NIL_P(flaglist)
 				 ? RPMFILE_NONE
-				 : NUM2INT(RARRAY_PTR(flaglist)[i])),
+				 : NUM2INT(RARRAY(flaglist)->ptr[i])),
 				(NIL_P(statelist)
 				 ? RPMFILE_STATE_NORMAL
-				 : NUM2INT(RARRAY_PTR(statelist)[i])));
+				 : NUM2INT(RARRAY(statelist)->ptr[i])));
 			rb_ary_push(files, file);
 		}
 	}
 	return files;
@@ -760,9 +760,9 @@
 	off_t size;
 	char* buf;

 	temp = ruby_rpm_make_temp_name();
-	fd = Fopen(RSTRING_PTR(temp), "wb+");
+	fd = Fopen(RSTRING(temp)->ptr, "wb+");
 	headerWrite(fd, RPM_HEADER(pkg), HEADER_MAGIC_YES);
 	size = fdSize(fd);

 	buf = mmap(NULL, size, PROT_READ, MAP_PRIVATE, Fileno(fd), 0);
@@ -770,11 +770,11 @@
 	munmap(buf, size);

 	Fclose(fd);
 #if RPM_VERSION(4,6,0) <= RPM_VERSION_CODE
-	unlink(RSTRING_PTR(temp));
+	unlink(RSTRING(temp)->ptr);
 #else
-	Unlink(RSTRING_PTR(temp));
+	Unlink(RSTRING(temp)->ptr);
 #endif

 	return dump;
 }
@@ -795,18 +795,18 @@

 	if (NIL_P(name)) {
 		buf[0] = '\0';
 	} else if (NIL_P(ver)) {
-		snprintf(buf, BUFSIZ, "%s", RSTRING_PTR(name));
+		snprintf(buf, BUFSIZ, "%s", RSTRING(name)->ptr);
 	} else if (NIL_P(arch)) {
 		snprintf(buf, BUFSIZ, "%s-%s",
-				RSTRING_PTR(name),
-				RSTRING_PTR(rpm_version_to_s(ver)));
+				RSTRING(name)->ptr,
+				RSTRING(rpm_version_to_s(ver))->ptr);
 	} else {
 		snprintf(buf, BUFSIZ, "%s-%s-%s",
-				RSTRING_PTR(name),
-				RSTRING_PTR(rpm_version_to_s(ver)),
-				RSTRING_PTR(arch));
+				RSTRING(name)->ptr,
+				RSTRING(rpm_version_to_s(ver))->ptr,
+				RSTRING(arch)->ptr);
 	}

 	return rb_str_new2(buf);
 }
@@ -821,13 +821,13 @@
 	if (NIL_P(name)) {
 		buf[0] = '\0';
 	} else if (NIL_P(ver)) {
 		snprintf(buf, BUFSIZ, "#<RPM::Package name=%s>",
-				RSTRING_PTR(rb_inspect(name)));
+				RSTRING(rb_inspect(name))->ptr);
 	} else {
 		snprintf(buf, BUFSIZ, "#<RPM::Package name=%s, version=%s>",
-				RSTRING_PTR(rb_inspect(name)),
-				RSTRING_PTR(rb_inspect(ver)));
+				RSTRING(rb_inspect(name))->ptr,
+				RSTRING(rb_inspect(ver))->ptr);
 	}

 	return rb_str_new2(buf);
 }
--- ruby-rpm/BUILD/ruby-rpm-1.2.3/ext/rpm/package.c	2009-05-20 15:36:48.223136366 -0400
+++ ruby19-rpm/BUILD/ruby-rpm-1.2.3/ext/rpm/package.c	2009-05-20 14:30:44.179479905 -0400
@@ -111,11 +111,11 @@
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}
 
 	hdr = headerNew();
-        headerAddEntry(hdr,RPMTAG_NAME,RPM_STRING_TYPE,RSTRING_PTR(name),1);
-        headerAddEntry(hdr,RPMTAG_VERSION,RPM_STRING_TYPE,RSTRING_PTR(rpm_version_get_v(version)),1);
-        headerAddEntry(hdr,RPMTAG_RELEASE,RPM_STRING_TYPE,RSTRING_PTR(rpm_version_get_r(version)),1);
+        headerAddEntry(hdr,RPMTAG_NAME,RPM_STRING_TYPE,RSTRING(name)->ptr,1);
+        headerAddEntry(hdr,RPMTAG_VERSION,RPM_STRING_TYPE,RSTRING(rpm_version_get_v(version))->ptr,1);
+        headerAddEntry(hdr,RPMTAG_RELEASE,RPM_STRING_TYPE,RSTRING(rpm_version_get_r(version))->ptr,1);
         if(!NIL_P(rpm_version_get_e(version))){
 		int e = NUM2INT(rpm_version_get_e(version));
         	headerAddEntry(hdr,RPMTAG_EPOCH,RPM_INT32_TYPE,&e,1);
 	}
@@ -134,12 +134,12 @@
 	if (TYPE(filename) != T_STRING) {
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}
 
-	fd = Fopen(RSTRING_PTR(filename), "r");
+	fd = Fopen(RSTRING(filename)->ptr, "r");
 	if (!fd) {
 		rb_raise(rb_eRuntimeError, "can not open file %s",
-				 RSTRING_PTR(filename));
+				 RSTRING(filename)->ptr);
 	}
 	rc = rpmReadPackageInfo(fd, &sigs, &hdr);
 	Fclose(fd);
 
@@ -188,17 +188,17 @@
 
 	Check_Type(str, T_STRING);
 
 	temp = ruby_rpm_make_temp_name();
-	fd = Fopen(RSTRING_PTR(temp), "wb+");
-	Fwrite(RSTRING_PTR(str), RSTRING_LEN(str), 1, fd);
+	fd = Fopen(RSTRING(temp)->ptr, "wb+");
+	Fwrite(RSTRING(str)->ptr, RSTRING(str)->len, 1, fd);
 	Fseek(fd, 0, SEEK_SET);
 	hdr = headerRead(fd, HEADER_MAGIC_YES);
 	Fclose(fd);
 #if RPM_VERSION(4,6,0) <= RPM_VERSION_CODE
-	unlink(RSTRING_PTR(temp));
+	unlink(RSTRING(temp)->ptr);
 #else
-	Unlink(RSTRING_PTR(temp));
+	Unlink(RSTRING(temp)->ptr);
 #endif
 
 	if (!hdr) {
 		rb_raise(rb_eArgError, "unable load RPM::Package");
@@ -255,10 +255,10 @@
 	nametag = NUM2INT(rpm_dependency_get_nametag(dep));
 	versiontag = NUM2INT(rpm_dependency_get_versiontag(dep));
 	flagstag = NUM2INT(rpm_dependency_get_flagstag(dep));
 
-	name = RSTRING_PTR(rpm_dependency_get_name(dep));
-	evr = RSTRING_PTR(rpm_version_to_vre(rpm_dependency_get_version(dep)));
+	name = RSTRING(rpm_dependency_get_name(dep))->ptr;
+	evr = RSTRING(rpm_version_to_vre(rpm_dependency_get_version(dep)))->ptr;
 	flag = NUM2INT(rpm_dependency_get_flags(dep));
 
 	headerAddOrAppendEntry(RPM_HEADER(pkg),nametag,RPM_STRING_ARRAY_TYPE,&name,1);
 	headerAddOrAppendEntry(RPM_HEADER(pkg),versiontag,RPM_STRING_ARRAY_TYPE,&evr,1);
@@ -289,9 +289,9 @@
 {
 	if ((TYPE(val) != T_STRING))  {
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}
-	headerAddOrAppendEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_STRING_ARRAY_TYPE,&RSTRING_PTR(val),1);
+	headerAddOrAppendEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_STRING_ARRAY_TYPE,&RSTRING(val)->ptr,1);
   return Qnil;
 }
 
 VALUE
@@ -299,9 +299,9 @@
 {
 	if ((TYPE(val) != T_STRING))  {
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}
-	headerAddEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_STRING_TYPE,RSTRING_PTR(val),1);
+	headerAddEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_STRING_TYPE,RSTRING(val)->ptr,1);
   return Qnil;
 }
 
 VALUE
@@ -309,9 +309,9 @@
 {
 	if ((TYPE(val) != T_STRING))  {
 		rb_raise(rb_eTypeError, "illegal argument type");
 	}
-	headerAddEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_BIN_TYPE,RSTRING_PTR(val),RSTRING_LEN(val));
+	headerAddEntry(RPM_HEADER(pkg),NUM2INT(tag),RPM_BIN_TYPE,RSTRING(val)->ptr,RSTRING(val)->len);
   return Qnil;
 }
 
 VALUE
@@ -584,37 +584,37 @@
 	register int i;
 
 	files = rb_ary_new();
 	if (!NIL_P(basenames)) {
-		for (i = 0; i < RARRAY_LEN(basenames);i++) {
+		for (i = 0; i < RARRAY(basenames)->len; i++) {
 			static char buf[BUFSIZ];
 			VALUE file;
 			buf[0] = '\0';
-			stpcpy(stpcpy(buf, RSTRING_PTR(RARRAY_PTR(dirnames)[
-				           NUM2INT(RARRAY_PTR(diridxs)[i])])),
-					   RSTRING_PTR(RARRAY_PTR(basenames)[i]));
+			stpcpy(stpcpy(buf, RSTRING(RARRAY(dirnames)->ptr[
+				           NUM2INT(RARRAY(diridxs)->ptr[i])])->ptr),
+					   RSTRING(RARRAY(basenames)->ptr[i])->ptr);
 			file = rpm_file_new(
 				buf,
-				RSTRING_PTR(RARRAY_PTR(md5list)[i]),
+				RSTRING(RARRAY(md5list)->ptr[i])->ptr,
 				(NIL_P(linklist)
 				 ? NULL
-				 : RSTRING_PTR(RARRAY_PTR(linklist)[i])),
-				NUM2UINT(RARRAY_PTR(sizelist)[i]),
-				NUM2INT(RARRAY_PTR(mtimelist)[i]),
+				 : RSTRING(RARRAY(linklist)->ptr[i])->ptr),
+				NUM2UINT(RARRAY(sizelist)->ptr[i]),
+				NUM2INT(RARRAY(mtimelist)->ptr[i]),
 				(NIL_P(ownerlist)
 				 ? NULL
-				 : RSTRING_PTR(RARRAY_PTR(ownerlist)[i])),
+				 : RSTRING(RARRAY(ownerlist)->ptr[i])->ptr),
 				(NIL_P(grouplist)
 				 ? NULL
-				 : RSTRING_PTR(RARRAY_PTR(grouplist)[i])),
-				NUM2UINT(RARRAY_PTR(rdevlist)[i]),
-				NUM2UINT(RARRAY_PTR(modelist)[i]),
+				 : RSTRING(RARRAY(grouplist)->ptr[i])->ptr),
+				NUM2UINT(RARRAY(rdevlist)->ptr[i]),
+				NUM2UINT(RARRAY(modelist)->ptr[i]),
 				(NIL_P(flaglist)
 				 ? RPMFILE_NONE
-				 : NUM2INT(RARRAY_PTR(flaglist)[i])),
+				 : NUM2INT(RARRAY(flaglist)->ptr[i])),
 				(NIL_P(statelist)
 				 ? RPMFILE_STATE_NORMAL
-				 : NUM2INT(RARRAY_PTR(statelist)[i])));
+				 : NUM2INT(RARRAY(statelist)->ptr[i])));
 			rb_ary_push(files, file);
 		}
 	}
 	return files;
@@ -760,9 +760,9 @@
 	off_t size;
 	char* buf;
 
 	temp = ruby_rpm_make_temp_name();
-	fd = Fopen(RSTRING_PTR(temp), "wb+");
+	fd = Fopen(RSTRING(temp)->ptr, "wb+");
 	headerWrite(fd, RPM_HEADER(pkg), HEADER_MAGIC_YES);
 	size = fdSize(fd);
 
 	buf = mmap(NULL, size, PROT_READ, MAP_PRIVATE, Fileno(fd), 0);
@@ -770,11 +770,11 @@
 	munmap(buf, size);
 
 	Fclose(fd);
 #if RPM_VERSION(4,6,0) <= RPM_VERSION_CODE
-	unlink(RSTRING_PTR(temp));
+	unlink(RSTRING(temp)->ptr);
 #else
-	Unlink(RSTRING_PTR(temp));
+	Unlink(RSTRING(temp)->ptr);
 #endif
 
 	return dump;
 }
@@ -795,18 +795,18 @@
 
 	if (NIL_P(name)) {
 		buf[0] = '\0';
 	} else if (NIL_P(ver)) {
-		snprintf(buf, BUFSIZ, "%s", RSTRING_PTR(name));
+		snprintf(buf, BUFSIZ, "%s", RSTRING(name)->ptr);
 	} else if (NIL_P(arch)) {
 		snprintf(buf, BUFSIZ, "%s-%s",
-				RSTRING_PTR(name),
-				RSTRING_PTR(rpm_version_to_s(ver)));
+				RSTRING(name)->ptr,
+				RSTRING(rpm_version_to_s(ver))->ptr);
 	} else {
 		snprintf(buf, BUFSIZ, "%s-%s-%s",
-				RSTRING_PTR(name),
-				RSTRING_PTR(rpm_version_to_s(ver)),
-				RSTRING_PTR(arch));
+				RSTRING(name)->ptr,
+				RSTRING(rpm_version_to_s(ver))->ptr,
+				RSTRING(arch)->ptr);
 	}
 
 	return rb_str_new2(buf);
 }
@@ -821,13 +821,13 @@
 	if (NIL_P(name)) {
 		buf[0] = '\0';
 	} else if (NIL_P(ver)) {
 		snprintf(buf, BUFSIZ, "#<RPM::Package name=%s>",
-				RSTRING_PTR(rb_inspect(name)));
+				RSTRING(rb_inspect(name))->ptr);
 	} else {
 		snprintf(buf, BUFSIZ, "#<RPM::Package name=%s, version=%s>",
-				RSTRING_PTR(rb_inspect(name)),
-				RSTRING_PTR(rb_inspect(ver)));
+				RSTRING(rb_inspect(name))->ptr,
+				RSTRING(rb_inspect(ver))->ptr);
 	}
 
 	return rb_str_new2(buf);
 }