]> arthur.barton.de Git - netatalk.git/commitdiff
megatron, fix errors introduced in Sun Feb 6 10:16:00 2005 commit, 'replace a wrong... branch-dircache-rewrite-start
authordidg <didg>
Wed, 27 Jan 2010 21:27:53 +0000 (21:27 +0000)
committerdidg <didg>
Wed, 27 Jan 2010 21:27:53 +0000 (21:27 +0000)
bin/megatron/asingle.c
bin/megatron/asingle.h
bin/megatron/hqx.c
bin/megatron/hqx.h
bin/megatron/macbin.c
bin/megatron/macbin.h
bin/megatron/megatron.c
bin/megatron/nad.c
bin/megatron/nad.h

index 4fb9a3ea4f11c012c0571da8ca5ec14decedead9..60c754f0ac8fae5a6acd4679c806b8e6f7352007 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: asingle.c,v 1.13 2009-10-14 01:38:28 didg Exp $
+ * $Id: asingle.c,v 1.14 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -389,12 +389,12 @@ int single_header_test(void)
  *
  */
 
-int single_read( int fork, char *buffer, u_int32_t length)
+ssize_t single_read( int fork, char *buffer, size_t length)
 {
     u_int32_t          entry_id;
     char               *buf_ptr;
-    int                        readlen;
-    int                        cc = 1;
+    size_t             readlen;
+    ssize_t            cc = 1;
     off_t              pos;
 
     switch ( fork ) {
@@ -409,9 +409,9 @@ int single_read( int fork, char *buffer, u_int32_t length)
            break;
     }
 
-    if (single.entry[entry_id].ade_len > length) {
-       fprintf(stderr, "single_read: Trying to read past end of fork!, length %d, ade_len == %u\n", length, single.entry[entry_id].ade_len);
-       return single.entry[entry_id].ade_len;
+    if (single.entry[entry_id].ade_len > 0x7FFFFFFF) {
+       fprintf(stderr, "single_read: Trying to read past end of fork!, ade_len == %u\n", single.entry[entry_id].ade_len);
+       return -1;
     }
     if ( single.entry[ entry_id ].ade_len == 0 ) {
        if ( fork == DATA ) {
index 557ba9d0a782dc02f485f87b55c2984189960464..c041ccaa99c9875844bdda6e98387563f4c0b9a4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: asingle.h,v 1.3 2005-04-28 20:49:19 bfernhomberg Exp $
+ * $Id: asingle.h,v 1.4 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifndef _ASINGLE_H
@@ -12,6 +12,6 @@ int single_open(char *singlefile, int flags, struct FHeader *fh, int options);
 int single_close(int readflag);
 int single_header_read(struct FHeader *fh, int version);
 int single_header_test(void);
-int single_read(int fork, char *buffer, u_int32_t length);
+ssize_t single_read(int fork, char *buffer, size_t length);
 
 #endif /* _ASINGLE_H */
index 43db208df0e98ff0dfc450baf5c52b97ff7f5d7f..117c9dd65d08b0726ab83168cfb18c83a93aa89f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: hqx.c,v 1.17 2009-10-14 02:24:04 didg Exp $
+ * $Id: hqx.c,v 1.18 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
 #define BHH_CRCSIZ             2
 #define BHH_HEADSIZ            21
 
-/*     Forward declarations.
- */
-int skip_junk(int line);
-int hqx_close(int keepflag);
-int hqx_header_read(struct FHeader *fh);
-int hqx_header_write(struct FHeader *fh);
-int hqx_7tobin(char *outbuf, int datalen);
-int hqx7_fill(u_char *hqx7_ptr);
-
 #if HEXOUTPUT
 FILE           *rawhex, *expandhex;
 #endif /* HEXOUTPUT */
@@ -183,11 +174,11 @@ int hqx_close(int keepflag)
  * return zero and no more than that.
  */
 
-int hqx_read(int fork, char *buffer, int length)
+ssize_t hqx_read(int fork, char *buffer, size_t length)
 {
     u_short            storedcrc;
-    int                        readlen;
-    int                        cc;
+    size_t             readlen;
+    size_t             cc;
 
 #if DEBUG >= 3
     {
@@ -199,9 +190,9 @@ int hqx_read(int fork, char *buffer, int length)
     fprintf( stderr, "hqx_read: remaining length is %d\n", hqx.forklen[fork] );
 #endif /* DEBUG >= 3 */
 
-    if (hqx.forklen[fork] > length) {
-       fprintf(stderr, "This should never happen, dude! length %d, fork length == %u\n", length, hqx.forklen[fork]);
-       return hqx.forklen[fork];
+    if (hqx.forklen[fork] > 0x7FFFFFFF) {
+       fprintf(stderr, "This should never happen, dude!, fork length == %u\n", hqx.forklen[fork]);
+       return -1;
     }
 
     if ( hqx.forklen[ fork ] == 0 ) {
@@ -395,10 +386,10 @@ int hqx_header_write(struct FHeader *fh _U_)
  * it sets the pointers to the hqx7 buffer up to point to the valid data.
  */
 
-int hqx7_fill(u_char *hqx7_ptr)
+ssize_t hqx7_fill(u_char *hqx7_ptr)
 {
-    int                        cc;
-    int                        cs;
+    ssize_t            cc;
+    size_t             cs;
 
     cs = hqx7_ptr - hqx7_buf;
     if ( cs >= sizeof( hqx7_buf )) return( -1 );
@@ -566,7 +557,7 @@ int skip_junk(int line)
  * file is reached.
  */
 
-int hqx_7tobin( char *outbuf, int datalen)
+size_t hqx_7tobin( char *outbuf, size_t datalen)
 {
     static u_char      hqx8[3];
     static int         hqx8i;
index 73fbdeae63ce180578cef196a1197b3b9afec227..38730d055ef4fbf96b4658279b35f04e8f65b6f8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: hqx.h,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $
+ * $Id: hqx.h,v 1.3 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifndef _HQX_H
@@ -11,10 +11,10 @@ struct FHeader;
 int skip_junk(int line);
 int hqx_open(char *hqxfile, int flags, struct FHeader *fh, int options);
 int hqx_close(int keepflag);
-int hqx_read(int fork, char *buffer, int length);
+ssize_t hqx_read(int fork, char *buffer, size_t length);
 int hqx_header_read(struct FHeader *fh);
 int hqx_header_write(struct FHeader *fh);
-int hqx_7tobin(char *outbuf, int datalen);
-int hqx7_fill(u_char *hqx7_ptr);
+size_t hqx_7tobin(char *outbuf, size_t datalen);
+ssize_t hqx7_fill(u_char *hqx7_ptr);
 
 #endif /* _HQX_H */
index 1b2dd197a665efeba762772576fe600a0c35ca0d..349a7e1efc8725875dd4503d0bd3a46656ccb496 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: macbin.c,v 1.14 2009-10-14 01:38:28 didg Exp $
+ * $Id: macbin.c,v 1.15 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -167,11 +167,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 +179,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 +236,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;
+    size_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 +278,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;
 
 /*
index e9ec2834b14c642fb5c1fd15edd68f80471755ba..d216b1b9fcae4c5fa50c5f940007f42576218255 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: macbin.h,v 1.3 2009-10-13 22:55:36 didg Exp $
+ * $Id: macbin.h,v 1.4 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifndef _MACBIN_H
@@ -10,8 +10,8 @@ struct FHeader;
 
 int bin_open(char *binfile, int flags, struct FHeader *fh, int options);
 int bin_close(int keepflag);
-int bin_read(int fork, char *buffer, int length);
-int bin_write(int fork, char *buffer, int length);
+ssize_t bin_read(int fork, char *buffer, size_t length);
+ssize_t bin_write(int fork, char *buffer, size_t length);
 int bin_header_read(struct FHeader *fh, int revision);
 int bin_header_write(struct FHeader *fh);
 int test_header(void);
index 583465a9beec09eeaf3fb7bdbaa9c40d57fbcc80..1dc83d777c0991e5f4d7a85b911930f63b6143f8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: megatron.c,v 1.13 2009-10-14 02:24:04 didg Exp $
+ * $Id: megatron.c,v 1.14 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -61,7 +61,7 @@ static int from_open(int un, char *file, struct FHeader *fh, int flags)
     }
 }
 
-static int from_read(int un, int fork, char *buf, int len)
+static ssize_t from_read(int un, int fork, char *buf, size_t len)
 {
     switch ( un ) {
        case MEGATRON :
@@ -127,7 +127,7 @@ static int to_open(int to, char *file, struct FHeader *fh, int flags)
     }
 }
 
-static int to_write(int to, int fork, int bufc)
+static ssize_t to_write(int to, int fork, size_t bufc)
 {
     switch ( to ) {
        case MEGATRON :
@@ -171,9 +171,9 @@ static int megatron( char *path, int module, char *newname, int flags)
 {
     struct stat                st;
     struct FHeader     fh;
-    int                        bufc;
+    ssize_t            bufc;
     int                        fork;
-    unsigned int       forkred;
+    size_t             forkred;
 
 /*
  * If the source file is not stdin, make sure it exists and
index 250f51ac196a501be670979e2b5f63d4c06c0886..92be35413fc8ed3c17a91ef2dc120e42ea5e55bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: nad.c,v 1.17 2009-10-14 01:38:28 didg Exp $
+ * $Id: nad.c,v 1.18 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -691,9 +691,9 @@ int nad_header_write(struct FHeader *fh)
 
 static int             forkeid[] = { ADEID_DFORK, ADEID_RFORK };
 
-int nad_read(int fork, char *forkbuf, int bufc)
+ssize_t nad_read(int fork, char *forkbuf, size_t bufc)
 {
-    int                        cc = 0;
+    ssize_t            cc = 0;
 
 #if DEBUG
     fprintf( stderr, "Entering nad_read\n" );
@@ -713,11 +713,11 @@ int nad_read(int fork, char *forkbuf, int bufc)
     return( cc );
 }
 
-int nad_write(int fork, char *forkbuf, int bufc)
+ssize_t nad_write(int fork, char *forkbuf, size_t bufc)
 {
     char               *buf_ptr;
-    int                        writelen;
-    int                        cc = 0;
+    size_t             writelen;
+    ssize_t            cc = 0;
 
 #if DEBUG
     fprintf( stderr, "Entering nad_write\n" );
index b4b43ec0c8c51d816825607b6c48a1405ca5b849..9fa8568442fc8a9680f353cf568d8aba3404df3c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: nad.h,v 1.4 2005-04-28 20:49:20 bfernhomberg Exp $
+ * $Id: nad.h,v 1.5 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifndef _NAD_H
@@ -11,8 +11,8 @@ struct FHeader;
 int nad_open(char *path, int openflags, struct FHeader *fh, int options);
 int nad_header_read(struct FHeader *fh);
 int nad_header_write(struct FHeader *fh);
-int nad_read(int fork, char *forkbuf, int bufc);
-int nad_write(int fork, char *forkbuf, int bufc);
+ssize_t nad_read(int fork, char *forkbuf, size_t bufc);
+ssize_t nad_write(int fork, char *forkbuf, size_t bufc);
 int nad_close(int status);
 
 void select_charset(int options);