]> mj.ucw.cz Git - libucw.git/commitdiff
partmap.h deserves its own header
authorRobert Spalek <robert@ucw.cz>
Sun, 16 Oct 2005 15:53:38 +0000 (15:53 +0000)
committerRobert Spalek <robert@ucw.cz>
Sun, 16 Oct 2005 15:53:38 +0000 (15:53 +0000)
lib/lib.h
lib/partmap.c
lib/partmap.h [new file with mode: 0644]

index 81728f1022bef457f054f40c8c2057903a84b3af..ddd03121077fe5e57a969438fb401db794efcef6 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -201,38 +201,6 @@ uns random_max(uns);
 void *mmap_file(byte *name, unsigned *len, int writeable);
 void munmap_file(void *start, unsigned len);
 
-/* partmap.c */
-
-struct partmap {
-  int fd;
-  sh_off_t file_size;
-  sh_off_t start_off, end_off;
-  byte *start_map;
-  int writeable;
-};
-
-struct partmap;
-struct partmap *partmap_open(byte *name, int writeable);
-void partmap_close(struct partmap *p);
-sh_off_t partmap_size(struct partmap *p);
-void partmap_load(struct partmap *p, sh_off_t start, uns size);
-
-static inline void *
-partmap_map(struct partmap *p, sh_off_t start, uns size)
-{
-  if (unlikely(!p->start_map || start < p->start_off || (sh_off_t) (start+size) > p->end_off))
-    partmap_load(p, start, size);
-  return p->start_map + (start - p->start_off);
-}
-
-static inline void *
-partmap_map_forward(struct partmap *p, sh_off_t start, uns size)
-{
-  if (unlikely((sh_off_t) (start+size) > p->end_off))
-    partmap_load(p, start, size);
-  return p->start_map + (start - p->start_off);
-}
-
 /* proctitle.c */
 
 void setproctitle_init(int argc, char **argv);
index e0832fcd798d1b5b0e679adcc8145cd04c5941fd..60ec168c41ae37f2b2604644c1fc3a95b3a2f3a7 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "lib/lib.h"
 #include "lib/lfs.h"
+#include "lib/partmap.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/lib/partmap.h b/lib/partmap.h
new file mode 100644 (file)
index 0000000..b5c4809
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *     UCW Library -- Mapping of File Parts
+ *
+ *     (c) 2003 Martin Mares <mj@ucw.cz>
+ *     (c) 2003--2005 Robert Spalek <robert@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
+ */
+
+#ifndef _UCW_PARTMAP_H
+#define _UCW_PARTMAP_H
+
+struct partmap {
+  int fd;
+  sh_off_t file_size;
+  sh_off_t start_off, end_off;
+  byte *start_map;
+  int writeable;
+};
+
+struct partmap *partmap_open(byte *name, int writeable);
+void partmap_close(struct partmap *p);
+sh_off_t partmap_size(struct partmap *p);
+void partmap_load(struct partmap *p, sh_off_t start, uns size);
+
+static inline void *
+partmap_map(struct partmap *p, sh_off_t start, uns size)
+{
+  if (unlikely(!p->start_map || start < p->start_off || (sh_off_t) (start+size) > p->end_off))
+    partmap_load(p, start, size);
+  return p->start_map + (start - p->start_off);
+}
+
+static inline void *
+partmap_map_forward(struct partmap *p, sh_off_t start, uns size)
+{
+  if (unlikely((sh_off_t) (start+size) > p->end_off))
+    partmap_load(p, start, size);
+  return p->start_map + (start - p->start_off);
+}
+
+#endif