]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vapi: Add gnu.vapi with binding for getopt_long() and some other GNU APIs
authorReuben Thomas <rrt@sc3d.org>
Tue, 10 Nov 2020 18:22:08 +0000 (18:22 +0000)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 2 Dec 2020 07:51:55 +0000 (08:51 +0100)
vapi/Makefile.am
vapi/gnu.deps [new file with mode: 0644]
vapi/gnu.vapi [new file with mode: 0644]

index 06ddf3db16a53de5dc7d99ec46e2e97bca3dd60c..0f1bb0a3dcc2bce87f52bdb56c43e802d3bc8a07 100644 (file)
@@ -86,6 +86,8 @@ dist_vapi_DATA = \
        gnome-desktop-3.0.deps \
        gnome-desktop-3.0.vapi \
        gnome-vfs-2.0.vapi \
+       gnu.deps \
+       gnu.vapi \
        gnutls.vapi \
        gobject-2.0.deps \
        gobject-2.0.vapi \
diff --git a/vapi/gnu.deps b/vapi/gnu.deps
new file mode 100644 (file)
index 0000000..b3188f7
--- /dev/null
@@ -0,0 +1 @@
+posix
diff --git a/vapi/gnu.vapi b/vapi/gnu.vapi
new file mode 100644 (file)
index 0000000..5da463e
--- /dev/null
@@ -0,0 +1,61 @@
+/* gnu.vapi
+ *
+ * Copyright (C) 2020 Reuben Thomas
+ *
+ * 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.1 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:
+ *     Reuben Thomas <rrt@sc3d.org>
+ */
+
+[CCode (cprefix = "", lower_case_cprefix = "")]
+namespace Gnu {
+       /**
+        * Provides the values for the 'has_arg' field of 'GetoptOption'.
+        */
+       [CCode (cname = "int", cprefix = "", cheader_filename = "getopt.h", has_type_id = false)]
+       public enum GetoptArgument {
+               [CCode (cname = "no_argument")]
+               NONE,
+               [CCode (cname = "required_argument")]
+               REQUIRED,
+               [CCode (cname = "optional_argument")]
+               OPTIONAL
+       }
+
+       [CCode (cname = "struct option", cheader_filename = "getopt.h", has_type_id = false)]
+       public struct GetoptOption {
+               public unowned string name;
+               public int has_arg;
+               public int *flag;
+               public int val;
+       }
+
+       [CCode (cheader_filename = "getopt.h")]
+       public int getopt_long ([CCode (array_length_pos = 0.1)] string[] args, string shortopts, [CCode (array_length = false, array_null_terminated = true)] GetoptOption[] longopts, out int longind);
+       [CCode (cheader_filename = "getopt.h")]
+       public int getopt_long_only ([CCode (array_length_pos = 0.1)] string[] args, string shortopts, [CCode (array_length = false, array_null_terminated = true)] GetoptOption[] longopts, out int longind);
+
+
+       [CCode (cheader_filename = "string.h", feature_test_macro = "_GNU_SOURCE")]
+       public string memmem (string haystack, size_t haystack_len, string needle, size_t needle_len);
+
+       [CCode (cheader_filename = "error.h")]
+       [PrintfFormat]
+       public void error (int status, int errnum, string format, ...);
+
+       [CCode (cheader_filename = "quote.h")]
+       public string quote (string arg);
+}