]>
Commit | Line | Data |
---|---|---|
b72432fd JA |
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 | ||
a0c0a00f | 14 | #include "loadables.h" |
b72432fd JA |
15 | |
16 | #if !defined (errno) | |
17 | extern int errno; | |
18 | #endif | |
19 | ||
20 | extern char *strerror (); | |
21 | ||
a0c0a00f | 22 | int |
b72432fd JA |
23 | template_builtin (list) |
24 | WORD_LIST *list; | |
25 | { | |
26 | int opt, rval; | |
27 | ||
28 | rval = EXECUTION_SUCCESS; | |
29 | reset_internal_getopt (); | |
30 | while ((opt = internal_getopt (list, "")) != -1) | |
31 | { | |
32 | switch (opt) | |
33 | { | |
9a51695b | 34 | CASE_HELPOPT; |
b72432fd JA |
35 | default: |
36 | builtin_usage (); | |
37 | return (EX_USAGE); | |
38 | } | |
39 | } | |
40 | list = loptend; | |
41 | ||
42 | return (rval); | |
43 | } | |
44 | ||
a0c0a00f CR |
45 | /* Called when `template' is enabled and loaded from the shared object. If this |
46 | function returns 0, the load fails. */ | |
47 | int | |
48 | template_builtin_load (name) | |
49 | char *name; | |
50 | { | |
51 | return (1); | |
52 | } | |
53 | ||
54 | /* Called when `template' is disabled. */ | |
55 | void | |
56 | template_builtin_unload (name) | |
57 | char *name; | |
58 | { | |
59 | } | |
60 | ||
b72432fd | 61 | char *template_doc[] = { |
3185942a JA |
62 | "Short description.", |
63 | "" | |
64 | "Longer description of builtin and usage.", | |
b72432fd JA |
65 | (char *)NULL |
66 | }; | |
67 | ||
68 | struct builtin template_struct = { | |
69 | "template", /* builtin name */ | |
70 | template_builtin, /* function implementing the builtin */ | |
71 | BUILTIN_ENABLED, /* initial flags for builtin */ | |
72 | template_doc, /* array of long documentation strings. */ | |
73 | "template", /* usage synopsis; becomes short_doc */ | |
74 | 0 /* reserved for internal use */ | |
75 | }; |