aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QUtil.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-06-22 01:32:21 +0200
committerJay Berkenbilt <ejb@ql.org>2012-06-22 03:23:24 +0200
commit81e8752362eeab80f156eb74d1b523eba20a0366 (patch)
tree96ec527e8aaf243767458058598740c9fbffc2d4 /libqpdf/QUtil.cc
parentc833295a3948e914fa23042896f19f35ddd8d927 (diff)
downloadqpdf-81e8752362eeab80f156eb74d1b523eba20a0366.tar.zst
Use qpdf_offset_t in place of off_t in public APIs.
off_t is used internally only when needed to talk to standard libraries. This requires that the "long long" type be supported by the compiler.
Diffstat (limited to 'libqpdf/QUtil.cc')
-rw-r--r--libqpdf/QUtil.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc
index e1071940..3c3bf011 100644
--- a/libqpdf/QUtil.cc
+++ b/libqpdf/QUtil.cc
@@ -82,6 +82,16 @@ QUtil::double_to_string(double num, int decimal_places)
return std::string(t);
}
+long long
+QUtil::string_to_ll(char const* str)
+{
+#ifdef _MSC_VER
+ return _strtoi64(str, 0, 10);
+#else
+ return strtoll(str, 0, 10);
+#endif
+}
+
void
QUtil::throw_system_error(std::string const& description)
{
@@ -109,22 +119,22 @@ QUtil::fopen_wrapper(std::string const& description, FILE* f)
}
int
-QUtil::fseek_off_t(FILE* stream, off_t offset, int whence)
+QUtil::fseek_off_t(FILE* stream, qpdf_offset_t offset, int whence)
{
#if HAVE_FSEEKO
- return fseeko(stream, offset, whence);
+ return fseeko(stream, (off_t)offset, whence);
#else
- return fseek(stream, offset, whence);
+ return fseek(stream, (long)offset, whence);
#endif
}
-off_t
+qpdf_offset_t
QUtil::ftell_off_t(FILE* stream)
{
#if HAVE_FSEEKO
- return ftello(stream);
+ return (qpdf_offset_t)ftello(stream);
#else
- return ftell(stream);
+ return (qpdf_offset_t)ftell(stream);
#endif
}