Fixed uint64_t printf.

This commit is contained in:
Guenter Knauf 2011-09-10 16:29:29 +02:00
parent 8faefc0a8a
commit b5cd8fe120
2 changed files with 42 additions and 16 deletions

View File

@ -26,6 +26,9 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
@ -33,6 +36,22 @@
#include <stdio.h>
#include <ctype.h>
/* last resort for systems not defining PRIu64 in inttypes.h */
#ifndef __PRI64_PREFIX
#ifdef WIN32
#define __PRI64_PREFIX "I64"
#else
#if __WORDSIZE == 64
#define __PRI64_PREFIX "l"
#else
#define __PRI64_PREFIX "ll"
#endif /* __WORDSIZE */
#endif /* WIN32 */
#endif /* !__PRI64_PREFIX */
#ifndef PRIu64
#define PRIu64 __PRI64_PREFIX "u"
#endif /* PRIu64 */
int main(int argc, char *argv[])
{
unsigned long hostaddr;
@ -186,13 +205,7 @@ int main(int argc, char *argv[])
}
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
/* attrs.filesize is an uint64_t according to
the docs but there is no really good and
portable 64bit type for C before C99, and
correspondingly there was no good printf()
option for it... */
printf("%8lld ", attrs.filesize);
printf("%8" PRIu64 " ", attrs.filesize);
}
printf("%s\n", mem);

View File

@ -26,6 +26,9 @@
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
@ -33,6 +36,22 @@
#include <stdio.h>
#include <ctype.h>
/* last resort for systems not defining PRIu64 in inttypes.h */
#ifndef __PRI64_PREFIX
#ifdef WIN32
#define __PRI64_PREFIX "I64"
#else
#if __WORDSIZE == 64
#define __PRI64_PREFIX "l"
#else
#define __PRI64_PREFIX "ll"
#endif /* __WORDSIZE */
#endif /* WIN32 */
#endif /* !__PRI64_PREFIX */
#ifndef PRIu64
#define PRIu64 __PRI64_PREFIX "u"
#endif /* PRIu64 */
int main(int argc, char *argv[])
{
unsigned long hostaddr;
@ -193,13 +212,7 @@ int main(int argc, char *argv[])
}
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
/* attrs.filesize is an uint64_t according to
the docs but there is no really good and
portable 64bit type for C before C99, and
correspondingly there was no good printf()
option for it... */
printf("%8lld ", attrs.filesize);
printf("%8" PRIu64 " ", attrs.filesize);
}
printf("%s\n", mem);