]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
posix: Add wordexp(3), wordexp_t, and assorted constants
authorDr. Michael Lauer <mickey@vanille-media.de>
Tue, 6 Mar 2018 14:04:27 +0000 (15:04 +0100)
committerDr. Michael Lauer <mickey@vanille-media.de>
Tue, 6 Mar 2018 14:04:27 +0000 (15:04 +0100)
Based on a patch by Andre Masella.

https://bugzilla.gnome.org/show_bug.cgi?id=663633

vapi/posix.vapi

index 7e4d7a0ac427e391a7b1a58a94df32350c9b14d8..155e704296ac8fe3ff7030a20a3a5e0845ceb207 100644 (file)
@@ -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;
 }