aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/ifupdown_design.txt2
-rw-r--r--docs/new-applet-HOWTO.txt104
2 files changed, 65 insertions, 41 deletions
diff --git a/docs/ifupdown_design.txt b/docs/ifupdown_design.txt
index 8ab4e51ad..39e28a9f4 100644
--- a/docs/ifupdown_design.txt
+++ b/docs/ifupdown_design.txt
@@ -21,7 +21,7 @@ static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
21#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP 21#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
22 int i ; 22 int i ;
23 for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) { 23 for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
24 if (exists_execable(ext_dhcp_clients[i].name)) 24 if (executable_exists(ext_dhcp_clients[i].name))
25 return execute(ext_dhcp_clients[i].stopcmd, ifd, exec); 25 return execute(ext_dhcp_clients[i].stopcmd, ifd, exec);
26 } 26 }
27 bb_error_msg("no dhcp clients found, using static interface shutdown"); 27 bb_error_msg("no dhcp clients found, using static interface shutdown");
diff --git a/docs/new-applet-HOWTO.txt b/docs/new-applet-HOWTO.txt
index 6a8054d0e..078e77bce 100644
--- a/docs/new-applet-HOWTO.txt
+++ b/docs/new-applet-HOWTO.txt
@@ -6,7 +6,7 @@ This document details the steps you must take to add a new applet to BusyBox.
6Credits: 6Credits:
7Matt Kraai - initial writeup 7Matt Kraai - initial writeup
8Mark Whitley - the remix 8Mark Whitley - the remix
9Thomas Lundquist - Trying to keep it updated. 9Thomas Lundquist - trying to keep it updated
10 10
11When doing this you should consider using the latest git HEAD. 11When doing this you should consider using the latest git HEAD.
12This is a good thing if you plan to getting it committed into mainline. 12This is a good thing if you plan to getting it committed into mainline.
@@ -16,14 +16,14 @@ Initial Write
16 16
17First, write your applet. Be sure to include copyright information at the top, 17First, write your applet. Be sure to include copyright information at the top,
18such as who you stole the code from and so forth. Also include the mini-GPL 18such as who you stole the code from and so forth. Also include the mini-GPL
19boilerplate. Be sure to name the main function <applet>_main instead of main. 19boilerplate and Config.in/Kbuild/usage/applet.h snippets (more on that below
20And be sure to put it in <applet>.c. Usage does not have to be taken care of by 20in this document). Be sure to name the main function <applet>_main instead
21your applet. 21of main. And be sure to put it in <applet>.c. Make sure to #include "libbb.h"
22Make sure to #include "libbb.h" as the first include file in your applet. 22as the first include file in your applet.
23 23
24For a new applet mu, here is the code that would go in mu.c: 24For a new applet mu, here is the code that would go in mu.c:
25 25
26(busybox.h already includes most usual header files. You do not need 26(libbb.h already includes most usual header files. You do not need
27#include <stdio.h> etc...) 27#include <stdio.h> etc...)
28 28
29 29
@@ -41,6 +41,22 @@ For a new applet mu, here is the code that would go in mu.c:
41#include "libbb.h" 41#include "libbb.h"
42#include "other.h" 42#include "other.h"
43 43
44//config:config MU
45//config: bool "MU"
46//config: default y
47//config: help
48//config: Returns an indeterminate value.
49
50//kbuild:lib-$(CONFIG_MU) += mu.o
51//applet:IF_MU(APPLET(mu, BB_DIR_USR_BIN, BB_SUID_DROP))
52
53//usage:#define mu_trivial_usage
54//usage: "[-abcde] FILE..."
55//usage:#define mu_full_usage
56//usage: "Returns an indeterminate value\n"
57//usage: "\n -a First function"
58//usage: "\n -b Second function"
59
44int mu_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 60int mu_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
45int mu_main(int argc, char **argv) 61int mu_main(int argc, char **argv)
46{ 62{
@@ -90,6 +106,8 @@ Make a new file named <function_name>.c
90#include "libbb.h" 106#include "libbb.h"
91#include "other.h" 107#include "other.h"
92 108
109//kbuild:lib-y += function.o
110
93int function(char *a) 111int function(char *a)
94{ 112{
95 return *a; 113 return *a;
@@ -97,9 +115,7 @@ int function(char *a)
97 115
98----end example code------ 116----end example code------
99 117
100Add <function_name>.o in the right alphabetically sorted place 118Remember about the kbuild snippet.
101in libbb/Kbuild.src. You should look at the conditional part of
102libbb/Kbuild.src as well.
103 119
104You should also try to find a suitable place in include/libbb.h for 120You should also try to find a suitable place in include/libbb.h for
105the function declaration. If not, add it somewhere anyway, with or without 121the function declaration. If not, add it somewhere anyway, with or without
@@ -109,60 +125,68 @@ You can look at libbb/Config.src and try to find out if the function is
109tunable and add it there if it is. 125tunable and add it there if it is.
110 126
111 127
128Kbuild/Config.in/usage/applets.h snippets in .c files
129-----------------------------------------------------
130
131The old way of adding new applets was to put all the information needed by the
132configuration and build system into appropriate files (namely: Kbuild.src and
133Config.src in new applet's directory) and to add the applet declaration and
134usage info text to include/applets.src.h and include/usage.src.h respectively.
135
136Since the scripts/gen_build_files.sh script had been introduced, the preferred
137way is to have all these declarations contained within the applet .c files.
138
139Every line intended to be processed by gen_build_files.sh should start as a
140comment without any preceding whitespaces and be followed by an appropriate
141keyword - kbuild, config, usage or applet - and a colon, just like shown in the
142first example above.
143
144
112Placement / Directory 145Placement / Directory
113--------------------- 146---------------------
114 147
115Find the appropriate directory for your new applet. 148Find the appropriate directory for your new applet.
116 149
117Make sure you find the appropriate places in the files, the applets are 150Add the kbuild snippet to the .c file:
118sorted alphabetically.
119 151
120Add the applet to Kbuild.src in the chosen directory: 152//kbuild:lib-$(CONFIG_MU) += mu.o
121 153
122lib-$(CONFIG_MU) += mu.o 154Add the config snippet to the .c file:
123 155
124Add the applet to Config.src in the chosen directory: 156//config:config MU
125 157//config: bool "MU"
126config MU 158//config: default y
127 bool "MU" 159//config: help
128 default n 160//config: Returns an indeterminate value.
129 help
130 Returns an indeterminate value.
131 161
132 162
133Usage String(s) 163Usage String(s)
134--------------- 164---------------
135 165
136Next, add usage information for you applet to include/usage.src.h. 166Next, add usage information for your applet to the .c file.
137This should look like the following: 167This should look like the following:
138 168
139 #define mu_trivial_usage \ 169//usage:#define mu_trivial_usage
140 "-[abcde] FILES" 170//usage: "[-abcde] FILE..."
141 #define mu_full_usage \ 171//usage:#define mu_full_usage
142 "Returns an indeterminate value.\n\n" \ 172//usage: "Returns an indeterminate value\n"
143 "Options:\n" \ 173//usage: "\n -a First function"
144 "\t-a\t\tfirst function\n" \ 174//usage: "\n -b Second function"
145 "\t-b\t\tsecond function\n" \ 175//usage: ...
146 ...
147 176
148If your program supports flags, the flags should be mentioned on the first 177If your program supports flags, the flags should be mentioned on the first
149line (-[abcde]) and a detailed description of each flag should go in the 178line ([-abcde]) and a detailed description of each flag should go in the
150mu_full_usage section, one flag per line. (Numerous examples of this 179mu_full_usage section, one flag per line.
151currently exist in usage.src.h.)
152 180
153 181
154Header Files 182Header Files
155------------ 183------------
156 184
157Next, add an entry to include/applets.src.h. Be *sure* to keep the list 185Finally add the applet declaration snippet. Be sure to read the top of
158in alphabetical order, or else it will break the binary-search lookup 186applets.src.h before adding your applet - it contains important info
159algorithm in busybox.c and the Gods of BusyBox smite you. Yea, verily: 187on applet macros and conventions.
160
161Be sure to read the top of applets.src.h before adding your applet.
162 188
163 /* all programs above here are alphabetically "less than" 'mu' */ 189//applet:IF_MU(APPLET(mu, BB_DIR_USR_BIN, BB_SUID_DROP))
164 IF_MU(APPLET(mu, BB_DIR_USR_BIN, BB_SUID_DROP))
165 /* all programs below here are alphabetically "greater than" 'mu' */
166 190
167 191
168The Grand Announcement 192The Grand Announcement