From: Dr. Michael Lauer Date: Tue, 6 Mar 2018 14:04:27 +0000 (+0100) Subject: posix: Add wordexp(3), wordexp_t, and assorted constants X-Git-Tag: 0.40.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1464eb4c1463b44b856cd1650a9d95d9d7228556;p=thirdparty%2Fvala.git posix: Add wordexp(3), wordexp_t, and assorted constants Based on a patch by Andre Masella. https://bugzilla.gnome.org/show_bug.cgi?id=663633 --- diff --git a/vapi/posix.vapi b/vapi/posix.vapi index 7e4d7a0ac..155e70429 100644 --- a/vapi/posix.vapi +++ b/vapi/posix.vapi @@ -2949,4 +2949,46 @@ namespace Posix { public static int opterr; [CCode (cheader_filename = "unistd.h")] public static int optopt; + + [CCode(cname = "wordexp_t", cheader_filename = "wordexp.h", destroy_function = "wordfree")] + public struct Wordexp { + [CCode(cname = "we_wordv", array_length_cname = "we_wordc", array_length_type = "size_t")] + public string[] words; + + [CCode(cname = "wordexp", instance_pos = 1.1)] + private int _wordexp (string s, int flags = 0); + [CCode(cname = "wordfree")] + private int _wordfree (); + + public int expand (string s, int flags = 0) { + if (!(WRDE_APPEND in flags || WRDE_REUSE in flags)) { + _wordfree(); + } + return _wordexp (s, flags); + } + public int append(string s, int flags = 0) { + return _wordexp (s, flags | WRDE_APPEND); + } + } + + [CCode(cheader_filename = "wordexp.h")] + private const int WRDE_APPEND; + [CCode(cheader_filename = "wordexp.h")] + public const int WRDE_BADCHAR; + [CCode(cheader_filename = "wordexp.h")] + public const int WRDE_BADVAL; + [CCode(cheader_filename = "wordexp.h")] + public const int WRDE_CMDSUB; + [CCode(cheader_filename = "wordexp.h")] + public const int WRDE_NOCMD; + [CCode(cheader_filename = "wordexp.h")] + public const int WRDE_NOSPACE; + [CCode(cheader_filename = "wordexp.h")] + public const int WRDE_REUSE; + [CCode(cheader_filename = "wordexp.h")] + public const int WRDE_SHOWERR; + [CCode(cheader_filename = "wordexp.h")] + public const int WRDE_SYNTAX; + [CCode(cheader_filename = "wordexp.h")] + public const int WRDE_UNDEF; }