summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-03-11 09:35:07 +0700
committerHarald Welte <laforge@gnumonks.org>2016-03-11 22:05:25 +0700
commitc28f4cdd6d4d9155e431775baf5e897f0a388ad3 (patch)
tree30a2b49019b0539dee02a02fd468082880ca6a31 /src
parent1cc66f093f2ecd85b3dfb9ba411c45102cc1ac65 (diff)
sim: Add osim_file_find_{fid,sfid}() functions
We don't always want to look-up by name, but the latter is the only implemented 'find' function so far. Let's change that.
Diffstat (limited to 'src')
-rw-r--r--src/sim/core.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/sim/core.c b/src/sim/core.c
index 890df667..ddddc7dc 100644
--- a/src/sim/core.c
+++ b/src/sim/core.c
@@ -183,6 +183,31 @@ osim_file_find_name(struct osim_file_desc *parent, const char *name)
return NULL;
}
+struct osim_file_desc *
+osim_file_find_fid(struct osim_file_desc *parent, uint16_t fid)
+{
+ struct osim_file_desc *ofd;
+ llist_for_each_entry(ofd, &parent->child_list, list) {
+ if (ofd->fid == fid) {
+ return ofd;
+ }
+ }
+ return NULL;
+}
+
+struct osim_file_desc *
+osim_file_find_sfid(struct osim_file_desc *parent, uint8_t sfid)
+{
+ struct osim_file_desc *ofd;
+ llist_for_each_entry(ofd, &parent->child_list, list) {
+ if (ofd->sfid == sfid) {
+ return ofd;
+ }
+ }
+ return NULL;
+}
+
+
/*! \brief Generate an APDU message and initialize APDU command header
* \param[in] cla CLASS byte
* \param[in] ins INSTRUCTION byte