瀏覽代碼

libdpkg: Rename struct TarFunctions and members

Use lower case names, and name members closer to the Unix functions
doing the same actions.
Guillem Jover 16 年之前
父節點
當前提交
ff159b0d80
共有 3 個文件被更改,包括 25 次插入25 次删除
  1. 8 8
      lib/dpkg/tarfn.c
  2. 10 10
      lib/dpkg/tarfn.h
  3. 7 7
      src/processarc.c

+ 8 - 8
lib/dpkg/tarfn.c

@@ -176,7 +176,7 @@ struct symlinkList {
 };
 
 int
-TarExtractor(void *userData, const struct TarFunctions *ops)
+TarExtractor(void *userData, const struct tar_operations *ops)
 {
 	int status;
 	char buffer[TARBLKSZ];
@@ -196,7 +196,7 @@ TarExtractor(void *userData, const struct TarFunctions *ops)
 	h.LinkName = NULL;
 	h.UserData = userData;
 
-	while ((status = ops->Read(userData, buffer, TARBLKSZ)) == TARBLKSZ) {
+	while ((status = ops->read(userData, buffer, TARBLKSZ)) == TARBLKSZ) {
 		int nameLength;
 
 		if (!DecodeTarHeader(buffer, &h)) {
@@ -236,7 +236,7 @@ TarExtractor(void *userData, const struct TarFunctions *ops)
 		case NormalFile1:
 			/* Compatibility with pre-ANSI ustar. */
 			if (h.Name[nameLength - 1] != '/') {
-				status = ops->ExtractFile(&h);
+				status = ops->extract_file(&h);
 				break;
 			}
 			/* Else, fall through. */
@@ -244,10 +244,10 @@ TarExtractor(void *userData, const struct TarFunctions *ops)
 			if (h.Name[nameLength - 1] == '/') {
 				h.Name[nameLength - 1] = '\0';
 			}
-			status = ops->MakeDirectory(&h);
+			status = ops->mkdir(&h);
 			break;
 		case HardLink:
-			status = ops->MakeHardLink(&h);
+			status = ops->link(&h);
 			break;
 		case SymbolicLink:
 			symlink_node = m_malloc(sizeof(*symlink_node));
@@ -266,7 +266,7 @@ TarExtractor(void *userData, const struct TarFunctions *ops)
 		case CharacterDevice:
 		case BlockDevice:
 		case FIFO:
-			status = ops->MakeSpecialFile(&h);
+			status = ops->mknod(&h);
 			break;
 		case GNU_LONGLINK:
 		case GNU_LONGNAME:
@@ -295,7 +295,7 @@ TarExtractor(void *userData, const struct TarFunctions *ops)
 			     long_read -= TARBLKSZ) {
 				int copysize;
 
-				status = ops->Read(userData, buffer, TARBLKSZ);
+				status = ops->read(userData, buffer, TARBLKSZ);
 				/* If we didn't get TARBLKSZ bytes read, punt. */
 				if (status != TARBLKSZ) {
 					 /* Read partial header record? */
@@ -332,7 +332,7 @@ TarExtractor(void *userData, const struct TarFunctions *ops)
 	while (symlink_head) {
 		symlink_node = symlink_head->next;
 		if (status == 0)
-			status = ops->MakeSymbolicLink(&symlink_head->h);
+			status = ops->symlink(&symlink_head->h);
 		free(symlink_head->h.Name);
 		free(symlink_head->h.LinkName);
 		free(symlink_head);

+ 10 - 10
lib/dpkg/tarfn.h

@@ -62,19 +62,19 @@ struct	TarInfo {
 	gid_t		GroupID;	/* Numeric GID */
 };
 
-typedef	int	(*TarReadFunction)(void * userData, char * buffer, int length);
+typedef int (*tar_read_func)(void * userData, char * buffer, int length);
+typedef int (*tar_func)(struct TarInfo * h);
 
-typedef int	(*TarFunction)(struct TarInfo * h);
+struct tar_operations {
+	tar_read_func read;
 
-struct TarFunctions {
-	TarReadFunction	Read;
-	TarFunction	ExtractFile;
-	TarFunction	MakeDirectory;
-	TarFunction	MakeHardLink;
-	TarFunction	MakeSymbolicLink;
-	TarFunction	MakeSpecialFile;
+	tar_func extract_file;
+	tar_func link;
+	tar_func symlink;
+	tar_func mkdir;
+	tar_func mknod;
 };
 
-int TarExtractor(void *userData, const struct TarFunctions *ops);
+int TarExtractor(void *userData, const struct tar_operations *ops);
 
 #endif

+ 7 - 7
src/processarc.c

@@ -73,13 +73,13 @@ summarize_filename(const char *filename)
 }
 
 void process_archive(const char *filename) {
-  static const struct TarFunctions tf = {
-    .Read = tarfileread,
-    .ExtractFile = tarobject,
-    .MakeDirectory = tarobject,
-    .MakeHardLink = tarobject,
-    .MakeSymbolicLink = tarobject,
-    .MakeSpecialFile = tarobject,
+  static const struct tar_operations tf = {
+    .read = tarfileread,
+    .extract_file = tarobject,
+    .link = tarobject,
+    .symlink = tarobject,
+    .mkdir = tarobject,
+    .mknod = tarobject,
   };
 
   /* These need to be static so that we can pass their addresses to