summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorJesper Jensen <jesper@jnsn.dev>2026-10-09 07:56:25 +0200
committerJesper Jensen <jesper@jnsn.dev>2026-10-09 07:56:25 +0200
commit0dacf7988513117da9b0935e658f9eca3ead09f7 (patch)
tree95b2b7a35bd73dfe62755986749a872c253cd663 /src/main.c
parenta436773a9f69182b799d88f75eb3cbe14d5d37a1 (diff)
downloadlibrm-main.tar.gz
librm-main.zip
Get it working against the serverHEADmain
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index bf833b9..a2e4dba 100644
--- a/src/main.c
+++ b/src/main.c
@@ -128,11 +128,15 @@ int main(int argc, char **argv) {
}
}
- if(device.deviceToken == NULL && code[0] == 0) {
- FATAL("--code is required when enrolling the device the first time");
+ if(device.deviceToken == NULL) {
+ if(code[0] == 0) {
+ FATAL("--code is required when enrolling the device the first time");
+ }
+
+ rm_device_enroll(&device, code);
}
- rm_device_open(&device, code);
+ rm_device_open(&device);
{
fseek(runtime_file, 0, SEEK_SET);
@@ -160,8 +164,24 @@ int main(int argc, char **argv) {
FATAL("fsync failed");
}
}
+ enum ReturnCode rc = RC_SUCCESS;
- struct SizedBlock body = {0};
- transport_request(GET_ROOT_URL, HTTP_GET, NULL, NULL, &body);
- TRACE("Body fetched: %ld bytes", strlen(body.memory));
+ TRACE("ROOT %.*s", 64, device.root);
+
+ struct RMDir rootDir = {};
+ rc = rm_dir_root(&device, &rootDir);
+ if(rc != RC_SUCCESS) {
+ FATAL("dir open failed");
+ }
+
+ struct RMDEntry dentry = {};
+ while((rc = rm_dir_read(&rootDir, &dentry)) == RC_NEXT) {
+ TRACE("Entry %s Subs %d Type %s", dentry.id, dentry.n, dentry.type);
+ struct RMStat stat = {};
+ rm_stat(&dentry, &stat);
+ TRACE("Name %s", stat.name);
+ }
+ if(rc != RC_SUCCESS) {
+ FATAL("dir open failed");
+ }
}