Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Pryor <jpryor@novell.com>2005-04-30 16:45:59 +0400
committerJonathan Pryor <jpryor@novell.com>2005-04-30 16:45:59 +0400
commit7d3f3b07b91b185c8dc029aeb28d1564de2de0d8 (patch)
tree4775d43b73f97ffb2c8da615d6ba8ef9536d2dce /support
parent0ab302d997413293c983cc20babda8e611e01745 (diff)
* stdio.c: Add Mono_Posix_Stdlib_DumpFilePosition, which create a hex string
"dump" of a fpos_t. This is used for Mono.Unix.FilePosition.ToString(). svn path=/trunk/mono/; revision=43825
Diffstat (limited to 'support')
-rw-r--r--support/ChangeLog5
-rw-r--r--support/stdio.c31
2 files changed, 36 insertions, 0 deletions
diff --git a/support/ChangeLog b/support/ChangeLog
index a682d29af6c..4ba890bdf9d 100644
--- a/support/ChangeLog
+++ b/support/ChangeLog
@@ -1,3 +1,8 @@
+2005-04-30 Jonathan Pryor <jonpryor@vt.edu>
+
+ * stdio.c: Add Mono_Posix_Stdlib_DumpFilePosition, which create a hex string
+ "dump" of a fpos_t. This is used for Mono.Unix.FilePosition.ToString().
+
2005-04-19 Jonathan Pryor <jonpryor@vt.edu>
* map.c, map.h: Added XattrFlags values, functions.
diff --git a/support/stdio.c b/support/stdio.c
index 5973adb85a9..6ddf22eadbd 100644
--- a/support/stdio.c
+++ b/support/stdio.c
@@ -175,6 +175,37 @@ Mono_Posix_Stdlib_fsetpos (FILE* stream, fpos_t *pos)
return fsetpos (stream, pos);
}
+#define MPH_FPOS_LENGTH (sizeof(fpos_t)*2)
+
+int
+Mono_Posix_Stdlib_DumpFilePosition (char *dest, fpos_t *pos, gint32 len)
+{
+ char *destp;
+ unsigned char *posp, *pose;
+ int i;
+
+ if (dest == NULL)
+ return MPH_FPOS_LENGTH;
+
+ if (pos == NULL || len <= 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ posp = (unsigned char*) pos;
+ pose = posp + sizeof(*pos);
+ destp = dest;
+
+ for ( ; posp < pose && len > 1; destp += 2, ++posp, len -= 2) {
+ sprintf (destp, "%02X", *posp);
+ }
+
+ if (len)
+ dest[MPH_FPOS_LENGTH] = '\0';
+
+ return dest;
+}
+
G_END_DECLS
/*