summaryrefslogtreecommitdiffstats
path: root/examples/loadables/template.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:38:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:38:56 +0000
commit6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321 (patch)
treef63ce19d57fad3ac4a15bc26dbfbfa2b834111b5 /examples/loadables/template.c
parentInitial commit. (diff)
downloadbash-6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321.tar.xz
bash-6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321.zip
Adding upstream version 5.2.15.upstream/5.2.15upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'examples/loadables/template.c')
-rw-r--r--examples/loadables/template.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/examples/loadables/template.c b/examples/loadables/template.c
new file mode 100644
index 0000000..094b80c
--- /dev/null
+++ b/examples/loadables/template.c
@@ -0,0 +1,75 @@
+/* template - example template for loadable builtin */
+
+/* See Makefile for compilation details. */
+
+#include <config.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+#include "bashansi.h"
+#include <stdio.h>
+#include <errno.h>
+
+#include "loadables.h"
+
+#if !defined (errno)
+extern int errno;
+#endif
+
+extern char *strerror ();
+
+int
+template_builtin (list)
+ WORD_LIST *list;
+{
+ int opt, rval;
+
+ rval = EXECUTION_SUCCESS;
+ reset_internal_getopt ();
+ while ((opt = internal_getopt (list, "")) != -1)
+ {
+ switch (opt)
+ {
+ CASE_HELPOPT;
+ default:
+ builtin_usage ();
+ return (EX_USAGE);
+ }
+ }
+ list = loptend;
+
+ return (rval);
+}
+
+/* Called when `template' is enabled and loaded from the shared object. If this
+ function returns 0, the load fails. */
+int
+template_builtin_load (name)
+ char *name;
+{
+ return (1);
+}
+
+/* Called when `template' is disabled. */
+void
+template_builtin_unload (name)
+ char *name;
+{
+}
+
+char *template_doc[] = {
+ "Short description.",
+ ""
+ "Longer description of builtin and usage.",
+ (char *)NULL
+};
+
+struct builtin template_struct = {
+ "template", /* builtin name */
+ template_builtin, /* function implementing the builtin */
+ BUILTIN_ENABLED, /* initial flags for builtin */
+ template_doc, /* array of long documentation strings. */
+ "template", /* usage synopsis; becomes short_doc */
+ 0 /* reserved for internal use */
+};