]> arthur.barton.de Git - netatalk.git/blobdiff - bin/megatron/macbin.c
Spotlight: use async Tracker SPARQL API
[netatalk.git] / bin / megatron / macbin.c
index 1b2dd197a665efeba762772576fe600a0c35ca0d..986aac9247c91f6e7cb210030facfa4d566ef01d 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * $Id: macbin.c,v 1.14 2009-10-14 01:38:28 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -10,12 +9,8 @@
 #include <sys/uio.h>
 #include <sys/time.h>
 #include <sys/param.h>
-#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif /* HAVE_UNISTD_H */
 #include <string.h>
 #include <strings.h>
 #include <ctype.h>
@@ -167,11 +162,11 @@ int bin_close(int keepflag)
  * return zero and no more than that.
  */
 
-int bin_read( int fork, char *buffer, int length)
+ssize_t bin_read( int fork, char *buffer, size_t length)
 {
     char               *buf_ptr;
-    int                        readlen;
-    int                        cc = 1;
+    size_t             readlen;
+    ssize_t            cc = 1;
     off_t              pos;
 
 #if DEBUG >= 3
@@ -179,9 +174,9 @@ int bin_read( int fork, char *buffer, int length)
     fprintf( stderr, "bin_read: remaining length is %d\n", bin.forklen[fork] );
 #endif /* DEBUG >= 3 */
 
-    if (bin.forklen[fork] > length) {
-       fprintf(stderr, "This should never happen, dude! length %d, fork length == %u\n", length, bin.forklen[fork]);
-       return bin.forklen[fork];
+    if (bin.forklen[fork] > 0x7FFFFFFF) {
+       fprintf(stderr, "This should never happen, dude! fork length == %u\n", bin.forklen[fork]);
+       return -1;
     }
 
     if ( bin.forklen[ fork ] == 0 ) {
@@ -236,11 +231,11 @@ int bin_read( int fork, char *buffer, int length)
  * bin_write 
  */
 
-int bin_write(int fork, char *buffer, int length)
+ssize_t bin_write(int fork, char *buffer, size_t length)
 {
     char               *buf_ptr;
-    int                        writelen;
-    int                        cc = 0;
+    ssize_t            writelen;
+    ssize_t            cc = 0;
     off_t              pos;
     u_char             padchar = 0x7f;
                /* Not sure why, but it seems this must be 0x7f to match
@@ -278,11 +273,6 @@ int bin_write(int fork, char *buffer, int length)
        return( cc );
     }
 
-    if (length > bin.forklen[fork]) {
-       fprintf(stderr, "This should never happen, dude! length %d, fork length %u\n", length, bin.forklen[fork]);
-       return bin.forklen[fork];
-    }
-
     bin.forklen[fork] -= length;
 
 /*
@@ -528,7 +518,7 @@ int bin_header_write(struct FHeader *fh)
 int test_header(void)
 {
     const char          zeros[25] = "";
-    u_int32_t          cc;
+    ssize_t            cc;
     u_short            header_crc;
     u_char             namelen;