summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-05-10 06:00:54 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-05-10 06:00:54 (EDT)
commit6b474997b57dafb81577dadd54ea5c3948346d9c (patch)
treee4b85a0e0254d64c3d412f7ee353d1d76acac096
parent19e086419645edd449bde992081b8ca82893ff51 (diff)
dirent: Re-add and update test code
This reverts commit 50f9ee989f89fd47a5f554d9967e8abedd6bd938.
-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;
+}