]> arthur.barton.de Git - netatalk.git/blobdiff - bin/megatron/hqx.c
megatron, fix errors introduced in Sun Feb 6 10:16:00 2005 commit, 'replace a wrong...
[netatalk.git] / bin / megatron / hqx.c
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;