Jari Aalto | b72432f | 1999-02-19 17:11:39 +0000 | [diff] [blame] | 1 | /* template - example template for loadable builtin */ |
| 2 | |
| 3 | /* See Makefile for compilation details. */ |
| 4 | |
| 5 | #include <config.h> |
| 6 | |
| 7 | #if defined (HAVE_UNISTD_H) |
| 8 | # include <unistd.h> |
| 9 | #endif |
| 10 | #include "bashansi.h" |
| 11 | #include <stdio.h> |
| 12 | #include <errno.h> |
| 13 | |
| 14 | #include "builtins.h" |
| 15 | #include "shell.h" |
| 16 | #include "bashgetopt.h" |
| 17 | |
| 18 | #if !defined (errno) |
Ricardo Cerqueira | a02fbff | 2013-07-25 22:35:34 +0100 | [diff] [blame] | 19 | #include <errno.h> |
Jari Aalto | b72432f | 1999-02-19 17:11:39 +0000 | [diff] [blame] | 20 | #endif |
| 21 | |
| 22 | extern char *strerror (); |
| 23 | |
| 24 | template_builtin (list) |
| 25 | WORD_LIST *list; |
| 26 | { |
| 27 | int opt, rval; |
| 28 | |
| 29 | rval = EXECUTION_SUCCESS; |
| 30 | reset_internal_getopt (); |
| 31 | while ((opt = internal_getopt (list, "")) != -1) |
| 32 | { |
| 33 | switch (opt) |
| 34 | { |
| 35 | default: |
| 36 | builtin_usage (); |
| 37 | return (EX_USAGE); |
| 38 | } |
| 39 | } |
| 40 | list = loptend; |
| 41 | |
| 42 | return (rval); |
| 43 | } |
| 44 | |
| 45 | char *template_doc[] = { |
Jari Aalto | 3185942 | 2009-01-12 13:36:28 +0000 | [diff] [blame] | 46 | "Short description.", |
| 47 | "" |
| 48 | "Longer description of builtin and usage.", |
Jari Aalto | b72432f | 1999-02-19 17:11:39 +0000 | [diff] [blame] | 49 | (char *)NULL |
| 50 | }; |
| 51 | |
| 52 | struct builtin template_struct = { |
| 53 | "template", /* builtin name */ |
| 54 | template_builtin, /* function implementing the builtin */ |
| 55 | BUILTIN_ENABLED, /* initial flags for builtin */ |
| 56 | template_doc, /* array of long documentation strings. */ |
| 57 | "template", /* usage synopsis; becomes short_doc */ |
| 58 | 0 /* reserved for internal use */ |
| 59 | }; |