summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dirent.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/dirent.c b/src/dirent.c
index 0fa3156..b918a0d 100644
--- a/src/dirent.c
+++ b/src/dirent.c
@@ -17,6 +17,7 @@
* along with opkg-opk. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "defs.h"
@@ -89,3 +90,32 @@ opkg_opk_dirent_name_prefix(struct opkg_opk_dirent *dirent, char *name_buf,
pref_buf[pref_len] = '\0';
return OPKG_OPK_OK;
}
+
+int
+main()
+{
+ struct opkg_opk_dirent foo = {
+ .name = "foo",
+ .parent = NULL,
+ };
+ struct opkg_opk_dirent bar = {
+ .name = "bar",
+ .parent = &foo,
+ };
+ struct opkg_opk_dirent baz = {
+ .name = "baz",
+ .parent = &bar,
+ };
+ char name[8];
+ char pref[5];
+
+ if (opkg_opk_dirent_name_prefix(&baz, name, 8, pref, 5) != OPKG_OPK_OK)
+ {
+ puts("Error building name parts");
+ return EXIT_FAILURE;
+ }
+ puts(name);
+ puts(pref);
+
+ return EXIT_SUCCESS;
+}