* 64 bit cleanness: format size_t properly in printf()
authorWilfried Göesgens <willi@citadel.org>
Tue, 11 Sep 2007 20:00:18 +0000 (20:00 +0000)
committerWilfried Göesgens <willi@citadel.org>
Tue, 11 Sep 2007 20:00:18 +0000 (20:00 +0000)
citadel/configure.ac
citadel/modules/funambol/serv_funambol.c
citadel/modules/imap/imap_fetch.c
citadel/sysdep_decls.h

index 82aeece2d1d35b7f41924e55bd58e7da5fb3f1b6..929a3978c23794921b776e4a728253ffb5309587 100644 (file)
@@ -284,6 +284,7 @@ AC_MSG_CHECKING([how to create dependancy checks])
                 fi
 AC_SUBST(DEPEND_FLAG)
 
+
 AC_PROG_INSTALL
 AC_PROG_YACC
 missing_dir=`cd $ac_aux_dir && pwd`
@@ -297,6 +298,7 @@ AC_CHECK_SIZEOF(char, 0)
 AC_CHECK_SIZEOF(short, 0)
 AC_CHECK_SIZEOF(int, 0)
 AC_CHECK_SIZEOF(long, 0)
+AC_CHECK_SIZEOF(size_t, 0)
 dnl AC_CHECK_SIZEOF(long long, 0)
 
 dnl Checks for libraries.
index 827bdb7172901eb320259e80c0b2acd5de998089..3ea21710509be11ca107bc9611d2094e3b0f677f 100644 (file)
@@ -189,7 +189,7 @@ void notify_funambol(long msgnum, void *userdata) {
                );
                strcat(SOAPHeader,buf);
        strcat(SOAPHeader,"Pragma: no-cache\r\nSOAPAction: \"\"\r\n");
-       sprintf(buf, "Content-Length: %d\r\n",
+       sprintf(buf, "Content-Length: " SIZE_T_FMT "\r\n",
                strlen(SOAPData));
        strcat(SOAPHeader, buf);
        sprintf(buf, "Authorization: Basic %s\r\n\r\n",
index 2165688125cea1edadc66a1cb5baa53445d0adbc..ae24522d18162119d9739536a77539779089ab4b 100644 (file)
@@ -219,11 +219,14 @@ void imap_fetch_rfc822(long msgnum, char *whichfmt) {
                text_size = 0;
        }
 
-       lprintf(CTDL_DEBUG, "RFC822: headers=%d, text=%d, total=%d\n",
+       lprintf(CTDL_DEBUG, 
+               "RFC822: headers=" SIZE_T_FMT 
+               ", text=" SIZE_T_FMT
+               ", total=" SIZE_T_FMT "\n",
                headers_size, text_size, total_size);
 
        if (!strcasecmp(whichfmt, "RFC822.SIZE")) {
-               cprintf("RFC822.SIZE %d", total_size);
+               cprintf("RFC822.SIZE " SIZE_T_FMT, total_size);
                return;
        }
 
@@ -242,7 +245,7 @@ void imap_fetch_rfc822(long msgnum, char *whichfmt) {
                bytes_to_send = text_size;
        }
 
-       cprintf("%s {%d}\r\n", whichfmt, bytes_to_send);
+       cprintf("%s {" SIZE_T_FMT "}\r\n", whichfmt, bytes_to_send);
        client_write(ptr, bytes_to_send);
 }
 
@@ -694,16 +697,16 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
        }
 
        if (is_partial == 0) {
-               cprintf("BODY[%s] {%d}\r\n", section, IMAP->cached_body_len);
+               cprintf("BODY[%s] {" SIZE_T_FMT "}\r\n", section, IMAP->cached_body_len);
                pstart = 0;
                pbytes = IMAP->cached_body_len;
        }
        else {
-               sscanf(partial, "%d.%d", &pstart, &pbytes);
+               sscanf(partial, SIZE_T_FMT "." SIZE_T_FMT, &pstart, &pbytes);
                if (pbytes > (IMAP->cached_body_len - pstart)) {
                        pbytes = IMAP->cached_body_len - pstart;
                }
-               cprintf("BODY[%s]<%d> {%d}\r\n", section, pstart, pbytes);
+               cprintf("BODY[%s]<" SIZE_T_FMT "> {" SIZE_T_FMT "}\r\n", section, pstart, pbytes);
        }
 
        /* Here we go -- output it */
@@ -934,7 +937,7 @@ void imap_fetch_bodystructure (long msgnum, char *item,
 
                cprintf("BODYSTRUCTURE (\"TEXT\" \"PLAIN\" "
                        "(\"CHARSET\" \"US-ASCII\") NIL NIL "
-                       "\"7BIT\" %d %d)", rfc822_body_len, lines);
+                       "\"7BIT\" " SIZE_T_FMT " %d)", rfc822_body_len, lines);
 
                return;
        }
index 99a29e68e52d0f5910807c0c02ba2d9483d10ef6..b880d09ac4e617db2e9a0e8d78bfbd69858e2a56 100644 (file)
 #include "sysdep.h"
 #include "server.h"
 
+#if SIZEOF_SIZE_T == 8
+#define SIZE_T_FMT "%ld"
+#else 
+#define SIZE_T_FMT "%d"
+#endif
+
 
 /* Logging levels - correspond to syslog(3) */
 enum LogLevel {