Author: jonpryor
Date: 2005-04-30 08:45:59 -0400 (Sat, 30 Apr 2005)
New Revision: 43825

Modified:
   trunk/mono/support/ChangeLog
   trunk/mono/support/stdio.c
Log:
        * 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().


Modified: trunk/mono/support/ChangeLog
===================================================================
--- trunk/mono/support/ChangeLog        2005-04-30 10:53:28 UTC (rev 43824)
+++ trunk/mono/support/ChangeLog        2005-04-30 12:45:59 UTC (rev 43825)
@@ -1,3 +1,8 @@
+2005-04-30  Jonathan Pryor  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * map.c, map.h: Added XattrFlags values, functions.

Modified: trunk/mono/support/stdio.c
===================================================================
--- trunk/mono/support/stdio.c  2005-04-30 10:53:28 UTC (rev 43824)
+++ trunk/mono/support/stdio.c  2005-04-30 12:45:59 UTC (rev 43825)
@@ -175,6 +175,37 @@
        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
 
 /*

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to