diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-08 17:52:17 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-08 17:52:17 +0000 |
commit | 7e84e539de530b2060f0e570fc8f063ed0aaad2f (patch) | |
tree | c03518f2059504a513119cf4d499ccf5c7233f83 /docs/new-applet-HOWTO.txt | |
parent | 92c0b8222eb50dd35c06e2f1265706b388762234 (diff) | |
download | busybox-w32-7e84e539de530b2060f0e570fc8f063ed0aaad2f.tar.gz busybox-w32-7e84e539de530b2060f0e570fc8f063ed0aaad2f.tar.bz2 busybox-w32-7e84e539de530b2060f0e570fc8f063ed0aaad2f.zip |
cryptpw: new applet (a bit less than 3k added)
(by Thomas Lundquist <lists@zelow.no>)
Diffstat (limited to 'docs/new-applet-HOWTO.txt')
-rw-r--r-- | docs/new-applet-HOWTO.txt | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/docs/new-applet-HOWTO.txt b/docs/new-applet-HOWTO.txt index b1e103572..5d8fbe78a 100644 --- a/docs/new-applet-HOWTO.txt +++ b/docs/new-applet-HOWTO.txt | |||
@@ -6,7 +6,10 @@ This document details the steps you must take to add a new applet to BusyBox. | |||
6 | Credits: | 6 | Credits: |
7 | Matt Kraai - initial writeup | 7 | Matt Kraai - initial writeup |
8 | Mark Whitley - the remix | 8 | Mark Whitley - the remix |
9 | Thomas Lundquist - Added stuff for the new directory layout. | 9 | Thomas Lundquist - Trying to keep it updated. |
10 | |||
11 | When doing this you should consider using the latest svn trunk. | ||
12 | This is a good thing if you plan to getting it commited into mainline. | ||
10 | 13 | ||
11 | Initial Write | 14 | Initial Write |
12 | ------------- | 15 | ------------- |
@@ -21,6 +24,10 @@ the bb_config.h and appropriate platform specific files are included properly. | |||
21 | 24 | ||
22 | For a new applet mu, here is the code that would go in mu.c: | 25 | For a new applet mu, here is the code that would go in mu.c: |
23 | 26 | ||
27 | (busybox.h already includes most usual header files. You do not need | ||
28 | #include <stdio.h> etc...) | ||
29 | |||
30 | |||
24 | ----begin example code------ | 31 | ----begin example code------ |
25 | 32 | ||
26 | /* vi: set sw=4 ts=4: */ | 33 | /* vi: set sw=4 ts=4: */ |
@@ -33,7 +40,7 @@ For a new applet mu, here is the code that would go in mu.c: | |||
33 | */ | 40 | */ |
34 | 41 | ||
35 | #include "busybox.h" | 42 | #include "busybox.h" |
36 | #include <other.h> | 43 | #include "other.h" |
37 | 44 | ||
38 | int mu_main(int argc, char **argv); | 45 | int mu_main(int argc, char **argv); |
39 | int mu_main(int argc, char **argv) | 46 | int mu_main(int argc, char **argv) |
@@ -69,6 +76,38 @@ useful functions in libbb. Use these instead of reinventing the wheel. | |||
69 | Additionally, if you have any useful, general-purpose functions in your | 76 | Additionally, if you have any useful, general-purpose functions in your |
70 | applet that could be useful in other applets, consider putting them in libbb. | 77 | applet that could be useful in other applets, consider putting them in libbb. |
71 | 78 | ||
79 | And it may be possible that some of the other applets uses functions you | ||
80 | could use. If so, you have to rip the function out of the applet and make | ||
81 | a libbb function out of it. | ||
82 | |||
83 | Adding a libbb function: | ||
84 | ------------------------ | ||
85 | |||
86 | Make a new file named <function_name>.c | ||
87 | |||
88 | ----start example code------ | ||
89 | |||
90 | #include "libbb.h" | ||
91 | #include "other.h" | ||
92 | |||
93 | int function(char *a) | ||
94 | { | ||
95 | return *a; | ||
96 | } | ||
97 | |||
98 | ----end example code------ | ||
99 | |||
100 | Add <function_name>.o in the right alphabetically sorted place | ||
101 | in libbb/Kbuild. You should look at the conditional part of | ||
102 | libbb/Kbuild aswell. | ||
103 | |||
104 | You should also try to find a suitable place in include/libbb.h for | ||
105 | the function declaration. If not, add it somewhere anyway, with or without | ||
106 | ifdefs to include or not. | ||
107 | |||
108 | You can look at libbb/Config.in and try to find out if the function is | ||
109 | tuneable and add it there if it is. | ||
110 | |||
72 | 111 | ||
73 | Placement / Directory | 112 | Placement / Directory |
74 | --------------------- | 113 | --------------------- |
@@ -78,9 +117,9 @@ Find the appropriate directory for your new applet. | |||
78 | Make sure you find the appropriate places in the files, the applets are | 117 | Make sure you find the appropriate places in the files, the applets are |
79 | sorted alphabetically. | 118 | sorted alphabetically. |
80 | 119 | ||
81 | Add the applet to Makefile.in in the chosen directory: | 120 | Add the applet to Kbuild in the chosen directory: |
82 | 121 | ||
83 | obj-$(CONFIG_MU) += mu.o | 122 | lib-$(CONFIG_MU) += mu.o |
84 | 123 | ||
85 | Add the applet to Config.in in the chosen directory: | 124 | Add the applet to Config.in in the chosen directory: |
86 | 125 | ||
@@ -119,31 +158,22 @@ Next, add an entry to include/applets.h. Be *sure* to keep the list | |||
119 | in alphabetical order, or else it will break the binary-search lookup | 158 | in alphabetical order, or else it will break the binary-search lookup |
120 | algorithm in busybox.c and the Gods of BusyBox smite you. Yea, verily: | 159 | algorithm in busybox.c and the Gods of BusyBox smite you. Yea, verily: |
121 | 160 | ||
161 | Be sure to read the top of applets.h before adding your applet. | ||
162 | |||
122 | /* all programs above here are alphabetically "less than" 'mu' */ | 163 | /* all programs above here are alphabetically "less than" 'mu' */ |
123 | #ifdef CONFIG_MU | 164 | USE_MU(APPLET(mu, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
124 | APPLET("mu", mu_main, _BB_DIR_USR_BIN, mu_usage) | ||
125 | #endif | ||
126 | /* all programs below here are alphabetically "greater than" 'mu' */ | 165 | /* all programs below here are alphabetically "greater than" 'mu' */ |
127 | 166 | ||
128 | 167 | ||
129 | Documentation | ||
130 | ------------- | ||
131 | |||
132 | If you're feeling especially nice, you should also document your applet in the | ||
133 | docs directory (but nobody ever does that). | ||
134 | |||
135 | Adding some text to docs/Configure.help is a nice start. | ||
136 | |||
137 | |||
138 | The Grand Announcement | 168 | The Grand Announcement |
139 | ---------------------- | 169 | ---------------------- |
140 | 170 | ||
141 | Then create a diff -urN of the files you added and/or modified. Typically: | 171 | Then create a diff by adding the new files with svn (remember your libbb files) |
142 | <appletdir>/<applet>.c | 172 | svn add <where you put it>/mu.c |
143 | include/usage.c | 173 | eventually also: |
144 | include/applets.h | 174 | svn add libbb/function.c |
145 | <appletdir>/Makefile.in | 175 | then |
146 | <appletdir>/config.in | 176 | svn diff |
147 | and send it to the mailing list: | 177 | and send it to the mailing list: |
148 | busybox@busybox.net | 178 | busybox@busybox.net |
149 | http://busybox.net/mailman/listinfo/busybox | 179 | http://busybox.net/mailman/listinfo/busybox |