2007-11-12 Mike Kestner <mkestner@novell.com>
* glib/IOChannel.cs: IOChannel wrapper implementation. * glib/Makefile.am: build new files. * glib/Marshaller.cs: new string array marshaling methods. * glib/Spawn.cs: g_spawn* wrapper implementation. * sample/SpawnTests.cs: tests for the new GLib.Process class and a cursory exercise of IOChannel for SpawnAsyncWithPipes. svn path=/trunk/gtk-sharp/; revision=89477
This commit is contained in:
parent
e948f26420
commit
097537310e
18 changed files with 2344 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2007-11-12 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* glib/IOChannel.cs: IOChannel wrapper implementation.
|
||||||
|
* glib/Makefile.am: build new files.
|
||||||
|
* glib/Marshaller.cs: new string array marshaling methods.
|
||||||
|
* glib/Spawn.cs: g_spawn* wrapper implementation.
|
||||||
|
* sample/SpawnTests.cs: tests for the new GLib.Process class
|
||||||
|
and a cursory exercise of IOChannel for SpawnAsyncWithPipes.
|
||||||
|
|
||||||
2007-11-09 Mike Kestner <mkestner@novell.com>
|
2007-11-09 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* generator/Parameters.cs: support for null_term_array attribute.
|
* generator/Parameters.cs: support for null_term_array attribute.
|
||||||
|
|
472
doc/en/GLib/IOChannel.xml
Normal file
472
doc/en/GLib/IOChannel.xml
Normal file
|
@ -0,0 +1,472 @@
|
||||||
|
<Type Name="IOChannel" FullName="GLib.IOChannel">
|
||||||
|
<TypeSignature Language="C#" Value="public class IOChannel : GLib.IWrapper, IDisposable" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Object</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Interfaces>
|
||||||
|
<Interface>
|
||||||
|
<InterfaceName>GLib.IWrapper</InterfaceName>
|
||||||
|
</Interface>
|
||||||
|
<Interface>
|
||||||
|
<InterfaceName>System.IDisposable</InterfaceName>
|
||||||
|
</Interface>
|
||||||
|
</Interfaces>
|
||||||
|
<Members>
|
||||||
|
<Member MemberName=".ctor">
|
||||||
|
<MemberSignature Language="C#" Value="public IOChannel (int fd);" />
|
||||||
|
<MemberType>Constructor</MemberType>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="fd" Type="System.Int32" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="fd">A UNIX file descriptor.</param>
|
||||||
|
<summary>Public constructor.</summary>
|
||||||
|
<remarks>Constructs a channel for a UNIX file descriptor or pipe.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName=".ctor">
|
||||||
|
<MemberSignature Language="C#" Value="public IOChannel (string filename, string mode);" />
|
||||||
|
<MemberType>Constructor</MemberType>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="filename" Type="System.String" />
|
||||||
|
<Parameter Name="mode" Type="System.String" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="filename">Path to a file.</param>
|
||||||
|
<param name="mode">One of "r", "w", "a", "r+", "w+", "a+", with the same meaning as fopen.</param>
|
||||||
|
<summary>Public constructor.</summary>
|
||||||
|
<remarks>Constructs a channel for a file with a given mode.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="AddWatch">
|
||||||
|
<MemberSignature Language="C#" Value="public uint AddWatch (int priority, GLib.IOCondition condition, GLib.IOFunc func);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.UInt32</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="priority" Type="System.Int32" />
|
||||||
|
<Parameter Name="condition" Type="GLib.IOCondition" />
|
||||||
|
<Parameter Name="func" Type="GLib.IOFunc" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="priority">Priority level. Default priority is 0. System defined values range from -100 (High priority) to 300 (Low priority).</param>
|
||||||
|
<param name="condition">Conditions to notify.</param>
|
||||||
|
<param name="func">Notification callback delegate.</param>
|
||||||
|
<summary>Adds a notification watch to the mainloop at a given priority.</summary>
|
||||||
|
<returns>A source ID which can be removed with <see cref="M:GLib.Source.Remove" />.</returns>
|
||||||
|
<remarks>
|
||||||
|
<para>The following example spawns a process to run the pwd command and writes the output to the console using an IOChannel watch:</para>
|
||||||
|
<para>
|
||||||
|
<example>
|
||||||
|
<code lang="C#">
|
||||||
|
using GLib;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class SpawnTest {
|
||||||
|
|
||||||
|
public static void Main (string[] args)
|
||||||
|
{
|
||||||
|
new SpawnTest ();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainLoop main_loop;
|
||||||
|
IOChannel channel;
|
||||||
|
|
||||||
|
public SpawnTest ()
|
||||||
|
{
|
||||||
|
main_loop = new MainLoop ();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Process proc;
|
||||||
|
int stdin = Process.IgnorePipe;
|
||||||
|
int stdout = Process.RequestPipe;
|
||||||
|
int stderr = Process.IgnorePipe;
|
||||||
|
GLib.Process.SpawnAsyncWithPipes (null, new string[] {"pwd"}, null, SpawnFlags.SearchPath, null, out proc, ref stdin, ref stdout, ref stderr);
|
||||||
|
channel = new IOChannel (stdout);
|
||||||
|
channel.AddWatch (0, IOCondition.In | IOCondition.Hup, new IOFunc (ReadStdout));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine ("Exception in Spawn: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
main_loop.Run ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadStdout (IOChannel source, IOCondition condition)
|
||||||
|
{
|
||||||
|
if ((condition & IOCondition.In) == IOCondition.In) {
|
||||||
|
string txt;
|
||||||
|
if (source.ReadToEnd (out txt) == IOStatus.Normal)
|
||||||
|
Console.WriteLine ("[SpawnTest output] " + txt);
|
||||||
|
}
|
||||||
|
if ((condition & IOCondition.Hup) == IOCondition.Hup) {
|
||||||
|
source.Dispose ();
|
||||||
|
main_loop.Quit ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
|
</para>
|
||||||
|
</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="BufferCondition">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOCondition BufferCondition { get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOCondition</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>BufferCondition property.</summary>
|
||||||
|
<value>Indicates if there is data to read or room to output to the channel.</value>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Buffered">
|
||||||
|
<MemberSignature Language="C#" Value="public bool Buffered { set; get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Boolean</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Buffered property.</summary>
|
||||||
|
<value>A boolean value indicating if buffering is active.</value>
|
||||||
|
<remarks>Buffering can only be altered when the <see cref="M:GLib.IOChannel.Encoding" /> is <see langword="null" />. All other encodings must be buffered. It can only be cleared after the buffer has been flushed.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="BufferSize">
|
||||||
|
<MemberSignature Language="C#" Value="public ulong BufferSize { set; get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.UInt64</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>BufferSize property.</summary>
|
||||||
|
<value>The buffer size, or 0 to pick a reasonable size.</value>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="CloseOnUnref">
|
||||||
|
<MemberSignature Language="C#" Value="public bool CloseOnUnref { set; get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Boolean</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>CloseOnUnref property.</summary>
|
||||||
|
<value>A boolean indicating if the channel should be closed on disposal.</value>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Dispose">
|
||||||
|
<MemberSignature Language="C#" Value="public void Dispose ();" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Void</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters />
|
||||||
|
<Docs>
|
||||||
|
<summary>Disposes the channel.</summary>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Encoding">
|
||||||
|
<MemberSignature Language="C#" Value="public string Encoding { set; get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.String</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Encoding property.</summary>
|
||||||
|
<value>Specifies the native encoding of the channel. Use <see langword="null" /> for binary channels. The default encoding is UTF8.</value>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="ErrorFromErrno">
|
||||||
|
<MemberSignature Language="C#" Value="public static GLib.IOChannelError ErrorFromErrno (int en);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="en" Type="System.Int32" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="en">Error number.</param>
|
||||||
|
<summary>Converts an error number to an Error value.</summary>
|
||||||
|
<returns>The error.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Flags">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOFlags Flags { set; get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Flags property.</summary>
|
||||||
|
<value>The IO Flags for the channel.</value>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Flush">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus Flush ();" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters />
|
||||||
|
<Docs>
|
||||||
|
<summary>Flushes the write buffer for the channel.</summary>
|
||||||
|
<returns>Status of the operation.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="FromHandle">
|
||||||
|
<MemberSignature Language="C#" Value="public static GLib.IOChannel FromHandle (IntPtr handle);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannel</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="handle" Type="System.IntPtr" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="handle">Native channel pointer.</param>
|
||||||
|
<summary>Wraps a native channel.</summary>
|
||||||
|
<returns>A managed channel instance.</returns>
|
||||||
|
<remarks>Provided for language binding use.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Handle">
|
||||||
|
<MemberSignature Language="C#" Value="public IntPtr Handle { get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.IntPtr</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Handle property.</summary>
|
||||||
|
<value>A point to the native channel.</value>
|
||||||
|
<remarks>Provided for language binding use.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Init">
|
||||||
|
<MemberSignature Language="C#" Value="protected void Init ();" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Void</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters />
|
||||||
|
<Docs>
|
||||||
|
<summary>Init method.</summary>
|
||||||
|
<remarks>Provided for subclassers to initialize derived channels.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="LineTerminator">
|
||||||
|
<MemberSignature Language="C#" Value="public char[] LineTerminator { set; get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Char[]</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>LineTerminator property.</summary>
|
||||||
|
<value>The chars representing line termination in the channel.</value>
|
||||||
|
<remarks>This property is represented as an array of chars to allow for null char terminators.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="ReadChars">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus ReadChars (byte[] buf, out ulong bytes_read);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="buf" Type="System.Byte[]" />
|
||||||
|
<Parameter Name="bytes_read" Type="System.UInt64&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="buf">Buffer to store the read data.</param>
|
||||||
|
<param name="bytes_read">Length of data read.</param>
|
||||||
|
<summary>Reads data from the channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks>Method fills the buffer with as many complete utf8 characters as possible. Provided primarily for binary data reading in null encodings. Use <see cref="M:GLib.IOChannel.ReadLine" /> for text stream reading to strings.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="ReadLine">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus ReadLine (out string str_return);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="str_return" Type="System.String&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="str_return">Returns the next line in the channel.</param>
|
||||||
|
<summary>Reads a line from the channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="ReadLine">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus ReadLine (out string str_return, out ulong terminator_pos);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="str_return" Type="System.String&" RefType="out" />
|
||||||
|
<Parameter Name="terminator_pos" Type="System.UInt64&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="str_return">Returns the text read.</param>
|
||||||
|
<param name="terminator_pos">Location of line terminator.</param>
|
||||||
|
<summary>Reads the next line in the channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="ReadToEnd">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus ReadToEnd (out string str_return);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="str_return" Type="System.String&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="str_return">Returns the text read.</param>
|
||||||
|
<summary>Reads to the end of the channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="ReadUnichar">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus ReadUnichar (out uint thechar);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="thechar" Type="System.UInt32&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="thechar">Returns the UCS4 character.</param>
|
||||||
|
<summary>Reads a UCS4 character from the channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="SeekPosition">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus SeekPosition (long offset, GLib.SeekType type);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="offset" Type="System.Int64" />
|
||||||
|
<Parameter Name="type" Type="GLib.SeekType" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="offset">Byte offset.</param>
|
||||||
|
<param name="type">Base position.</param>
|
||||||
|
<summary>Seeks to a position in the channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Shutdown">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus Shutdown (bool flush);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="flush" Type="System.Boolean" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="flush">A boolean indicating if buffer should be flushed.</param>
|
||||||
|
<summary>Shuts down a channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="UnixFd">
|
||||||
|
<MemberSignature Language="C#" Value="public int UnixFd { get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Int32</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>UnixFd property.</summary>
|
||||||
|
<value>An integer representing the descriptor value.</value>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="WriteChars">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus WriteChars (byte[] buf, out ulong bytes_written);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="buf" Type="System.Byte[]" />
|
||||||
|
<Parameter Name="bytes_written" Type="System.UInt64&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="buf">Data buffer to write.</param>
|
||||||
|
<param name="bytes_written">Returns the number of bytes written.</param>
|
||||||
|
<summary>Writes binary data to a channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="WriteChars">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus WriteChars (string str, out string remainder);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="str" Type="System.String" />
|
||||||
|
<Parameter Name="remainder" Type="System.String&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="str">Text to write.</param>
|
||||||
|
<param name="remainder">Returns unwritten text.</param>
|
||||||
|
<summary>Writes text to the channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="WriteUnichar">
|
||||||
|
<MemberSignature Language="C#" Value="public GLib.IOStatus WriteUnichar (uint thechar);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="thechar" Type="System.UInt32" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="thechar">A UCS4 character.</param>
|
||||||
|
<summary>Writes a UCS4 character to the channel.</summary>
|
||||||
|
<returns>An operation status value.</returns>
|
||||||
|
<remarks />
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
<Docs>
|
||||||
|
<summary>IO Channel class.</summary>
|
||||||
|
<remarks>Provides methods to read and write data to an IO channel.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
106
doc/en/GLib/IOChannelError.xml
Normal file
106
doc/en/GLib/IOChannelError.xml
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
<Type Name="IOChannelError" FullName="GLib.IOChannelError">
|
||||||
|
<TypeSignature Language="C#" Value="public enum IOChannelError" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Enum</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Members>
|
||||||
|
<Member MemberName="Failed">
|
||||||
|
<MemberSignature Language="C#" Value="Failed" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Operation failed.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="FileTooBig">
|
||||||
|
<MemberSignature Language="C#" Value="FileTooBig" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>File too large.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Inval">
|
||||||
|
<MemberSignature Language="C#" Value="Inval" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Invalid argument.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="IO">
|
||||||
|
<MemberSignature Language="C#" Value="IO" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>IO error.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="IsDir">
|
||||||
|
<MemberSignature Language="C#" Value="IsDir" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>File is a directory.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="NoSpace">
|
||||||
|
<MemberSignature Language="C#" Value="NoSpace" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>No space left on device.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Nxio">
|
||||||
|
<MemberSignature Language="C#" Value="Nxio" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>No such device or address.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Overflow">
|
||||||
|
<MemberSignature Language="C#" Value="Overflow" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Value too large for defined data table.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Pipe">
|
||||||
|
<MemberSignature Language="C#" Value="Pipe" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOChannelError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Broken pipe.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
<Docs>
|
||||||
|
<summary>IOChannelError enumeration.</summary>
|
||||||
|
<remarks>Error results for IOChannel operations.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
81
doc/en/GLib/IOCondition.xml
Normal file
81
doc/en/GLib/IOCondition.xml
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
<Type Name="IOCondition" FullName="GLib.IOCondition">
|
||||||
|
<TypeSignature Language="C#" Value="public enum IOCondition" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Enum</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Attributes>
|
||||||
|
<Attribute>
|
||||||
|
<AttributeName>System.Flags</AttributeName>
|
||||||
|
</Attribute>
|
||||||
|
</Attributes>
|
||||||
|
<Members>
|
||||||
|
<Member MemberName="Err">
|
||||||
|
<MemberSignature Language="C#" Value="Err" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOCondition</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Error condition.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Hup">
|
||||||
|
<MemberSignature Language="C#" Value="Hup" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOCondition</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Hung up. The connection has been broken.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="In">
|
||||||
|
<MemberSignature Language="C#" Value="In" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOCondition</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>There is data to read.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Nval">
|
||||||
|
<MemberSignature Language="C#" Value="Nval" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOCondition</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Invalid request.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Out">
|
||||||
|
<MemberSignature Language="C#" Value="Out" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOCondition</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Data can be written without blocking.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Pri">
|
||||||
|
<MemberSignature Language="C#" Value="Pri" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOCondition</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>There is urgent data to be read.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
<Docs>
|
||||||
|
<summary>IOCondition enumeration.</summary>
|
||||||
|
<remarks>Flags to configure watches on an event source.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
101
doc/en/GLib/IOFlags.xml
Normal file
101
doc/en/GLib/IOFlags.xml
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
<Type Name="IOFlags" FullName="GLib.IOFlags">
|
||||||
|
<TypeSignature Language="C#" Value="public enum IOFlags" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Enum</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Attributes>
|
||||||
|
<Attribute>
|
||||||
|
<AttributeName>System.Flags</AttributeName>
|
||||||
|
</Attribute>
|
||||||
|
</Attributes>
|
||||||
|
<Members>
|
||||||
|
<Member MemberName="Append">
|
||||||
|
<MemberSignature Language="C#" Value="Append" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Enables Append mode.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="GetMask">
|
||||||
|
<MemberSignature Language="C#" Value="GetMask" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Mask for all flags.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="IsReadable">
|
||||||
|
<MemberSignature Language="C#" Value="IsReadable" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Enables read support.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="IsSeekable">
|
||||||
|
<MemberSignature Language="C#" Value="IsSeekable" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Enables seek support.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="IsWriteable">
|
||||||
|
<MemberSignature Language="C#" Value="IsWriteable" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Enables write support.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Mask">
|
||||||
|
<MemberSignature Language="C#" Value="Mask" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Mask for all flags.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Nonblock">
|
||||||
|
<MemberSignature Language="C#" Value="Nonblock" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Enables non-blocking mode.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="SetMask">
|
||||||
|
<MemberSignature Language="C#" Value="SetMask" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Enables non-blocking and append mode.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
<Docs>
|
||||||
|
<summary>IOFlags enumeration.</summary>
|
||||||
|
<remarks>Flags for configuring IO channel usage.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
24
doc/en/GLib/IOFunc.xml
Normal file
24
doc/en/GLib/IOFunc.xml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<Type Name="IOFunc" FullName="GLib.IOFunc">
|
||||||
|
<TypeSignature Language="C#" Value="public delegate bool IOFunc(IOChannel source, IOCondition condition);" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Delegate</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="source" Type="GLib.IOChannel" />
|
||||||
|
<Parameter Name="condition" Type="GLib.IOCondition" />
|
||||||
|
</Parameters>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Boolean</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<param name="source">The <see cref="T:GLib.IOChannel" /> raising the notification.</param>
|
||||||
|
<param name="condition">The condition prompting the notification.</param>
|
||||||
|
<summary>Callback delegate for IO channel notifications.</summary>
|
||||||
|
<returns>If <see langword="false" />, the delegate is removed from the main loop.</returns>
|
||||||
|
<remarks>Use an instance of this delegate to add watch notifications for IO channels.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
56
doc/en/GLib/IOStatus.xml
Normal file
56
doc/en/GLib/IOStatus.xml
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<Type Name="IOStatus" FullName="GLib.IOStatus">
|
||||||
|
<TypeSignature Language="C#" Value="public enum IOStatus" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Enum</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Members>
|
||||||
|
<Member MemberName="Again">
|
||||||
|
<MemberSignature Language="C#" Value="Again" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Resource was temporarily unavailable.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Eof">
|
||||||
|
<MemberSignature Language="C#" Value="Eof" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>End of file reached.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Error">
|
||||||
|
<MemberSignature Language="C#" Value="Error" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>An error occurred.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Normal">
|
||||||
|
<MemberSignature Language="C#" Value="Normal" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.IOStatus</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Operation completed normally.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
<Docs>
|
||||||
|
<summary>IOStatus enumeration.</summary>
|
||||||
|
<remarks>Status results for IO channel operations.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
302
doc/en/GLib/Process.xml
Normal file
302
doc/en/GLib/Process.xml
Normal file
|
@ -0,0 +1,302 @@
|
||||||
|
<Type Name="Process" FullName="GLib.Process">
|
||||||
|
<TypeSignature Language="C#" Value="public class Process" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Object</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Interfaces />
|
||||||
|
<Members>
|
||||||
|
<Member MemberName="IgnorePipe">
|
||||||
|
<MemberSignature Language="C#" Value="public const int IgnorePipe = 2147483647;" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Int32</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<MemberValue>2147483647</MemberValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>IgnorePipe field.</summary>
|
||||||
|
<remarks>Pass this value to <see cref="M:GLib.Process.SpawnAsyncWithPipes" /> to ignore a pipe parameter.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="RequestPipe">
|
||||||
|
<MemberSignature Language="C#" Value="public const int RequestPipe = 0;" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Int32</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<MemberValue>0</MemberValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>RequestPipe field.</summary>
|
||||||
|
<remarks>Pass this value to <see cref="M:GLib.Process.SpawnAsyncWithPipes" /> to request a request a pipe descriptor be returned in the parameter.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="SpawnCommandLineAsync">
|
||||||
|
<MemberSignature Language="C#" Value="public static bool SpawnCommandLineAsync (string command_line);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Boolean</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="command_line" Type="System.String" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="command_line">The command line with arguments.</param>
|
||||||
|
<summary>Spawns a child process asynchronously.</summary>
|
||||||
|
<returns>A boolean value indicating spawning success.</returns>
|
||||||
|
<remarks />
|
||||||
|
<remarks>
|
||||||
|
<para>This method does not wait for the child process to complete before returning. It is a convenience method for the more detailed <see cref="M:GLib.Process.SpawnAsync" /> method.</para>
|
||||||
|
<para>
|
||||||
|
<example>
|
||||||
|
<code lang="C#">
|
||||||
|
...
|
||||||
|
try {
|
||||||
|
GLib.Process.SpawnCommandLineAsync ("echo \"[Async echo process running]\"");
|
||||||
|
} catch (GException e) {
|
||||||
|
Console.WriteLine ("Exception in Spawn operation: " + e);
|
||||||
|
}
|
||||||
|
...
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
|
</para>
|
||||||
|
</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="SpawnCommandLineSync">
|
||||||
|
<MemberSignature Language="C#" Value="public static bool SpawnCommandLineSync (string command_line, out string stdout, out string stderr, out int exit_status);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Boolean</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="command_line" Type="System.String" />
|
||||||
|
<Parameter Name="stdout" Type="System.String&" RefType="out" />
|
||||||
|
<Parameter Name="stderr" Type="System.String&" RefType="out" />
|
||||||
|
<Parameter Name="exit_status" Type="System.Int32&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="command_line">The command line with arguments.</param>
|
||||||
|
<param name="stdout">Returns the stdout output of the child process as a string.</param>
|
||||||
|
<param name="stderr">Returns the stderr output of the child process as a string.</param>
|
||||||
|
<param name="exit_status">Returns the exit code returned by the process.</param>
|
||||||
|
<summary>Spawns a child process synchronously.</summary>
|
||||||
|
<returns>A boolean value indicating spawning success.</returns>
|
||||||
|
<remarks>
|
||||||
|
<para>The method waits for the child process to complete prior to returning. This is a convenience method for the more detailed <see cref="M:GLib.Process.SpawnSync" /> method.</para>
|
||||||
|
<para>
|
||||||
|
<example>
|
||||||
|
<code lang="C#">
|
||||||
|
...
|
||||||
|
try {
|
||||||
|
string stdout, stderr;
|
||||||
|
int exit_status;
|
||||||
|
GLib.Process.SpawnCommandLineSync ("pwd", out stdout, out stderr, out exit_status);
|
||||||
|
Console.Write ("pwd exit_status=" + exit_status + " output: " + stdout);
|
||||||
|
} catch (GException e) {
|
||||||
|
Console.WriteLine ("Exception in Spawn operation: " + e);
|
||||||
|
}
|
||||||
|
...
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
|
</para>
|
||||||
|
</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="SpawnSync">
|
||||||
|
<MemberSignature Language="C#" Value="public static bool SpawnSync (string working_directory, string[] argv, string[] envp, GLib.SpawnFlags flags, GLib.SpawnChildSetupFunc child_setup, out string stdout, out string stderr, out int exit_status);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Boolean</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="working_directory" Type="System.String" />
|
||||||
|
<Parameter Name="argv" Type="System.String[]" />
|
||||||
|
<Parameter Name="envp" Type="System.String[]" />
|
||||||
|
<Parameter Name="flags" Type="GLib.SpawnFlags" />
|
||||||
|
<Parameter Name="child_setup" Type="GLib.SpawnChildSetupFunc" />
|
||||||
|
<Parameter Name="stdout" Type="System.String&" RefType="out" />
|
||||||
|
<Parameter Name="stderr" Type="System.String&" RefType="out" />
|
||||||
|
<Parameter Name="exit_status" Type="System.Int32&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="working_directory">The directory in which to execute the process, or <see langword="null" /> to use the current directory of the parent process.</param>
|
||||||
|
<param name="argv">A string array containing the program name in the first element.</param>
|
||||||
|
<param name="envp">An array of environment values in the form 'var=value', or <see langword="null" />.</param>
|
||||||
|
<param name="flags">Process spawning configuration flags.</param>
|
||||||
|
<param name="child_setup">A child process setup callback, or <see langword="null" />.</param>
|
||||||
|
<param name="stdout">Returns the stdout output of the child process as a string.</param>
|
||||||
|
<param name="stderr">Returns the stderr output of the child process as a string.</param>
|
||||||
|
<param name="exit_status">Returns the exit code of the child process.</param>
|
||||||
|
<summary>Spawns a child process synchronously.</summary>
|
||||||
|
<returns>A boolean value indicating spawning success.</returns>
|
||||||
|
<remarks>
|
||||||
|
<para>The method waits for the child process to complete prior to returning.</para>
|
||||||
|
<para>
|
||||||
|
<example>
|
||||||
|
<code lang="C#">
|
||||||
|
...
|
||||||
|
try {
|
||||||
|
string stdout, stderr;
|
||||||
|
int exit_status;
|
||||||
|
GLib.Process.SpawnSync ("/usr", new string[] {"pwd"}, null, GLib.SpawnFlags.SearchPath, null, out stdout, out stderr, out exit_status);
|
||||||
|
Console.Write ("pwd exit_status=" + exit_status + " output: " + stdout);
|
||||||
|
} catch (GException e) {
|
||||||
|
Console.WriteLine ("Exception in Spawn operation: " + e);
|
||||||
|
}
|
||||||
|
...
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
|
</para>
|
||||||
|
</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Close">
|
||||||
|
<MemberSignature Language="C#" Value="public void Close ();" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Void</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters />
|
||||||
|
<Docs>
|
||||||
|
<summary>Closes a process.</summary>
|
||||||
|
<remarks>Processes spawned with <see cref="M:GLib.SpawnFlags.DoNotReapChild" /> must use this method to ensure zombie processes are not stranded.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="SpawnAsync">
|
||||||
|
<MemberSignature Language="C#" Value="public static bool SpawnAsync (string working_directory, string[] argv, string[] envp, GLib.SpawnFlags flags, GLib.SpawnChildSetupFunc child_setup, out GLib.Process child_process);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Boolean</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="working_directory" Type="System.String" />
|
||||||
|
<Parameter Name="argv" Type="System.String[]" />
|
||||||
|
<Parameter Name="envp" Type="System.String[]" />
|
||||||
|
<Parameter Name="flags" Type="GLib.SpawnFlags" />
|
||||||
|
<Parameter Name="child_setup" Type="GLib.SpawnChildSetupFunc" />
|
||||||
|
<Parameter Name="child_process" Type="GLib.Process&" RefType="out" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="working_directory">The directory in which to execute the process, or <see langword="null" /> to use the current directory of the parent process.</param>
|
||||||
|
<param name="argv">A string array containing the program name in the first element.</param>
|
||||||
|
<param name="envp">An array of environment values in the form 'var=value', or <see langword="null" />.</param>
|
||||||
|
<param name="flags">Process spawning configuration flags.</param>
|
||||||
|
<param name="child_setup">A child process setup callback, or <see langword="null" />.</param>
|
||||||
|
<param name="child_process">Returns the child process.</param>
|
||||||
|
<summary>Spawns a child process asynchronously.</summary>
|
||||||
|
<returns>A boolean value indicating spawning success.</returns>
|
||||||
|
<remarks>
|
||||||
|
<para>The method does not wait for the child process to complete before returning. This is a convenience method for the more detailed <see cref="M:GLib.Process.SpawnAsyncWithPipes" /> method. This method throws <see cref="T:GLib.GException" /> if an error occurs creating the process.</para>
|
||||||
|
<para>
|
||||||
|
<example>
|
||||||
|
<code lang="C#">
|
||||||
|
...
|
||||||
|
try {
|
||||||
|
GLib.Process proc;
|
||||||
|
GLib.Process.SpawnAsync (null, new string[] {"echo", "[Async echo is running]"}, null, GLib.SpawnFlags.SearchPath, null, out proc);
|
||||||
|
} catch (GException e) {
|
||||||
|
Console.WriteLine ("Exception in Spawn operation: " + e);
|
||||||
|
}
|
||||||
|
...
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
|
</para>
|
||||||
|
</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="SpawnAsyncWithPipes">
|
||||||
|
<MemberSignature Language="C#" Value="public static bool SpawnAsyncWithPipes (string working_directory, string[] argv, string[] envp, GLib.SpawnFlags flags, GLib.SpawnChildSetupFunc child_setup, out GLib.Process child_process, ref int stdin, ref int stdout, ref int stderr);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Boolean</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="working_directory" Type="System.String" />
|
||||||
|
<Parameter Name="argv" Type="System.String[]" />
|
||||||
|
<Parameter Name="envp" Type="System.String[]" />
|
||||||
|
<Parameter Name="flags" Type="GLib.SpawnFlags" />
|
||||||
|
<Parameter Name="child_setup" Type="GLib.SpawnChildSetupFunc" />
|
||||||
|
<Parameter Name="child_process" Type="GLib.Process&" RefType="out" />
|
||||||
|
<Parameter Name="stdin" Type="System.Int32&" RefType="ref" />
|
||||||
|
<Parameter Name="stdout" Type="System.Int32&" RefType="ref" />
|
||||||
|
<Parameter Name="stderr" Type="System.Int32&" RefType="ref" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<param name="working_directory">The directory in which to execute the process, or <see langword="null" /> to use the current directory of the parent process.</param>
|
||||||
|
<param name="argv">A string array containing the program name in the first element.</param>
|
||||||
|
<param name="envp">An array of environment values in the form 'var=value', or <see langword="null" />.</param>
|
||||||
|
<param name="flags">Process spawning configuration flags.</param>
|
||||||
|
<param name="child_setup">A child process setup callback, or <see langword="null" />.</param>
|
||||||
|
<param name="child_process">Returns the spawned process.</param>
|
||||||
|
<param name="stdin">Returns the stdin pipe descriptor if caller passes anything but <see cref="GLib.Process.IgnorePipe" />.</param>
|
||||||
|
<param name="stdout">Returns the stdout pipe descriptor if caller passes anything but <see cref="GLib.Process.IgnorePipe" />.</param>
|
||||||
|
<param name="stderr">Returns the stderr pipe descriptor if caller passes anything but <see cref="GLib.Process.IgnorePipe" />.</param>
|
||||||
|
<summary>Spawns a child process and returns requested pipe descriptors.</summary>
|
||||||
|
<returns>A boolean value indicating operation success.</returns>
|
||||||
|
<remarks>
|
||||||
|
<para>This method throws <see cref="T:GLib.GException" /> if an error occurs creating the process.</para>
|
||||||
|
<para>
|
||||||
|
<example>
|
||||||
|
<code lang="C#">
|
||||||
|
using GLib;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class SpawnTest {
|
||||||
|
|
||||||
|
public static void Main (string[] args)
|
||||||
|
{
|
||||||
|
new SpawnTest ();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainLoop main_loop;
|
||||||
|
IOChannel channel;
|
||||||
|
|
||||||
|
public SpawnTest ()
|
||||||
|
{
|
||||||
|
main_loop = new MainLoop ();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Process proc;
|
||||||
|
int stdin = Process.IgnorePipe;
|
||||||
|
int stdout = Process.RequestPipe;
|
||||||
|
int stderr = Process.IgnorePipe;
|
||||||
|
GLib.Process.SpawnAsyncWithPipes (null, new string[] {"pwd"}, null, SpawnFlags.SearchPath, null, out proc, ref stdin, ref stdout, ref stderr);
|
||||||
|
channel = new IOChannel (stdout);
|
||||||
|
channel.AddWatch (0, IOCondition.In | IOCondition.Hup, new IOFunc (ReadStdout));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine ("Exception in Spawn: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
main_loop.Run ();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadStdout (IOChannel source, IOCondition condition)
|
||||||
|
{
|
||||||
|
if ((condition & IOCondition.In) == IOCondition.In) {
|
||||||
|
string txt;
|
||||||
|
if (source.ReadToEnd (out txt) == IOStatus.Normal)
|
||||||
|
Console.WriteLine ("[SpawnTest output] " + txt);
|
||||||
|
}
|
||||||
|
if ((condition & IOCondition.Hup) == IOCondition.Hup) {
|
||||||
|
source.Dispose ();
|
||||||
|
main_loop.Quit ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</example>
|
||||||
|
</para>
|
||||||
|
</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
<Docs>
|
||||||
|
<summary>Process class.</summary>
|
||||||
|
<remarks>Methods for spawning child processes.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
46
doc/en/GLib/SeekType.xml
Normal file
46
doc/en/GLib/SeekType.xml
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<Type Name="SeekType" FullName="GLib.SeekType">
|
||||||
|
<TypeSignature Language="C#" Value="public enum SeekType" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Enum</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Members>
|
||||||
|
<Member MemberName="Cur">
|
||||||
|
<MemberSignature Language="C#" Value="Cur" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SeekType</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Current position in the file.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="End">
|
||||||
|
<MemberSignature Language="C#" Value="End" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SeekType</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>End of the file.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Set">
|
||||||
|
<MemberSignature Language="C#" Value="Set" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SeekType</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Start of the file.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
<Docs>
|
||||||
|
<summary>SeekType enumeration.</summary>
|
||||||
|
<remarks>Base positions for seek operations.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
18
doc/en/GLib/SpawnChildSetupFunc.xml
Normal file
18
doc/en/GLib/SpawnChildSetupFunc.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<Type Name="SpawnChildSetupFunc" FullName="GLib.SpawnChildSetupFunc">
|
||||||
|
<TypeSignature Language="C#" Value="public delegate void SpawnChildSetupFunc();" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Delegate</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Parameters />
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Void</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Child process setup callback delegate.</summary>
|
||||||
|
<remarks>Pass this delegate one of the Spawn methods on <see cref="T:GLib.Process" /> to perform process setup. Note that using this capability can cause portability issues if you are targetting a win32 environment. In POSIX environments, the function is run in the child's environment, but on win32 this is not possible, so it runs in the parent environment.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
216
doc/en/GLib/SpawnError.xml
Normal file
216
doc/en/GLib/SpawnError.xml
Normal file
|
@ -0,0 +1,216 @@
|
||||||
|
<Type Name="SpawnError" FullName="GLib.SpawnError">
|
||||||
|
<TypeSignature Language="C#" Value="public enum SpawnError" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Enum</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Members>
|
||||||
|
<Member MemberName="Acces">
|
||||||
|
<MemberSignature Language="C#" Value="Acces" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned EACCESS.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Chdir">
|
||||||
|
<MemberSignature Language="C#" Value="Chdir" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Changing to working directory failed.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Failed">
|
||||||
|
<MemberSignature Language="C#" Value="Failed" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Some other failure. Error message output will have additional info.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Fork">
|
||||||
|
<MemberSignature Language="C#" Value="Fork" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Fork failed due to lack of memory.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Inval">
|
||||||
|
<MemberSignature Language="C#" Value="Inval" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned EINVAL.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="IO">
|
||||||
|
<MemberSignature Language="C#" Value="IO" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned EIO.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="IsDir">
|
||||||
|
<MemberSignature Language="C#" Value="IsDir" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned EISDIR.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="LibBad">
|
||||||
|
<MemberSignature Language="C#" Value="LibBad" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ELIBBAD.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Loop">
|
||||||
|
<MemberSignature Language="C#" Value="Loop" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ELOOP.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="MFile">
|
||||||
|
<MemberSignature Language="C#" Value="MFile" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned EMFILE.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="NameTooLong">
|
||||||
|
<MemberSignature Language="C#" Value="NameTooLong" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ENAMETOOLONG.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="NFile">
|
||||||
|
<MemberSignature Language="C#" Value="NFile" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ENFILE.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="NoEnt">
|
||||||
|
<MemberSignature Language="C#" Value="NoEnt" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ENOENT.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="NoExec">
|
||||||
|
<MemberSignature Language="C#" Value="NoExec" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ENOEXEC.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="NoMem">
|
||||||
|
<MemberSignature Language="C#" Value="NoMem" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ENOMEM.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="NotDir">
|
||||||
|
<MemberSignature Language="C#" Value="NotDir" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ENOTDIR.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Perm">
|
||||||
|
<MemberSignature Language="C#" Value="Perm" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned EPERM.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Read">
|
||||||
|
<MemberSignature Language="C#" Value="Read" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Read or select on pipe failed.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="TooBig">
|
||||||
|
<MemberSignature Language="C#" Value="TooBig" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ETOOBIG.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="TxtBusy">
|
||||||
|
<MemberSignature Language="C#" Value="TxtBusy" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnError</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>execv() returned ETXTBUSY.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
<Docs>
|
||||||
|
<summary>SpawnError enumeration.</summary>
|
||||||
|
<remarks>Error codes returned by process spawing methods.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
91
doc/en/GLib/SpawnFlags.xml
Normal file
91
doc/en/GLib/SpawnFlags.xml
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
<Type Name="SpawnFlags" FullName="GLib.SpawnFlags">
|
||||||
|
<TypeSignature Language="C#" Value="public enum SpawnFlags" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyVersion>2.10.0.0</AssemblyVersion>
|
||||||
|
</AssemblyInfo>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Enum</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Attributes>
|
||||||
|
<Attribute>
|
||||||
|
<AttributeName>System.Flags</AttributeName>
|
||||||
|
</Attribute>
|
||||||
|
</Attributes>
|
||||||
|
<Members>
|
||||||
|
<Member MemberName="ChildInheritsStdin">
|
||||||
|
<MemberSignature Language="C#" Value="ChildInheritsStdin" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Indicates if the child process should inherit the parent's stdin.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="DoNotReapChild">
|
||||||
|
<MemberSignature Language="C#" Value="DoNotReapChild" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Indicates if child should not be reaped automatically. Caller must call <see cref="M:GLib.Process.Close" /> on the returned process to avoid zombies.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="FileAndArgvZero">
|
||||||
|
<MemberSignature Language="C#" Value="FileAndArgvZero" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Indicates if the first element should be dropped from the argv that is passed to the process. Normally the first element of the argv is the program name to be invoked, and the entire argv is passed to the process, including the program name. Using this flag causes the program name to be dropped from the vector.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="LeaveDescriptorsOpen">
|
||||||
|
<MemberSignature Language="C#" Value="LeaveDescriptorsOpen" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Indicates if parent file descriptors should remain open for the child. Without this flag, all descriptors except for stdin, stdout, and stderr are closed.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="SearchPath">
|
||||||
|
<MemberSignature Language="C#" Value="SearchPath" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Indicates if the user's PATH variable should be used to locate the executable. Without this flag, a fully-qualified path to the executable must be provided in the command or argument vector. Setting this flag can create security issues, so it should be used with caution.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="StderrToDevNull">
|
||||||
|
<MemberSignature Language="C#" Value="StderrToDevNull" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Indicates if stderr should be redirected to /dev/null, ignoring the output. If this flag is set, users of <see cref="M:GLib.Process.SpawnAsyncWithPipes" /> must pass <see cref="M:GLib.Process.IgnorePipe" /> for the stderr parameter.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="StdoutToDevNull">
|
||||||
|
<MemberSignature Language="C#" Value="StdoutToDevNull" />
|
||||||
|
<MemberType>Field</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>GLib.SpawnFlags</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Docs>
|
||||||
|
<summary>Indicates if stdout should be redirected to /dev/null, ignoring the output. If this flag is set, users of <see cref="M:GLib.Process.SpawnAsyncWithPipes" /> must pass <see cref="M:GLib.Process.IgnorePipe" /> for the stdout parameter.</summary>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
<Docs>
|
||||||
|
<summary>SpawnFlags enumeration.</summary>
|
||||||
|
<remarks>Provides process spawning configuration information.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Type>
|
469
glib/IOChannel.cs
Normal file
469
glib/IOChannel.cs
Normal file
|
@ -0,0 +1,469 @@
|
||||||
|
// glib/IOChannel.cs : IOChannel API wrapper
|
||||||
|
//
|
||||||
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2007 Novell, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of version 2 of the Lesser GNU General
|
||||||
|
// Public License as published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this program; if not, write to the
|
||||||
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
|
namespace GLibSharp {
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using GLib;
|
||||||
|
|
||||||
|
[CDeclCallback]
|
||||||
|
internal delegate bool IOFuncNative(IntPtr source, int condition, IntPtr data);
|
||||||
|
|
||||||
|
internal class IOFuncWrapper {
|
||||||
|
|
||||||
|
IOFunc managed;
|
||||||
|
|
||||||
|
public IOFuncNative NativeDelegate;
|
||||||
|
|
||||||
|
public IOFuncWrapper (IOFunc managed)
|
||||||
|
{
|
||||||
|
this.managed = managed;
|
||||||
|
NativeDelegate = new IOFuncNative (NativeCallback);
|
||||||
|
}
|
||||||
|
bool NativeCallback (IntPtr source, int condition, IntPtr data)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return managed (IOChannel.FromHandle (source), (IOCondition) condition);
|
||||||
|
} catch (Exception e) {
|
||||||
|
ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace GLib {
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using GLibSharp;
|
||||||
|
|
||||||
|
public class IOChannel : IDisposable, IWrapper {
|
||||||
|
|
||||||
|
IntPtr handle;
|
||||||
|
|
||||||
|
private IOChannel(IntPtr handle)
|
||||||
|
{
|
||||||
|
this.handle = handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOChannel (int fd) : this (g_io_channel_unix_new (fd)) {}
|
||||||
|
|
||||||
|
public IOChannel (string filename, string mode)
|
||||||
|
{
|
||||||
|
IntPtr native_filename = Marshaller.StringToPtrGStrdup (filename);
|
||||||
|
IntPtr native_mode = Marshaller.StringToPtrGStrdup (mode);
|
||||||
|
IntPtr error;
|
||||||
|
handle = g_io_channel_new_file(native_filename, native_mode, out error);
|
||||||
|
Marshaller.Free (native_filename);
|
||||||
|
Marshaller.Free (native_mode);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOCondition BufferCondition
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return (IOCondition) g_io_channel_get_buffer_condition (Handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Buffered
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return g_io_channel_get_buffered (Handle);
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
g_io_channel_set_buffered (Handle, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ulong BufferSize
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return (ulong) g_io_channel_get_buffer_size (Handle);
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
g_io_channel_set_buffer_size (Handle, new UIntPtr (value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CloseOnUnref
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return g_io_channel_get_close_on_unref (Handle);
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
g_io_channel_set_close_on_unref (Handle, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Encoding
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return Marshaller.Utf8PtrToString (g_io_channel_get_encoding (Handle));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
IntPtr native_encoding = Marshaller.StringToPtrGStrdup (value);
|
||||||
|
IntPtr error;
|
||||||
|
g_io_channel_set_encoding (Handle, native_encoding, out error);
|
||||||
|
Marshaller.Free (native_encoding);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOFlags Flags
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return (IOFlags) g_io_channel_get_flags(Handle);
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
IntPtr error;
|
||||||
|
g_io_channel_set_flags(Handle, (int) value, out error);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public char[] LineTerminator {
|
||||||
|
get {
|
||||||
|
int length;
|
||||||
|
IntPtr raw = g_io_channel_get_line_term (Handle, out length);
|
||||||
|
if (length == -1)
|
||||||
|
return Marshaller.Utf8PtrToString (raw).ToCharArray ();
|
||||||
|
byte[] buffer = new byte [length];
|
||||||
|
return System.Text.Encoding.UTF8.GetChars (buffer);
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
byte[] buffer = System.Text.Encoding.UTF8.GetBytes (value);
|
||||||
|
g_io_channel_set_line_term (Handle, buffer, buffer.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr Handle {
|
||||||
|
get {
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int UnixFd {
|
||||||
|
get {
|
||||||
|
return g_io_channel_unix_get_fd (Handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Init ()
|
||||||
|
{
|
||||||
|
g_io_channel_init (Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose ()
|
||||||
|
{
|
||||||
|
g_io_channel_unref (Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint AddWatch (int priority, IOCondition condition, IOFunc func)
|
||||||
|
{
|
||||||
|
IOFuncWrapper func_wrapper = null;
|
||||||
|
IntPtr user_data = IntPtr.Zero;
|
||||||
|
DestroyNotify notify = null;
|
||||||
|
if (func != null) {
|
||||||
|
func_wrapper = new IOFuncWrapper (func);
|
||||||
|
user_data = (IntPtr) GCHandle.Alloc (func_wrapper);
|
||||||
|
notify = DestroyHelper.NotifyHandler;
|
||||||
|
}
|
||||||
|
return g_io_add_watch_full (Handle, priority, (int) condition, func_wrapper.NativeDelegate, user_data, notify);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus Flush ()
|
||||||
|
{
|
||||||
|
IntPtr error;
|
||||||
|
IOStatus ret = (IOStatus) g_io_channel_flush (Handle, out error);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus ReadChars (byte[] buf, out ulong bytes_read)
|
||||||
|
{
|
||||||
|
UIntPtr native_bytes_read;
|
||||||
|
IntPtr error;
|
||||||
|
IOStatus ret = (IOStatus) g_io_channel_read_chars (Handle, buf, new UIntPtr ((ulong) buf.Length), out native_bytes_read, out error);
|
||||||
|
bytes_read = (ulong) native_bytes_read;
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus ReadLine (out string str_return)
|
||||||
|
{
|
||||||
|
ulong dump;
|
||||||
|
return ReadLine (out str_return, out dump);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus ReadLine (out string str_return, out ulong terminator_pos)
|
||||||
|
{
|
||||||
|
IntPtr native_string;
|
||||||
|
UIntPtr native_terminator_pos;
|
||||||
|
IntPtr error;
|
||||||
|
IOStatus ret = (IOStatus) g_io_channel_read_line (Handle, out native_string, IntPtr.Zero, out native_terminator_pos, out error);
|
||||||
|
terminator_pos = (ulong) native_terminator_pos;
|
||||||
|
str_return = null;
|
||||||
|
if (ret == IOStatus.Normal)
|
||||||
|
str_return = Marshaller.PtrToStringGFree (native_string);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus ReadToEnd (out string str_return)
|
||||||
|
{
|
||||||
|
IntPtr native_str;
|
||||||
|
UIntPtr native_length;
|
||||||
|
IntPtr error;
|
||||||
|
IOStatus ret = (IOStatus) g_io_channel_read_to_end (Handle, out native_str, out native_length, out error);
|
||||||
|
str_return = null;
|
||||||
|
if (ret == IOStatus.Normal) {
|
||||||
|
byte[] buffer = new byte [(ulong) native_length];
|
||||||
|
Marshal.Copy (native_str, buffer, 0, (int)(ulong) native_length);
|
||||||
|
str_return = System.Text.Encoding.UTF8.GetString (buffer);
|
||||||
|
}
|
||||||
|
Marshaller.Free (native_str);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus ReadUnichar (out uint thechar)
|
||||||
|
{
|
||||||
|
IntPtr error;
|
||||||
|
IOStatus ret = (IOStatus) g_io_channel_read_unichar (Handle, out thechar, out error);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus SeekPosition (long offset, SeekType type)
|
||||||
|
{
|
||||||
|
IntPtr error;
|
||||||
|
IOStatus ret = (IOStatus) g_io_channel_seek_position (Handle, offset, (int) type, out error);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus Shutdown (bool flush)
|
||||||
|
{
|
||||||
|
IntPtr error;
|
||||||
|
IOStatus ret = (IOStatus) g_io_channel_shutdown (Handle, flush, out error);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus WriteChars (string str, out string remainder)
|
||||||
|
{
|
||||||
|
ulong written;
|
||||||
|
System.Text.Encoding enc = System.Text.Encoding.UTF8;
|
||||||
|
byte[] buffer = enc.GetBytes (str);
|
||||||
|
IOStatus ret = WriteChars (buffer, out written);
|
||||||
|
remainder = null;
|
||||||
|
if ((int) written == buffer.Length)
|
||||||
|
return ret;
|
||||||
|
int count = buffer.Length - (int) written;
|
||||||
|
byte[] rem = new byte [count];
|
||||||
|
Array.Copy (buffer, (int) written, rem, 0, count);
|
||||||
|
remainder = enc.GetString (rem);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus WriteChars (byte[] buf, out ulong bytes_written)
|
||||||
|
{
|
||||||
|
UIntPtr native_bytes_written;
|
||||||
|
IntPtr error;
|
||||||
|
IOStatus ret = (IOStatus) g_io_channel_write_chars (Handle, buf, new IntPtr (buf.Length), out native_bytes_written, out error);
|
||||||
|
bytes_written = (ulong) native_bytes_written;
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOStatus WriteUnichar (uint thechar)
|
||||||
|
{
|
||||||
|
IntPtr error;
|
||||||
|
IOStatus ret = (IOStatus) g_io_channel_write_unichar (Handle, thechar, out error);
|
||||||
|
if (error != IntPtr.Zero) throw new GException (error);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IOChannel FromHandle (IntPtr handle)
|
||||||
|
{
|
||||||
|
if (handle == IntPtr.Zero)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
g_io_channel_ref (handle);
|
||||||
|
return new IOChannel (handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IOChannelError ErrorFromErrno (int en)
|
||||||
|
{
|
||||||
|
return (IOChannelError) g_io_channel_error_from_errno (en);
|
||||||
|
}
|
||||||
|
|
||||||
|
const string libname = "libglib-2.0-0.dll";
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern IntPtr g_io_channel_unix_new (int fd);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern IntPtr g_io_channel_new_file (IntPtr filename, IntPtr mode, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_error_quark ();
|
||||||
|
|
||||||
|
[DllImport(libname)]
|
||||||
|
static extern int g_io_channel_error_from_errno (int en);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_flush (IntPtr raw, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern void g_io_channel_init (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_read_chars (IntPtr raw, byte[] buf, UIntPtr count, out UIntPtr bytes_read, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_read_line (IntPtr raw, out IntPtr str_return, IntPtr length, out UIntPtr terminator_pos, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_read_to_end (IntPtr raw, out IntPtr str_return, out UIntPtr length, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_read_unichar (IntPtr raw, out uint thechar, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_seek_position (IntPtr raw, long offset, int type, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_shutdown (IntPtr raw, bool flush, out IntPtr err);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_write_chars (IntPtr raw, byte[] buf, IntPtr count, out UIntPtr bytes_written, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_write_unichar (IntPtr raw, uint thechar, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_get_buffer_condition (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern bool g_io_channel_get_buffered (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern void g_io_channel_set_buffered (IntPtr raw, bool buffered);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern UIntPtr g_io_channel_get_buffer_size (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern void g_io_channel_set_buffer_size (IntPtr raw, UIntPtr size);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern bool g_io_channel_get_close_on_unref (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern void g_io_channel_set_close_on_unref (IntPtr raw, bool do_close);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern IntPtr g_io_channel_get_encoding (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_set_encoding (IntPtr raw, IntPtr encoding, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_get_flags (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_set_flags (IntPtr raw, int flags, out IntPtr error);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern IntPtr g_io_channel_get_line_term (IntPtr raw, out int length);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern void g_io_channel_set_line_term (IntPtr raw, byte[] term, int length);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern int g_io_channel_unix_get_fd (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern IntPtr g_io_channel_ref (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern void g_io_channel_unref (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern uint g_io_add_watch_full (IntPtr raw, int priority, int condition, IOFuncNative func, IntPtr user_data, DestroyNotify notify);
|
||||||
|
|
||||||
|
[DllImport (libname)]
|
||||||
|
static extern IntPtr g_io_create_watch (IntPtr raw, int condition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate bool IOFunc (IOChannel source, IOCondition condition);
|
||||||
|
|
||||||
|
public enum IOChannelError {
|
||||||
|
FileTooBig,
|
||||||
|
Inval,
|
||||||
|
IO,
|
||||||
|
IsDir,
|
||||||
|
NoSpace,
|
||||||
|
Nxio,
|
||||||
|
Overflow,
|
||||||
|
Pipe,
|
||||||
|
Failed,
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum IOCondition {
|
||||||
|
In = 1 << 0,
|
||||||
|
Out = 1 << 2,
|
||||||
|
Pri = 1 << 1,
|
||||||
|
Err = 1 << 3,
|
||||||
|
Hup = 1 << 4,
|
||||||
|
Nval = 1 << 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum IOFlags {
|
||||||
|
Append = 1 << 0,
|
||||||
|
Nonblock = 1 << 1,
|
||||||
|
IsReadable = 1 << 2,
|
||||||
|
IsWriteable = 1 << 3,
|
||||||
|
IsSeekable = 1 << 4,
|
||||||
|
Mask = 1 << 5- 1,
|
||||||
|
GetMask = Mask,
|
||||||
|
SetMask = Append | Nonblock,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum IOStatus {
|
||||||
|
Error,
|
||||||
|
Normal,
|
||||||
|
Eof,
|
||||||
|
Again,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SeekType {
|
||||||
|
Cur,
|
||||||
|
Set,
|
||||||
|
End,
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,6 +37,7 @@ sources = \
|
||||||
Idle.cs \
|
Idle.cs \
|
||||||
IgnoreClassInitializersAttribute.cs \
|
IgnoreClassInitializersAttribute.cs \
|
||||||
InitiallyUnowned.cs \
|
InitiallyUnowned.cs \
|
||||||
|
IOChannel.cs \
|
||||||
IWrapper.cs \
|
IWrapper.cs \
|
||||||
ListBase.cs \
|
ListBase.cs \
|
||||||
List.cs \
|
List.cs \
|
||||||
|
@ -58,6 +59,7 @@ sources = \
|
||||||
SignalCallback.cs \
|
SignalCallback.cs \
|
||||||
SList.cs \
|
SList.cs \
|
||||||
Source.cs \
|
Source.cs \
|
||||||
|
Spawn.cs \
|
||||||
Thread.cs \
|
Thread.cs \
|
||||||
Timeout.cs \
|
Timeout.cs \
|
||||||
ToggleRef.cs \
|
ToggleRef.cs \
|
||||||
|
|
|
@ -37,6 +37,12 @@ namespace GLib {
|
||||||
g_free (ptr);
|
g_free (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Free (IntPtr[] ptrs)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ptrs.Length; i++)
|
||||||
|
g_free (ptrs [i]);
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport("libglib-2.0-0.dll")]
|
[DllImport("libglib-2.0-0.dll")]
|
||||||
static extern IntPtr g_filename_to_utf8 (IntPtr mem, int len, IntPtr read, out IntPtr written, out IntPtr error);
|
static extern IntPtr g_filename_to_utf8 (IntPtr mem, int len, IntPtr read, out IntPtr written, out IntPtr error);
|
||||||
|
|
||||||
|
@ -133,6 +139,17 @@ namespace GLib {
|
||||||
return ret.Replace ("%", "%%");
|
return ret.Replace ("%", "%%");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IntPtr[] StringArrayToNullTermPointer (string[] strs)
|
||||||
|
{
|
||||||
|
if (strs == null)
|
||||||
|
return new IntPtr [0];
|
||||||
|
IntPtr[] result = new IntPtr [strs.Length + 1];
|
||||||
|
for (int i = 0; i < strs.Length; i++)
|
||||||
|
result [i] = StringToPtrGStrdup (strs [i]);
|
||||||
|
result [strs.Length] = IntPtr.Zero;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static string[] PtrToStringArrayGFree (IntPtr string_array)
|
public static string[] PtrToStringArrayGFree (IntPtr string_array)
|
||||||
{
|
{
|
||||||
if (string_array == IntPtr.Zero)
|
if (string_array == IntPtr.Zero)
|
||||||
|
|
216
glib/Spawn.cs
Normal file
216
glib/Spawn.cs
Normal file
|
@ -0,0 +1,216 @@
|
||||||
|
// glib/Spawn.cs : Spawn g_spawn API wrapper
|
||||||
|
//
|
||||||
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2007 Novell, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of version 2 of the Lesser GNU General
|
||||||
|
// Public License as published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this program; if not, write to the
|
||||||
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
|
namespace GLib {
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
public enum SpawnError {
|
||||||
|
Fork,
|
||||||
|
Read,
|
||||||
|
Chdir,
|
||||||
|
Acces,
|
||||||
|
Perm,
|
||||||
|
TooBig,
|
||||||
|
NoExec,
|
||||||
|
NameTooLong,
|
||||||
|
NoEnt,
|
||||||
|
NoMem,
|
||||||
|
NotDir,
|
||||||
|
Loop,
|
||||||
|
TxtBusy,
|
||||||
|
IO,
|
||||||
|
NFile,
|
||||||
|
MFile,
|
||||||
|
Inval,
|
||||||
|
IsDir,
|
||||||
|
LibBad,
|
||||||
|
Failed,
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum SpawnFlags {
|
||||||
|
LeaveDescriptorsOpen = 1 << 0,
|
||||||
|
DoNotReapChild = 1 << 1,
|
||||||
|
SearchPath = 1 << 2,
|
||||||
|
StdoutToDevNull = 1 << 3,
|
||||||
|
StderrToDevNull = 1 << 4,
|
||||||
|
ChildInheritsStdin = 1 << 5,
|
||||||
|
FileAndArgvZero = 1 << 6,
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void SpawnChildSetupFunc ();
|
||||||
|
|
||||||
|
[CDeclCallback]
|
||||||
|
internal delegate void SpawnChildSetupFuncNative (IntPtr gch);
|
||||||
|
|
||||||
|
internal class SpawnChildSetupWrapper {
|
||||||
|
|
||||||
|
SpawnChildSetupFunc handler;
|
||||||
|
|
||||||
|
public SpawnChildSetupWrapper (SpawnChildSetupFunc handler)
|
||||||
|
{
|
||||||
|
if (handler == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.handler = handler;
|
||||||
|
Data = (IntPtr) GCHandle.Alloc (this);
|
||||||
|
NativeCallback = new SpawnChildSetupFuncNative (InvokeHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr Data;
|
||||||
|
public SpawnChildSetupFuncNative NativeCallback;
|
||||||
|
|
||||||
|
static void InvokeHandler (IntPtr data)
|
||||||
|
{
|
||||||
|
if (data == IntPtr.Zero)
|
||||||
|
return;
|
||||||
|
GCHandle gch = (GCHandle) data;
|
||||||
|
(gch.Target as SpawnChildSetupWrapper).handler ();
|
||||||
|
gch.Free ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Process {
|
||||||
|
|
||||||
|
public const int IgnorePipe = Int32.MaxValue;
|
||||||
|
public const int RequestPipe = 0;
|
||||||
|
|
||||||
|
long pid;
|
||||||
|
|
||||||
|
private Process (int pid)
|
||||||
|
{
|
||||||
|
this.pid = pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libglib-2.0-0.dll")]
|
||||||
|
static extern void g_spawn_close_pid (int pid);
|
||||||
|
|
||||||
|
public void Close ()
|
||||||
|
{
|
||||||
|
g_spawn_close_pid ((int) pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libglib-2.0-0.dll")]
|
||||||
|
static extern bool g_spawn_async (IntPtr dir, IntPtr[] argv, IntPtr[] envp, int flags, SpawnChildSetupFuncNative func, IntPtr data, out int pid, out IntPtr error);
|
||||||
|
|
||||||
|
public static bool SpawnAsync (string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out Process child_process)
|
||||||
|
{
|
||||||
|
int pid;
|
||||||
|
IntPtr error;
|
||||||
|
IntPtr native_dir = Marshaller.StringToPtrGStrdup (working_directory);
|
||||||
|
IntPtr[] native_argv = Marshaller.StringArrayToNullTermPointer (argv);
|
||||||
|
IntPtr[] native_envp = Marshaller.StringArrayToNullTermPointer (envp);
|
||||||
|
SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper (child_setup);
|
||||||
|
bool result = g_spawn_async (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out pid, out error);
|
||||||
|
child_process = new Process (pid);
|
||||||
|
Marshaller.Free (native_dir);
|
||||||
|
Marshaller.Free (native_argv);
|
||||||
|
Marshaller.Free (native_envp);
|
||||||
|
if (error != IntPtr.Zero) throw new GLib.GException (error);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libglib-2.0-0.dll")]
|
||||||
|
static extern bool g_spawn_async_with_pipes (IntPtr dir, IntPtr[] argv, IntPtr[] envp, int flags, SpawnChildSetupFuncNative func, IntPtr data, out int pid, IntPtr stdin, IntPtr stdout, IntPtr stderr, out IntPtr error);
|
||||||
|
|
||||||
|
public static bool SpawnAsyncWithPipes (string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out Process child_process, ref int stdin, ref int stdout, ref int stderr)
|
||||||
|
{
|
||||||
|
int pid;
|
||||||
|
IntPtr error;
|
||||||
|
IntPtr native_dir = Marshaller.StringToPtrGStrdup (working_directory);
|
||||||
|
IntPtr[] native_argv = Marshaller.StringArrayToNullTermPointer (argv);
|
||||||
|
IntPtr[] native_envp = Marshaller.StringArrayToNullTermPointer (envp);
|
||||||
|
SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper (child_setup);
|
||||||
|
IntPtr in_ptr = stdin == IgnorePipe ? IntPtr.Zero : Marshal.AllocHGlobal (4);
|
||||||
|
IntPtr out_ptr = stdout == IgnorePipe ? IntPtr.Zero : Marshal.AllocHGlobal (4);
|
||||||
|
IntPtr err_ptr = stderr == IgnorePipe ? IntPtr.Zero : Marshal.AllocHGlobal (4);
|
||||||
|
bool result = g_spawn_async_with_pipes (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out pid, in_ptr, out_ptr, err_ptr, out error);
|
||||||
|
child_process = new Process (pid);
|
||||||
|
if (in_ptr != IntPtr.Zero) {
|
||||||
|
stdin = Marshal.ReadInt32 (in_ptr);
|
||||||
|
Marshal.FreeHGlobal (in_ptr);
|
||||||
|
}
|
||||||
|
if (out_ptr != IntPtr.Zero) {
|
||||||
|
stdout = Marshal.ReadInt32 (out_ptr);
|
||||||
|
Marshal.FreeHGlobal (out_ptr);
|
||||||
|
}
|
||||||
|
if (err_ptr != IntPtr.Zero) {
|
||||||
|
stderr = Marshal.ReadInt32 (err_ptr);
|
||||||
|
Marshal.FreeHGlobal (err_ptr);
|
||||||
|
}
|
||||||
|
Marshaller.Free (native_dir);
|
||||||
|
Marshaller.Free (native_argv);
|
||||||
|
Marshaller.Free (native_envp);
|
||||||
|
if (error != IntPtr.Zero) throw new GLib.GException (error);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libglib-2.0-0.dll")]
|
||||||
|
static extern bool g_spawn_sync (IntPtr dir, IntPtr[] argv, IntPtr[] envp, int flags, SpawnChildSetupFuncNative func, IntPtr data, out IntPtr stdout, out IntPtr stderr, out int exit_status, out IntPtr error);
|
||||||
|
|
||||||
|
public static bool SpawnSync (string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out string stdout, out string stderr, out int exit_status)
|
||||||
|
{
|
||||||
|
IntPtr native_stdout, native_stderr, error;
|
||||||
|
IntPtr native_dir = Marshaller.StringToPtrGStrdup (working_directory);
|
||||||
|
IntPtr[] native_argv = Marshaller.StringArrayToNullTermPointer (argv);
|
||||||
|
IntPtr[] native_envp = Marshaller.StringArrayToNullTermPointer (envp);
|
||||||
|
SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper (child_setup);
|
||||||
|
bool result = g_spawn_sync (native_dir, native_argv, native_envp, (int) flags, wrapper.NativeCallback, wrapper.Data, out native_stdout, out native_stderr, out exit_status, out error);
|
||||||
|
Marshaller.Free (native_dir);
|
||||||
|
Marshaller.Free (native_argv);
|
||||||
|
Marshaller.Free (native_envp);
|
||||||
|
stdout = Marshaller.PtrToStringGFree (native_stdout);
|
||||||
|
stderr = Marshaller.PtrToStringGFree (native_stderr);
|
||||||
|
if (error != IntPtr.Zero) throw new GLib.GException (error);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libglib-2.0-0.dll")]
|
||||||
|
static extern bool g_spawn_command_line_async (IntPtr cmdline, out IntPtr error);
|
||||||
|
|
||||||
|
public static bool SpawnCommandLineAsync (string command_line)
|
||||||
|
{
|
||||||
|
IntPtr error;
|
||||||
|
IntPtr native_cmd = Marshaller.StringToPtrGStrdup (command_line);
|
||||||
|
bool result = g_spawn_command_line_async (native_cmd, out error);
|
||||||
|
Marshaller.Free (native_cmd);
|
||||||
|
if (error != IntPtr.Zero) throw new GLib.GException (error);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libglib-2.0-0.dll")]
|
||||||
|
static extern bool g_spawn_command_line_sync (IntPtr cmdline, out IntPtr stdout, out IntPtr stderr, out int exit_status, out IntPtr error);
|
||||||
|
|
||||||
|
public static bool SpawnCommandLineSync (string command_line, out string stdout, out string stderr, out int exit_status)
|
||||||
|
{
|
||||||
|
IntPtr error, native_stdout, native_stderr;
|
||||||
|
IntPtr native_cmd = Marshaller.StringToPtrGStrdup (command_line);
|
||||||
|
bool result = g_spawn_command_line_sync (native_cmd, out native_stdout, out native_stderr, out exit_status, out error);
|
||||||
|
Marshaller.Free (native_cmd);
|
||||||
|
stdout = Marshaller.PtrToStringGFree (native_stdout);
|
||||||
|
stderr = Marshaller.PtrToStringGFree (native_stderr);
|
||||||
|
if (error != IntPtr.Zero) throw new GLib.GException (error);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ DOTNET_TARGETS=
|
||||||
DOTNET_ASSEMBLY=
|
DOTNET_ASSEMBLY=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TARGETS = polarfixed.exe custom-widget.exe custom-cellrenderer.exe gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe size.exe scribble.exe scribble-xinput.exe treeviewdemo.exe managedtreeviewdemo.exe nodeviewdemo.exe treemodeldemo.exe testdnd.exe actions.exe $(GLADE_TARGETS) $(DOTNET_TARGETS)
|
TARGETS = polarfixed.exe custom-widget.exe custom-cellrenderer.exe gtk-hello-world.exe button.exe calendar.exe subclass.exe menu.exe size.exe scribble.exe scribble-xinput.exe treeviewdemo.exe managedtreeviewdemo.exe nodeviewdemo.exe treemodeldemo.exe testdnd.exe actions.exe spawn.exe $(GLADE_TARGETS) $(DOTNET_TARGETS)
|
||||||
|
|
||||||
DEBUGS = $(addsuffix .mdb, $(TARGETS))
|
DEBUGS = $(addsuffix .mdb, $(TARGETS))
|
||||||
|
|
||||||
|
@ -91,6 +91,9 @@ actions.exe: $(srcdir)/Actions.cs
|
||||||
polarfixed.exe: $(srcdir)/PolarFixed.cs $(assemblies)
|
polarfixed.exe: $(srcdir)/PolarFixed.cs $(assemblies)
|
||||||
$(CSC) /debug /out:polarfixed.exe $(references) $(srcdir)/PolarFixed.cs
|
$(CSC) /debug /out:polarfixed.exe $(references) $(srcdir)/PolarFixed.cs
|
||||||
|
|
||||||
|
spawn.exe: $(srcdir)/SpawnTests.cs $(assemblies)
|
||||||
|
$(CSC) /out:spawn.exe $(references) $(srcdir)/SpawnTests.cs
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
HelloWorld.cs \
|
HelloWorld.cs \
|
||||||
ButtonApp.cs \
|
ButtonApp.cs \
|
||||||
|
|
114
sample/SpawnTests.cs
Normal file
114
sample/SpawnTests.cs
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
// SpawnTests.cs - Tests for GLib.Process.Spawn*
|
||||||
|
//
|
||||||
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
|
//
|
||||||
|
// Copyright (c) 2007 Novell, Inc.
|
||||||
|
|
||||||
|
namespace GtkSamples {
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
using Gdk;
|
||||||
|
using GLib;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class SpawnTests {
|
||||||
|
|
||||||
|
static MainLoop ml;
|
||||||
|
|
||||||
|
public static void Main (string[] args)
|
||||||
|
{
|
||||||
|
CommandLineSyncTest ();
|
||||||
|
CommandLineAsyncTest ();
|
||||||
|
SyncTest ();
|
||||||
|
AsyncTest ();
|
||||||
|
AsyncWithPipesTest ();
|
||||||
|
ml = new MainLoop ();
|
||||||
|
ml.Run ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CommandLineAsyncTest ()
|
||||||
|
{
|
||||||
|
Console.WriteLine ("CommandLineAsyncTest:");
|
||||||
|
try {
|
||||||
|
GLib.Process.SpawnCommandLineAsync ("echo \"[CommandLineAsync running: `pwd`]\"");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine ("Exception in SpawnCommandLineAsync: " + e);
|
||||||
|
}
|
||||||
|
Console.WriteLine ("returning");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CommandLineSyncTest ()
|
||||||
|
{
|
||||||
|
Console.WriteLine ("CommandLineSyncTest:");
|
||||||
|
try {
|
||||||
|
string stdout, stderr;
|
||||||
|
int exit_status;
|
||||||
|
GLib.Process.SpawnCommandLineSync ("pwd", out stdout, out stderr, out exit_status);
|
||||||
|
Console.Write ("pwd exit_status=" + exit_status + " output: " + stdout);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine ("Exception in SpawnCommandLineSync: " + e);
|
||||||
|
}
|
||||||
|
Console.WriteLine ("returning");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SyncTest ()
|
||||||
|
{
|
||||||
|
Console.WriteLine ("SyncTest:");
|
||||||
|
try {
|
||||||
|
string stdout, stderr;
|
||||||
|
int exit_status;
|
||||||
|
GLib.Process.SpawnSync ("/usr", new string[] {"pwd"}, null, SpawnFlags.SearchPath, null, out stdout, out stderr, out exit_status);
|
||||||
|
Console.Write ("pwd exit_status=" + exit_status + " output: " + stdout);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine ("Exception in SpawnSync: " + e);
|
||||||
|
}
|
||||||
|
Console.WriteLine ("returning");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AsyncTest ()
|
||||||
|
{
|
||||||
|
Console.WriteLine ("AsyncTest:");
|
||||||
|
try {
|
||||||
|
Process proc;
|
||||||
|
GLib.Process.SpawnAsync (null, new string[] {"echo", "[AsyncTest running]"}, null, SpawnFlags.SearchPath, null, out proc);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine ("Exception in SpawnSync: " + e);
|
||||||
|
}
|
||||||
|
Console.WriteLine ("returning");
|
||||||
|
}
|
||||||
|
|
||||||
|
static IOChannel channel;
|
||||||
|
|
||||||
|
static void AsyncWithPipesTest ()
|
||||||
|
{
|
||||||
|
Console.WriteLine ("AsyncWithPipesTest:");
|
||||||
|
try {
|
||||||
|
Process proc;
|
||||||
|
int stdin = Process.IgnorePipe;
|
||||||
|
int stdout = Process.RequestPipe;
|
||||||
|
int stderr = Process.IgnorePipe;
|
||||||
|
GLib.Process.SpawnAsyncWithPipes (null, new string[] {"pwd"}, null, SpawnFlags.SearchPath, null, out proc, ref stdin, ref stdout, ref stderr);
|
||||||
|
channel = new IOChannel (stdout);
|
||||||
|
channel.AddWatch (0, IOCondition.In | IOCondition.Hup, new IOFunc (ReadStdout));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine ("Exception in SpawnSync: " + e);
|
||||||
|
}
|
||||||
|
Console.WriteLine ("returning");
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ReadStdout (IOChannel source, IOCondition condition)
|
||||||
|
{
|
||||||
|
if ((condition & IOCondition.In) == IOCondition.In) {
|
||||||
|
string txt;
|
||||||
|
if (source.ReadToEnd (out txt) == IOStatus.Normal)
|
||||||
|
Console.WriteLine ("[AsyncWithPipesTest output] " + txt);
|
||||||
|
}
|
||||||
|
if ((condition & IOCondition.Hup) == IOCondition.Hup) {
|
||||||
|
source.Dispose ();
|
||||||
|
ml.Quit ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue