]> arthur.barton.de Git - netatalk.git/blobdiff - bin/megatron/hqx.c
Merge master
[netatalk.git] / bin / megatron / hqx.c
index 8f303b0c5e7c7c2b2cfce150268eb044c54e2614..da2f71cf58f04f7c25d6a0851fd8d8659ff78605 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: hqx.c,v 1.16 2009-10-14 01:38:28 didg Exp $
+ * $Id: hqx.c,v 1.18 2010-01-27 21:27:53 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -18,9 +18,7 @@
 #include <time.h>
 
 #include <unistd.h>
-#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
 
 #include <netinet/in.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 +172,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 +188,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 ) {
@@ -278,7 +267,7 @@ int hqx_header_read(struct FHeader *fh)
 #endif /* HEXOUTPUT */
 
     if (( headerbuf = 
-           (char *)malloc( (unsigned int)( namelen + BHH_HEADSIZ ))) == 0 ) {
+           (char *)malloc( (unsigned int)( namelen + BHH_HEADSIZ ))) == NULL ) {
        return( -1 );
     }
     if ( hqx_7tobin( headerbuf, ( namelen + BHH_HEADSIZ )) == 0 ) {
@@ -395,10 +384,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 +555,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;