static public int sprintf(__arglist) { var Arguments = CLibUtils.GetObjectsFromArgsIterator(new ArgIterator(__arglist)); var Buffer = (sbyte *)((UIntPtr)Arguments[0]).ToPointer(); var Format = CLibUtils.GetStringFromPointer((UIntPtr)Arguments[1]); var Str = CLibUtils.sprintf_hl(Format, Arguments.Skip(2).ToArray()); var Bytes = CLibUtils.DefaultEncoding.GetBytes(Str); Marshal.Copy(Bytes, 0, new IntPtr(Buffer), Bytes.Length); Buffer[Bytes.Length] = 0; return(Bytes.Length); }
static public int fprintf(__arglist) { var Arguments = CLibUtils.GetObjectsFromArgsIterator(new ArgIterator(__arglist)); var File = (FILE *)((UIntPtr)Arguments[0]).ToPointer(); var Format = CLibUtils.GetStringFromPointer((UIntPtr)Arguments[1]); var Str = CLibUtils.sprintf_hl(Format, Arguments.Skip(2).ToArray()); var DataToWrite = CLibUtils.DefaultEncoding.GetBytes(Str); fixed(byte *DataToWritePtr = DataToWrite) { return(fwrite((sbyte *)DataToWritePtr, 1, DataToWrite.Length, File)); } }
static public int printf(__arglist) { var Arguments = CLibUtils.GetObjectsFromArgsIterator(new ArgIterator(__arglist)); var Format = CLibUtils.GetStringFromPointer((UIntPtr)Arguments[0]); var Str = CLibUtils.sprintf_hl(Format, Arguments.Skip(1).ToArray()); #if true var StrBytes = CLibUtils.DefaultEncoding.GetBytes(Str); stdout->GetStream().Write(StrBytes, 0, StrBytes.Length); #else Console.Write(Str); #endif return(Str.Length); }