Change in libosmocore[master]: osmo-sim-test: Recurse through subdirectories

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sat Feb 15 18:00:27 UTC 2020


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/17153 )


Change subject: osmo-sim-test: Recurse through subdirectories
......................................................................

osmo-sim-test: Recurse through subdirectories

Don't just iterate over all files in the current working
directory (cwd), but also recurse through all sub-directories.

Change-Id: I737b01d9a845e37d8be9d4709ef0de04e749daec
---
M utils/osmo-sim-test.c
1 file changed, 39 insertions(+), 13 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/53/17153/1

diff --git a/utils/osmo-sim-test.c b/utils/osmo-sim-test.c
index cd98397..ea3ce2a 100644
--- a/utils/osmo-sim-test.c
+++ b/utils/osmo-sim-test.c
@@ -374,6 +374,44 @@
 	}
 }
 
+
+static void iterate_fs(struct osim_chan_hdl *chan)
+{
+	const struct osim_file_desc *prev_cwd;
+	struct osim_file_desc *ofd;
+
+	/* iterate over all files in current working directory */
+	llist_for_each_entry(ofd, &chan->cwd->child_list, list) {
+		struct msgb *m;
+		printf("\n\n================ %s (%s) ==================\n",
+			ofd->short_name, ofd->long_name);
+
+		m = select_file(chan, ofd->fid);
+		if (msgb_apdu_sw(m) != 0x9000) {
+			msgb_free(m);
+			continue;
+		}
+		dump_fcp_template_msg(m);
+		msgb_free(m);
+
+		/* If this is a DF, recurse into it */
+		switch (ofd->type) {
+		case TYPE_DF:
+			/* the select above has just changed into this directory */
+			prev_cwd = chan->cwd;
+			chan->cwd = ofd;
+			iterate_fs(chan);
+			/* "pop" the directory from the stack */
+			chan->cwd = prev_cwd;
+			break;
+		default:
+			dump_file(chan, ofd->fid);
+			break;
+		}
+	}
+}
+
+
 int main(int argc, char **argv)
 {
 	struct osim_reader_hdl *reader;
@@ -410,19 +448,7 @@
 	dump_fcp_template_msg(msg);
 	msgb_free(msg);
 
-	{
-		struct osim_file_desc *ofd;
-		llist_for_each_entry(ofd, &chan->cwd->child_list, list) {
-			struct msgb *m;
-			printf("\n\n================ %s (%s) ==================\n",
-				ofd->short_name, ofd->long_name);
-
-			m = select_file(chan, ofd->fid);
-			dump_fcp_template_msg(m);
-			msgb_free(m);
-			dump_file(chan, ofd->fid);
-		}
-	}
+	iterate_fs(chan);
 
 	exit(0);
 }

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/17153
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I737b01d9a845e37d8be9d4709ef0de04e749daec
Gerrit-Change-Number: 17153
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200215/410fe363/attachment.htm>


More information about the gerrit-log mailing list