1 // GLib.Shell.cs
2 //
3 // Author(s):
4 //      Stephane Delcroix <stephane@delcroix.org>
5 //
6 // Copyright (c) 2009 Novell, Inc.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of version 2 of the Lesser GNU General
10 // Public License as published by the Free Software Foundation.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // Lesser General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this program; if not, write to the
19 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 // Boston, MA 02111-1307, USA.
21 
22 
23 using System;
24 using System.Runtime.InteropServices;
25 
26 namespace GLib
27 {
28 	public class Shell
29 	{
30 		[DllImport ("libglib-2.0-0.dll")]
g_shell_quote(IntPtr unquoted_string)31 		static extern IntPtr g_shell_quote (IntPtr unquoted_string);
32 
Quote(string unquoted)33 		public static string Quote (string unquoted)
34 		{
35 			IntPtr native_string = GLib.Marshaller.StringToPtrGStrdup (unquoted);
36 			string quoted = GLib.Marshaller.PtrToStringGFree (g_shell_quote (native_string));
37 			GLib.Marshaller.Free (native_string);
38 			return quoted;
39 		}
40 	}
41 }
42