glib-2.0.vala 52.2 KB
Newer Older
1
/* glib-2.0.vala
2
 *
3
 * Copyright (C) 2006-2007  Jürg Billeter, Raffaele Sandrini
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.

 * This library 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 library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Jürg Billeter <j@bitron.ch>
21
 *	Raffaele Sandrini <rasa@gmx.ch>
22 23
 */

24
[CCode (cname = "gboolean", cheader_filename = "glib.h", type_id = "G_TYPE_BOOLEAN", marshaller_type_name = "BOOLEAN", get_value_function = "g_value_get_boolean", set_value_function = "g_value_set_boolean", default_value = "FALSE")]
25 26 27
public struct bool {
}

28
[CCode (cname = "gpointer", cheader_filename = "glib.h", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER", get_value_function = "g_value_get_pointer", set_value_function = "g_value_set_pointer", default_value = "NULL")]
29 30 31
public struct pointer {
}

32
[CCode (cname = "gconstpointer", cheader_filename = "glib.h", type_id = "G_TYPE_POINTER", marshaller_type_name = "POINTER", get_value_function = "g_value_get_pointer", set_value_function = "g_value_set_pointer", default_value = "NULL")]
33 34 35
public struct constpointer {
}

36
[CCode (cname = "gchar", cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_char", set_value_function = "g_value_set_char", default_value = "\'\\0\'")]
37
[IntegerType (rank = 1)]
38
public struct char {
39 40 41
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%hhi");
42 43
}

44
[CCode (cname = "guchar", cheader_filename = "glib.h", type_id = "G_TYPE_UCHAR", marshaller_type_name = "UCHAR", get_value_function = "g_value_get_uchar", set_value_function = "g_value_set_uchar", default_value = "\'\\0\'")]
45
[IntegerType (rank = 2)]
46
public struct uchar {
47 48 49
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%hhu");
50 51
}

52
[CCode (cname = "gint", cheader_filename = "glib.h", type_id = "G_TYPE_INT", marshaller_type_name = "INT", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0")]
53
[IntegerType (rank = 9)]
54
public struct int {
55 56 57 58 59
	[CCode (cname = "G_MININT")]
	public static int MIN;
	[CCode (cname = "G_MAXINT")]
	public static int MAX;

60 61 62
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%i");
63 64 65

	[CCode (cname = "CLAMP")]
	public int clamp (int low, int high);
66 67
}

68
[CCode (cname = "guint", cheader_filename = "glib.h", type_id = "G_TYPE_UINT", marshaller_type_name = "UINT", get_value_function = "g_value_get_uint", set_value_function = "g_value_set_uint", default_value = "0U")]
69
[IntegerType (rank = 10)]
70
public struct uint {
71 72 73 74 75
	[CCode (cname = "0")]
	public static uint MIN;
	[CCode (cname = "G_MAXUINT")]
	public static uint MAX;

76 77 78
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%u");
79 80 81

	[CCode (cname = "CLAMP")]
	public uint clamp (uint low, uint high);
82 83
}

84
[CCode (cname = "gshort", cheader_filename = "glib.h", default_value = "0")]
85
[IntegerType (rank = 5)]
86
public struct short {
87 88 89 90 91
	[CCode (cname = "G_MINSHORT")]
	public static short MIN;
	[CCode (cname = "G_MAXSHORT")]
	public static short MAX;

92 93 94
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%hi");
95 96
}

97
[CCode (cname = "gushort", cheader_filename = "glib.h", default_value = "0U")]
98
[IntegerType (rank = 6)]
99
public struct ushort {
100 101 102 103 104
	[CCode (cname = "0U")]
	public static ushort MIN;
	[CCode (cname = "G_MAXUSHORT")]
	public static ushort MAX;

105 106 107
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%hu");
108 109
}

110
[CCode (cname = "glong", cheader_filename = "glib.h", type_id = "G_TYPE_LONG", marshaller_type_name = "LONG", get_value_function = "g_value_get_long", set_value_function = "g_value_set_long", default_value = "0L")]
111
[IntegerType (rank = 14)]
112
public struct long {
113 114 115 116 117
	[CCode (cname = "G_MINLONG")]
	public static long MIN;
	[CCode (cname = "G_MAXLONG")]
	public static long MAX;

118 119 120
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%li");
121 122
}

123
[CCode (cname = "gulong", cheader_filename = "glib.h", type_id = "G_TYPE_ULONG", marshaller_type_name = "ULONG", get_value_function = "g_value_get_ulong", set_value_function = "g_value_set_ulong", default_value = "0UL")]
124
[IntegerType (rank = 15)]
125
public struct ulong {
126 127 128 129 130
	[CCode (cname = "0UL")]
	public static ulong MIN;
	[CCode (cname = "G_MAXULONG")]
	public static ulong MAX;

131 132 133
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%lu");
134 135
}

136
[CCode (cname = "gint8", cheader_filename = "glib.h", type_id = "G_TYPE_CHAR", marshaller_type_name = "CHAR", get_value_function = "g_value_get_char", set_value_function = "g_value_set_char", default_value = "0")]
137 138 139 140 141 142 143 144
[IntegerType (rank = 3)]
public struct int8 {
	[CCode (cname = "G_MININT8")]
	public static int8 MIN;
	[CCode (cname = "G_MAXINT8")]
	public static int8 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
145
	public string! to_string (string! format = "%hhi");
146 147
}

148
[CCode (cname = "guint8", cheader_filename = "glib.h", default_value = "0U")]
149 150 151 152 153 154 155 156
[IntegerType (rank = 4)]
public struct uint8 {
	[CCode (cname = "0U")]
	public static uint8 MIN;
	[CCode (cname = "G_MAXUINT8")]
	public static uint8 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
157
	public ref string! to_string (string! format = "%hhu");
158 159
}

160
[CCode (cname = "gint16", cheader_filename = "glib.h", default_value = "0")]
161
[IntegerType (rank = 7)]
162
public struct int16 {
163 164 165 166 167 168
	[CCode (cname = "G_MININT16")]
	public static int16 MIN;
	[CCode (cname = "G_MAXINT16")]
	public static int16 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
169
	public ref string! to_string (string! format = "%hi");
170 171
}

172
[CCode (cname = "guint16", cheader_filename = "glib.h", default_value = "0U")]
173
[IntegerType (rank = 8)]
174
public struct uint16 {
175 176 177 178 179 180
	[CCode (cname = "0U")]
	public static uint16 MIN;
	[CCode (cname = "G_MAXUINT16")]
	public static uint16 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
181
	public ref string! to_string (string! format = "%hu");
182 183
}

184
[CCode (cname = "gint32", cheader_filename = "glib.h", default_value = "0")]
185
[IntegerType (rank = 11)]
186
public struct int32 {
187 188 189 190 191 192
	[CCode (cname = "G_MININT32")]
	public static int32 MIN;
	[CCode (cname = "G_MAXINT32")]
	public static int32 MAX;

	[CCode (cname = "g_strdup_printf"), InstanceLast]
193
	public ref string! to_string (string! format = "%i");
194 195
}

196
[CCode (cname = "guint32", cheader_filename = "glib.h", default_value = "0U")]
197
[IntegerType (rank = 12)]
198
public struct uint32 {
199 200 201 202 203 204 205
	[CCode (cname = "0U")]
	public static uint32 MIN;
	[CCode (cname = "G_MAXUINT32")]
	public static uint32 MAX;

	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
206
	public ref string! to_string (string! format = "%u");
207 208
}

209
[CCode (cname = "gint64", cheader_filename = "glib.h", type_id = "G_TYPE_INT64", marshaller_type_name = "INT64", get_value_function = "g_value_get_int64", set_value_function = "g_value_set_int64", default_value = "0LL")]
210
[IntegerType (rank = 16)]
211
public struct int64 {
212 213 214 215 216
	[CCode (cname = "G_MININT64")]
	public static int64 MIN;
	[CCode (cname = "G_MAXINT64")]
	public static int64 MAX;

217 218 219
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%lli");
220 221
}

222
[CCode (cname = "guint64", cheader_filename = "glib.h", type_id = "G_TYPE_UINT64", marshaller_type_name = "UINT64", get_value_function = "g_value_get_uint64", set_value_function = "g_value_set_uint64", default_value = "0ULL")]
223
[IntegerType (rank = 17)]
224
public struct uint64 {
225 226 227 228 229
	[CCode (cname = "0ULL")]
	public static uint64 MIN;
	[CCode (cname = "G_MAXUINT64")]
	public static uint64 MAX;

230 231 232
	[InstanceLast ()]
	[CCode (cname = "g_strdup_printf")]
	public ref string! to_string (string! format = "%llu");
233 234
}

235
[CCode (cname = "float", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_FLOAT", marshaller_type_name = "FLOAT", get_value_function = "g_value_get_float", set_value_function = "g_value_set_float", default_value = "0.0F")]
236
[FloatingType (rank = 1)]
237
public struct float {
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
	[CCode (cname = "FLT_MANT_DIG")]
	public static int MANT_DIG;
	[CCode (cname = "FLT_DIG")]
	public static int DIG;

	[CCode (cname = "FLT_MIN_EXP")]
	public static int MIN_EXP;
	[CCode (cname = "FLT_MAX_EXP")]
	public static int MAX_EXP;

	[CCode (cname = "FLT_MIN_10_EXP")]
	public static int MIN_10_EXP;
	[CCode (cname = "FLT_MAX_10_EXP")]
	public static int MAX_10_EXP;

	[CCode (cname = "FLT_EPSILON")]
	public static float EPSILON;
	[CCode (cname = "FLT_MIN")]
	public static float MIN;
	[CCode (cname = "FLT_MAX")]
	public static float MAX;

	[CCode (cname = "NAN")]
	public static float NAN;
	[CCode (cname = "INFINITY")]
	public static float INFINITY;

	[CCode (cname = "isnan")]
	public bool is_nan ();
	[CCode (cname = "isfinite")]
	public bool is_finite ();
	[CCode (cname = "isnormal")]
	public bool is_normal ();
	[CCode (cname = "isinf")]
	public int is_infinity ();

	[CCode (cname = "g_strdup_printf"), InstanceLast]
	public ref string! to_string (string! format = "%g");
276 277
}

278
[CCode (cname = "double", cheader_filename = "glib.h,float.h,math.h", type_id = "G_TYPE_DOUBLE", marshaller_type_name = "DOUBLE", get_value_function = "g_value_get_double", set_value_function = "g_value_set_double", default_value = "0.0")]
279
[FloatingType (rank = 2)]
280
public struct double {
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
	[CCode (cname = "DBL_MANT_DIG")]
	public static int MANT_DIG;
	[CCode (cname = "DBL_DIG")]
	public static int DIG;

	[CCode (cname = "DBL_MIN_EXP")]
	public static int MIN_EXP;
	[CCode (cname = "DBL_MAX_EXP")]
	public static int MAX_EXP;

	[CCode (cname = "DBL_MIN_10_EXP")]
	public static int MIN_10_EXP;
	[CCode (cname = "DBL_MAX_10_EXP")]
	public static int MAX_10_EXP;

	[CCode (cname = "DBL_EPSILON")]
	public static double EPSILON;
	[CCode (cname = "DBL_MIN")]
	public static double MIN;
	[CCode (cname = "DBL_MAX")]
	public static double MAX;

	[CCode (cname = "((double) NAN)")]
	public static double NAN;
	[CCode (cname = "((double) INFINITY)")]
	public static double INFINITY;

	[CCode (cname = "isnan")]
	public bool is_nan ();
	[CCode (cname = "isfinite")]
	public bool is_finite ();
	[CCode (cname = "isnormal")]
	public bool is_normal ();
	[CCode (cname = "isinf")]
	public int is_infinity ();

	[CCode (cname = "g_strdup_printf"), InstanceLast]
	public ref string! to_string (string! format = "%g");
319 320
}

321
[CCode (cname = "gunichar", cprefix = "g_unichar_", cheader_filename = "glib.h", get_value_function = "g_value_get_int", set_value_function = "g_value_set_int", default_value = "0U")]
322
[IntegerType (rank = 13)]
323
public struct unichar {
324
	public bool validate ();
325
	public bool isalnum ();
326 327
	public bool isalpha ();
	public bool iscntrl ();
328
	public bool isdigit ();
329 330 331 332
	public bool isgraph ();
	public bool islower ();
	public bool isprint ();
	public bool ispunct ();
333
	public bool isspace ();
334
	public bool isupper ();
335
	public bool isxdigit ();
336 337 338 339 340
	public bool istitle ();
	public bool isdefined ();
	public bool iswide ();
	public bool iswide_cjk ();
	public bool iszerowidth ();
341
	public unichar toupper ();
342
	public unichar tolower ();
343
	public unichar totitle ();
344 345
	public int digit_value ();
	public int xdigit_value ();
346 347 348
	public UnicodeType type ();
	public UnicodeBreakType break_type ();

349
	public int to_utf8 (string outbuf);
350 351
}

352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
[CCode (cprefix = "G_UNICODE_")]
public enum UnicodeType {
	CONTROL,
	FORMAT,
	UNASSIGNED,
	PRIVATE_USE,
	SURROGATE,
	LOWERCASE_LETTER,
	MODIFIER_LETTER,
	OTHER_LETTER,
	TITLECASE_LETTER,
	UPPERCASE_LETTER,
	COMBINING_MARK,
	ENCLOSING_MARK,
	NON_SPACING_MARK,
	DECIMAL_NUMBER,
	LETTER_NUMBER,
	OTHER_NUMBER,
	CONNECT_PUNCTUATION,
	DASH_PUNCTUATION,
	CLOSE_PUNCTUATION,
	FINAL_PUNCTUATION,
	INITIAL_PUNCTUATION,
	OTHER_PUNCTUATION,
	OPEN_PUNCTUATION,
	CURRENCY_SYMBOL,
	MODIFIER_SYMBOL,
	MATH_SYMBOL,
	OTHER_SYMBOL,
	LINE_SEPARATOR,
	PARAGRAPH_SEPARATOR,
	SPACE_SEPARATOR
}

[CCode (cprefix = "G_UNICODE_BREAK_")]
public enum UnicodeBreakType {
	MANDATORY,
	CARRIAGE_RETURN,
	LINE_FEED,
	COMBINING_MARK,
	SURROGATE,
	ZERO_WIDTH_SPACE,
	INSEPARABLE,
	NON_BREAKING_GLUE,
	CONTINGENT,
	SPACE,
	AFTER,
	BEFORE,
	BEFORE_AND_AFTER,
	HYPHEN,
	NON_STARTER,
	OPEN_PUNCTUATION,
	CLOSE_PUNCTUATION,
	QUOTATION,
	EXCLAMATION,
	IDEOGRAPHIC,
	NUMERIC,
	INFIX_SEPARATOR,
	SYMBOL,
	ALPHABETIC,
	PREFIX,
	POSTFIX,
	COMPLEX_CONTEXT,
	AMBIGUOUS,
	UNKNOWN,
	NEXT_LINE,
	WORD_JOINER,
	HANGUL_L_JAMO,
	HANGUL_V_JAMO,
	HANGUL_T_JAMO,
	HANGUL_LV_SYLLABLE,
	HANGUL_LVT_SYLLABLE
}

Jürg Billeter's avatar
Jürg Billeter committed
426
[ReferenceType (dup_function = "g_strdup", free_function = "g_free", type_id = "G_TYPE_STRING")]
427
[CCode (cname = "char", const_cname = "const char", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string")]
428
public struct string {
429
	[CCode (cname = "g_strstr")]
430
	public weak string str (string! needle);
431 432
	[CCode (cname = "g_str_has_prefix")]
	public bool has_prefix (string! prefix);
433
	[CCode (cname = "g_str_has_suffix")]
434
	public bool has_suffix (string! suffix);
435
	[CCode (cname = "g_strdup_printf"), PrintfFormat]
436
	public ref string printf (...);
437
	[CCode (cname = "g_strconcat")]
438
	public ref string concat (string string2, ...);
439
	[CCode (cname = "g_strndup")]
440
	public ref string ndup (ulong n); /* FIXME: only UTF-8 */
441
	[CCode (cname = "g_strcompress")]
442
	public ref string compress ();
443
	[CCode (cname = "g_strsplit")]
444 445 446
	public ref string[] split (string! delimiter, int max_tokens = 0);
	[CCode (cname = "g_strsplit_set")]
	public ref string[] split_set (string! delimiters, int max_tokens = 0);
447 448 449
	[CCode (cname = "g_strjoinv")]
	[NoArrayLength]
	public static string joinv (string! separator, string[] str_array);
450
	
451
	[CCode (cname = "g_utf8_next_char")]
452
	public weak string next_char ();
453 454
	[CCode (cname = "g_utf8_get_char")]
	public unichar get_char ();
455 456
	[CCode (cname = "g_utf8_get_char_validated")]
	public unichar get_char_validated (long max_len = -1);
457 458
	[CCode (cname = "g_utf8_offset_to_pointer")]
	[PlusOperator ()]
459
	public weak string offset (long offset);
460 461
	[CCode (cname = "g_utf8_pointer_to_offset")]
	public long pointer_to_offset (string pos);
462
	[CCode (cname = "g_utf8_prev_char")]
463
	public weak string prev_char ();
464
	[CCode (cname = "g_utf8_strlen")]
465
	public long len (long max = -1);
466
	[CCode (cname = "g_utf8_strchr")]
467
	public weak string chr (long len, unichar c);
468 469
	[CCode (cname = "g_utf8_strrchr")]
	public weak string rchr (long len, unichar c);
470
	[CCode (cname = "g_utf8_strreverse")]
471
	public ref string! reverse (int len = -1);
472 473
	[CCode (cname = "g_utf8_validate")]
	public bool validate (long max_len = -1, out string end = null);
474 475
	
	[CCode (cname = "g_utf8_strup")]
476
	public ref string up (long len = -1);
477 478
	[CCode (cname = "g_utf8_strdown")]
	public ref string down (long len = -1);
479 480
	[CCode (cname = "g_utf8_casefold")]
	public ref string casefold (long len = -1);
481 482
	[CCode (cname = "g_utf8_collate")]
	public int collate (string str2);
483 484

	[CCode (cname="g_strchomp")]
485
	public weak string chomp();
486
	[CCode (cname="g_strchug")]
487
	public weak string chug();
488
	
489 490 491
	[CCode (cname = "g_str_hash")]
	public uint hash ();
	
492 493
	[CCode (cname = "atoi")]
	public int to_int ();
494 495
	[CCode (cname = "strtoll")]
	public int64 to_int64 (out string endptr = null, int _base = 0);
496 497
	[CCode (cname = "strlen")]
	public long size ();
498 499 500
}

[Import ()]
501
[CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h")]
502
namespace GLib {
503
	public struct Type {
504 505
		[CCode (cname = "G_TYPE_IS_OBJECT")]
		public bool is_object ();
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
		[CCode (cname = "G_TYPE_IS_ABSTRACT")]
		public bool is_abstract ();
		[CCode (cname = "G_TYPE_IS_CLASSED")]
		public bool is_classed ();
		[CCode (cname = "G_TYPE_IS_DERIVABLE")]
		public bool is_derivable ();
		[CCode (cname = "G_TYPE_IS_DEEP_DERIVABLE")]
		public bool is_deep_derivable ();
		[CCode (cname = "G_TYPE_IS_DERIVED")]
		public bool is_derived ();
		[CCode (cname = "G_TYPE_IS_FUNDAMENTAL")]
		public bool is_fundamental ();
		[CCode (cname = "G_TYPE_IS_INSTANTIATABLE")]
		public bool is_instantiatable ();
		[CCode (cname = "G_TYPE_IS_INTERFACE")]
		public bool is_interface ();
		[CCode (cname = "G_TYPE_IS_VALUE_TYPE")]
		public bool is_value_type ();
524
		
525 526 527 528 529 530 531 532
		//public ref Type[] children (ref uint n_children = null);
		public uint depth ();
		public static Type from_name (string! name);
		//public ref Type[] interfaces (ref uint n_interfaces = null);
		public bool is_a (Type is_a_type);
		public string! name ();
		public Type parent ();
				
533
		public ref TypeClass class_ref ();
534
		
535 536 537 538 539 540
	}
	
	[ReferenceType ()]
	public struct TypeClass {
		
	}
541 542 543 544 545 546 547 548 549 550

	public interface TypePlugin {
	}

	public class TypeModule : TypePlugin {
		public bool use ();
		public void unuse ();
		public void set_name (string! name);
	}

551 552 553 554 555 556
	[ReferenceType ()]
	public struct ParamSpec {
	}
	
	[ReferenceType ()]
	public struct ObjectClass {
557
		public ref ParamSpec[] list_properties (ref int n_properties);
558 559 560 561 562
	}
	
	public struct ObjectConstructParam {
	}

563
	[CCode (cheader_filename = "glib-object.h")]
564
	public class Object {
565 566
		[CCode (cname = "G_TYPE_FROM_INSTANCE")]
		public Type get_type ();
567 568 569
		public Object @ref ();
		public void unref ();
		public Object ref_sink ();
570
	}
571
	
572
	public class InitiallyUnowned : Object {
573
	}
574 575 576 577 578 579

	public /* static */ interface Boxed<G> {
		public abstract G copy ();
		public abstract void free ();
	}

580 581
	[ReferenceType (free_function = "g_free")]
	public struct Value {
582
		public weak Object get_object ();
583 584
	}
	
585 586 587 588 589 590
	public struct SignalInvocationHint {
		public uint signal_id;
		public Quark detail;
		public SignalFlags run_type;
	}
	
591
	[NoArrayLength ()]
592 593 594 595 596 597 598 599 600 601 602 603
	public callback bool SignalEmissionHook (SignalInvocationHint ihint, uint n_param_values, Value[] param_values, pointer data);
	
	[CCode (cprefix = "G_SIGNAL_")]
	public enum SignalFlags {
		RUN_FIRST,
		RUN_LAST,
		RUN_CLEANUP,
		DETAILED,
		ACTION,
		NO_HOOKS
	}
	
604 605 606 607 608
	public callback void Callback ();
	
	public struct Closure {
	}
	
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
	public struct ValueArray {
	}

	[CCode (cheader_filename = "math.h")]
	public struct Math {
		[CCode (cname = "sqrt")]
		public static double sqrt (double v);
		
		[CCode (cname = "G_E")]
		public static double E;
		
		[CCode (cname = "G_PI")]
		public static double PI;
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
624 625
	/* The Main Event Loop */
	
626 627
	[ReferenceType (dup_function = "g_main_loop_ref", free_function = "g_main_loop_unref")]
	public struct MainLoop {
628
		public MainLoop (MainContext context, bool is_running);
629 630 631
		public void run ();
		public void quit ();
		public bool is_running ();
632
		public weak MainContext get_context ();
633 634
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
635 636 637 638 639 640 641 642
	public enum Priority {
		HIGH,
		DEFAULT,
		HIGH_IDLE,
		DEFAULT_IDLE,
		LOW
	}
	
643 644
	[ReferenceType (dup_function = "g_main_context_ref", free_function = "g_main_context_unref")]
	public struct MainContext {
645
		public MainContext ();
646
		public static weak MainContext @default ();
647 648
		public bool iteration (bool may_block);
		public bool pending ();
649 650 651
		public weak Source find_source_by_id (uint source_id);
		public weak Source find_source_by_user_data (pointer user_data);
		public weak Source find_source_by_funcs_user_data (SourceFuncs funcs, pointer user_data);
652 653 654 655
		public void wakeup ();
		public bool acquire ();
		public void release ();
		public bool is_owner ();
Jürg Billeter's avatar
Jürg Billeter committed
656 657 658 659 660 661 662 663 664 665 666
		public bool wait (Cond cond, Mutex mutex);
		public bool prepare (ref int priority);
		[NoArrayLength ()]
		public int query (int max_priority, ref int timeout_, PollFD[] fds, int n_fds);
		public int check (int max_priority, PollFD[] fds, int n_fds);
		public void dispatch ();
		public void set_poll_func (PollFunc func);
		public PollFunc get_poll_func ();
		public void add_poll (ref PollFD fd, int priority);
		public void remove_poll (ref PollFD fd);
		public int depth ();
667
		public weak Source current_source ();
668 669
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
670 671 672
	public callback int PollFunc (PollFD[] ufds, uint nfsd, int timeout_);
	
	public struct TimeoutSource : Source {
673
		public TimeoutSource (uint interval);
Jürg Billeter's avatar
Jürg Billeter committed
674 675
	}

676 677
	public struct Timeout {
		public static uint add (uint interval, SourceFunc function, pointer data);
Jürg Billeter's avatar
Jürg Billeter committed
678
		public static uint add_full (int priority, uint interval, SourceFunc function, pointer data, DestroyNotify notify);
679 680
	}
	
681
	[ReferenceType ()]
Jürg Billeter's avatar
Jürg Billeter committed
682
	public struct IdleSource : Source {
683
		public IdleSource ();
Jürg Billeter's avatar
Jürg Billeter committed
684 685 686
	}

	public struct Idle {
687
		public static uint add (SourceFunc function, pointer data);
Jürg Billeter's avatar
Jürg Billeter committed
688 689
		public static uint add_full (int priority, SourceFunc function, pointer data, DestroyNotify notify);
		public static bool remove_by_data (pointer data);
690 691
	}
	
692 693 694
	public struct Pid {
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
695 696 697 698
	public callback void ChildWatchFunc (Pid pid, int status, pointer data);
	
	[ReferenceType ()]
	public struct ChildWatchSource : Source {
699
		public ChildWatchSource (Pid pid, int status, pointer data);
Jürg Billeter's avatar
Jürg Billeter committed
700 701 702 703 704 705 706 707
	}
	
	public struct ChildWatch {
		public static uint add (Pid pid, ChildWatchFunc function, pointer data);
		public static uint add_full (int priority, Pid pid, ChildWatchFunc function, pointer data, DestroyNotify notify);
	}
	
	public struct PollFD {
Jürg Billeter's avatar
Jürg Billeter committed
708 709 710
		public int fd;
		public IOCondition events;
		public IOCondition revents;
Jürg Billeter's avatar
Jürg Billeter committed
711 712
	}
	
713 714
	[ReferenceType (dup_function = "g_source_ref", free_function = "g_source_unref")]
	public struct Source {
715
		public Source (SourceFuncs source_funcs);
Jürg Billeter's avatar
Jürg Billeter committed
716
		public void set_funcs (SourceFuncs funcs);
717
		public uint attach (MainContext context);
Jürg Billeter's avatar
Jürg Billeter committed
718 719 720 721 722 723 724
		public void destroy ();
		public bool is_destroyed ();
		public void set_priority (int priority);
		public int get_priority ();
		public void set_can_recurse (bool can_recurse);
		public bool get_can_recurse ();
		public uint get_id ();
725
		public weak MainContext get_context ();
726
		public void set_callback (SourceFunc func, pointer data, DestroyNotify notify);
Jürg Billeter's avatar
Jürg Billeter committed
727 728 729 730
		public void set_callback_indirect (pointer callback_data, SourceCallbackFuncs callback_funcs);
		public void add_poll (ref PollFD fd);
		public void remove_poll (ref PollFD fd);
		public void get_current_time (ref TimeVal timeval);
731
		public static void remove (uint id);
Jürg Billeter's avatar
Jürg Billeter committed
732 733
		public static bool remove_by_funcs_user_data (pointer user_data);
		public static bool remove_by_user_data (pointer user_data);
734 735
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
736 737
	public callback void SourceDummyMarshal ();
	
738 739 740 741 742 743 744 745 746 747 748 749 750
	public callback bool SourcePrepareFunc (Source source, ref int timeout_);
	public callback bool SourceCheckFunc (Source source);
	public callback bool SourceDispatchFunc (Source source, SourceFunc _callback, pointer user_data);
	public callback void SourceFinalizeFunc (Source source);
	
	[ReferenceType ()]
	public struct SourceFuncs {
		public SourcePrepareFunc prepare;
		public SourceCheckFunc check;
		public SourceDispatchFunc dispatch;
		public SourceFinalizeFunc finalize;
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
751 752 753 754 755 756 757 758 759 760 761
	public callback void SourceCallbackRefFunc (pointer cb_data);
	public callback void SourceCallbackUnrefFunc (pointer cb_data);
	public callback void SourceCallbackGetFunc (pointer cb_data, Source source, SourceFunc func, pointer data);
	
	[ReferenceType ()]
	public struct SourceCallbackFuncs {
		public SourceCallbackRefFunc @ref;
		public SourceCallbackUnrefFunc unref;
		public SourceCallbackGetFunc @get;
	}
	
762 763
	public callback bool SourceFunc (pointer data);
	
764
	/* Thread support */
765 766 767 768
	[ReferenceType ()]
	public struct ThreadFunctions {
	}
	
769 770 771 772 773 774 775 776 777 778
	public callback pointer ThreadFunc (pointer data);
	public callback void Func (pointer data, pointer user_data);
	
	public enum ThreadPriority {
		LOW,
		NORMAL,
		HIGH,
		URGENT
	}
	
779 780
	[ReferenceType ()]
	public struct Thread {
781
		public static void init (ThreadFunctions vtable = null);
782
		public static bool supported ();
783 784 785
		public static weak Thread create (ThreadFunc func, pointer data, bool joinable, out Error error);
		public static weak Thread create_full (ThreadFunc func, pointer data, ulong stack_size, bool joinable, bool bound, ThreadPriority priority, out Error error);
		public static weak Thread self ();
786 787 788 789 790
		public pointer join ();
		public void set_priority (ThreadPriority priority);
		public static void yield ();
		public static void exit (pointer retval);
		public static void @foreach (Func thread_func, pointer user_data);
791 792 793
		
		[CCode (cname = "g_usleep")]
		public static void usleep (ulong microseconds);
794 795
	}
	
796 797
	[ReferenceType (free_function = "g_mutex_free")]
	public struct Mutex {
798
		public Mutex ();
799 800 801 802 803 804 805
		public void @lock ();
		public bool try_lock ();
		public void unlock ();
	}
	
	[ReferenceType (free_function = "g_cond_free")]
	public struct Cond {
806
		public Cond ();
807 808 809 810 811 812
		public void @signal ();
		public void broadcast ();
		public void wait (Mutex mutex);
		public bool timed_wait (Mutex mutex, TimeVal abs_time);
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
813 814 815 816
	/* Thread Pools */
	
	[ReferenceType (free_function = "g_thread_pool_free")]
	public struct ThreadPool {
817
		public ThreadPool (Func func, pointer user_data, int max_threads, bool exclusive, out Error error);
Jürg Billeter's avatar
Jürg Billeter committed
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835
		public void push (pointer data, out Error error);
		public void set_max_threads (int max_threads, out Error error);
		public int get_max_threads ();
		public uint get_num_threads ();
		public uint unprocessed ();
		public static void set_max_unused_threads (int max_threads);
		public static int get_max_unused_threads ();
		public static uint get_num_unused_threads ();
		public static void stop_unused_threads ();
		public void set_sort_function (CompareDataFunc func, pointer user_data);
		public static void set_max_idle_time (uint interval);
		public static uint get_max_idle_time ();
	}
	
	/* Asynchronous Queues */
	
	[ReferenceType (dup_function = "g_async_queue_ref", free_function = "g_async_queue_unref")]
	public struct AsyncQueue {
836
		public AsyncQueue ();
Jürg Billeter's avatar
Jürg Billeter committed
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864
		public void push (pointer data);
		public void push_sorted (pointer data, CompareDataFunc func, pointer user_data);
		public pointer pop ();
		public pointer try_pop ();
		public pointer timed_pop (ref TimeVal end_time);
		public int length ();
		public void sort (CompareDataFunc func, pointer user_data);
		public void @lock ();
		public void unlock ();
		public void ref_unlocked ();
		public void unref_and_unlock ();
		public void push_unlocked (pointer data);
		public void push_sorted_unlocked (pointer data, CompareDataFunc func, pointer user_data);
		public pointer pop_unlocked ();
		public pointer try_pop_unlocked ();
		public pointer timed_pop_unlocked (ref TimeVal end_time);
		public int length_unlocked ();
		public void sort_unlocked (CompareDataFunc func, pointer user_data);
	}
	
	/* Dynamic Loading of Modules */
	
	[ReferenceType (free_function = "g_module_close")]
	public struct Module {
		public static bool supported ();
		public static ref string build_path (string directory, string module_name);
		public static ref Module open (string file_name, ModuleFlags @flags);
		public bool symbol (string! symbol_name, ref pointer symbol);
865
		public weak string name ();
Jürg Billeter's avatar
Jürg Billeter committed
866
		public void make_resident ();
867
		public weak string error ();
Jürg Billeter's avatar
Jürg Billeter committed
868 869 870 871 872 873 874 875 876 877 878 879
	}
	
	[CCode (cprefix = "G_MODULE_")]
	public enum ModuleFlags {
		BIND_LAZY,
		BIND_LOCAL,
		BIND_MASK
	}
	
	/* Memory Allocation */
	
	public static pointer malloc (ulong n_bytes);
880
	public static pointer malloc0 (ulong n_bytes);
Jürg Billeter's avatar
Jürg Billeter committed
881 882 883 884 885
	public static pointer realloc (pointer mem, ulong n_bytes);

	public static pointer try_malloc (ulong n_bytes);
	public static pointer try_malloc0 (ulong n_bytes);
	public static pointer try_realloc (pointer mem, ulong n_bytes);
886
	
Jürg Billeter's avatar
Jürg Billeter committed
887 888 889 890 891
	public static void free (pointer mem);
	
	/* IO Channels */
	
	[ReferenceType (dup_function = "g_io_channel_ref", free_function = "g_io_channel_unref")]
892
	public struct IOChannel {
893
		public IOChannel.file (string! filename, string! mode, out Error error);
Jürg Billeter's avatar
Jürg Billeter committed
894 895 896 897 898 899 900 901 902 903
		public IOStatus read_chars (string! buf, ulong count, ref ulong bytes_read, out Error error);
		public IOStatus read_unichar (ref unichar thechar, out Error error);
		public IOStatus read_line (out string str_return, ref ulong length, ref ulong terminator_pos, out Error error);
		public IOStatus read_line_string (String! buffer, ref ulong terminator_pos, out Error error);
		public IOStatus read_to_end (out string str_return, ref ulong length, out Error error);
		public IOStatus write_chars (string! buf, long count, ref ulong bytes_written, out Error error);
		public IOStatus write_unichar (unichar thechar, out Error error);
		public IOStatus flush (out Error error);
		public IOStatus seek_position (int64 offset, SeekType type, out Error error);
		public IOStatus shutdown (bool flush, out Error error);
904
	}
Jürg Billeter's avatar
Jürg Billeter committed
905 906 907 908 909 910 911 912 913 914 915

	[CCode (cprefix = "G_IO_")]
	public enum IOCondition {
		IN,
		OUT,
		PRI,
		ERR,
		HUP,
		NVAL
	}

Jürg Billeter's avatar
Jürg Billeter committed
916 917 918 919 920 921 922 923 924 925 926 927 928 929 930
	[CCode (cprefix = "G_SEEK_")]
	public enum SeekType {
		CUR,
		SET,
		END
	}
	
	public enum IOStatus {
		ERROR,
		NORMAL,
		EOF,
		AGAIN
	}
	
	/* Error Reporting */
931

932
	[ReferenceType (dup_function = "g_error_copy", free_function = "g_error_free")]
933
	public struct Error {
934
		public Error (Quark domain, int code, string! format, ...);
935 936
		public int code;
		public string message;
937 938
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
939 940
	/* Message Output and Debugging Functions */
	
941
	public static void return_if_fail (bool expr);
942 943
	public static void assert (bool expr);
	public static void assert_not_reached ();
944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976

	/* Message Logging */
	
	[CCode (cprefix = "G_LOG_")]
	public enum LogLevelFlags {
		/* log flags */
		FLAG_RECURSION,
		FLAG_FATAL,

		/* GLib log levels */
		LEVEL_ERROR,
		LEVEL_CRITICAL,
		LEVEL_WARNING,
		LEVEL_MESSAGE,
		LEVEL_INFO,
		LEVEL_DEBUG,

		LEVEL_MASK
	}
	
	[Diagnostics ()]
	public void log (string log_domain, LogLevelFlags log_level, string format, ...);
	
	[Diagnostics ()]
	public void message (string format, ...);
	[Diagnostics ()]
	public void warning (string format, ...);
	[Diagnostics ()]
	public void critical (string format, ...);
	[Diagnostics ()]
	public void error (string format, ...);
	[Diagnostics ()]
	public void debug (string format, ...);
977
	
Jürg Billeter's avatar
Jürg Billeter committed
978 979
	/* Character Set Conversions */
	
980 981
	public static ref string convert (string! str, long len, string! to_codeset, string! from_codeset, ref int bytes_read, ref int bytes_written, out Error error);
	
982 983 984 985 986 987
	public struct Filename {
		public static ref string from_uri (string! uri, out string hostname = null, out Error error = null);
		public static ref string to_uri (string! filename, string hostname = null, out Error error = null);
		public static ref string display_basename (string! filename);
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
988 989
	/* Base64 Encoding */
	
990 991 992 993 994 995 996 997
	public struct Base64 {
		public static int encode_step (string! _in, int len, bool break_lines, string _out, ref int state, ref int save);
		public static int encode_close (bool break_lines, string _out, ref int state, ref int save);
		public static ref string encode (string! data, int len);
		public static int decode_step (string! _in, int len, ref int state, ref uint save);
		public static ref string decode (string! text, ref ulong out_len);
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
998 999
	/* Date and Time Functions */
	
1000
	[ReferenceType (free_function = "g_free")]
1001
	public struct TimeVal {
1002 1003 1004 1005 1006
		[CCode (cname = "g_get_current_time")]
		public void get_current_time ();
		public void add (long microseconds);
		[InstanceLast ()]
		public bool from_iso8601 (string iso_date);
1007
		public ref string to_iso8601 ();
1008
		
1009 1010
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
1011 1012 1013 1014
	/* Random Numbers */
	
	[ReferenceType (dup_function = "g_rand_copy", free_function = "g_rand_free")]
	public struct Rand {
1015
		public Rand.with_seed (uint32 seed);
Jürg Billeter's avatar
Jürg Billeter committed
1016
		[NoArrayLength ()]
1017 1018
		public Rand.with_seed_array (uint32[] seed, uint seed_length);
		public Rand ();
Jürg Billeter's avatar
Jürg Billeter committed
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
		public void set_seed (uint32 seed);
		[NoArrayLength ()]
		public void set_seed_array (uint32[] seed, uint seed_length);
		public bool boolean ();
		public uint32 @int ();
		public int32 int_range (int32 begin, int32 end);
		public double @double ();
		public double double_range (double begin, double end);
	}
	
	public struct Random {
		public static void set_seed (uint32 seed);
		public static bool boolean ();
		public static uint32 @int ();
		public static int32 int_range (int32 begin, int32 end);
		public static double @double ();
		public static double double_range (double begin, double end);
	}
	
	/* Miscellaneous Utility Functions */
	
1040 1041
	public struct Environment {
		[CCode (cname = "g_get_application_name")]
1042
		public static weak string get_application_name ();
1043 1044
		[CCode (cname = "g_set_application_name")]
		public static void set_application_name (string application_name);
1045
		[CCode (cname = "g_getenv")]
1046
		public static weak string get_variable (string! variable);
1047 1048
		[CCode (cname = "g_setenv")]
		public static bool set_variable (string! variable, string! value, bool overwrite);
1049
		[CCode (cname = "g_get_user_name")]
1050
		public static weak string get_user_name ();
1051
		[CCode (cname = "g_get_host_name")]
1052
		public static weak string! get_host_name ();
1053
		[CCode (cname = "g_get_home_dir")]
1054
		public static weak string get_home_dir ();
1055 1056
		[CCode (cname = "g_get_current_dir")]
		public static ref string get_current_dir ();
1057 1058
	}
	
1059
	public struct Path {
1060
		public static bool is_absolute (string! file_name);
1061
		public static weak string skip_root (string! file_name);
1062
		public static ref string get_basename (string file_name);
1063
		public static ref string get_dirname (string file_name);
1064 1065 1066
		[CCode (cname = "g_build_filename")]
		public static ref string build_filename (string first_element, ...);
	}
1067

1068 1069 1070 1071 1072 1073
	public static class Bit {
		public static int nth_lsf (ulong mask, int nth_bit);
		public static int nth_msf (ulong mask, int nth_bit);
		public static uint storage (ulong number);
	}

1074 1075 1076 1077
	public static class SpacedPrimes {
		public static uint closest (uint num);
	}

Jürg Billeter's avatar
Jürg Billeter committed
1078 1079
	/* Lexical Scanner */
	
1080 1081 1082 1083
	[ReferenceType (free_function = "g_scanner_destroy")]
	public struct Scanner {
	}
	
Jürg Billeter's avatar
Jürg Billeter committed
1084 1085
	/* Spawning Processes */
	
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109
	public enum SpawnError {
		FORK,
		READ,
		CHDIR,
		ACCES,
		PERM,
		TOOBIG,
		NOEXEC,
		NAMETOOLONG,
		NOENT,
		NOMEM,
		NOTDIR,
		LOOP,
		TXTBUSY,
		IO,
		NFILE,
		MFILE,
		INVAL,
		ISDIR,
		LIBBAD,
		FAILED
	}
	
	[CCode (cprefix = "G_SPAWN_")]
1110
	public enum SpawnFlags {
1111 1112 1113 1114 1115 1116 1117
		LEAVE_DESCRIPTOR_OPEN,
		DO_NOT_REAP_CHILD,
		SEARCH_PATH,
		STDOUT_TO_DEV_NULL,
		STDERR_TO_DEV_NULL,
		CHILS_INHERITS_STDIN,
		FILE_AND_ARGV_ZERO
1118 1119 1120
	}
	
	public callback void SpawnChildSetupFunc (pointer user_data);
1121
	
1122
	[CCode (cprefix = "g_")]
1123
	public struct Process {
1124
		[NoArrayLength ()]
1125
		public static bool spawn_async_with_pipes (string working_directory, string[] argv, string[] envp, SpawnFlags _flags, SpawnChildSetupFunc child_setup, pointer user_data, Pid child_pid, ref int standard_input, ref int standard_output, ref int standard_error, out Error error);
1126
		[NoArrayLength ()]
1127
		public static bool spawn_async (string working_directory, string[] argv, string[] envp, SpawnFlags _flags, SpawnChildSetupFunc child_setup, pointer user_data, Pid child_pid, out Error error);
1128
		[NoArrayLength ()]
1129 1130 1131 1132 1133
		public static bool spawn_sync (string working_directory, string[] argv, string[] envp, SpawnFlags _flags, SpawnChildSetupFunc child_setup, pointer user_data, out string standard_output, out string standard_error, ref int exit_status, out Error error);
		public static bool spawn_command_line_async (string! command_line, out Error error);
		public static bool spawn_command_line_sync (string! command_line, out string standard_output, out string standard_error, ref int exit_status, out Error error);
		public static void close_pid (Pid pid);
	}
Jürg Billeter's avatar
Jürg Billeter committed
1134 1135
	
	/* File Utilities */
1136

1137 1138 1139 1140 1141 1142 1143 1144
	public enum FileTest {
		IS_REGULAR,
		IS_SYMLINK,
		IS_DIR,
		IS_EXECUTABLE,
		EXISTS
	}
	
1145
	[ReferenceType (free_function = "fclose")]
1146
	[CCode (cname = "FILE", cheader_filename = "stdio.h,glib/gstdio.h")]
1147
	public struct File {
1148
		[CCode (cname = "fopen")]
1149
		public static ref File open (string path, string mode);
1150 1151
		[CCode (cname = "fdopen")]
		public static ref File fdopen (int fildes, string mode);
1152
		[CCode (cname = "fprintf")]
1153
		[PrintfFormat ()]
1154
		public void printf (string format, ...);
1155 1156 1157 1158 1159 1160 1161 1162
		[InstanceLast ()]
		[CCode (cname = "fputc")]
		public void putc (char c);
		[InstanceLast ()]
		[CCode (cname = "fputs")]
		public void puts (string s);
		[CCode (cname = "fclose")]
		public void close ();
1163
		
1164 1165
		public static bool get_contents (string! filename, out string contents, ref long length, out Error error);
		public static bool set_contents (string! filename, string contents, long length, out Error error);
1166
		public static bool test (string filename, FileTest test);
1167
		public static int open_tmp (string tmpl, out string name_used, out Error error);
1168
		public static ref string read_link (string filename, out Error error);
1169 1170 1171 1172 1173
		
		[CCode (cname = "g_rename")]
		public static int rename (string oldfilename, string newfilename);
		[CCode (cname = "g_unlink")]
		public static int unlink (string filename);
1174 1175 1176
		
		[CCode (cname = "symlink")]
		public static int symlink (string! oldpath, string! newpath);
1177 1178
	}
	
1179 1180 1181
	[ReferenceType (free_function = "g_dir_close")]
	public struct Dir {
		public static ref Dir open (string filename, uint _flags, out Error error);
1182
		public weak string read_name ();
1183 1184 1185 1186 1187 1188 1189
		
		[CCode (cname = "g_mkdir")]
		public static int create (string pathname, int mode);
		[CCode (cname = "g_mkdir_with_parents")]
		public static int create_with_parents (string pathname, int mode);
	}
	
1190
	[ReferenceType (free_function = "g_mapped_file_free")]
1191
	public struct MappedFile {
1192
		public MappedFile (string filename, bool writable, out Error error);
1193 1194
		public void free ();
		public long get_length ();
1195
		public weak char[] get_contents ();
1196 1197 1198 1199 1200 1201
	}
	
	[ReferenceType ()]
	[CCode (cname = "char", cheader_filename = "string.h")]
	public struct Memory {
		[CCode (cname = "memcmp")]
1202
		[NoArrayLength ()]
1203
		public static int cmp (char[] s1, char[] s2, long n);
1204 1205
	}
	
1206 1207 1208
	[CCode (cname = "stdout", cheader_filename = "stdio.h")]
	public static File stdout;
	
1209
	[CCode (cname = "stderr", cheader_filename = "stdio.h")]
1210
	public static File stderr;
1211

Jürg Billeter's avatar
Jürg Billeter committed
1212 1213
	/* Commandline option parser */

1214
	[ReferenceType (free_function = "g_option_context_free")]
1215
	public struct OptionContext {